Compare commits

...

29 Commits

Author SHA1 Message Date
standardci
af17698334 chore(release): publish new version
- @standardnotes/analytics@2.28.3
 - @standardnotes/api-gateway@1.78.0
 - @standardnotes/auth-server@1.153.0
 - @standardnotes/domain-events-infra@1.15.0
 - @standardnotes/event-store@1.12.13
 - @standardnotes/files-server@1.27.0
 - @standardnotes/home-server@1.16.38
 - @standardnotes/revisions-server@1.41.0
 - @standardnotes/scheduler-server@1.22.3
 - @standardnotes/syncing-server@1.113.0
 - @standardnotes/websockets-server@1.13.0
2023-10-09 10:33:23 +00:00
Karol Sójko
5e930d08eb feat: add opentelemetry to all services 2023-10-09 12:15:12 +02:00
Karol Sójko
0c89d8bd2d fix(revisions): instrumenting opentelemetry on non production 2023-10-09 11:36:40 +02:00
Karol Sójko
cb23506c1f fix: checksums on packages 2023-10-09 11:21:22 +02:00
Karol Sójko
bf9072dbd4 fix(revisions): add trace id sampler 2023-10-09 11:18:52 +02:00
Karol Sójko
6abdd73a31 feat(revisions): switch to open telemetry 2023-10-09 11:11:55 +02:00
standardci
421b5c5487 chore(release): publish new version
- @standardnotes/home-server@1.16.37
 - @standardnotes/revisions-server@1.40.4
2023-10-09 08:35:11 +00:00
Karol Sójko
465530841f fix(revisions): creation date formatting 2023-10-09 10:15:20 +02:00
standardci
0057a5d6ff chore(release): publish new version
- @standardnotes/analytics@2.28.2
 - @standardnotes/api-gateway@1.77.2
 - @standardnotes/auth-server@1.152.2
 - @standardnotes/domain-events-infra@1.14.9
 - @standardnotes/event-store@1.12.12
 - @standardnotes/files-server@1.26.4
 - @standardnotes/home-server@1.16.36
 - @standardnotes/revisions-server@1.40.3
 - @standardnotes/scheduler-server@1.22.2
 - @standardnotes/syncing-server@1.112.4
 - @standardnotes/websockets-server@1.12.1
2023-10-09 08:12:19 +00:00
Karol Sójko
b736dab3c1 fix: remove xray sdk in favor of opentelemetry 2023-10-09 09:53:34 +02:00
standardci
951d965304 chore(release): publish new version
- @standardnotes/home-server@1.16.35
 - @standardnotes/revisions-server@1.40.2
 - @standardnotes/syncing-server@1.112.3
2023-10-09 06:45:04 +00:00
Karol Sójko
29e8de3238 fix: logs in transition 2023-10-09 08:26:18 +02:00
standardci
eeeacabaa8 chore(release): publish new version
- @standardnotes/home-server@1.16.34
 - @standardnotes/syncing-server@1.112.2
2023-10-06 14:30:24 +00:00
Karol Sójko
51ca8229b8 fix(syncing-server): calling auth server for user key params 2023-10-06 15:56:10 +02:00
Karol Sójko
a6a19a391e fix(syncing-server): error log on email backup requested 2023-10-06 15:44:11 +02:00
standardci
f6cdb7916c chore(release): publish new version
- @standardnotes/auth-server@1.152.1
 - @standardnotes/home-server@1.16.33
 - @standardnotes/revisions-server@1.40.1
 - @standardnotes/syncing-server@1.112.1
