Compare commits

..

14 Commits

Author SHA1 Message Date
standardci
6c95ab8a1c chore(release): publish new version
- @standardnotes/api-gateway@1.89.12
 - @standardnotes/auth-server@1.177.10
 - @standardnotes/home-server@1.22.35
 - @standardnotes/syncing-server@1.129.9
2024-01-02 10:14:36 +00:00
Karol Sójko
5987b0899c fix: adjust grpc keepalive parameters 2024-01-02 10:54:07 +01:00
standardci
664a92132b chore(release): publish new version
- @standardnotes/auth-server@1.177.9
 - @standardnotes/home-server@1.22.34
2023-12-29 10:29:32 +00:00
Karol Sójko
26b13ed6d4 fix(auth): adding user roles upon renewal of shared subscription (#1012)
* fix(auth): adding user roles upon renewal of shared subscription

* feat(auth): add procedure to fix roles on shared subscriptions
2023-12-29 11:07:51 +01:00
standardci
be7c66b145 chore(release): publish new version
- @standardnotes/analytics@2.34.11
 - @standardnotes/api-gateway@1.89.11
 - @standardnotes/auth-server@1.177.8
 - @standardnotes/domain-events-infra@1.22.10
 - @standardnotes/domain-events@2.139.3
 - @standardnotes/files-server@1.37.5
 - @standardnotes/home-server@1.22.33
 - @standardnotes/revisions-server@1.51.11
 - @standardnotes/scheduler-server@1.27.16
 - @standardnotes/syncing-server@1.129.8
 - @standardnotes/websockets-server@1.22.7
2023-12-29 07:16:40 +00:00
Karol Sójko
7e8d7f6874 fix: cleanup revision requests 2023-12-29 07:55:16 +01:00
standardci
c1805ee2ac chore(release): publish new version
- @standardnotes/auth-server@1.177.7
 - @standardnotes/home-server@1.22.32
2023-12-28 15:59:49 +00:00
Karol Sójko
eff1d642cf fix(auth): missing return statement in lock middleware 2023-12-28 16:39:38 +01:00
standardci
a05d7afe00 chore(release): publish new version
- @standardnotes/api-gateway@1.89.10
 - @standardnotes/home-server@1.22.31
2023-12-28 15:13:45 +00:00
Karol Sójko
c2650646d1 fix(api-gateway): log severity 2023-12-28 15:53:26 +01:00
standardci
f73e4adf5a chore(release): publish new version
- @standardnotes/api-gateway@1.89.9
 - @standardnotes/auth-server@1.177.6
 - @standardnotes/grpc@1.4.1
 - @standardnotes/home-server@1.22.30
 - @standardnotes/syncing-server@1.129.7
2023-12-28 14:42:08 +00:00
Karol Sójko
7c67a5a0f9 fix: retry grpc calls upon service unavailable response (#1011)
* fix: retry grpc calls upon service unavailable response

* fix: retry grpc calls for session verification
2023-12-28 15:21:40 +01:00
standardci
6dde9209af chore(release): publish new version
- @standardnotes/analytics@2.34.10
 - @standardnotes/api-gateway@1.89.8
 - @standardnotes/auth-server@1.177.5
 - @standardnotes/domain-events-infra@1.22.9
 - @standardnotes/files-server@1.37.4
 - @standardnotes/home-server@1.22.29
 - @standardnotes/revisions-server@1.51.10
 - @standardnotes/scheduler-server@1.27.15
 - @standardnotes/syncing-server@1.129.6
 - @standardnotes/websockets-server@1.22.6
2023-12-28 13:33:52 +00:00
Karol Sójko
264fd4c36e chore: upgrade node version to 20.10.0 (#1010)
* chore: upgrade node version to 20.10.0

* fix specs

* fix pip system managed packages
2023-12-28 14:13:07 +01:00
60 changed files with 468 additions and 248 deletions

2
.nvmrc
View File

@@ -1 +1 @@
20.6.1
20.10.0

14
.pnp.cjs generated
View File

@@ -2190,10 +2190,10 @@ const RAW_RUNTIME_STATE =
}]\
]],\
["@grpc/grpc-js", [\
["npm:1.9.12", {\
"packageLocation": "./.yarn/cache/@grpc-grpc-js-npm-1.9.12-cb97be6754-fe13b04844.zip/node_modules/@grpc/grpc-js/",\
["npm:1.9.13", {\
"packageLocation": "./.yarn/cache/@grpc-grpc-js-npm-1.9.13-33f9b49e10-c52150053c.zip/node_modules/@grpc/grpc-js/",\
"packageDependencies": [\
["@grpc/grpc-js", "npm:1.9.12"],\
["@grpc/grpc-js", "npm:1.9.13"],\
["@grpc/proto-loader", "npm:0.7.10"],\
["@types/node", "npm:20.2.5"]\
],\
@@ -5532,7 +5532,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./packages/api-gateway/",\
"packageDependencies": [\
["@standardnotes/api-gateway", "workspace:packages/api-gateway"],\
["@grpc/grpc-js", "npm:1.9.12"],\
["@grpc/grpc-js", "npm:1.9.13"],\
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
@@ -5582,7 +5582,7 @@ const RAW_RUNTIME_STATE =
["@aws-sdk/client-sqs", "npm:3.462.0"],\
["@cbor-extract/cbor-extract-linux-arm64", "npm:2.1.1"],\
["@cbor-extract/cbor-extract-linux-x64", "npm:2.1.1"],\
["@grpc/grpc-js", "npm:1.9.12"],\
["@grpc/grpc-js", "npm:1.9.13"],\
["@simplewebauthn/server", "npm:8.1.1"],\
["@simplewebauthn/typescript-types", "npm:8.0.0"],\
["@standardnotes/api", "npm:1.26.26"],\
@@ -5809,7 +5809,7 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./packages/grpc/",\
"packageDependencies": [\
["@standardnotes/grpc", "workspace:packages/grpc"],\
["@grpc/grpc-js", "npm:1.9.12"],\
["@grpc/grpc-js", "npm:1.9.13"],\
["@types/google-protobuf", "npm:3.15.10"],\
["google-protobuf", "npm:3.21.2"],\
["grpc-tools", "npm:1.12.4"],\
@@ -6082,7 +6082,7 @@ const RAW_RUNTIME_STATE =
["@aws-sdk/client-s3", "npm:3.462.0"],\
["@aws-sdk/client-sns", "npm:3.462.0"],\
["@aws-sdk/client-sqs", "npm:3.462.0"],\
["@grpc/grpc-js", "npm:1.9.12"],\
["@grpc/grpc-js", "npm:1.9.13"],\
["@standardnotes/api", "npm:1.26.26"],\
["@standardnotes/common", "workspace:packages/common"],\
["@standardnotes/domain-core", "workspace:packages/domain-core"],\

View File

@@ -1,4 +1,4 @@
FROM node:20.6.1-alpine
FROM node:20.10.0-alpine
ENV NODE_ENV production
@@ -10,7 +10,7 @@ RUN apk add --update --no-cache \
bash \
py3-pip
RUN pip install --no-cache-dir --upgrade supervisor
RUN pip install --no-cache-dir --upgrade --break-system-packages supervisor
RUN mkdir -p /var/lib/server/logs

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.34.11](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.34.10...@standardnotes/analytics@2.34.11) (2023-12-29)
**Note:** Version bump only for package @standardnotes/analytics
## [2.34.10](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.34.9...@standardnotes/analytics@2.34.10) (2023-12-28)
**Note:** Version bump only for package @standardnotes/analytics
## [2.34.9](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.34.8...@standardnotes/analytics@2.34.9) (2023-12-28)
**Note:** Version bump only for package @standardnotes/analytics

View File

@@ -1,4 +1,4 @@
FROM node:20.6.1-alpine
FROM node:20.10.0-alpine
RUN apk add --update \
curl \

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "2.34.9",
"version": "2.34.11",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,6 +3,32 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.89.12](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.89.11...@standardnotes/api-gateway@1.89.12) (2024-01-02)
### Bug Fixes
* adjust grpc keepalive parameters ([5987b08](https://github.com/standardnotes/server/commit/5987b0899c21d40cc2c90c29fcf3c25b27660d0c))
## [1.89.11](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.89.10...@standardnotes/api-gateway@1.89.11) (2023-12-29)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.89.10](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.89.9...@standardnotes/api-gateway@1.89.10) (2023-12-28)
### Bug Fixes
* **api-gateway:** log severity ([c265064](https://github.com/standardnotes/server/commit/c2650646d1f89ca509b4d256e4305a592d12f850))
## [1.89.9](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.89.8...@standardnotes/api-gateway@1.89.9) (2023-12-28)
### Bug Fixes
* retry grpc calls upon service unavailable response ([#1011](https://github.com/standardnotes/server/issues/1011)) ([7c67a5a](https://github.com/standardnotes/server/commit/7c67a5a0f93f9d506ee4010e2837288457fc2c1d))
## [1.89.8](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.89.7...@standardnotes/api-gateway@1.89.8) (2023-12-28)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.89.7](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.89.6...@standardnotes/api-gateway@1.89.7) (2023-12-28)
**Note:** Version bump only for package @standardnotes/api-gateway

View File

@@ -1,4 +1,4 @@
FROM node:20.6.1-alpine
FROM node:20.10.0-alpine
RUN apk add --update \
curl \

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.89.7",
"version": "1.89.12",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -31,7 +31,7 @@
"start": "yarn node dist/bin/server.js"
},
"dependencies": {
"@grpc/grpc-js": "^1.9.12",
"@grpc/grpc-js": "^1.9.13",
"@standardnotes/domain-core": "workspace:^",
"@standardnotes/domain-events": "workspace:*",
"@standardnotes/domain-events-infra": "workspace:*",

View File

@@ -152,7 +152,7 @@ export class ContainerConfigLoader {
container.bind(TYPES.ApiGateway_SYNCING_SERVER_GRPC_URL).toConstantValue(env.get('SYNCING_SERVER_GRPC_URL'))
const grpcAgentKeepAliveTimeout = env.get('GRPC_AGENT_KEEP_ALIVE_TIMEOUT', true)
? +env.get('GRPC_AGENT_KEEP_ALIVE_TIMEOUT', true)
: 8_000
: 20_000
const grpcMaxMessageSize = env.get('GRPC_MAX_MESSAGE_SIZE', true)
? +env.get('GRPC_MAX_MESSAGE_SIZE', true)
@@ -163,7 +163,6 @@ export class ContainerConfigLoader {
container.get<string>(TYPES.ApiGateway_AUTH_SERVER_GRPC_URL),
grpc.credentials.createInsecure(),
{
'grpc.keepalive_time_ms': grpcAgentKeepAliveTimeout * 2,
'grpc.keepalive_timeout_ms': grpcAgentKeepAliveTimeout,
'grpc.default_compression_algorithm': grpc.compressionAlgorithms.gzip,
'grpc.default_compression_level': 2,
@@ -177,7 +176,6 @@ export class ContainerConfigLoader {
container.get<string>(TYPES.ApiGateway_SYNCING_SERVER_GRPC_URL),
grpc.credentials.createInsecure(),
{
'grpc.keepalive_time_ms': grpcAgentKeepAliveTimeout * 2,
'grpc.keepalive_timeout_ms': grpcAgentKeepAliveTimeout,
'grpc.default_compression_algorithm': grpc.compressionAlgorithms.gzip,
'grpc.default_compression_level': 2,

View File

@@ -8,6 +8,7 @@ import * as grpc from '@grpc/grpc-js'
import { CrossServiceTokenCacheInterface } from '../Cache/CrossServiceTokenCacheInterface'
import { ServiceProxyInterface } from '../Proxy/ServiceProxyInterface'
import { GRPCSyncingServerServiceProxy } from './GRPCSyncingServerServiceProxy'
import { Status } from '@grpc/grpc-js/build/src/constants'
export class GRPCServiceProxy implements ServiceProxyInterface {
constructor(
@@ -27,11 +28,14 @@ export class GRPCServiceProxy implements ServiceProxyInterface {
private gRPCSyncingServerServiceProxy: GRPCSyncingServerServiceProxy,
) {}
async validateSession(headers: {
authorization: string
sharedVaultOwnerContext?: string
}): Promise<{ status: number; data: unknown; headers: { contentType: string } }> {
return new Promise((resolve, reject) => {
async validateSession(
headers: {
authorization: string
sharedVaultOwnerContext?: string
},
retryAttempt?: number,
): Promise<{ status: number; data: unknown; headers: { contentType: string } }> {
const promise = new Promise((resolve, reject) => {
try {
const request = new AuthorizationHeader()
request.setBearerToken(headers.authorization)
@@ -80,6 +84,32 @@ export class GRPCServiceProxy implements ServiceProxyInterface {
return reject(error)
}
})
try {
const result = await promise
if (retryAttempt) {
this.logger.debug(`Request to Auth Server succeeded after ${retryAttempt} retries`)
}
return result as { status: number; data: unknown; headers: { contentType: string } }
} catch (error) {
const requestDidNotMakeIt =
'code' in (error as Record<string, unknown>) && (error as Record<string, unknown>).code === Status.UNAVAILABLE
const tooManyRetryAttempts = retryAttempt && retryAttempt > 2
if (!tooManyRetryAttempts && requestDidNotMakeIt) {
await this.timer.sleep(50)
const nextRetryAttempt = retryAttempt ? retryAttempt + 1 : 1
this.logger.debug(`Retrying request to Auth Server for the ${nextRetryAttempt} time`)
return this.validateSession(headers, nextRetryAttempt)
}
throw error
}
}
async callSyncingServer(
@@ -92,6 +122,21 @@ export class GRPCServiceProxy implements ServiceProxyInterface {
payload !== undefined && typeof payload !== 'string' && 'api' in payload && payload.api === '20200115'
if (requestIsUsingLatestApiVersions && endpoint === 'items/sync') {
await this.callSyncingServerGRPC(request, response, payload)
return
}
await this.callServer(this.syncingServerJsUrl, request, response, endpoint, payload)
}
private async callSyncingServerGRPC(
request: Request,
response: Response,
payload?: Record<string, unknown> | string,
retryAttempt?: number,
): Promise<void> {
try {
const result = await this.gRPCSyncingServerServiceProxy.sync(request, response, payload)
response.status(result.status).send({
@@ -107,10 +152,30 @@ export class GRPCServiceProxy implements ServiceProxyInterface {
data: result.data,
})
return
}
if (retryAttempt) {
this.logger.debug(`Request to Syncing Server succeeded after ${retryAttempt} retries`, {
userId: response.locals.user ? response.locals.user.uuid : undefined,
})
}
} catch (error) {
const requestDidNotMakeIt =
'code' in (error as Record<string, unknown>) && (error as Record<string, unknown>).code === Status.UNAVAILABLE
await this.callServer(this.syncingServerJsUrl, request, response, endpoint, payload)
const tooManyRetryAttempts = retryAttempt && retryAttempt > 2
if (!tooManyRetryAttempts && requestDidNotMakeIt) {
await this.timer.sleep(50)
const nextRetryAttempt = retryAttempt ? retryAttempt + 1 : 1
this.logger.debug(`Retrying request to Syncing Server for the ${nextRetryAttempt} time`, {
userId: response.locals.user ? response.locals.user.uuid : undefined,
})
return this.callSyncingServerGRPC(request, response, payload, nextRetryAttempt)
}
throw error
}
}
async callRevisionsServer(

View File

@@ -3,6 +3,40 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.177.10](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.177.9...@standardnotes/auth-server@1.177.10) (2024-01-02)
### Bug Fixes
* adjust grpc keepalive parameters ([5987b08](https://github.com/standardnotes/server/commit/5987b0899c21d40cc2c90c29fcf3c25b27660d0c))
## [1.177.9](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.177.8...@standardnotes/auth-server@1.177.9) (2023-12-29)
### Bug Fixes
* **auth:** adding user roles upon renewal of shared subscription ([#1012](https://github.com/standardnotes/server/issues/1012)) ([26b13ed](https://github.com/standardnotes/server/commit/26b13ed6d488fb5038a3928482b3079ab2b5f8d8))
## [1.177.8](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.177.7...@standardnotes/auth-server@1.177.8) (2023-12-29)
### Bug Fixes
* cleanup revision requests ([7e8d7f6](https://github.com/standardnotes/server/commit/7e8d7f6874bb1db55ee6feb9e128c684a6900189))
## [1.177.7](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.177.6...@standardnotes/auth-server@1.177.7) (2023-12-28)
### Bug Fixes
* **auth:** missing return statement in lock middleware ([eff1d64](https://github.com/standardnotes/server/commit/eff1d642cfd3502f479761a3bb76a543ae0166af))
## [1.177.6](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.177.5...@standardnotes/auth-server@1.177.6) (2023-12-28)
### Bug Fixes
* retry grpc calls upon service unavailable response ([#1011](https://github.com/standardnotes/server/issues/1011)) ([7c67a5a](https://github.com/standardnotes/server/commit/7c67a5a0f93f9d506ee4010e2837288457fc2c1d))
## [1.177.5](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.177.4...@standardnotes/auth-server@1.177.5) (2023-12-28)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.177.4](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.177.3...@standardnotes/auth-server@1.177.4) (2023-12-28)
**Note:** Version bump only for package @standardnotes/auth-server

View File

@@ -1,4 +1,4 @@
FROM node:20.6.1-alpine
FROM node:20.10.0-alpine
RUN apk add --update \
curl \

View File

@@ -0,0 +1,67 @@
import 'reflect-metadata'
import { Logger } from 'winston'
import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
import { Uuid } from '@standardnotes/domain-core'
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
import { UserSubscriptionRepositoryInterface } from '../src/Domain/Subscription/UserSubscriptionRepositoryInterface'
import { RoleServiceInterface } from '../src/Domain/Role/RoleServiceInterface'
import { UserSubscriptionType } from '../src/Domain/Subscription/UserSubscriptionType'
import { UserRepositoryInterface } from '../src/Domain/User/UserRepositoryInterface'
const fixRoles = async (
userRepository: UserRepositoryInterface,
userSubscriptionRepository: UserSubscriptionRepositoryInterface,
roleService: RoleServiceInterface,
): Promise<void> => {
const subscriptions = await userSubscriptionRepository.findActiveByType(UserSubscriptionType.Shared)
for (const subscription of subscriptions) {
const userUuidOrError = Uuid.create(subscription.userUuid)
if (userUuidOrError.isFailed()) {
continue
}
const userUuid = userUuidOrError.getValue()
const user = await userRepository.findOneByUuid(userUuid)
if (!user) {
continue
}
await roleService.addUserRoleBasedOnSubscription(user, subscription.planName)
}
}
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 roles fix for shared subscriptions...')
const userRepository = container.get<UserRepositoryInterface>(TYPES.Auth_UserRepository)
const userSubscriptionRepository = container.get<UserSubscriptionRepositoryInterface>(
TYPES.Auth_UserSubscriptionRepository,
)
const roleService = container.get<RoleServiceInterface>(TYPES.Auth_RoleService)
Promise.resolve(fixRoles(userRepository, userSubscriptionRepository, roleService))
.then(() => {
logger.info('Finished fixing roles for shared subscriptions')
process.exit(0)
})
.catch((error) => {
logger.error(`Error while fixing roles for shared subscriptions: ${(error as Error).message}`)
process.exit(1)
})
})

View File

@@ -1,71 +0,0 @@
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 { DomainEventPublisherInterface } from '@standardnotes/domain-events'
import { DomainEventFactoryInterface } from '../src/Domain/Event/DomainEventFactoryInterface'
import { UserSubscriptionRepositoryInterface } from '../src/Domain/Subscription/UserSubscriptionRepositoryInterface'
import { SubscriptionPlanName } from '@standardnotes/domain-core'
const requestCleanup = async (
userSubscriptionRepository: UserSubscriptionRepositoryInterface,
domainEventFactory: DomainEventFactoryInterface,
domainEventPublisher: DomainEventPublisherInterface,
): Promise<void> => {
const proSubscriptionPlan = SubscriptionPlanName.create(SubscriptionPlanName.NAMES.ProPlan).getValue()
const plusSubscriptionPlan = SubscriptionPlanName.create(SubscriptionPlanName.NAMES.PlusPlan).getValue()
const totalSubscriptions = await userSubscriptionRepository.countByPlanName([
proSubscriptionPlan,
plusSubscriptionPlan,
])
const limitPerPage = 100
const numberOfPages = Math.ceil(totalSubscriptions / limitPerPage)
for (let i = 0; i < numberOfPages; i++) {
const subscriptions = await userSubscriptionRepository.findByPlanName(
[proSubscriptionPlan, plusSubscriptionPlan],
i * limitPerPage,
limitPerPage,
)
for (const subscription of subscriptions) {
await domainEventPublisher.publish(
domainEventFactory.createRevisionsCleanupRequestedEvent({
userUuid: subscription.userUuid,
}),
)
}
}
}
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 revisions cleanup triggering...')
const domainEventFactory = container.get<DomainEventFactoryInterface>(TYPES.Auth_DomainEventFactory)
const domainEventPublisher = container.get<DomainEventPublisherInterface>(TYPES.Auth_DomainEventPublisher)
const userSubscriptionRepository = container.get<UserSubscriptionRepositoryInterface>(
TYPES.Auth_UserSubscriptionRepository,
)
Promise.resolve(requestCleanup(userSubscriptionRepository, domainEventFactory, domainEventPublisher))
.then(() => {
logger.info('Finished revisions cleanup triggering')
process.exit(0)
})
.catch((error) => {
logger.error(`Failed to trigger revisions cleanup: ${(error as Error).message}`)
process.exit(1)
})
})

View File

@@ -58,8 +58,14 @@ void container.load().then((container) => {
const logger: winston.Logger = container.get(TYPES.Auth_Logger)
server.setErrorConfig((app) => {
app.use((error: Record<string, unknown>, _request: Request, response: Response, _next: NextFunction) => {
logger.error(error.stack)
app.use((error: Record<string, unknown>, request: Request, response: Response, _next: NextFunction) => {
logger.error(`${error.stack}`, {
method: request.method,
url: request.url,
snjs: request.headers['x-snjs-version'],
application: request.headers['x-application-version'],
userId: response.locals.user ? response.locals.user.uuid : undefined,
})
response.status(500).send({
error: {
@@ -78,16 +84,18 @@ void container.load().then((container) => {
serverInstance.keepAliveTimeout = httpKeepAliveTimeout
const grpcKeepAliveTime = env.get('GRPC_KEEP_ALIVE_TIME', true) ? +env.get('GRPC_KEEP_ALIVE_TIME', true) : 7_200_000
const grpcKeepAliveTimeout = env.get('GRPC_KEEP_ALIVE_TIMEOUT', true)
? +env.get('GRPC_KEEP_ALIVE_TIMEOUT', true)
: 10_000
: 20_000
const grpcMaxMessageSize = env.get('GRPC_MAX_MESSAGE_SIZE', true)
? +env.get('GRPC_MAX_MESSAGE_SIZE', true)
: 1024 * 1024 * 50
const grpcServer = new grpc.Server({
'grpc.keepalive_time_ms': grpcKeepAliveTimeout * 2,
'grpc.keepalive_time_ms': grpcKeepAliveTime,
'grpc.keepalive_timeout_ms': grpcKeepAliveTimeout,
'grpc.default_compression_algorithm': grpc.compressionAlgorithms.gzip,
'grpc.max_receive_message_length': grpcMaxMessageSize,

View File

@@ -4,7 +4,7 @@ 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/revisions_cleanup.js')))
const index = require(path.normalize(path.resolve(__dirname, '../dist/bin/fix_roles.js')))
Object.defineProperty(exports, '__esModule', { value: true })

View File

@@ -38,16 +38,16 @@ case "$COMMAND" in
exec node docker/entrypoint-fix-quota.js $EMAIL
;;
'fix-roles' )
exec node docker/entrypoint-fix-roles.js
;;
'delete-accounts' )
FILE_NAME=$1 && shift 1
MODE=$1 && shift 1
exec node docker/entrypoint-delete-accounts.js $FILE_NAME $MODE
;;
'revisions-cleanup' )
exec node docker/entrypoint-revisions-cleanup.js
;;
* )
echo "[Docker] Unknown command"
;;

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.177.4",
"version": "1.177.10",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -43,7 +43,7 @@
"@aws-sdk/client-sqs": "^3.462.0",
"@cbor-extract/cbor-extract-linux-arm64": "^2.1.1",
"@cbor-extract/cbor-extract-linux-x64": "^2.1.1",
"@grpc/grpc-js": "^1.9.12",
"@grpc/grpc-js": "^1.9.13",
"@simplewebauthn/server": "^8.1.1",
"@simplewebauthn/typescript-types": "^8.0.0",
"@standardnotes/api": "^1.26.26",

View File

@@ -1284,6 +1284,7 @@ export class ContainerConfigLoader {
),
container.get<UserSubscriptionRepositoryInterface>(TYPES.Auth_UserSubscriptionRepository),
container.get<UserRepositoryInterface>(TYPES.Auth_UserRepository),
container.get<RoleServiceInterface>(TYPES.Auth_RoleService),
container.get<winston.Logger>(TYPES.Auth_Logger),
),
)

View File

@@ -22,7 +22,6 @@ import {
SessionRefreshedEvent,
AccountDeletionVerificationRequestedEvent,
FileQuotaRecalculationRequestedEvent,
RevisionsCleanupRequestedEvent,
} from '@standardnotes/domain-events'
import { Predicate, PredicateVerificationResult } from '@standardnotes/predicates'
import { TimerInterface } from '@standardnotes/time'
@@ -35,22 +34,6 @@ import { KeyParamsData } from '@standardnotes/responses'
@injectable()
export class DomainEventFactory implements DomainEventFactoryInterface {
constructor(@inject(TYPES.Auth_Timer) private timer: TimerInterface) {}
createRevisionsCleanupRequestedEvent(dto: { userUuid: string }): RevisionsCleanupRequestedEvent {
return {
type: 'REVISIONS_CLEANUP_REQUESTED',
createdAt: this.timer.getUTCDate(),
meta: {
correlation: {
userIdentifier: dto.userUuid,
userIdentifierType: 'uuid',
},
origin: DomainEventService.Auth,
},
payload: dto,
}
}
createFileQuotaRecalculationRequestedEvent(dto: { userUuid: string }): FileQuotaRecalculationRequestedEvent {
return {
type: 'FILE_QUOTA_RECALCULATION_REQUESTED',

View File

@@ -20,13 +20,11 @@ import {
SessionRefreshedEvent,
AccountDeletionVerificationRequestedEvent,
FileQuotaRecalculationRequestedEvent,
RevisionsCleanupRequestedEvent,
} from '@standardnotes/domain-events'
import { InviteeIdentifierType } from '../SharedSubscription/InviteeIdentifierType'
import { KeyParamsData } from '@standardnotes/responses'
export interface DomainEventFactoryInterface {
createRevisionsCleanupRequestedEvent(dto: { userUuid: string }): RevisionsCleanupRequestedEvent
createFileQuotaRecalculationRequestedEvent(dto: { userUuid: string }): FileQuotaRecalculationRequestedEvent
createWebSocketMessageRequestedEvent(dto: { userUuid: string; message: JSONString }): WebSocketMessageRequestedEvent
createEmailRequestedEvent(dto: {

View File

@@ -10,6 +10,7 @@ export interface UserSubscriptionRepositoryInterface {
findByUserUuid(userUuid: string): Promise<UserSubscription[]>
countByPlanName(planNames: SubscriptionPlanName[]): Promise<number>
findByPlanName(planNames: SubscriptionPlanName[], offset: number, limit: number): Promise<UserSubscription[]>
findActiveByType(type: UserSubscriptionType): Promise<UserSubscription[]>
findOneByUserUuidAndSubscriptionId(userUuid: string, subscriptionId: number): Promise<UserSubscription | null>
findBySubscriptionIdAndType(subscriptionId: number, type: UserSubscriptionType): Promise<UserSubscription[]>
findBySubscriptionId(subscriptionId: number): Promise<UserSubscription[]>

View File

@@ -8,6 +8,7 @@ import { SharedSubscriptionInvitation } from '../../SharedSubscription/SharedSub
import { InviteeIdentifierType } from '../../SharedSubscription/InviteeIdentifierType'
import { User } from '../../User/User'
import { InvitationStatus } from '../../SharedSubscription/InvitationStatus'
import { RoleServiceInterface } from '../../Role/RoleServiceInterface'
describe('RenewSharedSubscriptions', () => {
let listSharedSubscriptionInvitations: ListSharedSubscriptionInvitations
@@ -17,6 +18,7 @@ describe('RenewSharedSubscriptions', () => {
let logger: Logger
let sharedSubscriptionInvitation: SharedSubscriptionInvitation
let user: User
let roleService: RoleServiceInterface
const createUseCase = () =>
new RenewSharedSubscriptions(
@@ -24,6 +26,7 @@ describe('RenewSharedSubscriptions', () => {
sharedSubscriptionInvitationRepository,
userSubscriptionRepository,
userRepository,
roleService,
logger,
)
@@ -48,8 +51,12 @@ describe('RenewSharedSubscriptions', () => {
userSubscriptionRepository = {} as jest.Mocked<UserSubscriptionRepositoryInterface>
userSubscriptionRepository.save = jest.fn()
roleService = {} as jest.Mocked<RoleServiceInterface>
roleService.addUserRoleBasedOnSubscription = jest.fn()
userRepository = {} as jest.Mocked<UserRepositoryInterface>
userRepository.findOneByUsernameOrEmail = jest.fn().mockReturnValue(user)
userRepository.findOneByUuid = jest.fn().mockReturnValue(user)
logger = {} as jest.Mocked<Logger>
logger.error = jest.fn()
@@ -71,7 +78,7 @@ describe('RenewSharedSubscriptions', () => {
expect(userSubscriptionRepository.save).toBeCalledTimes(1)
})
it('should log error if user not found', async () => {
it('should log error if user not found by email', async () => {
userRepository.findOneByUsernameOrEmail = jest.fn().mockReturnValue(null)
const useCase = createUseCase()
@@ -88,6 +95,42 @@ describe('RenewSharedSubscriptions', () => {
expect(logger.error).toBeCalledTimes(1)
})
it('should log error if user not found by uuid', async () => {
sharedSubscriptionInvitation.inviteeIdentifierType = InviteeIdentifierType.Uuid
sharedSubscriptionInvitation.inviteeIdentifier = '00000000-0000-0000-0000-000000000000'
userRepository.findOneByUuid = jest.fn().mockReturnValue(null)
const useCase = createUseCase()
const result = await useCase.execute({
inviterEmail: 'inviter@test.te',
newSubscriptionId: 123,
newSubscriptionName: 'test',
newSubscriptionExpiresAt: 123,
timestamp: 123,
})
expect(result.isFailed()).toBeFalsy()
expect(logger.error).toBeCalledTimes(1)
})
it('should log error if user not found by unknown identifier type', async () => {
sharedSubscriptionInvitation.inviteeIdentifierType = 'unknown' as InviteeIdentifierType
const useCase = createUseCase()
const result = await useCase.execute({
inviterEmail: 'inviter@test.te',
newSubscriptionId: 123,
newSubscriptionName: 'test',
newSubscriptionExpiresAt: 123,
timestamp: 123,
})
expect(result.isFailed()).toBeFalsy()
expect(logger.error).toBeCalledTimes(1)
})
it('should log error if error occurs', async () => {
userRepository.findOneByUsernameOrEmail = jest.fn().mockImplementation(() => {
throw new Error('test')
@@ -125,6 +168,24 @@ describe('RenewSharedSubscriptions', () => {
expect(logger.error).toBeCalledTimes(1)
})
it('should log error if uuid is invalid', async () => {
sharedSubscriptionInvitation.inviteeIdentifierType = InviteeIdentifierType.Uuid
sharedSubscriptionInvitation.inviteeIdentifier = 'invalid'
const useCase = createUseCase()
const result = await useCase.execute({
inviterEmail: 'inviter@test.te',
newSubscriptionId: 123,
newSubscriptionName: 'test',
newSubscriptionExpiresAt: 123,
timestamp: 123,
})
expect(result.isFailed()).toBeFalsy()
expect(logger.error).toBeCalledTimes(1)
})
it('should renew shared subscription for invitations by user uuid', async () => {
sharedSubscriptionInvitation.inviteeIdentifierType = InviteeIdentifierType.Uuid
sharedSubscriptionInvitation.inviteeIdentifier = '00000000-0000-0000-0000-000000000000'

View File

@@ -1,4 +1,4 @@
import { Result, UseCaseInterface, Username } from '@standardnotes/domain-core'
import { Result, UseCaseInterface, Username, Uuid } from '@standardnotes/domain-core'
import { Logger } from 'winston'
import { RenewSharedSubscriptionsDTO } from './RenewSharedSubscriptionsDTO'
@@ -10,6 +10,8 @@ import { UserSubscriptionType } from '../../Subscription/UserSubscriptionType'
import { UserSubscriptionRepositoryInterface } from '../../Subscription/UserSubscriptionRepositoryInterface'
import { UserRepositoryInterface } from '../../User/UserRepositoryInterface'
import { InviteeIdentifierType } from '../../SharedSubscription/InviteeIdentifierType'
import { RoleServiceInterface } from '../../Role/RoleServiceInterface'
import { User } from '../../User/User'
export class RenewSharedSubscriptions implements UseCaseInterface<void> {
constructor(
@@ -17,6 +19,7 @@ export class RenewSharedSubscriptions implements UseCaseInterface<void> {
private sharedSubscriptionInvitationRepository: SharedSubscriptionInvitationRepositoryInterface,
private userSubscriptionRepository: UserSubscriptionRepositoryInterface,
private userRepository: UserRepositoryInterface,
private roleService: RoleServiceInterface,
private logger: Logger,
) {}
@@ -31,8 +34,8 @@ export class RenewSharedSubscriptions implements UseCaseInterface<void> {
for (const invitation of acceptedInvitations) {
try {
const userUuid = await this.getInviteeUserUuid(invitation.inviteeIdentifier, invitation.inviteeIdentifierType)
if (userUuid === null) {
const user = await this.getInviteeUserUuid(invitation.inviteeIdentifier, invitation.inviteeIdentifierType)
if (user === null) {
this.logger.error(
`[SUBSCRIPTION: ${dto.newSubscriptionId}] Could not renew shared subscription for invitation: ${invitation.uuid}: Could not find user with identifier: ${invitation.inviteeIdentifier}`,
)
@@ -42,11 +45,13 @@ export class RenewSharedSubscriptions implements UseCaseInterface<void> {
await this.createSharedSubscription({
subscriptionId: dto.newSubscriptionId,
subscriptionName: dto.newSubscriptionName,
userUuid,
userUuid: user.uuid,
timestamp: dto.timestamp,
subscriptionExpiresAt: dto.newSubscriptionExpiresAt,
})
await this.roleService.addUserRoleBasedOnSubscription(user, dto.newSubscriptionName)
invitation.subscriptionId = dto.newSubscriptionId
invitation.updatedAt = dto.timestamp
@@ -83,7 +88,7 @@ export class RenewSharedSubscriptions implements UseCaseInterface<void> {
return this.userSubscriptionRepository.save(subscription)
}
private async getInviteeUserUuid(inviteeIdentifier: string, inviteeIdentifierType: string): Promise<string | null> {
private async getInviteeUserUuid(inviteeIdentifier: string, inviteeIdentifierType: string): Promise<User | null> {
if (inviteeIdentifierType === InviteeIdentifierType.Email) {
const usernameOrError = Username.create(inviteeIdentifier)
if (usernameOrError.isFailed()) {
@@ -91,14 +96,16 @@ export class RenewSharedSubscriptions implements UseCaseInterface<void> {
}
const username = usernameOrError.getValue()
const user = await this.userRepository.findOneByUsernameOrEmail(username)
if (user === null) {
return this.userRepository.findOneByUsernameOrEmail(username)
} else if (inviteeIdentifierType === InviteeIdentifierType.Uuid) {
const uuidOrError = Uuid.create(inviteeIdentifier)
if (uuidOrError.isFailed()) {
return null
}
return user.uuid
const uuid = uuidOrError.getValue()
return this.userRepository.findOneByUuid(uuid)
}
return inviteeIdentifier
return null
}
}

View File

@@ -26,6 +26,8 @@ export class LockMiddleware extends BaseMiddleware {
message: usernameOrError.getError(),
},
})
return
}
const username = usernameOrError.getValue()

View File

@@ -1,3 +1,4 @@
import { SubscriptionPlanName } from '@standardnotes/domain-core'
import { TimerInterface } from '@standardnotes/time'
import { inject, injectable } from 'inversify'
import { Repository } from 'typeorm'
@@ -6,7 +7,6 @@ import TYPES from '../../Bootstrap/Types'
import { UserSubscription } from '../../Domain/Subscription/UserSubscription'
import { UserSubscriptionRepositoryInterface } from '../../Domain/Subscription/UserSubscriptionRepositoryInterface'
import { UserSubscriptionType } from '../../Domain/Subscription/UserSubscriptionType'
import { SubscriptionPlanName } from '@standardnotes/domain-core'
@injectable()
export class TypeORMUserSubscriptionRepository implements UserSubscriptionRepositoryInterface {
@@ -16,6 +16,15 @@ export class TypeORMUserSubscriptionRepository implements UserSubscriptionReposi
@inject(TYPES.Auth_Timer) private timer: TimerInterface,
) {}
async findActiveByType(type: UserSubscriptionType): Promise<UserSubscription[]> {
return await this.ormRepository
.createQueryBuilder()
.where('ends_at > :timestamp', { timestamp: this.timer.getTimestampInMicroseconds() })
.andWhere('subscription_type = :type', { type })
.orderBy('created_at', 'ASC')
.getMany()
}
async countByPlanName(planNames: SubscriptionPlanName[]): Promise<number> {
return await this.ormRepository
.createQueryBuilder()

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.10](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.22.9...@standardnotes/domain-events-infra@1.22.10) (2023-12-29)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.22.9](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.22.8...@standardnotes/domain-events-infra@1.22.9) (2023-12-28)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.22.8](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.22.7...@standardnotes/domain-events-infra@1.22.8) (2023-12-28)
**Note:** Version bump only for package @standardnotes/domain-events-infra

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events-infra",
"version": "1.22.8",
"version": "1.22.10",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -26,7 +26,7 @@ describe('RedisDomainEventPublisher', () => {
expect(redisClient.publish).toHaveBeenCalledWith(
'events',
'eJyrViqpLEhVslIKcQ0OUdJRKkiszMlPTFGyqlZKy88HiiclFinV1gIA9tQMhA==',
'eJyrViqpLEhVslIKcQ0OUdJRKkiszMlPTFGyqlZKy89XslJKSixSqq0FAPbUDIQ=',
)
})
})

View File

@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.139.3](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.139.2...@standardnotes/domain-events@2.139.3) (2023-12-29)
### Bug Fixes
* cleanup revision requests ([7e8d7f6](https://github.com/standardnotes/server/commit/7e8d7f6874bb1db55ee6feb9e128c684a6900189))
## [2.139.2](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.139.1...@standardnotes/domain-events@2.139.2) (2023-12-28)
**Note:** Version bump only for package @standardnotes/domain-events

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events",
"version": "2.139.2",
"version": "2.139.3",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -1,7 +0,0 @@
import { DomainEventInterface } from './DomainEventInterface'
import { RevisionsCleanupRequestedEventPayload } from './RevisionsCleanupRequestedEventPayload'
export interface RevisionsCleanupRequestedEvent extends DomainEventInterface {
type: 'REVISIONS_CLEANUP_REQUESTED'
payload: RevisionsCleanupRequestedEventPayload
}

View File

@@ -1,3 +0,0 @@
export interface RevisionsCleanupRequestedEventPayload {
userUuid: string
}

View File

@@ -72,8 +72,6 @@ export * from './Event/PredicateVerifiedEvent'
export * from './Event/PredicateVerifiedEventPayload'
export * from './Event/RefundProcessedEvent'
export * from './Event/RefundProcessedEventPayload'
export * from './Event/RevisionsCleanupRequestedEvent'
export * from './Event/RevisionsCleanupRequestedEventPayload'
export * from './Event/RevisionsCopyRequestedEvent'
export * from './Event/RevisionsCopyRequestedEventPayload'
export * from './Event/SessionCreatedEvent'

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.37.5](https://github.com/standardnotes/server/compare/@standardnotes/files-server@1.37.4...@standardnotes/files-server@1.37.5) (2023-12-29)
**Note:** Version bump only for package @standardnotes/files-server
## [1.37.4](https://github.com/standardnotes/server/compare/@standardnotes/files-server@1.37.3...@standardnotes/files-server@1.37.4) (2023-12-28)
**Note:** Version bump only for package @standardnotes/files-server
## [1.37.3](https://github.com/standardnotes/server/compare/@standardnotes/files-server@1.37.2...@standardnotes/files-server@1.37.3) (2023-12-28)
**Note:** Version bump only for package @standardnotes/files-server

View File

@@ -1,4 +1,4 @@
FROM node:20.6.1-alpine
FROM node:20.10.0-alpine
RUN apk add --update \
curl \

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/files-server",
"version": "1.37.3",
"version": "1.37.5",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.4.1](https://github.com/standardnotes/server/compare/@standardnotes/grpc@1.4.0...@standardnotes/grpc@1.4.1) (2023-12-28)
### Bug Fixes
* retry grpc calls upon service unavailable response ([#1011](https://github.com/standardnotes/server/issues/1011)) ([7c67a5a](https://github.com/standardnotes/server/commit/7c67a5a0f93f9d506ee4010e2837288457fc2c1d))
# [1.4.0](https://github.com/standardnotes/server/compare/@standardnotes/grpc@1.3.2...@standardnotes/grpc@1.4.0) (2023-12-07)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/grpc",
"version": "1.4.0",
"version": "1.4.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -27,7 +27,7 @@
"build": "tsc --build"
},
"dependencies": {
"@grpc/grpc-js": "^1.9.12",
"@grpc/grpc-js": "^1.9.13",
"google-protobuf": "^3.21.2"
},
"devDependencies": {

View File

@@ -3,6 +3,34 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.35](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.34...@standardnotes/home-server@1.22.35) (2024-01-02)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.34](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.33...@standardnotes/home-server@1.22.34) (2023-12-29)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.33](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.32...@standardnotes/home-server@1.22.33) (2023-12-29)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.32](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.31...@standardnotes/home-server@1.22.32) (2023-12-28)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.31](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.30...@standardnotes/home-server@1.22.31) (2023-12-28)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.30](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.29...@standardnotes/home-server@1.22.30) (2023-12-28)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.29](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.28...@standardnotes/home-server@1.22.29) (2023-12-28)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.28](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.27...@standardnotes/home-server@1.22.28) (2023-12-28)
**Note:** Version bump only for package @standardnotes/home-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/home-server",
"version": "1.22.28",
"version": "1.22.35",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.51.11](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.51.10...@standardnotes/revisions-server@1.51.11) (2023-12-29)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.51.10](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.51.9...@standardnotes/revisions-server@1.51.10) (2023-12-28)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.51.9](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.51.8...@standardnotes/revisions-server@1.51.9) (2023-12-28)
**Note:** Version bump only for package @standardnotes/revisions-server

View File

@@ -1,4 +1,4 @@
FROM node:20.6.1-alpine
FROM node:20.10.0-alpine
RUN apk add --update \
curl \

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/revisions-server",
"version": "1.51.9",
"version": "1.51.11",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.27.16](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.27.15...@standardnotes/scheduler-server@1.27.16) (2023-12-29)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.27.15](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.27.14...@standardnotes/scheduler-server@1.27.15) (2023-12-28)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.27.14](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.27.13...@standardnotes/scheduler-server@1.27.14) (2023-12-28)
**Note:** Version bump only for package @standardnotes/scheduler-server

View File

@@ -1,4 +1,4 @@
FROM node:20.6.1-alpine
FROM node:20.10.0-alpine
RUN apk add --update \
curl \

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/scheduler-server",
"version": "1.27.14",
"version": "1.27.16",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,6 +3,28 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.129.9](https://github.com/standardnotes/server/compare/@standardnotes/syncing-server@1.129.8...@standardnotes/syncing-server@1.129.9) (2024-01-02)
### Bug Fixes
* adjust grpc keepalive parameters ([5987b08](https://github.com/standardnotes/server/commit/5987b0899c21d40cc2c90c29fcf3c25b27660d0c))
## [1.129.8](https://github.com/standardnotes/server/compare/@standardnotes/syncing-server@1.129.7...@standardnotes/syncing-server@1.129.8) (2023-12-29)
### Bug Fixes
* cleanup revision requests ([7e8d7f6](https://github.com/standardnotes/server/commit/7e8d7f6874bb1db55ee6feb9e128c684a6900189))
## [1.129.7](https://github.com/standardnotes/server/compare/@standardnotes/syncing-server@1.129.6...@standardnotes/syncing-server@1.129.7) (2023-12-28)
### Bug Fixes
* retry grpc calls upon service unavailable response ([#1011](https://github.com/standardnotes/server/issues/1011)) ([7c67a5a](https://github.com/standardnotes/server/commit/7c67a5a0f93f9d506ee4010e2837288457fc2c1d))
## [1.129.6](https://github.com/standardnotes/server/compare/@standardnotes/syncing-server@1.129.5...@standardnotes/syncing-server@1.129.6) (2023-12-28)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.129.5](https://github.com/standardnotes/server/compare/@standardnotes/syncing-server@1.129.4...@standardnotes/syncing-server@1.129.5) (2023-12-28)
**Note:** Version bump only for package @standardnotes/syncing-server

View File

@@ -1,4 +1,4 @@
FROM node:20.6.1-alpine
FROM node:20.10.0-alpine
RUN apk add --update \
curl \

View File

@@ -85,16 +85,18 @@ void container.load().then((container) => {
serverInstance.keepAliveTimeout = keepAliveTimeout
const grpcKeepAliveTime = env.get('GRPC_KEEP_ALIVE_TIME', true) ? +env.get('GRPC_KEEP_ALIVE_TIME', true) : 7_200_000
const grpcKeepAliveTimeout = env.get('GRPC_KEEP_ALIVE_TIMEOUT', true)
? +env.get('GRPC_KEEP_ALIVE_TIMEOUT', true)
: 10_000
: 20_000
const grpcMaxMessageSize = env.get('GRPC_MAX_MESSAGE_SIZE', true)
? +env.get('GRPC_MAX_MESSAGE_SIZE', true)
: 1024 * 1024 * 50
const grpcServer = new grpc.Server({
'grpc.keepalive_time_ms': grpcKeepAliveTimeout * 2,
'grpc.keepalive_time_ms': grpcKeepAliveTime,
'grpc.keepalive_timeout_ms': grpcKeepAliveTimeout,
'grpc.default_compression_algorithm': grpc.compressionAlgorithms.gzip,
'grpc.max_receive_message_length': grpcMaxMessageSize,

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.129.5",
"version": "1.129.9",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -35,7 +35,7 @@
"@aws-sdk/client-s3": "^3.462.0",
"@aws-sdk/client-sns": "^3.462.0",
"@aws-sdk/client-sqs": "^3.462.0",
"@grpc/grpc-js": "^1.9.12",
"@grpc/grpc-js": "^1.9.13",
"@standardnotes/api": "^1.26.26",
"@standardnotes/common": "workspace:*",
"@standardnotes/domain-core": "workspace:^",

View File

@@ -162,7 +162,6 @@ import { SyncResponse } from '@standardnotes/grpc'
import { SyncResponseGRPCMapper } from '../Mapping/gRPC/SyncResponseGRPCMapper'
import { AccountDeletionVerificationRequestedEventHandler } from '../Domain/Handler/AccountDeletionVerificationRequestedEventHandler'
import { SendEventToClients } from '../Domain/UseCase/Syncing/SendEventToClients/SendEventToClients'
import { RevisionsCleanupRequestedEventHandler } from '../Domain/Handler/RevisionsCleanupRequestedEventHandler'
export class ContainerConfigLoader {
private readonly DEFAULT_CONTENT_SIZE_TRANSFER_LIMIT = 10_000_000
@@ -981,16 +980,6 @@ export class ContainerConfigLoader {
container.get<Logger>(TYPES.Sync_Logger),
),
)
container
.bind<RevisionsCleanupRequestedEventHandler>(TYPES.Sync_RevisionsCleanupRequestedEventHandler)
.toConstantValue(
new RevisionsCleanupRequestedEventHandler(
container.get<ItemRepositoryInterface>(TYPES.Sync_SQLItemRepository),
container.get<DomainEventFactoryInterface>(TYPES.Sync_DomainEventFactory),
container.get<DomainEventPublisherInterface>(TYPES.Sync_DomainEventPublisher),
container.get<Logger>(TYPES.Sync_Logger),
),
)
// Services
container.bind<ContentDecoderInterface>(TYPES.Sync_ContentDecoder).toDynamicValue(() => new ContentDecoder())
@@ -1019,7 +1008,6 @@ export class ContainerConfigLoader {
'SHARED_VAULT_REMOVED',
container.get<SharedVaultRemovedEventHandler>(TYPES.Sync_SharedVaultRemovedEventHandler),
],
['REVISIONS_CLEANUP_REQUESTED', container.get(TYPES.Sync_RevisionsCleanupRequestedEventHandler)],
])
if (!isConfiguredForHomeServer) {
container

View File

@@ -97,7 +97,6 @@ const TYPES = {
Sync_SharedVaultFileUploadedEventHandler: Symbol.for('Sync_SharedVaultFileUploadedEventHandler'),
Sync_SharedVaultFileMovedEventHandler: Symbol.for('Sync_SharedVaultFileMovedEventHandler'),
Sync_SharedVaultRemovedEventHandler: Symbol.for('Sync_SharedVaultRemovedEventHandler'),
Sync_RevisionsCleanupRequestedEventHandler: Symbol.for('Sync_RevisionsCleanupRequestedEventHandler'),
// Services
Sync_ContentDecoder: Symbol.for('Sync_ContentDecoder'),
Sync_DomainEventPublisher: Symbol.for('Sync_DomainEventPublisher'),

View File

@@ -1,56 +0,0 @@
import {
RevisionsCleanupRequestedEvent,
DomainEventHandlerInterface,
DomainEventPublisherInterface,
} from '@standardnotes/domain-events'
import { Logger } from 'winston'
import { ItemRepositoryInterface } from '../Item/ItemRepositoryInterface'
import { DomainEventFactoryInterface } from '../Event/DomainEventFactoryInterface'
export class RevisionsCleanupRequestedEventHandler implements DomainEventHandlerInterface {
constructor(
private itemRepository: ItemRepositoryInterface,
private domainEventFactory: DomainEventFactoryInterface,
private domainEventPublisher: DomainEventPublisherInterface,
private logger: Logger,
) {}
async handle(event: RevisionsCleanupRequestedEvent): Promise<void> {
const totalDeletedItems = await this.itemRepository.countAll({
userUuid: event.payload.userUuid,
deleted: true,
})
this.logger.info(`Found ${totalDeletedItems} deleted items`, {
userId: event.payload.userUuid,
})
const limitPerPage = 100
const numberOfPages = Math.ceil(totalDeletedItems / limitPerPage)
for (let i = 0; i < numberOfPages; i++) {
const items = await this.itemRepository.findAll({
userUuid: event.payload.userUuid,
deleted: true,
offset: i * limitPerPage,
limit: limitPerPage,
sortOrder: 'ASC',
sortBy: 'created_at_timestamp',
})
for (const item of items) {
await this.domainEventPublisher.publish(
this.domainEventFactory.createItemDeletedEvent({
itemUuid: item.id.toString(),
userUuid: item.props.userUuid.value,
}),
)
}
}
this.logger.info(`Finished processing ${totalDeletedItems} deleted items`, {
userId: event.payload.userUuid,
})
}
}

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.7](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.22.6...@standardnotes/websockets-server@1.22.7) (2023-12-29)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.22.6](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.22.5...@standardnotes/websockets-server@1.22.6) (2023-12-28)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.22.5](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.22.4...@standardnotes/websockets-server@1.22.5) (2023-12-28)
**Note:** Version bump only for package @standardnotes/websockets-server

View File

@@ -1,4 +1,4 @@
FROM node:20.6.1-alpine
FROM node:20.10.0-alpine
RUN apk add --update \
curl \

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/websockets-server",
"version": "1.22.5",
"version": "1.22.7",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -1583,13 +1583,13 @@ __metadata:
languageName: node
linkType: hard
"@grpc/grpc-js@npm:^1.9.12":
version: 1.9.12
resolution: "@grpc/grpc-js@npm:1.9.12"
"@grpc/grpc-js@npm:^1.9.13":
version: 1.9.13
resolution: "@grpc/grpc-js@npm:1.9.13"
dependencies:
"@grpc/proto-loader": "npm:^0.7.8"
"@types/node": "npm:>=12.12.47"
checksum: fe13b04844b525ad860521589e2d640bb8cfeea46e3cb8e4eab537e0a4fcb04a033083c25d5c3cd4e061a6471c933f6f12e81dcc626acdcf68435e6e4a833a06
checksum: c52150053ca3911bf9ec5012265aa754627aba9c60577ef07c594c5c22896e939ec0f656cc130a54a8651ea0ae23f385a4a48868fc71ff56dff54eeaec8b6912
languageName: node
linkType: hard
@@ -4084,7 +4084,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@standardnotes/api-gateway@workspace:packages/api-gateway"
dependencies:
"@grpc/grpc-js": "npm:^1.9.12"
"@grpc/grpc-js": "npm:^1.9.13"
"@standardnotes/domain-core": "workspace:^"
"@standardnotes/domain-events": "workspace:*"
"@standardnotes/domain-events-infra": "workspace:*"
@@ -4147,7 +4147,7 @@ __metadata:
"@aws-sdk/client-sqs": "npm:^3.462.0"
"@cbor-extract/cbor-extract-linux-arm64": "npm:^2.1.1"
"@cbor-extract/cbor-extract-linux-x64": "npm:^2.1.1"
"@grpc/grpc-js": "npm:^1.9.12"
"@grpc/grpc-js": "npm:^1.9.13"
"@simplewebauthn/server": "npm:^8.1.1"
"@simplewebauthn/typescript-types": "npm:^8.0.0"
"@standardnotes/api": "npm:^1.26.26"
@@ -4361,7 +4361,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@standardnotes/grpc@workspace:packages/grpc"
dependencies:
"@grpc/grpc-js": "npm:^1.9.12"
"@grpc/grpc-js": "npm:^1.9.13"
"@types/google-protobuf": "npm:^3"
google-protobuf: "npm:^3.21.2"
grpc-tools: "npm:^1.12.4"
@@ -4618,7 +4618,7 @@ __metadata:
"@aws-sdk/client-s3": "npm:^3.462.0"
"@aws-sdk/client-sns": "npm:^3.462.0"
"@aws-sdk/client-sqs": "npm:^3.462.0"
"@grpc/grpc-js": "npm:^1.9.12"
"@grpc/grpc-js": "npm:^1.9.13"
"@standardnotes/api": "npm:^1.26.26"
"@standardnotes/common": "workspace:*"
"@standardnotes/domain-core": "workspace:^"