Compare commits

...

109 Commits

Author SHA1 Message Date
standardci
6778a80f21 chore(release): publish new version
- @standardnotes/analytics@2.26.13
 - @standardnotes/api-gateway@1.74.11
 - @standardnotes/auth-server@1.142.0
 - @standardnotes/domain-events-infra@1.12.29
 - @standardnotes/domain-events@2.126.0
 - @standardnotes/event-store@1.11.41
 - @standardnotes/files-server@1.22.20
 - @standardnotes/home-server@1.15.56
 - @standardnotes/revisions-server@1.34.0
 - @standardnotes/scheduler-server@1.20.45
 - @standardnotes/syncing-server@1.96.0
 - @standardnotes/websockets-server@1.10.42
2023-09-15 09:49:09 +00:00
Karol Sójko
d4d49454a6 feat: add skipping verified transitions (#827)
* fix(syncing-server): remove transitioning individual users

* feat: add skipping verified transitions

* fix(auth): remove unused use case
2023-09-15 11:31:52 +02:00
standardci
04b52e6773 chore(release): publish new version
- @standardnotes/auth-server@1.141.14
 - @standardnotes/home-server@1.15.55
 - @standardnotes/syncing-server@1.95.19
2023-09-15 08:53:53 +00:00
Karol Sójko
2a1859e4be fix(auth): remove extensive logs from updating transitions 2023-09-15 10:35:50 +02:00
Karol Sójko
dd9a9c68cb fix(auth): upgrade simplewebauthn dependency (#826) 2023-09-15 10:35:14 +02:00
Karol Sójko
9147ff5d49 fix(syncing-server): remove unused index in mongodb 2023-09-14 14:18:20 +02:00
standardci
503b84531b chore(release): publish new version
- @standardnotes/auth-server@1.141.13
 - @standardnotes/home-server@1.15.54
 - @standardnotes/revisions-server@1.33.21
 - @standardnotes/syncing-server@1.95.18
2023-09-14 10:16:54 +00:00
Karol Sójko
fe8ca828fb fix(auth): set ttl for started and not picked up transitions to 10h 2023-09-14 11:57:21 +02:00
Karol Sójko
03a4a3f2ab fix: skip already updated items and revisions in integrity check (#825) 2023-09-14 11:54:30 +02:00
Karol Sójko
3a8607d146 fix(syncing-server): updating with missing creation date (#824) 2023-09-14 11:45:24 +02:00
standardci
93b6e65554 chore(release): publish new version
- @standardnotes/auth-server@1.141.12
 - @standardnotes/home-server@1.15.53
2023-09-13 10:22:30 +00:00
Karol Sójko
5984e4c3e7 fix(auth): remove re-triggering revisions transition 2023-09-13 11:51:34 +02:00
standardci
b4257c10ea chore(release): publish new version
- @standardnotes/auth-server@1.141.11
 - @standardnotes/home-server@1.15.52
2023-09-13 09:41:28 +00:00
Karol Sójko
c164bde847 fix(auth): passing transition timestamp 2023-09-13 11:03:32 +02:00
standardci
883df939dd chore(release): publish new version
- @standardnotes/api-gateway@1.74.10
 - @standardnotes/auth-server@1.141.10
 - @standardnotes/home-server@1.15.51
 - @standardnotes/revisions-server@1.33.20
 - @standardnotes/syncing-server@1.95.17
2023-09-13 08:40:17 +00:00
Karol Sójko
c7807d0f9e fix: adjust transition timestamps to be universal 2023-09-13 10:25:02 +02:00
standardci
fc90343aaa chore(release): publish new version
- @standardnotes/home-server@1.15.50
 - @standardnotes/revisions-server@1.33.19
 - @standardnotes/syncing-server@1.95.16
2023-09-13 08:17:45 +00:00
Karol Sójko
fbcb45c3a2 fix: include handling updated items in revisions in secondary 2023-09-13 10:00:02 +02:00
standardci
179d8eaaa1 chore(release): publish new version
- @standardnotes/analytics@2.26.12
 - @standardnotes/api-gateway@1.74.9
 - @standardnotes/auth-server@1.141.9
 - @standardnotes/domain-events-infra@1.12.28
 - @standardnotes/domain-events@2.125.4
 - @standardnotes/event-store@1.11.40
 - @standardnotes/files-server@1.22.19
 - @standardnotes/home-server@1.15.49
 - @standardnotes/revisions-server@1.33.18
 - @standardnotes/scheduler-server@1.20.44
 - @standardnotes/syncing-server@1.95.15
 - @standardnotes/websockets-server@1.10.41
2023-09-13 07:47:36 +00:00
Karol Sójko
38685c1861 fix: display transition progress in logs 2023-09-13 09:31:07 +02:00
standardci
cdf42fbe2d chore(release): publish new version
- @standardnotes/home-server@1.15.48
 - @standardnotes/revisions-server@1.33.17
 - @standardnotes/syncing-server@1.95.14
2023-09-13 06:39:14 +00:00
Karol Sójko
9be4c002b7 fix: setting status for already migrated users 2023-09-13 08:21:21 +02:00
standardci
a16c5307a0 chore(release): publish new version
- @standardnotes/home-server@1.15.47
 - @standardnotes/revisions-server@1.33.16
 - @standardnotes/syncing-server@1.95.13
2023-09-13 04:50:15 +00:00
Karol Sójko
d5536f5430 fix(syncing-server): case insensitive integrity check 2023-09-13 06:33:31 +02:00
Karol Sójko
b1d88b15be fix: cleanup only for 0 new items 2023-09-12 22:51:39 +02:00
Karol Sójko
ff78285e43 fix(syncing-server): add catch up timeout for secondary db 2023-09-12 22:24:48 +02:00
standardci
1a26221385 chore(release): publish new version
- @standardnotes/auth-server@1.141.8
 - @standardnotes/home-server@1.15.46
 - @standardnotes/revisions-server@1.33.15
 - @standardnotes/syncing-server@1.95.12
2023-09-12 20:05:02 +00:00
Karol Sójko
54113abe2a fix: imports 2023-09-12 21:31:58 +02:00
Karol Sójko
afe385aed4 fix(auth): remove the transition role constraint 2023-09-12 21:28:48 +02:00
Karol Sójko
f055e52e06 fix(auth): add transition role only if the items transition has completed 2023-09-12 21:26:40 +02:00
Karol Sójko
fab5d18064 fix: sync between primary and secondary database with diff 2023-09-12 21:00:01 +02:00
standardci
a1e654a0d0 chore(release): publish new version
- @standardnotes/home-server@1.15.45
 - @standardnotes/revisions-server@1.33.14
2023-09-12 16:21:14 +00:00
Karol Sójko
aa835268ea fix(revisions): handle transitions with already existing data in secondary 2023-09-12 17:42:11 +02:00
standardci
74b4312928 chore(release): publish new version
- @standardnotes/home-server@1.15.44
 - @standardnotes/syncing-server@1.95.11
2023-09-12 15:17:12 +00:00
Karol Sójko
e91a832152 fix(syncing-server): binding 2023-09-12 16:41:39 +02:00
standardci
4f95bbee3f chore(release): publish new version
- @standardnotes/analytics@2.26.11
 - @standardnotes/api-gateway@1.74.8
 - @standardnotes/auth-server@1.141.7
 - @standardnotes/domain-events-infra@1.12.27
 - @standardnotes/domain-events@2.125.3
 - @standardnotes/event-store@1.11.39
 - @standardnotes/files-server@1.22.18
 - @standardnotes/home-server@1.15.43
 - @standardnotes/revisions-server@1.33.13
 - @standardnotes/scheduler-server@1.20.43
 - @standardnotes/syncing-server@1.95.10
 - @standardnotes/websockets-server@1.10.40
2023-09-12 13:37:37 +00:00
Karol Sójko
b9c9f74d0c fix(syncing-server): log syncing errors 2023-09-12 15:03:11 +02:00
Karol Sójko
e535cd504c fix: retry failed revision transitions 2023-09-12 14:45:17 +02:00
standardci
db0360860a chore(release): publish new version
- @standardnotes/home-server@1.15.42
 - @standardnotes/revisions-server@1.33.12
 - @standardnotes/syncing-server@1.95.9
2023-09-12 10:57:29 +00:00
Karol Sójko
aa2b5f3b74 chore: add logs for failed item dumps 2023-09-12 12:13:55 +02:00
standardci
6241661e27 chore(release): publish new version
- @standardnotes/home-server@1.15.41
 - @standardnotes/syncing-server@1.95.8
2023-09-12 09:38:19 +00:00
Karol Sójko
25047bf46d fix(syncing-server): allow fetching shared vault users for members (#821) 2023-09-12 11:00:55 +02:00
standardci
a1820ed212 chore(release): publish new version
- @standardnotes/analytics@2.26.10
 - @standardnotes/api-gateway@1.74.7
 - @standardnotes/auth-server@1.141.6
 - @standardnotes/domain-core@1.28.1
 - @standardnotes/event-store@1.11.38
 - @standardnotes/files-server@1.22.17
 - @standardnotes/home-server@1.15.40
 - @standardnotes/revisions-server@1.33.11
 - @standardnotes/scheduler-server@1.20.42
 - @standardnotes/settings@1.21.31
 - @standardnotes/syncing-server@1.95.7
 - @standardnotes/websockets-server@1.10.39
2023-09-12 08:55:11 +00:00
Karol Sójko
0a1d1624e8 fix: comparing uuids 2023-09-12 10:21:42 +02:00
standardci
7367de6832 chore(release): publish new version
- @standardnotes/analytics@2.26.9
 - @standardnotes/api-gateway@1.74.6
 - @standardnotes/auth-server@1.141.5
 - @standardnotes/domain-events-infra@1.12.26
 - @standardnotes/domain-events@2.125.2
 - @standardnotes/event-store@1.11.37
 - @standardnotes/files-server@1.22.16
 - @standardnotes/home-server@1.15.39
 - @standardnotes/revisions-server@1.33.10
 - @standardnotes/scheduler-server@1.20.41
 - @standardnotes/syncing-server@1.95.6
 - @standardnotes/websockets-server@1.10.38
2023-09-12 07:40:20 +00:00
Karol Sójko
f0abfe89fc fix: domain event values 2023-09-12 08:59:28 +02:00
standardci
d1244d165a chore(release): publish new version
- @standardnotes/analytics@2.26.8
 - @standardnotes/api-gateway@1.74.5
 - @standardnotes/auth-server@1.141.4
 - @standardnotes/domain-events-infra@1.12.25
 - @standardnotes/domain-events@2.125.1
 - @standardnotes/event-store@1.11.36
 - @standardnotes/files-server@1.22.15
 - @standardnotes/home-server@1.15.38
 - @standardnotes/revisions-server@1.33.9
 - @standardnotes/scheduler-server@1.20.40
 - @standardnotes/security@1.13.1
 - @standardnotes/syncing-server@1.95.5
 - @standardnotes/websockets-server@1.10.37
2023-09-12 06:58:11 +00:00
Karol Sójko
106d8f9192 fix: adjust transitions to not create revisions during ongoing revisions transition 2023-09-12 08:22:50 +02:00
standardci
1d86ba8fcb chore(release): publish new version
- @standardnotes/auth-server@1.141.3
 - @standardnotes/home-server@1.15.37
 - @standardnotes/revisions-server@1.33.8
 - @standardnotes/syncing-server@1.95.4
2023-09-12 05:31:57 +00:00
Karol Sójko
f20a947f8a fix: transition adjustments 2023-09-12 06:52:34 +02:00
standardci
19b9de05ae chore(release): publish new version
- @standardnotes/home-server@1.15.36
 - @standardnotes/syncing-server@1.95.3
2023-09-11 19:06:39 +00:00
Karol Sójko
1d751c0fbe fix: debug sync block 2023-09-11 19:23:09 +02:00
standardci
fa2564e164 chore(release): publish new version
- @standardnotes/auth-server@1.141.2
 - @standardnotes/home-server@1.15.35
 - @standardnotes/revisions-server@1.33.7
 - @standardnotes/syncing-server@1.95.2
2023-09-11 15:18:55 +00:00
Karol Sójko
330bff0124 fix(auth): remove transitioning upon sign out (#819) 2023-09-11 16:42:11 +02:00
standardci
ca57c8e7b5 chore(release): publish new version
- @standardnotes/auth-server@1.141.1
 - @standardnotes/home-server@1.15.34
 - @standardnotes/revisions-server@1.33.6
 - @standardnotes/syncing-server@1.95.1
2023-09-11 13:00:46 +00:00
Karol Sójko
a82b9a0c8a fix: disable running migrations in worker mode of a given service 2023-09-11 14:27:52 +02:00
standardci
ea7e9d73c4 chore(release): publish new version
- @standardnotes/api-gateway@1.74.4
 - @standardnotes/auth-server@1.141.0
 - @standardnotes/home-server@1.15.33
 - @standardnotes/revisions-server@1.33.5
2023-09-11 11:23:06 +00:00
Karol Sójko
117b7b4b99 fix(revisions): removing queries 2023-09-11 12:42:40 +02:00
Karol Sójko
b4bf11d9da fix(revisions): legacy table syncing and select for metadata 2023-09-11 12:23:11 +02:00
Karol Sójko
0306e10469 fix: db debug level on e2e 2023-09-11 12:03:15 +02:00
Karol Sójko
0ab47013f2 fix(api-gateway): awaiting for other services to start 2023-09-11 12:00:43 +02:00
Karol Sójko
836883b82d fix(revisions): rename table only if exists 2023-09-11 11:56:57 +02:00
Karol Sójko
ed671be9c5 fix(revisions): conflict with table naming 2023-09-11 11:52:39 +02:00
Karol Sójko
9676a2586c fix(revisions): add item_uuid to revisions metadata http representation 2023-09-11 11:39:42 +02:00
Karol Sójko
e95ba61c7f feat(auth): add procedure to transition users created between dates (#816) 2023-09-11 10:40:40 +02:00
standardci
a0718aea26 chore(release): publish new version
- @standardnotes/home-server@1.15.32
 - @standardnotes/revisions-server@1.33.4
2023-09-11 07:17:47 +00:00
Karol Sójko
156fa7a618 fix(revisions): add shared vault uuid to revision metadata http representation 2023-09-11 08:44:18 +02:00
standardci
8d006ece30 chore(release): publish new version
- @standardnotes/analytics@2.26.7
 - @standardnotes/api-gateway@1.74.3
 - @standardnotes/auth-server@1.140.0
 - @standardnotes/domain-events-infra@1.12.24
 - @standardnotes/domain-events@2.125.0
 - @standardnotes/event-store@1.11.35
 - @standardnotes/files-server@1.22.14
 - @standardnotes/home-server@1.15.31
 - @standardnotes/revisions-server@1.33.3
 - @standardnotes/scheduler-server@1.20.39
 - @standardnotes/syncing-server@1.95.0
 - @standardnotes/websockets-server@1.10.36
2023-09-08 14:54:00 +00:00
Karol Sójko
037c994040 chore: add run name for e2e test suite 2023-09-08 15:21:26 +02:00
Karol Sójko
a164ba291d fix(auth): specs 2023-09-08 13:41:37 +02:00
Karol Sójko
610fba2601 fix(auth): transition users only when transition mode enabled 2023-09-08 13:34:54 +02:00
Karol Sójko
398338c8f8 feat: transition users after sign out 2023-09-08 12:51:44 +02:00
standardci
34be157d8e chore(release): publish new version
- @standardnotes/home-server@1.15.30
 - @standardnotes/revisions-server@1.33.2
2023-09-08 10:08:48 +00:00
Karol Sójko
76372fe357 fix(revisions): persistence mapper (#814) 2023-09-08 11:29:03 +02:00
standardci
46879c336b chore(release): publish new version
- @standardnotes/auth-server@1.139.0
 - @standardnotes/home-server@1.15.29
 - @standardnotes/syncing-server@1.94.0
2023-09-08 07:53:10 +00:00
Karol Sójko
aef9e936bd feat(auth): add vaults user role into database 2023-09-08 09:19:52 +02:00
Karol Sójko
8cb92d9678 feat(syncing-server): add procedure to trigger transition for specific user 2023-09-08 09:14:07 +02:00
Karol Sójko
52db89de81 chore: disable fail fast on e2e 2023-09-07 19:03:38 +02:00
standardci
c5af8dfc05 chore(release): publish new version
- @standardnotes/home-server@1.15.28
 - @standardnotes/revisions-server@1.33.1
 - @standardnotes/syncing-server@1.93.1
2023-09-07 16:23:44 +00:00
Karol Sójko
27ad8e6959 fix(revisions): waiting for syncing-server on self-hosted setup 2023-09-07 17:44:53 +02:00
Karol Sójko
c4a1502f70 fix(syncing-server): invalidating cache for user removed from shared vault (#812) 2023-09-07 15:41:34 +02:00
standardci
d1d6c753c4 chore(release): publish new version
- @standardnotes/analytics@2.26.6
 - @standardnotes/api-gateway@1.74.2
 - @standardnotes/auth-server@1.138.2
 - @standardnotes/domain-events-infra@1.12.23
 - @standardnotes/domain-events@2.124.0
 - @standardnotes/event-store@1.11.34
 - @standardnotes/files-server@1.22.13
 - @standardnotes/home-server@1.15.27
 - @standardnotes/revisions-server@1.33.0
 - @standardnotes/scheduler-server@1.20.38
 - @standardnotes/syncing-server@1.93.0
 - @standardnotes/websockets-server@1.10.35
2023-09-07 10:46:30 +00:00
Karol Sójko
3bd63f7674 feat: add removing revisions from shared vaults (#811) 2023-09-07 12:02:38 +02:00
standardci
376466d9b2 chore(release): publish new version
- @standardnotes/analytics@2.26.5
 - @standardnotes/api-gateway@1.74.1
 - @standardnotes/auth-server@1.138.1
 - @standardnotes/domain-core@1.28.0
 - @standardnotes/event-store@1.11.33
 - @standardnotes/files-server@1.22.12
 - @standardnotes/home-server@1.15.26
 - @standardnotes/revisions-server@1.32.0
 - @standardnotes/scheduler-server@1.20.37
 - @standardnotes/settings@1.21.30
 - @standardnotes/syncing-server@1.92.1
 - @standardnotes/websockets-server@1.10.34
2023-09-07 09:00:39 +00:00
Karol Sójko
e100c52bbc feat(revisions): fetching single revision in shared vault (#810)
* feat(revisions): fetching single revision in shared vault

* fix(revisions): mapping to http representation
2023-09-07 10:23:03 +02:00
Aman Harwara
d4830dec01 feat: add VaultsUser role name (#809)
* feat: add VaultsUser role name

* fix: test coverage
2023-09-07 08:07:06 +02:00
Karol Sójko
7e11821021 fix(revisions): query for shared vault revisions 2023-09-07 08:05:47 +02:00
standardci
4715e019a2 chore(release): publish new version
- @standardnotes/analytics@2.26.4
 - @standardnotes/api-gateway@1.74.0
 - @standardnotes/auth-server@1.138.0
 - @standardnotes/domain-core@1.27.0
 - @standardnotes/domain-events-infra@1.12.22
 - @standardnotes/domain-events@2.123.0
 - @standardnotes/event-store@1.11.32
 - @standardnotes/files-server@1.22.11
 - @standardnotes/home-server@1.15.25
 - @standardnotes/revisions-server@1.31.0
 - @standardnotes/scheduler-server@1.20.36
 - @standardnotes/security@1.13.0
 - @standardnotes/settings@1.21.29
 - @standardnotes/syncing-server@1.92.0
 - @standardnotes/websockets-server@1.10.33
2023-09-06 14:12:13 +00:00
Karol Sójko
794cd8734a feat: should be able to access shared item revisions as third party user (#807) 2023-09-06 15:36:23 +02:00
standardci
14d42b26bb chore(release): publish new version
- @standardnotes/websockets-server@1.10.32
2023-09-05 12:29:23 +00:00
Karol Sójko
6bb44afd91 fix(websockets): add missing region parameter in api gateway client 2023-09-05 13:50:30 +02:00
standardci
c82345aeeb chore(release): publish new version
- @standardnotes/websockets-server@1.10.31
2023-09-05 06:49:48 +00:00
Karol Sójko
72ab08a0d0 fix(websockets): issue with sending messages to active websocket connections (#806) 2023-09-05 08:13:42 +02:00
standardci
f2d1b47e40 chore(release): publish new version
- @standardnotes/home-server@1.15.24
 - @standardnotes/revisions-server@1.30.14
 - @standardnotes/syncing-server@1.91.3
2023-09-04 12:48:16 +00:00
Karol Sójko
d9ee2c5be2 fix: prevent doubling transitions 2023-09-04 14:10:37 +02:00
standardci
eb59902cf7 chore(release): publish new version
- @standardnotes/home-server@1.15.23
 - @standardnotes/revisions-server@1.30.13
 - @standardnotes/websockets-server@1.10.30
2023-09-04 11:11:04 +00:00
Karol Sójko
002074e4d1 fix(websockets): stringify response from the AWS Api Gateway 2023-09-04 12:32:47 +02:00
Karol Sójko
45b55068f9 fix(revisions): change logs severity in the transition process 2023-09-04 12:19:03 +02:00
Karol Sójko
157eee5d93 chore: increase mocha headless chrome global timeout 2023-09-04 12:06:49 +02:00
standardci
d5f2b4f6eb chore(release): publish new version
- @standardnotes/home-server@1.15.22
 - @standardnotes/revisions-server@1.30.12
 - @standardnotes/websockets-server@1.10.29
2023-09-04 10:05:10 +00:00
Karol Sójko
a7a93497e8 fix(revisions): change order field for transition of revisions 2023-09-04 10:56:14 +02:00
Karol Sójko
8f96f0ed7a fix(websockets): add response debug on websockets sending 2023-09-04 10:43:58 +02:00
standardci
3f064176f2 chore(release): publish new version
- @standardnotes/analytics@2.26.3
 - @standardnotes/api-gateway@1.73.7
 - @standardnotes/auth-server@1.137.6
 - @standardnotes/common@1.50.4
 - @standardnotes/domain-core@1.26.3
 - @standardnotes/domain-events-infra@1.12.21
 - @standardnotes/domain-events@2.122.2
 - @standardnotes/event-store@1.11.31
 - @standardnotes/files-server@1.22.10
 - @standardnotes/home-server@1.15.21
 - @standardnotes/predicates@1.6.11
 - @standardnotes/revisions-server@1.30.11
 - @standardnotes/scheduler-server@1.20.35
 - @standardnotes/security@1.12.2
 - @standardnotes/settings@1.21.28
 - @standardnotes/sncrypto-node@1.15.6
 - @standardnotes/syncing-server@1.91.2
 - @standardnotes/time@1.15.3
 - @standardnotes/websockets-server@1.10.28
2023-09-04 08:26:34 +00:00
Karol Sójko
c7b0c7dfa8 fix(websockets): add debug logs 2023-09-04 09:47:20 +02:00
Karol Sójko
df20dd46db fix(revisions): add more verbose logs to the transition 2023-09-04 09:05:54 +02:00
Karol Sójko
6dfd09989e chore: remove unused nodemon 2023-09-04 08:28:02 +02:00
Karol Sójko
fc821709e2 chore: upgrade docker build push action: 2023-09-04 08:24:39 +02:00
Karol Sójko
e986abaab5 chore: upgrade @types/uuid 2023-09-04 08:23:46 +02:00
Karol Sójko
a006fb3119 chore: upgrade typescript eslint plugin 2023-09-04 08:22:42 +02:00
310 changed files with 5833 additions and 2617 deletions

1
.github/ci.env vendored
View File

@@ -4,6 +4,7 @@ DB_USERNAME=std_notes_user
DB_PASSWORD=changeme123
DB_DATABASE=standard_notes_db
DB_PORT=3306
DB_DEBUG_LEVEL=all
DB_SQLITE_DATABASE_PATH=standard_notes_db
REDIS_PORT=6379
REDIS_HOST=cache

View File

@@ -90,7 +90,7 @@ jobs:
uses: docker/setup-buildx-action@master
- name: Publish Docker image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
builder: ${{ steps.buildx.outputs.name }}
context: ${{ steps.bundle-dir.outputs.temp_dir }}

View File

@@ -21,7 +21,7 @@ jobs:
e2e:
name: (Self Hosting) E2E Test Suite
strategy:
fail-fast: true
fail-fast: false
matrix:
secondary_db_enabled: [true, false]
transition_mode_enabled: [true, false]
@@ -57,7 +57,7 @@ jobs:
run: docker/is-available.sh http://localhost:3123 $(pwd)/logs
- name: Run E2E Test Suite
run: yarn dlx mocha-headless-chrome --timeout 1800000 -f http://localhost:9001/mocha/test.html
run: yarn dlx mocha-headless-chrome --timeout 3600000 -f http://localhost:9001/mocha/test.html
- name: Show logs on failure
if: ${{ failure() }}
@@ -70,7 +70,7 @@ jobs:
e2e-home-server:
name: (Home Server) E2E Test Suite
strategy:
fail-fast: true
fail-fast: false
matrix:
db_type: [mysql, sqlite]
cache_type: [redis, memory]
@@ -141,6 +141,7 @@ jobs:
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 "DB_DEBUG_LEVEL=all" >> packages/home-server/.env
echo "REDIS_URL=redis://localhost:6379" >> packages/home-server/.env
echo "CACHE_TYPE=${{ matrix.cache_type }}" >> packages/home-server/.env
echo "SECONDARY_DB_ENABLED=${{ matrix.secondary_db_enabled }}" >> packages/home-server/.env
@@ -162,7 +163,7 @@ jobs:
run: for i in {1..30}; do curl -s http://localhost:3123/healthcheck && break || sleep 1; done
- name: Run E2E Test Suite
run: yarn dlx mocha-headless-chrome --timeout 1800000 -f http://localhost:9001/mocha/test.html
run: yarn dlx mocha-headless-chrome --timeout 3600000 -f http://localhost:9001/mocha/test.html
- name: Show logs on failure
if: ${{ failure() }}

View File

@@ -35,7 +35,7 @@ jobs:
uses: docker/setup-buildx-action@master
- name: Publish Docker image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
builder: ${{ steps.buildx.outputs.name }}
context: .

View File

@@ -1,5 +1,7 @@
name: E2E Test Suite On Self Hosted Server
run-name: E2E Test Suite against ${{ inputs.ref_name }} by ${{ inputs.author }}
on:
schedule:
- cron: '0 */12 * * *'
@@ -9,6 +11,14 @@ on:
type: string
default: latest
description: The Docker image tag used for SNJS container
author:
type: string
default: unknown
description: The author that triggered the workflow
ref_name:
type: string
default: unknown
description: The ref name from which the workflow was triggered
jobs:
e2e:

866
.pnp.cjs generated

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -53,7 +53,7 @@ services:
image: mysql:8
container_name: db-ci
env_file: .github/ci.env
expose:
ports:
- 3306
restart: unless-stopped
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
@@ -66,7 +66,7 @@ services:
secondary_db:
image: mongo:5.0
container_name: secondary_db-ci
expose:
ports:
- 27017
restart: unless-stopped
volumes:
@@ -83,7 +83,7 @@ services:
container_name: cache-ci
volumes:
- ./data/redis/:/data
expose:
ports:
- 6379
restart: unless-stopped
networks:

View File

@@ -3,6 +3,50 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.26.13](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.12...@standardnotes/analytics@2.26.13) (2023-09-15)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.12](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.11...@standardnotes/analytics@2.26.12) (2023-09-13)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.11](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.10...@standardnotes/analytics@2.26.11) (2023-09-12)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.10](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.9...@standardnotes/analytics@2.26.10) (2023-09-12)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.9](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.8...@standardnotes/analytics@2.26.9) (2023-09-12)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.8](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.7...@standardnotes/analytics@2.26.8) (2023-09-12)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.7](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.6...@standardnotes/analytics@2.26.7) (2023-09-08)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.6](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.5...@standardnotes/analytics@2.26.6) (2023-09-07)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.5](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.4...@standardnotes/analytics@2.26.5) (2023-09-07)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.4](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.3...@standardnotes/analytics@2.26.4) (2023-09-06)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.3](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.2...@standardnotes/analytics@2.26.3) (2023-09-04)
**Note:** Version bump only for package @standardnotes/analytics
## [2.26.2](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.26.1...@standardnotes/analytics@2.26.2) (2023-09-01)
**Note:** Version bump only for package @standardnotes/analytics

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "2.26.2",
"version": "2.26.13",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -29,7 +29,7 @@
"@types/jest": "^29.5.1",
"@types/mixpanel": "^2.14.4",
"@types/node": "^20.5.7",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"eslint": "^8.39.0",
"eslint-plugin-prettier": "^5.0.0",

View File

@@ -3,6 +3,64 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.74.11](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.10...@standardnotes/api-gateway@1.74.11) (2023-09-15)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.10](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.9...@standardnotes/api-gateway@1.74.10) (2023-09-13)
### Bug Fixes
* adjust transition timestamps to be universal ([c7807d0](https://github.com/standardnotes/api-gateway/commit/c7807d0f9e69ce572c4c03ff606375d706f24d9f))
## [1.74.9](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.8...@standardnotes/api-gateway@1.74.9) (2023-09-13)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.8](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.7...@standardnotes/api-gateway@1.74.8) (2023-09-12)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.7](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.6...@standardnotes/api-gateway@1.74.7) (2023-09-12)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.6](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.5...@standardnotes/api-gateway@1.74.6) (2023-09-12)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.5](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.4...@standardnotes/api-gateway@1.74.5) (2023-09-12)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.4](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.3...@standardnotes/api-gateway@1.74.4) (2023-09-11)
### Bug Fixes
* **api-gateway:** awaiting for other services to start ([0ab4701](https://github.com/standardnotes/api-gateway/commit/0ab47013f210dca7aa404966798011947fb5c362))
## [1.74.3](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.2...@standardnotes/api-gateway@1.74.3) (2023-09-08)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.1...@standardnotes/api-gateway@1.74.2) (2023-09-07)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.74.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.74.0...@standardnotes/api-gateway@1.74.1) (2023-09-07)
**Note:** Version bump only for package @standardnotes/api-gateway
# [1.74.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.73.7...@standardnotes/api-gateway@1.74.0) (2023-09-06)
### Features
* should be able to access shared item revisions as third party user ([#807](https://github.com/standardnotes/api-gateway/issues/807)) ([794cd87](https://github.com/standardnotes/api-gateway/commit/794cd8734acf89fb29f09dfb169a3f08f252bb6a))
## [1.73.7](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.73.6...@standardnotes/api-gateway@1.73.7) (2023-09-04)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.73.6](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.73.5...@standardnotes/api-gateway@1.73.6) (2023-09-01)
**Note:** Version bump only for package @standardnotes/api-gateway

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.73.6",
"version": "1.74.11",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -54,12 +54,11 @@
"@types/jsonwebtoken": "^9.0.1",
"@types/node": "^20.5.7",
"@types/prettyjson": "^0.0.30",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"eslint": "^8.39.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"nodemon": "^2.0.19",
"npm-check-updates": "^16.13.2",
"prettier": "^3.0.3",
"ts-jest": "^29.1.0",

View File

@@ -72,6 +72,7 @@ export abstract class AuthMiddleware extends BaseMiddleware {
response.locals.session = decodedToken.session
response.locals.roles = decodedToken.roles
response.locals.sharedVaultOwnerContext = decodedToken.shared_vault_owner_context
response.locals.belongsToSharedVaults = decodedToken.belongs_to_shared_vaults ?? []
} catch (error) {
const errorMessage = (error as AxiosError).isAxiosError
? JSON.stringify((error as AxiosError).response?.data)

View File

@@ -80,15 +80,6 @@ export class UsersController extends BaseHttpController {
)
}
@httpGet('/transition-status', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
async getTransitionStatus(request: Request, response: Response): Promise<void> {
await this.httpService.callAuthServer(
request,
response,
this.endpointResolver.resolveEndpointOrMethodIdentifier('GET', 'users/transition-status'),
)
}
@httpGet('/:userId/params', TYPES.ApiGateway_RequiredCrossServiceTokenMiddleware)
async getKeyParams(request: Request, response: Response): Promise<void> {
await this.httpService.callAuthServer(

View File

@@ -43,7 +43,6 @@ export class EndpointResolver implements EndpointResolverInterface {
['[PATCH]:users/:userId', 'auth.users.update'],
['[PUT]:users/:userUuid/attributes/credentials', 'auth.users.updateCredentials'],
['[GET]:users/params', 'auth.users.getKeyParams'],
['[GET]:users/transition-status', 'auth.users.transition-status'],
['[DELETE]:users/:userUuid', 'auth.users.delete'],
['[POST]:listed', 'auth.users.createListedAccount'],
['[POST]:auth', 'auth.users.register'],
@@ -59,13 +58,11 @@ export class EndpointResolver implements EndpointResolverInterface {
// Syncing Server
['[POST]:items/sync', 'sync.items.sync'],
['[POST]:items/check-integrity', 'sync.items.check_integrity'],
['[POST]:items/transition', 'sync.items.transition'],
['[GET]:items/:uuid', 'sync.items.get_item'],
// Revisions Controller V2
['[GET]:items/:itemUuid/revisions', 'revisions.revisions.getRevisions'],
['[GET]:items/:itemUuid/revisions/:id', 'revisions.revisions.getRevision'],
['[DELETE]:items/:itemUuid/revisions/:id', 'revisions.revisions.deleteRevision'],
['[POST]:revisions/transition', 'revisions.revisions.transition'],
// Messages Controller
['[GET]:messages/', 'sync.messages.get-received'],
['[GET]:messages/outbound', 'sync.messages.get-sent'],

View File

@@ -2,5 +2,8 @@
set -euo pipefail
sh supervisor/wait-for.sh localhost $AUTH_SERVER_PORT
sh supervisor/wait-for.sh localhost $FILES_SERVER_PORT
sh supervisor/wait-for.sh localhost $REVISIONS_SERVER_PORT
sh supervisor/wait-for.sh localhost $SYNCING_SERVER_PORT
node docker/entrypoint-server.js

View File

@@ -3,6 +3,138 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.142.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.14...@standardnotes/auth-server@1.142.0) (2023-09-15)
### Features
* add skipping verified transitions ([#827](https://github.com/standardnotes/server/issues/827)) ([d4d4945](https://github.com/standardnotes/server/commit/d4d49454a68de0acdf440dc202fa14b9743905f6))
## [1.141.14](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.13...@standardnotes/auth-server@1.141.14) (2023-09-15)
### Bug Fixes
* **auth:** remove extensive logs from updating transitions ([2a1859e](https://github.com/standardnotes/server/commit/2a1859e4beff4cc7c4348ebbff8357a8e061bf5e))
* **auth:** upgrade simplewebauthn dependency ([#826](https://github.com/standardnotes/server/issues/826)) ([dd9a9c6](https://github.com/standardnotes/server/commit/dd9a9c68cb431a61700a8e5d8247eb1b505a9d62))
## [1.141.13](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.12...@standardnotes/auth-server@1.141.13) (2023-09-14)
### Bug Fixes
* **auth:** set ttl for started and not picked up transitions to 10h ([fe8ca82](https://github.com/standardnotes/server/commit/fe8ca828fb37306e0e5056627e67366885e86861))
## [1.141.12](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.11...@standardnotes/auth-server@1.141.12) (2023-09-13)
### Bug Fixes
* **auth:** remove re-triggering revisions transition ([5984e4c](https://github.com/standardnotes/server/commit/5984e4c3e7e550e5ed53805bde1e6dabcbe54da8))
## [1.141.11](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.10...@standardnotes/auth-server@1.141.11) (2023-09-13)
### Bug Fixes
* **auth:** passing transition timestamp ([c164bde](https://github.com/standardnotes/server/commit/c164bde847b5974e74fd439f0d439526ad439443))
## [1.141.10](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.9...@standardnotes/auth-server@1.141.10) (2023-09-13)
### Bug Fixes
* adjust transition timestamps to be universal ([c7807d0](https://github.com/standardnotes/server/commit/c7807d0f9e69ce572c4c03ff606375d706f24d9f))
## [1.141.9](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.8...@standardnotes/auth-server@1.141.9) (2023-09-13)
### Bug Fixes
* display transition progress in logs ([38685c1](https://github.com/standardnotes/server/commit/38685c1861b13e398dd96aa39f2cf1aece2090fb))
## [1.141.8](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.7...@standardnotes/auth-server@1.141.8) (2023-09-12)
### Bug Fixes
* **auth:** add transition role only if the items transition has completed ([f055e52](https://github.com/standardnotes/server/commit/f055e52e06b6e93501abd340dfce214d5363bc30))
* **auth:** remove the transition role constraint ([afe385a](https://github.com/standardnotes/server/commit/afe385aed4ba5ca53d8ef429ae4154f4ccf81419))
* imports ([54113ab](https://github.com/standardnotes/server/commit/54113abe2a961720a3561e5ff3a0069046ea8d25))
## [1.141.7](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.6...@standardnotes/auth-server@1.141.7) (2023-09-12)
### Bug Fixes
* retry failed revision transitions ([e535cd5](https://github.com/standardnotes/server/commit/e535cd504cf1929539ff7faf13e9c1fdd2b7bfd1))
## [1.141.6](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.5...@standardnotes/auth-server@1.141.6) (2023-09-12)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.141.5](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.4...@standardnotes/auth-server@1.141.5) (2023-09-12)
### Bug Fixes
* domain event values ([f0abfe8](https://github.com/standardnotes/server/commit/f0abfe89fca0049c47131389683efe2f5aff23f8))
## [1.141.4](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.3...@standardnotes/auth-server@1.141.4) (2023-09-12)
### Bug Fixes
* adjust transitions to not create revisions during ongoing revisions transition ([106d8f9](https://github.com/standardnotes/server/commit/106d8f9192f630794ca4ddc2c4503f2c6cd196e7))
## [1.141.3](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.2...@standardnotes/auth-server@1.141.3) (2023-09-12)
### Bug Fixes
* transition adjustments ([f20a947](https://github.com/standardnotes/server/commit/f20a947f8a555c074d8dc1543c7a8bf61d1d887e))
## [1.141.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.1...@standardnotes/auth-server@1.141.2) (2023-09-11)
### Bug Fixes
* **auth:** remove transitioning upon sign out ([#819](https://github.com/standardnotes/server/issues/819)) ([330bff0](https://github.com/standardnotes/server/commit/330bff0124f5f49c3441304d166ea43c21fea7bc))
## [1.141.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.141.0...@standardnotes/auth-server@1.141.1) (2023-09-11)
### Bug Fixes
* disable running migrations in worker mode of a given service ([a82b9a0](https://github.com/standardnotes/server/commit/a82b9a0c8a023ba8a450ff9e34bcd62f928fcab3))
# [1.141.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.140.0...@standardnotes/auth-server@1.141.0) (2023-09-11)
### Features
* **auth:** add procedure to transition users created between dates ([#816](https://github.com/standardnotes/server/issues/816)) ([e95ba61](https://github.com/standardnotes/server/commit/e95ba61c7f769736698ebbc38179d6dc05a8cc5e))
# [1.140.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.139.0...@standardnotes/auth-server@1.140.0) (2023-09-08)
### Bug Fixes
* **auth:** specs ([a164ba2](https://github.com/standardnotes/server/commit/a164ba291d4893b5a0bb4b39a8795d654212a1a6))
* **auth:** transition users only when transition mode enabled ([610fba2](https://github.com/standardnotes/server/commit/610fba260150d0757020e01ac0c8967feeadd4d6))
### Features
* transition users after sign out ([398338c](https://github.com/standardnotes/server/commit/398338c8f81b12406c7ab3bf1654e60b94d7cfd0))
# [1.139.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.138.2...@standardnotes/auth-server@1.139.0) (2023-09-08)
### Features
* **auth:** add vaults user role into database ([aef9e93](https://github.com/standardnotes/server/commit/aef9e936bdbd1f4ccc32658d3d892e7675ec0e0e))
## [1.138.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.138.1...@standardnotes/auth-server@1.138.2) (2023-09-07)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.138.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.138.0...@standardnotes/auth-server@1.138.1) (2023-09-07)
**Note:** Version bump only for package @standardnotes/auth-server
# [1.138.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.137.6...@standardnotes/auth-server@1.138.0) (2023-09-06)
### Features
* should be able to access shared item revisions as third party user ([#807](https://github.com/standardnotes/server/issues/807)) ([794cd87](https://github.com/standardnotes/server/commit/794cd8734acf89fb29f09dfb169a3f08f252bb6a))
## [1.137.6](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.137.5...@standardnotes/auth-server@1.137.6) (2023-09-04)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.137.5](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.137.4...@standardnotes/auth-server@1.137.5) (2023-09-01)
**Note:** Version bump only for package @standardnotes/auth-server

View File

@@ -75,7 +75,7 @@ const requestBackups = async (
})
}
const container = new ContainerConfigLoader()
const container = new ContainerConfigLoader('worker')
void container.load().then((container) => {
dayjs.extend(utc)

View File

@@ -18,7 +18,7 @@ const cleanup = async (
await cleanupExpiredSessions.execute({ date })
}
const container = new ContainerConfigLoader()
const container = new ContainerConfigLoader('worker')
void container.load().then((container) => {
const env: Env = new Env()
env.load()

View File

@@ -8,7 +8,7 @@ import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
import { PersistStatistics } from '../src/Domain/UseCase/PersistStatistics/PersistStatistics'
const container = new ContainerConfigLoader()
const container = new ContainerConfigLoader('worker')
void container.load().then((container) => {
const env: Env = new Env()
env.load()

View File

@@ -0,0 +1,112 @@
import 'reflect-metadata'
import { Logger } from 'winston'
import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
import { DomainEventFactoryInterface } from '../src/Domain/Event/DomainEventFactoryInterface'
import { UserRepositoryInterface } from '../src/Domain/User/UserRepositoryInterface'
import { TimerInterface } from '@standardnotes/time'
import { TransitionStatusRepositoryInterface } from '../src/Domain/Transition/TransitionStatusRepositoryInterface'
import { RoleName } from '@standardnotes/domain-core'
const inputArgs = process.argv.slice(2)
const startDateString = inputArgs[0]
const endDateString = inputArgs[1]
const requestTransition = async (
transitionStatusRepository: TransitionStatusRepositoryInterface,
userRepository: UserRepositoryInterface,
logger: Logger,
domainEventFactory: DomainEventFactoryInterface,
domainEventPublisher: DomainEventPublisherInterface,
timer: TimerInterface,
): Promise<void> => {
const startDate = new Date(startDateString)
const endDate = new Date(endDateString)
const users = await userRepository.findAllCreatedBetween(startDate, endDate)
const timestamp = timer.getTimestampInMicroseconds()
logger.info(
`[TRANSITION ${timestamp}] Found ${users.length} users created between ${startDateString} and ${endDateString}`,
)
let usersTriggered = 0
for (const user of users) {
const itemsTransitionStatus = await transitionStatusRepository.getStatus(user.uuid, 'items')
const revisionsTransitionStatus = await transitionStatusRepository.getStatus(user.uuid, 'revisions')
const userRoles = await user.roles
const userHasTransitionRole = userRoles.some((role) => role.name === RoleName.NAMES.TransitionUser)
const bothTransitionStatusesAreVerified =
itemsTransitionStatus === 'VERIFIED' && revisionsTransitionStatus === 'VERIFIED'
if (userHasTransitionRole && bothTransitionStatusesAreVerified) {
continue
}
const transitionRequestedEvent = domainEventFactory.createTransitionRequestedEvent({
userUuid: user.uuid,
type: 'items',
timestamp,
})
usersTriggered += 1
await domainEventPublisher.publish(transitionRequestedEvent)
}
logger.info(
`[TRANSITION ${timestamp}] Triggered transition for ${usersTriggered} users created between ${startDateString} and ${endDateString}`,
)
}
const container = new ContainerConfigLoader('worker')
void container.load().then((container) => {
dayjs.extend(utc)
const env: Env = new Env()
env.load()
const logger: Logger = container.get(TYPES.Auth_Logger)
logger.info(`Starting transition request for users created between ${startDateString} and ${endDateString}`)
const userRepository: UserRepositoryInterface = container.get(TYPES.Auth_UserRepository)
const domainEventFactory: DomainEventFactoryInterface = container.get(TYPES.Auth_DomainEventFactory)
const domainEventPublisher: DomainEventPublisherInterface = container.get(TYPES.Auth_DomainEventPublisher)
const timer = container.get<TimerInterface>(TYPES.Auth_Timer)
const transitionStatusRepository = container.get<TransitionStatusRepositoryInterface>(
TYPES.Auth_TransitionStatusRepository,
)
Promise.resolve(
requestTransition(
transitionStatusRepository,
userRepository,
logger,
domainEventFactory,
domainEventPublisher,
timer,
),
)
.then(() => {
logger.info(`Finished transition request for users created between ${startDateString} and ${endDateString}`)
process.exit(0)
})
.catch((error) => {
logger.error(
`Error while requesting transition for users created between ${startDateString} and ${endDateString}: ${error}`,
)
process.exit(1)
})
})

View File

@@ -63,7 +63,7 @@ const requestBackups = async (
return
}
const container = new ContainerConfigLoader()
const container = new ContainerConfigLoader('worker')
void container.load().then((container) => {
dayjs.extend(utc)

View File

@@ -9,7 +9,7 @@ import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-eve
import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
const container = new ContainerConfigLoader()
const container = new ContainerConfigLoader('worker')
void container.load().then((container) => {
dayjs.extend(utc)

View File

@@ -0,0 +1,11 @@
'use strict'
const path = require('path')
const pnp = require(path.normalize(path.resolve(__dirname, '../../..', '.pnp.cjs'))).setup()
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/transition.js')))
Object.defineProperty(exports, '__esModule', { value: true })
exports.default = index

View File

@@ -55,6 +55,13 @@ case "$COMMAND" in
node docker/entrypoint-backup.js one_drive daily
;;
'transition' )
START_DATE=$1 && shift 1
END_DATE=$1 && shift 1
echo "[Docker] Starting Transition..."
node docker/entrypoint-transition.js $START_DATE $END_DATE
;;
* )
echo "[Docker] Unknown command"
;;

View File

@@ -0,0 +1,15 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddSharedVaultUsers1694000575425 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'CREATE TABLE `auth_shared_vault_users` (`uuid` varchar(36) NOT NULL, `shared_vault_uuid` varchar(36) NOT NULL, `user_uuid` varchar(36) NOT NULL, `permission` varchar(24) NOT NULL, `created_at_timestamp` bigint NOT NULL, `updated_at_timestamp` bigint NOT NULL, INDEX `shared_vault_uuid_on_auth_shared_vault_users` (`shared_vault_uuid`), INDEX `user_uuid_on_auth_shared_vault_users` (`user_uuid`), PRIMARY KEY (`uuid`)) ENGINE=InnoDB',
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('DROP INDEX `user_uuid_on_auth_shared_vault_users` ON `auth_shared_vault_users`')
await queryRunner.query('DROP INDEX `shared_vault_uuid_on_auth_shared_vault_users` ON `auth_shared_vault_users`')
await queryRunner.query('DROP TABLE `auth_shared_vault_users`')
}
}

View File

@@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddVaultsUser1694157482134 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'INSERT INTO `roles` (uuid, name, version) VALUES ("35669f45-a2d8-4172-bdab-b7b3d42044ce", "VAULTS_USER", 1)',
)
}
public async down(): Promise<void> {
return
}
}

View File

@@ -0,0 +1,21 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class AddSharedVaultUsers1694000640645 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'CREATE TABLE "auth_shared_vault_users" ("uuid" varchar PRIMARY KEY NOT NULL, "shared_vault_uuid" varchar(36) NOT NULL, "user_uuid" varchar(36) NOT NULL, "permission" varchar(24) NOT NULL, "created_at_timestamp" bigint NOT NULL, "updated_at_timestamp" bigint NOT NULL)',
)
await queryRunner.query(
'CREATE INDEX "shared_vault_uuid_on_auth_shared_vault_users" ON "auth_shared_vault_users" ("shared_vault_uuid") ',
)
await queryRunner.query(
'CREATE INDEX "user_uuid_on_auth_shared_vault_users" ON "auth_shared_vault_users" ("user_uuid") ',
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('DROP INDEX "user_uuid_on_auth_shared_vault_users"')
await queryRunner.query('DROP INDEX "shared_vault_uuid_on_auth_shared_vault_users"')
await queryRunner.query('DROP TABLE "auth_shared_vault_users"')
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.137.5",
"version": "1.142.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -40,8 +40,8 @@
"@aws-sdk/client-sqs": "^3.332.0",
"@cbor-extract/cbor-extract-linux-arm64": "^2.1.1",
"@cbor-extract/cbor-extract-linux-x64": "^2.1.1",
"@simplewebauthn/server": "^7.2.0",
"@simplewebauthn/typescript-types": "^7.0.0",
"@simplewebauthn/server": "^8.1.1",
"@simplewebauthn/typescript-types": "^8.0.0",
"@standardnotes/api": "^1.26.26",
"@standardnotes/common": "workspace:*",
"@standardnotes/domain-core": "workspace:^",
@@ -84,13 +84,12 @@
"@types/otplib": "^10.0.0",
"@types/prettyjson": "^0.0.30",
"@types/ua-parser-js": "^0.7.36",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@types/uuid": "^9.0.3",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"eslint": "^8.39.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"nodemon": "^2.0.19",
"npm-check-updates": "^16.13.2",
"prettier": "^3.0.3",
"ts-jest": "^29.1.0",

View File

@@ -189,6 +189,7 @@ import {
ControllerContainer,
ControllerContainerInterface,
MapperInterface,
SharedVaultUser,
} from '@standardnotes/domain-core'
import { SessionTracePersistenceMapper } from '../Mapping/SessionTracePersistenceMapper'
import { SessionTrace } from '../Domain/Session/SessionTrace'
@@ -262,9 +263,18 @@ import { RedisTransitionStatusRepository } from '../Infra/Redis/RedisTransitionS
import { InMemoryTransitionStatusRepository } from '../Infra/InMemory/InMemoryTransitionStatusRepository'
import { TransitionStatusUpdatedEventHandler } from '../Domain/Handler/TransitionStatusUpdatedEventHandler'
import { UpdateTransitionStatus } from '../Domain/UseCase/UpdateTransitionStatus/UpdateTransitionStatus'
import { GetTransitionStatus } from '../Domain/UseCase/GetTransitionStatus/GetTransitionStatus'
import { TypeORMSharedVaultUser } from '../Infra/TypeORM/TypeORMSharedVaultUser'
import { SharedVaultUserPersistenceMapper } from '../Mapping/SharedVaultUserPersistenceMapper'
import { SharedVaultUserRepositoryInterface } from '../Domain/SharedVault/SharedVaultUserRepositoryInterface'
import { TypeORMSharedVaultUserRepository } from '../Infra/TypeORM/TypeORMSharedVaultUserRepository'
import { AddSharedVaultUser } from '../Domain/UseCase/AddSharedVaultUser/AddSharedVaultUser'
import { RemoveSharedVaultUser } from '../Domain/UseCase/RemoveSharedVaultUser/RemoveSharedVaultUser'
import { UserAddedToSharedVaultEventHandler } from '../Domain/Handler/UserAddedToSharedVaultEventHandler'
import { UserRemovedFromSharedVaultEventHandler } from '../Domain/Handler/UserRemovedFromSharedVaultEventHandler'
export class ContainerConfigLoader {
constructor(private mode: 'server' | 'worker' = 'server') {}
async load(configuration?: {
controllerConatiner?: ControllerContainerInterface
directCallDomainEventPublisher?: DirectCallDomainEventPublisher
@@ -301,7 +311,7 @@ export class ContainerConfigLoader {
}
container.bind<winston.Logger>(TYPES.Auth_Logger).toConstantValue(logger)
const appDataSource = new AppDataSource(env)
const appDataSource = new AppDataSource({ env, runMigrations: this.mode === 'server' })
await appDataSource.initialize()
logger.debug('Database initialized')
@@ -372,6 +382,9 @@ export class ContainerConfigLoader {
container
.bind<MapperInterface<CacheEntry, TypeORMCacheEntry>>(TYPES.Auth_CacheEntryPersistenceMapper)
.toConstantValue(new CacheEntryPersistenceMapper())
container
.bind<MapperInterface<SharedVaultUser, TypeORMSharedVaultUser>>(TYPES.Auth_SharedVaultUserPersistenceMapper)
.toConstantValue(new SharedVaultUserPersistenceMapper())
// ORM
container
@@ -412,6 +425,9 @@ export class ContainerConfigLoader {
container
.bind<Repository<TypeORMCacheEntry>>(TYPES.Auth_ORMCacheEntryRepository)
.toConstantValue(appDataSource.getRepository(TypeORMCacheEntry))
container
.bind<Repository<TypeORMSharedVaultUser>>(TYPES.Auth_ORMSharedVaultUserRepository)
.toConstantValue(appDataSource.getRepository(TypeORMSharedVaultUser))
// Repositories
container.bind<SessionRepositoryInterface>(TYPES.Auth_SessionRepository).to(TypeORMSessionRepository)
@@ -468,6 +484,16 @@ export class ContainerConfigLoader {
container.get(TYPES.Auth_CacheEntryPersistenceMapper),
),
)
container
.bind<SharedVaultUserRepositoryInterface>(TYPES.Auth_SharedVaultUserRepository)
.toConstantValue(
new TypeORMSharedVaultUserRepository(
container.get<Repository<TypeORMSharedVaultUser>>(TYPES.Auth_ORMSharedVaultUserRepository),
container.get<MapperInterface<SharedVaultUser, TypeORMSharedVaultUser>>(
TYPES.Auth_SharedVaultUserPersistenceMapper,
),
),
)
// Middleware
container.bind<SessionMiddleware>(TYPES.Auth_SessionMiddleware).to(SessionMiddleware)
@@ -919,11 +945,15 @@ export class ContainerConfigLoader {
),
)
container
.bind<GetTransitionStatus>(TYPES.Auth_GetTransitionStatus)
.bind<AddSharedVaultUser>(TYPES.Auth_AddSharedVaultUser)
.toConstantValue(
new GetTransitionStatus(
container.get<TransitionStatusRepositoryInterface>(TYPES.Auth_TransitionStatusRepository),
container.get<UserRepositoryInterface>(TYPES.Auth_UserRepository),
new AddSharedVaultUser(container.get<SharedVaultUserRepositoryInterface>(TYPES.Auth_SharedVaultUserRepository)),
)
container
.bind<RemoveSharedVaultUser>(TYPES.Auth_RemoveSharedVaultUser)
.toConstantValue(
new RemoveSharedVaultUser(
container.get<SharedVaultUserRepositoryInterface>(TYPES.Auth_SharedVaultUserRepository),
),
)
@@ -1075,6 +1105,22 @@ export class ContainerConfigLoader {
container.get<winston.Logger>(TYPES.Auth_Logger),
),
)
container
.bind<UserAddedToSharedVaultEventHandler>(TYPES.Auth_UserAddedToSharedVaultEventHandler)
.toConstantValue(
new UserAddedToSharedVaultEventHandler(
container.get<AddSharedVaultUser>(TYPES.Auth_AddSharedVaultUser),
container.get<winston.Logger>(TYPES.Auth_Logger),
),
)
container
.bind<UserRemovedFromSharedVaultEventHandler>(TYPES.Auth_UserRemovedFromSharedVaultEventHandler)
.toConstantValue(
new UserRemovedFromSharedVaultEventHandler(
container.get<RemoveSharedVaultUser>(TYPES.Auth_RemoveSharedVaultUser),
container.get<winston.Logger>(TYPES.Auth_Logger),
),
)
const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([
['USER_REGISTERED', container.get(TYPES.Auth_UserRegisteredEventHandler)],
@@ -1107,6 +1153,8 @@ export class ContainerConfigLoader {
['EMAIL_SUBSCRIPTION_UNSUBSCRIBED', container.get(TYPES.Auth_EmailSubscriptionUnsubscribedEventHandler)],
['PAYMENTS_ACCOUNT_DELETED', container.get(TYPES.Auth_PaymentsAccountDeletedEventHandler)],
['TRANSITION_STATUS_UPDATED', container.get(TYPES.Auth_TransitionStatusUpdatedEventHandler)],
['USER_ADDED_TO_SHARED_VAULT', container.get(TYPES.Auth_UserAddedToSharedVaultEventHandler)],
['USER_REMOVED_FROM_SHARED_VAULT', container.get(TYPES.Auth_UserRemovedFromSharedVaultEventHandler)],
])
if (isConfiguredForHomeServer) {
@@ -1218,7 +1266,6 @@ export class ContainerConfigLoader {
container.get<ClearLoginAttempts>(TYPES.Auth_ClearLoginAttempts),
container.get<IncreaseLoginAttempts>(TYPES.Auth_IncreaseLoginAttempts),
container.get<ChangeCredentials>(TYPES.Auth_ChangeCredentials),
container.get<GetTransitionStatus>(TYPES.Auth_GetTransitionStatus),
container.get<ControllerContainerInterface>(TYPES.Auth_ControllerContainer),
),
)

View File

@@ -18,11 +18,17 @@ import { TypeORMEmergencyAccessInvitation } from '../Infra/TypeORM/TypeORMEmerge
import { TypeORMSessionTrace } from '../Infra/TypeORM/TypeORMSessionTrace'
import { Env } from './Env'
import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions'
import { TypeORMSharedVaultUser } from '../Infra/TypeORM/TypeORMSharedVaultUser'
export class AppDataSource {
private _dataSource: DataSource | undefined
constructor(private env: Env) {}
constructor(
private configuration: {
env: Env
runMigrations: boolean
},
) {}
getRepository<Entity extends ObjectLiteral>(target: EntityTarget<Entity>): Repository<Entity> {
if (!this._dataSource) {
@@ -37,12 +43,12 @@ export class AppDataSource {
}
get dataSource(): DataSource {
this.env.load()
this.configuration.env.load()
const isConfiguredForMySQL = this.env.get('DB_TYPE') === 'mysql'
const isConfiguredForMySQL = this.configuration.env.get('DB_TYPE') === 'mysql'
const maxQueryExecutionTime = this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
? +this.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
const maxQueryExecutionTime = this.configuration.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
? +this.configuration.env.get('DB_MAX_QUERY_EXECUTION_TIME', true)
: 45_000
const commonDataSourceOptions = {
@@ -64,30 +70,31 @@ export class AppDataSource {
TypeORMAuthenticatorChallenge,
TypeORMEmergencyAccessInvitation,
TypeORMCacheEntry,
TypeORMSharedVaultUser,
],
migrations: [`${__dirname}/../../migrations/${isConfiguredForMySQL ? 'mysql' : 'sqlite'}/*.js`],
migrationsRun: true,
logging: <LoggerOptions>this.env.get('DB_DEBUG_LEVEL', true) ?? 'info',
migrationsRun: this.configuration.runMigrations,
logging: <LoggerOptions>this.configuration.env.get('DB_DEBUG_LEVEL', true) ?? 'info',
}
if (isConfiguredForMySQL) {
const inReplicaMode = this.env.get('DB_REPLICA_HOST', true) ? true : false
const inReplicaMode = this.configuration.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'),
host: this.configuration.env.get('DB_HOST'),
port: parseInt(this.configuration.env.get('DB_PORT')),
username: this.configuration.env.get('DB_USERNAME'),
password: this.configuration.env.get('DB_PASSWORD'),
database: this.configuration.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'),
host: this.configuration.env.get('DB_REPLICA_HOST', true),
port: parseInt(this.configuration.env.get('DB_PORT')),
username: this.configuration.env.get('DB_USERNAME'),
password: this.configuration.env.get('DB_PASSWORD'),
database: this.configuration.env.get('DB_DATABASE'),
},
],
removeNodeErrorCount: 10,
@@ -101,11 +108,11 @@ export class AppDataSource {
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'),
host: inReplicaMode ? undefined : this.configuration.env.get('DB_HOST'),
port: inReplicaMode ? undefined : parseInt(this.configuration.env.get('DB_PORT')),
username: inReplicaMode ? undefined : this.configuration.env.get('DB_USERNAME'),
password: inReplicaMode ? undefined : this.configuration.env.get('DB_PASSWORD'),
database: inReplicaMode ? undefined : this.configuration.env.get('DB_DATABASE'),
}
this._dataSource = new DataSource(mySQLDataSourceOptions)
@@ -113,7 +120,7 @@ export class AppDataSource {
const sqliteDataSourceOptions: SqliteConnectionOptions = {
...commonDataSourceOptions,
type: 'sqlite',
database: this.env.get('DB_SQLITE_DATABASE_PATH'),
database: this.configuration.env.get('DB_SQLITE_DATABASE_PATH'),
enableWAL: true,
busyErrorRetry: 2000,
}

View File

@@ -4,4 +4,4 @@ import { Env } from './Env'
const env: Env = new Env()
env.load()
export const MigrationsDataSource = new AppDataSource(env).dataSource
export const MigrationsDataSource = new AppDataSource({ env, runMigrations: true }).dataSource

View File

@@ -9,6 +9,7 @@ const TYPES = {
Auth_AuthenticatorPersistenceMapper: Symbol.for('Auth_AuthenticatorPersistenceMapper'),
Auth_AuthenticatorHttpMapper: Symbol.for('Auth_AuthenticatorHttpMapper'),
Auth_CacheEntryPersistenceMapper: Symbol.for('Auth_CacheEntryPersistenceMapper'),
Auth_SharedVaultUserPersistenceMapper: Symbol.for('Auth_SharedVaultUserPersistenceMapper'),
// Controller
Auth_ControllerContainer: Symbol.for('Auth_ControllerContainer'),
Auth_AuthController: Symbol.for('Auth_AuthController'),
@@ -36,6 +37,7 @@ const TYPES = {
Auth_AuthenticatorChallengeRepository: Symbol.for('Auth_AuthenticatorChallengeRepository'),
Auth_CacheEntryRepository: Symbol.for('Auth_CacheEntryRepository'),
Auth_TransitionStatusRepository: Symbol.for('Auth_TransitionStatusRepository'),
Auth_SharedVaultUserRepository: Symbol.for('Auth_SharedVaultUserRepository'),
// ORM
Auth_ORMOfflineSettingRepository: Symbol.for('Auth_ORMOfflineSettingRepository'),
Auth_ORMOfflineUserSubscriptionRepository: Symbol.for('Auth_ORMOfflineUserSubscriptionRepository'),
@@ -51,6 +53,7 @@ const TYPES = {
Auth_ORMAuthenticatorRepository: Symbol.for('Auth_ORMAuthenticatorRepository'),
Auth_ORMAuthenticatorChallengeRepository: Symbol.for('Auth_ORMAuthenticatorChallengeRepository'),
Auth_ORMCacheEntryRepository: Symbol.for('Auth_ORMCacheEntryRepository'),
Auth_ORMSharedVaultUserRepository: Symbol.for('Auth_ORMSharedVaultUserRepository'),
// Middleware
Auth_RequiredCrossServiceTokenMiddleware: Symbol.for('Auth_RequiredCrossServiceTokenMiddleware'),
Auth_OptionalCrossServiceTokenMiddleware: Symbol.for('Auth_OptionalCrossServiceTokenMiddleware'),
@@ -156,7 +159,8 @@ const TYPES = {
Auth_GetUserKeyParamsRecovery: Symbol.for('Auth_GetUserKeyParamsRecovery'),
Auth_UpdateStorageQuotaUsedForUser: Symbol.for('Auth_UpdateStorageQuotaUsedForUser'),
Auth_UpdateTransitionStatus: Symbol.for('Auth_UpdateTransitionStatus'),
Auth_GetTransitionStatus: Symbol.for('Auth_GetTransitionStatus'),
Auth_AddSharedVaultUser: Symbol.for('Auth_AddSharedVaultUser'),
Auth_RemoveSharedVaultUser: Symbol.for('Auth_RemoveSharedVaultUser'),
// Handlers
Auth_UserRegisteredEventHandler: Symbol.for('Auth_UserRegisteredEventHandler'),
Auth_AccountDeletionRequestedEventHandler: Symbol.for('Auth_AccountDeletionRequestedEventHandler'),
@@ -186,6 +190,8 @@ const TYPES = {
Auth_EmailSubscriptionUnsubscribedEventHandler: Symbol.for('Auth_EmailSubscriptionUnsubscribedEventHandler'),
Auth_PaymentsAccountDeletedEventHandler: Symbol.for('Auth_PaymentsAccountDeletedEventHandler'),
Auth_TransitionStatusUpdatedEventHandler: Symbol.for('Auth_TransitionStatusUpdatedEventHandler'),
Auth_UserAddedToSharedVaultEventHandler: Symbol.for('Auth_UserAddedToSharedVaultEventHandler'),
Auth_UserRemovedFromSharedVaultEventHandler: Symbol.for('Auth_UserRemovedFromSharedVaultEventHandler'),
// Services
Auth_DeviceDetector: Symbol.for('Auth_DeviceDetector'),
Auth_SessionService: Symbol.for('Auth_SessionService'),

View File

@@ -20,6 +20,7 @@ import {
StatisticPersistenceRequestedEvent,
SessionCreatedEvent,
SessionRefreshedEvent,
TransitionRequestedEvent,
} from '@standardnotes/domain-events'
import { Predicate, PredicateVerificationResult } from '@standardnotes/predicates'
import { TimerInterface } from '@standardnotes/time'
@@ -32,6 +33,25 @@ import { DomainEventFactoryInterface } from './DomainEventFactoryInterface'
export class DomainEventFactory implements DomainEventFactoryInterface {
constructor(@inject(TYPES.Auth_Timer) private timer: TimerInterface) {}
createTransitionRequestedEvent(dto: {
userUuid: string
type: 'items' | 'revisions'
timestamp: number
}): TransitionRequestedEvent {
return {
type: 'TRANSITION_REQUESTED',
createdAt: this.timer.getUTCDate(),
meta: {
correlation: {
userIdentifier: dto.userUuid,
userIdentifierType: 'uuid',
},
origin: DomainEventService.Auth,
},
payload: dto,
}
}
createSessionCreatedEvent(dto: { userUuid: string }): SessionCreatedEvent {
return {
type: 'SESSION_CREATED',

View File

@@ -18,6 +18,7 @@ import {
StatisticPersistenceRequestedEvent,
SessionCreatedEvent,
SessionRefreshedEvent,
TransitionRequestedEvent,
} from '@standardnotes/domain-events'
import { InviteeIdentifierType } from '../SharedSubscription/InviteeIdentifierType'
@@ -89,4 +90,9 @@ export interface DomainEventFactoryInterface {
}): StatisticPersistenceRequestedEvent
createSessionCreatedEvent(dto: { userUuid: string }): SessionCreatedEvent
createSessionRefreshedEvent(dto: { userUuid: string }): SessionRefreshedEvent
createTransitionRequestedEvent(dto: {
userUuid: string
type: 'items' | 'revisions'
timestamp: number
}): TransitionRequestedEvent
}

View File

@@ -13,6 +13,7 @@ export class TransitionStatusUpdatedEventHandler implements DomainEventHandlerIn
status: event.payload.status,
userUuid: event.payload.userUuid,
transitionType: event.payload.transitionType,
transitionTimestamp: event.payload.transitionTimestamp,
})
if (result.isFailed()) {

View File

@@ -0,0 +1,24 @@
import { DomainEventHandlerInterface, UserAddedToSharedVaultEvent } from '@standardnotes/domain-events'
import { Logger } from 'winston'
import { AddSharedVaultUser } from '../UseCase/AddSharedVaultUser/AddSharedVaultUser'
export class UserAddedToSharedVaultEventHandler implements DomainEventHandlerInterface {
constructor(
private addSharedVaultUser: AddSharedVaultUser,
private logger: Logger,
) {}
async handle(event: UserAddedToSharedVaultEvent): Promise<void> {
const result = await this.addSharedVaultUser.execute({
userUuid: event.payload.userUuid,
sharedVaultUuid: event.payload.sharedVaultUuid,
permission: event.payload.permission,
createdAt: event.payload.createdAt,
updatedAt: event.payload.updatedAt,
})
if (result.isFailed()) {
this.logger.error(`Failed to add user to shared vault: ${result.getError()}`)
}
}
}

View File

@@ -0,0 +1,22 @@
import { DomainEventHandlerInterface, UserRemovedFromSharedVaultEvent } from '@standardnotes/domain-events'
import { Logger } from 'winston'
import { RemoveSharedVaultUser } from '../UseCase/RemoveSharedVaultUser/RemoveSharedVaultUser'
export class UserRemovedFromSharedVaultEventHandler implements DomainEventHandlerInterface {
constructor(
private removeSharedVaultUser: RemoveSharedVaultUser,
private logger: Logger,
) {}
async handle(event: UserRemovedFromSharedVaultEvent): Promise<void> {
const result = await this.removeSharedVaultUser.execute({
userUuid: event.payload.userUuid,
sharedVaultUuid: event.payload.sharedVaultUuid,
})
if (result.isFailed()) {
this.logger.error(`Failed to remove user from shared vault: ${result.getError()}`)
}
}
}

View File

@@ -0,0 +1,8 @@
import { SharedVaultUser, Uuid } from '@standardnotes/domain-core'
export interface SharedVaultUserRepositoryInterface {
findByUserUuidAndSharedVaultUuid(dto: { userUuid: Uuid; sharedVaultUuid: Uuid }): Promise<SharedVaultUser | null>
findByUserUuid(userUuid: Uuid): Promise<SharedVaultUser[]>
save(sharedVaultUser: SharedVaultUser): Promise<void>
remove(sharedVault: SharedVaultUser): Promise<void>
}

View File

@@ -1,5 +1,11 @@
export interface TransitionStatusRepositoryInterface {
updateStatus(userUuid: string, transitionType: 'items' | 'revisions', status: 'STARTED' | 'FAILED'): Promise<void>
removeStatus(userUuid: string, transitionType: 'items' | 'revisions'): Promise<void>
getStatus(userUuid: string, transitionType: 'items' | 'revisions'): Promise<'STARTED' | 'FAILED' | null>
updateStatus(
userUuid: string,
transitionType: 'items' | 'revisions',
status: 'STARTED' | 'IN_PROGRESS' | 'FINISHED' | 'FAILED' | 'VERIFIED',
): Promise<void>
getStatus(
userUuid: string,
transitionType: 'items' | 'revisions',
): Promise<'STARTED' | 'IN_PROGRESS' | 'FINISHED' | 'FAILED' | 'VERIFIED' | null>
}

View File

@@ -0,0 +1,106 @@
import { Result, SharedVaultUser } from '@standardnotes/domain-core'
import { SharedVaultUserRepositoryInterface } from '../../SharedVault/SharedVaultUserRepositoryInterface'
import { AddSharedVaultUser } from './AddSharedVaultUser'
describe('AddSharedVaultUser', () => {
let sharedVaultUserRepository: SharedVaultUserRepositoryInterface
const createUseCase = () => new AddSharedVaultUser(sharedVaultUserRepository)
beforeEach(() => {
sharedVaultUserRepository = {} as jest.Mocked<SharedVaultUserRepositoryInterface>
sharedVaultUserRepository.save = jest.fn()
})
it('should save shared vault user', async () => {
const useCase = createUseCase()
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
sharedVaultUuid: '00000000-0000-0000-0000-000000000000',
permission: 'read',
createdAt: 1,
updatedAt: 2,
})
expect(result.isFailed()).toBeFalsy()
expect(sharedVaultUserRepository.save).toHaveBeenCalled()
})
it('should fail when user uuid is invalid', async () => {
const useCase = createUseCase()
const result = await useCase.execute({
userUuid: 'invalid',
sharedVaultUuid: '00000000-0000-0000-0000-000000000000',
permission: 'read',
createdAt: 1,
updatedAt: 2,
})
expect(result.isFailed()).toBeTruthy()
expect(sharedVaultUserRepository.save).not.toHaveBeenCalled()
})
it('should fail when shared vault uuid is invalid', async () => {
const useCase = createUseCase()
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
sharedVaultUuid: 'invalid',
permission: 'read',
createdAt: 1,
updatedAt: 2,
})
expect(result.isFailed()).toBeTruthy()
expect(sharedVaultUserRepository.save).not.toHaveBeenCalled()
})
it('should fail when permission is invalid', async () => {
const useCase = createUseCase()
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
sharedVaultUuid: '00000000-0000-0000-0000-000000000000',
permission: 'invalid',
createdAt: 1,
updatedAt: 2,
})
expect(result.isFailed()).toBeTruthy()
expect(sharedVaultUserRepository.save).not.toHaveBeenCalled()
})
it('should fail when timestamps are invalid', async () => {
const useCase = createUseCase()
const result = await useCase.execute({
userUuid: '00000000-0000-0000-0000-000000000000',
sharedVaultUuid: '00000000-0000-0000-0000-000000000000',
permission: 'read',
createdAt: 'invalid' as unknown as number,
updatedAt: 1,
})
expect(result.isFailed()).toBeTruthy()
expect(sharedVaultUserRepository.save).not.toHaveBeenCalled()
})
it('should fail when shared vault user is invalid', async () => {
const mock = jest.spyOn(SharedVaultUser, 'create')
mock.mockReturnValue(Result.fail('Oops'))
const result = await createUseCase().execute({
userUuid: '00000000-0000-0000-0000-000000000000',
sharedVaultUuid: '00000000-0000-0000-0000-000000000000',
permission: 'read',
createdAt: 2,
updatedAt: 1,
})
expect(result.isFailed()).toBeTruthy()
mock.mockRestore()
})
})

View File

@@ -0,0 +1,56 @@
import {
Result,
SharedVaultUser,
SharedVaultUserPermission,
Timestamps,
UseCaseInterface,
Uuid,
} from '@standardnotes/domain-core'
import { SharedVaultUserRepositoryInterface } from '../../SharedVault/SharedVaultUserRepositoryInterface'
import { AddSharedVaultUserDTO } from './AddSharedVaultUserDTO'
export class AddSharedVaultUser implements UseCaseInterface<void> {
constructor(private sharedVaultUserRepository: SharedVaultUserRepositoryInterface) {}
async execute(dto: AddSharedVaultUserDTO): Promise<Result<void>> {
const userUuidOrError = Uuid.create(dto.userUuid)
if (userUuidOrError.isFailed()) {
return Result.fail(userUuidOrError.getError())
}
const userUuid = userUuidOrError.getValue()
const sharedVaultUuidOrError = Uuid.create(dto.sharedVaultUuid)
if (sharedVaultUuidOrError.isFailed()) {
return Result.fail(sharedVaultUuidOrError.getError())
}
const sharedVaultUuid = sharedVaultUuidOrError.getValue()
const permissionOrError = SharedVaultUserPermission.create(dto.permission)
if (permissionOrError.isFailed()) {
return Result.fail(permissionOrError.getError())
}
const permission = permissionOrError.getValue()
const timestampsOrError = Timestamps.create(dto.createdAt, dto.updatedAt)
if (timestampsOrError.isFailed()) {
return Result.fail(timestampsOrError.getError())
}
const timestamps = timestampsOrError.getValue()
const sharedVaultUserOrError = SharedVaultUser.create({
userUuid,
sharedVaultUuid,
permission,
timestamps,
})
if (sharedVaultUserOrError.isFailed()) {
return Result.fail(sharedVaultUserOrError.getError())
}
const sharedVaultUser = sharedVaultUserOrError.getValue()
await this.sharedVaultUserRepository.save(sharedVaultUser)
return Result.ok()
}
}

Some files were not shown because too many files have changed in this diff Show More