2023-10-06 13:34:07 +00:00
Karol Sójko
eafb064d79 fix(syncing-server): increase axios timeout on calling auth 2023-10-06 15:18:26 +02:00
Karol Sójko
ba050681f7 fix(syncing-server): logs on request backup handler 2023-10-06 15:16:38 +02:00
Karol Sójko
4780629549 fix(revisions): casting creation date from MongoDB 2023-10-06 15:14:11 +02:00
Karol Sójko
79a44aa51f fix(auth): checking for transition role when triggering transition 2023-10-06 14:56:45 +02:00
standardci
dd72769841 chore(release): publish new version
- @standardnotes/auth-server@1.152.0
 - @standardnotes/home-server@1.16.32
 - @standardnotes/revisions-server@1.40.0
 - @standardnotes/syncing-server@1.112.0
2023-10-06 11:22:47 +00:00
Karol Sójko
d8f1c66fd5 fix: enable TransitionRequestedEventHandler 2023-10-06 13:02:37 +02:00
Karol Sójko
afe9967d26 fix(auth): strip user from transition role after migration 2023-10-06 12:59:18 +02:00
Karol Sójko
27bea444cc feat: switch transition direction 2023-10-06 12:48:08 +02:00
standardci
7a571dec0a chore(release): publish new version
- @standardnotes/home-server@1.16.31
 - @standardnotes/syncing-server@1.111.5
2023-10-06 08:48:31 +00:00
Karol Sójko
8c57f505be fix(syncing-server): add more logs on successfull email backups requested 2023-10-06 10:28:50 +02:00
standardci
973612bf4f chore(release): publish new version
- @standardnotes/analytics@2.28.1
 - @standardnotes/auth-server@1.151.2
 - @standardnotes/home-server@1.16.30
 - @standardnotes/scheduler-server@1.22.1
 - @standardnotes/syncing-server@1.111.4
2023-10-06 08:01:50 +00:00
Karol Sójko
702a1286eb fix(syncing-server): error log on email backup request handler 2023-10-06 09:40:27 +02:00
Karol Sójko
a45b5b69b5 fix: add xray-sdk to background processors 2023-10-06 09:33:15 +02:00
157 changed files with 2296 additions and 1494 deletions

