mirror of
https://github.com/standardnotes/server
synced 2026-04-25 00:01:47 -04:00
Compare commits
201 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f911473be9 | |||
| 71624f1897 | |||
| 17de6ea7e1 | |||
| 6aad7cd207 | |||
| 63af335877 | |||
| 8cd7a138ab | |||
| f69cdc7b03 | |||
| 2ca649cf31 | |||
| f2ada08201 | |||
| 54ba1f69e5 | |||
| f13a99f5fd | |||
| e9bba6fd3a | |||
| f0d1a70c87 | |||
| 56f0aef21d | |||
| 75e266cb9e | |||
| b9bb83c0ce | |||
| da645c5ab3 | |||
| 318af5757d | |||
| b1cc156a25 | |||
| 79d71ca161 | |||
| cedd50b366 | |||
| 0d5dcdd8ec | |||
| d2b0fb144b | |||
| 053852b46c | |||
| 6ad349d379 | |||
| f7d33c7164 | |||
| b53b67328f | |||
| 573ffbfcf3 | |||
| 501ac0e99f | |||
| 959a11293a | |||
| fee1f1a3a7 | |||
| b0fbe0bb58 | |||
| 0087c70007 | |||
| 36e496dd7c | |||
| f2e2030e85 | |||
| 0c3737dc19 | |||
| f7471119e1 | |||
| 9bd97b95e9 | |||
| b7400c198f | |||
| f87036e3a8 | |||
| a43e5ef724 | |||
| 913ced70b0 | |||
| 6ffce30a36 | |||
| f5a57d886c | |||
| e8ba49ecca | |||
| c79a5dc94b | |||
| 4db83ae678 | |||
| 84ceb7ffd2 | |||
| e215ac4343 | |||
| bc8048790f | |||
| 886ccf84c1 | |||
| c067cb9fe4 | |||
| 6b2389cdc3 | |||
| d93916b159 | |||
| c34f548e45 | |||
| 6fcd56cc86 | |||
| 8f88a87c93 | |||
| f8c2f84322 | |||
| 46c4947871 | |||
| 64759ec2da | |||
| 5f7e768e64 | |||
| 4bc189f1c5 | |||
| 71721ab198 | |||
| 5536a48966 | |||
| f77e29d3c9 | |||
| 4b1fc718a2 | |||
| 1708c3f8a0 | |||
| 352e02028d | |||
| 1bbb639c83 | |||
| c14265f103 | |||
| c030a6b3d8 | |||
| af997ea658 | |||
| efa4d7fc60 | |||
| f714aaa0e9 | |||
| aee6e60583 | |||
| 4e602687d5 | |||
| d026152ac8 | |||
| 3f21a358d2 | |||
| dc55e47c98 | |||
| 3b804e2321 | |||
| b32f851a90 | |||
| 479d20e76f | |||
| fae4553fc8 | |||
| cb74b23e45 | |||
| af8f12c33a | |||
| a148c4d1f6 | |||
| f7190c0c9c | |||
| c00d7765a9 | |||
| 2b651d86e2 | |||
| 9be3517093 | |||
| fcfedaf7e7 | |||
| 0b82794e9c | |||
| 2a52e398cb | |||
| c31e882ad2 | |||
| 2f0903e0eb | |||
| 2396053bc1 | |||
| 17fd12305e | |||
| 425ea4374d | |||
| c076c3c74a | |||
| 547cdfd8ec | |||
| a0af8f0025 | |||
| c970b1ea68 | |||
| 4d1e2dec26 | |||
| 108408a944 | |||
| 18d07d431f | |||
| cbc024f67a | |||
| 55ec5970da | |||
| 58bdca6659 | |||
| ef49b0d3f8 | |||
| 9cb691e5ad | |||
| 04d09582d4 | |||
| 8f90dc172b | |||
| f759261919 | |||
| 2606f6d929 | |||
| c288e5d8dc | |||
| 4b76d4b71e | |||
| 72310130d2 | |||
| f9e51ef06e | |||
| 92a5eb0d98 | |||
| 77d2ea1a1f | |||
| 92f96ddb84 | |||
| 15a914e25e | |||
| 912a29d091 | |||
| b2c32ce70e | |||
| ed1a708c40 | |||
| e905128d45 | |||
| fd598f372a | |||
| 7a3946a9e2 | |||
| cbdd2584d0 | |||
| f3161c2712 | |||
| 148542dd5a | |||
| d2b2c339f2 | |||
| d2578c48f0 | |||
| fecfd54728 | |||
| 17e4162d3e | |||
| 742209d773 | |||
| 1fa4b7cf27 | |||
| 5dc5507039 | |||
| 3035a20b9f | |||
| 04b3bb034f | |||
| bf84be0136 | |||
| 890cf48749 | |||
| 2b3436c6ce | |||
| 4df8c3b2e5 | |||
| 25a2696c32 | |||
| 52f879f842 | |||
| 4f70fa156d | |||
| 38e77f04be | |||
| 060206ddd4 | |||
| 0bc0909386 | |||
| 667d528a8c | |||
| fa7fbe26e7 | |||
| ba422a29d0 | |||
| d220ec5bf7 | |||
| 7baf5492bc | |||
| d5a8409bb5 | |||
| f58f90667c | |||
| a388e1a802 | |||
| 8811d10a73 | |||
| c7a394cd1a | |||
| b7615a7f2e | |||
| 1ca70c1e50 | |||
| 253cbb1d0c | |||
| e38a16404c | |||
| f17a1f875c | |||
| 2237e0f5df | |||
| 0df471585f | |||
| 95aac1a7bf | |||
| c078bc958d | |||
| 49c27924ea | |||
| c9dd8e7338 | |||
| 5ef90cc75b | |||
| 063c61d96c | |||
| 0cb5e36b20 | |||
| 319bab5b34 | |||
| 90a4f2111f | |||
| 3aba202970 | |||
| c8974b7fa2 | |||
| 3654a19586 | |||
| 5f0929c1aa | |||
| c0fa83bce6 | |||
| c201ee42a0 | |||
| e6a4cc3098 | |||
| 39f2fe2ba1 | |||
| 72ce190996 | |||
| 527dd1b61b | |||
| af8feaadfe | |||
| 3164f76662 | |||
| d6e531d4b6 | |||
| af76878dad | |||
| 28cce39fe7 | |||
| a8b806af08 | |||
| fa0b0294b4 | |||
| 58ab410b0a | |||
| 51c8b20506 | |||
| 1e62a3760e | |||
| 2f569d4104 | |||
| f23e444ed0 | |||
| e6e9a32f03 | |||
| 8237df33a7 | |||
| 624b574013 |
@@ -4,6 +4,7 @@ DB_USERNAME=std_notes_user
|
|||||||
DB_PASSWORD=changeme123
|
DB_PASSWORD=changeme123
|
||||||
DB_DATABASE=standard_notes_db
|
DB_DATABASE=standard_notes_db
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
|
DB_SQLITE_DATABASE_PATH=standard_notes_db
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
REDIS_HOST=cache
|
REDIS_HOST=cache
|
||||||
AUTH_SERVER_ACCESS_TOKEN_AGE=4
|
AUTH_SERVER_ACCESS_TOKEN_AGE=4
|
||||||
|
|||||||
@@ -50,10 +50,31 @@ jobs:
|
|||||||
run: docker/is-available.sh http://localhost:3123 $(pwd)/logs
|
run: docker/is-available.sh http://localhost:3123 $(pwd)/logs
|
||||||
|
|
||||||
- name: Run E2E Test Suite
|
- name: Run E2E Test Suite
|
||||||
run: yarn dlx mocha-headless-chrome --timeout 1200000 -f http://localhost:9001/mocha/test.html
|
run: yarn dlx mocha-headless-chrome --timeout 1800000 -f http://localhost:9001/mocha/test.html
|
||||||
|
|
||||||
|
- name: Show logs on failure
|
||||||
|
if: ${{ failure() }}
|
||||||
|
run: |
|
||||||
|
echo "# Errors:"
|
||||||
|
tail -n 100 logs/*.err
|
||||||
|
echo "# Logs:"
|
||||||
|
tail -n 100 logs/*.log
|
||||||
|
|
||||||
e2e-home-server:
|
e2e-home-server:
|
||||||
name: (Home Server) E2E Test Suite
|
name: (Home Server) E2E Test Suite
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
db_type: [mysql, sqlite]
|
||||||
|
cache_type: [redis, memory]
|
||||||
|
include:
|
||||||
|
- cache_type: redis
|
||||||
|
db_type: mysql
|
||||||
|
redis_port: 6380
|
||||||
|
- cache_type: redis
|
||||||
|
db_type: sqlite
|
||||||
|
redis_port: 6381
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
services:
|
services:
|
||||||
@@ -61,6 +82,19 @@ jobs:
|
|||||||
image: standardnotes/snjs:${{ inputs.snjs_image_tag }}
|
image: standardnotes/snjs:${{ inputs.snjs_image_tag }}
|
||||||
ports:
|
ports:
|
||||||
- 9001:9001
|
- 9001:9001
|
||||||
|
cache:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- ${{ matrix.redis_port }}:6379
|
||||||
|
db:
|
||||||
|
image: mysql
|
||||||
|
ports:
|
||||||
|
- 3307:3306
|
||||||
|
env:
|
||||||
|
MYSQL_ROOT_PASSWORD: root
|
||||||
|
MYSQL_DATABASE: standardnotes_${{ matrix.cache_type }}
|
||||||
|
MYSQL_USER: standardnotes
|
||||||
|
MYSQL_PASSWORD: standardnotes
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@@ -88,11 +122,22 @@ jobs:
|
|||||||
sed -i "s/PSEUDO_KEY_PARAMS_KEY=/PSEUDO_KEY_PARAMS_KEY=$(openssl rand -hex 32)/g" packages/home-server/.env
|
sed -i "s/PSEUDO_KEY_PARAMS_KEY=/PSEUDO_KEY_PARAMS_KEY=$(openssl rand -hex 32)/g" packages/home-server/.env
|
||||||
sed -i "s/VALET_TOKEN_SECRET=/VALET_TOKEN_SECRET=$(openssl rand -hex 32)/g" packages/home-server/.env
|
sed -i "s/VALET_TOKEN_SECRET=/VALET_TOKEN_SECRET=$(openssl rand -hex 32)/g" packages/home-server/.env
|
||||||
echo "ACCESS_TOKEN_AGE=4" >> packages/home-server/.env
|
echo "ACCESS_TOKEN_AGE=4" >> packages/home-server/.env
|
||||||
echo "REFRESH_TOKEN_AGE=7" >> packages/home-server/.env
|
echo "REFRESH_TOKEN_AGE=10" >> packages/home-server/.env
|
||||||
echo "REVISIONS_FREQUENCY=5" >> packages/home-server/.env
|
echo "REVISIONS_FREQUENCY=5" >> packages/home-server/.env
|
||||||
|
echo "DB_HOST=localhost" >> packages/home-server/.env
|
||||||
|
echo "DB_PORT=3307" >> packages/home-server/.env
|
||||||
|
echo "DB_DATABASE=standardnotes_${{ matrix.cache_type }}" >> packages/home-server/.env
|
||||||
|
echo "DB_SQLITE_DATABASE_PATH=sqlite_${{ matrix.cache_type }}.db" >> packages/home-server/.env
|
||||||
|
echo "DB_USERNAME=standardnotes" >> packages/home-server/.env
|
||||||
|
echo "DB_PASSWORD=standardnotes" >> packages/home-server/.env
|
||||||
|
echo "DB_TYPE=${{ matrix.db_type }}" >> packages/home-server/.env
|
||||||
|
echo "REDIS_URL=redis://localhost:${{ matrix.redis_port }}" >> packages/home-server/.env
|
||||||
|
echo "CACHE_TYPE=${{ matrix.cache_type }}" >> packages/home-server/.env
|
||||||
|
echo "FILES_SERVER_URL=http://localhost:3123" >> packages/home-server/.env
|
||||||
|
echo "E2E_TESTING=true" >> packages/home-server/.env
|
||||||
|
|
||||||
- name: Run Server
|
- name: Run Server
|
||||||
run: nohup yarn workspace @standardnotes/home-server start &
|
run: nohup yarn workspace @standardnotes/home-server start > logs/output.log 2>&1 &
|
||||||
env:
|
env:
|
||||||
PORT: 3123
|
PORT: 3123
|
||||||
|
|
||||||
@@ -100,4 +145,8 @@ jobs:
|
|||||||
run: for i in {1..30}; do curl -s http://localhost:3123/healthcheck && break || sleep 1; done
|
run: for i in {1..30}; do curl -s http://localhost:3123/healthcheck && break || sleep 1; done
|
||||||
|
|
||||||
- name: Run E2E Test Suite
|
- name: Run E2E Test Suite
|
||||||
run: yarn dlx mocha-headless-chrome --timeout 1200000 -f http://localhost:9001/mocha/test.html?skip_paid_features=true
|
run: yarn dlx mocha-headless-chrome --timeout 1800000 -f http://localhost:9001/mocha/test.html
|
||||||
|
|
||||||
|
- name: Show logs on failure
|
||||||
|
if: ${{ failure() }}
|
||||||
|
run: tail -n 500 logs/output.log
|
||||||
|
|||||||
@@ -4560,17 +4560,16 @@ const RAW_RUNTIME_STATE =
|
|||||||
}]\
|
}]\
|
||||||
]],\
|
]],\
|
||||||
["@standardnotes/api", [\
|
["@standardnotes/api", [\
|
||||||
["npm:1.26.10", {\
|
["npm:1.26.26", {\
|
||||||
"packageLocation": "./.yarn/cache/@standardnotes-api-npm-1.26.10-f6165cafd3-3c3561aec8.zip/node_modules/@standardnotes/api/",\
|
"packageLocation": "./.yarn/cache/@standardnotes-api-npm-1.26.26-4338a5fe92-db41aedfa3.zip/node_modules/@standardnotes/api/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["@standardnotes/api", "npm:1.26.10"],\
|
["@standardnotes/api", "npm:1.26.26"],\
|
||||||
["@standardnotes/common", "workspace:packages/common"],\
|
["@standardnotes/common", "workspace:packages/common"],\
|
||||||
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
||||||
["@standardnotes/encryption", "npm:1.21.38"],\
|
["@standardnotes/models", "npm:1.46.8"],\
|
||||||
["@standardnotes/models", "npm:1.45.5"],\
|
["@standardnotes/responses", "npm:1.13.27"],\
|
||||||
["@standardnotes/responses", "npm:1.13.24"],\
|
|
||||||
["@standardnotes/security", "workspace:packages/security"],\
|
["@standardnotes/security", "workspace:packages/security"],\
|
||||||
["@standardnotes/utils", "npm:1.16.5"],\
|
["@standardnotes/utils", "npm:1.17.5"],\
|
||||||
["reflect-metadata", "npm:0.1.13"]\
|
["reflect-metadata", "npm:0.1.13"]\
|
||||||
],\
|
],\
|
||||||
"linkType": "HARD"\
|
"linkType": "HARD"\
|
||||||
@@ -4635,17 +4634,17 @@ const RAW_RUNTIME_STATE =
|
|||||||
["@newrelic/winston-enricher", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.0.1"],\
|
["@newrelic/winston-enricher", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.0.1"],\
|
||||||
["@simplewebauthn/server", "npm:7.2.0"],\
|
["@simplewebauthn/server", "npm:7.2.0"],\
|
||||||
["@simplewebauthn/typescript-types", "npm:7.0.0"],\
|
["@simplewebauthn/typescript-types", "npm:7.0.0"],\
|
||||||
["@standardnotes/api", "npm:1.26.10"],\
|
["@standardnotes/api", "npm:1.26.26"],\
|
||||||
["@standardnotes/common", "workspace:packages/common"],\
|
["@standardnotes/common", "workspace:packages/common"],\
|
||||||
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
||||||
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
||||||
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
||||||
["@standardnotes/features", "npm:1.59.5"],\
|
["@standardnotes/features", "npm:1.59.7"],\
|
||||||
["@standardnotes/predicates", "workspace:packages/predicates"],\
|
["@standardnotes/predicates", "workspace:packages/predicates"],\
|
||||||
["@standardnotes/responses", "npm:1.13.24"],\
|
["@standardnotes/responses", "npm:1.13.27"],\
|
||||||
["@standardnotes/security", "workspace:packages/security"],\
|
["@standardnotes/security", "workspace:packages/security"],\
|
||||||
["@standardnotes/settings", "workspace:packages/settings"],\
|
["@standardnotes/settings", "workspace:packages/settings"],\
|
||||||
["@standardnotes/sncrypto-common", "npm:1.13.3"],\
|
["@standardnotes/sncrypto-common", "npm:1.13.4"],\
|
||||||
["@standardnotes/sncrypto-node", "workspace:packages/sncrypto-node"],\
|
["@standardnotes/sncrypto-node", "workspace:packages/sncrypto-node"],\
|
||||||
["@standardnotes/time", "workspace:packages/time"],\
|
["@standardnotes/time", "workspace:packages/time"],\
|
||||||
["@types/bcryptjs", "npm:2.4.2"],\
|
["@types/bcryptjs", "npm:2.4.2"],\
|
||||||
@@ -4781,21 +4780,6 @@ const RAW_RUNTIME_STATE =
|
|||||||
"linkType": "SOFT"\
|
"linkType": "SOFT"\
|
||||||
}]\
|
}]\
|
||||||
]],\
|
]],\
|
||||||
["@standardnotes/encryption", [\
|
|
||||||
["npm:1.21.38", {\
|
|
||||||
"packageLocation": "./.yarn/cache/@standardnotes-encryption-npm-1.21.38-d08c3d4766-1393840523.zip/node_modules/@standardnotes/encryption/",\
|
|
||||||
"packageDependencies": [\
|
|
||||||
["@standardnotes/encryption", "npm:1.21.38"],\
|
|
||||||
["@standardnotes/common", "workspace:packages/common"],\
|
|
||||||
["@standardnotes/models", "npm:1.45.5"],\
|
|
||||||
["@standardnotes/responses", "npm:1.13.24"],\
|
|
||||||
["@standardnotes/sncrypto-common", "npm:1.13.3"],\
|
|
||||||
["@standardnotes/utils", "npm:1.16.5"],\
|
|
||||||
["reflect-metadata", "npm:0.1.13"]\
|
|
||||||
],\
|
|
||||||
"linkType": "HARD"\
|
|
||||||
}]\
|
|
||||||
]],\
|
|
||||||
["@standardnotes/event-store", [\
|
["@standardnotes/event-store", [\
|
||||||
["workspace:packages/event-store", {\
|
["workspace:packages/event-store", {\
|
||||||
"packageLocation": "./packages/event-store/",\
|
"packageLocation": "./packages/event-store/",\
|
||||||
@@ -4831,10 +4815,10 @@ const RAW_RUNTIME_STATE =
|
|||||||
}]\
|
}]\
|
||||||
]],\
|
]],\
|
||||||
["@standardnotes/features", [\
|
["@standardnotes/features", [\
|
||||||
["npm:1.59.5", {\
|
["npm:1.59.7", {\
|
||||||
"packageLocation": "./.yarn/cache/@standardnotes-features-npm-1.59.5-83c83acde9-173b1f5d52.zip/node_modules/@standardnotes/features/",\
|
"packageLocation": "./.yarn/cache/@standardnotes-features-npm-1.59.7-27c3e5296e-1632d64cc1.zip/node_modules/@standardnotes/features/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["@standardnotes/features", "npm:1.59.5"],\
|
["@standardnotes/features", "npm:1.59.7"],\
|
||||||
["@standardnotes/common", "workspace:packages/common"],\
|
["@standardnotes/common", "workspace:packages/common"],\
|
||||||
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
||||||
["@standardnotes/security", "workspace:packages/security"],\
|
["@standardnotes/security", "workspace:packages/security"],\
|
||||||
@@ -4855,7 +4839,7 @@ const RAW_RUNTIME_STATE =
|
|||||||
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
||||||
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
||||||
["@standardnotes/security", "workspace:packages/security"],\
|
["@standardnotes/security", "workspace:packages/security"],\
|
||||||
["@standardnotes/sncrypto-common", "npm:1.13.3"],\
|
["@standardnotes/sncrypto-common", "npm:1.13.4"],\
|
||||||
["@standardnotes/sncrypto-node", "workspace:packages/sncrypto-node"],\
|
["@standardnotes/sncrypto-node", "workspace:packages/sncrypto-node"],\
|
||||||
["@standardnotes/time", "workspace:packages/time"],\
|
["@standardnotes/time", "workspace:packages/time"],\
|
||||||
["@types/connect-busboy", "npm:1.0.0"],\
|
["@types/connect-busboy", "npm:1.0.0"],\
|
||||||
@@ -4935,14 +4919,16 @@ const RAW_RUNTIME_STATE =
|
|||||||
}]\
|
}]\
|
||||||
]],\
|
]],\
|
||||||
["@standardnotes/models", [\
|
["@standardnotes/models", [\
|
||||||
["npm:1.45.5", {\
|
["npm:1.46.8", {\
|
||||||
"packageLocation": "./.yarn/cache/@standardnotes-models-npm-1.45.5-29326e959c-15f26c11b2.zip/node_modules/@standardnotes/models/",\
|
"packageLocation": "./.yarn/cache/@standardnotes-models-npm-1.46.8-bc0390832e-8404340f27.zip/node_modules/@standardnotes/models/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["@standardnotes/models", "npm:1.45.5"],\
|
["@standardnotes/models", "npm:1.46.8"],\
|
||||||
["@standardnotes/common", "workspace:packages/common"],\
|
["@standardnotes/common", "workspace:packages/common"],\
|
||||||
["@standardnotes/features", "npm:1.59.5"],\
|
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
||||||
["@standardnotes/responses", "npm:1.13.24"],\
|
["@standardnotes/features", "npm:1.59.7"],\
|
||||||
["@standardnotes/utils", "npm:1.16.5"],\
|
["@standardnotes/responses", "npm:1.13.27"],\
|
||||||
|
["@standardnotes/sncrypto-common", "npm:1.13.4"],\
|
||||||
|
["@standardnotes/utils", "npm:1.17.5"],\
|
||||||
["lodash", "npm:4.17.21"]\
|
["lodash", "npm:4.17.21"]\
|
||||||
],\
|
],\
|
||||||
"linkType": "HARD"\
|
"linkType": "HARD"\
|
||||||
@@ -4967,12 +4953,12 @@ const RAW_RUNTIME_STATE =
|
|||||||
}]\
|
}]\
|
||||||
]],\
|
]],\
|
||||||
["@standardnotes/responses", [\
|
["@standardnotes/responses", [\
|
||||||
["npm:1.13.24", {\
|
["npm:1.13.27", {\
|
||||||
"packageLocation": "./.yarn/cache/@standardnotes-responses-npm-1.13.24-3b4167c7ea-3bcfee90f0.zip/node_modules/@standardnotes/responses/",\
|
"packageLocation": "./.yarn/cache/@standardnotes-responses-npm-1.13.27-829dec3e6e-9bf55e5f02.zip/node_modules/@standardnotes/responses/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["@standardnotes/responses", "npm:1.13.24"],\
|
["@standardnotes/responses", "npm:1.13.27"],\
|
||||||
["@standardnotes/common", "workspace:packages/common"],\
|
["@standardnotes/common", "workspace:packages/common"],\
|
||||||
["@standardnotes/features", "npm:1.59.5"],\
|
["@standardnotes/features", "npm:1.59.7"],\
|
||||||
["@standardnotes/security", "workspace:packages/security"],\
|
["@standardnotes/security", "workspace:packages/security"],\
|
||||||
["reflect-metadata", "npm:0.1.13"]\
|
["reflect-metadata", "npm:0.1.13"]\
|
||||||
],\
|
],\
|
||||||
@@ -4987,12 +4973,12 @@ const RAW_RUNTIME_STATE =
|
|||||||
["@aws-sdk/client-s3", "npm:3.342.0"],\
|
["@aws-sdk/client-s3", "npm:3.342.0"],\
|
||||||
["@aws-sdk/client-sqs", "npm:3.342.0"],\
|
["@aws-sdk/client-sqs", "npm:3.342.0"],\
|
||||||
["@newrelic/winston-enricher", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.0.1"],\
|
["@newrelic/winston-enricher", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.0.1"],\
|
||||||
["@standardnotes/api", "npm:1.26.10"],\
|
["@standardnotes/api", "npm:1.26.26"],\
|
||||||
["@standardnotes/common", "workspace:packages/common"],\
|
["@standardnotes/common", "workspace:packages/common"],\
|
||||||
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
||||||
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
||||||
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
||||||
["@standardnotes/responses", "npm:1.13.24"],\
|
["@standardnotes/responses", "npm:1.13.27"],\
|
||||||
["@standardnotes/security", "workspace:packages/security"],\
|
["@standardnotes/security", "workspace:packages/security"],\
|
||||||
["@standardnotes/time", "workspace:packages/time"],\
|
["@standardnotes/time", "workspace:packages/time"],\
|
||||||
["@types/cors", "npm:2.8.13"],\
|
["@types/cors", "npm:2.8.13"],\
|
||||||
@@ -5129,10 +5115,10 @@ const RAW_RUNTIME_STATE =
|
|||||||
}]\
|
}]\
|
||||||
]],\
|
]],\
|
||||||
["@standardnotes/sncrypto-common", [\
|
["@standardnotes/sncrypto-common", [\
|
||||||
["npm:1.13.3", {\
|
["npm:1.13.4", {\
|
||||||
"packageLocation": "./.yarn/cache/@standardnotes-sncrypto-common-npm-1.13.3-97ef3850ce-a73af90962.zip/node_modules/@standardnotes/sncrypto-common/",\
|
"packageLocation": "./.yarn/cache/@standardnotes-sncrypto-common-npm-1.13.4-3186513fa6-48e0e207f2.zip/node_modules/@standardnotes/sncrypto-common/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["@standardnotes/sncrypto-common", "npm:1.13.3"],\
|
["@standardnotes/sncrypto-common", "npm:1.13.4"],\
|
||||||
["reflect-metadata", "npm:0.1.13"]\
|
["reflect-metadata", "npm:0.1.13"]\
|
||||||
],\
|
],\
|
||||||
"linkType": "HARD"\
|
"linkType": "HARD"\
|
||||||
@@ -5143,7 +5129,7 @@ const RAW_RUNTIME_STATE =
|
|||||||
"packageLocation": "./packages/sncrypto-node/",\
|
"packageLocation": "./packages/sncrypto-node/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["@standardnotes/sncrypto-node", "workspace:packages/sncrypto-node"],\
|
["@standardnotes/sncrypto-node", "workspace:packages/sncrypto-node"],\
|
||||||
["@standardnotes/sncrypto-common", "npm:1.13.3"],\
|
["@standardnotes/sncrypto-common", "npm:1.13.4"],\
|
||||||
["@types/jest", "npm:29.5.2"],\
|
["@types/jest", "npm:29.5.2"],\
|
||||||
["@types/node", "npm:20.2.5"],\
|
["@types/node", "npm:20.2.5"],\
|
||||||
["@typescript-eslint/eslint-plugin", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:5.59.8"],\
|
["@typescript-eslint/eslint-plugin", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:5.59.8"],\
|
||||||
@@ -5171,14 +5157,15 @@ const RAW_RUNTIME_STATE =
|
|||||||
["@aws-sdk/client-sns", "npm:3.342.0"],\
|
["@aws-sdk/client-sns", "npm:3.342.0"],\
|
||||||
["@aws-sdk/client-sqs", "npm:3.342.0"],\
|
["@aws-sdk/client-sqs", "npm:3.342.0"],\
|
||||||
["@newrelic/winston-enricher", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.0.1"],\
|
["@newrelic/winston-enricher", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.0.1"],\
|
||||||
["@standardnotes/api", "npm:1.26.10"],\
|
["@standardnotes/api", "npm:1.26.26"],\
|
||||||
["@standardnotes/common", "workspace:packages/common"],\
|
["@standardnotes/common", "workspace:packages/common"],\
|
||||||
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
||||||
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
||||||
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
||||||
["@standardnotes/responses", "npm:1.13.24"],\
|
["@standardnotes/responses", "npm:1.13.27"],\
|
||||||
["@standardnotes/security", "workspace:packages/security"],\
|
["@standardnotes/security", "workspace:packages/security"],\
|
||||||
["@standardnotes/settings", "workspace:packages/settings"],\
|
["@standardnotes/settings", "workspace:packages/settings"],\
|
||||||
|
["@standardnotes/sncrypto-node", "workspace:packages/sncrypto-node"],\
|
||||||
["@standardnotes/time", "workspace:packages/time"],\
|
["@standardnotes/time", "workspace:packages/time"],\
|
||||||
["@types/cors", "npm:2.8.13"],\
|
["@types/cors", "npm:2.8.13"],\
|
||||||
["@types/dotenv", "npm:8.2.0"],\
|
["@types/dotenv", "npm:8.2.0"],\
|
||||||
@@ -5188,6 +5175,7 @@ const RAW_RUNTIME_STATE =
|
|||||||
["@types/newrelic", "npm:9.14.0"],\
|
["@types/newrelic", "npm:9.14.0"],\
|
||||||
["@types/node", "npm:20.2.5"],\
|
["@types/node", "npm:20.2.5"],\
|
||||||
["@types/prettyjson", "npm:0.0.30"],\
|
["@types/prettyjson", "npm:0.0.30"],\
|
||||||
|
["@types/semver", "npm:7.5.0"],\
|
||||||
["@types/ua-parser-js", "npm:0.7.36"],\
|
["@types/ua-parser-js", "npm:0.7.36"],\
|
||||||
["@types/uuid", "npm:8.3.4"],\
|
["@types/uuid", "npm:8.3.4"],\
|
||||||
["@typescript-eslint/eslint-plugin", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:5.59.8"],\
|
["@typescript-eslint/eslint-plugin", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:5.59.8"],\
|
||||||
@@ -5210,6 +5198,7 @@ const RAW_RUNTIME_STATE =
|
|||||||
["prettier", "npm:2.8.8"],\
|
["prettier", "npm:2.8.8"],\
|
||||||
["prettyjson", "npm:1.2.5"],\
|
["prettyjson", "npm:1.2.5"],\
|
||||||
["reflect-metadata", "npm:0.1.13"],\
|
["reflect-metadata", "npm:0.1.13"],\
|
||||||
|
["semver", "npm:7.5.1"],\
|
||||||
["sqlite3", "virtual:31b5a94a105c89c9294c3d524a7f8929fe63ee5a2efadf21951ca4c0cfd2ecf02e8f4ef5a066bbda091f1e3a56e57c6749069a080618c96b22e51131a330fc4a#npm:5.1.6"],\
|
["sqlite3", "virtual:31b5a94a105c89c9294c3d524a7f8929fe63ee5a2efadf21951ca4c0cfd2ecf02e8f4ef5a066bbda091f1e3a56e57c6749069a080618c96b22e51131a330fc4a#npm:5.1.6"],\
|
||||||
["ts-jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.1.0"],\
|
["ts-jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.1.0"],\
|
||||||
["typeorm", "virtual:365b8c88cdf194291829ee28b79556e2328175d26a621363e703848100bea0042e9500db2a1206c9bbc3a4a76a1d169639ef774b2ea3a1a98584a9936b58c6be#npm:0.3.16"],\
|
["typeorm", "virtual:365b8c88cdf194291829ee28b79556e2328175d26a621363e703848100bea0042e9500db2a1206c9bbc3a4a76a1d169639ef774b2ea3a1a98584a9936b58c6be#npm:0.3.16"],\
|
||||||
@@ -5244,10 +5233,10 @@ const RAW_RUNTIME_STATE =
|
|||||||
}]\
|
}]\
|
||||||
]],\
|
]],\
|
||||||
["@standardnotes/utils", [\
|
["@standardnotes/utils", [\
|
||||||
["npm:1.16.5", {\
|
["npm:1.17.5", {\
|
||||||
"packageLocation": "./.yarn/cache/@standardnotes-utils-npm-1.16.5-47f537f49f-d5caa7181f.zip/node_modules/@standardnotes/utils/",\
|
"packageLocation": "./.yarn/cache/@standardnotes-utils-npm-1.17.5-210b60222d-47e8520174.zip/node_modules/@standardnotes/utils/",\
|
||||||
"packageDependencies": [\
|
"packageDependencies": [\
|
||||||
["@standardnotes/utils", "npm:1.16.5"],\
|
["@standardnotes/utils", "npm:1.17.5"],\
|
||||||
["@standardnotes/common", "workspace:packages/common"],\
|
["@standardnotes/common", "workspace:packages/common"],\
|
||||||
["dompurify", "npm:2.4.5"],\
|
["dompurify", "npm:2.4.5"],\
|
||||||
["lodash", "npm:4.17.21"],\
|
["lodash", "npm:4.17.21"],\
|
||||||
@@ -5263,14 +5252,13 @@ const RAW_RUNTIME_STATE =
|
|||||||
["@standardnotes/websockets-server", "workspace:packages/websockets"],\
|
["@standardnotes/websockets-server", "workspace:packages/websockets"],\
|
||||||
["@aws-sdk/client-sqs", "npm:3.342.0"],\
|
["@aws-sdk/client-sqs", "npm:3.342.0"],\
|
||||||
["@newrelic/winston-enricher", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.0.1"],\
|
["@newrelic/winston-enricher", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.0.1"],\
|
||||||
["@standardnotes/api", "npm:1.26.10"],\
|
["@standardnotes/api", "npm:1.26.26"],\
|
||||||
["@standardnotes/common", "workspace:packages/common"],\
|
["@standardnotes/common", "workspace:packages/common"],\
|
||||||
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
||||||
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
||||||
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
||||||
["@standardnotes/responses", "npm:1.13.24"],\
|
["@standardnotes/responses", "npm:1.13.27"],\
|
||||||
["@standardnotes/security", "workspace:packages/security"],\
|
["@standardnotes/security", "workspace:packages/security"],\
|
||||||
["@standardnotes/utils", "npm:1.16.5"],\
|
|
||||||
["@types/cors", "npm:2.8.13"],\
|
["@types/cors", "npm:2.8.13"],\
|
||||||
["@types/express", "npm:4.17.17"],\
|
["@types/express", "npm:4.17.17"],\
|
||||||
["@types/ioredis", "npm:5.0.0"],\
|
["@types/ioredis", "npm:5.0.0"],\
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -3,6 +3,7 @@ services:
|
|||||||
image: standardnotes/server
|
image: standardnotes/server
|
||||||
env_file: .env
|
env_file: .env
|
||||||
container_name: server_self_hosted
|
container_name: server_self_hosted
|
||||||
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
- 3125:3104
|
- 3125:3104
|
||||||
|
|||||||
+3
-1
@@ -12,12 +12,14 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "yarn workspaces foreach -p -j 10 --verbose run lint",
|
"lint": "yarn workspaces foreach -p -j 10 --verbose run lint",
|
||||||
|
"lint:fix": "yarn workspaces foreach -p -j 10 --verbose run lint:fix",
|
||||||
"clean": "yarn workspaces foreach -p --verbose run clean",
|
"clean": "yarn workspaces foreach -p --verbose run clean",
|
||||||
"setup:env": "cp .env.sample .env && yarn workspaces foreach -p --verbose run setup:env",
|
"setup:env": "cp .env.sample .env && yarn workspaces foreach -p --verbose run setup:env",
|
||||||
"release": "lerna version --conventional-graduate --conventional-commits --yes -m \"chore(release): publish new version\"",
|
"release": "lerna version --conventional-graduate --conventional-commits --yes -m \"chore(release): publish new version\"",
|
||||||
"publish": "lerna publish from-git --yes --no-verify-access --loglevel verbose",
|
"publish": "lerna publish from-git --yes --no-verify-access --loglevel verbose",
|
||||||
"postversion": "./scripts/push-tags-one-by-one.sh",
|
"postversion": "./scripts/push-tags-one-by-one.sh",
|
||||||
"upgrade:snjs": "yarn workspaces foreach --verbose run upgrade:snjs"
|
"upgrade:snjs": "yarn workspaces foreach --verbose run upgrade:snjs",
|
||||||
|
"e2e": "yarn build packages/home-server && PORT=3123 yarn workspace @standardnotes/home-server start"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^17.0.2",
|
"@commitlint/cli": "^17.0.2",
|
||||||
|
|||||||
@@ -3,6 +3,78 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [2.25.7](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.25.6...@standardnotes/analytics@2.25.7) (2023-08-02)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.25.6](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.25.5...@standardnotes/analytics@2.25.6) (2023-07-27)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.25.5](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.25.4...@standardnotes/analytics@2.25.5) (2023-07-26)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.25.4](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.25.3...@standardnotes/analytics@2.25.4) (2023-07-26)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.25.3](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.25.2...@standardnotes/analytics@2.25.3) (2023-07-21)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.25.2](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.25.1...@standardnotes/analytics@2.25.2) (2023-07-21)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.25.1](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.25.0...@standardnotes/analytics@2.25.1) (2023-07-19)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
# [2.25.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.9...@standardnotes/analytics@2.25.0) (2023-07-17)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **syncing-server:** refactor syncing to decouple getting and saving items ([#659](https://github.com/standardnotes/server/issues/659)) ([cb74b23](https://github.com/standardnotes/server/commit/cb74b23e45b207136e299ce8a3db2c04dc87e21e))
|
||||||
|
|
||||||
|
## [2.24.9](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.8...@standardnotes/analytics@2.24.9) (2023-07-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.24.8](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.7...@standardnotes/analytics@2.24.8) (2023-07-07)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.24.7](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.6...@standardnotes/analytics@2.24.7) (2023-07-06)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.24.6](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.5...@standardnotes/analytics@2.24.6) (2023-07-05)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.24.5](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.4...@standardnotes/analytics@2.24.5) (2023-06-30)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.24.4](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.3...@standardnotes/analytics@2.24.4) (2023-06-30)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.24.3](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.2...@standardnotes/analytics@2.24.3) (2023-06-30)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.24.2](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.1...@standardnotes/analytics@2.24.2) (2023-06-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/analytics
|
||||||
|
|
||||||
|
## [2.24.1](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.0...@standardnotes/analytics@2.24.1) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/server/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
# [2.24.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.23.7...@standardnotes/analytics@2.24.0) (2023-06-02)
|
# [2.24.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.23.7...@standardnotes/analytics@2.24.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/analytics",
|
"name": "@standardnotes/analytics",
|
||||||
"version": "2.24.0",
|
"version": "2.25.7",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -88,9 +88,9 @@ export class ContainerConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
level: env.get('LOG_LEVEL', true) || 'info',
|
||||||
format: winston.format.combine(...winstonFormatters),
|
format: winston.format.combine(...winstonFormatters),
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||||
})
|
})
|
||||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ import { Result, Entity, UniqueEntityId } from '@standardnotes/domain-core'
|
|||||||
import { StatisticMeasureProps } from './StatisticMeasureProps'
|
import { StatisticMeasureProps } from './StatisticMeasureProps'
|
||||||
|
|
||||||
export class StatisticMeasure extends Entity<StatisticMeasureProps> {
|
export class StatisticMeasure extends Entity<StatisticMeasureProps> {
|
||||||
get id(): UniqueEntityId {
|
|
||||||
return this._id
|
|
||||||
}
|
|
||||||
|
|
||||||
get name(): string {
|
get name(): string {
|
||||||
return this.props.name.value
|
return this.props.name.value
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ import { Entity, Result, UniqueEntityId } from '@standardnotes/domain-core'
|
|||||||
import { SubscriptionProps } from './SubscriptionProps'
|
import { SubscriptionProps } from './SubscriptionProps'
|
||||||
|
|
||||||
export class Subscription extends Entity<SubscriptionProps> {
|
export class Subscription extends Entity<SubscriptionProps> {
|
||||||
get id(): UniqueEntityId {
|
|
||||||
return this._id
|
|
||||||
}
|
|
||||||
|
|
||||||
private constructor(props: SubscriptionProps, id?: UniqueEntityId) {
|
private constructor(props: SubscriptionProps, id?: UniqueEntityId) {
|
||||||
super(props, id)
|
super(props, id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ import { Entity, Result, UniqueEntityId } from '@standardnotes/domain-core'
|
|||||||
import { UserProps } from './UserProps'
|
import { UserProps } from './UserProps'
|
||||||
|
|
||||||
export class User extends Entity<UserProps> {
|
export class User extends Entity<UserProps> {
|
||||||
get id(): UniqueEntityId {
|
|
||||||
return this._id
|
|
||||||
}
|
|
||||||
|
|
||||||
private constructor(props: UserProps, id?: UniqueEntityId) {
|
private constructor(props: UserProps, id?: UniqueEntityId) {
|
||||||
super(props, id)
|
super(props, id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
MODE=microservice # microservice | home-server
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
VERSION=development
|
VERSION=development
|
||||||
|
|||||||
@@ -3,6 +3,136 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.69.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.69.1...@standardnotes/api-gateway@1.69.2) (2023-08-02)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.69.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.69.0...@standardnotes/api-gateway@1.69.1) (2023-07-31)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **api-gateway:** remove duplicating req/res objects on return raw response from payments ([79d71ca](https://github.com/standardnotes/api-gateway/commit/79d71ca161cc18135fcd1a83b021662e189b3ddb))
|
||||||
|
|
||||||
|
# [1.69.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.68.1...@standardnotes/api-gateway@1.69.0) (2023-07-31)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* refactor deleting account ([#676](https://github.com/standardnotes/api-gateway/issues/676)) ([0d5dcdd](https://github.com/standardnotes/api-gateway/commit/0d5dcdd8ec2336e41e7604c4157f79a89163ed29))
|
||||||
|
|
||||||
|
## [1.68.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.68.0...@standardnotes/api-gateway@1.68.1) (2023-07-27)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
# [1.68.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.67.4...@standardnotes/api-gateway@1.68.0) (2023-07-27)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **syncing-server:** add deleting outbound messages ([e8ba49e](https://github.com/standardnotes/api-gateway/commit/e8ba49ecca38ab10c0ea0e1f4cf4db9fb17366db))
|
||||||
|
|
||||||
|
## [1.67.4](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.67.3...@standardnotes/api-gateway@1.67.4) (2023-07-26)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.67.3](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.67.2...@standardnotes/api-gateway@1.67.3) (2023-07-26)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.67.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.67.1...@standardnotes/api-gateway@1.67.2) (2023-07-21)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.67.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.67.0...@standardnotes/api-gateway@1.67.1) (2023-07-21)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
# [1.67.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.66.1...@standardnotes/api-gateway@1.67.0) (2023-07-20)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **syncing-server:** add shared vaults, invites, messages and notifications to sync response ([#665](https://github.com/standardnotes/api-gateway/issues/665)) ([efa4d7f](https://github.com/standardnotes/api-gateway/commit/efa4d7fc6007ef668e3de3b04853ac11b2d13c30))
|
||||||
|
|
||||||
|
## [1.66.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.66.0...@standardnotes/api-gateway@1.66.1) (2023-07-19)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add missing imports and exports for controllers ([#664](https://github.com/standardnotes/api-gateway/issues/664)) ([aee6e60](https://github.com/standardnotes/api-gateway/commit/aee6e6058359e2b5231cc13387656f837699300f))
|
||||||
|
|
||||||
|
# [1.66.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.65.7...@standardnotes/api-gateway@1.66.0) (2023-07-19)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **syncing-server:** add persistence of shared vaults with users and invites + controllers ([#662](https://github.com/standardnotes/api-gateway/issues/662)) ([3f21a35](https://github.com/standardnotes/api-gateway/commit/3f21a358d24d70daf541aa62dc86cd9e29500e62))
|
||||||
|
|
||||||
|
## [1.65.7](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.65.6...@standardnotes/api-gateway@1.65.7) (2023-07-17)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.65.6](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.65.5...@standardnotes/api-gateway@1.65.6) (2023-07-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.65.5](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.65.4...@standardnotes/api-gateway@1.65.5) (2023-07-07)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.65.4](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.65.3...@standardnotes/api-gateway@1.65.4) (2023-07-06)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.65.3](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.65.2...@standardnotes/api-gateway@1.65.3) (2023-07-05)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.65.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.65.1...@standardnotes/api-gateway@1.65.2) (2023-06-30)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
## [1.65.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.65.0...@standardnotes/api-gateway@1.65.1) (2023-06-30)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/api-gateway
|
||||||
|
|
||||||
|
# [1.65.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.64.3...@standardnotes/api-gateway@1.65.0) (2023-06-30)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* shared vaults functionality in api-gateway,auth,files,common,security,domain-events. ([#629](https://github.com/standardnotes/api-gateway/issues/629)) ([fa7fbe2](https://github.com/standardnotes/api-gateway/commit/fa7fbe26e7b0707fc21d71e04af76870f5248baf))
|
||||||
|
|
||||||
|
## [1.64.3](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.64.2...@standardnotes/api-gateway@1.64.3) (2023-06-28)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add debug logs for invalid-auth responses ([d5a8409](https://github.com/standardnotes/api-gateway/commit/d5a8409bb5d35b9caf410a36ea0d5cb747129e8d))
|
||||||
|
|
||||||
|
## [1.64.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.64.1...@standardnotes/api-gateway@1.64.2) (2023-06-22)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** add debug logs about container initalizations ([0df4715](https://github.com/standardnotes/api-gateway/commit/0df471585fd5b4626ec2972f3b9a3e33b2830e65))
|
||||||
|
|
||||||
|
## [1.64.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.64.0...@standardnotes/api-gateway@1.64.1) (2023-06-09)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **api-gateway:** direct call service proxy to return 400 responses instead of throwing errors ([e6a4cc3](https://github.com/standardnotes/api-gateway/commit/e6a4cc3098bdf84fc9d48ed0d9098ebb52afb0e7))
|
||||||
|
|
||||||
|
# [1.64.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.63.2...@standardnotes/api-gateway@1.64.0) (2023-06-05)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **home-server:** allow running the home server with a mysql and redis configuration ([#622](https://github.com/standardnotes/api-gateway/issues/622)) ([d6e531d](https://github.com/standardnotes/api-gateway/commit/d6e531d4b6c1c80a894f6d7ec93632595268dd64))
|
||||||
|
|
||||||
|
## [1.63.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.63.1...@standardnotes/api-gateway@1.63.2) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/api-gateway/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
|
## [1.63.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.63.0...@standardnotes/api-gateway@1.63.1) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** add default for VERSION environment variable ([2f569d4](https://github.com/standardnotes/api-gateway/commit/2f569d41047a802eb72ef1a3618ffe4df28a709c))
|
||||||
|
|
||||||
# [1.63.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.62.4...@standardnotes/api-gateway@1.63.0) (2023-06-02)
|
# [1.63.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.62.4...@standardnotes/api-gateway@1.63.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ import '../src/Controller/v1/OfflineController'
|
|||||||
import '../src/Controller/v1/FilesController'
|
import '../src/Controller/v1/FilesController'
|
||||||
import '../src/Controller/v1/SubscriptionInvitesController'
|
import '../src/Controller/v1/SubscriptionInvitesController'
|
||||||
import '../src/Controller/v1/AuthenticatorsController'
|
import '../src/Controller/v1/AuthenticatorsController'
|
||||||
|
import '../src/Controller/v1/MessagesController'
|
||||||
|
import '../src/Controller/v1/SharedVaultsController'
|
||||||
|
import '../src/Controller/v1/SharedVaultInvitesController'
|
||||||
|
import '../src/Controller/v1/SharedVaultUsersController'
|
||||||
|
|
||||||
import '../src/Controller/v2/PaymentsControllerV2'
|
import '../src/Controller/v2/PaymentsControllerV2'
|
||||||
import '../src/Controller/v2/ActionsControllerV2'
|
import '../src/Controller/v2/ActionsControllerV2'
|
||||||
@@ -42,31 +46,32 @@ void container.load().then((container) => {
|
|||||||
|
|
||||||
server.setConfig((app) => {
|
server.setConfig((app) => {
|
||||||
app.use((_request: Request, response: Response, next: NextFunction) => {
|
app.use((_request: Request, response: Response, next: NextFunction) => {
|
||||||
response.setHeader('X-API-Gateway-Version', container.get(TYPES.VERSION))
|
response.setHeader('X-API-Gateway-Version', container.get(TYPES.ApiGateway_VERSION))
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
/* eslint-disable */
|
app.use(
|
||||||
app.use(helmet({
|
helmet({
|
||||||
contentSecurityPolicy: {
|
contentSecurityPolicy: {
|
||||||
directives: {
|
directives: {
|
||||||
defaultSrc: ["https: 'self'"],
|
defaultSrc: ["https: 'self'"],
|
||||||
baseUri: ["'self'"],
|
baseUri: ["'self'"],
|
||||||
childSrc: ["*", "blob:"],
|
childSrc: ['*', 'blob:'],
|
||||||
connectSrc: ["*"],
|
connectSrc: ['*'],
|
||||||
fontSrc: ["*", "'self'"],
|
fontSrc: ['*', "'self'"],
|
||||||
formAction: ["'self'"],
|
formAction: ["'self'"],
|
||||||
frameAncestors: ["*", "*.standardnotes.org", "*.standardnotes.com"],
|
frameAncestors: ['*', '*.standardnotes.org', '*.standardnotes.com'],
|
||||||
frameSrc: ["*", "blob:"],
|
frameSrc: ['*', 'blob:'],
|
||||||
imgSrc: ["'self'", "*", "data:"],
|
imgSrc: ["'self'", '*', 'data:'],
|
||||||
manifestSrc: ["'self'"],
|
manifestSrc: ["'self'"],
|
||||||
mediaSrc: ["'self'"],
|
mediaSrc: ["'self'"],
|
||||||
objectSrc: ["'self'"],
|
objectSrc: ["'self'"],
|
||||||
scriptSrc: ["'self'"],
|
scriptSrc: ["'self'"],
|
||||||
styleSrc: ["'self'"]
|
styleSrc: ["'self'"],
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}))
|
}),
|
||||||
/* eslint-enable */
|
)
|
||||||
|
|
||||||
app.use(json({ limit: '50mb' }))
|
app.use(json({ limit: '50mb' }))
|
||||||
app.use(
|
app.use(
|
||||||
text({
|
text({
|
||||||
@@ -82,7 +87,7 @@ void container.load().then((container) => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
const logger: winston.Logger = container.get(TYPES.Logger)
|
const logger: winston.Logger = container.get(TYPES.ApiGateway_Logger)
|
||||||
|
|
||||||
server.setErrorConfig((app) => {
|
server.setErrorConfig((app) => {
|
||||||
app.use((error: Record<string, unknown>, _request: Request, response: Response, _next: NextFunction) => {
|
app.use((error: Record<string, unknown>, _request: Request, response: Response, _next: NextFunction) => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/api-gateway",
|
"name": "@standardnotes/api-gateway",
|
||||||
"version": "1.63.0",
|
"version": "1.69.2",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
"clean": "rm -fr dist",
|
"clean": "rm -fr dist",
|
||||||
"build": "tsc --build",
|
"build": "tsc --build",
|
||||||
"lint": "eslint . --ext .ts",
|
"lint": "eslint . --ext .ts",
|
||||||
|
"lint:fix": "eslint . --fix --ext .ts",
|
||||||
"setup:env": "cp .env.sample .env",
|
"setup:env": "cp .env.sample .env",
|
||||||
"start": "yarn node dist/bin/server.js",
|
"start": "yarn node dist/bin/server.js",
|
||||||
"upgrade:snjs": "yarn ncu -u '@standardnotes/*'"
|
"upgrade:snjs": "yarn ncu -u '@standardnotes/*'"
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ export class ContainerConfigLoader {
|
|||||||
|
|
||||||
const container = new Container()
|
const container = new Container()
|
||||||
|
|
||||||
const isConfiguredForHomeServer = env.get('CACHE_TYPE') === 'memory'
|
const isConfiguredForHomeServer = env.get('MODE', true) === 'home-server'
|
||||||
|
const isConfiguredForInMemoryCache = env.get('CACHE_TYPE', true) === 'memory'
|
||||||
|
|
||||||
const winstonFormatters = [winston.format.splat(), winston.format.json()]
|
const winstonFormatters = [winston.format.splat(), winston.format.json()]
|
||||||
if (env.get('NEW_RELIC_ENABLED', true) === 'true') {
|
if (env.get('NEW_RELIC_ENABLED', true) === 'true') {
|
||||||
@@ -45,19 +46,20 @@ export class ContainerConfigLoader {
|
|||||||
winstonFormatters.push(newrelicWinstonFormatter())
|
winstonFormatters.push(newrelicWinstonFormatter())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let logger: winston.Logger
|
||||||
if (configuration?.logger) {
|
if (configuration?.logger) {
|
||||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(configuration.logger as winston.Logger)
|
logger = configuration.logger as winston.Logger
|
||||||
} else {
|
} else {
|
||||||
const logger = winston.createLogger({
|
logger = winston.createLogger({
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
level: env.get('LOG_LEVEL', true) || 'info',
|
||||||
format: winston.format.combine(...winstonFormatters),
|
format: winston.format.combine(...winstonFormatters),
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||||
defaultMeta: { service: 'api-gateway' },
|
defaultMeta: { service: 'api-gateway' },
|
||||||
})
|
})
|
||||||
container.bind<winston.Logger>(TYPES.Logger).toConstantValue(logger)
|
|
||||||
}
|
}
|
||||||
|
container.bind<winston.Logger>(TYPES.ApiGateway_Logger).toConstantValue(logger)
|
||||||
|
|
||||||
if (!isConfiguredForHomeServer) {
|
if (!isConfiguredForInMemoryCache) {
|
||||||
const redisUrl = env.get('REDIS_URL')
|
const redisUrl = env.get('REDIS_URL')
|
||||||
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
|
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
|
||||||
let redis
|
let redis
|
||||||
@@ -66,36 +68,39 @@ export class ContainerConfigLoader {
|
|||||||
} else {
|
} else {
|
||||||
redis = new Redis(redisUrl)
|
redis = new Redis(redisUrl)
|
||||||
}
|
}
|
||||||
container.bind(TYPES.Redis).toConstantValue(redis)
|
container.bind(TYPES.ApiGateway_Redis).toConstantValue(redis)
|
||||||
}
|
}
|
||||||
|
|
||||||
container.bind<AxiosInstance>(TYPES.HTTPClient).toConstantValue(axios.create())
|
container.bind<AxiosInstance>(TYPES.ApiGateway_HTTPClient).toConstantValue(axios.create())
|
||||||
|
|
||||||
// env vars
|
// env vars
|
||||||
container.bind(TYPES.SYNCING_SERVER_JS_URL).toConstantValue(env.get('SYNCING_SERVER_JS_URL', true))
|
container.bind(TYPES.ApiGateway_SYNCING_SERVER_JS_URL).toConstantValue(env.get('SYNCING_SERVER_JS_URL', true))
|
||||||
container.bind(TYPES.AUTH_SERVER_URL).toConstantValue(env.get('AUTH_SERVER_URL', true))
|
container.bind(TYPES.ApiGateway_AUTH_SERVER_URL).toConstantValue(env.get('AUTH_SERVER_URL', true))
|
||||||
container.bind(TYPES.REVISIONS_SERVER_URL).toConstantValue(env.get('REVISIONS_SERVER_URL', true))
|
container.bind(TYPES.ApiGateway_REVISIONS_SERVER_URL).toConstantValue(env.get('REVISIONS_SERVER_URL', true))
|
||||||
container.bind(TYPES.EMAIL_SERVER_URL).toConstantValue(env.get('EMAIL_SERVER_URL', true))
|
container.bind(TYPES.ApiGateway_EMAIL_SERVER_URL).toConstantValue(env.get('EMAIL_SERVER_URL', true))
|
||||||
container.bind(TYPES.PAYMENTS_SERVER_URL).toConstantValue(env.get('PAYMENTS_SERVER_URL', true))
|
container.bind(TYPES.ApiGateway_PAYMENTS_SERVER_URL).toConstantValue(env.get('PAYMENTS_SERVER_URL', true))
|
||||||
container.bind(TYPES.FILES_SERVER_URL).toConstantValue(env.get('FILES_SERVER_URL', true))
|
container.bind(TYPES.ApiGateway_FILES_SERVER_URL).toConstantValue(env.get('FILES_SERVER_URL', true))
|
||||||
container.bind(TYPES.WEB_SOCKET_SERVER_URL).toConstantValue(env.get('WEB_SOCKET_SERVER_URL', true))
|
container.bind(TYPES.ApiGateway_WEB_SOCKET_SERVER_URL).toConstantValue(env.get('WEB_SOCKET_SERVER_URL', true))
|
||||||
container.bind(TYPES.AUTH_JWT_SECRET).toConstantValue(env.get('AUTH_JWT_SECRET'))
|
container.bind(TYPES.ApiGateway_AUTH_JWT_SECRET).toConstantValue(env.get('AUTH_JWT_SECRET'))
|
||||||
container
|
container
|
||||||
.bind(TYPES.HTTP_CALL_TIMEOUT)
|
.bind(TYPES.ApiGateway_HTTP_CALL_TIMEOUT)
|
||||||
.toConstantValue(env.get('HTTP_CALL_TIMEOUT', true) ? +env.get('HTTP_CALL_TIMEOUT', true) : 60_000)
|
.toConstantValue(env.get('HTTP_CALL_TIMEOUT', true) ? +env.get('HTTP_CALL_TIMEOUT', true) : 60_000)
|
||||||
container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION'))
|
container.bind(TYPES.ApiGateway_VERSION).toConstantValue(env.get('VERSION', true) ?? 'development')
|
||||||
container.bind(TYPES.CROSS_SERVICE_TOKEN_CACHE_TTL).toConstantValue(+env.get('CROSS_SERVICE_TOKEN_CACHE_TTL', true))
|
container
|
||||||
|
.bind(TYPES.ApiGateway_CROSS_SERVICE_TOKEN_CACHE_TTL)
|
||||||
|
.toConstantValue(+env.get('CROSS_SERVICE_TOKEN_CACHE_TTL', true))
|
||||||
|
container.bind(TYPES.ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER).toConstantValue(isConfiguredForHomeServer)
|
||||||
|
|
||||||
// Middleware
|
// Middleware
|
||||||
container
|
container
|
||||||
.bind<RequiredCrossServiceTokenMiddleware>(TYPES.RequiredCrossServiceTokenMiddleware)
|
.bind<RequiredCrossServiceTokenMiddleware>(TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
.to(RequiredCrossServiceTokenMiddleware)
|
.to(RequiredCrossServiceTokenMiddleware)
|
||||||
container
|
container
|
||||||
.bind<OptionalCrossServiceTokenMiddleware>(TYPES.OptionalCrossServiceTokenMiddleware)
|
.bind<OptionalCrossServiceTokenMiddleware>(TYPES.ApiGateway_OptionalCrossServiceTokenMiddleware)
|
||||||
.to(OptionalCrossServiceTokenMiddleware)
|
.to(OptionalCrossServiceTokenMiddleware)
|
||||||
container.bind<WebSocketAuthMiddleware>(TYPES.WebSocketAuthMiddleware).to(WebSocketAuthMiddleware)
|
container.bind<WebSocketAuthMiddleware>(TYPES.ApiGateway_WebSocketAuthMiddleware).to(WebSocketAuthMiddleware)
|
||||||
container
|
container
|
||||||
.bind<SubscriptionTokenAuthMiddleware>(TYPES.SubscriptionTokenAuthMiddleware)
|
.bind<SubscriptionTokenAuthMiddleware>(TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
.to(SubscriptionTokenAuthMiddleware)
|
.to(SubscriptionTokenAuthMiddleware)
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
@@ -104,26 +109,30 @@ export class ContainerConfigLoader {
|
|||||||
throw new Error('Service container is required when configured for home server')
|
throw new Error('Service container is required when configured for home server')
|
||||||
}
|
}
|
||||||
container
|
container
|
||||||
.bind<ServiceProxyInterface>(TYPES.ServiceProxy)
|
.bind<ServiceProxyInterface>(TYPES.ApiGateway_ServiceProxy)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new DirectCallServiceProxy(configuration.serviceContainer, container.get(TYPES.FILES_SERVER_URL)),
|
new DirectCallServiceProxy(configuration.serviceContainer, container.get(TYPES.ApiGateway_FILES_SERVER_URL)),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
container.bind<ServiceProxyInterface>(TYPES.ServiceProxy).to(HttpServiceProxy)
|
container.bind<ServiceProxyInterface>(TYPES.ApiGateway_ServiceProxy).to(HttpServiceProxy)
|
||||||
}
|
}
|
||||||
container.bind<TimerInterface>(TYPES.Timer).toConstantValue(new Timer())
|
container.bind<TimerInterface>(TYPES.ApiGateway_Timer).toConstantValue(new Timer())
|
||||||
|
|
||||||
if (isConfiguredForHomeServer) {
|
if (isConfiguredForHomeServer) {
|
||||||
container
|
container
|
||||||
.bind<CrossServiceTokenCacheInterface>(TYPES.CrossServiceTokenCache)
|
.bind<CrossServiceTokenCacheInterface>(TYPES.ApiGateway_CrossServiceTokenCache)
|
||||||
.toConstantValue(new InMemoryCrossServiceTokenCache(container.get(TYPES.Timer)))
|
.toConstantValue(new InMemoryCrossServiceTokenCache(container.get(TYPES.ApiGateway_Timer)))
|
||||||
} else {
|
} else {
|
||||||
container.bind<CrossServiceTokenCacheInterface>(TYPES.CrossServiceTokenCache).to(RedisCrossServiceTokenCache)
|
container
|
||||||
|
.bind<CrossServiceTokenCacheInterface>(TYPES.ApiGateway_CrossServiceTokenCache)
|
||||||
|
.to(RedisCrossServiceTokenCache)
|
||||||
}
|
}
|
||||||
container
|
container
|
||||||
.bind<EndpointResolverInterface>(TYPES.EndpointResolver)
|
.bind<EndpointResolverInterface>(TYPES.ApiGateway_EndpointResolver)
|
||||||
.toConstantValue(new EndpointResolver(isConfiguredForHomeServer))
|
.toConstantValue(new EndpointResolver(isConfiguredForHomeServer))
|
||||||
|
|
||||||
|
logger.debug('Configuration complete')
|
||||||
|
|
||||||
return container
|
return container
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,28 @@
|
|||||||
export const TYPES = {
|
export const TYPES = {
|
||||||
Logger: Symbol.for('Logger'),
|
ApiGateway_Logger: Symbol.for('ApiGateway_Logger'),
|
||||||
Redis: Symbol.for('Redis'),
|
ApiGateway_Redis: Symbol.for('ApiGateway_Redis'),
|
||||||
HTTPClient: Symbol.for('HTTPClient'),
|
ApiGateway_HTTPClient: Symbol.for('ApiGateway_HTTPClient'),
|
||||||
// env vars
|
// env vars
|
||||||
SYNCING_SERVER_JS_URL: Symbol.for('SYNCING_SERVER_JS_URL'),
|
ApiGateway_SYNCING_SERVER_JS_URL: Symbol.for('ApiGateway_SYNCING_SERVER_JS_URL'),
|
||||||
AUTH_SERVER_URL: Symbol.for('AUTH_SERVER_URL'),
|
ApiGateway_AUTH_SERVER_URL: Symbol.for('ApiGateway_AUTH_SERVER_URL'),
|
||||||
PAYMENTS_SERVER_URL: Symbol.for('PAYMENTS_SERVER_URL'),
|
ApiGateway_PAYMENTS_SERVER_URL: Symbol.for('ApiGateway_PAYMENTS_SERVER_URL'),
|
||||||
FILES_SERVER_URL: Symbol.for('FILES_SERVER_URL'),
|
ApiGateway_FILES_SERVER_URL: Symbol.for('ApiGateway_FILES_SERVER_URL'),
|
||||||
REVISIONS_SERVER_URL: Symbol.for('REVISIONS_SERVER_URL'),
|
ApiGateway_REVISIONS_SERVER_URL: Symbol.for('ApiGateway_REVISIONS_SERVER_URL'),
|
||||||
EMAIL_SERVER_URL: Symbol.for('EMAIL_SERVER_URL'),
|
ApiGateway_EMAIL_SERVER_URL: Symbol.for('ApiGateway_EMAIL_SERVER_URL'),
|
||||||
WEB_SOCKET_SERVER_URL: Symbol.for('WEB_SOCKET_SERVER_URL'),
|
ApiGateway_WEB_SOCKET_SERVER_URL: Symbol.for('ApiGateway_WEB_SOCKET_SERVER_URL'),
|
||||||
AUTH_JWT_SECRET: Symbol.for('AUTH_JWT_SECRET'),
|
ApiGateway_AUTH_JWT_SECRET: Symbol.for('ApiGateway_AUTH_JWT_SECRET'),
|
||||||
HTTP_CALL_TIMEOUT: Symbol.for('HTTP_CALL_TIMEOUT'),
|
ApiGateway_HTTP_CALL_TIMEOUT: Symbol.for('ApiGateway_HTTP_CALL_TIMEOUT'),
|
||||||
VERSION: Symbol.for('VERSION'),
|
ApiGateway_VERSION: Symbol.for('ApiGateway_VERSION'),
|
||||||
CROSS_SERVICE_TOKEN_CACHE_TTL: Symbol.for('CROSS_SERVICE_TOKEN_CACHE_TTL'),
|
ApiGateway_CROSS_SERVICE_TOKEN_CACHE_TTL: Symbol.for('ApiGateway_CROSS_SERVICE_TOKEN_CACHE_TTL'),
|
||||||
|
ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER: Symbol.for('ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER'),
|
||||||
// Middleware
|
// Middleware
|
||||||
RequiredCrossServiceTokenMiddleware: Symbol.for('RequiredCrossServiceTokenMiddleware'),
|
ApiGateway_RequiredCrossServiceTokenMiddleware: Symbol.for('ApiGateway_RequiredCrossServiceTokenMiddleware'),
|
||||||
OptionalCrossServiceTokenMiddleware: Symbol.for('OptionalCrossServiceTokenMiddleware'),
|
ApiGateway_OptionalCrossServiceTokenMiddleware: Symbol.for('ApiGateway_OptionalCrossServiceTokenMiddleware'),
|
||||||
WebSocketAuthMiddleware: Symbol.for('WebSocketAuthMiddleware'),
|
ApiGateway_WebSocketAuthMiddleware: Symbol.for('ApiGateway_WebSocketAuthMiddleware'),
|
||||||
SubscriptionTokenAuthMiddleware: Symbol.for('SubscriptionTokenAuthMiddleware'),
|
ApiGateway_SubscriptionTokenAuthMiddleware: Symbol.for('ApiGateway_SubscriptionTokenAuthMiddleware'),
|
||||||
// Services
|
// Services
|
||||||
ServiceProxy: Symbol.for('ServiceProxy'),
|
ApiGateway_ServiceProxy: Symbol.for('ApiGateway_ServiceProxy'),
|
||||||
CrossServiceTokenCache: Symbol.for('CrossServiceTokenCache'),
|
ApiGateway_CrossServiceTokenCache: Symbol.for('ApiGateway_CrossServiceTokenCache'),
|
||||||
Timer: Symbol.for('Timer'),
|
ApiGateway_Timer: Symbol.for('ApiGateway_Timer'),
|
||||||
EndpointResolver: Symbol.for('EndpointResolver'),
|
ApiGateway_EndpointResolver: Symbol.for('ApiGateway_EndpointResolver'),
|
||||||
}
|
}
|
||||||
|
|
||||||
// export default TYPES
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export abstract class AuthMiddleware extends BaseMiddleware {
|
|||||||
private crossServiceTokenCacheTTL: number,
|
private crossServiceTokenCacheTTL: number,
|
||||||
private crossServiceTokenCache: CrossServiceTokenCacheInterface,
|
private crossServiceTokenCache: CrossServiceTokenCacheInterface,
|
||||||
private timer: TimerInterface,
|
private timer: TimerInterface,
|
||||||
private logger: Logger,
|
protected logger: Logger,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export class LegacyController extends BaseHttpController {
|
|||||||
private AUTH_ROUTES: Map<string, string>
|
private AUTH_ROUTES: Map<string, string>
|
||||||
private PARAMETRIZED_AUTH_ROUTES: Map<string, string>
|
private PARAMETRIZED_AUTH_ROUTES: Map<string, string>
|
||||||
|
|
||||||
constructor(@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface) {
|
constructor(@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface) {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
this.AUTH_ROUTES = new Map([
|
this.AUTH_ROUTES = new Map([
|
||||||
@@ -29,17 +29,17 @@ export class LegacyController extends BaseHttpController {
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/items/sync', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPost('/items/sync', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async legacyItemsSync(request: Request, response: Response): Promise<void> {
|
async legacyItemsSync(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callLegacySyncingServer(request, response, request.path.substring(1), request.body)
|
await this.httpService.callLegacySyncingServer(request, response, request.path.substring(1), request.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/items/:item_id/revisions', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpGet('/items/:item_id/revisions', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async legacyGetRevisions(request: Request, response: Response): Promise<void> {
|
async legacyGetRevisions(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callLegacySyncingServer(request, response, request.path.substring(1), request.body)
|
await this.httpService.callLegacySyncingServer(request, response, request.path.substring(1), request.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/items/:item_id/revisions/:id', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpGet('/items/:item_id/revisions/:id', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async legacyGetRevision(request: Request, response: Response): Promise<void> {
|
async legacyGetRevision(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callLegacySyncingServer(request, response, request.path.substring(1), request.body)
|
await this.httpService.callLegacySyncingServer(request, response, request.path.substring(1), request.body)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ import { AuthMiddleware } from './AuthMiddleware'
|
|||||||
@injectable()
|
@injectable()
|
||||||
export class OptionalCrossServiceTokenMiddleware extends AuthMiddleware {
|
export class OptionalCrossServiceTokenMiddleware extends AuthMiddleware {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) serviceProxy: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) serviceProxy: ServiceProxyInterface,
|
||||||
@inject(TYPES.AUTH_JWT_SECRET) jwtSecret: string,
|
@inject(TYPES.ApiGateway_AUTH_JWT_SECRET) jwtSecret: string,
|
||||||
@inject(TYPES.CROSS_SERVICE_TOKEN_CACHE_TTL) crossServiceTokenCacheTTL: number,
|
@inject(TYPES.ApiGateway_CROSS_SERVICE_TOKEN_CACHE_TTL) crossServiceTokenCacheTTL: number,
|
||||||
@inject(TYPES.CrossServiceTokenCache) crossServiceTokenCache: CrossServiceTokenCacheInterface,
|
@inject(TYPES.ApiGateway_CrossServiceTokenCache) crossServiceTokenCache: CrossServiceTokenCacheInterface,
|
||||||
@inject(TYPES.Timer) timer: TimerInterface,
|
@inject(TYPES.ApiGateway_Timer) timer: TimerInterface,
|
||||||
@inject(TYPES.Logger) logger: Logger,
|
@inject(TYPES.ApiGateway_Logger) logger: Logger,
|
||||||
) {
|
) {
|
||||||
super(serviceProxy, jwtSecret, crossServiceTokenCacheTTL, crossServiceTokenCache, timer, logger)
|
super(serviceProxy, jwtSecret, crossServiceTokenCacheTTL, crossServiceTokenCache, timer, logger)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ import { AuthMiddleware } from './AuthMiddleware'
|
|||||||
@injectable()
|
@injectable()
|
||||||
export class RequiredCrossServiceTokenMiddleware extends AuthMiddleware {
|
export class RequiredCrossServiceTokenMiddleware extends AuthMiddleware {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) serviceProxy: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) serviceProxy: ServiceProxyInterface,
|
||||||
@inject(TYPES.AUTH_JWT_SECRET) jwtSecret: string,
|
@inject(TYPES.ApiGateway_AUTH_JWT_SECRET) jwtSecret: string,
|
||||||
@inject(TYPES.CROSS_SERVICE_TOKEN_CACHE_TTL) crossServiceTokenCacheTTL: number,
|
@inject(TYPES.ApiGateway_CROSS_SERVICE_TOKEN_CACHE_TTL) crossServiceTokenCacheTTL: number,
|
||||||
@inject(TYPES.CrossServiceTokenCache) crossServiceTokenCache: CrossServiceTokenCacheInterface,
|
@inject(TYPES.ApiGateway_CrossServiceTokenCache) crossServiceTokenCache: CrossServiceTokenCacheInterface,
|
||||||
@inject(TYPES.Timer) timer: TimerInterface,
|
@inject(TYPES.ApiGateway_Timer) timer: TimerInterface,
|
||||||
@inject(TYPES.Logger) logger: Logger,
|
@inject(TYPES.ApiGateway_Logger) logger: Logger,
|
||||||
) {
|
) {
|
||||||
super(serviceProxy, jwtSecret, crossServiceTokenCacheTTL, crossServiceTokenCache, timer, logger)
|
super(serviceProxy, jwtSecret, crossServiceTokenCacheTTL, crossServiceTokenCache, timer, logger)
|
||||||
}
|
}
|
||||||
@@ -42,6 +42,8 @@ export class RequiredCrossServiceTokenMiddleware extends AuthMiddleware {
|
|||||||
_next: NextFunction,
|
_next: NextFunction,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (!authHeaderValue) {
|
if (!authHeaderValue) {
|
||||||
|
this.logger.debug('Missing auth header')
|
||||||
|
|
||||||
response.status(401).send({
|
response.status(401).send({
|
||||||
error: {
|
error: {
|
||||||
tag: 'invalid-auth',
|
tag: 'invalid-auth',
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ import { TokenAuthenticationMethod } from './TokenAuthenticationMethod'
|
|||||||
@injectable()
|
@injectable()
|
||||||
export class SubscriptionTokenAuthMiddleware extends BaseMiddleware {
|
export class SubscriptionTokenAuthMiddleware extends BaseMiddleware {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.HTTPClient) private httpClient: AxiosInstance,
|
@inject(TYPES.ApiGateway_HTTPClient) private httpClient: AxiosInstance,
|
||||||
@inject(TYPES.AUTH_SERVER_URL) private authServerUrl: string,
|
@inject(TYPES.ApiGateway_AUTH_SERVER_URL) private authServerUrl: string,
|
||||||
@inject(TYPES.AUTH_JWT_SECRET) private jwtSecret: string,
|
@inject(TYPES.ApiGateway_AUTH_JWT_SECRET) private jwtSecret: string,
|
||||||
@inject(TYPES.Logger) private logger: Logger,
|
@inject(TYPES.ApiGateway_Logger) private logger: Logger,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ import { TYPES } from '../Bootstrap/Types'
|
|||||||
@injectable()
|
@injectable()
|
||||||
export class WebSocketAuthMiddleware extends BaseMiddleware {
|
export class WebSocketAuthMiddleware extends BaseMiddleware {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.HTTPClient) private httpClient: AxiosInstance,
|
@inject(TYPES.ApiGateway_HTTPClient) private httpClient: AxiosInstance,
|
||||||
@inject(TYPES.AUTH_SERVER_URL) private authServerUrl: string,
|
@inject(TYPES.ApiGateway_AUTH_SERVER_URL) private authServerUrl: string,
|
||||||
@inject(TYPES.AUTH_JWT_SECRET) private jwtSecret: string,
|
@inject(TYPES.ApiGateway_AUTH_JWT_SECRET) private jwtSecret: string,
|
||||||
@inject(TYPES.Logger) private logger: Logger,
|
@inject(TYPES.ApiGateway_Logger) private logger: Logger,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ export * from './SubscriptionTokenAuthMiddleware'
|
|||||||
export * from './TokenAuthenticationMethod'
|
export * from './TokenAuthenticationMethod'
|
||||||
export * from './WebSocketAuthMiddleware'
|
export * from './WebSocketAuthMiddleware'
|
||||||
export * from './v1/ActionsController'
|
export * from './v1/ActionsController'
|
||||||
|
export * from './v1/MessagesController'
|
||||||
export * from './v1/AuthenticatorsController'
|
export * from './v1/AuthenticatorsController'
|
||||||
export * from './v1/FilesController'
|
export * from './v1/FilesController'
|
||||||
export * from './v1/InvoicesController'
|
export * from './v1/InvoicesController'
|
||||||
@@ -12,6 +13,9 @@ export * from './v1/OfflineController'
|
|||||||
export * from './v1/PaymentsController'
|
export * from './v1/PaymentsController'
|
||||||
export * from './v1/RevisionsController'
|
export * from './v1/RevisionsController'
|
||||||
export * from './v1/SessionsController'
|
export * from './v1/SessionsController'
|
||||||
|
export * from './v1/SharedVaultInvitesController'
|
||||||
|
export * from './v1/SharedVaultUsersController'
|
||||||
|
export * from './v1/SharedVaultsController'
|
||||||
export * from './v1/SubscriptionInvitesController'
|
export * from './v1/SubscriptionInvitesController'
|
||||||
export * from './v1/TokensController'
|
export * from './v1/TokensController'
|
||||||
export * from './v1/UsersController'
|
export * from './v1/UsersController'
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolv
|
|||||||
@controller('/v1')
|
@controller('/v1')
|
||||||
export class ActionsController extends BaseHttpController {
|
export class ActionsController extends BaseHttpController {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) private serviceProxy: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) private serviceProxy: ServiceProxyInterface,
|
||||||
@inject(TYPES.EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ export class ActionsController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/login-params', TYPES.OptionalCrossServiceTokenMiddleware)
|
@httpGet('/login-params', TYPES.ApiGateway_OptionalCrossServiceTokenMiddleware)
|
||||||
async loginParams(request: Request, response: Response): Promise<void> {
|
async loginParams(request: Request, response: Response): Promise<void> {
|
||||||
await this.serviceProxy.callAuthServer(
|
await this.serviceProxy.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -34,7 +34,7 @@ export class ActionsController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/logout', TYPES.OptionalCrossServiceTokenMiddleware)
|
@httpPost('/logout', TYPES.ApiGateway_OptionalCrossServiceTokenMiddleware)
|
||||||
async logout(request: Request, response: Response): Promise<void> {
|
async logout(request: Request, response: Response): Promise<void> {
|
||||||
await this.serviceProxy.callAuthServer(
|
await this.serviceProxy.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -54,7 +54,7 @@ export class ActionsController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/recovery/codes', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPost('/recovery/codes', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async recoveryCodes(request: Request, response: Response): Promise<void> {
|
async recoveryCodes(request: Request, response: Response): Promise<void> {
|
||||||
await this.serviceProxy.callAuthServer(
|
await this.serviceProxy.callAuthServer(
|
||||||
request,
|
request,
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolv
|
|||||||
@controller('/v1/authenticators')
|
@controller('/v1/authenticators')
|
||||||
export class AuthenticatorsController extends BaseHttpController {
|
export class AuthenticatorsController extends BaseHttpController {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
@inject(TYPES.EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpDelete('/:authenticatorId', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpDelete('/:authenticatorId', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async delete(request: Request, response: Response): Promise<void> {
|
async delete(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -29,7 +29,7 @@ export class AuthenticatorsController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpGet('/', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async list(request: Request, response: Response): Promise<void> {
|
async list(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -39,7 +39,7 @@ export class AuthenticatorsController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/generate-registration-options', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpGet('/generate-registration-options', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async generateRegistrationOptions(request: Request, response: Response): Promise<void> {
|
async generateRegistrationOptions(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -59,7 +59,7 @@ export class AuthenticatorsController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/verify-registration', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPost('/verify-registration', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async verifyRegistration(request: Request, response: Response): Promise<void> {
|
async verifyRegistration(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolv
|
|||||||
@controller('/v1/files')
|
@controller('/v1/files')
|
||||||
export class FilesController extends BaseHttpController {
|
export class FilesController extends BaseHttpController {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
@inject(TYPES.EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/valet-tokens', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPost('/valet-tokens', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async createToken(request: Request, response: Response): Promise<void> {
|
async createToken(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import { ServiceProxyInterface } from '../../Service/Http/ServiceProxyInterface'
|
|||||||
|
|
||||||
@controller('/v1')
|
@controller('/v1')
|
||||||
export class InvoicesController extends BaseHttpController {
|
export class InvoicesController extends BaseHttpController {
|
||||||
constructor(@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface) {
|
constructor(@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/invoices/send-latest', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpPost('/invoices/send-latest', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async sendLatestInvoice(request: Request, response: Response): Promise<void> {
|
async sendLatestInvoice(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(request, response, 'api/pro_users/send-invoice', request.body)
|
await this.httpService.callPaymentsServer(request, response, 'api/pro_users/send-invoice', request.body)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import { TYPES } from '../../Bootstrap/Types'
|
|||||||
import { ServiceProxyInterface } from '../../Service/Http/ServiceProxyInterface'
|
import { ServiceProxyInterface } from '../../Service/Http/ServiceProxyInterface'
|
||||||
import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolverInterface'
|
import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolverInterface'
|
||||||
|
|
||||||
@controller('/v1/items', TYPES.RequiredCrossServiceTokenMiddleware)
|
@controller('/v1/items', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
export class ItemsController extends BaseHttpController {
|
export class ItemsController extends BaseHttpController {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) private serviceProxy: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) private serviceProxy: ServiceProxyInterface,
|
||||||
@inject(TYPES.EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import { Request, Response } from 'express'
|
||||||
|
import { inject } from 'inversify'
|
||||||
|
import { BaseHttpController, controller, httpDelete, httpGet, httpPost } from 'inversify-express-utils'
|
||||||
|
import { TYPES } from '../../Bootstrap/Types'
|
||||||
|
import { ServiceProxyInterface } from '../../Service/Http/ServiceProxyInterface'
|
||||||
|
import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolverInterface'
|
||||||
|
|
||||||
|
@controller('/v1/messages', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
|
export class MessagesController extends BaseHttpController {
|
||||||
|
constructor(
|
||||||
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
|
) {
|
||||||
|
super()
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpGet('/')
|
||||||
|
async getMessages(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier('GET', 'messages/'),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpGet('/outbound')
|
||||||
|
async getMessagesSent(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier('GET', 'messages/outbound'),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpPost('/')
|
||||||
|
async sendMessage(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier('POST', 'messages/'),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpDelete('/inbound')
|
||||||
|
async deleteMessagesSentToUser(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier('DELETE', 'messages/inbound'),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpDelete('/:messageUuid')
|
||||||
|
async deleteMessage(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier(
|
||||||
|
'DELETE',
|
||||||
|
'messages/:messageUuid',
|
||||||
|
request.params.messageUuid,
|
||||||
|
),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,8 +9,8 @@ import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolv
|
|||||||
@controller('/v1/offline')
|
@controller('/v1/offline')
|
||||||
export class OfflineController extends BaseHttpController {
|
export class OfflineController extends BaseHttpController {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
@inject(TYPES.EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { ServiceProxyInterface } from '../../Service/Http/ServiceProxyInterface'
|
|||||||
|
|
||||||
@controller('/v1')
|
@controller('/v1')
|
||||||
export class PaymentsController extends BaseHttpController {
|
export class PaymentsController extends BaseHttpController {
|
||||||
constructor(@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface) {
|
constructor(@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,12 +40,12 @@ export class PaymentsController extends BaseHttpController {
|
|||||||
await this.httpService.callPaymentsServer(request, response, 'api/extensions', request.body)
|
await this.httpService.callPaymentsServer(request, response, 'api/extensions', request.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/subscriptions/tiered', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpPost('/subscriptions/tiered', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async createTieredSubscription(request: Request, response: Response): Promise<void> {
|
async createTieredSubscription(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(request, response, 'api/subscriptions/tiered', request.body)
|
await this.httpService.callPaymentsServer(request, response, 'api/subscriptions/tiered', request.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/subscriptions/apple_iap_confirm', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpPost('/subscriptions/apple_iap_confirm', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async appleIAPConfirm(request: Request, response: Response): Promise<void> {
|
async appleIAPConfirm(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(request, response, 'api/subscriptions/apple_iap_confirm', request.body)
|
await this.httpService.callPaymentsServer(request, response, 'api/subscriptions/apple_iap_confirm', request.body)
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ export class PaymentsController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/payments/stripe-setup-intent', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpPost('/payments/stripe-setup-intent', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async createStripeSetupIntent(request: Request, response: Response): Promise<void> {
|
async createStripeSetupIntent(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(request, response, 'api/pro_users/stripe-setup-intent', request.body)
|
await this.httpService.callPaymentsServer(request, response, 'api/pro_users/stripe-setup-intent', request.body)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { BaseHttpController, controller, httpDelete, httpGet, results } from 'inversify-express-utils'
|
import { BaseHttpController, controller, httpDelete, httpGet, results } from 'inversify-express-utils'
|
||||||
import { TYPES } from '../../Bootstrap/Types'
|
import { TYPES } from '../../Bootstrap/Types'
|
||||||
|
|
||||||
@controller('/v1/items/:item_id/revisions', TYPES.RequiredCrossServiceTokenMiddleware)
|
@controller('/v1/items/:item_id/revisions', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
export class RevisionsController extends BaseHttpController {
|
export class RevisionsController extends BaseHttpController {
|
||||||
@httpGet('/')
|
@httpGet('/')
|
||||||
async getRevisions(): Promise<results.JsonResult> {
|
async getRevisions(): Promise<results.JsonResult> {
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolv
|
|||||||
@controller('/v1/sessions')
|
@controller('/v1/sessions')
|
||||||
export class SessionsController extends BaseHttpController {
|
export class SessionsController extends BaseHttpController {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
@inject(TYPES.EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpGet('/', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async getSessions(request: Request, response: Response): Promise<void> {
|
async getSessions(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -23,7 +23,7 @@ export class SessionsController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpDelete('/:uuid', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpDelete('/:uuid', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async deleteSession(request: Request, response: Response): Promise<void> {
|
async deleteSession(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -35,7 +35,7 @@ export class SessionsController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpDelete('/', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpDelete('/', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async deleteSessions(request: Request, response: Response): Promise<void> {
|
async deleteSessions(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
|
|||||||
@@ -0,0 +1,158 @@
|
|||||||
|
import { Request, Response } from 'express'
|
||||||
|
import { inject } from 'inversify'
|
||||||
|
import { BaseHttpController, controller, httpDelete, httpGet, httpPatch, httpPost } from 'inversify-express-utils'
|
||||||
|
import { TYPES } from '../../Bootstrap/Types'
|
||||||
|
import { ServiceProxyInterface } from '../../Service/Http/ServiceProxyInterface'
|
||||||
|
import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolverInterface'
|
||||||
|
|
||||||
|
@controller('/v1/shared-vaults', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
|
export class SharedVaultInvitesController extends BaseHttpController {
|
||||||
|
constructor(
|
||||||
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
|
) {
|
||||||
|
super()
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpPost('/:sharedVaultUuid/invites')
|
||||||
|
async createSharedVaultInvite(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier(
|
||||||
|
'POST',
|
||||||
|
'shared-vaults/:sharedVaultUuid/invites',
|
||||||
|
request.params.sharedVaultUuid,
|
||||||
|
),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpPatch('/:sharedVaultUuid/invites/:inviteUuid')
|
||||||
|
async updateSharedVaultInvite(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier(
|
||||||
|
'PATCH',
|
||||||
|
'shared-vaults/:sharedVaultUuid/invites/:inviteUuid',
|
||||||
|
request.params.sharedVaultUuid,
|
||||||
|
request.params.inviteUuid,
|
||||||
|
),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpPost('/:sharedVaultUuid/invites/:inviteUuid/accept')
|
||||||
|
async acceptSharedVaultInvite(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier(
|
||||||
|
'POST',
|
||||||
|
'shared-vaults/:sharedVaultUuid/invites/:inviteUuid/accept',
|
||||||
|
request.params.sharedVaultUuid,
|
||||||
|
request.params.inviteUuid,
|
||||||
|
),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpPost('/:sharedVaultUuid/invites/:inviteUuid/decline')
|
||||||
|
async declineSharedVaultInvite(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier(
|
||||||
|
'POST',
|
||||||
|
'shared-vaults/:sharedVaultUuid/invites/:inviteUuid/decline',
|
||||||
|
request.params.sharedVaultUuid,
|
||||||
|
request.params.inviteUuid,
|
||||||
|
),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpDelete('/invites/inbound')
|
||||||
|
async deleteInboundUserInvites(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier('DELETE', 'shared-vaults/invites/inbound'),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpDelete('/invites/outbound')
|
||||||
|
async deleteOutboundUserInvites(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier('DELETE', 'shared-vaults/invites/outbound'),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpGet('/invites/outbound')
|
||||||
|
async getOutboundUserInvites(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier('GET', 'shared-vaults/invites/outbound'),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpGet('/invites')
|
||||||
|
async getUserInvites(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier('GET', 'shared-vaults/invites'),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpGet('/:sharedVaultUuid/invites')
|
||||||
|
async getSharedVaultInvites(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier(
|
||||||
|
'GET',
|
||||||
|
'shared-vaults/:sharedVaultUuid/invites',
|
||||||
|
request.params.sharedVaultUuid,
|
||||||
|
),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpDelete('/:sharedVaultUuid/invites/:inviteUuid')
|
||||||
|
async deleteSharedVaultInvite(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier(
|
||||||
|
'DELETE',
|
||||||
|
'shared-vaults/:sharedVaultUuid/invites/:inviteUuid',
|
||||||
|
request.params.sharedVaultUuid,
|
||||||
|
request.params.inviteUuid,
|
||||||
|
),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpDelete('/:sharedVaultUuid/invites')
|
||||||
|
async deleteAllSharedVaultInvites(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier(
|
||||||
|
'DELETE',
|
||||||
|
'shared-vaults/:sharedVaultUuid/invites',
|
||||||
|
request.params.sharedVaultUuid,
|
||||||
|
),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import { Request, Response } from 'express'
|
||||||
|
import { inject } from 'inversify'
|
||||||
|
import { BaseHttpController, controller, httpDelete, httpGet } from 'inversify-express-utils'
|
||||||
|
import { TYPES } from '../../Bootstrap/Types'
|
||||||
|
import { ServiceProxyInterface } from '../../Service/Http/ServiceProxyInterface'
|
||||||
|
import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolverInterface'
|
||||||
|
|
||||||
|
@controller('/v1/shared-vaults/:sharedVaultUuid/users', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
|
export class SharedVaultUsersController extends BaseHttpController {
|
||||||
|
constructor(
|
||||||
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
|
) {
|
||||||
|
super()
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpGet('/')
|
||||||
|
async getSharedVaultUsers(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier(
|
||||||
|
'GET',
|
||||||
|
'shared-vaults/:sharedVaultUuid/users',
|
||||||
|
request.params.sharedVaultUuid,
|
||||||
|
),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpDelete('/:userUuid')
|
||||||
|
async removeUserFromSharedVault(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier(
|
||||||
|
'DELETE',
|
||||||
|
'shared-vaults/:sharedVaultUuid/users/:userUuid',
|
||||||
|
request.params.sharedVaultUuid,
|
||||||
|
request.params.userUuid,
|
||||||
|
),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import { Request, Response } from 'express'
|
||||||
|
import { inject } from 'inversify'
|
||||||
|
import { BaseHttpController, controller, httpDelete, httpGet, httpPost } from 'inversify-express-utils'
|
||||||
|
import { TYPES } from '../../Bootstrap/Types'
|
||||||
|
import { ServiceProxyInterface } from '../../Service/Http/ServiceProxyInterface'
|
||||||
|
import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolverInterface'
|
||||||
|
|
||||||
|
@controller('/v1/shared-vaults', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
|
export class SharedVaultsController extends BaseHttpController {
|
||||||
|
constructor(
|
||||||
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
|
) {
|
||||||
|
super()
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpGet('/')
|
||||||
|
async getSharedVaults(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier('GET', 'shared-vaults/'),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpPost('/')
|
||||||
|
async createSharedVault(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier('POST', 'shared-vaults/'),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpDelete('/:sharedVaultUuid')
|
||||||
|
async deleteSharedVault(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier(
|
||||||
|
'DELETE',
|
||||||
|
'shared-vaults/:sharedVaultUuid',
|
||||||
|
request.params.sharedVaultUuid,
|
||||||
|
),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@httpPost('/:sharedVaultUuid/valet-tokens')
|
||||||
|
async createValetTokenForSharedVaultFile(request: Request, response: Response): Promise<void> {
|
||||||
|
await this.httpService.callSyncingServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier(
|
||||||
|
'POST',
|
||||||
|
'shared-vaults/:sharedVaultUuid/valet-tokens',
|
||||||
|
request.params.sharedVaultUuid,
|
||||||
|
),
|
||||||
|
request.body,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,13 +9,13 @@ import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolv
|
|||||||
@controller('/v1/subscription-invites')
|
@controller('/v1/subscription-invites')
|
||||||
export class SubscriptionInvitesController extends BaseHttpController {
|
export class SubscriptionInvitesController extends BaseHttpController {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
@inject(TYPES.EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPost('/', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async inviteToSubscriptionSharing(request: Request, response: Response): Promise<void> {
|
async inviteToSubscriptionSharing(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -25,7 +25,7 @@ export class SubscriptionInvitesController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpGet('/', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async listInvites(request: Request, response: Response): Promise<void> {
|
async listInvites(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -35,7 +35,7 @@ export class SubscriptionInvitesController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpDelete('/:inviteUuid', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpDelete('/:inviteUuid', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async cancelSubscriptionSharing(request: Request, response: Response): Promise<void> {
|
async cancelSubscriptionSharing(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -48,7 +48,7 @@ export class SubscriptionInvitesController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/:inviteUuid/accept', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPost('/:inviteUuid/accept', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async acceptInvite(request: Request, response: Response): Promise<void> {
|
async acceptInvite(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
|
|||||||
@@ -9,13 +9,13 @@ import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolv
|
|||||||
@controller('/v1/subscription-tokens')
|
@controller('/v1/subscription-tokens')
|
||||||
export class TokensController extends BaseHttpController {
|
export class TokensController extends BaseHttpController {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
@inject(TYPES.EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPost('/', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async createToken(request: Request, response: Response): Promise<void> {
|
async createToken(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
|
|||||||
@@ -20,9 +20,10 @@ import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolv
|
|||||||
@controller('/v1/users')
|
@controller('/v1/users')
|
||||||
export class UsersController extends BaseHttpController {
|
export class UsersController extends BaseHttpController {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
@inject(TYPES.EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
@inject(TYPES.Logger) private logger: Logger,
|
@inject(TYPES.ApiGateway_Logger) private logger: Logger,
|
||||||
|
@inject(TYPES.ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER) private isConfiguredForHomeServer: boolean,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
@@ -32,12 +33,12 @@ export class UsersController extends BaseHttpController {
|
|||||||
await this.httpService.callPaymentsServer(request, response, 'api/pro_users/claim-account', request.body)
|
await this.httpService.callPaymentsServer(request, response, 'api/pro_users/claim-account', request.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/send-activation-code', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpPost('/send-activation-code', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async sendActivationCode(request: Request, response: Response): Promise<void> {
|
async sendActivationCode(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(request, response, 'api/pro_users/send-activation-code', request.body)
|
await this.httpService.callPaymentsServer(request, response, 'api/pro_users/send-activation-code', request.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPatch('/:userId', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPatch('/:userId', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async updateUser(request: Request, response: Response): Promise<void> {
|
async updateUser(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -47,7 +48,7 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPut('/:userUuid/password', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPut('/:userUuid/password', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async changePassword(request: Request, response: Response): Promise<void> {
|
async changePassword(request: Request, response: Response): Promise<void> {
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
'[DEPRECATED] use endpoint /v1/users/:userUuid/attributes/credentials instead of /v1/users/:userUuid/password',
|
'[DEPRECATED] use endpoint /v1/users/:userUuid/attributes/credentials instead of /v1/users/:userUuid/password',
|
||||||
@@ -65,7 +66,7 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPut('/:userUuid/attributes/credentials', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPut('/:userUuid/attributes/credentials', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async changeCredentials(request: Request, response: Response): Promise<void> {
|
async changeCredentials(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -79,7 +80,7 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/:userId/params', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpGet('/:userId/params', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async getKeyParams(request: Request, response: Response): Promise<void> {
|
async getKeyParams(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -88,12 +89,12 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@all('/:userId/mfa', TYPES.RequiredCrossServiceTokenMiddleware)
|
@all('/:userId/mfa', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async blockMFA(): Promise<results.StatusCodeResult> {
|
async blockMFA(): Promise<results.StatusCodeResult> {
|
||||||
return this.statusCode(401)
|
return this.statusCode(401)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/:userUuid/integrations/listed', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPost('/:userUuid/integrations/listed', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async createListedAccount(request: Request, response: Response): Promise<void> {
|
async createListedAccount(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -113,7 +114,7 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/:userUuid/settings', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpGet('/:userUuid/settings', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async listSettings(request: Request, response: Response): Promise<void> {
|
async listSettings(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -126,7 +127,7 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPut('/:userUuid/settings', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPut('/:userUuid/settings', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async putSetting(request: Request, response: Response): Promise<void> {
|
async putSetting(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -140,7 +141,7 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/:userUuid/settings/:settingName', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpGet('/:userUuid/settings/:settingName', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async getSetting(request: Request, response: Response): Promise<void> {
|
async getSetting(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -154,7 +155,7 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpDelete('/:userUuid/settings/:settingName', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpDelete('/:userUuid/settings/:settingName', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async deleteSetting(request: Request, response: Response): Promise<void> {
|
async deleteSetting(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -169,7 +170,10 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/:userUuid/subscription-settings/:subscriptionSettingName', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpGet(
|
||||||
|
'/:userUuid/subscription-settings/:subscriptionSettingName',
|
||||||
|
TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware,
|
||||||
|
)
|
||||||
async getSubscriptionSetting(request: Request, response: Response): Promise<void> {
|
async getSubscriptionSetting(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -183,7 +187,7 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/:userUuid/features', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpGet('/:userUuid/features', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async getFeatures(request: Request, response: Response): Promise<void> {
|
async getFeatures(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -196,7 +200,7 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/:userUuid/subscription', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpGet('/:userUuid/subscription', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async getSubscription(request: Request, response: Response): Promise<void> {
|
async getSubscription(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
@@ -209,7 +213,7 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/subscription', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpGet('/subscription', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async getSubscriptionBySubscriptionToken(request: Request, response: Response): Promise<void> {
|
async getSubscriptionBySubscriptionToken(request: Request, response: Response): Promise<void> {
|
||||||
if (response.locals.tokenAuthenticationMethod === TokenAuthenticationMethod.OfflineSubscriptionToken) {
|
if (response.locals.tokenAuthenticationMethod === TokenAuthenticationMethod.OfflineSubscriptionToken) {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
@@ -232,12 +236,20 @@ export class UsersController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpDelete('/:userUuid', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpDelete('/:userUuid', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async deleteUser(request: Request, response: Response): Promise<void> {
|
async deleteUser(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(request, response, 'api/account', request.body)
|
if (!this.isConfiguredForHomeServer) {
|
||||||
|
await this.httpService.callPaymentsServer(request, response, 'api/account', request.body, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.httpService.callAuthServer(
|
||||||
|
request,
|
||||||
|
response,
|
||||||
|
this.endpointResolver.resolveEndpointOrMethodIdentifier('DELETE', 'users/:userUuid', request.params.userUuid),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/:userUuid/requests', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPost('/:userUuid/requests', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async submitRequest(request: Request, response: Response): Promise<void> {
|
async submitRequest(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callAuthServer(
|
await this.httpService.callAuthServer(
|
||||||
request,
|
request,
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolv
|
|||||||
@controller('/v1/sockets')
|
@controller('/v1/sockets')
|
||||||
export class WebSocketsController extends BaseHttpController {
|
export class WebSocketsController extends BaseHttpController {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
@inject(TYPES.EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
@inject(TYPES.Logger) private logger: Logger,
|
@inject(TYPES.ApiGateway_Logger) private logger: Logger,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/tokens', TYPES.RequiredCrossServiceTokenMiddleware)
|
@httpPost('/tokens', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
async createWebSocketConnectionToken(request: Request, response: Response): Promise<void> {
|
async createWebSocketConnectionToken(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callWebSocketServer(
|
await this.httpService.callWebSocketServer(
|
||||||
request,
|
request,
|
||||||
@@ -27,7 +27,7 @@ export class WebSocketsController extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/connections', TYPES.WebSocketAuthMiddleware)
|
@httpPost('/connections', TYPES.ApiGateway_WebSocketAuthMiddleware)
|
||||||
async createWebSocketConnection(request: Request, response: Response): Promise<void> {
|
async createWebSocketConnection(request: Request, response: Response): Promise<void> {
|
||||||
if (!request.headers.connectionid) {
|
if (!request.headers.connectionid) {
|
||||||
this.logger.error('Could not create a websocket connection. Missing connection id header.')
|
this.logger.error('Could not create a websocket connection. Missing connection id header.')
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolv
|
|||||||
@controller('/v2')
|
@controller('/v2')
|
||||||
export class ActionsControllerV2 extends BaseHttpController {
|
export class ActionsControllerV2 extends BaseHttpController {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) private serviceProxy: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) private serviceProxy: ServiceProxyInterface,
|
||||||
@inject(TYPES.EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ export class ActionsControllerV2 extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/login-params', TYPES.OptionalCrossServiceTokenMiddleware)
|
@httpPost('/login-params', TYPES.ApiGateway_OptionalCrossServiceTokenMiddleware)
|
||||||
async loginParams(request: Request, response: Response): Promise<void> {
|
async loginParams(request: Request, response: Response): Promise<void> {
|
||||||
await this.serviceProxy.callAuthServer(
|
await this.serviceProxy.callAuthServer(
|
||||||
request,
|
request,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { ServiceProxyInterface } from '../../Service/Http/ServiceProxyInterface'
|
|||||||
|
|
||||||
@controller('/v2')
|
@controller('/v2')
|
||||||
export class PaymentsControllerV2 extends BaseHttpController {
|
export class PaymentsControllerV2 extends BaseHttpController {
|
||||||
constructor(@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface) {
|
constructor(@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,22 +15,22 @@ export class PaymentsControllerV2 extends BaseHttpController {
|
|||||||
await this.httpService.callPaymentsServer(request, response, 'api/subscriptions/features', request.body)
|
await this.httpService.callPaymentsServer(request, response, 'api/subscriptions/features', request.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/subscriptions/tailored', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpGet('/subscriptions/tailored', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async getTailoredSubscriptionsWithFeatures(request: Request, response: Response): Promise<void> {
|
async getTailoredSubscriptionsWithFeatures(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(request, response, 'api/subscriptions/features', request.body)
|
await this.httpService.callPaymentsServer(request, response, 'api/subscriptions/features', request.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/subscriptions/deltas', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpGet('/subscriptions/deltas', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async getSubscriptionDeltasForChangingPlan(request: Request, response: Response): Promise<void> {
|
async getSubscriptionDeltasForChangingPlan(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(request, response, 'api/subscriptions/deltas', request.body)
|
await this.httpService.callPaymentsServer(request, response, 'api/subscriptions/deltas', request.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/subscriptions/deltas/apply', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpPost('/subscriptions/deltas/apply', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async applySubscriptionDelta(request: Request, response: Response): Promise<void> {
|
async applySubscriptionDelta(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(request, response, 'api/subscriptions/deltas/apply', request.body)
|
await this.httpService.callPaymentsServer(request, response, 'api/subscriptions/deltas/apply', request.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPost('/subscriptions/change-payment-method', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpPost('/subscriptions/change-payment-method', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async changePaymentMethod(request: Request, response: Response): Promise<void> {
|
async changePaymentMethod(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(
|
await this.httpService.callPaymentsServer(
|
||||||
request,
|
request,
|
||||||
@@ -40,7 +40,7 @@ export class PaymentsControllerV2 extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpGet('/subscriptions/:subscriptionId', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpGet('/subscriptions/:subscriptionId', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async getSubscription(request: Request, response: Response): Promise<void> {
|
async getSubscription(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(
|
await this.httpService.callPaymentsServer(
|
||||||
request,
|
request,
|
||||||
@@ -50,7 +50,7 @@ export class PaymentsControllerV2 extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpDelete('/subscriptions/:subscriptionId', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpDelete('/subscriptions/:subscriptionId', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async cancelSubscription(request: Request, response: Response): Promise<void> {
|
async cancelSubscription(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(
|
await this.httpService.callPaymentsServer(
|
||||||
request,
|
request,
|
||||||
@@ -60,7 +60,7 @@ export class PaymentsControllerV2 extends BaseHttpController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@httpPatch('/subscriptions/:subscriptionId', TYPES.SubscriptionTokenAuthMiddleware)
|
@httpPatch('/subscriptions/:subscriptionId', TYPES.ApiGateway_SubscriptionTokenAuthMiddleware)
|
||||||
async updateSubscription(request: Request, response: Response): Promise<void> {
|
async updateSubscription(request: Request, response: Response): Promise<void> {
|
||||||
await this.httpService.callPaymentsServer(
|
await this.httpService.callPaymentsServer(
|
||||||
request,
|
request,
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import { TYPES } from '../../Bootstrap/Types'
|
|||||||
import { ServiceProxyInterface } from '../../Service/Http/ServiceProxyInterface'
|
import { ServiceProxyInterface } from '../../Service/Http/ServiceProxyInterface'
|
||||||
import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolverInterface'
|
import { EndpointResolverInterface } from '../../Service/Resolver/EndpointResolverInterface'
|
||||||
|
|
||||||
@controller('/v2/items/:itemUuid/revisions', TYPES.RequiredCrossServiceTokenMiddleware)
|
@controller('/v2/items/:itemUuid/revisions', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
|
||||||
export class RevisionsControllerV2 extends BaseHttpController {
|
export class RevisionsControllerV2 extends BaseHttpController {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.ServiceProxy) private httpService: ServiceProxyInterface,
|
@inject(TYPES.ApiGateway_ServiceProxy) private httpService: ServiceProxyInterface,
|
||||||
@inject(TYPES.EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
@inject(TYPES.ApiGateway_EndpointResolver) private endpointResolver: EndpointResolverInterface,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export class RedisCrossServiceTokenCache implements CrossServiceTokenCacheInterf
|
|||||||
private readonly PREFIX = 'cst'
|
private readonly PREFIX = 'cst'
|
||||||
private readonly USER_CST_PREFIX = 'user-cst'
|
private readonly USER_CST_PREFIX = 'user-cst'
|
||||||
|
|
||||||
constructor(@inject(TYPES.Redis) private redisClient: IORedis.Redis) {}
|
constructor(@inject(TYPES.ApiGateway_Redis) private redisClient: IORedis.Redis) {}
|
||||||
|
|
||||||
async set(dto: {
|
async set(dto: {
|
||||||
authorizationHeaderValue: string
|
authorizationHeaderValue: string
|
||||||
|
|||||||
@@ -11,17 +11,17 @@ import { ServiceProxyInterface } from './ServiceProxyInterface'
|
|||||||
@injectable()
|
@injectable()
|
||||||
export class HttpServiceProxy implements ServiceProxyInterface {
|
export class HttpServiceProxy implements ServiceProxyInterface {
|
||||||
constructor(
|
constructor(
|
||||||
@inject(TYPES.HTTPClient) private httpClient: AxiosInstance,
|
@inject(TYPES.ApiGateway_HTTPClient) private httpClient: AxiosInstance,
|
||||||
@inject(TYPES.AUTH_SERVER_URL) private authServerUrl: string,
|
@inject(TYPES.ApiGateway_AUTH_SERVER_URL) private authServerUrl: string,
|
||||||
@inject(TYPES.SYNCING_SERVER_JS_URL) private syncingServerJsUrl: string,
|
@inject(TYPES.ApiGateway_SYNCING_SERVER_JS_URL) private syncingServerJsUrl: string,
|
||||||
@inject(TYPES.PAYMENTS_SERVER_URL) private paymentsServerUrl: string,
|
@inject(TYPES.ApiGateway_PAYMENTS_SERVER_URL) private paymentsServerUrl: string,
|
||||||
@inject(TYPES.FILES_SERVER_URL) private filesServerUrl: string,
|
@inject(TYPES.ApiGateway_FILES_SERVER_URL) private filesServerUrl: string,
|
||||||
@inject(TYPES.WEB_SOCKET_SERVER_URL) private webSocketServerUrl: string,
|
@inject(TYPES.ApiGateway_WEB_SOCKET_SERVER_URL) private webSocketServerUrl: string,
|
||||||
@inject(TYPES.REVISIONS_SERVER_URL) private revisionsServerUrl: string,
|
@inject(TYPES.ApiGateway_REVISIONS_SERVER_URL) private revisionsServerUrl: string,
|
||||||
@inject(TYPES.EMAIL_SERVER_URL) private emailServerUrl: string,
|
@inject(TYPES.ApiGateway_EMAIL_SERVER_URL) private emailServerUrl: string,
|
||||||
@inject(TYPES.HTTP_CALL_TIMEOUT) private httpCallTimeout: number,
|
@inject(TYPES.ApiGateway_HTTP_CALL_TIMEOUT) private httpCallTimeout: number,
|
||||||
@inject(TYPES.CrossServiceTokenCache) private crossServiceTokenCache: CrossServiceTokenCacheInterface,
|
@inject(TYPES.ApiGateway_CrossServiceTokenCache) private crossServiceTokenCache: CrossServiceTokenCacheInterface,
|
||||||
@inject(TYPES.Logger) private logger: Logger,
|
@inject(TYPES.ApiGateway_Logger) private logger: Logger,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async validateSession(
|
async validateSession(
|
||||||
@@ -130,19 +130,26 @@ export class HttpServiceProxy implements ServiceProxyInterface {
|
|||||||
response: Response,
|
response: Response,
|
||||||
endpointOrMethodIdentifier: string,
|
endpointOrMethodIdentifier: string,
|
||||||
payload?: Record<string, unknown> | string,
|
payload?: Record<string, unknown> | string,
|
||||||
): Promise<void> {
|
returnRawResponse?: boolean,
|
||||||
|
): Promise<void | Response<unknown, Record<string, unknown>>> {
|
||||||
if (!this.paymentsServerUrl) {
|
if (!this.paymentsServerUrl) {
|
||||||
this.logger.debug('Payments Server URL not defined. Skipped request to Payments API.')
|
this.logger.debug('Payments Server URL not defined. Skipped request to Payments API.')
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await this.callServerWithLegacyFormat(
|
|
||||||
|
const rawResponse = await this.callServerWithLegacyFormat(
|
||||||
this.paymentsServerUrl,
|
this.paymentsServerUrl,
|
||||||
request,
|
request,
|
||||||
response,
|
response,
|
||||||
endpointOrMethodIdentifier,
|
endpointOrMethodIdentifier,
|
||||||
payload,
|
payload,
|
||||||
|
returnRawResponse,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (returnRawResponse) {
|
||||||
|
return rawResponse
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async callAuthServerWithLegacyFormat(
|
async callAuthServerWithLegacyFormat(
|
||||||
@@ -279,7 +286,8 @@ export class HttpServiceProxy implements ServiceProxyInterface {
|
|||||||
response: Response,
|
response: Response,
|
||||||
endpointOrMethodIdentifier: string,
|
endpointOrMethodIdentifier: string,
|
||||||
payload?: Record<string, unknown> | string,
|
payload?: Record<string, unknown> | string,
|
||||||
): Promise<void> {
|
returnRawResponse?: boolean,
|
||||||
|
): Promise<void | Response<unknown, Record<string, unknown>>> {
|
||||||
const serviceResponse = await this.getServerResponse(
|
const serviceResponse = await this.getServerResponse(
|
||||||
serverUrl,
|
serverUrl,
|
||||||
request,
|
request,
|
||||||
@@ -295,9 +303,21 @@ export class HttpServiceProxy implements ServiceProxyInterface {
|
|||||||
this.applyResponseHeaders(serviceResponse, response)
|
this.applyResponseHeaders(serviceResponse, response)
|
||||||
|
|
||||||
if (serviceResponse.request._redirectable._redirectCount > 0) {
|
if (serviceResponse.request._redirectable._redirectCount > 0) {
|
||||||
response.status(302).redirect(serviceResponse.request.res.responseUrl)
|
response.status(302)
|
||||||
|
|
||||||
|
if (returnRawResponse) {
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
|
response.redirect(serviceResponse.request.res.responseUrl)
|
||||||
} else {
|
} else {
|
||||||
response.status(serviceResponse.status).send(serviceResponse.data)
|
response.status(serviceResponse.status)
|
||||||
|
|
||||||
|
if (returnRawResponse) {
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
|
response.send(serviceResponse.data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ export interface ServiceProxyInterface {
|
|||||||
response: Response,
|
response: Response,
|
||||||
endpointOrMethodIdentifier: string,
|
endpointOrMethodIdentifier: string,
|
||||||
payload?: Record<string, unknown> | string,
|
payload?: Record<string, unknown> | string,
|
||||||
): Promise<void>
|
returnRawResponse?: boolean,
|
||||||
|
): Promise<void | Response<unknown, Record<string, unknown>>>
|
||||||
callWebSocketServer(
|
callWebSocketServer(
|
||||||
request: Request,
|
request: Request,
|
||||||
response: Response,
|
response: Response,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Request, Response } from 'express'
|
import { Request, Response } from 'express'
|
||||||
|
import { ServiceContainerInterface, ServiceIdentifier } from '@standardnotes/domain-core'
|
||||||
|
|
||||||
import { ServiceProxyInterface } from '../Http/ServiceProxyInterface'
|
import { ServiceProxyInterface } from '../Http/ServiceProxyInterface'
|
||||||
import { ServiceContainerInterface, ServiceIdentifier } from '@standardnotes/domain-core'
|
|
||||||
|
|
||||||
export class DirectCallServiceProxy implements ServiceProxyInterface {
|
export class DirectCallServiceProxy implements ServiceProxyInterface {
|
||||||
constructor(private serviceContainer: ServiceContainerInterface, private filesServerUrl: string) {}
|
constructor(private serviceContainer: ServiceContainerInterface, private filesServerUrl: string) {}
|
||||||
@@ -34,8 +34,12 @@ export class DirectCallServiceProxy implements ServiceProxyInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async callEmailServer(_request: Request, _response: Response, _endpointOrMethodIdentifier: string): Promise<void> {
|
async callEmailServer(_request: Request, response: Response, _endpointOrMethodIdentifier: string): Promise<void> {
|
||||||
throw new Error('Email server is not available.')
|
response.status(400).send({
|
||||||
|
error: {
|
||||||
|
message: 'Email server is not available.',
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async callAuthServer(request: never, response: never, endpointOrMethodIdentifier: string): Promise<void> {
|
async callAuthServer(request: never, response: never, endpointOrMethodIdentifier: string): Promise<void> {
|
||||||
@@ -54,10 +58,14 @@ export class DirectCallServiceProxy implements ServiceProxyInterface {
|
|||||||
|
|
||||||
async callAuthServerWithLegacyFormat(
|
async callAuthServerWithLegacyFormat(
|
||||||
_request: Request,
|
_request: Request,
|
||||||
_response: Response,
|
response: Response,
|
||||||
_endpointOrMethodIdentifier: string,
|
_endpointOrMethodIdentifier: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
throw new Error('Legacy auth endpoints are no longer available.')
|
response.status(400).send({
|
||||||
|
error: {
|
||||||
|
message: 'Legacy auth endpoints are no longer available.',
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async callRevisionsServer(request: never, response: never, endpointOrMethodIdentifier: string): Promise<void> {
|
async callRevisionsServer(request: never, response: never, endpointOrMethodIdentifier: string): Promise<void> {
|
||||||
@@ -92,22 +100,30 @@ export class DirectCallServiceProxy implements ServiceProxyInterface {
|
|||||||
|
|
||||||
async callLegacySyncingServer(
|
async callLegacySyncingServer(
|
||||||
_request: Request,
|
_request: Request,
|
||||||
_response: Response,
|
response: Response,
|
||||||
_endpointOrMethodIdentifier: string,
|
_endpointOrMethodIdentifier: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
throw new Error('Legacy syncing server endpoints are no longer available.')
|
response.status(400).send({
|
||||||
|
error: {
|
||||||
|
message: 'Legacy syncing server endpoints are no longer available.',
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async callPaymentsServer(_request: Request, _response: Response, _endpointOrMethodIdentifier: string): Promise<void> {
|
async callPaymentsServer(_request: Request, response: Response, _endpointOrMethodIdentifier: string): Promise<void> {
|
||||||
throw new Error('Payments server is not available.')
|
response.status(400).send({
|
||||||
|
error: {
|
||||||
|
message: 'Payments server is not available.',
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async callWebSocketServer(
|
async callWebSocketServer(_request: Request, response: Response, _endpointOrMethodIdentifier: string): Promise<void> {
|
||||||
_request: Request,
|
response.status(400).send({
|
||||||
_response: Response,
|
error: {
|
||||||
_endpointOrMethodIdentifier: string,
|
message: 'Websockets server is not available.',
|
||||||
): Promise<void> {
|
},
|
||||||
throw new Error('Websockets server is not available.')
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private sendDecoratedResponse(
|
private sendDecoratedResponse(
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export class EndpointResolver implements EndpointResolverInterface {
|
|||||||
['[PATCH]:users/:userId', 'auth.users.update'],
|
['[PATCH]:users/:userId', 'auth.users.update'],
|
||||||
['[PUT]:users/:userUuid/attributes/credentials', 'auth.users.updateCredentials'],
|
['[PUT]:users/:userUuid/attributes/credentials', 'auth.users.updateCredentials'],
|
||||||
['[PUT]:auth/params', 'auth.users.getKeyParams'],
|
['[PUT]:auth/params', 'auth.users.getKeyParams'],
|
||||||
|
['[DELETE]:users/:userUuid', 'auth.users.delete'],
|
||||||
['[POST]:listed', 'auth.users.createListedAccount'],
|
['[POST]:listed', 'auth.users.createListedAccount'],
|
||||||
['[POST]:auth', 'auth.users.register'],
|
['[POST]:auth', 'auth.users.register'],
|
||||||
['[GET]:users/:userUuid/settings', 'auth.users.getSettings'],
|
['[GET]:users/:userUuid/settings', 'auth.users.getSettings'],
|
||||||
@@ -62,6 +63,32 @@ export class EndpointResolver implements EndpointResolverInterface {
|
|||||||
['[GET]:items/:itemUuid/revisions', 'revisions.revisions.getRevisions'],
|
['[GET]:items/:itemUuid/revisions', 'revisions.revisions.getRevisions'],
|
||||||
['[GET]:items/:itemUuid/revisions/:id', 'revisions.revisions.getRevision'],
|
['[GET]:items/:itemUuid/revisions/:id', 'revisions.revisions.getRevision'],
|
||||||
['[DELETE]:items/:itemUuid/revisions/:id', 'revisions.revisions.deleteRevision'],
|
['[DELETE]:items/:itemUuid/revisions/:id', 'revisions.revisions.deleteRevision'],
|
||||||
|
// Messages Controller
|
||||||
|
['[GET]:messages/', 'sync.messages.get-received'],
|
||||||
|
['[GET]:messages/outbound', 'sync.messages.get-sent'],
|
||||||
|
['[POST]:messages/', 'sync.messages.send'],
|
||||||
|
['[DELETE]:messages/inbound', 'sync.messages.delete-all'],
|
||||||
|
['[DELETE]:messages/:messageUuid', 'sync.messages.delete'],
|
||||||
|
// Shared Vaults Controller
|
||||||
|
['[GET]:shared-vaults/', 'sync.shared-vaults.get-vaults'],
|
||||||
|
['[POST]:shared-vaults/', 'sync.shared-vaults.create-vault'],
|
||||||
|
['[DELETE]:shared-vaults/:sharedVaultUuid', 'sync.shared-vaults.delete-vault'],
|
||||||
|
['[POST]:shared-vaults/:sharedVaultUuid/valet-tokens', 'sync.shared-vaults.create-file-valet-token'],
|
||||||
|
// Shared Vault Invites Controller
|
||||||
|
['[POST]:shared-vaults/:sharedVaultUuid/invites', 'sync.shared-vault-invites.create'],
|
||||||
|
['[PATCH]:shared-vaults/:sharedVaultUuid/invites/:inviteUuid', 'sync.shared-vault-invites.update'],
|
||||||
|
['[POST]:shared-vaults/:sharedVaultUuid/invites/:inviteUuid/accept', 'sync.shared-vault-invites.accept'],
|
||||||
|
['[POST]:shared-vaults/:sharedVaultUuid/invites/:inviteUuid/decline', 'sync.shared-vault-invites.decline'],
|
||||||
|
['[DELETE]:shared-vaults/invites/inbound', 'sync.shared-vault-invites.delete-inbound'],
|
||||||
|
['[DELETE]:shared-vaults/invites/outbound', 'sync.shared-vault-invites.delete-outbound'],
|
||||||
|
['[GET]:shared-vaults/invites/outbound', 'sync.shared-vault-invites.get-outbound'],
|
||||||
|
['[GET]:shared-vaults/invites', 'sync.shared-vault-invites.get-user-invites'],
|
||||||
|
['[GET]:shared-vaults/:sharedVaultUuid/invites', 'sync.shared-vault-invites.get-vault-invites'],
|
||||||
|
['[DELETE]:shared-vaults/:sharedVaultUuid/invites/:inviteUuid', 'sync.shared-vault-invites.delete-invite'],
|
||||||
|
['[DELETE]:shared-vaults/:sharedVaultUuid/invites', 'sync.shared-vault-invites.delete-all'],
|
||||||
|
// Shared Vault Users Controller
|
||||||
|
['[GET]:shared-vaults/:sharedVaultUuid/users', 'sync.shared-vault-users.get-users'],
|
||||||
|
['[DELETE]:shared-vaults/:sharedVaultUuid/users/:userUuid', 'sync.shared-vault-users.remove-user'],
|
||||||
])
|
])
|
||||||
|
|
||||||
resolveEndpointOrMethodIdentifier(method: string, endpoint: string, ...params: string[]): string {
|
resolveEndpointOrMethodIdentifier(method: string, endpoint: string, ...params: string[]): string {
|
||||||
@@ -75,7 +102,7 @@ export class EndpointResolver implements EndpointResolverInterface {
|
|||||||
const identifier = this.endpointToIdentifierMap.get(`[${method}]:${endpoint}`)
|
const identifier = this.endpointToIdentifierMap.get(`[${method}]:${endpoint}`)
|
||||||
|
|
||||||
if (!identifier) {
|
if (!identifier) {
|
||||||
throw new Error(`Endpoint ${endpoint} not found`)
|
throw new Error(`Endpoint [${method}]:${endpoint} not found`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return identifier
|
return identifier
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
MODE=microservice # microservice | home-server
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
VERSION=development
|
VERSION=development
|
||||||
@@ -20,8 +21,10 @@ DB_USERNAME=auth
|
|||||||
DB_PASSWORD=changeme123
|
DB_PASSWORD=changeme123
|
||||||
DB_DATABASE=auth
|
DB_DATABASE=auth
|
||||||
DB_DEBUG_LEVEL=all # "all" | "query" | "schema" | "error" | "warn" | "info" | "log" | "migration"
|
DB_DEBUG_LEVEL=all # "all" | "query" | "schema" | "error" | "warn" | "info" | "log" | "migration"
|
||||||
|
DB_TYPE=mysql
|
||||||
|
|
||||||
REDIS_URL=redis://cache
|
REDIS_URL=redis://cache
|
||||||
|
CACHE_TYPE=redis
|
||||||
|
|
||||||
DISABLE_USER_REGISTRATION=false
|
DISABLE_USER_REGISTRATION=false
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,202 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||||
|
|
||||||
|
## [1.128.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.128.0...@standardnotes/auth-server@1.128.1) (2023-08-02)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
# [1.128.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.127.2...@standardnotes/auth-server@1.128.0) (2023-08-02)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* enable Write Ahead Log mode for SQLite ([#681](https://github.com/standardnotes/server/issues/681)) ([8cd7a13](https://github.com/standardnotes/server/commit/8cd7a138ab56f6a2b0d6c06ef6041ab9b85ae540))
|
||||||
|
|
||||||
|
## [1.127.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.127.1...@standardnotes/auth-server@1.127.2) (2023-08-01)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* controller naming ([#678](https://github.com/standardnotes/server/issues/678)) ([56f0aef](https://github.com/standardnotes/server/commit/56f0aef21d3fcec7ac7e968cb1c1b071becbbe26))
|
||||||
|
|
||||||
|
## [1.127.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.127.0...@standardnotes/auth-server@1.127.1) (2023-07-31)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **auth:** auth middleware on delete account ([318af57](https://github.com/standardnotes/server/commit/318af5757d6c42f580157647b22112a9936765e7))
|
||||||
|
|
||||||
|
# [1.127.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.126.5...@standardnotes/auth-server@1.127.0) (2023-07-31)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* refactor deleting account ([#676](https://github.com/standardnotes/server/issues/676)) ([0d5dcdd](https://github.com/standardnotes/server/commit/0d5dcdd8ec2336e41e7604c4157f79a89163ed29))
|
||||||
|
|
||||||
|
## [1.126.5](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.126.4...@standardnotes/auth-server@1.126.5) (2023-07-27)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
## [1.126.4](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.126.3...@standardnotes/auth-server@1.126.4) (2023-07-26)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
## [1.126.3](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.126.2...@standardnotes/auth-server@1.126.3) (2023-07-26)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
## [1.126.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.126.1...@standardnotes/auth-server@1.126.2) (2023-07-21)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
## [1.126.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.126.0...@standardnotes/auth-server@1.126.1) (2023-07-21)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
# [1.126.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.125.1...@standardnotes/auth-server@1.126.0) (2023-07-20)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **syncing-server:** add shared vaults, invites, messages and notifications to sync response ([#665](https://github.com/standardnotes/server/issues/665)) ([efa4d7f](https://github.com/standardnotes/server/commit/efa4d7fc6007ef668e3de3b04853ac11b2d13c30))
|
||||||
|
|
||||||
|
## [1.125.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.125.0...@standardnotes/auth-server@1.125.1) (2023-07-19)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
# [1.125.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.124.2...@standardnotes/auth-server@1.125.0) (2023-07-17)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **syncing-server:** refactor syncing to decouple getting and saving items ([#659](https://github.com/standardnotes/server/issues/659)) ([cb74b23](https://github.com/standardnotes/server/commit/cb74b23e45b207136e299ce8a3db2c04dc87e21e))
|
||||||
|
|
||||||
|
## [1.124.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.124.1...@standardnotes/auth-server@1.124.2) (2023-07-14)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** allow custom atributtes for activating premium features ([f7190c0](https://github.com/standardnotes/server/commit/f7190c0c9c2d105f97d1cf980ce6a4f0dae34805))
|
||||||
|
|
||||||
|
## [1.124.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.124.0...@standardnotes/auth-server@1.124.1) (2023-07-13)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **files:** handling unlimited storage quota on home server ([9be3517](https://github.com/standardnotes/server/commit/9be3517093f8dd7bbdd7507c1e2ff059e6c9a889))
|
||||||
|
|
||||||
|
# [1.124.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.123.2...@standardnotes/auth-server@1.124.0) (2023-07-13)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **auth:** add overriding subscription settings on home server ([#656](https://github.com/standardnotes/server/issues/656)) ([0b82794](https://github.com/standardnotes/server/commit/0b82794e9c7ed82cfc08a92eafc016fbde5c4fcc))
|
||||||
|
|
||||||
|
## [1.123.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.123.1...@standardnotes/auth-server@1.123.2) (2023-07-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
## [1.123.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.123.0...@standardnotes/auth-server@1.123.1) (2023-07-12)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
# [1.123.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.122.2...@standardnotes/auth-server@1.123.0) (2023-07-12)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* domain items ([#655](https://github.com/standardnotes/server/issues/655)) ([a0af8f0](https://github.com/standardnotes/server/commit/a0af8f00252e1219e58cb7e066c11a8e71692e9d))
|
||||||
|
|
||||||
|
## [1.122.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.122.1...@standardnotes/auth-server@1.122.2) (2023-07-07)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* transfer notifications from auth to syncing-server. ([#648](https://github.com/standardnotes/server/issues/648)) ([c288e5d](https://github.com/standardnotes/server/commit/c288e5d8dc54778a96a9fc33e3c9cae00583fade))
|
||||||
|
|
||||||
|
## [1.122.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.122.0...@standardnotes/auth-server@1.122.1) (2023-07-06)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
# [1.122.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.121.0...@standardnotes/auth-server@1.122.0) (2023-07-05)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* deleting shared vaults. ([#640](https://github.com/standardnotes/server/issues/640)) ([f3161c2](https://github.com/standardnotes/server/commit/f3161c271296159331639814b2dbb2e566cc54c9))
|
||||||
|
|
||||||
|
# [1.121.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.120.2...@standardnotes/auth-server@1.121.0) (2023-07-05)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **auth:** add notifications model ([#638](https://github.com/standardnotes/server/issues/638)) ([fecfd54](https://github.com/standardnotes/server/commit/fecfd5472824b5adae708db95d351e4ad65ee87b))
|
||||||
|
|
||||||
|
## [1.120.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.120.1...@standardnotes/auth-server@1.120.2) (2023-06-30)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
## [1.120.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.120.0...@standardnotes/auth-server@1.120.1) (2023-06-30)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
# [1.120.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.119.6...@standardnotes/auth-server@1.120.0) (2023-06-30)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* shared vaults functionality in api-gateway,auth,files,common,security,domain-events. ([#629](https://github.com/standardnotes/server/issues/629)) ([fa7fbe2](https://github.com/standardnotes/server/commit/fa7fbe26e7b0707fc21d71e04af76870f5248baf))
|
||||||
|
|
||||||
|
## [1.119.6](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.119.5...@standardnotes/auth-server@1.119.6) (2023-06-28)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **auth:** add debug logs for authentication method resolver ([d220ec5](https://github.com/standardnotes/server/commit/d220ec5bf7509f9eb19dcda71c3667aaf388a35b))
|
||||||
|
|
||||||
|
## [1.119.5](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.119.4...@standardnotes/auth-server@1.119.5) (2023-06-28)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add debug logs for invalid-auth responses ([d5a8409](https://github.com/standardnotes/server/commit/d5a8409bb5d35b9caf410a36ea0d5cb747129e8d))
|
||||||
|
|
||||||
|
## [1.119.4](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.119.3...@standardnotes/auth-server@1.119.4) (2023-06-28)
|
||||||
|
|
||||||
|
**Note:** Version bump only for package @standardnotes/auth-server
|
||||||
|
|
||||||
|
## [1.119.3](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.119.2...@standardnotes/auth-server@1.119.3) (2023-06-22)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** add debug logs about container initalizations ([0df4715](https://github.com/standardnotes/server/commit/0df471585fd5b4626ec2972f3b9a3e33b2830e65))
|
||||||
|
|
||||||
|
## [1.119.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.119.1...@standardnotes/auth-server@1.119.2) (2023-06-14)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** env var determining the sqlite database location ([#626](https://github.com/standardnotes/server/issues/626)) ([0cb5e36](https://github.com/standardnotes/server/commit/0cb5e36b20d9b095ea0edbcd877387e6c0069856))
|
||||||
|
|
||||||
|
## [1.119.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.119.0...@standardnotes/auth-server@1.119.1) (2023-06-09)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** add default value for valet token ttl ([c201ee4](https://github.com/standardnotes/server/commit/c201ee42a00d9e5402afea2f2c5848a362c1529e))
|
||||||
|
|
||||||
|
# [1.119.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.118.0...@standardnotes/auth-server@1.119.0) (2023-06-09)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **home-server:** add activating premium features ([#624](https://github.com/standardnotes/server/issues/624)) ([72ce190](https://github.com/standardnotes/server/commit/72ce1909960fbd2ec6a47b8dbdfbe53a4f10e776))
|
||||||
|
|
||||||
|
# [1.118.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.117.0...@standardnotes/auth-server@1.118.0) (2023-06-07)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* configurable path for uploads and db ([#623](https://github.com/standardnotes/server/issues/623)) ([af8feaa](https://github.com/standardnotes/server/commit/af8feaadfe2dd58baab4cca217d6307b4a221326))
|
||||||
|
|
||||||
|
# [1.117.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.116.2...@standardnotes/auth-server@1.117.0) (2023-06-05)
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **home-server:** allow running the home server with a mysql and redis configuration ([#622](https://github.com/standardnotes/server/issues/622)) ([d6e531d](https://github.com/standardnotes/server/commit/d6e531d4b6c1c80a894f6d7ec93632595268dd64))
|
||||||
|
|
||||||
|
## [1.116.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.116.1...@standardnotes/auth-server@1.116.2) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **home-server:** streaming logs ([a8b806a](https://github.com/standardnotes/server/commit/a8b806af084b3e3fe8707ff0cb041a74042ee049))
|
||||||
|
|
||||||
|
## [1.116.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.116.0...@standardnotes/auth-server@1.116.1) (2023-06-02)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* initializing data source with already configured environment ([624b574](https://github.com/standardnotes/server/commit/624b574013157e9e044d4a8ed53cadb7fcc567ae))
|
||||||
|
|
||||||
# [1.116.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.115.5...@standardnotes/auth-server@1.116.0) (2023-06-02)
|
# [1.116.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.115.5...@standardnotes/auth-server@1.116.0) (2023-06-02)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
+18
-18
@@ -1,23 +1,23 @@
|
|||||||
import 'reflect-metadata'
|
import 'reflect-metadata'
|
||||||
|
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressAuthController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedAuthController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressAuthenticatorsController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedAuthenticatorsController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressSessionsController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedSessionsController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressSubscriptionInvitesController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedSubscriptionInvitesController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressUserRequestsController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedUserRequestsController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressWebSocketsController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedWebSocketsController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressUsersController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedUsersController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressValetTokenController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedValetTokenController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressAdminController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedAdminController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressSubscriptionTokensController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedSubscriptionTokensController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressSubscriptionSettingsController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedSubscriptionSettingsController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressSettingsController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedSettingsController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressSessionController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedSessionController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressOfflineController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedOfflineController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressListedController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedListedController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressInternalController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedInternalController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressHealthCheckController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedHealthCheckController'
|
||||||
import '../src/Infra/InversifyExpressUtils/InversifyExpressFeaturesController'
|
import '../src/Infra/InversifyExpressUtils/AnnotatedFeaturesController'
|
||||||
|
|
||||||
import * as cors from 'cors'
|
import * as cors from 'cors'
|
||||||
import { urlencoded, json, Request, Response, NextFunction } from 'express'
|
import { urlencoded, json, Request, Response, NextFunction } from 'express'
|
||||||
|
|||||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@standardnotes/auth-server",
|
"name": "@standardnotes/auth-server",
|
||||||
"version": "1.116.0",
|
"version": "1.128.1",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0 <21.0.0"
|
"node": ">=18.0.0 <21.0.0"
|
||||||
},
|
},
|
||||||
@@ -32,7 +32,8 @@
|
|||||||
"weekly-backup:email": "yarn node dist/bin/backup.js email weekly",
|
"weekly-backup:email": "yarn node dist/bin/backup.js email weekly",
|
||||||
"content-recalculation": "yarn node dist/bin/content.js",
|
"content-recalculation": "yarn node dist/bin/content.js",
|
||||||
"typeorm": "typeorm-ts-node-commonjs",
|
"typeorm": "typeorm-ts-node-commonjs",
|
||||||
"upgrade:snjs": "yarn ncu -u '@standardnotes/*'"
|
"upgrade:snjs": "yarn ncu -u '@standardnotes/*'",
|
||||||
|
"migrate": "yarn build && yarn typeorm migration:run -d dist/src/Bootstrap/DataSource.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-sns": "^3.332.0",
|
"@aws-sdk/client-sns": "^3.332.0",
|
||||||
@@ -41,17 +42,17 @@
|
|||||||
"@cbor-extract/cbor-extract-linux-x64": "^2.1.1",
|
"@cbor-extract/cbor-extract-linux-x64": "^2.1.1",
|
||||||
"@simplewebauthn/server": "^7.2.0",
|
"@simplewebauthn/server": "^7.2.0",
|
||||||
"@simplewebauthn/typescript-types": "^7.0.0",
|
"@simplewebauthn/typescript-types": "^7.0.0",
|
||||||
"@standardnotes/api": "^1.25.3",
|
"@standardnotes/api": "^1.26.26",
|
||||||
"@standardnotes/common": "workspace:*",
|
"@standardnotes/common": "workspace:*",
|
||||||
"@standardnotes/domain-core": "workspace:^",
|
"@standardnotes/domain-core": "workspace:^",
|
||||||
"@standardnotes/domain-events": "workspace:*",
|
"@standardnotes/domain-events": "workspace:*",
|
||||||
"@standardnotes/domain-events-infra": "workspace:*",
|
"@standardnotes/domain-events-infra": "workspace:*",
|
||||||
"@standardnotes/features": "^1.58.12",
|
"@standardnotes/features": "^1.59.7",
|
||||||
"@standardnotes/predicates": "workspace:*",
|
"@standardnotes/predicates": "workspace:*",
|
||||||
"@standardnotes/responses": "^1.13.9",
|
"@standardnotes/responses": "^1.13.27",
|
||||||
"@standardnotes/security": "workspace:*",
|
"@standardnotes/security": "workspace:*",
|
||||||
"@standardnotes/settings": "workspace:*",
|
"@standardnotes/settings": "workspace:*",
|
||||||
"@standardnotes/sncrypto-common": "^1.9.0",
|
"@standardnotes/sncrypto-common": "^1.13.4",
|
||||||
"@standardnotes/sncrypto-node": "workspace:*",
|
"@standardnotes/sncrypto-node": "workspace:*",
|
||||||
"@standardnotes/time": "workspace:*",
|
"@standardnotes/time": "workspace:*",
|
||||||
"axios": "^1.1.3",
|
"axios": "^1.1.3",
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { Result, ServiceInterface } from '@standardnotes/domain-core'
|
||||||
|
|
||||||
|
export interface AuthServiceInterface extends ServiceInterface {
|
||||||
|
activatePremiumFeatures(dto: {
|
||||||
|
username: string
|
||||||
|
subscriptionPlanName?: string
|
||||||
|
endsAt?: Date
|
||||||
|
}): Promise<Result<string>>
|
||||||
|
}
|
||||||
@@ -234,23 +234,24 @@ import { OfflineUserAuthMiddleware } from '../Infra/InversifyExpressUtils/Middle
|
|||||||
import { LockMiddleware } from '../Infra/InversifyExpressUtils/Middleware/LockMiddleware'
|
import { LockMiddleware } from '../Infra/InversifyExpressUtils/Middleware/LockMiddleware'
|
||||||
import { RequiredCrossServiceTokenMiddleware } from '../Infra/InversifyExpressUtils/Middleware/RequiredCrossServiceTokenMiddleware'
|
import { RequiredCrossServiceTokenMiddleware } from '../Infra/InversifyExpressUtils/Middleware/RequiredCrossServiceTokenMiddleware'
|
||||||
import { OptionalCrossServiceTokenMiddleware } from '../Infra/InversifyExpressUtils/Middleware/OptionalCrossServiceTokenMiddleware'
|
import { OptionalCrossServiceTokenMiddleware } from '../Infra/InversifyExpressUtils/Middleware/OptionalCrossServiceTokenMiddleware'
|
||||||
import { HomeServerSettingsController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerSettingsController'
|
import { BaseSettingsController } from '../Infra/InversifyExpressUtils/Base/BaseSettingsController'
|
||||||
import { HomeServerAdminController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerAdminController'
|
import { BaseAdminController } from '../Infra/InversifyExpressUtils/Base/BaseAdminController'
|
||||||
import { HomeServerAuthController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerAuthController'
|
import { BaseAuthController } from '../Infra/InversifyExpressUtils/Base/BaseAuthController'
|
||||||
import { HomeServerAuthenticatorsController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerAuthenticatorsController'
|
import { BaseAuthenticatorsController } from '../Infra/InversifyExpressUtils/Base/BaseAuthenticatorsController'
|
||||||
import { HomeServerFeaturesController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerFeaturesController'
|
import { BaseFeaturesController } from '../Infra/InversifyExpressUtils/Base/BaseFeaturesController'
|
||||||
import { HomeServerListedController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerListedController'
|
import { BaseListedController } from '../Infra/InversifyExpressUtils/Base/BaseListedController'
|
||||||
import { HomeServerOfflineController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerOfflineController'
|
import { BaseOfflineController } from '../Infra/InversifyExpressUtils/Base/BaseOfflineController'
|
||||||
import { HomeServerSessionController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerSessionController'
|
import { BaseSessionController } from '../Infra/InversifyExpressUtils/Base/BaseSessionController'
|
||||||
import { HomeServerSubscriptionInvitesController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerSubscriptionInvitesController'
|
import { BaseSubscriptionInvitesController } from '../Infra/InversifyExpressUtils/Base/BaseSubscriptionInvitesController'
|
||||||
import { HomeServerSubscriptionSettingsController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerSubscriptionSettingsController'
|
import { BaseSubscriptionSettingsController } from '../Infra/InversifyExpressUtils/Base/BaseSubscriptionSettingsController'
|
||||||
import { HomeServerSubscriptionTokensController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerSubscriptionTokensController'
|
import { BaseSubscriptionTokensController } from '../Infra/InversifyExpressUtils/Base/BaseSubscriptionTokensController'
|
||||||
import { HomeServerUserRequestsController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerUserRequestsController'
|
import { BaseUserRequestsController } from '../Infra/InversifyExpressUtils/Base/BaseUserRequestsController'
|
||||||
import { HomeServerUsersController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerUsersController'
|
import { BaseUsersController } from '../Infra/InversifyExpressUtils/Base/BaseUsersController'
|
||||||
import { HomeServerValetTokenController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerValetTokenController'
|
import { BaseValetTokenController } from '../Infra/InversifyExpressUtils/Base/BaseValetTokenController'
|
||||||
import { HomeServerWebSocketsController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerWebSocketsController'
|
import { BaseWebSocketsController } from '../Infra/InversifyExpressUtils/Base/BaseWebSocketsController'
|
||||||
import { HomeServerSessionsController } from '../Infra/InversifyExpressUtils/HomeServer/HomeServerSessionsController'
|
import { BaseSessionsController } from '../Infra/InversifyExpressUtils/Base/BaseSessionsController'
|
||||||
import { Transform } from 'stream'
|
import { Transform } from 'stream'
|
||||||
|
import { ActivatePremiumFeatures } from '../Domain/UseCase/ActivatePremiumFeatures/ActivatePremiumFeatures'
|
||||||
|
|
||||||
export class ContainerConfigLoader {
|
export class ContainerConfigLoader {
|
||||||
async load(configuration?: {
|
async load(configuration?: {
|
||||||
@@ -267,11 +268,37 @@ export class ContainerConfigLoader {
|
|||||||
|
|
||||||
const container = new Container()
|
const container = new Container()
|
||||||
|
|
||||||
await AppDataSource.initialize()
|
const winstonFormatters = [winston.format.splat(), winston.format.json()]
|
||||||
|
if (env.get('NEW_RELIC_ENABLED', true) === 'true') {
|
||||||
|
await import('newrelic')
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
|
const newrelicFormatter = require('@newrelic/winston-enricher')
|
||||||
|
const newrelicWinstonFormatter = newrelicFormatter(winston)
|
||||||
|
winstonFormatters.push(newrelicWinstonFormatter())
|
||||||
|
}
|
||||||
|
|
||||||
const isConfiguredForHomeServer = env.get('DB_TYPE') === 'sqlite'
|
let logger: winston.Logger
|
||||||
|
if (configuration?.logger) {
|
||||||
|
logger = configuration.logger as winston.Logger
|
||||||
|
} else {
|
||||||
|
logger = winston.createLogger({
|
||||||
|
level: env.get('LOG_LEVEL', true) || 'info',
|
||||||
|
format: winston.format.combine(...winstonFormatters),
|
||||||
|
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL', true) || 'info' })],
|
||||||
|
defaultMeta: { service: 'auth' },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
container.bind<winston.Logger>(TYPES.Auth_Logger).toConstantValue(logger)
|
||||||
|
|
||||||
if (!isConfiguredForHomeServer) {
|
const appDataSource = new AppDataSource(env)
|
||||||
|
await appDataSource.initialize()
|
||||||
|
|
||||||
|
logger.debug('Database initialized')
|
||||||
|
|
||||||
|
const isConfiguredForHomeServer = env.get('MODE', true) === 'home-server'
|
||||||
|
const isConfiguredForInMemoryCache = env.get('CACHE_TYPE', true) === 'memory'
|
||||||
|
|
||||||
|
if (!isConfiguredForInMemoryCache) {
|
||||||
const redisUrl = env.get('REDIS_URL')
|
const redisUrl = env.get('REDIS_URL')
|
||||||
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
|
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
|
||||||
let redis
|
let redis
|
||||||
@@ -284,27 +311,6 @@ export class ContainerConfigLoader {
|
|||||||
container.bind(TYPES.Auth_Redis).toConstantValue(redis)
|
container.bind(TYPES.Auth_Redis).toConstantValue(redis)
|
||||||
}
|
}
|
||||||
|
|
||||||
const winstonFormatters = [winston.format.splat(), winston.format.json()]
|
|
||||||
if (env.get('NEW_RELIC_ENABLED', true) === 'true') {
|
|
||||||
await import('newrelic')
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
||||||
const newrelicFormatter = require('@newrelic/winston-enricher')
|
|
||||||
const newrelicWinstonFormatter = newrelicFormatter(winston)
|
|
||||||
winstonFormatters.push(newrelicWinstonFormatter())
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configuration?.logger) {
|
|
||||||
container.bind<winston.Logger>(TYPES.Auth_Logger).toConstantValue(configuration.logger as winston.Logger)
|
|
||||||
} else {
|
|
||||||
const logger = winston.createLogger({
|
|
||||||
level: env.get('LOG_LEVEL') || 'info',
|
|
||||||
format: winston.format.combine(...winstonFormatters),
|
|
||||||
transports: [new winston.transports.Console({ level: env.get('LOG_LEVEL') || 'info' })],
|
|
||||||
defaultMeta: { service: 'auth' },
|
|
||||||
})
|
|
||||||
container.bind<winston.Logger>(TYPES.Auth_Logger).toConstantValue(logger)
|
|
||||||
}
|
|
||||||
|
|
||||||
container.bind<TimerInterface>(TYPES.Auth_Timer).toConstantValue(new Timer())
|
container.bind<TimerInterface>(TYPES.Auth_Timer).toConstantValue(new Timer())
|
||||||
|
|
||||||
if (!isConfiguredForHomeServer) {
|
if (!isConfiguredForHomeServer) {
|
||||||
@@ -359,42 +365,42 @@ export class ContainerConfigLoader {
|
|||||||
// ORM
|
// ORM
|
||||||
container
|
container
|
||||||
.bind<Repository<OfflineSetting>>(TYPES.Auth_ORMOfflineSettingRepository)
|
.bind<Repository<OfflineSetting>>(TYPES.Auth_ORMOfflineSettingRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(OfflineSetting))
|
.toConstantValue(appDataSource.getRepository(OfflineSetting))
|
||||||
container
|
container
|
||||||
.bind<Repository<OfflineUserSubscription>>(TYPES.Auth_ORMOfflineUserSubscriptionRepository)
|
.bind<Repository<OfflineUserSubscription>>(TYPES.Auth_ORMOfflineUserSubscriptionRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(OfflineUserSubscription))
|
.toConstantValue(appDataSource.getRepository(OfflineUserSubscription))
|
||||||
container
|
container
|
||||||
.bind<Repository<RevokedSession>>(TYPES.Auth_ORMRevokedSessionRepository)
|
.bind<Repository<RevokedSession>>(TYPES.Auth_ORMRevokedSessionRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(RevokedSession))
|
.toConstantValue(appDataSource.getRepository(RevokedSession))
|
||||||
container.bind<Repository<Role>>(TYPES.Auth_ORMRoleRepository).toConstantValue(AppDataSource.getRepository(Role))
|
container.bind<Repository<Role>>(TYPES.Auth_ORMRoleRepository).toConstantValue(appDataSource.getRepository(Role))
|
||||||
container
|
container
|
||||||
.bind<Repository<Session>>(TYPES.Auth_ORMSessionRepository)
|
.bind<Repository<Session>>(TYPES.Auth_ORMSessionRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(Session))
|
.toConstantValue(appDataSource.getRepository(Session))
|
||||||
container
|
container
|
||||||
.bind<Repository<Setting>>(TYPES.Auth_ORMSettingRepository)
|
.bind<Repository<Setting>>(TYPES.Auth_ORMSettingRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(Setting))
|
.toConstantValue(appDataSource.getRepository(Setting))
|
||||||
container
|
container
|
||||||
.bind<Repository<SharedSubscriptionInvitation>>(TYPES.Auth_ORMSharedSubscriptionInvitationRepository)
|
.bind<Repository<SharedSubscriptionInvitation>>(TYPES.Auth_ORMSharedSubscriptionInvitationRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(SharedSubscriptionInvitation))
|
.toConstantValue(appDataSource.getRepository(SharedSubscriptionInvitation))
|
||||||
container
|
container
|
||||||
.bind<Repository<SubscriptionSetting>>(TYPES.Auth_ORMSubscriptionSettingRepository)
|
.bind<Repository<SubscriptionSetting>>(TYPES.Auth_ORMSubscriptionSettingRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(SubscriptionSetting))
|
.toConstantValue(appDataSource.getRepository(SubscriptionSetting))
|
||||||
container.bind<Repository<User>>(TYPES.Auth_ORMUserRepository).toConstantValue(AppDataSource.getRepository(User))
|
container.bind<Repository<User>>(TYPES.Auth_ORMUserRepository).toConstantValue(appDataSource.getRepository(User))
|
||||||
container
|
container
|
||||||
.bind<Repository<UserSubscription>>(TYPES.Auth_ORMUserSubscriptionRepository)
|
.bind<Repository<UserSubscription>>(TYPES.Auth_ORMUserSubscriptionRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(UserSubscription))
|
.toConstantValue(appDataSource.getRepository(UserSubscription))
|
||||||
container
|
container
|
||||||
.bind<Repository<TypeORMSessionTrace>>(TYPES.Auth_ORMSessionTraceRepository)
|
.bind<Repository<TypeORMSessionTrace>>(TYPES.Auth_ORMSessionTraceRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(TypeORMSessionTrace))
|
.toConstantValue(appDataSource.getRepository(TypeORMSessionTrace))
|
||||||
container
|
container
|
||||||
.bind<Repository<TypeORMAuthenticator>>(TYPES.Auth_ORMAuthenticatorRepository)
|
.bind<Repository<TypeORMAuthenticator>>(TYPES.Auth_ORMAuthenticatorRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(TypeORMAuthenticator))
|
.toConstantValue(appDataSource.getRepository(TypeORMAuthenticator))
|
||||||
container
|
container
|
||||||
.bind<Repository<TypeORMAuthenticatorChallenge>>(TYPES.Auth_ORMAuthenticatorChallengeRepository)
|
.bind<Repository<TypeORMAuthenticatorChallenge>>(TYPES.Auth_ORMAuthenticatorChallengeRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(TypeORMAuthenticatorChallenge))
|
.toConstantValue(appDataSource.getRepository(TypeORMAuthenticatorChallenge))
|
||||||
container
|
container
|
||||||
.bind<Repository<TypeORMCacheEntry>>(TYPES.Auth_ORMCacheEntryRepository)
|
.bind<Repository<TypeORMCacheEntry>>(TYPES.Auth_ORMCacheEntryRepository)
|
||||||
.toConstantValue(AppDataSource.getRepository(TypeORMCacheEntry))
|
.toConstantValue(appDataSource.getRepository(TypeORMCacheEntry))
|
||||||
|
|
||||||
// Repositories
|
// Repositories
|
||||||
container.bind<SessionRepositoryInterface>(TYPES.Auth_SessionRepository).to(TypeORMSessionRepository)
|
container.bind<SessionRepositoryInterface>(TYPES.Auth_SessionRepository).to(TypeORMSessionRepository)
|
||||||
@@ -487,7 +493,9 @@ export class ContainerConfigLoader {
|
|||||||
.bind(TYPES.Auth_AUTH_JWT_TTL)
|
.bind(TYPES.Auth_AUTH_JWT_TTL)
|
||||||
.toConstantValue(env.get('AUTH_JWT_TTL', true) ? +env.get('AUTH_JWT_TTL') : 60_000)
|
.toConstantValue(env.get('AUTH_JWT_TTL', true) ? +env.get('AUTH_JWT_TTL') : 60_000)
|
||||||
container.bind(TYPES.Auth_VALET_TOKEN_SECRET).toConstantValue(env.get('VALET_TOKEN_SECRET', true))
|
container.bind(TYPES.Auth_VALET_TOKEN_SECRET).toConstantValue(env.get('VALET_TOKEN_SECRET', true))
|
||||||
container.bind(TYPES.Auth_VALET_TOKEN_TTL).toConstantValue(+env.get('VALET_TOKEN_TTL', true))
|
container
|
||||||
|
.bind(TYPES.Auth_VALET_TOKEN_TTL)
|
||||||
|
.toConstantValue(env.get('VALET_TOKEN_TTL', true) ? +env.get('VALET_TOKEN_TTL', true) : 7200)
|
||||||
container
|
container
|
||||||
.bind(TYPES.Auth_WEB_SOCKET_CONNECTION_TOKEN_SECRET)
|
.bind(TYPES.Auth_WEB_SOCKET_CONNECTION_TOKEN_SECRET)
|
||||||
.toConstantValue(env.get('WEB_SOCKET_CONNECTION_TOKEN_SECRET', true))
|
.toConstantValue(env.get('WEB_SOCKET_CONNECTION_TOKEN_SECRET', true))
|
||||||
@@ -549,7 +557,16 @@ export class ContainerConfigLoader {
|
|||||||
.bind(TYPES.Auth_READONLY_USERS)
|
.bind(TYPES.Auth_READONLY_USERS)
|
||||||
.toConstantValue(env.get('READONLY_USERS', true) ? env.get('READONLY_USERS', true).split(',') : [])
|
.toConstantValue(env.get('READONLY_USERS', true) ? env.get('READONLY_USERS', true).split(',') : [])
|
||||||
|
|
||||||
if (isConfiguredForHomeServer) {
|
if (isConfiguredForInMemoryCache) {
|
||||||
|
container
|
||||||
|
.bind<PKCERepositoryInterface>(TYPES.Auth_PKCERepository)
|
||||||
|
.toConstantValue(
|
||||||
|
new TypeORMPKCERepository(
|
||||||
|
container.get(TYPES.Auth_CacheEntryRepository),
|
||||||
|
container.get(TYPES.Auth_Logger),
|
||||||
|
container.get(TYPES.Auth_Timer),
|
||||||
|
),
|
||||||
|
)
|
||||||
container
|
container
|
||||||
.bind<LockRepositoryInterface>(TYPES.Auth_LockRepository)
|
.bind<LockRepositoryInterface>(TYPES.Auth_LockRepository)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
@@ -577,15 +594,6 @@ export class ContainerConfigLoader {
|
|||||||
container.get(TYPES.Auth_Timer),
|
container.get(TYPES.Auth_Timer),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
|
||||||
.bind<PKCERepositoryInterface>(TYPES.Auth_PKCERepository)
|
|
||||||
.toConstantValue(
|
|
||||||
new TypeORMPKCERepository(
|
|
||||||
container.get(TYPES.Auth_CacheEntryRepository),
|
|
||||||
container.get(TYPES.Auth_Logger),
|
|
||||||
container.get(TYPES.Auth_Timer),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
container
|
container
|
||||||
.bind<SubscriptionTokenRepositoryInterface>(TYPES.Auth_SubscriptionTokenRepository)
|
.bind<SubscriptionTokenRepositoryInterface>(TYPES.Auth_SubscriptionTokenRepository)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
@@ -779,6 +787,17 @@ export class ContainerConfigLoader {
|
|||||||
container.get(TYPES.Auth_CryptoNode),
|
container.get(TYPES.Auth_CryptoNode),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
container
|
||||||
|
.bind<ActivatePremiumFeatures>(TYPES.Auth_ActivatePremiumFeatures)
|
||||||
|
.toConstantValue(
|
||||||
|
new ActivatePremiumFeatures(
|
||||||
|
container.get(TYPES.Auth_UserRepository),
|
||||||
|
container.get(TYPES.Auth_UserSubscriptionRepository),
|
||||||
|
container.get(TYPES.Auth_SubscriptionSettingService),
|
||||||
|
container.get(TYPES.Auth_RoleService),
|
||||||
|
container.get(TYPES.Auth_Timer),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
container
|
container
|
||||||
.bind<CleanupSessionTraces>(TYPES.Auth_CleanupSessionTraces)
|
.bind<CleanupSessionTraces>(TYPES.Auth_CleanupSessionTraces)
|
||||||
@@ -1018,9 +1037,9 @@ export class ContainerConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
container
|
container
|
||||||
.bind<HomeServerAuthController>(TYPES.Auth_HomeServerAuthController)
|
.bind<BaseAuthController>(TYPES.Auth_BaseAuthController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerAuthController(
|
new BaseAuthController(
|
||||||
container.get(TYPES.Auth_VerifyMFA),
|
container.get(TYPES.Auth_VerifyMFA),
|
||||||
container.get(TYPES.Auth_SignIn),
|
container.get(TYPES.Auth_SignIn),
|
||||||
container.get(TYPES.Auth_GetUserKeyParams),
|
container.get(TYPES.Auth_GetUserKeyParams),
|
||||||
@@ -1035,42 +1054,42 @@ export class ContainerConfigLoader {
|
|||||||
// Inversify Controllers
|
// Inversify Controllers
|
||||||
if (isConfiguredForHomeServer) {
|
if (isConfiguredForHomeServer) {
|
||||||
container
|
container
|
||||||
.bind<HomeServerAuthenticatorsController>(TYPES.Auth_HomeServerAuthenticatorsController)
|
.bind<BaseAuthenticatorsController>(TYPES.Auth_BaseAuthenticatorsController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerAuthenticatorsController(
|
new BaseAuthenticatorsController(
|
||||||
container.get(TYPES.Auth_AuthenticatorsController),
|
container.get(TYPES.Auth_AuthenticatorsController),
|
||||||
container.get(TYPES.Auth_ControllerContainer),
|
container.get(TYPES.Auth_ControllerContainer),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerSubscriptionInvitesController>(TYPES.Auth_HomeServerSubscriptionInvitesController)
|
.bind<BaseSubscriptionInvitesController>(TYPES.Auth_BaseSubscriptionInvitesController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerSubscriptionInvitesController(
|
new BaseSubscriptionInvitesController(
|
||||||
container.get(TYPES.Auth_SubscriptionInvitesController),
|
container.get(TYPES.Auth_SubscriptionInvitesController),
|
||||||
container.get(TYPES.Auth_ControllerContainer),
|
container.get(TYPES.Auth_ControllerContainer),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerUserRequestsController>(TYPES.Auth_HomeServerUserRequestsController)
|
.bind<BaseUserRequestsController>(TYPES.Auth_BaseUserRequestsController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerUserRequestsController(
|
new BaseUserRequestsController(
|
||||||
container.get(TYPES.Auth_UserRequestsController),
|
container.get(TYPES.Auth_UserRequestsController),
|
||||||
container.get(TYPES.Auth_ControllerContainer),
|
container.get(TYPES.Auth_ControllerContainer),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerWebSocketsController>(TYPES.Auth_HomeServerWebSocketsController)
|
.bind<BaseWebSocketsController>(TYPES.Auth_BaseWebSocketsController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerWebSocketsController(
|
new BaseWebSocketsController(
|
||||||
container.get(TYPES.Auth_CreateCrossServiceToken),
|
container.get(TYPES.Auth_CreateCrossServiceToken),
|
||||||
container.get(TYPES.Auth_WebSocketConnectionTokenDecoder),
|
container.get(TYPES.Auth_WebSocketConnectionTokenDecoder),
|
||||||
container.get(TYPES.Auth_ControllerContainer),
|
container.get(TYPES.Auth_ControllerContainer),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerSessionsController>(TYPES.Auth_HomeServerSessionsController)
|
.bind<BaseSessionsController>(TYPES.Auth_BaseSessionsController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerSessionsController(
|
new BaseSessionsController(
|
||||||
container.get(TYPES.Auth_GetActiveSessionsForUser),
|
container.get(TYPES.Auth_GetActiveSessionsForUser),
|
||||||
container.get(TYPES.Auth_AuthenticateRequest),
|
container.get(TYPES.Auth_AuthenticateRequest),
|
||||||
container.get(TYPES.Auth_SessionProjector),
|
container.get(TYPES.Auth_SessionProjector),
|
||||||
@@ -1079,17 +1098,17 @@ export class ContainerConfigLoader {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerValetTokenController>(TYPES.Auth_HomeServerValetTokenController)
|
.bind<BaseValetTokenController>(TYPES.Auth_BaseValetTokenController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerValetTokenController(
|
new BaseValetTokenController(
|
||||||
container.get(TYPES.Auth_CreateValetToken),
|
container.get(TYPES.Auth_CreateValetToken),
|
||||||
container.get(TYPES.Auth_ControllerContainer),
|
container.get(TYPES.Auth_ControllerContainer),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerUsersController>(TYPES.Auth_HomeServerUsersController)
|
.bind<BaseUsersController>(TYPES.Auth_BaseUsersController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerUsersController(
|
new BaseUsersController(
|
||||||
container.get(TYPES.Auth_UpdateUser),
|
container.get(TYPES.Auth_UpdateUser),
|
||||||
container.get(TYPES.Auth_GetUserKeyParams),
|
container.get(TYPES.Auth_GetUserKeyParams),
|
||||||
container.get(TYPES.Auth_DeleteAccount),
|
container.get(TYPES.Auth_DeleteAccount),
|
||||||
@@ -1101,9 +1120,9 @@ export class ContainerConfigLoader {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerAdminController>(TYPES.Auth_HomeServerAdminController)
|
.bind<BaseAdminController>(TYPES.Auth_BaseAdminController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerAdminController(
|
new BaseAdminController(
|
||||||
container.get(TYPES.Auth_DeleteSetting),
|
container.get(TYPES.Auth_DeleteSetting),
|
||||||
container.get(TYPES.Auth_UserRepository),
|
container.get(TYPES.Auth_UserRepository),
|
||||||
container.get(TYPES.Auth_CreateSubscriptionToken),
|
container.get(TYPES.Auth_CreateSubscriptionToken),
|
||||||
@@ -1112,9 +1131,9 @@ export class ContainerConfigLoader {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerSubscriptionTokensController>(TYPES.Auth_HomeServerSubscriptionTokensController)
|
.bind<BaseSubscriptionTokensController>(TYPES.Auth_BaseSubscriptionTokensController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerSubscriptionTokensController(
|
new BaseSubscriptionTokensController(
|
||||||
container.get(TYPES.Auth_CreateSubscriptionToken),
|
container.get(TYPES.Auth_CreateSubscriptionToken),
|
||||||
container.get(TYPES.Auth_AuthenticateSubscriptionToken),
|
container.get(TYPES.Auth_AuthenticateSubscriptionToken),
|
||||||
container.get(TYPES.Auth_SettingService),
|
container.get(TYPES.Auth_SettingService),
|
||||||
@@ -1126,17 +1145,17 @@ export class ContainerConfigLoader {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerSubscriptionSettingsController>(TYPES.Auth_HomeServerSubscriptionSettingsController)
|
.bind<BaseSubscriptionSettingsController>(TYPES.Auth_BaseSubscriptionSettingsController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerSubscriptionSettingsController(
|
new BaseSubscriptionSettingsController(
|
||||||
container.get(TYPES.Auth_GetSetting),
|
container.get(TYPES.Auth_GetSetting),
|
||||||
container.get(TYPES.Auth_ControllerContainer),
|
container.get(TYPES.Auth_ControllerContainer),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerSettingsController>(TYPES.Auth_HomeServerSettingsController)
|
.bind<BaseSettingsController>(TYPES.Auth_BaseSettingsController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerSettingsController(
|
new BaseSettingsController(
|
||||||
container.get(TYPES.Auth_GetSettings),
|
container.get(TYPES.Auth_GetSettings),
|
||||||
container.get(TYPES.Auth_GetSetting),
|
container.get(TYPES.Auth_GetSetting),
|
||||||
container.get(TYPES.Auth_UpdateSetting),
|
container.get(TYPES.Auth_UpdateSetting),
|
||||||
@@ -1145,9 +1164,9 @@ export class ContainerConfigLoader {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerSessionController>(TYPES.Auth_HomeServerSessionController)
|
.bind<BaseSessionController>(TYPES.Auth_BaseSessionController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerSessionController(
|
new BaseSessionController(
|
||||||
container.get(TYPES.Auth_DeleteSessionForUser),
|
container.get(TYPES.Auth_DeleteSessionForUser),
|
||||||
container.get(TYPES.Auth_DeletePreviousSessionsForUser),
|
container.get(TYPES.Auth_DeletePreviousSessionsForUser),
|
||||||
container.get(TYPES.Auth_RefreshSessionToken),
|
container.get(TYPES.Auth_RefreshSessionToken),
|
||||||
@@ -1155,9 +1174,9 @@ export class ContainerConfigLoader {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerOfflineController>(TYPES.Auth_HomeServerOfflineController)
|
.bind<BaseOfflineController>(TYPES.Auth_BaseOfflineController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerOfflineController(
|
new BaseOfflineController(
|
||||||
container.get(TYPES.Auth_GetUserFeatures),
|
container.get(TYPES.Auth_GetUserFeatures),
|
||||||
container.get(TYPES.Auth_GetUserOfflineSubscription),
|
container.get(TYPES.Auth_GetUserOfflineSubscription),
|
||||||
container.get(TYPES.Auth_CreateOfflineSubscriptionToken),
|
container.get(TYPES.Auth_CreateOfflineSubscriptionToken),
|
||||||
@@ -1169,23 +1188,25 @@ export class ContainerConfigLoader {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerListedController>(TYPES.Auth_HomeServerListedController)
|
.bind<BaseListedController>(TYPES.Auth_BaseListedController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerListedController(
|
new BaseListedController(
|
||||||
container.get(TYPES.Auth_CreateListedAccount),
|
container.get(TYPES.Auth_CreateListedAccount),
|
||||||
container.get(TYPES.Auth_ControllerContainer),
|
container.get(TYPES.Auth_ControllerContainer),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
container
|
container
|
||||||
.bind<HomeServerFeaturesController>(TYPES.Auth_HomeServerFeaturesController)
|
.bind<BaseFeaturesController>(TYPES.Auth_BaseFeaturesController)
|
||||||
.toConstantValue(
|
.toConstantValue(
|
||||||
new HomeServerFeaturesController(
|
new BaseFeaturesController(
|
||||||
container.get(TYPES.Auth_GetUserFeatures),
|
container.get(TYPES.Auth_GetUserFeatures),
|
||||||
container.get(TYPES.Auth_ControllerContainer),
|
container.get(TYPES.Auth_ControllerContainer),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug('Configuration complete')
|
||||||
|
|
||||||
return container
|
return container
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { DataSource, LoggerOptions } from 'typeorm'
|
import { DataSource, EntityTarget, LoggerOptions, ObjectLiteral, Repository } from 'typeorm'
|
||||||
import { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions'
|
import { MysqlConnectionOptions } from 'typeorm/driver/mysql/MysqlConnectionOptions'
|
||||||
import { Permission } from '../Domain/Permission/Permission'
|
import { Permission } from '../Domain/Permission/Permission'
|
||||||
import { Role } from '../Domain/Role/Role'
|
import { Role } from '../Domain/Role/Role'
|
||||||
@@ -19,88 +19,108 @@ import { TypeORMSessionTrace } from '../Infra/TypeORM/TypeORMSessionTrace'
|
|||||||
import { Env } from './Env'
|
import { Env } from './Env'
|
||||||
import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions'
|
import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions'
|
||||||
|
|
||||||
const env: Env = new Env()
|
export class AppDataSource {
|
||||||
env.load()
|
private _dataSource: DataSource | undefined
|
||||||
|
|
||||||
const isConfiguredForMySQL = env.get('DB_TYPE') === 'mysql'
|
constructor(private env: Env) {}
|
||||||
|
|
||||||
const maxQueryExecutionTime = env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
getRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): Repository<Entity> {
|
||||||
? +env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
if (!this._dataSource) {
|
||||||
: 45_000
|
throw new Error('DataSource not initialized')
|
||||||
|
}
|
||||||
|
|
||||||
const commonDataSourceOptions = {
|
return this._dataSource.getRepository(target)
|
||||||
maxQueryExecutionTime,
|
}
|
||||||
entities: [
|
|
||||||
User,
|
async initialize(): Promise<void> {
|
||||||
UserSubscription,
|
await this.dataSource.initialize()
|
||||||
OfflineUserSubscription,
|
}
|
||||||
Session,
|
|
||||||
RevokedSession,
|
get dataSource(): DataSource {
|
||||||
Role,
|
this.env.load()
|
||||||
Permission,
|
|
||||||
Setting,
|
const isConfiguredForMySQL = this.env.get('DB_TYPE') === 'mysql'
|
||||||
OfflineSetting,
|
|
||||||
SharedSubscriptionInvitation,
|
const maxQueryExecutionTime = this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
||||||
SubscriptionSetting,
|
? +this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
|
||||||
TypeORMSessionTrace,
|
: 45_000
|
||||||
TypeORMAuthenticator,
|
|
||||||
TypeORMAuthenticatorChallenge,
|
const commonDataSourceOptions = {
|
||||||
TypeORMEmergencyAccessInvitation,
|
maxQueryExecutionTime,
|
||||||
TypeORMCacheEntry,
|
entities: [
|
||||||
],
|
User,
|
||||||
migrations: [`${__dirname}/../../migrations/${isConfiguredForMySQL ? 'mysql' : 'sqlite'}/*.js`],
|
UserSubscription,
|
||||||
migrationsRun: true,
|
OfflineUserSubscription,
|
||||||
logging: <LoggerOptions>env.get('DB_DEBUG_LEVEL', true) ?? 'info',
|
Session,
|
||||||
|
RevokedSession,
|
||||||
|
Role,
|
||||||
|
Permission,
|
||||||
|
Setting,
|
||||||
|
OfflineSetting,
|
||||||
|
SharedSubscriptionInvitation,
|
||||||
|
SubscriptionSetting,
|
||||||
|
TypeORMSessionTrace,
|
||||||
|
TypeORMAuthenticator,
|
||||||
|
TypeORMAuthenticatorChallenge,
|
||||||
|
TypeORMEmergencyAccessInvitation,
|
||||||
|
TypeORMCacheEntry,
|
||||||
|
],
|
||||||
|
migrations: [`${__dirname}/../../migrations/${isConfiguredForMySQL ? 'mysql' : 'sqlite'}/*.js`],
|
||||||
|
migrationsRun: true,
|
||||||
|
logging: <LoggerOptions>this.env.get('DB_DEBUG_LEVEL', true) ?? 'info',
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isConfiguredForMySQL) {
|
||||||
|
const inReplicaMode = this.env.get('DB_REPLICA_HOST', true) ? true : false
|
||||||
|
|
||||||
|
const replicationConfig = {
|
||||||
|
master: {
|
||||||
|
host: this.env.get('DB_HOST'),
|
||||||
|
port: parseInt(this.env.get('DB_PORT')),
|
||||||
|
username: this.env.get('DB_USERNAME'),
|
||||||
|
password: this.env.get('DB_PASSWORD'),
|
||||||
|
database: this.env.get('DB_DATABASE'),
|
||||||
|
},
|
||||||
|
slaves: [
|
||||||
|
{
|
||||||
|
host: this.env.get('DB_REPLICA_HOST', true),
|
||||||
|
port: parseInt(this.env.get('DB_PORT')),
|
||||||
|
username: this.env.get('DB_USERNAME'),
|
||||||
|
password: this.env.get('DB_PASSWORD'),
|
||||||
|
database: this.env.get('DB_DATABASE'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
removeNodeErrorCount: 10,
|
||||||
|
restoreNodeTimeout: 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
const mySQLDataSourceOptions: MysqlConnectionOptions = {
|
||||||
|
...commonDataSourceOptions,
|
||||||
|
type: 'mysql',
|
||||||
|
charset: 'utf8mb4',
|
||||||
|
supportBigNumbers: true,
|
||||||
|
bigNumberStrings: false,
|
||||||
|
replication: inReplicaMode ? replicationConfig : undefined,
|
||||||
|
host: inReplicaMode ? undefined : this.env.get('DB_HOST'),
|
||||||
|
port: inReplicaMode ? undefined : parseInt(this.env.get('DB_PORT')),
|
||||||
|
username: inReplicaMode ? undefined : this.env.get('DB_USERNAME'),
|
||||||
|
password: inReplicaMode ? undefined : this.env.get('DB_PASSWORD'),
|
||||||
|
database: inReplicaMode ? undefined : this.env.get('DB_DATABASE'),
|
||||||
|
}
|
||||||
|
|
||||||
|
this._dataSource = new DataSource(mySQLDataSourceOptions)
|
||||||
|
} else {
|
||||||
|
const sqliteDataSourceOptions: SqliteConnectionOptions = {
|
||||||
|
...commonDataSourceOptions,
|
||||||
|
type: 'sqlite',
|
||||||
|
database: this.env.get('DB_SQLITE_DATABASE_PATH'),
|
||||||
|
enableWAL: true,
|
||||||
|
busyErrorRetry: 2000,
|
||||||
|
}
|
||||||
|
|
||||||
|
this._dataSource = new DataSource(sqliteDataSourceOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
return this._dataSource
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let dataSource: DataSource
|
|
||||||
if (isConfiguredForMySQL) {
|
|
||||||
const inReplicaMode = env.get('DB_REPLICA_HOST', true) ? true : false
|
|
||||||
|
|
||||||
const replicationConfig = {
|
|
||||||
master: {
|
|
||||||
host: env.get('DB_HOST'),
|
|
||||||
port: parseInt(env.get('DB_PORT')),
|
|
||||||
username: env.get('DB_USERNAME'),
|
|
||||||
password: env.get('DB_PASSWORD'),
|
|
||||||
database: env.get('DB_DATABASE'),
|
|
||||||
},
|
|
||||||
slaves: [
|
|
||||||
{
|
|
||||||
host: env.get('DB_REPLICA_HOST', true),
|
|
||||||
port: parseInt(env.get('DB_PORT')),
|
|
||||||
username: env.get('DB_USERNAME'),
|
|
||||||
password: env.get('DB_PASSWORD'),
|
|
||||||
database: env.get('DB_DATABASE'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
removeNodeErrorCount: 10,
|
|
||||||
restoreNodeTimeout: 5,
|
|
||||||
}
|
|
||||||
|
|
||||||
const mySQLDataSourceOptions: MysqlConnectionOptions = {
|
|
||||||
...commonDataSourceOptions,
|
|
||||||
type: 'mysql',
|
|
||||||
charset: 'utf8mb4',
|
|
||||||
supportBigNumbers: true,
|
|
||||||
bigNumberStrings: false,
|
|
||||||
replication: inReplicaMode ? replicationConfig : undefined,
|
|
||||||
host: inReplicaMode ? undefined : env.get('DB_HOST'),
|
|
||||||
port: inReplicaMode ? undefined : parseInt(env.get('DB_PORT')),
|
|
||||||
username: inReplicaMode ? undefined : env.get('DB_USERNAME'),
|
|
||||||
password: inReplicaMode ? undefined : env.get('DB_PASSWORD'),
|
|
||||||
database: inReplicaMode ? undefined : env.get('DB_DATABASE'),
|
|
||||||
}
|
|
||||||
|
|
||||||
dataSource = new DataSource(mySQLDataSourceOptions)
|
|
||||||
} else {
|
|
||||||
const sqliteDataSourceOptions: SqliteConnectionOptions = {
|
|
||||||
...commonDataSourceOptions,
|
|
||||||
type: 'sqlite',
|
|
||||||
database: `data/${env.get('DB_DATABASE')}.sqlite`,
|
|
||||||
}
|
|
||||||
|
|
||||||
dataSource = new DataSource(sqliteDataSourceOptions)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const AppDataSource = dataSource
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { AppDataSource } from './DataSource'
|
||||||
|
import { Env } from './Env'
|
||||||
|
|
||||||
|
const env: Env = new Env()
|
||||||
|
env.load()
|
||||||
|
|
||||||
|
export const MigrationsDataSource = new AppDataSource(env).dataSource
|
||||||
@@ -1,15 +1,21 @@
|
|||||||
import {
|
import {
|
||||||
ControllerContainerInterface,
|
ControllerContainerInterface,
|
||||||
|
Result,
|
||||||
ServiceConfiguration,
|
ServiceConfiguration,
|
||||||
ServiceContainerInterface,
|
ServiceContainerInterface,
|
||||||
ServiceIdentifier,
|
ServiceIdentifier,
|
||||||
ServiceInterface,
|
|
||||||
} from '@standardnotes/domain-core'
|
} from '@standardnotes/domain-core'
|
||||||
|
|
||||||
import { ContainerConfigLoader } from './Container'
|
import { ContainerConfigLoader } from './Container'
|
||||||
import { DirectCallDomainEventPublisher } from '@standardnotes/domain-events-infra'
|
import { DirectCallDomainEventPublisher } from '@standardnotes/domain-events-infra'
|
||||||
|
import TYPES from './Types'
|
||||||
|
import { Container } from 'inversify'
|
||||||
|
import { ActivatePremiumFeatures } from '../Domain/UseCase/ActivatePremiumFeatures/ActivatePremiumFeatures'
|
||||||
|
import { AuthServiceInterface } from './AuthServiceInterface'
|
||||||
|
|
||||||
|
export class Service implements AuthServiceInterface {
|
||||||
|
private container: Container | undefined
|
||||||
|
|
||||||
export class Service implements ServiceInterface {
|
|
||||||
constructor(
|
constructor(
|
||||||
private serviceContainer: ServiceContainerInterface,
|
private serviceContainer: ServiceContainerInterface,
|
||||||
private controllerContainer: ControllerContainerInterface,
|
private controllerContainer: ControllerContainerInterface,
|
||||||
@@ -18,6 +24,20 @@ export class Service implements ServiceInterface {
|
|||||||
this.serviceContainer.register(this.getId(), this)
|
this.serviceContainer.register(this.getId(), this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async activatePremiumFeatures(dto: {
|
||||||
|
username: string
|
||||||
|
subscriptionPlanName?: string
|
||||||
|
endsAt?: Date
|
||||||
|
}): Promise<Result<string>> {
|
||||||
|
if (!this.container) {
|
||||||
|
return Result.fail('Container not initialized')
|
||||||
|
}
|
||||||
|
|
||||||
|
const activatePremiumFeatures = this.container.get(TYPES.Auth_ActivatePremiumFeatures) as ActivatePremiumFeatures
|
||||||
|
|
||||||
|
return activatePremiumFeatures.execute(dto)
|
||||||
|
}
|
||||||
|
|
||||||
async handleRequest(request: never, response: never, endpointOrMethodIdentifier: string): Promise<unknown> {
|
async handleRequest(request: never, response: never, endpointOrMethodIdentifier: string): Promise<unknown> {
|
||||||
const method = this.controllerContainer.get(endpointOrMethodIdentifier)
|
const method = this.controllerContainer.get(endpointOrMethodIdentifier)
|
||||||
|
|
||||||
@@ -31,12 +51,16 @@ export class Service implements ServiceInterface {
|
|||||||
async getContainer(configuration?: ServiceConfiguration): Promise<unknown> {
|
async getContainer(configuration?: ServiceConfiguration): Promise<unknown> {
|
||||||
const config = new ContainerConfigLoader()
|
const config = new ContainerConfigLoader()
|
||||||
|
|
||||||
return config.load({
|
const container = await config.load({
|
||||||
controllerConatiner: this.controllerContainer,
|
controllerConatiner: this.controllerContainer,
|
||||||
directCallDomainEventPublisher: this.directCallDomainEventPublisher,
|
directCallDomainEventPublisher: this.directCallDomainEventPublisher,
|
||||||
logger: configuration?.logger,
|
logger: configuration?.logger,
|
||||||
environmentOverrides: configuration?.environmentOverrides,
|
environmentOverrides: configuration?.environmentOverrides,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.container = container
|
||||||
|
|
||||||
|
return container
|
||||||
}
|
}
|
||||||
|
|
||||||
getId(): ServiceIdentifier {
|
getId(): ServiceIdentifier {
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ const TYPES = {
|
|||||||
Auth_ListAuthenticators: Symbol.for('Auth_ListAuthenticators'),
|
Auth_ListAuthenticators: Symbol.for('Auth_ListAuthenticators'),
|
||||||
Auth_DeleteAuthenticator: Symbol.for('Auth_DeleteAuthenticator'),
|
Auth_DeleteAuthenticator: Symbol.for('Auth_DeleteAuthenticator'),
|
||||||
Auth_GenerateRecoveryCodes: Symbol.for('Auth_GenerateRecoveryCodes'),
|
Auth_GenerateRecoveryCodes: Symbol.for('Auth_GenerateRecoveryCodes'),
|
||||||
|
Auth_ActivatePremiumFeatures: Symbol.for('Auth_ActivatePremiumFeatures'),
|
||||||
Auth_SignInWithRecoveryCodes: Symbol.for('Auth_SignInWithRecoveryCodes'),
|
Auth_SignInWithRecoveryCodes: Symbol.for('Auth_SignInWithRecoveryCodes'),
|
||||||
Auth_GetUserKeyParamsRecovery: Symbol.for('Auth_GetUserKeyParamsRecovery'),
|
Auth_GetUserKeyParamsRecovery: Symbol.for('Auth_GetUserKeyParamsRecovery'),
|
||||||
// Handlers
|
// Handlers
|
||||||
@@ -216,22 +217,22 @@ const TYPES = {
|
|||||||
Auth_ProtocolVersionSelector: Symbol.for('Auth_ProtocolVersionSelector'),
|
Auth_ProtocolVersionSelector: Symbol.for('Auth_ProtocolVersionSelector'),
|
||||||
Auth_BooleanSelector: Symbol.for('Auth_BooleanSelector'),
|
Auth_BooleanSelector: Symbol.for('Auth_BooleanSelector'),
|
||||||
Auth_UserSubscriptionService: Symbol.for('Auth_UserSubscriptionService'),
|
Auth_UserSubscriptionService: Symbol.for('Auth_UserSubscriptionService'),
|
||||||
Auth_HomeServerAuthController: Symbol.for('Auth_HomeServerAuthController'),
|
Auth_BaseAuthController: Symbol.for('Auth_BaseAuthController'),
|
||||||
Auth_HomeServerAuthenticatorsController: Symbol.for('Auth_HomeServerAuthenticatorsController'),
|
Auth_BaseAuthenticatorsController: Symbol.for('Auth_BaseAuthenticatorsController'),
|
||||||
Auth_HomeServerSubscriptionInvitesController: Symbol.for('Auth_HomeServerSubscriptionInvitesController'),
|
Auth_BaseSubscriptionInvitesController: Symbol.for('Auth_BaseSubscriptionInvitesController'),
|
||||||
Auth_HomeServerUserRequestsController: Symbol.for('Auth_HomeServerUserRequestsController'),
|
Auth_BaseUserRequestsController: Symbol.for('Auth_BaseUserRequestsController'),
|
||||||
Auth_HomeServerWebSocketsController: Symbol.for('Auth_HomeServerWebSocketsController'),
|
Auth_BaseWebSocketsController: Symbol.for('Auth_BaseWebSocketsController'),
|
||||||
Auth_HomeServerSessionsController: Symbol.for('Auth_HomeServerSessionsController'),
|
Auth_BaseSessionsController: Symbol.for('Auth_BaseSessionsController'),
|
||||||
Auth_HomeServerValetTokenController: Symbol.for('Auth_HomeServerValetTokenController'),
|
Auth_BaseValetTokenController: Symbol.for('Auth_BaseValetTokenController'),
|
||||||
Auth_HomeServerUsersController: Symbol.for('Auth_HomeServerUsersController'),
|
Auth_BaseUsersController: Symbol.for('Auth_BaseUsersController'),
|
||||||
Auth_HomeServerAdminController: Symbol.for('Auth_HomeServerAdminController'),
|
Auth_BaseAdminController: Symbol.for('Auth_BaseAdminController'),
|
||||||
Auth_HomeServerSubscriptionTokensController: Symbol.for('Auth_HomeServerSubscriptionTokensController'),
|
Auth_BaseSubscriptionTokensController: Symbol.for('Auth_BaseSubscriptionTokensController'),
|
||||||
Auth_HomeServerSubscriptionSettingsController: Symbol.for('Auth_HomeServerSubscriptionSettingsController'),
|
Auth_BaseSubscriptionSettingsController: Symbol.for('Auth_BaseSubscriptionSettingsController'),
|
||||||
Auth_HomeServerSettingsController: Symbol.for('Auth_HomeServerSettingsController'),
|
Auth_BaseSettingsController: Symbol.for('Auth_BaseSettingsController'),
|
||||||
Auth_HomeServerSessionController: Symbol.for('Auth_HomeServerSessionController'),
|
Auth_BaseSessionController: Symbol.for('Auth_BaseSessionController'),
|
||||||
Auth_HomeServerOfflineController: Symbol.for('Auth_HomeServerOfflineController'),
|
Auth_BaseOfflineController: Symbol.for('Auth_BaseOfflineController'),
|
||||||
Auth_HomeServerListedController: Symbol.for('Auth_HomeServerListedController'),
|
Auth_BaseListedController: Symbol.for('Auth_BaseListedController'),
|
||||||
Auth_HomeServerFeaturesController: Symbol.for('Auth_HomeServerFeaturesController'),
|
Auth_BaseFeaturesController: Symbol.for('Auth_BaseFeaturesController'),
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TYPES
|
export default TYPES
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
|
export * from './AuthServiceInterface'
|
||||||
export * from './Service'
|
export * from './Service'
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ import { User } from '../Domain/User/User'
|
|||||||
import { Register } from '../Domain/UseCase/Register'
|
import { Register } from '../Domain/UseCase/Register'
|
||||||
import { DomainEventFactoryInterface } from '../Domain/Event/DomainEventFactoryInterface'
|
import { DomainEventFactoryInterface } from '../Domain/Event/DomainEventFactoryInterface'
|
||||||
import { KeyParamsOrigination, ProtocolVersion } from '@standardnotes/common'
|
import { KeyParamsOrigination, ProtocolVersion } from '@standardnotes/common'
|
||||||
import { ApiVersion } from '@standardnotes/api'
|
|
||||||
import { SignInWithRecoveryCodes } from '../Domain/UseCase/SignInWithRecoveryCodes/SignInWithRecoveryCodes'
|
import { SignInWithRecoveryCodes } from '../Domain/UseCase/SignInWithRecoveryCodes/SignInWithRecoveryCodes'
|
||||||
import { GetUserKeyParamsRecovery } from '../Domain/UseCase/GetUserKeyParamsRecovery/GetUserKeyParamsRecovery'
|
import { GetUserKeyParamsRecovery } from '../Domain/UseCase/GetUserKeyParamsRecovery/GetUserKeyParamsRecovery'
|
||||||
import { GenerateRecoveryCodes } from '../Domain/UseCase/GenerateRecoveryCodes/GenerateRecoveryCodes'
|
import { GenerateRecoveryCodes } from '../Domain/UseCase/GenerateRecoveryCodes/GenerateRecoveryCodes'
|
||||||
import { Logger } from 'winston'
|
import { Logger } from 'winston'
|
||||||
import { SessionServiceInterface } from '../Domain/Session/SessionServiceInterface'
|
import { SessionServiceInterface } from '../Domain/Session/SessionServiceInterface'
|
||||||
|
import { ApiVersion } from '../Domain/Api/ApiVersion'
|
||||||
|
|
||||||
describe('AuthController', () => {
|
describe('AuthController', () => {
|
||||||
let clearLoginAttempts: ClearLoginAttempts
|
let clearLoginAttempts: ClearLoginAttempts
|
||||||
@@ -73,7 +73,7 @@ describe('AuthController', () => {
|
|||||||
email: 'test@test.te',
|
email: 'test@test.te',
|
||||||
password: 'asdzxc',
|
password: 'asdzxc',
|
||||||
version: ProtocolVersion.V004,
|
version: ProtocolVersion.V004,
|
||||||
api: ApiVersion.v0,
|
api: ApiVersion.v20200115,
|
||||||
origination: KeyParamsOrigination.Registration,
|
origination: KeyParamsOrigination.Registration,
|
||||||
userAgent: 'Google Chrome',
|
userAgent: 'Google Chrome',
|
||||||
identifier: 'test@test.te',
|
identifier: 'test@test.te',
|
||||||
@@ -103,7 +103,7 @@ describe('AuthController', () => {
|
|||||||
email: 'test@test.te',
|
email: 'test@test.te',
|
||||||
password: '',
|
password: '',
|
||||||
version: ProtocolVersion.V004,
|
version: ProtocolVersion.V004,
|
||||||
api: ApiVersion.v0,
|
api: ApiVersion.v20200115,
|
||||||
origination: KeyParamsOrigination.Registration,
|
origination: KeyParamsOrigination.Registration,
|
||||||
userAgent: 'Google Chrome',
|
userAgent: 'Google Chrome',
|
||||||
identifier: 'test@test.te',
|
identifier: 'test@test.te',
|
||||||
@@ -123,7 +123,7 @@ describe('AuthController', () => {
|
|||||||
email: 'test@test.te',
|
email: 'test@test.te',
|
||||||
password: 'test',
|
password: 'test',
|
||||||
version: ProtocolVersion.V004,
|
version: ProtocolVersion.V004,
|
||||||
api: ApiVersion.v0,
|
api: ApiVersion.v20200115,
|
||||||
origination: KeyParamsOrigination.Registration,
|
origination: KeyParamsOrigination.Registration,
|
||||||
userAgent: 'Google Chrome',
|
userAgent: 'Google Chrome',
|
||||||
identifier: 'test@test.te',
|
identifier: 'test@test.te',
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
|
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
|
||||||
import {
|
import {
|
||||||
ApiVersion,
|
|
||||||
UserRegistrationRequestParams,
|
UserRegistrationRequestParams,
|
||||||
UserServerInterface,
|
UserServerInterface,
|
||||||
UserDeletionResponseBody,
|
UserDeletionResponseBody,
|
||||||
UserRegistrationResponseBody,
|
UserRegistrationResponseBody,
|
||||||
|
UserUpdateRequestParams,
|
||||||
} from '@standardnotes/api'
|
} from '@standardnotes/api'
|
||||||
import { ErrorTag, HttpResponse, HttpStatusCode } from '@standardnotes/responses'
|
import { ErrorTag, HttpResponse, HttpStatusCode } from '@standardnotes/responses'
|
||||||
import { ProtocolVersion } from '@standardnotes/common'
|
import { ProtocolVersion } from '@standardnotes/common'
|
||||||
@@ -23,6 +23,8 @@ import { GenerateRecoveryCodes } from '../Domain/UseCase/GenerateRecoveryCodes/G
|
|||||||
import { GenerateRecoveryCodesRequestParams } from '../Infra/Http/Request/GenerateRecoveryCodesRequestParams'
|
import { GenerateRecoveryCodesRequestParams } from '../Infra/Http/Request/GenerateRecoveryCodesRequestParams'
|
||||||
import { Logger } from 'winston'
|
import { Logger } from 'winston'
|
||||||
import { SessionServiceInterface } from '../Domain/Session/SessionServiceInterface'
|
import { SessionServiceInterface } from '../Domain/Session/SessionServiceInterface'
|
||||||
|
import { ApiVersion } from '../Domain/Api/ApiVersion'
|
||||||
|
import { UserUpdateResponse } from '@standardnotes/api/dist/Domain/Response/User/UserUpdateResponse'
|
||||||
|
|
||||||
export class AuthController implements UserServerInterface {
|
export class AuthController implements UserServerInterface {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -37,6 +39,10 @@ export class AuthController implements UserServerInterface {
|
|||||||
private sessionService: SessionServiceInterface,
|
private sessionService: SessionServiceInterface,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
async update(_params: UserUpdateRequestParams): Promise<HttpResponse<UserUpdateResponse>> {
|
||||||
|
throw new Error('Method not implemented.')
|
||||||
|
}
|
||||||
|
|
||||||
async deleteAccount(_params: never): Promise<HttpResponse<UserDeletionResponseBody>> {
|
async deleteAccount(_params: never): Promise<HttpResponse<UserDeletionResponseBody>> {
|
||||||
throw new Error('This method is implemented on the payments server.')
|
throw new Error('This method is implemented on the payments server.')
|
||||||
}
|
}
|
||||||
@@ -121,7 +127,7 @@ export class AuthController implements UserServerInterface {
|
|||||||
async signInWithRecoveryCodes(
|
async signInWithRecoveryCodes(
|
||||||
params: SignInWithRecoveryCodesRequestParams,
|
params: SignInWithRecoveryCodesRequestParams,
|
||||||
): Promise<HttpResponse<SignInWithRecoveryCodesResponseBody>> {
|
): Promise<HttpResponse<SignInWithRecoveryCodesResponseBody>> {
|
||||||
if (params.apiVersion !== ApiVersion.v0) {
|
if (params.apiVersion !== ApiVersion.v20200115) {
|
||||||
return {
|
return {
|
||||||
status: HttpStatusCode.BadRequest,
|
status: HttpStatusCode.BadRequest,
|
||||||
data: {
|
data: {
|
||||||
@@ -162,7 +168,7 @@ export class AuthController implements UserServerInterface {
|
|||||||
async recoveryKeyParams(
|
async recoveryKeyParams(
|
||||||
params: RecoveryKeyParamsRequestParams,
|
params: RecoveryKeyParamsRequestParams,
|
||||||
): Promise<HttpResponse<RecoveryKeyParamsResponseBody>> {
|
): Promise<HttpResponse<RecoveryKeyParamsResponseBody>> {
|
||||||
if (params.apiVersion !== ApiVersion.v0) {
|
if (params.apiVersion !== ApiVersion.v20200115) {
|
||||||
return {
|
return {
|
||||||
status: HttpStatusCode.BadRequest,
|
status: HttpStatusCode.BadRequest,
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { AcceptSharedSubscriptionInvitation } from '../Domain/UseCase/AcceptShar
|
|||||||
import { DeclineSharedSubscriptionInvitation } from '../Domain/UseCase/DeclineSharedSubscriptionInvitation/DeclineSharedSubscriptionInvitation'
|
import { DeclineSharedSubscriptionInvitation } from '../Domain/UseCase/DeclineSharedSubscriptionInvitation/DeclineSharedSubscriptionInvitation'
|
||||||
import { CancelSharedSubscriptionInvitation } from '../Domain/UseCase/CancelSharedSubscriptionInvitation/CancelSharedSubscriptionInvitation'
|
import { CancelSharedSubscriptionInvitation } from '../Domain/UseCase/CancelSharedSubscriptionInvitation/CancelSharedSubscriptionInvitation'
|
||||||
import { ListSharedSubscriptionInvitations } from '../Domain/UseCase/ListSharedSubscriptionInvitations/ListSharedSubscriptionInvitations'
|
import { ListSharedSubscriptionInvitations } from '../Domain/UseCase/ListSharedSubscriptionInvitations/ListSharedSubscriptionInvitations'
|
||||||
import { ApiVersion } from '@standardnotes/api'
|
import { ApiVersion } from '../Domain/Api/ApiVersion'
|
||||||
|
|
||||||
describe('SubscriptionInvitesController', () => {
|
describe('SubscriptionInvitesController', () => {
|
||||||
let inviteToSharedSubscription: InviteToSharedSubscription
|
let inviteToSharedSubscription: InviteToSharedSubscription
|
||||||
@@ -53,7 +53,7 @@ describe('SubscriptionInvitesController', () => {
|
|||||||
invitations: [],
|
invitations: [],
|
||||||
})
|
})
|
||||||
|
|
||||||
const result = await createController().listInvites({ api: ApiVersion.v0, inviterEmail: 'test@test.te' })
|
const result = await createController().listInvites({ api: ApiVersion.v20200115, inviterEmail: 'test@test.te' })
|
||||||
|
|
||||||
expect(listSharedSubscriptionInvitations.execute).toHaveBeenCalledWith({
|
expect(listSharedSubscriptionInvitations.execute).toHaveBeenCalledWith({
|
||||||
inviterEmail: 'test@test.te',
|
inviterEmail: 'test@test.te',
|
||||||
@@ -68,7 +68,7 @@ describe('SubscriptionInvitesController', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const result = await createController().cancelInvite({
|
const result = await createController().cancelInvite({
|
||||||
api: ApiVersion.v0,
|
api: ApiVersion.v20200115,
|
||||||
inviteUuid: '1-2-3',
|
inviteUuid: '1-2-3',
|
||||||
inviterEmail: 'test@test.te',
|
inviterEmail: 'test@test.te',
|
||||||
})
|
})
|
||||||
@@ -87,7 +87,7 @@ describe('SubscriptionInvitesController', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const result = await createController().cancelInvite({
|
const result = await createController().cancelInvite({
|
||||||
api: ApiVersion.v0,
|
api: ApiVersion.v20200115,
|
||||||
inviteUuid: '1-2-3',
|
inviteUuid: '1-2-3',
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ describe('SubscriptionInvitesController', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const result = await createController().declineInvite({
|
const result = await createController().declineInvite({
|
||||||
api: ApiVersion.v0,
|
api: ApiVersion.v20200115,
|
||||||
inviteUuid: '1-2-3',
|
inviteUuid: '1-2-3',
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ describe('SubscriptionInvitesController', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const result = await createController().declineInvite({
|
const result = await createController().declineInvite({
|
||||||
api: ApiVersion.v0,
|
api: ApiVersion.v20200115,
|
||||||
inviteUuid: '1-2-3',
|
inviteUuid: '1-2-3',
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ describe('SubscriptionInvitesController', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const result = await createController().acceptInvite({
|
const result = await createController().acceptInvite({
|
||||||
api: ApiVersion.v0,
|
api: ApiVersion.v20200115,
|
||||||
inviteUuid: '1-2-3',
|
inviteUuid: '1-2-3',
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ describe('SubscriptionInvitesController', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const result = await createController().acceptInvite({
|
const result = await createController().acceptInvite({
|
||||||
api: ApiVersion.v0,
|
api: ApiVersion.v20200115,
|
||||||
inviteUuid: '1-2-3',
|
inviteUuid: '1-2-3',
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ describe('SubscriptionInvitesController', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const result = await createController().invite({
|
const result = await createController().invite({
|
||||||
api: ApiVersion.v0,
|
api: ApiVersion.v20200115,
|
||||||
identifier: 'invitee@test.te',
|
identifier: 'invitee@test.te',
|
||||||
inviterUuid: '1-2-3',
|
inviterUuid: '1-2-3',
|
||||||
inviterEmail: 'test@test.te',
|
inviterEmail: 'test@test.te',
|
||||||
@@ -187,7 +187,7 @@ describe('SubscriptionInvitesController', () => {
|
|||||||
|
|
||||||
it('should not invite to user subscription if the identifier is missing in request', async () => {
|
it('should not invite to user subscription if the identifier is missing in request', async () => {
|
||||||
const result = await createController().invite({
|
const result = await createController().invite({
|
||||||
api: ApiVersion.v0,
|
api: ApiVersion.v20200115,
|
||||||
identifier: '',
|
identifier: '',
|
||||||
inviterUuid: '1-2-3',
|
inviterUuid: '1-2-3',
|
||||||
inviterEmail: 'test@test.te',
|
inviterEmail: 'test@test.te',
|
||||||
@@ -205,7 +205,7 @@ describe('SubscriptionInvitesController', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const result = await createController().invite({
|
const result = await createController().invite({
|
||||||
api: ApiVersion.v0,
|
api: ApiVersion.v20200115,
|
||||||
identifier: 'invitee@test.te',
|
identifier: 'invitee@test.te',
|
||||||
inviterUuid: '1-2-3',
|
inviterUuid: '1-2-3',
|
||||||
inviterEmail: 'test@test.te',
|
inviterEmail: 'test@test.te',
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
import { ProtocolVersion } from '@standardnotes/common'
|
import { SimpleUserProjection } from '../../Projection/SimpleUserProjection'
|
||||||
|
|
||||||
export interface AuthResponse {
|
export interface AuthResponse {
|
||||||
user: {
|
user: SimpleUserProjection
|
||||||
uuid: string
|
|
||||||
email: string
|
|
||||||
protocolVersion: ProtocolVersion
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import {
|
|||||||
TokenEncoderInterface,
|
TokenEncoderInterface,
|
||||||
} from '@standardnotes/security'
|
} from '@standardnotes/security'
|
||||||
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
|
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
|
||||||
import { ProtocolVersion } from '@standardnotes/common'
|
|
||||||
import { SessionBody } from '@standardnotes/responses'
|
import { SessionBody } from '@standardnotes/responses'
|
||||||
import { inject, injectable } from 'inversify'
|
import { inject, injectable } from 'inversify'
|
||||||
import { Logger } from 'winston'
|
import { Logger } from 'winston'
|
||||||
|
|
||||||
import TYPES from '../../Bootstrap/Types'
|
import TYPES from '../../Bootstrap/Types'
|
||||||
import { ProjectorInterface } from '../../Projection/ProjectorInterface'
|
import { ProjectorInterface } from '../../Projection/ProjectorInterface'
|
||||||
|
import { SimpleUserProjection } from '../../Projection/SimpleUserProjection'
|
||||||
import { SessionServiceInterface } from '../Session/SessionServiceInterface'
|
import { SessionServiceInterface } from '../Session/SessionServiceInterface'
|
||||||
import { KeyParamsFactoryInterface } from '../User/KeyParamsFactoryInterface'
|
import { KeyParamsFactoryInterface } from '../User/KeyParamsFactoryInterface'
|
||||||
import { User } from '../User/User'
|
import { User } from '../User/User'
|
||||||
@@ -54,11 +54,7 @@ export class AuthResponseFactory20200115 extends AuthResponseFactory20190520 {
|
|||||||
return {
|
return {
|
||||||
session: sessionPayload,
|
session: sessionPayload,
|
||||||
key_params: this.keyParamsFactory.create(dto.user, true),
|
key_params: this.keyParamsFactory.create(dto.user, true),
|
||||||
user: this.userProjector.projectSimple(dto.user) as {
|
user: this.userProjector.projectSimple(dto.user) as SimpleUserProjection,
|
||||||
uuid: string
|
|
||||||
email: string
|
|
||||||
protocolVersion: ProtocolVersion
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { User } from '../User/User'
|
|||||||
import { UserRepositoryInterface } from '../User/UserRepositoryInterface'
|
import { UserRepositoryInterface } from '../User/UserRepositoryInterface'
|
||||||
|
|
||||||
import { AuthenticationMethodResolver } from './AuthenticationMethodResolver'
|
import { AuthenticationMethodResolver } from './AuthenticationMethodResolver'
|
||||||
|
import { Logger } from 'winston'
|
||||||
|
|
||||||
describe('AuthenticationMethodResolver', () => {
|
describe('AuthenticationMethodResolver', () => {
|
||||||
let userRepository: UserRepositoryInterface
|
let userRepository: UserRepositoryInterface
|
||||||
@@ -18,14 +19,20 @@ describe('AuthenticationMethodResolver', () => {
|
|||||||
let user: User
|
let user: User
|
||||||
let session: Session
|
let session: Session
|
||||||
let revokedSession: RevokedSession
|
let revokedSession: RevokedSession
|
||||||
|
let logger: Logger
|
||||||
|
|
||||||
const createResolver = () =>
|
const createResolver = () =>
|
||||||
new AuthenticationMethodResolver(userRepository, sessionService, sessionTokenDecoder, fallbackTokenDecoder)
|
new AuthenticationMethodResolver(userRepository, sessionService, sessionTokenDecoder, fallbackTokenDecoder, logger)
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
logger = {} as jest.Mocked<Logger>
|
||||||
|
logger.debug = jest.fn()
|
||||||
|
|
||||||
user = {} as jest.Mocked<User>
|
user = {} as jest.Mocked<User>
|
||||||
|
|
||||||
session = {} as jest.Mocked<Session>
|
session = {
|
||||||
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
|
} as jest.Mocked<Session>
|
||||||
|
|
||||||
revokedSession = {} as jest.Mocked<RevokedSession>
|
revokedSession = {} as jest.Mocked<RevokedSession>
|
||||||
|
|
||||||
@@ -45,17 +52,23 @@ describe('AuthenticationMethodResolver', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should resolve jwt authentication method', async () => {
|
it('should resolve jwt authentication method', async () => {
|
||||||
sessionTokenDecoder.decodeToken = jest.fn().mockReturnValue({ user_uuid: '123' })
|
sessionTokenDecoder.decodeToken = jest.fn().mockReturnValue({ user_uuid: '00000000-0000-0000-0000-000000000000' })
|
||||||
|
|
||||||
expect(await createResolver().resolve('test')).toEqual({
|
expect(await createResolver().resolve('test')).toEqual({
|
||||||
claims: {
|
claims: {
|
||||||
user_uuid: '123',
|
user_uuid: '00000000-0000-0000-0000-000000000000',
|
||||||
},
|
},
|
||||||
type: 'jwt',
|
type: 'jwt',
|
||||||
user,
|
user,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should not resolve jwt authentication method with invalid user uuid', async () => {
|
||||||
|
sessionTokenDecoder.decodeToken = jest.fn().mockReturnValue({ user_uuid: 'invalid' })
|
||||||
|
|
||||||
|
expect(await createResolver().resolve('test')).toBeUndefined
|
||||||
|
})
|
||||||
|
|
||||||
it('should resolve session authentication method', async () => {
|
it('should resolve session authentication method', async () => {
|
||||||
sessionService.getSessionFromToken = jest.fn().mockReturnValue(session)
|
sessionService.getSessionFromToken = jest.fn().mockReturnValue(session)
|
||||||
|
|
||||||
@@ -66,6 +79,12 @@ describe('AuthenticationMethodResolver', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should not resolve session authentication method with invalid user uuid on session', async () => {
|
||||||
|
sessionService.getSessionFromToken = jest.fn().mockReturnValue({ userUuid: 'invalid' })
|
||||||
|
|
||||||
|
expect(await createResolver().resolve('test')).toBeUndefined
|
||||||
|
})
|
||||||
|
|
||||||
it('should resolve archvied session authentication method', async () => {
|
it('should resolve archvied session authentication method', async () => {
|
||||||
sessionService.getRevokedSessionFromToken = jest.fn().mockReturnValue(revokedSession)
|
sessionService.getRevokedSessionFromToken = jest.fn().mockReturnValue(revokedSession)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { SessionServiceInterface } from '../Session/SessionServiceInterface'
|
|||||||
import { UserRepositoryInterface } from '../User/UserRepositoryInterface'
|
import { UserRepositoryInterface } from '../User/UserRepositoryInterface'
|
||||||
import { AuthenticationMethod } from './AuthenticationMethod'
|
import { AuthenticationMethod } from './AuthenticationMethod'
|
||||||
import { AuthenticationMethodResolverInterface } from './AuthenticationMethodResolverInterface'
|
import { AuthenticationMethodResolverInterface } from './AuthenticationMethodResolverInterface'
|
||||||
|
import { Logger } from 'winston'
|
||||||
|
import { Uuid } from '@standardnotes/domain-core'
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class AuthenticationMethodResolver implements AuthenticationMethodResolverInterface {
|
export class AuthenticationMethodResolver implements AuthenticationMethodResolverInterface {
|
||||||
@@ -14,33 +16,54 @@ export class AuthenticationMethodResolver implements AuthenticationMethodResolve
|
|||||||
@inject(TYPES.Auth_SessionTokenDecoder) private sessionTokenDecoder: TokenDecoderInterface<SessionTokenData>,
|
@inject(TYPES.Auth_SessionTokenDecoder) private sessionTokenDecoder: TokenDecoderInterface<SessionTokenData>,
|
||||||
@inject(TYPES.Auth_FallbackSessionTokenDecoder)
|
@inject(TYPES.Auth_FallbackSessionTokenDecoder)
|
||||||
private fallbackSessionTokenDecoder: TokenDecoderInterface<SessionTokenData>,
|
private fallbackSessionTokenDecoder: TokenDecoderInterface<SessionTokenData>,
|
||||||
|
@inject(TYPES.Auth_Logger) private logger: Logger,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async resolve(token: string): Promise<AuthenticationMethod | undefined> {
|
async resolve(token: string): Promise<AuthenticationMethod | undefined> {
|
||||||
let decodedToken: SessionTokenData | undefined = this.sessionTokenDecoder.decodeToken(token)
|
let decodedToken: SessionTokenData | undefined = this.sessionTokenDecoder.decodeToken(token)
|
||||||
if (decodedToken === undefined) {
|
if (decodedToken === undefined) {
|
||||||
|
this.logger.debug('Could not decode token with primary decoder, trying fallback decoder.')
|
||||||
|
|
||||||
decodedToken = this.fallbackSessionTokenDecoder.decodeToken(token)
|
decodedToken = this.fallbackSessionTokenDecoder.decodeToken(token)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decodedToken) {
|
if (decodedToken) {
|
||||||
|
this.logger.debug('Token decoded successfully. User found.')
|
||||||
|
|
||||||
|
const userUuidOrError = Uuid.create(decodedToken.user_uuid as string)
|
||||||
|
if (userUuidOrError.isFailed()) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
const userUuid = userUuidOrError.getValue()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'jwt',
|
type: 'jwt',
|
||||||
user: await this.userRepository.findOneByUuid(<string>decodedToken.user_uuid),
|
user: await this.userRepository.findOneByUuid(userUuid),
|
||||||
claims: decodedToken,
|
claims: decodedToken,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const session = await this.sessionService.getSessionFromToken(token)
|
const session = await this.sessionService.getSessionFromToken(token)
|
||||||
if (session) {
|
if (session) {
|
||||||
|
this.logger.debug('Token decoded successfully. Session found.')
|
||||||
|
|
||||||
|
const userUuidOrError = Uuid.create(session.userUuid)
|
||||||
|
if (userUuidOrError.isFailed()) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
const userUuid = userUuidOrError.getValue()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'session_token',
|
type: 'session_token',
|
||||||
user: await this.userRepository.findOneByUuid(session.userUuid),
|
user: await this.userRepository.findOneByUuid(userUuid),
|
||||||
session: session,
|
session: session,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const revokedSession = await this.sessionService.getRevokedSessionFromToken(token)
|
const revokedSession = await this.sessionService.getRevokedSessionFromToken(token)
|
||||||
if (revokedSession) {
|
if (revokedSession) {
|
||||||
|
this.logger.debug('Token decoded successfully. Revoked session found.')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'revoked',
|
type: 'revoked',
|
||||||
revokedSession: await this.sessionService.markRevokedSessionAsReceived(revokedSession),
|
revokedSession: await this.sessionService.markRevokedSessionAsReceived(revokedSession),
|
||||||
@@ -48,6 +71,8 @@ export class AuthenticationMethodResolver implements AuthenticationMethodResolve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.debug('Could not decode token.')
|
||||||
|
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ import { Entity, Result, UniqueEntityId } from '@standardnotes/domain-core'
|
|||||||
import { AuthenticatorProps } from './AuthenticatorProps'
|
import { AuthenticatorProps } from './AuthenticatorProps'
|
||||||
|
|
||||||
export class Authenticator extends Entity<AuthenticatorProps> {
|
export class Authenticator extends Entity<AuthenticatorProps> {
|
||||||
get id(): UniqueEntityId {
|
|
||||||
return this._id
|
|
||||||
}
|
|
||||||
|
|
||||||
private constructor(props: AuthenticatorProps, id?: UniqueEntityId) {
|
private constructor(props: AuthenticatorProps, id?: UniqueEntityId) {
|
||||||
super(props, id)
|
super(props, id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ import { Entity, Result, UniqueEntityId } from '@standardnotes/domain-core'
|
|||||||
import { AuthenticatorChallengeProps } from './AuthenticatorChallengeProps'
|
import { AuthenticatorChallengeProps } from './AuthenticatorChallengeProps'
|
||||||
|
|
||||||
export class AuthenticatorChallenge extends Entity<AuthenticatorChallengeProps> {
|
export class AuthenticatorChallenge extends Entity<AuthenticatorChallengeProps> {
|
||||||
get id(): UniqueEntityId {
|
|
||||||
return this._id
|
|
||||||
}
|
|
||||||
|
|
||||||
private constructor(props: AuthenticatorChallengeProps, id?: UniqueEntityId) {
|
private constructor(props: AuthenticatorChallengeProps, id?: UniqueEntityId) {
|
||||||
super(props, id)
|
super(props, id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ import { Entity, Result, UniqueEntityId } from '@standardnotes/domain-core'
|
|||||||
import { EmergencyAccessInvitationProps } from './EmergencyAccessInvitationProps'
|
import { EmergencyAccessInvitationProps } from './EmergencyAccessInvitationProps'
|
||||||
|
|
||||||
export class EmergencyAccessInvitation extends Entity<EmergencyAccessInvitationProps> {
|
export class EmergencyAccessInvitation extends Entity<EmergencyAccessInvitationProps> {
|
||||||
get id(): UniqueEntityId {
|
|
||||||
return this._id
|
|
||||||
}
|
|
||||||
|
|
||||||
private constructor(props: EmergencyAccessInvitationProps, id?: UniqueEntityId) {
|
private constructor(props: EmergencyAccessInvitationProps, id?: UniqueEntityId) {
|
||||||
super(props, id)
|
super(props, id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ describe('AccountDeletionRequestedEventHandler', () => {
|
|||||||
|
|
||||||
ephemeralSession = {
|
ephemeralSession = {
|
||||||
uuid: '2-3-4',
|
uuid: '2-3-4',
|
||||||
userUuid: '1-2-3',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
} as jest.Mocked<EphemeralSession>
|
} as jest.Mocked<EphemeralSession>
|
||||||
|
|
||||||
ephemeralSessionRepository = {} as jest.Mocked<EphemeralSessionRepositoryInterface>
|
ephemeralSessionRepository = {} as jest.Mocked<EphemeralSessionRepositoryInterface>
|
||||||
@@ -68,7 +68,7 @@ describe('AccountDeletionRequestedEventHandler', () => {
|
|||||||
event = {} as jest.Mocked<AccountDeletionRequestedEvent>
|
event = {} as jest.Mocked<AccountDeletionRequestedEvent>
|
||||||
event.createdAt = new Date(1)
|
event.createdAt = new Date(1)
|
||||||
event.payload = {
|
event.payload = {
|
||||||
userUuid: '1-2-3',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
userCreatedAtTimestamp: 1,
|
userCreatedAtTimestamp: 1,
|
||||||
regularSubscriptionUuid: '2-3-4',
|
regularSubscriptionUuid: '2-3-4',
|
||||||
}
|
}
|
||||||
@@ -84,6 +84,14 @@ describe('AccountDeletionRequestedEventHandler', () => {
|
|||||||
expect(userRepository.remove).toHaveBeenCalledWith(user)
|
expect(userRepository.remove).toHaveBeenCalledWith(user)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should not remove a user with invalid uuid', async () => {
|
||||||
|
event.payload.userUuid = 'invalid'
|
||||||
|
|
||||||
|
await createHandler().handle(event)
|
||||||
|
|
||||||
|
expect(userRepository.remove).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
it('should not remove a user if one does not exist', async () => {
|
it('should not remove a user if one does not exist', async () => {
|
||||||
userRepository.findOneByUuid = jest.fn().mockReturnValue(null)
|
userRepository.findOneByUuid = jest.fn().mockReturnValue(null)
|
||||||
|
|
||||||
@@ -100,6 +108,6 @@ describe('AccountDeletionRequestedEventHandler', () => {
|
|||||||
|
|
||||||
expect(sessionRepository.remove).toHaveBeenCalledWith(session)
|
expect(sessionRepository.remove).toHaveBeenCalledWith(session)
|
||||||
expect(revokedSessionRepository.remove).toHaveBeenCalledWith(revokedSession)
|
expect(revokedSessionRepository.remove).toHaveBeenCalledWith(revokedSession)
|
||||||
expect(ephemeralSessionRepository.deleteOne).toHaveBeenCalledWith('2-3-4', '1-2-3')
|
expect(ephemeralSessionRepository.deleteOne).toHaveBeenCalledWith('2-3-4', '00000000-0000-0000-0000-000000000000')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { EphemeralSessionRepositoryInterface } from '../Session/EphemeralSession
|
|||||||
import { RevokedSessionRepositoryInterface } from '../Session/RevokedSessionRepositoryInterface'
|
import { RevokedSessionRepositoryInterface } from '../Session/RevokedSessionRepositoryInterface'
|
||||||
import { SessionRepositoryInterface } from '../Session/SessionRepositoryInterface'
|
import { SessionRepositoryInterface } from '../Session/SessionRepositoryInterface'
|
||||||
import { UserRepositoryInterface } from '../User/UserRepositoryInterface'
|
import { UserRepositoryInterface } from '../User/UserRepositoryInterface'
|
||||||
|
import { Uuid } from '@standardnotes/domain-core'
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class AccountDeletionRequestedEventHandler implements DomainEventHandlerInterface {
|
export class AccountDeletionRequestedEventHandler implements DomainEventHandlerInterface {
|
||||||
@@ -19,19 +20,27 @@ export class AccountDeletionRequestedEventHandler implements DomainEventHandlerI
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async handle(event: AccountDeletionRequestedEvent): Promise<void> {
|
async handle(event: AccountDeletionRequestedEvent): Promise<void> {
|
||||||
const user = await this.userRepository.findOneByUuid(event.payload.userUuid)
|
const userUuidOrError = Uuid.create(event.payload.userUuid)
|
||||||
|
if (userUuidOrError.isFailed()) {
|
||||||
if (user === null) {
|
|
||||||
this.logger.warn(`Could not find user with uuid: ${event.payload.userUuid}`)
|
this.logger.warn(`Could not find user with uuid: ${event.payload.userUuid}`)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const userUuid = userUuidOrError.getValue()
|
||||||
|
|
||||||
await this.removeSessions(event.payload.userUuid)
|
const user = await this.userRepository.findOneByUuid(userUuid)
|
||||||
|
|
||||||
|
if (user === null) {
|
||||||
|
this.logger.warn(`Could not find user with uuid: ${userUuid.value}`)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.removeSessions(userUuid.value)
|
||||||
|
|
||||||
await this.userRepository.remove(user)
|
await this.userRepository.remove(user)
|
||||||
|
|
||||||
this.logger.info(`Finished account cleanup for user: ${event.payload.userUuid}`)
|
this.logger.info(`Finished account cleanup for user: ${userUuid.value}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async removeSessions(userUuid: string): Promise<void> {
|
private async removeSessions(userUuid: string): Promise<void> {
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ import { UserSubscriptionServiceInterface } from '../Subscription/UserSubscripti
|
|||||||
describe('FileRemovedEventHandler', () => {
|
describe('FileRemovedEventHandler', () => {
|
||||||
let userSubscriptionService: UserSubscriptionServiceInterface
|
let userSubscriptionService: UserSubscriptionServiceInterface
|
||||||
let logger: Logger
|
let logger: Logger
|
||||||
let user: User
|
let regularUser: User
|
||||||
|
let sharedUser: User
|
||||||
let event: FileRemovedEvent
|
let event: FileRemovedEvent
|
||||||
let subscriptionSettingService: SubscriptionSettingServiceInterface
|
let subscriptionSettingService: SubscriptionSettingServiceInterface
|
||||||
let regularSubscription: UserSubscription
|
let regularSubscription: UserSubscription
|
||||||
@@ -22,20 +23,24 @@ describe('FileRemovedEventHandler', () => {
|
|||||||
const createHandler = () => new FileRemovedEventHandler(userSubscriptionService, subscriptionSettingService, logger)
|
const createHandler = () => new FileRemovedEventHandler(userSubscriptionService, subscriptionSettingService, logger)
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
user = {
|
regularUser = {
|
||||||
uuid: '123',
|
uuid: '123',
|
||||||
} as jest.Mocked<User>
|
} as jest.Mocked<User>
|
||||||
|
|
||||||
|
sharedUser = {
|
||||||
|
uuid: '234',
|
||||||
|
} as jest.Mocked<User>
|
||||||
|
|
||||||
regularSubscription = {
|
regularSubscription = {
|
||||||
uuid: '1-2-3',
|
uuid: '1-2-3',
|
||||||
subscriptionType: UserSubscriptionType.Regular,
|
subscriptionType: UserSubscriptionType.Regular,
|
||||||
user: Promise.resolve(user),
|
user: Promise.resolve(regularUser),
|
||||||
} as jest.Mocked<UserSubscription>
|
} as jest.Mocked<UserSubscription>
|
||||||
|
|
||||||
sharedSubscription = {
|
sharedSubscription = {
|
||||||
uuid: '2-3-4',
|
uuid: '2-3-4',
|
||||||
subscriptionType: UserSubscriptionType.Shared,
|
subscriptionType: UserSubscriptionType.Shared,
|
||||||
user: Promise.resolve(user),
|
user: Promise.resolve(sharedUser),
|
||||||
} as jest.Mocked<UserSubscription>
|
} as jest.Mocked<UserSubscription>
|
||||||
|
|
||||||
userSubscriptionService = {} as jest.Mocked<UserSubscriptionServiceInterface>
|
userSubscriptionService = {} as jest.Mocked<UserSubscriptionServiceInterface>
|
||||||
@@ -93,10 +98,11 @@ describe('FileRemovedEventHandler', () => {
|
|||||||
unencryptedValue: '222',
|
unencryptedValue: '222',
|
||||||
serverEncryptionVersion: 0,
|
serverEncryptionVersion: 0,
|
||||||
},
|
},
|
||||||
|
user: regularUser,
|
||||||
userSubscription: {
|
userSubscription: {
|
||||||
uuid: '1-2-3',
|
uuid: '1-2-3',
|
||||||
subscriptionType: 'regular',
|
subscriptionType: 'regular',
|
||||||
user: Promise.resolve(user),
|
user: Promise.resolve(regularUser),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -118,10 +124,11 @@ describe('FileRemovedEventHandler', () => {
|
|||||||
unencryptedValue: '222',
|
unencryptedValue: '222',
|
||||||
serverEncryptionVersion: 0,
|
serverEncryptionVersion: 0,
|
||||||
},
|
},
|
||||||
|
user: regularUser,
|
||||||
userSubscription: {
|
userSubscription: {
|
||||||
uuid: '1-2-3',
|
uuid: '1-2-3',
|
||||||
subscriptionType: 'regular',
|
subscriptionType: 'regular',
|
||||||
user: Promise.resolve(user),
|
user: Promise.resolve(regularUser),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -132,10 +139,11 @@ describe('FileRemovedEventHandler', () => {
|
|||||||
unencryptedValue: '222',
|
unencryptedValue: '222',
|
||||||
serverEncryptionVersion: 0,
|
serverEncryptionVersion: 0,
|
||||||
},
|
},
|
||||||
|
user: sharedUser,
|
||||||
userSubscription: {
|
userSubscription: {
|
||||||
uuid: '2-3-4',
|
uuid: '2-3-4',
|
||||||
subscriptionType: 'shared',
|
subscriptionType: 'shared',
|
||||||
user: Promise.resolve(user),
|
user: Promise.resolve(sharedUser),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export class FileRemovedEventHandler implements DomainEventHandlerInterface {
|
|||||||
|
|
||||||
await this.subscriptionSettingService.createOrReplace({
|
await this.subscriptionSettingService.createOrReplace({
|
||||||
userSubscription: subscription,
|
userSubscription: subscription,
|
||||||
|
user,
|
||||||
props: {
|
props: {
|
||||||
name: SettingName.NAMES.FileUploadBytesUsed,
|
name: SettingName.NAMES.FileUploadBytesUsed,
|
||||||
unencryptedValue: (+bytesUsed - byteSize).toString(),
|
unencryptedValue: (+bytesUsed - byteSize).toString(),
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ describe('FileUploadedEventHandler', () => {
|
|||||||
userRepository.findOneByUuid = jest.fn().mockReturnValue(user)
|
userRepository.findOneByUuid = jest.fn().mockReturnValue(user)
|
||||||
|
|
||||||
regularSubscription = {
|
regularSubscription = {
|
||||||
uuid: '1-2-3',
|
uuid: '00000000-0000-0000-0000-000000000000',
|
||||||
subscriptionType: UserSubscriptionType.Regular,
|
subscriptionType: UserSubscriptionType.Regular,
|
||||||
user: Promise.resolve(user),
|
user: Promise.resolve(user),
|
||||||
} as jest.Mocked<UserSubscription>
|
} as jest.Mocked<UserSubscription>
|
||||||
@@ -56,9 +56,9 @@ describe('FileUploadedEventHandler', () => {
|
|||||||
event = {} as jest.Mocked<FileUploadedEvent>
|
event = {} as jest.Mocked<FileUploadedEvent>
|
||||||
event.createdAt = new Date(1)
|
event.createdAt = new Date(1)
|
||||||
event.payload = {
|
event.payload = {
|
||||||
userUuid: '1-2-3',
|
userUuid: '00000000-0000-0000-0000-000000000000',
|
||||||
fileByteSize: 123,
|
fileByteSize: 123,
|
||||||
filePath: '1-2-3/2-3-4',
|
filePath: '00000000-0000-0000-0000-000000000000/2-3-4',
|
||||||
fileName: '2-3-4',
|
fileName: '2-3-4',
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,14 +76,23 @@ describe('FileUploadedEventHandler', () => {
|
|||||||
unencryptedValue: '123',
|
unencryptedValue: '123',
|
||||||
serverEncryptionVersion: 0,
|
serverEncryptionVersion: 0,
|
||||||
},
|
},
|
||||||
|
user,
|
||||||
userSubscription: {
|
userSubscription: {
|
||||||
uuid: '1-2-3',
|
uuid: '00000000-0000-0000-0000-000000000000',
|
||||||
subscriptionType: 'regular',
|
subscriptionType: 'regular',
|
||||||
user: Promise.resolve(user),
|
user: Promise.resolve(user),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should not do anything if a user uuid is invalid', async () => {
|
||||||
|
event.payload.userUuid = 'invalid'
|
||||||
|
|
||||||
|
await createHandler().handle(event)
|
||||||
|
|
||||||
|
expect(subscriptionSettingService.createOrReplace).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
it('should not do anything if a user is not found', async () => {
|
it('should not do anything if a user is not found', async () => {
|
||||||
userRepository.findOneByUuid = jest.fn().mockReturnValue(null)
|
userRepository.findOneByUuid = jest.fn().mockReturnValue(null)
|
||||||
|
|
||||||
@@ -118,8 +127,9 @@ describe('FileUploadedEventHandler', () => {
|
|||||||
unencryptedValue: '468',
|
unencryptedValue: '468',
|
||||||
serverEncryptionVersion: 0,
|
serverEncryptionVersion: 0,
|
||||||
},
|
},
|
||||||
|
user,
|
||||||
userSubscription: {
|
userSubscription: {
|
||||||
uuid: '1-2-3',
|
uuid: '00000000-0000-0000-0000-000000000000',
|
||||||
subscriptionType: 'regular',
|
subscriptionType: 'regular',
|
||||||
user: Promise.resolve(user),
|
user: Promise.resolve(user),
|
||||||
},
|
},
|
||||||
@@ -143,8 +153,9 @@ describe('FileUploadedEventHandler', () => {
|
|||||||
unencryptedValue: '468',
|
unencryptedValue: '468',
|
||||||
serverEncryptionVersion: 0,
|
serverEncryptionVersion: 0,
|
||||||
},
|
},
|
||||||
|
user,
|
||||||
userSubscription: {
|
userSubscription: {
|
||||||
uuid: '1-2-3',
|
uuid: '00000000-0000-0000-0000-000000000000',
|
||||||
subscriptionType: 'regular',
|
subscriptionType: 'regular',
|
||||||
user: Promise.resolve(user),
|
user: Promise.resolve(user),
|
||||||
},
|
},
|
||||||
@@ -157,6 +168,7 @@ describe('FileUploadedEventHandler', () => {
|
|||||||
unencryptedValue: '468',
|
unencryptedValue: '468',
|
||||||
serverEncryptionVersion: 0,
|
serverEncryptionVersion: 0,
|
||||||
},
|
},
|
||||||
|
user,
|
||||||
userSubscription: {
|
userSubscription: {
|
||||||
uuid: '2-3-4',
|
uuid: '2-3-4',
|
||||||
subscriptionType: 'shared',
|
subscriptionType: 'shared',
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import { SubscriptionSettingServiceInterface } from '../Setting/SubscriptionSett
|
|||||||
import { UserSubscription } from '../Subscription/UserSubscription'
|
import { UserSubscription } from '../Subscription/UserSubscription'
|
||||||
import { UserSubscriptionServiceInterface } from '../Subscription/UserSubscriptionServiceInterface'
|
import { UserSubscriptionServiceInterface } from '../Subscription/UserSubscriptionServiceInterface'
|
||||||
import { UserRepositoryInterface } from '../User/UserRepositoryInterface'
|
import { UserRepositoryInterface } from '../User/UserRepositoryInterface'
|
||||||
|
import { User } from '../User/User'
|
||||||
|
import { Uuid } from '@standardnotes/domain-core'
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class FileUploadedEventHandler implements DomainEventHandlerInterface {
|
export class FileUploadedEventHandler implements DomainEventHandlerInterface {
|
||||||
@@ -21,29 +23,41 @@ export class FileUploadedEventHandler implements DomainEventHandlerInterface {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
async handle(event: FileUploadedEvent): Promise<void> {
|
async handle(event: FileUploadedEvent): Promise<void> {
|
||||||
const user = await this.userRepository.findOneByUuid(event.payload.userUuid)
|
const userUuidOrError = Uuid.create(event.payload.userUuid)
|
||||||
|
if (userUuidOrError.isFailed()) {
|
||||||
|
this.logger.warn(userUuidOrError.getError())
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const userUuid = userUuidOrError.getValue()
|
||||||
|
|
||||||
|
const user = await this.userRepository.findOneByUuid(userUuid)
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
this.logger.warn(`Could not find user with uuid: ${event.payload.userUuid}`)
|
this.logger.warn(`Could not find user with uuid: ${userUuid.value}`)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const { regularSubscription, sharedSubscription } =
|
const { regularSubscription, sharedSubscription } =
|
||||||
await this.userSubscriptionService.findRegularSubscriptionForUserUuid(event.payload.userUuid)
|
await this.userSubscriptionService.findRegularSubscriptionForUserUuid(userUuid.value)
|
||||||
if (regularSubscription === null) {
|
if (regularSubscription === null) {
|
||||||
this.logger.warn(`Could not find regular user subscription for user with uuid: ${event.payload.userUuid}`)
|
this.logger.warn(`Could not find regular user subscription for user with uuid: ${userUuid.value}`)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.updateUploadBytesUsedSetting(regularSubscription, event.payload.fileByteSize)
|
await this.updateUploadBytesUsedSetting(regularSubscription, user, event.payload.fileByteSize)
|
||||||
|
|
||||||
if (sharedSubscription !== null) {
|
if (sharedSubscription !== null) {
|
||||||
await this.updateUploadBytesUsedSetting(sharedSubscription, event.payload.fileByteSize)
|
await this.updateUploadBytesUsedSetting(sharedSubscription, user, event.payload.fileByteSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateUploadBytesUsedSetting(subscription: UserSubscription, byteSize: number): Promise<void> {
|
private async updateUploadBytesUsedSetting(
|
||||||
|
subscription: UserSubscription,
|
||||||
|
user: User,
|
||||||
|
byteSize: number,
|
||||||
|
): Promise<void> {
|
||||||
let bytesUsed = '0'
|
let bytesUsed = '0'
|
||||||
const bytesUsedSetting = await this.subscriptionSettingService.findSubscriptionSettingWithDecryptedValue({
|
const bytesUsedSetting = await this.subscriptionSettingService.findSubscriptionSettingWithDecryptedValue({
|
||||||
userUuid: (await subscription.user).uuid,
|
userUuid: (await subscription.user).uuid,
|
||||||
@@ -56,6 +70,7 @@ export class FileUploadedEventHandler implements DomainEventHandlerInterface {
|
|||||||
|
|
||||||
await this.subscriptionSettingService.createOrReplace({
|
await this.subscriptionSettingService.createOrReplace({
|
||||||
userSubscription: subscription,
|
userSubscription: subscription,
|
||||||
|
user,
|
||||||
props: {
|
props: {
|
||||||
name: SettingName.NAMES.FileUploadBytesUsed,
|
name: SettingName.NAMES.FileUploadBytesUsed,
|
||||||
unencryptedValue: (+bytesUsed + byteSize).toString(),
|
unencryptedValue: (+bytesUsed + byteSize).toString(),
|
||||||
|
|||||||
@@ -114,8 +114,6 @@ describe('SubscriptionPurchasedEventHandler', () => {
|
|||||||
|
|
||||||
expect(subscriptionSettingService.applyDefaultSubscriptionSettingsForSubscription).toHaveBeenCalledWith(
|
expect(subscriptionSettingService.applyDefaultSubscriptionSettingsForSubscription).toHaveBeenCalledWith(
|
||||||
subscription,
|
subscription,
|
||||||
SubscriptionName.ProPlan,
|
|
||||||
'123',
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -66,11 +66,7 @@ export class SubscriptionPurchasedEventHandler implements DomainEventHandlerInte
|
|||||||
|
|
||||||
await this.addUserRole(user, event.payload.subscriptionName)
|
await this.addUserRole(user, event.payload.subscriptionName)
|
||||||
|
|
||||||
await this.subscriptionSettingService.applyDefaultSubscriptionSettingsForSubscription(
|
await this.subscriptionSettingService.applyDefaultSubscriptionSettingsForSubscription(userSubscription)
|
||||||
userSubscription,
|
|
||||||
event.payload.subscriptionName,
|
|
||||||
user.uuid,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async addUserRole(user: User, subscriptionName: string): Promise<void> {
|
private async addUserRole(user: User, subscriptionName: string): Promise<void> {
|
||||||
|
|||||||
@@ -94,8 +94,6 @@ describe('SubscriptionReassignedEventHandler', () => {
|
|||||||
|
|
||||||
expect(subscriptionSettingService.applyDefaultSubscriptionSettingsForSubscription).toHaveBeenCalledWith(
|
expect(subscriptionSettingService.applyDefaultSubscriptionSettingsForSubscription).toHaveBeenCalledWith(
|
||||||
subscription,
|
subscription,
|
||||||
SubscriptionName.ProPlan,
|
|
||||||
'123',
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -63,11 +63,7 @@ export class SubscriptionReassignedEventHandler implements DomainEventHandlerInt
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
await this.subscriptionSettingService.applyDefaultSubscriptionSettingsForSubscription(
|
await this.subscriptionSettingService.applyDefaultSubscriptionSettingsForSubscription(userSubscription)
|
||||||
userSubscription,
|
|
||||||
event.payload.subscriptionName,
|
|
||||||
user.uuid,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async addUserRole(user: User, subscriptionName: string): Promise<void> {
|
private async addUserRole(user: User, subscriptionName: string): Promise<void> {
|
||||||
|
|||||||
@@ -129,8 +129,6 @@ describe('SubscriptionSyncRequestedEventHandler', () => {
|
|||||||
|
|
||||||
expect(subscriptionSettingService.applyDefaultSubscriptionSettingsForSubscription).toHaveBeenCalledWith(
|
expect(subscriptionSettingService.applyDefaultSubscriptionSettingsForSubscription).toHaveBeenCalledWith(
|
||||||
subscription,
|
subscription,
|
||||||
SubscriptionName.ProPlan,
|
|
||||||
'123',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(settingService.createOrReplace).toHaveBeenCalledWith({
|
expect(settingService.createOrReplace).toHaveBeenCalledWith({
|
||||||
|
|||||||
@@ -95,11 +95,7 @@ export class SubscriptionSyncRequestedEventHandler implements DomainEventHandler
|
|||||||
|
|
||||||
await this.roleService.addUserRole(user, event.payload.subscriptionName)
|
await this.roleService.addUserRole(user, event.payload.subscriptionName)
|
||||||
|
|
||||||
await this.subscriptionSettingService.applyDefaultSubscriptionSettingsForSubscription(
|
await this.subscriptionSettingService.applyDefaultSubscriptionSettingsForSubscription(userSubscription)
|
||||||
userSubscription,
|
|
||||||
event.payload.subscriptionName,
|
|
||||||
user.uuid,
|
|
||||||
)
|
|
||||||
|
|
||||||
await this.settingService.createOrReplace({
|
await this.settingService.createOrReplace({
|
||||||
user,
|
user,
|
||||||
|
|||||||
@@ -214,13 +214,25 @@ describe('RoleService', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should indicate if a user has given permission', async () => {
|
it('should indicate if a user has given permission', async () => {
|
||||||
const userHasPermission = await createService().userHasPermission('1-2-3', PermissionName.DailyEmailBackup)
|
const userHasPermission = await createService().userHasPermission(
|
||||||
|
'00000000-0000-0000-0000-000000000000',
|
||||||
|
PermissionName.DailyEmailBackup,
|
||||||
|
)
|
||||||
|
|
||||||
expect(userHasPermission).toBeTruthy()
|
expect(userHasPermission).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should not indiciate if a user has permission if the user uuid is invalid', async () => {
|
||||||
|
const userHasPermission = await createService().userHasPermission('invalid', PermissionName.DailyEmailBackup)
|
||||||
|
|
||||||
|
expect(userHasPermission).toBeFalsy()
|
||||||
|
})
|
||||||
|
|
||||||
it('should indicate if a user does not have a given permission', async () => {
|
it('should indicate if a user does not have a given permission', async () => {
|
||||||
const userHasPermission = await createService().userHasPermission('1-2-3', PermissionName.MarkdownProEditor)
|
const userHasPermission = await createService().userHasPermission(
|
||||||
|
'00000000-0000-0000-0000-000000000000',
|
||||||
|
PermissionName.MarkdownProEditor,
|
||||||
|
)
|
||||||
|
|
||||||
expect(userHasPermission).toBeFalsy()
|
expect(userHasPermission).toBeFalsy()
|
||||||
})
|
})
|
||||||
@@ -228,7 +240,10 @@ describe('RoleService', () => {
|
|||||||
it('should indicate user does not have a permission if user could not be found', async () => {
|
it('should indicate user does not have a permission if user could not be found', async () => {
|
||||||
userRepository.findOneByUuid = jest.fn().mockReturnValue(null)
|
userRepository.findOneByUuid = jest.fn().mockReturnValue(null)
|
||||||
|
|
||||||
const userHasPermission = await createService().userHasPermission('1-2-3', PermissionName.MarkdownProEditor)
|
const userHasPermission = await createService().userHasPermission(
|
||||||
|
'00000000-0000-0000-0000-000000000000',
|
||||||
|
PermissionName.MarkdownProEditor,
|
||||||
|
)
|
||||||
|
|
||||||
expect(userHasPermission).toBeFalsy()
|
expect(userHasPermission).toBeFalsy()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { RoleToSubscriptionMapInterface } from './RoleToSubscriptionMapInterface
|
|||||||
import { OfflineUserSubscriptionRepositoryInterface } from '../Subscription/OfflineUserSubscriptionRepositoryInterface'
|
import { OfflineUserSubscriptionRepositoryInterface } from '../Subscription/OfflineUserSubscriptionRepositoryInterface'
|
||||||
import { Role } from './Role'
|
import { Role } from './Role'
|
||||||
import { OfflineUserSubscription } from '../Subscription/OfflineUserSubscription'
|
import { OfflineUserSubscription } from '../Subscription/OfflineUserSubscription'
|
||||||
|
import { Uuid } from '@standardnotes/domain-core'
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class RoleService implements RoleServiceInterface {
|
export class RoleService implements RoleServiceInterface {
|
||||||
@@ -26,10 +27,16 @@ export class RoleService implements RoleServiceInterface {
|
|||||||
@inject(TYPES.Auth_Logger) private logger: Logger,
|
@inject(TYPES.Auth_Logger) private logger: Logger,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async userHasPermission(userUuid: string, permissionName: PermissionName): Promise<boolean> {
|
async userHasPermission(userUuidString: string, permissionName: PermissionName): Promise<boolean> {
|
||||||
|
const userUuidOrError = Uuid.create(userUuidString)
|
||||||
|
if (userUuidOrError.isFailed()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const userUuid = userUuidOrError.getValue()
|
||||||
|
|
||||||
const user = await this.userRepository.findOneByUuid(userUuid)
|
const user = await this.userRepository.findOneByUuid(userUuid)
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
this.logger.warn(`Could not find user with uuid ${userUuid} for permissions check`)
|
this.logger.warn(`Could not find user with uuid ${userUuid.value} for permissions check`)
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ import { Entity, Result, UniqueEntityId } from '@standardnotes/domain-core'
|
|||||||
import { SessionTraceProps } from './SessionTraceProps'
|
import { SessionTraceProps } from './SessionTraceProps'
|
||||||
|
|
||||||
export class SessionTrace extends Entity<SessionTraceProps> {
|
export class SessionTrace extends Entity<SessionTraceProps> {
|
||||||
get id(): UniqueEntityId {
|
|
||||||
return this._id
|
|
||||||
}
|
|
||||||
|
|
||||||
private constructor(props: SessionTraceProps, id?: UniqueEntityId) {
|
private constructor(props: SessionTraceProps, id?: UniqueEntityId) {
|
||||||
super(props, id)
|
super(props, id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { UserSubscription } from '../Subscription/UserSubscription'
|
import { UserSubscription } from '../Subscription/UserSubscription'
|
||||||
|
import { User } from '../User/User'
|
||||||
import { SubscriptionSettingProps } from './SubscriptionSettingProps'
|
import { SubscriptionSettingProps } from './SubscriptionSettingProps'
|
||||||
|
|
||||||
export type CreateOrReplaceSubscriptionSettingDTO = {
|
export type CreateOrReplaceSubscriptionSettingDTO = {
|
||||||
userSubscription: UserSubscription
|
userSubscription: UserSubscription
|
||||||
|
user: User
|
||||||
props: SubscriptionSettingProps
|
props: SubscriptionSettingProps
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ describe('SettingDecrypter', () => {
|
|||||||
serverEncryptionVersion: EncryptionVersion.Default,
|
serverEncryptionVersion: EncryptionVersion.Default,
|
||||||
} as jest.Mocked<Setting>
|
} as jest.Mocked<Setting>
|
||||||
|
|
||||||
expect(await createDecrypter().decryptSettingValue(setting, '1-2-3')).toEqual('decrypted')
|
expect(await createDecrypter().decryptSettingValue(setting, '00000000-0000-0000-0000-000000000000')).toEqual(
|
||||||
|
'decrypted',
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return null if the setting value is null', async () => {
|
it('should return null if the setting value is null', async () => {
|
||||||
@@ -41,7 +43,7 @@ describe('SettingDecrypter', () => {
|
|||||||
serverEncryptionVersion: EncryptionVersion.Default,
|
serverEncryptionVersion: EncryptionVersion.Default,
|
||||||
} as jest.Mocked<Setting>
|
} as jest.Mocked<Setting>
|
||||||
|
|
||||||
expect(await createDecrypter().decryptSettingValue(setting, '1-2-3')).toBeNull()
|
expect(await createDecrypter().decryptSettingValue(setting, '00000000-0000-0000-0000-000000000000')).toBeNull()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return unencrypted value if the setting value is unencrypted', async () => {
|
it('should return unencrypted value if the setting value is unencrypted', async () => {
|
||||||
@@ -50,7 +52,7 @@ describe('SettingDecrypter', () => {
|
|||||||
serverEncryptionVersion: EncryptionVersion.Unencrypted,
|
serverEncryptionVersion: EncryptionVersion.Unencrypted,
|
||||||
} as jest.Mocked<Setting>
|
} as jest.Mocked<Setting>
|
||||||
|
|
||||||
expect(await createDecrypter().decryptSettingValue(setting, '1-2-3')).toEqual('test')
|
expect(await createDecrypter().decryptSettingValue(setting, '00000000-0000-0000-0000-000000000000')).toEqual('test')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw if the user could not be found', async () => {
|
it('should throw if the user could not be found', async () => {
|
||||||
@@ -62,7 +64,23 @@ describe('SettingDecrypter', () => {
|
|||||||
|
|
||||||
let caughtError = null
|
let caughtError = null
|
||||||
try {
|
try {
|
||||||
await createDecrypter().decryptSettingValue(setting, '1-2-3')
|
await createDecrypter().decryptSettingValue(setting, '00000000-0000-0000-0000-000000000000')
|
||||||
|
} catch (error) {
|
||||||
|
caughtError = error
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(caughtError).not.toBeNull()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should throw if the user uuid is invalid', async () => {
|
||||||
|
const setting = {
|
||||||
|
value: 'encrypted',
|
||||||
|
serverEncryptionVersion: EncryptionVersion.Default,
|
||||||
|
} as jest.Mocked<Setting>
|
||||||
|
|
||||||
|
let caughtError = null
|
||||||
|
try {
|
||||||
|
await createDecrypter().decryptSettingValue(setting, 'invalid')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
caughtError = error
|
caughtError = error
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { UserRepositoryInterface } from '../User/UserRepositoryInterface'
|
|||||||
import { Setting } from './Setting'
|
import { Setting } from './Setting'
|
||||||
import { SettingDecrypterInterface } from './SettingDecrypterInterface'
|
import { SettingDecrypterInterface } from './SettingDecrypterInterface'
|
||||||
import { SubscriptionSetting } from './SubscriptionSetting'
|
import { SubscriptionSetting } from './SubscriptionSetting'
|
||||||
|
import { Uuid } from '@standardnotes/domain-core'
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class SettingDecrypter implements SettingDecrypterInterface {
|
export class SettingDecrypter implements SettingDecrypterInterface {
|
||||||
@@ -14,12 +15,18 @@ export class SettingDecrypter implements SettingDecrypterInterface {
|
|||||||
@inject(TYPES.Auth_Crypter) private crypter: CrypterInterface,
|
@inject(TYPES.Auth_Crypter) private crypter: CrypterInterface,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async decryptSettingValue(setting: Setting | SubscriptionSetting, userUuid: string): Promise<string | null> {
|
async decryptSettingValue(setting: Setting | SubscriptionSetting, userUuidString: string): Promise<string | null> {
|
||||||
if (setting.value !== null && setting.serverEncryptionVersion === EncryptionVersion.Default) {
|
if (setting.value !== null && setting.serverEncryptionVersion === EncryptionVersion.Default) {
|
||||||
|
const userUuidOrError = Uuid.create(userUuidString)
|
||||||
|
if (userUuidOrError.isFailed()) {
|
||||||
|
throw new Error(userUuidOrError.getError())
|
||||||
|
}
|
||||||
|
const userUuid = userUuidOrError.getValue()
|
||||||
|
|
||||||
const user = await this.userRepository.findOneByUuid(userUuid)
|
const user = await this.userRepository.findOneByUuid(userUuid)
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
throw new Error(`Could not find user with uuid: ${userUuid}`)
|
throw new Error(`Could not find user with uuid: ${userUuid.value}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.crypter.decryptForUser(setting.value, user)
|
return this.crypter.decryptForUser(setting.value, user)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ describe('SettingService', () => {
|
|||||||
user = {
|
user = {
|
||||||
uuid: '4-5-6',
|
uuid: '4-5-6',
|
||||||
} as jest.Mocked<User>
|
} as jest.Mocked<User>
|
||||||
user.isPotentiallyAVaultAccount = jest.fn().mockReturnValue(false)
|
user.isPotentiallyAPrivateUsernameAccount = jest.fn().mockReturnValue(false)
|
||||||
|
|
||||||
setting = {
|
setting = {
|
||||||
name: SettingName.NAMES.DropboxBackupToken,
|
name: SettingName.NAMES.DropboxBackupToken,
|
||||||
@@ -66,7 +66,7 @@ describe('SettingService', () => {
|
|||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
|
|
||||||
settingsAssociationService.getDefaultSettingsAndValuesForNewVaultAccount = jest.fn().mockReturnValue(
|
settingsAssociationService.getDefaultSettingsAndValuesForNewPrivateUsernameAccount = jest.fn().mockReturnValue(
|
||||||
new Map([
|
new Map([
|
||||||
[
|
[
|
||||||
SettingName.NAMES.LogSessionUserAgent,
|
SettingName.NAMES.LogSessionUserAgent,
|
||||||
@@ -98,7 +98,7 @@ describe('SettingService', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should create default settings for a newly registered vault account', async () => {
|
it('should create default settings for a newly registered vault account', async () => {
|
||||||
user.isPotentiallyAVaultAccount = jest.fn().mockReturnValue(true)
|
user.isPotentiallyAPrivateUsernameAccount = jest.fn().mockReturnValue(true)
|
||||||
|
|
||||||
await createService().applyDefaultSettingsUponRegistration(user)
|
await createService().applyDefaultSettingsUponRegistration(user)
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user