mirror of
https://github.com/standardnotes/server
synced 2026-02-13 14:01:13 -05:00
Compare commits
12 Commits
@standardn
...
@standardn
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b55d80a7cd | ||
|
|
16f92bdc99 | ||
|
|
4c5738416a | ||
|
|
45d4920e0f | ||
|
|
94e738532a | ||
|
|
c4ae12d53f | ||
|
|
4ff78452f9 | ||
|
|
9465f2ecd8 | ||
|
|
93c2f1f12f | ||
|
|
ca8a3fc77d | ||
|
|
00936e06bc | ||
|
|
a6dea50d74 |
BIN
.yarn/cache/@aws-sdk-client-s3-npm-3.445.0-fd17753af1-0a75a875cc.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-client-s3-npm-3.445.0-fd17753af1-0a75a875cc.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-client-sso-npm-3.445.0-201a856f2d-e0a8dc55fe.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-client-sso-npm-3.445.0-201a856f2d-e0a8dc55fe.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-client-sts-npm-3.445.0-94a7ac045f-f6d8ba39c0.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-client-sts-npm-3.445.0-94a7ac045f-f6d8ba39c0.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-core-npm-3.445.0-7420fe10a0-49d3719dba.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-core-npm-3.445.0-7420fe10a0-49d3719dba.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-credential-provider-env-npm-3.433.0-c654acd3b0-f1742342e4.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-credential-provider-env-npm-3.433.0-c654acd3b0-f1742342e4.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-credential-provider-ini-npm-3.445.0-ce6e456dae-491bafcbd5.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-credential-provider-ini-npm-3.445.0-ce6e456dae-491bafcbd5.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-credential-provider-node-npm-3.445.0-e46f520013-de0f42a581.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-credential-provider-node-npm-3.445.0-e46f520013-de0f42a581.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-credential-provider-process-npm-3.433.0-1f04178c18-ae5c357a48.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-credential-provider-process-npm-3.433.0-1f04178c18-ae5c357a48.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-credential-provider-sso-npm-3.445.0-55379ab4a6-674ca0b198.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-credential-provider-sso-npm-3.445.0-55379ab4a6-674ca0b198.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-credential-provider-web-identity-npm-3.433.0-d9c6f05357-fd5dc00316.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-credential-provider-web-identity-npm-3.433.0-d9c6f05357-fd5dc00316.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-middleware-bucket-endpoint-npm-3.433.0-75f3e083f1-4b8be28542.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-middleware-bucket-endpoint-npm-3.433.0-75f3e083f1-4b8be28542.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-middleware-expect-continue-npm-3.433.0-686c619b17-5a90a82c97.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-middleware-expect-continue-npm-3.433.0-686c619b17-5a90a82c97.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-middleware-flexible-checksums-npm-3.433.0-aedc837cff-895134e75f.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-middleware-flexible-checksums-npm-3.433.0-aedc837cff-895134e75f.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-middleware-host-header-npm-3.433.0-2d83f070b1-9cb0d75e5a.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-middleware-host-header-npm-3.433.0-2d83f070b1-9cb0d75e5a.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-middleware-location-constraint-npm-3.433.0-c994175ec3-b34361ae53.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-middleware-location-constraint-npm-3.433.0-c994175ec3-b34361ae53.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-middleware-logger-npm-3.433.0-89cf073fb9-0a0e7b0cc7.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-middleware-logger-npm-3.433.0-89cf073fb9-0a0e7b0cc7.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-middleware-recursion-detection-npm-3.433.0-27e67d3aaa-98d69e0466.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-middleware-recursion-detection-npm-3.433.0-27e67d3aaa-98d69e0466.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-middleware-sdk-s3-npm-3.440.0-c747652356-445be8121d.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-middleware-sdk-s3-npm-3.440.0-c747652356-445be8121d.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-middleware-sdk-sts-npm-3.433.0-2d279e516c-7c4d1768d3.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-middleware-sdk-sts-npm-3.433.0-2d279e516c-7c4d1768d3.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-middleware-signing-npm-3.433.0-3c0b9eb352-d7167473ee.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-middleware-signing-npm-3.433.0-3c0b9eb352-d7167473ee.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-middleware-ssec-npm-3.433.0-975479b90c-c080a66e5a.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-middleware-ssec-npm-3.433.0-975479b90c-c080a66e5a.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-middleware-user-agent-npm-3.438.0-e2a53e4959-1113259e54.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-middleware-user-agent-npm-3.438.0-e2a53e4959-1113259e54.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-region-config-resolver-npm-3.433.0-bc89f96cf1-450c73dcc7.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-region-config-resolver-npm-3.433.0-bc89f96cf1-450c73dcc7.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-signature-v4-multi-region-npm-3.437.0-38d95938ff-c537a28b20.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-signature-v4-multi-region-npm-3.437.0-38d95938ff-c537a28b20.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-token-providers-npm-3.438.0-4b94ec7c93-9c4f56de35.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-token-providers-npm-3.438.0-4b94ec7c93-9c4f56de35.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-types-npm-3.433.0-a08a292a43-527cda15da.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-types-npm-3.433.0-a08a292a43-527cda15da.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-util-endpoints-npm-3.438.0-6888f0e906-811dc75ece.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-util-endpoints-npm-3.438.0-6888f0e906-811dc75ece.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-util-user-agent-browser-npm-3.433.0-2f197d08d3-7b88a0a8f1.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-util-user-agent-browser-npm-3.433.0-2f197d08d3-7b88a0a8f1.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@aws-sdk-util-user-agent-node-npm-3.437.0-25f3a8fa22-0390fbea8a.zip
vendored
Normal file
BIN
.yarn/cache/@aws-sdk-util-user-agent-node-npm-3.437.0-25f3a8fa22-0390fbea8a.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-abort-controller-npm-2.0.12-284507d2d9-ade23e7e6d.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-abort-controller-npm-2.0.12-284507d2d9-ade23e7e6d.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-config-resolver-npm-2.0.16-7b859ffe5a-94665f8960.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-config-resolver-npm-2.0.16-7b859ffe5a-94665f8960.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-credential-provider-imds-npm-2.0.18-4843469616-76665cb083.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-credential-provider-imds-npm-2.0.18-4843469616-76665cb083.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-eventstream-codec-npm-2.0.12-ae100efef3-e2be231894.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-eventstream-codec-npm-2.0.12-ae100efef3-e2be231894.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-eventstream-serde-browser-npm-2.0.12-af51c5ffaa-6dbd214f75.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-eventstream-serde-browser-npm-2.0.12-af51c5ffaa-6dbd214f75.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-eventstream-serde-config-resolver-npm-2.0.12-d12ed9f499-869959136f.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-eventstream-serde-config-resolver-npm-2.0.12-d12ed9f499-869959136f.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-eventstream-serde-node-npm-2.0.12-b20645b33e-fb4fab3b5d.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-eventstream-serde-node-npm-2.0.12-b20645b33e-fb4fab3b5d.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-eventstream-serde-universal-npm-2.0.12-b1fd809aea-5de9fe4eab.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-eventstream-serde-universal-npm-2.0.12-b1fd809aea-5de9fe4eab.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-fetch-http-handler-npm-2.2.4-a07dc01282-0151a1b7f4.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-fetch-http-handler-npm-2.2.4-a07dc01282-0151a1b7f4.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-hash-blob-browser-npm-2.0.12-8ec60a052a-d0147b2860.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-hash-blob-browser-npm-2.0.12-8ec60a052a-d0147b2860.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-hash-node-npm-2.0.12-dc19684da2-73d8a5121a.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-hash-node-npm-2.0.12-dc19684da2-73d8a5121a.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-hash-stream-node-npm-2.0.12-837568259a-bcc24b615b.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-hash-stream-node-npm-2.0.12-837568259a-bcc24b615b.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-invalid-dependency-npm-2.0.12-fc7b4dbf99-4749da004a.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-invalid-dependency-npm-2.0.12-fc7b4dbf99-4749da004a.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-md5-js-npm-2.0.12-ff265e11d5-aca6a60871.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-md5-js-npm-2.0.12-ff265e11d5-aca6a60871.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-middleware-content-length-npm-2.0.14-dad35dc8cc-0a2d091368.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-middleware-content-length-npm-2.0.14-dad35dc8cc-0a2d091368.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-middleware-endpoint-npm-2.1.3-ebc2051146-a82b2b1aed.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-middleware-endpoint-npm-2.1.3-ebc2051146-a82b2b1aed.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-middleware-retry-npm-2.0.18-9fe8673f23-e18d073352.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-middleware-retry-npm-2.0.18-9fe8673f23-e18d073352.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-middleware-serde-npm-2.0.12-5c1625ab21-18406d2203.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-middleware-serde-npm-2.0.12-5c1625ab21-18406d2203.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-middleware-stack-npm-2.0.6-fcbeb7e7fc-f98dcd7688.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-middleware-stack-npm-2.0.6-fcbeb7e7fc-f98dcd7688.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-node-config-provider-npm-2.1.3-1ef774bf1f-f53d0cda8c.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-node-config-provider-npm-2.1.3-1ef774bf1f-f53d0cda8c.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-node-http-handler-npm-2.1.8-8ac787c2b2-aca079234e.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-node-http-handler-npm-2.1.8-8ac787c2b2-aca079234e.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-property-provider-npm-2.0.13-04595bfd4f-5b9469d17e.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-property-provider-npm-2.0.13-04595bfd4f-5b9469d17e.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-protocol-http-npm-3.0.8-3bec477c37-014df5fe50.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-protocol-http-npm-3.0.8-3bec477c37-014df5fe50.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-querystring-builder-npm-2.0.12-1035f75405-e3ba93e719.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-querystring-builder-npm-2.0.12-1035f75405-e3ba93e719.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-querystring-parser-npm-2.0.12-7c25c8b3f7-e491478c97.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-querystring-parser-npm-2.0.12-7c25c8b3f7-e491478c97.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-service-error-classification-npm-2.0.5-e08d76788e-fcd3e267de.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-service-error-classification-npm-2.0.5-e08d76788e-fcd3e267de.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-shared-ini-file-loader-npm-2.2.2-90c60eb131-ee3b6a9b0f.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-shared-ini-file-loader-npm-2.2.2-90c60eb131-ee3b6a9b0f.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-smithy-client-npm-2.1.12-2961adb1b3-78ad4c6599.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-smithy-client-npm-2.1.12-2961adb1b3-78ad4c6599.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-types-npm-2.4.0-79f798587a-d8998f754c.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-types-npm-2.4.0-79f798587a-d8998f754c.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-url-parser-npm-2.0.12-da5f841dc2-636e2548f7.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-url-parser-npm-2.0.12-da5f841dc2-636e2548f7.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-util-defaults-mode-browser-npm-2.0.16-b18594bcc4-388444a93e.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-util-defaults-mode-browser-npm-2.0.16-b18594bcc4-388444a93e.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-util-defaults-mode-node-npm-2.0.21-2a982d91e7-f0efa3e351.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-util-defaults-mode-node-npm-2.0.21-2a982d91e7-f0efa3e351.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-util-endpoints-npm-1.0.2-924b9d70eb-7438acafe9.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-util-endpoints-npm-1.0.2-924b9d70eb-7438acafe9.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-util-middleware-npm-2.0.5-bd5abccaea-13dc6d8ee9.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-util-middleware-npm-2.0.5-bd5abccaea-13dc6d8ee9.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-util-retry-npm-2.0.5-4f31bcfd57-83019b0b92.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-util-retry-npm-2.0.5-4f31bcfd57-83019b0b92.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-util-stream-npm-2.0.17-7d45860ae5-3d55c712db.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-util-stream-npm-2.0.17-7d45860ae5-3d55c712db.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@smithy-util-waiter-npm-2.0.12-0d6eb3dd54-bc5a5d1ce2.zip
vendored
Normal file
BIN
.yarn/cache/@smithy-util-waiter-npm-2.0.12-0d6eb3dd54-bc5a5d1ce2.zip
vendored
Normal file
Binary file not shown.
@@ -3,6 +3,18 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.81.13](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.12...@standardnotes/api-gateway@1.81.13) (2023-11-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **api-gateway:** add possibility to configure keep-alive timeout ([#920](https://github.com/standardnotes/api-gateway/issues/920)) ([16f92bd](https://github.com/standardnotes/api-gateway/commit/16f92bdc990ded5c3f1fe5af1e6e4a113a9954de))
|
||||
|
||||
## [1.81.12](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.11...@standardnotes/api-gateway@1.81.12) (2023-11-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* reduce websockets api communication data ([#919](https://github.com/standardnotes/api-gateway/issues/919)) ([c4ae12d](https://github.com/standardnotes/api-gateway/commit/c4ae12d53fc166879f90a4c5dbad1ab1cb4797e2))
|
||||
|
||||
## [1.81.11](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.81.10...@standardnotes/api-gateway@1.81.11) (2023-11-07)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -102,9 +102,11 @@ void container.load().then((container) => {
|
||||
})
|
||||
})
|
||||
|
||||
const serverInstance = server.build()
|
||||
const serverInstance = server.build().listen(env.get('PORT'))
|
||||
|
||||
serverInstance.listen(env.get('PORT'))
|
||||
const keepAliveTimeout = env.get('KEEP_ALIVE_TIMEOUT', true) ? +env.get('KEEP_ALIVE_TIMEOUT', true) : 5000
|
||||
|
||||
serverInstance.keepAliveTimeout = keepAliveTimeout
|
||||
|
||||
logger.info(`Server started on port ${process.env.PORT}`)
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/api-gateway",
|
||||
"version": "1.81.11",
|
||||
"version": "1.81.13",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <21.0.0"
|
||||
},
|
||||
|
||||
@@ -143,7 +143,18 @@ export class HttpServiceProxy implements ServiceProxyInterface {
|
||||
return
|
||||
}
|
||||
|
||||
await this.callServer(this.webSocketServerUrl, request, response, endpointOrMethodIdentifier, payload)
|
||||
const isARequestComingFromApiGatewayAndShouldBeKeptInMinimalFormat = request.headers.connectionid !== undefined
|
||||
if (isARequestComingFromApiGatewayAndShouldBeKeptInMinimalFormat) {
|
||||
await this.callServerWithLegacyFormat(
|
||||
this.webSocketServerUrl,
|
||||
request,
|
||||
response,
|
||||
endpointOrMethodIdentifier,
|
||||
payload,
|
||||
)
|
||||
} else {
|
||||
await this.callServer(this.webSocketServerUrl, request, response, endpointOrMethodIdentifier, payload)
|
||||
}
|
||||
}
|
||||
|
||||
async callPaymentsServer(
|
||||
|
||||
@@ -3,6 +3,24 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.167.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.167.1...@standardnotes/auth-server@1.167.2) (2023-11-08)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add logs about sending websocket events to clients ([9465f2e](https://github.com/standardnotes/server/commit/9465f2ecd8e8f0bf3ebeeb3976227b1b105aded0))
|
||||
|
||||
## [1.167.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.167.0...@standardnotes/auth-server@1.167.1) (2023-11-08)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **auth:** path to delete accounts script ([ca8a3fc](https://github.com/standardnotes/server/commit/ca8a3fc77d91410f0dee8c3ddef29c09947c9cf5))
|
||||
|
||||
# [1.167.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.166.0...@standardnotes/auth-server@1.167.0) (2023-11-08)
|
||||
|
||||
### Features
|
||||
|
||||
* script to mass delete accounts from CSV source ([#913](https://github.com/standardnotes/server/issues/913)) ([a6dea50](https://github.com/standardnotes/server/commit/a6dea50d745ff6f051fd9ede168aef27036159c3))
|
||||
|
||||
# [1.166.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.165.4...@standardnotes/auth-server@1.166.0) (2023-11-07)
|
||||
|
||||
### Features
|
||||
|
||||
43
packages/auth/bin/delete_accounts.ts
Normal file
43
packages/auth/bin/delete_accounts.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { Logger } from 'winston'
|
||||
|
||||
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
|
||||
import TYPES from '../src/Bootstrap/Types'
|
||||
import { Env } from '../src/Bootstrap/Env'
|
||||
import { DeleteAccountsFromCSVFile } from '../src/Domain/UseCase/DeleteAccountsFromCSVFile/DeleteAccountsFromCSVFile'
|
||||
|
||||
const inputArgs = process.argv.slice(2)
|
||||
const fileName = inputArgs[0]
|
||||
const mode = inputArgs[1]
|
||||
|
||||
const deleteAccounts = async (deleteAccountsFromCSVFile: DeleteAccountsFromCSVFile): Promise<void> => {
|
||||
await deleteAccountsFromCSVFile.execute({
|
||||
fileName,
|
||||
dryRun: mode !== 'delete',
|
||||
})
|
||||
}
|
||||
|
||||
const container = new ContainerConfigLoader('worker')
|
||||
void container.load().then((container) => {
|
||||
const env: Env = new Env()
|
||||
env.load()
|
||||
|
||||
const logger: Logger = container.get(TYPES.Auth_Logger)
|
||||
|
||||
logger.info('Starting mass accounts deletion from CSV file')
|
||||
|
||||
const deleteAccountsFromCSVFile = container.get<DeleteAccountsFromCSVFile>(TYPES.Auth_DeleteAccountsFromCSVFile)
|
||||
|
||||
Promise.resolve(deleteAccounts(deleteAccountsFromCSVFile))
|
||||
.then(() => {
|
||||
logger.info('Accounts deleted.')
|
||||
|
||||
process.exit(0)
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error(`Could not delete accounts: ${error.message}`)
|
||||
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
11
packages/auth/docker/entrypoint-delete-accounts.js
Normal file
11
packages/auth/docker/entrypoint-delete-accounts.js
Normal 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/delete_accounts.js')))
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true })
|
||||
|
||||
exports.default = index
|
||||
@@ -40,6 +40,13 @@ case "$COMMAND" in
|
||||
node docker/entrypoint-user-email-backup.js $EMAIL
|
||||
;;
|
||||
|
||||
'delete-accounts' )
|
||||
echo "[Docker] Starting Accounts Deleting from CSV..."
|
||||
FILE_NAME=$1 && shift 1
|
||||
MODE=$1 && shift 1
|
||||
node docker/entrypoint-delete-accounts.js $FILE_NAME $MODE
|
||||
;;
|
||||
|
||||
* )
|
||||
echo "[Docker] Unknown command"
|
||||
;;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/auth-server",
|
||||
"version": "1.166.0",
|
||||
"version": "1.167.2",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <21.0.0"
|
||||
},
|
||||
@@ -32,6 +32,7 @@
|
||||
"migrate": "yarn build && yarn typeorm migration:run -d dist/src/Bootstrap/DataSource.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.445.0",
|
||||
"@aws-sdk/client-sns": "^3.427.0",
|
||||
"@aws-sdk/client-sqs": "^3.427.0",
|
||||
"@cbor-extract/cbor-extract-linux-arm64": "^2.1.1",
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as winston from 'winston'
|
||||
import Redis from 'ioredis'
|
||||
import { SNSClient, SNSClientConfig } from '@aws-sdk/client-sns'
|
||||
import { SQSClient, SQSClientConfig } from '@aws-sdk/client-sqs'
|
||||
import { S3Client } from '@aws-sdk/client-s3'
|
||||
import { Container } from 'inversify'
|
||||
import {
|
||||
DomainEventHandlerInterface,
|
||||
@@ -276,6 +277,9 @@ import { UserInvitedToSharedVaultEventHandler } from '../Domain/Handler/UserInvi
|
||||
import { TriggerPostSettingUpdateActions } from '../Domain/UseCase/TriggerPostSettingUpdateActions/TriggerPostSettingUpdateActions'
|
||||
import { TriggerEmailBackupForUser } from '../Domain/UseCase/TriggerEmailBackupForUser/TriggerEmailBackupForUser'
|
||||
import { TriggerEmailBackupForAllUsers } from '../Domain/UseCase/TriggerEmailBackupForAllUsers/TriggerEmailBackupForAllUsers'
|
||||
import { CSVFileReaderInterface } from '../Domain/CSV/CSVFileReaderInterface'
|
||||
import { S3CsvFileReader } from '../Infra/S3/S3CsvFileReader'
|
||||
import { DeleteAccountsFromCSVFile } from '../Domain/UseCase/DeleteAccountsFromCSVFile/DeleteAccountsFromCSVFile'
|
||||
|
||||
export class ContainerConfigLoader {
|
||||
constructor(private mode: 'server' | 'worker' = 'server') {}
|
||||
@@ -370,6 +374,19 @@ export class ContainerConfigLoader {
|
||||
}
|
||||
const sqsClient = new SQSClient(sqsConfig)
|
||||
container.bind<SQSClient>(TYPES.Auth_SQS).toConstantValue(sqsClient)
|
||||
|
||||
container.bind<S3Client>(TYPES.Auth_S3).toConstantValue(
|
||||
new S3Client({
|
||||
apiVersion: 'latest',
|
||||
region: env.get('S3_AWS_REGION', true),
|
||||
}),
|
||||
)
|
||||
|
||||
container
|
||||
.bind<CSVFileReaderInterface>(TYPES.Auth_CSVFileReader)
|
||||
.toConstantValue(
|
||||
new S3CsvFileReader(env.get('S3_AUTH_SCRIPTS_DATA_BUCKET', true), container.get<S3Client>(TYPES.Auth_S3)),
|
||||
)
|
||||
}
|
||||
|
||||
container.bind(TYPES.Auth_SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true))
|
||||
@@ -1251,6 +1268,17 @@ export class ContainerConfigLoader {
|
||||
container.get<TriggerEmailBackupForUser>(TYPES.Auth_TriggerEmailBackupForUser),
|
||||
),
|
||||
)
|
||||
if (!isConfiguredForHomeServer) {
|
||||
container
|
||||
.bind<DeleteAccountsFromCSVFile>(TYPES.Auth_DeleteAccountsFromCSVFile)
|
||||
.toConstantValue(
|
||||
new DeleteAccountsFromCSVFile(
|
||||
container.get<CSVFileReaderInterface>(TYPES.Auth_CSVFileReader),
|
||||
container.get<DeleteAccount>(TYPES.Auth_DeleteAccount),
|
||||
container.get<winston.Logger>(TYPES.Auth_Logger),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
// Controller
|
||||
container
|
||||
|
||||
@@ -3,6 +3,7 @@ const TYPES = {
|
||||
Auth_Redis: Symbol.for('Auth_Redis'),
|
||||
Auth_SNS: Symbol.for('Auth_SNS'),
|
||||
Auth_SQS: Symbol.for('Auth_SQS'),
|
||||
Auth_S3: Symbol.for('Auth_S3'),
|
||||
// Mapping
|
||||
Auth_SessionTracePersistenceMapper: Symbol.for('Auth_SessionTracePersistenceMapper'),
|
||||
Auth_AuthenticatorChallengePersistenceMapper: Symbol.for('Auth_AuthenticatorChallengePersistenceMapper'),
|
||||
@@ -167,6 +168,7 @@ const TYPES = {
|
||||
Auth_TriggerPostSettingUpdateActions: Symbol.for('Auth_TriggerPostSettingUpdateActions'),
|
||||
Auth_TriggerEmailBackupForUser: Symbol.for('Auth_TriggerEmailBackupForUser'),
|
||||
Auth_TriggerEmailBackupForAllUsers: Symbol.for('Auth_TriggerEmailBackupForAllUsers'),
|
||||
Auth_DeleteAccountsFromCSVFile: Symbol.for('Auth_DeleteAccountsFromCSVFile'),
|
||||
// Handlers
|
||||
Auth_AccountDeletionRequestedEventHandler: Symbol.for('Auth_AccountDeletionRequestedEventHandler'),
|
||||
Auth_SubscriptionPurchasedEventHandler: Symbol.for('Auth_SubscriptionPurchasedEventHandler'),
|
||||
@@ -251,6 +253,7 @@ const TYPES = {
|
||||
Auth_BaseOfflineController: Symbol.for('Auth_BaseOfflineController'),
|
||||
Auth_BaseListedController: Symbol.for('Auth_BaseListedController'),
|
||||
Auth_BaseFeaturesController: Symbol.for('Auth_BaseFeaturesController'),
|
||||
Auth_CSVFileReader: Symbol.for('Auth_CSVFileReader'),
|
||||
}
|
||||
|
||||
export default TYPES
|
||||
|
||||
5
packages/auth/src/Domain/CSV/CSVFileReaderInterface.ts
Normal file
5
packages/auth/src/Domain/CSV/CSVFileReaderInterface.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { Result } from '@standardnotes/domain-core'
|
||||
|
||||
export interface CSVFileReaderInterface {
|
||||
getValues(fileName: string): Promise<Result<string[]>>
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import { Logger } from 'winston'
|
||||
import { Result } from '@standardnotes/domain-core'
|
||||
|
||||
import { CSVFileReaderInterface } from '../../CSV/CSVFileReaderInterface'
|
||||
import { DeleteAccount } from '../DeleteAccount/DeleteAccount'
|
||||
import { DeleteAccountsFromCSVFile } from './DeleteAccountsFromCSVFile'
|
||||
|
||||
describe('DeleteAccountsFromCSVFile', () => {
|
||||
let csvFileReader: CSVFileReaderInterface
|
||||
let deleteAccount: DeleteAccount
|
||||
let logger: Logger
|
||||
|
||||
const createUseCase = () => new DeleteAccountsFromCSVFile(csvFileReader, deleteAccount, logger)
|
||||
|
||||
beforeEach(() => {
|
||||
csvFileReader = {} as jest.Mocked<CSVFileReaderInterface>
|
||||
csvFileReader.getValues = jest.fn().mockResolvedValue(Result.ok(['email1']))
|
||||
|
||||
deleteAccount = {} as jest.Mocked<DeleteAccount>
|
||||
deleteAccount.execute = jest.fn().mockResolvedValue(Result.ok(''))
|
||||
|
||||
logger = {} as jest.Mocked<Logger>
|
||||
logger.info = jest.fn()
|
||||
})
|
||||
|
||||
it('should delete accounts', async () => {
|
||||
const useCase = createUseCase()
|
||||
|
||||
const result = await useCase.execute({ fileName: 'test.csv', dryRun: false })
|
||||
|
||||
expect(result.isFailed()).toBeFalsy()
|
||||
})
|
||||
|
||||
it('should return error if csv file is invalid', async () => {
|
||||
csvFileReader.getValues = jest.fn().mockResolvedValue(Result.fail('Oops'))
|
||||
|
||||
const useCase = createUseCase()
|
||||
|
||||
const result = await useCase.execute({ fileName: 'test.csv', dryRun: false })
|
||||
|
||||
expect(result.isFailed()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('should return error if csv file is empty', async () => {
|
||||
csvFileReader.getValues = jest.fn().mockResolvedValue(Result.ok([]))
|
||||
|
||||
const useCase = createUseCase()
|
||||
|
||||
const result = await useCase.execute({ fileName: 'test.csv', dryRun: false })
|
||||
|
||||
expect(result.isFailed()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('should do nothing on a dry run', async () => {
|
||||
const useCase = createUseCase()
|
||||
|
||||
const result = await useCase.execute({ fileName: 'test.csv', dryRun: true })
|
||||
|
||||
expect(deleteAccount.execute).not.toHaveBeenCalled()
|
||||
expect(result.isFailed()).toBeFalsy()
|
||||
})
|
||||
|
||||
it('should return error if delete account fails', async () => {
|
||||
deleteAccount.execute = jest.fn().mockResolvedValue(Result.fail('Oops'))
|
||||
|
||||
const useCase = createUseCase()
|
||||
|
||||
const result = await useCase.execute({ fileName: 'test.csv', dryRun: false })
|
||||
|
||||
expect(result.isFailed()).toBeTruthy()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,47 @@
|
||||
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
|
||||
import { Logger } from 'winston'
|
||||
|
||||
import { DeleteAccount } from '../DeleteAccount/DeleteAccount'
|
||||
import { CSVFileReaderInterface } from '../../CSV/CSVFileReaderInterface'
|
||||
import { DeleteAccountsFromCSVFileDTO } from './DeleteAccountsFromCSVFileDTO'
|
||||
|
||||
export class DeleteAccountsFromCSVFile implements UseCaseInterface<void> {
|
||||
constructor(
|
||||
private csvFileReader: CSVFileReaderInterface,
|
||||
private deleteAccount: DeleteAccount,
|
||||
private logger: Logger,
|
||||
) {}
|
||||
|
||||
async execute(dto: DeleteAccountsFromCSVFileDTO): Promise<Result<void>> {
|
||||
const emailsOrError = await this.csvFileReader.getValues(dto.fileName)
|
||||
if (emailsOrError.isFailed()) {
|
||||
return Result.fail(emailsOrError.getError())
|
||||
}
|
||||
const emails = emailsOrError.getValue()
|
||||
|
||||
if (emails.length === 0) {
|
||||
return Result.fail(`No emails found in CSV file ${dto.fileName}`)
|
||||
}
|
||||
|
||||
if (dto.dryRun) {
|
||||
const firstTenEmails = emails.slice(0, 10)
|
||||
this.logger.info(
|
||||
`Dry run mode enabled. Would delete ${emails.length} accounts. First 10 emails: ${firstTenEmails}`,
|
||||
)
|
||||
|
||||
return Result.ok()
|
||||
}
|
||||
|
||||
for (const email of emails) {
|
||||
const deleteAccountOrError = await this.deleteAccount.execute({
|
||||
username: email,
|
||||
})
|
||||
|
||||
if (deleteAccountOrError.isFailed()) {
|
||||
return Result.fail(deleteAccountOrError.getError())
|
||||
}
|
||||
}
|
||||
|
||||
return Result.ok()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface DeleteAccountsFromCSVFileDTO {
|
||||
fileName: string
|
||||
dryRun: boolean
|
||||
}
|
||||
32
packages/auth/src/Infra/S3/S3CsvFileReader.ts
Normal file
32
packages/auth/src/Infra/S3/S3CsvFileReader.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { S3Client, GetObjectCommand } from '@aws-sdk/client-s3'
|
||||
import { Result } from '@standardnotes/domain-core'
|
||||
|
||||
import { CSVFileReaderInterface } from '../../Domain/CSV/CSVFileReaderInterface'
|
||||
|
||||
export class S3CsvFileReader implements CSVFileReaderInterface {
|
||||
constructor(
|
||||
private s3BucketName: string,
|
||||
private s3Client: S3Client,
|
||||
) {}
|
||||
|
||||
async getValues(fileName: string): Promise<Result<string[]>> {
|
||||
if (this.s3BucketName.length === 0) {
|
||||
return Result.fail('S3 bucket name is not set')
|
||||
}
|
||||
|
||||
const response = await this.s3Client.send(
|
||||
new GetObjectCommand({
|
||||
Bucket: this.s3BucketName,
|
||||
Key: fileName,
|
||||
}),
|
||||
)
|
||||
|
||||
if (response.Body === undefined) {
|
||||
return Result.fail(`Could not find CSV file at path: ${fileName}`)
|
||||
}
|
||||
|
||||
const csvContent = await response.Body.transformToString()
|
||||
|
||||
return Result.ok(csvContent.split('\n').filter((line) => line.length > 0))
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,14 @@ import { DomainEventFactoryInterface } from '../../Domain/Event/DomainEventFacto
|
||||
import { User } from '../../Domain/User/User'
|
||||
import { ClientServiceInterface } from '../../Domain/Client/ClientServiceInterface'
|
||||
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
|
||||
import { Logger } from 'winston'
|
||||
|
||||
@injectable()
|
||||
export class WebSocketsClientService implements ClientServiceInterface {
|
||||
constructor(
|
||||
@inject(TYPES.Auth_DomainEventFactory) private domainEventFactory: DomainEventFactoryInterface,
|
||||
@inject(TYPES.Auth_DomainEventPublisher) private domainEventPublisher: DomainEventPublisherInterface,
|
||||
@inject(TYPES.Auth_Logger) private logger: Logger,
|
||||
) {}
|
||||
|
||||
async sendUserRolesChangedEvent(user: User): Promise<void> {
|
||||
@@ -20,6 +22,8 @@ export class WebSocketsClientService implements ClientServiceInterface {
|
||||
(await user.roles).map((role) => role.name),
|
||||
)
|
||||
|
||||
this.logger.info(`[WebSockets] Requesting message ${event.type} to user ${user.uuid}`)
|
||||
|
||||
await this.domainEventPublisher.publish(
|
||||
this.domainEventFactory.createWebSocketMessageRequestedEvent({
|
||||
userUuid: user.uuid,
|
||||
|
||||
@@ -3,6 +3,30 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.18.31](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.18.30...@standardnotes/home-server@1.18.31) (2023-11-09)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/home-server
|
||||
|
||||
## [1.18.30](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.18.29...@standardnotes/home-server@1.18.30) (2023-11-09)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/home-server
|
||||
|
||||
## [1.18.29](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.18.28...@standardnotes/home-server@1.18.29) (2023-11-09)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/home-server
|
||||
|
||||
## [1.18.28](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.18.27...@standardnotes/home-server@1.18.28) (2023-11-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/home-server
|
||||
|
||||
## [1.18.27](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.18.26...@standardnotes/home-server@1.18.27) (2023-11-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/home-server
|
||||
|
||||
## [1.18.26](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.18.25...@standardnotes/home-server@1.18.26) (2023-11-08)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/home-server
|
||||
|
||||
## [1.18.25](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.18.24...@standardnotes/home-server@1.18.25) (2023-11-07)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/home-server
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/home-server",
|
||||
"version": "1.18.25",
|
||||
"version": "1.18.31",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <21.0.0"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,18 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.120.5](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.120.4...@standardnotes/syncing-server@1.120.5) (2023-11-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* remove unused axios dep in subservices ([45d4920](https://github.com/standardnotes/syncing-server-js/commit/45d4920e0fc2848a28ce888d139201e68c4b416f))
|
||||
|
||||
## [1.120.4](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.120.3...@standardnotes/syncing-server@1.120.4) (2023-11-08)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add logs about sending websocket events to clients ([9465f2e](https://github.com/standardnotes/syncing-server-js/commit/9465f2ecd8e8f0bf3ebeeb3976227b1b105aded0))
|
||||
|
||||
## [1.120.3](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.120.2...@standardnotes/syncing-server@1.120.3) (2023-11-07)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/syncing-server
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/syncing-server",
|
||||
"version": "1.120.3",
|
||||
"version": "1.120.5",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <21.0.0"
|
||||
},
|
||||
@@ -40,7 +40,6 @@
|
||||
"@standardnotes/settings": "workspace:*",
|
||||
"@standardnotes/sncrypto-node": "workspace:*",
|
||||
"@standardnotes/time": "workspace:*",
|
||||
"axios": "^1.1.3",
|
||||
"cors": "2.8.5",
|
||||
"dotenv": "^16.0.1",
|
||||
"express": "^4.18.2",
|
||||
|
||||
@@ -44,9 +44,6 @@ import {
|
||||
DomainEventPublisherInterface,
|
||||
DomainEventSubscriberInterface,
|
||||
} from '@standardnotes/domain-events'
|
||||
import axios, { AxiosInstance } from 'axios'
|
||||
import { ExtensionsHttpService } from '../Domain/Extension/ExtensionsHttpService'
|
||||
import { ExtensionsHttpServiceInterface } from '../Domain/Extension/ExtensionsHttpServiceInterface'
|
||||
import { AccountDeletionRequestedEventHandler } from '../Domain/Handler/AccountDeletionRequestedEventHandler'
|
||||
import { DuplicateItemSyncedEventHandler } from '../Domain/Handler/DuplicateItemSyncedEventHandler'
|
||||
import { EmailBackupRequestedEventHandler } from '../Domain/Handler/EmailBackupRequestedEventHandler'
|
||||
@@ -554,6 +551,7 @@ export class ContainerConfigLoader {
|
||||
new SendEventToClient(
|
||||
container.get<DomainEventFactoryInterface>(TYPES.Sync_DomainEventFactory),
|
||||
container.get<DomainEventPublisherInterface>(TYPES.Sync_DomainEventPublisher),
|
||||
container.get<Logger>(TYPES.Sync_Logger),
|
||||
),
|
||||
)
|
||||
container
|
||||
@@ -948,20 +946,7 @@ export class ContainerConfigLoader {
|
||||
)
|
||||
|
||||
// Services
|
||||
container.bind<ContentDecoder>(TYPES.Sync_ContentDecoder).toDynamicValue(() => new ContentDecoder())
|
||||
container.bind<AxiosInstance>(TYPES.Sync_HTTPClient).toDynamicValue(() => axios.create())
|
||||
container
|
||||
.bind<ExtensionsHttpServiceInterface>(TYPES.Sync_ExtensionsHttpService)
|
||||
.toConstantValue(
|
||||
new ExtensionsHttpService(
|
||||
container.get<AxiosInstance>(TYPES.Sync_HTTPClient),
|
||||
container.get<ItemRepositoryInterface>(TYPES.Sync_SQLItemRepository),
|
||||
container.get<ContentDecoderInterface>(TYPES.Sync_ContentDecoder),
|
||||
container.get<DomainEventPublisherInterface>(TYPES.Sync_DomainEventPublisher),
|
||||
container.get<DomainEventFactoryInterface>(TYPES.Sync_DomainEventFactory),
|
||||
container.get<Logger>(TYPES.Sync_Logger),
|
||||
),
|
||||
)
|
||||
container.bind<ContentDecoderInterface>(TYPES.Sync_ContentDecoder).toDynamicValue(() => new ContentDecoder())
|
||||
|
||||
const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([
|
||||
['DUPLICATE_ITEM_SYNCED', container.get(TYPES.Sync_DuplicateItemSyncedEventHandler)],
|
||||
|
||||
@@ -104,7 +104,6 @@ const TYPES = {
|
||||
Sync_SyncResponseFactory20161215: Symbol.for('Sync_SyncResponseFactory20161215'),
|
||||
Sync_SyncResponseFactory20200115: Symbol.for('Sync_SyncResponseFactory20200115'),
|
||||
Sync_SyncResponseFactoryResolver: Symbol.for('Sync_SyncResponseFactoryResolver'),
|
||||
Sync_ExtensionsHttpService: Symbol.for('Sync_ExtensionsHttpService'),
|
||||
Sync_ItemBackupService: Symbol.for('Sync_ItemBackupService'),
|
||||
Sync_ItemSaveValidator: Symbol.for('Sync_ItemSaveValidator'),
|
||||
Sync_OwnershipFilter: Symbol.for('Sync_OwnershipFilter'),
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export enum ExtensionName {
|
||||
Dropbox = 'Dropbox',
|
||||
GoogleDrive = 'Google Drive',
|
||||
OneDrive = 'OneDrive',
|
||||
}
|
||||
@@ -1,438 +0,0 @@
|
||||
import 'reflect-metadata'
|
||||
|
||||
import { KeyParamsData } from '@standardnotes/responses'
|
||||
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
|
||||
import { Logger } from 'winston'
|
||||
import { ContentDecoderInterface } from '../Item/ContentDecoderInterface'
|
||||
import { Item } from '../Item/Item'
|
||||
import { ItemRepositoryInterface } from '../Item/ItemRepositoryInterface'
|
||||
import { ExtensionsHttpService } from './ExtensionsHttpService'
|
||||
import { DomainEventFactoryInterface } from '../Event/DomainEventFactoryInterface'
|
||||
import { AxiosInstance } from 'axios'
|
||||
import { Uuid, ContentType, Dates, Timestamps, UniqueEntityId } from '@standardnotes/domain-core'
|
||||
|
||||
describe('ExtensionsHttpService', () => {
|
||||
let httpClient: AxiosInstance
|
||||
let primaryItemRepository: ItemRepositoryInterface
|
||||
let contentDecoder: ContentDecoderInterface
|
||||
let domainEventPublisher: DomainEventPublisherInterface
|
||||
let domainEventFactory: DomainEventFactoryInterface
|
||||
let item: Item
|
||||
let authParams: KeyParamsData
|
||||
let logger: Logger
|
||||
|
||||
const createService = () =>
|
||||
new ExtensionsHttpService(
|
||||
httpClient,
|
||||
primaryItemRepository,
|
||||
contentDecoder,
|
||||
domainEventPublisher,
|
||||
domainEventFactory,
|
||||
logger,
|
||||
)
|
||||
|
||||
beforeEach(() => {
|
||||
httpClient = {} as jest.Mocked<AxiosInstance>
|
||||
httpClient.request = jest.fn().mockReturnValue({ status: 200, data: { foo: 'bar' } })
|
||||
|
||||
item = Item.create(
|
||||
{
|
||||
userUuid: Uuid.create('00000000-0000-0000-0000-000000000000').getValue(),
|
||||
updatedWithSession: null,
|
||||
content: 'foobar',
|
||||
contentType: ContentType.create(ContentType.TYPES.Note).getValue(),
|
||||
encItemKey: null,
|
||||
authHash: null,
|
||||
itemsKeyId: null,
|
||||
duplicateOf: null,
|
||||
deleted: false,
|
||||
dates: Dates.create(new Date(1616164633241311), new Date(1616164633241311)).getValue(),
|
||||
timestamps: Timestamps.create(1616164633241311, 1616164633241311).getValue(),
|
||||
},
|
||||
new UniqueEntityId('00000000-0000-0000-0000-000000000000'),
|
||||
).getValue()
|
||||
|
||||
authParams = {} as jest.Mocked<KeyParamsData>
|
||||
|
||||
primaryItemRepository = {} as jest.Mocked<ItemRepositoryInterface>
|
||||
primaryItemRepository.findByUuidAndUserUuid = jest.fn().mockReturnValue(item)
|
||||
|
||||
logger = {} as jest.Mocked<Logger>
|
||||
logger.error = jest.fn()
|
||||
|
||||
domainEventPublisher = {} as jest.Mocked<DomainEventPublisherInterface>
|
||||
domainEventPublisher.publish = jest.fn()
|
||||
|
||||
domainEventFactory = {} as jest.Mocked<DomainEventFactoryInterface>
|
||||
domainEventFactory.createEmailRequestedEvent = jest.fn()
|
||||
|
||||
contentDecoder = {} as jest.Mocked<ContentDecoderInterface>
|
||||
contentDecoder.decode = jest.fn().mockReturnValue({ name: 'Dropbox' })
|
||||
})
|
||||
|
||||
it('should trigger cloud backup on extensions server', async () => {
|
||||
await createService().triggerCloudBackupOnExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
backupFilename: 'test',
|
||||
authParams,
|
||||
cloudProvider: 'DROPBOX',
|
||||
})
|
||||
|
||||
expect(httpClient.request).toHaveBeenCalledWith({
|
||||
data: {
|
||||
auth_params: authParams,
|
||||
backup_filename: 'test',
|
||||
silent: false,
|
||||
user_uuid: '1-2-3',
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method: 'POST',
|
||||
url: 'https://extensions-server/extension1',
|
||||
validateStatus: expect.any(Function),
|
||||
})
|
||||
})
|
||||
|
||||
it('should publish a failed Dropbox backup event if request was not sent successfully', async () => {
|
||||
contentDecoder.decode = jest.fn().mockReturnValue({ name: 'Dropbox' })
|
||||
|
||||
httpClient.request = jest.fn().mockImplementation(() => {
|
||||
throw new Error('Could not reach the extensions server')
|
||||
})
|
||||
|
||||
await createService().triggerCloudBackupOnExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
backupFilename: 'test',
|
||||
authParams,
|
||||
cloudProvider: 'DROPBOX',
|
||||
})
|
||||
|
||||
expect(domainEventPublisher.publish).toHaveBeenCalled()
|
||||
expect(domainEventFactory.createEmailRequestedEvent).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should send items to extensions server', async () => {
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
items: [item],
|
||||
backupFilename: '',
|
||||
authParams,
|
||||
})
|
||||
|
||||
expect(httpClient.request).toHaveBeenCalledWith({
|
||||
data: {
|
||||
auth_params: authParams,
|
||||
backup_filename: '',
|
||||
items: [item],
|
||||
silent: false,
|
||||
user_uuid: '1-2-3',
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method: 'POST',
|
||||
url: 'https://extensions-server/extension1',
|
||||
validateStatus: expect.any(Function),
|
||||
})
|
||||
})
|
||||
|
||||
it('should send items proxy backup file name only to extensions server', async () => {
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
|
||||
expect(httpClient.request).toHaveBeenCalledWith({
|
||||
data: {
|
||||
auth_params: authParams,
|
||||
backup_filename: 'backup-file',
|
||||
silent: false,
|
||||
user_uuid: '1-2-3',
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method: 'POST',
|
||||
url: 'https://extensions-server/extension1',
|
||||
validateStatus: expect.any(Function),
|
||||
})
|
||||
})
|
||||
|
||||
it('should publish a failed Dropbox backup event if request was not sent successfully', async () => {
|
||||
contentDecoder.decode = jest.fn().mockReturnValue({ name: 'Dropbox' })
|
||||
|
||||
httpClient.request = jest.fn().mockImplementation(() => {
|
||||
throw new Error('Could not reach the extensions server')
|
||||
})
|
||||
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
items: [item],
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
|
||||
expect(domainEventPublisher.publish).toHaveBeenCalled()
|
||||
expect(domainEventFactory.createEmailRequestedEvent).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should publish a failed Dropbox backup event if request was sent and extensions server responded not ok', async () => {
|
||||
contentDecoder.decode = jest.fn().mockReturnValue({ name: 'Dropbox' })
|
||||
|
||||
httpClient.request = jest.fn().mockReturnValue({ status: 400, data: { error: 'foo-bar' } })
|
||||
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
items: [item],
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
|
||||
expect(domainEventPublisher.publish).toHaveBeenCalled()
|
||||
expect(domainEventFactory.createEmailRequestedEvent).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should publish a failed Google Drive backup event if request was not sent successfully', async () => {
|
||||
contentDecoder.decode = jest.fn().mockReturnValue({ name: 'Google Drive' })
|
||||
|
||||
httpClient.request = jest.fn().mockImplementation(() => {
|
||||
throw new Error('Could not reach the extensions server')
|
||||
})
|
||||
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
items: [item],
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
|
||||
expect(domainEventPublisher.publish).toHaveBeenCalled()
|
||||
expect(domainEventFactory.createEmailRequestedEvent).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should publish a failed One Drive backup event if request was not sent successfully', async () => {
|
||||
contentDecoder.decode = jest.fn().mockReturnValue({ name: 'OneDrive' })
|
||||
|
||||
httpClient.request = jest.fn().mockImplementation(() => {
|
||||
throw new Error('Could not reach the extensions server')
|
||||
})
|
||||
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
items: [item],
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
|
||||
expect(domainEventPublisher.publish).toHaveBeenCalled()
|
||||
expect(domainEventFactory.createEmailRequestedEvent).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should not publish a failed backup event if emailes are force muted', async () => {
|
||||
contentDecoder.decode = jest.fn().mockReturnValue({ name: 'OneDrive' })
|
||||
|
||||
httpClient.request = jest.fn().mockImplementation(() => {
|
||||
throw new Error('Could not reach the extensions server')
|
||||
})
|
||||
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: true,
|
||||
items: [item],
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
|
||||
expect(domainEventPublisher.publish).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should throw an error if the extension to post to is not found', async () => {
|
||||
primaryItemRepository.findByUuidAndUserUuid = jest.fn().mockReturnValue(null)
|
||||
|
||||
httpClient.request = jest.fn().mockImplementation(() => {
|
||||
throw new Error('Could not reach the extensions server')
|
||||
})
|
||||
|
||||
let error = null
|
||||
try {
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
items: [item],
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
} catch (e) {
|
||||
error = e
|
||||
}
|
||||
|
||||
expect(error).not.toBeNull()
|
||||
})
|
||||
|
||||
it('should throw an error if the extension to post to has no content', async () => {
|
||||
item = {} as jest.Mocked<Item>
|
||||
primaryItemRepository.findByUuidAndUserUuid = jest.fn().mockReturnValue(item)
|
||||
|
||||
httpClient.request = jest.fn().mockImplementation(() => {
|
||||
throw new Error('Could not reach the extensions server')
|
||||
})
|
||||
|
||||
let error = null
|
||||
try {
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
items: [item],
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
} catch (e) {
|
||||
error = e
|
||||
}
|
||||
|
||||
expect(error).not.toBeNull()
|
||||
})
|
||||
|
||||
it('should publish a failed Dropbox backup event judging by extension url if request was not sent successfully', async () => {
|
||||
contentDecoder.decode = jest.fn().mockReturnValue({ url: 'https://dbt.com/...' })
|
||||
|
||||
httpClient.request = jest.fn().mockImplementation(() => {
|
||||
throw new Error('Could not reach the extensions server')
|
||||
})
|
||||
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
items: [item],
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
|
||||
expect(domainEventPublisher.publish).toHaveBeenCalled()
|
||||
expect(domainEventFactory.createEmailRequestedEvent).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should publish a failed Google Drive backup event judging by extension url if request was not sent successfully', async () => {
|
||||
contentDecoder.decode = jest.fn().mockReturnValue({ url: 'https://gdrive.com/...' })
|
||||
|
||||
httpClient.request = jest.fn().mockImplementation(() => {
|
||||
throw new Error('Could not reach the extensions server')
|
||||
})
|
||||
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
items: [item],
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
|
||||
expect(domainEventPublisher.publish).toHaveBeenCalled()
|
||||
expect(domainEventFactory.createEmailRequestedEvent).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should publish a failed One Drive backup event judging by extension url if request was not sent successfully', async () => {
|
||||
contentDecoder.decode = jest.fn().mockReturnValue({ url: 'https://onedrive.com/...' })
|
||||
|
||||
httpClient.request = jest.fn().mockImplementation(() => {
|
||||
throw new Error('Could not reach the extensions server')
|
||||
})
|
||||
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
items: [item],
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
|
||||
expect(domainEventPublisher.publish).toHaveBeenCalled()
|
||||
expect(domainEventFactory.createEmailRequestedEvent).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should throw an error if cannot deduce extension by judging from the url', async () => {
|
||||
contentDecoder.decode = jest.fn().mockReturnValue({ url: 'https://foobar.com/...' })
|
||||
|
||||
httpClient.request = jest.fn().mockImplementation(() => {
|
||||
throw new Error('Could not reach the extensions server')
|
||||
})
|
||||
|
||||
let error = null
|
||||
try {
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
items: [item],
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
} catch (e) {
|
||||
error = e
|
||||
}
|
||||
|
||||
expect(error).not.toBeNull()
|
||||
})
|
||||
|
||||
it('should throw an error if there is no extension name or url', async () => {
|
||||
contentDecoder.decode = jest.fn().mockReturnValue({})
|
||||
|
||||
httpClient.request = jest.fn().mockImplementation(() => {
|
||||
throw new Error('Could not reach the extensions server')
|
||||
})
|
||||
|
||||
let error = null
|
||||
try {
|
||||
await createService().sendItemsToExtensionsServer({
|
||||
userUuid: '1-2-3',
|
||||
extensionId: '2-3-4',
|
||||
extensionsServerUrl: 'https://extensions-server/extension1',
|
||||
forceMute: false,
|
||||
items: [item],
|
||||
backupFilename: 'backup-file',
|
||||
authParams,
|
||||
})
|
||||
} catch (e) {
|
||||
error = e
|
||||
}
|
||||
|
||||
expect(error).not.toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -1,177 +0,0 @@
|
||||
import { KeyParamsData } from '@standardnotes/responses'
|
||||
import { DomainEventInterface, DomainEventPublisherInterface } from '@standardnotes/domain-events'
|
||||
import { EmailLevel } from '@standardnotes/domain-core'
|
||||
import { AxiosInstance } from 'axios'
|
||||
import { Logger } from 'winston'
|
||||
|
||||
import { DomainEventFactoryInterface } from '../Event/DomainEventFactoryInterface'
|
||||
import { ContentDecoderInterface } from '../Item/ContentDecoderInterface'
|
||||
import { ItemRepositoryInterface } from '../Item/ItemRepositoryInterface'
|
||||
import { ExtensionName } from './ExtensionName'
|
||||
import { ExtensionsHttpServiceInterface } from './ExtensionsHttpServiceInterface'
|
||||
import { SendItemsToExtensionsServerDTO } from './SendItemsToExtensionsServerDTO'
|
||||
import { getBody as googleDriveBody, getSubject as googleDriveSubject } from '../Email/GoogleDriveBackupFailed'
|
||||
import { getBody as dropboxBody, getSubject as dropboxSubject } from '../Email/DropboxBackupFailed'
|
||||
import { getBody as oneDriveBody, getSubject as oneDriveSubject } from '../Email/OneDriveBackupFailed'
|
||||
|
||||
export class ExtensionsHttpService implements ExtensionsHttpServiceInterface {
|
||||
constructor(
|
||||
private httpClient: AxiosInstance,
|
||||
private primaryItemRepository: ItemRepositoryInterface,
|
||||
private contentDecoder: ContentDecoderInterface,
|
||||
private domainEventPublisher: DomainEventPublisherInterface,
|
||||
private domainEventFactory: DomainEventFactoryInterface,
|
||||
private logger: Logger,
|
||||
) {}
|
||||
|
||||
async triggerCloudBackupOnExtensionsServer(dto: {
|
||||
cloudProvider: 'DROPBOX' | 'GOOGLE_DRIVE' | 'ONE_DRIVE'
|
||||
extensionsServerUrl: string
|
||||
backupFilename: string
|
||||
authParams: KeyParamsData
|
||||
forceMute: boolean
|
||||
userUuid: string
|
||||
}): Promise<void> {
|
||||
let sent = false
|
||||
try {
|
||||
const payload: Record<string, unknown> = {
|
||||
backup_filename: dto.backupFilename,
|
||||
auth_params: dto.authParams,
|
||||
silent: dto.forceMute,
|
||||
user_uuid: dto.userUuid,
|
||||
}
|
||||
|
||||
const response = await this.httpClient.request({
|
||||
method: 'POST',
|
||||
url: dto.extensionsServerUrl,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: payload,
|
||||
validateStatus:
|
||||
/* istanbul ignore next */
|
||||
(status: number) => status >= 200 && status < 500,
|
||||
})
|
||||
|
||||
sent = response.status >= 200 && response.status < 300
|
||||
} catch (error) {
|
||||
this.logger.error(`[${dto.userUuid}] Failed to send a request to extensions server: ${(error as Error).message}`)
|
||||
}
|
||||
|
||||
if (!sent && !dto.forceMute) {
|
||||
await this.domainEventPublisher.publish(
|
||||
this.createCloudBackupFailedEventBasedOnProvider(dto.cloudProvider, dto.authParams.identifier as string),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
async sendItemsToExtensionsServer(dto: SendItemsToExtensionsServerDTO): Promise<void> {
|
||||
let sent = false
|
||||
try {
|
||||
const payload: Record<string, unknown> = {
|
||||
backup_filename: dto.backupFilename,
|
||||
auth_params: dto.authParams,
|
||||
silent: dto.forceMute,
|
||||
user_uuid: dto.userUuid,
|
||||
}
|
||||
if (dto.items !== undefined) {
|
||||
payload.items = dto.items
|
||||
}
|
||||
|
||||
const response = await this.httpClient.request({
|
||||
method: 'POST',
|
||||
url: dto.extensionsServerUrl,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: payload,
|
||||
validateStatus:
|
||||
/* istanbul ignore next */
|
||||
(status: number) => status >= 200 && status < 500,
|
||||
})
|
||||
|
||||
sent = response.status >= 200 && response.status < 300
|
||||
} catch (error) {
|
||||
this.logger.error(`[${dto.userUuid}] Failed to send a request to extensions server: ${(error as Error).message}`)
|
||||
}
|
||||
|
||||
if (!sent && !dto.forceMute) {
|
||||
await this.domainEventPublisher.publish(
|
||||
await this.getBackupFailedEvent(dto.extensionId, dto.userUuid, dto.authParams.identifier as string),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private createCloudBackupFailedEventBasedOnProvider(
|
||||
cloudProvider: 'DROPBOX' | 'GOOGLE_DRIVE' | 'ONE_DRIVE',
|
||||
email: string,
|
||||
): DomainEventInterface {
|
||||
switch (cloudProvider) {
|
||||
case 'DROPBOX':
|
||||
return this.domainEventFactory.createEmailRequestedEvent({
|
||||
userEmail: email,
|
||||
level: EmailLevel.LEVELS.FailedCloudBackup,
|
||||
body: dropboxBody(),
|
||||
messageIdentifier: 'FAILED_DROPBOX_BACKUP',
|
||||
subject: dropboxSubject(),
|
||||
})
|
||||
case 'GOOGLE_DRIVE':
|
||||
return this.domainEventFactory.createEmailRequestedEvent({
|
||||
userEmail: email,
|
||||
level: EmailLevel.LEVELS.FailedCloudBackup,
|
||||
body: googleDriveBody(),
|
||||
messageIdentifier: 'FAILED_GOOGLE_DRIVE_BACKUP',
|
||||
subject: googleDriveSubject(),
|
||||
})
|
||||
case 'ONE_DRIVE':
|
||||
return this.domainEventFactory.createEmailRequestedEvent({
|
||||
userEmail: email,
|
||||
level: EmailLevel.LEVELS.FailedCloudBackup,
|
||||
body: oneDriveBody(),
|
||||
messageIdentifier: 'FAILED_ONE_DRIVE_BACKUP',
|
||||
subject: oneDriveSubject(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private async getBackupFailedEvent(
|
||||
extensionId: string,
|
||||
userUuid: string,
|
||||
email: string,
|
||||
): Promise<DomainEventInterface> {
|
||||
const extension = await this.primaryItemRepository.findByUuidAndUserUuid(extensionId, userUuid)
|
||||
if (extension === null || !extension.props.content) {
|
||||
throw Error(`Could not find extensions with id ${extensionId}`)
|
||||
}
|
||||
|
||||
const content = this.contentDecoder.decode(extension.props.content)
|
||||
switch (this.getExtensionName(content)) {
|
||||
case ExtensionName.Dropbox:
|
||||
return this.createCloudBackupFailedEventBasedOnProvider('DROPBOX', email)
|
||||
case ExtensionName.GoogleDrive:
|
||||
return this.createCloudBackupFailedEventBasedOnProvider('GOOGLE_DRIVE', email)
|
||||
case ExtensionName.OneDrive:
|
||||
return this.createCloudBackupFailedEventBasedOnProvider('ONE_DRIVE', email)
|
||||
}
|
||||
}
|
||||
|
||||
private getExtensionName(content: Record<string, unknown>): ExtensionName {
|
||||
if ('name' in content) {
|
||||
return <ExtensionName>content.name
|
||||
}
|
||||
|
||||
const url = 'url' in content ? <string>content.url : undefined
|
||||
|
||||
if (url) {
|
||||
if (url.indexOf('dbt') !== -1) {
|
||||
return ExtensionName.Dropbox
|
||||
} else if (url.indexOf('gdrive') !== -1) {
|
||||
return ExtensionName.GoogleDrive
|
||||
} else if (url.indexOf('onedrive') !== -1) {
|
||||
return ExtensionName.OneDrive
|
||||
}
|
||||
}
|
||||
|
||||
throw Error('Could not deduce extension name from extension content')
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { KeyParamsData } from '@standardnotes/responses'
|
||||
import { SendItemsToExtensionsServerDTO } from './SendItemsToExtensionsServerDTO'
|
||||
|
||||
export interface ExtensionsHttpServiceInterface {
|
||||
triggerCloudBackupOnExtensionsServer(dto: {
|
||||
cloudProvider: 'DROPBOX' | 'GOOGLE_DRIVE' | 'ONE_DRIVE'
|
||||
extensionsServerUrl: string
|
||||
backupFilename: string
|
||||
authParams: KeyParamsData
|
||||
forceMute: boolean
|
||||
userUuid: string
|
||||
muteEmailsSettingUuid: string
|
||||
}): Promise<void>
|
||||
sendItemsToExtensionsServer(dto: SendItemsToExtensionsServerDTO): Promise<void>
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { KeyParamsData } from '@standardnotes/responses'
|
||||
|
||||
import { Item } from '../Item/Item'
|
||||
|
||||
export type SendItemsToExtensionsServerDTO = {
|
||||
extensionsServerUrl: string
|
||||
extensionId: string
|
||||
backupFilename: string
|
||||
authParams: KeyParamsData
|
||||
forceMute: boolean
|
||||
userUuid: string
|
||||
items?: Array<Item>
|
||||
}
|
||||
@@ -5,14 +5,19 @@ import {
|
||||
} from '@standardnotes/domain-events'
|
||||
import { DomainEventFactoryInterface } from '../../../Event/DomainEventFactoryInterface'
|
||||
import { SendEventToClient } from './SendEventToClient'
|
||||
import { Logger } from 'winston'
|
||||
|
||||
describe('SendEventToClient', () => {
|
||||
let domainEventFactory: DomainEventFactoryInterface
|
||||
let domainEventPublisher: DomainEventPublisherInterface
|
||||
let logger: Logger
|
||||
|
||||
const createUseCase = () => new SendEventToClient(domainEventFactory, domainEventPublisher)
|
||||
const createUseCase = () => new SendEventToClient(domainEventFactory, domainEventPublisher, logger)
|
||||
|
||||
beforeEach(() => {
|
||||
logger = {} as jest.Mocked<Logger>
|
||||
logger.info = jest.fn()
|
||||
|
||||
domainEventFactory = {} as jest.Mocked<DomainEventFactoryInterface>
|
||||
domainEventFactory.createWebSocketMessageRequestedEvent = jest
|
||||
.fn()
|
||||
|
||||
@@ -3,11 +3,13 @@ import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
|
||||
|
||||
import { SendEventToClientDTO } from './SendEventToClientDTO'
|
||||
import { DomainEventFactoryInterface } from '../../../Event/DomainEventFactoryInterface'
|
||||
import { Logger } from 'winston'
|
||||
|
||||
export class SendEventToClient implements UseCaseInterface<void> {
|
||||
constructor(
|
||||
private domainEventFactory: DomainEventFactoryInterface,
|
||||
private domainEventPublisher: DomainEventPublisherInterface,
|
||||
private logger: Logger,
|
||||
) {}
|
||||
|
||||
async execute(dto: SendEventToClientDTO): Promise<Result<void>> {
|
||||
@@ -17,6 +19,8 @@ export class SendEventToClient implements UseCaseInterface<void> {
|
||||
}
|
||||
const userUuid = userUuidOrError.getValue()
|
||||
|
||||
this.logger.info(`[WebSockets] Requesting message ${dto.event.type} to user ${dto.userUuid}`)
|
||||
|
||||
const event = this.domainEventFactory.createWebSocketMessageRequestedEvent({
|
||||
userUuid: userUuid.value,
|
||||
message: JSON.stringify(dto.event),
|
||||
|
||||
@@ -3,6 +3,18 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.17.8](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.17.7...@standardnotes/websockets-server@1.17.8) (2023-11-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* remove unused axios dep in subservices ([45d4920](https://github.com/standardnotes/server/commit/45d4920e0fc2848a28ce888d139201e68c4b416f))
|
||||
|
||||
## [1.17.7](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.17.6...@standardnotes/websockets-server@1.17.7) (2023-11-09)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* reduce websockets api communication data ([#919](https://github.com/standardnotes/server/issues/919)) ([c4ae12d](https://github.com/standardnotes/server/commit/c4ae12d53fc166879f90a4c5dbad1ab1cb4797e2))
|
||||
|
||||
## [1.17.6](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.17.5...@standardnotes/websockets-server@1.17.6) (2023-11-07)
|
||||
|
||||
**Note:** Version bump only for package @standardnotes/websockets-server
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@standardnotes/websockets-server",
|
||||
"version": "1.17.6",
|
||||
"version": "1.17.8",
|
||||
"engines": {
|
||||
"node": ">=18.0.0 <21.0.0"
|
||||
},
|
||||
@@ -31,7 +31,6 @@
|
||||
"@standardnotes/domain-events-infra": "workspace:^",
|
||||
"@standardnotes/responses": "^1.13.27",
|
||||
"@standardnotes/security": "workspace:^",
|
||||
"axios": "^1.1.3",
|
||||
"cors": "2.8.5",
|
||||
"dotenv": "^16.0.1",
|
||||
"express": "^4.18.2",
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import * as winston from 'winston'
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const axios = require('axios')
|
||||
import { AxiosInstance } from 'axios'
|
||||
import Redis from 'ioredis'
|
||||
import { SQSClient, SQSClientConfig } from '@aws-sdk/client-sqs'
|
||||
import { ApiGatewayManagementApiClient } from '@aws-sdk/client-apigatewaymanagementapi'
|
||||
@@ -123,7 +120,6 @@ export class ContainerConfigLoader {
|
||||
.to(WebSocketMessageRequestedEventHandler)
|
||||
|
||||
// Services
|
||||
container.bind<AxiosInstance>(TYPES.HTTPClient).toConstantValue(axios.create())
|
||||
container
|
||||
.bind<TokenDecoderInterface<CrossServiceTokenData>>(TYPES.CrossServiceTokenDecoder)
|
||||
.toConstantValue(new TokenDecoder<CrossServiceTokenData>(container.get(TYPES.AUTH_JWT_SECRET)))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user