1350
.pnp.cjs generated

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.28.3](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.28.2...@standardnotes/analytics@2.28.3) (2023-10-09)
**Note:** Version bump only for package @standardnotes/analytics
## [2.28.2](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.28.1...@standardnotes/analytics@2.28.2) (2023-10-09)
### Bug Fixes
* remove xray sdk in favor of opentelemetry ([b736dab](https://github.com/standardnotes/server/commit/b736dab3c1f76c9e03c4bc7bbf153dcb3309b7cb))
## [2.28.1](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.28.0...@standardnotes/analytics@2.28.1) (2023-10-06)
### Bug Fixes
* add xray-sdk to background processors ([a45b5b6](https://github.com/standardnotes/server/commit/a45b5b69b5d68c2e696c30f0ba5ad22d313321e6))
# [2.28.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.27.10...@standardnotes/analytics@2.28.0) (2023-10-06)
### Features

View File

@@ -1,7 +1,6 @@
import 'reflect-metadata'
import { Logger } from 'winston'
import * as AWSXRay from 'aws-xray-sdk'
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
@@ -17,14 +16,6 @@ void container.load().then((container) => {
const env: Env = new Env()
env.load()
const isConfiguredForAWSProduction =
env.get('MODE', true) !== 'home-server' && env.get('MODE', true) !== 'self-hosted'
if (isConfiguredForAWSProduction) {
AWSXRay.enableManualMode()
AWSXRay.config([AWSXRay.plugins.ECSPlugin])
}
const logger: Logger = container.get(TYPES.Logger)
logger.info('Starting worker...')

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "2.28.0",
"version": "2.28.3",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -46,7 +46,6 @@
"@standardnotes/domain-events": "workspace:*",
"@standardnotes/domain-events-infra": "workspace:*",
"@standardnotes/time": "workspace:*",
"aws-xray-sdk": "^3.5.2",
"dayjs": "^1.11.6",
"dotenv": "^16.0.1",
"inversify": "^6.0.1",

View File

@@ -6,7 +6,7 @@ import {
DomainEventMessageHandlerInterface,
DomainEventSubscriberFactoryInterface,
} from '@standardnotes/domain-events'
import { MapperInterface, ServiceIdentifier } from '@standardnotes/domain-core'
import { MapperInterface } from '@standardnotes/domain-core'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Mixpanel = require('mixpanel')
@@ -18,7 +18,6 @@ import {
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
SQSXRayEventMessageHandler,
} from '@standardnotes/domain-events-infra'
import { Timer, TimerInterface } from '@standardnotes/time'
import { PeriodKeyGeneratorInterface } from '../Domain/Time/PeriodKeyGeneratorInterface'
@@ -57,7 +56,6 @@ import { SNSClient, SNSClientConfig } from '@aws-sdk/client-sns'
import { SQSClient, SQSClientConfig } from '@aws-sdk/client-sqs'
import { SessionCreatedEventHandler } from '../Domain/Handler/SessionCreatedEventHandler'
import { SessionRefreshedEventHandler } from '../Domain/Handler/SessionRefreshedEventHandler'
import { captureAWSv3Client } from 'aws-xray-sdk'
export class ContainerConfigLoader {
async load(): Promise<Container> {
@@ -108,7 +106,7 @@ export class ContainerConfigLoader {
secretAccessKey: env.get('SNS_SECRET_ACCESS_KEY', true),
}
}
container.bind<SNSClient>(TYPES.SNS).toConstantValue(captureAWSv3Client(new SNSClient(snsConfig)))
container.bind<SNSClient>(TYPES.SNS).toConstantValue(new SNSClient(snsConfig))
if (env.get('SQS_QUEUE_URL', true)) {
const sqsConfig: SQSClientConfig = {
@@ -123,7 +121,7 @@ export class ContainerConfigLoader {
secretAccessKey: env.get('SQS_SECRET_ACCESS_KEY', true),
}
}
container.bind<SQSClient>(TYPES.SQS).toConstantValue(captureAWSv3Client(new SQSClient(sqsConfig)))
container.bind<SQSClient>(TYPES.SQS).toConstantValue(new SQSClient(sqsConfig))
}
// env vars
@@ -245,15 +243,7 @@ export class ContainerConfigLoader {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
env.get('NEW_RELIC_ENABLED', true) === 'true'
? new SQSXRayEventMessageHandler(
ServiceIdentifier.NAMES.AnalyticsWorker,
eventHandlers,
container.get(TYPES.Logger),
)
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)),
)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.toConstantValue(

View File

@@ -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.78.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.77.2...@standardnotes/api-gateway@1.78.0) (2023-10-09)
### Features
* add opentelemetry to all services ([5e930d0](https://github.com/standardnotes/api-gateway/commit/5e930d08eb60a0da800081342315e7edaf130951))
## [1.77.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.77.1...@standardnotes/api-gateway@1.77.2) (2023-10-09)
### Bug Fixes
* remove xray sdk in favor of opentelemetry ([b736dab](https://github.com/standardnotes/api-gateway/commit/b736dab3c1f76c9e03c4bc7bbf153dcb3309b7cb))
## [1.77.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.77.0...@standardnotes/api-gateway@1.77.1) (2023-10-06)
**Note:** Version bump only for package @standardnotes/api-gateway

View File

@@ -29,7 +29,6 @@ import helmet from 'helmet'
import * as cors from 'cors'
import { text, json, Request, Response, NextFunction } from 'express'
import * as winston from 'winston'
import * as AWSXRay from 'aws-xray-sdk'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const robots = require('express-robots-txt')
@@ -37,27 +36,16 @@ import { InversifyExpressServer } from 'inversify-express-utils'
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
import { TYPES } from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
import { ServiceIdentifier } from '@standardnotes/domain-core'
import { OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
const container = new ContainerConfigLoader()
void container.load().then((container) => {
const env: Env = new Env()
env.load()
const isConfiguredForAWSProduction =
env.get('MODE', true) !== 'home-server' && env.get('MODE', true) !== 'self-hosted'
if (isConfiguredForAWSProduction) {
AWSXRay.config([AWSXRay.plugins.ECSPlugin])
}
const server = new InversifyExpressServer(container)
server.setConfig((app) => {
if (isConfiguredForAWSProduction) {
app.use(AWSXRay.express.openSegment(ServiceIdentifier.NAMES.ApiGateway))
}
app.use((_request: Request, response: Response, next: NextFunction) => {
response.setHeader('X-API-Gateway-Version', container.get(TYPES.ApiGateway_VERSION))
next()
@@ -117,8 +105,9 @@ void container.load().then((container) => {
const serverInstance = server.build()
if (isConfiguredForAWSProduction) {
serverInstance.use(AWSXRay.express.closeSegment())
if (!container.get<boolean>(TYPES.ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)) {
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.ApiGateway_OpenTelemetrySDK)
openTelemetrySDK.start()
}
serverInstance.listen(env.get('PORT'))

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.77.1",
"version": "1.78.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -31,7 +31,6 @@
"@standardnotes/domain-events-infra": "workspace:*",
"@standardnotes/security": "workspace:*",
"@standardnotes/time": "workspace:*",
"aws-xray-sdk": "^3.5.2",
"axios": "^1.1.3",
"cors": "2.8.5",
"dotenv": "^16.0.1",

View File

@@ -16,12 +16,13 @@ import { RedisCrossServiceTokenCache } from '../Infra/Redis/RedisCrossServiceTok
import { WebSocketAuthMiddleware } from '../Controller/WebSocketAuthMiddleware'
import { InMemoryCrossServiceTokenCache } from '../Infra/InMemory/InMemoryCrossServiceTokenCache'
import { DirectCallServiceProxy } from '../Service/Proxy/DirectCallServiceProxy'
import { ServiceContainerInterface } from '@standardnotes/domain-core'
import { ServiceContainerInterface, ServiceIdentifier } from '@standardnotes/domain-core'
import { EndpointResolverInterface } from '../Service/Resolver/EndpointResolverInterface'
import { EndpointResolver } from '../Service/Resolver/EndpointResolver'
import { RequiredCrossServiceTokenMiddleware } from '../Controller/RequiredCrossServiceTokenMiddleware'
import { OptionalCrossServiceTokenMiddleware } from '../Controller/OptionalCrossServiceTokenMiddleware'
import { Transform } from 'stream'
import { OpenTelemetrySDK, OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
export class ContainerConfigLoader {
async load(configuration?: {
@@ -36,9 +37,19 @@ export class ContainerConfigLoader {
const isConfiguredForHomeServer = env.get('MODE', true) === 'home-server'
const isConfiguredForSelfHosting = env.get('MODE', true) === 'self-hosted'
const isConfiguredForAWSProduction = !isConfiguredForHomeServer && !isConfiguredForSelfHosting
const isConfiguredForHomeServerOrSelfHosting = isConfiguredForHomeServer || isConfiguredForSelfHosting
const isConfiguredForInMemoryCache = env.get('CACHE_TYPE', true) === 'memory'
container
.bind<boolean>(TYPES.ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)
.toConstantValue(isConfiguredForHomeServerOrSelfHosting)
if (!isConfiguredForHomeServerOrSelfHosting) {
container
.bind<OpenTelemetrySDKInterface>(TYPES.ApiGateway_OpenTelemetrySDK)
.toConstantValue(new OpenTelemetrySDK(ServiceIdentifier.NAMES.ApiGateway))
}
const winstonFormatters = [winston.format.splat(), winston.format.json()]
if (env.get('NEW_RELIC_ENABLED', true) === 'true') {
await import('newrelic')
@@ -92,9 +103,6 @@ export class ContainerConfigLoader {
.bind(TYPES.ApiGateway_CROSS_SERVICE_TOKEN_CACHE_TTL)
.toConstantValue(+env.get('CROSS_SERVICE_TOKEN_CACHE_TTL', true))
container.bind(TYPES.ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER).toConstantValue(isConfiguredForHomeServer)
container
.bind<boolean>(TYPES.ApiGateway_IS_CONFIGURED_FOR_AWS_PRODUCTION)
.toConstantValue(isConfiguredForAWSProduction)
// Middleware
container

View File

@@ -15,7 +15,9 @@ export const TYPES = {
ApiGateway_VERSION: Symbol.for('ApiGateway_VERSION'),
ApiGateway_CROSS_SERVICE_TOKEN_CACHE_TTL: Symbol.for('ApiGateway_CROSS_SERVICE_TOKEN_CACHE_TTL'),
ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER: Symbol.for('ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER'),
ApiGateway_IS_CONFIGURED_FOR_AWS_PRODUCTION: Symbol.for('ApiGateway_IS_CONFIGURED_FOR_AWS_PRODUCTION'),
ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING: Symbol.for(
'ApiGateway_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING',
),
// Middleware
ApiGateway_RequiredCrossServiceTokenMiddleware: Symbol.for('ApiGateway_RequiredCrossServiceTokenMiddleware'),
ApiGateway_OptionalCrossServiceTokenMiddleware: Symbol.for('ApiGateway_OptionalCrossServiceTokenMiddleware'),
@@ -26,4 +28,5 @@ export const TYPES = {
ApiGateway_CrossServiceTokenCache: Symbol.for('ApiGateway_CrossServiceTokenCache'),
ApiGateway_Timer: Symbol.for('ApiGateway_Timer'),
ApiGateway_EndpointResolver: Symbol.for('ApiGateway_EndpointResolver'),
ApiGateway_OpenTelemetrySDK: Symbol.for('ApiGateway_OpenTelemetrySDK'),
}

View File

@@ -8,7 +8,6 @@ import { Logger } from 'winston'
import { CrossServiceTokenCacheInterface } from '../Service/Cache/CrossServiceTokenCacheInterface'
import { ServiceProxyInterface } from '../Service/Http/ServiceProxyInterface'
import { Segment, getSegment } from 'aws-xray-sdk'
export abstract class AuthMiddleware extends BaseMiddleware {
constructor(
@@ -17,7 +16,6 @@ export abstract class AuthMiddleware extends BaseMiddleware {
private crossServiceTokenCacheTTL: number,
private crossServiceTokenCache: CrossServiceTokenCacheInterface,
private timer: TimerInterface,
private isConfiguredForAWSProduction: boolean,
protected logger: Logger,
) {
super()
@@ -75,13 +73,6 @@ export abstract class AuthMiddleware extends BaseMiddleware {
response.locals.roles = decodedToken.roles
response.locals.sharedVaultOwnerContext = decodedToken.shared_vault_owner_context
response.locals.belongsToSharedVaults = decodedToken.belongs_to_shared_vaults ?? []
if (this.isConfiguredForAWSProduction) {
const segment = getSegment()
if (segment instanceof Segment) {
segment.setUser(decodedToken.user.uuid)
}
}
} catch (error) {
const errorMessage = (error as AxiosError).isAxiosError
? JSON.stringify((error as AxiosError).response?.data)

View File

@@ -16,18 +16,9 @@ export class OptionalCrossServiceTokenMiddleware extends AuthMiddleware {
@inject(TYPES.ApiGateway_CROSS_SERVICE_TOKEN_CACHE_TTL) crossServiceTokenCacheTTL: number,
@inject(TYPES.ApiGateway_CrossServiceTokenCache) crossServiceTokenCache: CrossServiceTokenCacheInterface,
@inject(TYPES.ApiGateway_Timer) timer: TimerInterface,
@inject(TYPES.ApiGateway_IS_CONFIGURED_FOR_AWS_PRODUCTION) isConfiguredForAWSProduction: boolean,
@inject(TYPES.ApiGateway_Logger) logger: Logger,
) {
super(
serviceProxy,
jwtSecret,
crossServiceTokenCacheTTL,
crossServiceTokenCache,
timer,
isConfiguredForAWSProduction,
logger,
)
super(serviceProxy, jwtSecret, crossServiceTokenCacheTTL, crossServiceTokenCache, timer, logger)
}
protected override handleSessionValidationResponse(

View File

@@ -16,18 +16,9 @@ export class RequiredCrossServiceTokenMiddleware extends AuthMiddleware {
@inject(TYPES.ApiGateway_CROSS_SERVICE_TOKEN_CACHE_TTL) crossServiceTokenCacheTTL: number,
@inject(TYPES.ApiGateway_CrossServiceTokenCache) crossServiceTokenCache: CrossServiceTokenCacheInterface,
@inject(TYPES.ApiGateway_Timer) timer: TimerInterface,
@inject(TYPES.ApiGateway_IS_CONFIGURED_FOR_AWS_PRODUCTION) isConfiguredForAWSProduction: boolean,
@inject(TYPES.ApiGateway_Logger) logger: Logger,
) {
super(
serviceProxy,
jwtSecret,
crossServiceTokenCacheTTL,
crossServiceTokenCache,
timer,
isConfiguredForAWSProduction,
logger,
)
super(serviceProxy, jwtSecret, crossServiceTokenCacheTTL, crossServiceTokenCache, timer, logger)
}
protected override handleSessionValidationResponse(

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.153.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.152.2...@standardnotes/auth-server@1.153.0) (2023-10-09)
### Features
* add opentelemetry to all services ([5e930d0](https://github.com/standardnotes/server/commit/5e930d08eb60a0da800081342315e7edaf130951))
## [1.152.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.152.1...@standardnotes/auth-server@1.152.2) (2023-10-09)
### Bug Fixes
* remove xray sdk in favor of opentelemetry ([b736dab](https://github.com/standardnotes/server/commit/b736dab3c1f76c9e03c4bc7bbf153dcb3309b7cb))
## [1.152.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.152.0...@standardnotes/auth-server@1.152.1) (2023-10-06)
### Bug Fixes
* **auth:** checking for transition role when triggering transition ([79a44aa](https://github.com/standardnotes/server/commit/79a44aa51f15311fcaf76c39f93d1934ec1d135d))
# [1.152.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.151.2...@standardnotes/auth-server@1.152.0) (2023-10-06)
### Bug Fixes
* **auth:** strip user from transition role after migration ([afe9967](https://github.com/standardnotes/server/commit/afe9967d26b5be02d1dc76a740df614d81a6984e))
### Features
* switch transition direction ([27bea44](https://github.com/standardnotes/server/commit/27bea444cce4964feda04bad64e5f12a07415e0c))
## [1.151.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.151.1...@standardnotes/auth-server@1.151.2) (2023-10-06)
### Bug Fixes
* add xray-sdk to background processors ([a45b5b6](https://github.com/standardnotes/server/commit/a45b5b69b5d68c2e696c30f0ba5ad22d313321e6))
## [1.151.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.151.0...@standardnotes/auth-server@1.151.1) (2023-10-06)
**Note:** Version bump only for package @standardnotes/auth-server

View File

@@ -24,13 +24,12 @@ import { urlencoded, json, Request, Response, NextFunction } from 'express'
import * as winston from 'winston'
import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
import * as AWSXRay from 'aws-xray-sdk'
import { InversifyExpressServer } from 'inversify-express-utils'
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
import { ServiceIdentifier } from '@standardnotes/domain-core'
import { OpenTelemetrySDKInterface } from '@standardnotes/domain-events-infra'
const container = new ContainerConfigLoader()
void container.load().then((container) => {
@@ -39,20 +38,9 @@ void container.load().then((container) => {
const env: Env = new Env()
env.load()
const isConfiguredForAWSProduction =
env.get('MODE', true) !== 'home-server' && env.get('MODE', true) !== 'self-hosted'
if (isConfiguredForAWSProduction) {
AWSXRay.config([AWSXRay.plugins.ECSPlugin])
}
const server = new InversifyExpressServer(container)
server.setConfig((app) => {
if (isConfiguredForAWSProduction) {
app.use(AWSXRay.express.openSegment(ServiceIdentifier.NAMES.Auth))
}
app.use((_request: Request, response: Response, next: NextFunction) => {
response.setHeader('X-Auth-Version', container.get(TYPES.Auth_VERSION))
next()
@@ -79,8 +67,9 @@ void container.load().then((container) => {
const serverInstance = server.build()
if (isConfiguredForAWSProduction) {
serverInstance.use(AWSXRay.express.closeSegment())
if (!container.get<boolean>(TYPES.Auth_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)) {
const openTelemetrySDK = container.get<OpenTelemetrySDKInterface>(TYPES.Auth_OpenTelemetrySDK)
openTelemetrySDK.start()
}
serverInstance.listen(env.get('PORT'))

View File

@@ -49,7 +49,7 @@ const requestTransition = async (
itemsTransitionStatus?.value === TransitionStatus.STATUSES.Verified &&
revisionsTransitionStatus?.value === TransitionStatus.STATUSES.Verified
if (userHasTransitionRole && bothTransitionStatusesAreVerified) {
if (!userHasTransitionRole && bothTransitionStatusesAreVerified) {
continue
}

View File

@@ -8,7 +8,6 @@ import { Env } from '../src/Bootstrap/Env'
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
import * as AWSXRay from 'aws-xray-sdk'
const container = new ContainerConfigLoader('worker')
void container.load().then((container) => {
@@ -17,14 +16,6 @@ void container.load().then((container) => {
const env: Env = new Env()
env.load()
const isConfiguredForAWSProduction =
env.get('MODE', true) !== 'home-server' && env.get('MODE', true) !== 'self-hosted'
if (isConfiguredForAWSProduction) {
AWSXRay.enableManualMode()
AWSXRay.config([AWSXRay.plugins.ECSPlugin])
}
const logger: Logger = container.get(TYPES.Auth_Logger)
logger.info('Starting worker...')

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.151.1",
"version": "1.153.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -54,7 +54,6 @@
"@standardnotes/sncrypto-common": "^1.13.4",
"@standardnotes/sncrypto-node": "workspace:*",
"@standardnotes/time": "workspace:*",
"aws-xray-sdk": "^3.5.2",
"axios": "^1.1.3",
"bcryptjs": "2.4.3",
"cors": "2.8.5",

View File

@@ -1,6 +1,5 @@
import * as winston from 'winston'
import Redis from 'ioredis'
import { captureAWSv3Client } from 'aws-xray-sdk'
import { SNSClient, SNSClientConfig } from '@aws-sdk/client-sns'
import { SQSClient, SQSClientConfig } from '@aws-sdk/client-sqs'
import { Container } from 'inversify'
@@ -90,10 +89,11 @@ import { ExtensionKeyGrantedEventHandler } from '../Domain/Handler/ExtensionKeyG
import {
DirectCallDomainEventPublisher,
DirectCallEventMessageHandler,
OpenTelemetrySDK,
OpenTelemetrySDKInterface,
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSEventMessageHandler,
SQSXRayEventMessageHandler,
} from '@standardnotes/domain-events-infra'
import { GetUserSubscription } from '../Domain/UseCase/GetUserSubscription/GetUserSubscription'
import { ChangeCredentials } from '../Domain/UseCase/ChangeCredentials/ChangeCredentials'
@@ -323,9 +323,19 @@ export class ContainerConfigLoader {
const isConfiguredForHomeServer = env.get('MODE', true) === 'home-server'
const isConfiguredForSelfHosting = env.get('MODE', true) === 'self-hosted'
const isConfiguredForAWSProduction = !isConfiguredForHomeServer && !isConfiguredForSelfHosting
const isConfiguredForHomeServerOrSelfHosting = isConfiguredForHomeServer || isConfiguredForSelfHosting
const isConfiguredForInMemoryCache = env.get('CACHE_TYPE', true) === 'memory'
container
.bind<boolean>(TYPES.Auth_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING)
.toConstantValue(isConfiguredForHomeServerOrSelfHosting)
if (!isConfiguredForHomeServerOrSelfHosting) {
container
.bind<OpenTelemetrySDKInterface>(TYPES.Auth_OpenTelemetrySDK)
.toConstantValue(new OpenTelemetrySDK(ServiceIdentifier.NAMES.Auth))
}
if (!isConfiguredForInMemoryCache) {
const redisUrl = env.get('REDIS_URL')
const isRedisInClusterMode = redisUrl.indexOf(',') > 0
@@ -354,10 +364,7 @@ export class ContainerConfigLoader {
secretAccessKey: env.get('SNS_SECRET_ACCESS_KEY', true),
}
}
let snsClient = new SNSClient(snsConfig)
if (isConfiguredForAWSProduction) {
snsClient = captureAWSv3Client(snsClient)
}
const snsClient = new SNSClient(snsConfig)
container.bind<SNSClient>(TYPES.Auth_SNS).toConstantValue(snsClient)
const sqsConfig: SQSClientConfig = {
@@ -372,10 +379,7 @@ export class ContainerConfigLoader {
secretAccessKey: env.get('SQS_SECRET_ACCESS_KEY', true),
}
}
let sqsClient = new SQSClient(sqsConfig)
if (isConfiguredForAWSProduction) {
sqsClient = captureAWSv3Client(sqsClient)
}
const sqsClient = new SQSClient(sqsConfig)
container.bind<SQSClient>(TYPES.Auth_SQS).toConstantValue(sqsClient)
}
@@ -1234,15 +1238,7 @@ export class ContainerConfigLoader {
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.Auth_DomainEventMessageHandler)
.toConstantValue(
isConfiguredForAWSProduction
? new SQSXRayEventMessageHandler(
ServiceIdentifier.NAMES.AuthWorker,
eventHandlers,
container.get(TYPES.Auth_Logger),
)
: new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Auth_Logger)),
)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Auth_Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.Auth_DomainEventSubscriberFactory)

View File

@@ -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_OpenTelemetrySDK: Symbol.for('Auth_OpenTelemetrySDK'),
// Mapping
Auth_SessionTracePersistenceMapper: Symbol.for('Auth_SessionTracePersistenceMapper'),
Auth_AuthenticatorChallengePersistenceMapper: Symbol.for('Auth_AuthenticatorChallengePersistenceMapper'),
@@ -105,6 +106,7 @@ const TYPES = {
Auth_U2F_EXPECTED_ORIGIN: Symbol.for('Auth_U2F_EXPECTED_ORIGIN'),
Auth_U2F_REQUIRE_USER_VERIFICATION: Symbol.for('Auth_U2F_REQUIRE_USER_VERIFICATION'),
Auth_READONLY_USERS: Symbol.for('Auth_READONLY_USERS'),
Auth_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING: Symbol.for('Auth_IS_CONFIGURED_FOR_HOME_SERVER_OR_SELF_HOSTING'),
// use cases
Auth_AuthenticateUser: Symbol.for('Auth_AuthenticateUser'),
Auth_AuthenticateRequest: Symbol.for('Auth_AuthenticateRequest'),

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