Compare commits

...

11 Commits

Author SHA1 Message Date
standardci
7baf5492bc chore(release): publish new version
- @standardnotes/api-gateway@1.64.3
 - @standardnotes/auth-server@1.119.5
 - @standardnotes/home-server@1.11.13
 - @standardnotes/syncing-server@1.44.4
2023-06-28 12:45:50 +00:00
Karol Sójko
d5a8409bb5 fix: add debug logs for invalid-auth responses 2023-06-28 14:30:39 +02:00
standardci
f58f90667c chore(release): publish new version
- @standardnotes/analytics@2.24.2
 - @standardnotes/auth-server@1.119.4
 - @standardnotes/common@1.48.3
 - @standardnotes/home-server@1.11.12
 - @standardnotes/revisions-server@1.23.3
 - @standardnotes/syncing-server@1.44.3
 - @standardnotes/websockets-server@1.9.2
2023-06-28 11:17:34 +00:00
Mo
a388e1a802 chore: add new content types 2023-06-28 06:02:18 -05:00
standardci
8811d10a73 chore(release): publish new version
- @standardnotes/home-server@1.11.11
2023-06-22 12:10:36 +00:00
Karol Sójko
c7a394cd1a fix(home-server): destroy winston loggers upon server shutdown 2023-06-22 13:56:05 +02:00
standardci
b7615a7f2e chore(release): publish new version
- @standardnotes/home-server@1.11.10
2023-06-22 11:30:12 +00:00
Karol Sójko
1ca70c1e50 fix(home-server): pass the log stream callback before loggers are created 2023-06-22 13:15:33 +02:00
standardci
253cbb1d0c chore(release): publish new version
- @standardnotes/home-server@1.11.9
2023-06-22 10:52:11 +00:00
Karol Sójko
e38a16404c fix(home-server): listening on log stream 2023-06-22 12:37:19 +02:00
Karol Sójko
f17a1f875c fix(home-server): passthrough stream for loggers 2023-06-22 12:33:23 +02:00
27 changed files with 144 additions and 36 deletions

View File

@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.24.2](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.1...@standardnotes/analytics@2.24.2) (2023-06-28)
**Note:** Version bump only for package @standardnotes/analytics
## [2.24.1](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.24.0...@standardnotes/analytics@2.24.1) (2023-06-02)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "2.24.1",
"version": "2.24.2",
"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.64.3](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.64.2...@standardnotes/api-gateway@1.64.3) (2023-06-28)
### Bug Fixes
* add debug logs for invalid-auth responses ([d5a8409](https://github.com/standardnotes/api-gateway/commit/d5a8409bb5d35b9caf410a36ea0d5cb747129e8d))
## [1.64.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.64.1...@standardnotes/api-gateway@1.64.2) (2023-06-22)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.64.2",
"version": "1.64.3",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -17,7 +17,7 @@ export abstract class AuthMiddleware extends BaseMiddleware {
private crossServiceTokenCacheTTL: number,
private crossServiceTokenCache: CrossServiceTokenCacheInterface,
private timer: TimerInterface,
private logger: Logger,
protected logger: Logger,
) {
super()
}

View File

@@ -42,6 +42,8 @@ export class RequiredCrossServiceTokenMiddleware extends AuthMiddleware {
_next: NextFunction,
): boolean {
if (!authHeaderValue) {
this.logger.debug('Missing auth header')
response.status(401).send({
error: {
tag: 'invalid-auth',

View File

@@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.119.5](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.119.4...@standardnotes/auth-server@1.119.5) (2023-06-28)
### Bug Fixes
* add debug logs for invalid-auth responses ([d5a8409](https://github.com/standardnotes/server/commit/d5a8409bb5d35b9caf410a36ea0d5cb747129e8d))
## [1.119.4](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.119.3...@standardnotes/auth-server@1.119.4) (2023-06-28)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.119.3](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.119.2...@standardnotes/auth-server@1.119.3) (2023-06-22)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.119.3",
"version": "1.119.5",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -16,6 +16,8 @@ export class AuthenticateRequest implements UseCaseInterface {
async execute(dto: AuthenticateRequestDTO): Promise<AuthenticateRequestResponse> {
if (!dto.authorizationHeader) {
this.logger.debug('Authorization header not provided.')
return {
success: false,
responseCode: 401,

View File

@@ -7,6 +7,7 @@ import { AuthenticateUser } from './AuthenticateUser'
import { RevokedSession } from '../Session/RevokedSession'
import { AuthenticationMethodResolverInterface } from '../Auth/AuthenticationMethodResolverInterface'
import { TimerInterface } from '@standardnotes/time'
import { Logger } from 'winston'
describe('AuthenticateUser', () => {
let user: User
@@ -14,11 +15,15 @@ describe('AuthenticateUser', () => {
let revokedSession: RevokedSession
let authenticationMethodResolver: AuthenticationMethodResolverInterface
let timer: TimerInterface
let logger: Logger
const accessTokenAge = 3600
const createUseCase = () => new AuthenticateUser(authenticationMethodResolver, timer, accessTokenAge)
const createUseCase = () => new AuthenticateUser(authenticationMethodResolver, timer, accessTokenAge, logger)
beforeEach(() => {
logger = {} as jest.Mocked<Logger>
logger.debug = jest.fn()
user = {} as jest.Mocked<User>
user.supportsSessions = jest.fn().mockReturnValue(false)

View File

@@ -9,6 +9,7 @@ import { Session } from '../Session/Session'
import { AuthenticateUserDTO } from './AuthenticateUserDTO'
import { AuthenticateUserResponse } from './AuthenticateUserResponse'
import { UseCaseInterface } from './UseCaseInterface'
import { Logger } from 'winston'
@injectable()
export class AuthenticateUser implements UseCaseInterface {
@@ -17,11 +18,14 @@ export class AuthenticateUser implements UseCaseInterface {
private authenticationMethodResolver: AuthenticationMethodResolverInterface,
@inject(TYPES.Auth_Timer) private timer: TimerInterface,
@inject(TYPES.Auth_ACCESS_TOKEN_AGE) private accessTokenAge: number,
@inject(TYPES.Auth_Logger) private logger: Logger,
) {}
async execute(dto: AuthenticateUserDTO): Promise<AuthenticateUserResponse> {
const authenticationMethod = await this.authenticationMethodResolver.resolve(dto.token)
if (!authenticationMethod) {
this.logger.debug('No authentication method found for token.')
return {
success: false,
failureType: 'INVALID_AUTH',
@@ -37,6 +41,8 @@ export class AuthenticateUser implements UseCaseInterface {
const user = authenticationMethod.user
if (!user) {
this.logger.debug('No user found for authentication method.')
return {
success: false,
failureType: 'INVALID_AUTH',
@@ -44,6 +50,8 @@ export class AuthenticateUser implements UseCaseInterface {
}
if (authenticationMethod.type == 'jwt' && user.supportsSessions()) {
this.logger.debug('User supports sessions but is trying to authenticate with a JWT.')
return {
success: false,
failureType: 'INVALID_AUTH',
@@ -56,6 +64,8 @@ export class AuthenticateUser implements UseCaseInterface {
const encryptedPasswordDigest = crypto.createHash('sha256').update(user.encryptedPassword).digest('hex')
if (!pwHash || !crypto.timingSafeEqual(Buffer.from(pwHash), Buffer.from(encryptedPasswordDigest))) {
this.logger.debug('Password hash does not match.')
return {
success: false,
failureType: 'INVALID_AUTH',
@@ -66,6 +76,8 @@ export class AuthenticateUser implements UseCaseInterface {
case 'session_token': {
const session = authenticationMethod.session
if (!session) {
this.logger.debug('No session found for authentication method.')
return {
success: false,
failureType: 'INVALID_AUTH',
@@ -73,6 +85,8 @@ export class AuthenticateUser implements UseCaseInterface {
}
if (session.refreshExpiration < this.timer.getUTCDate()) {
this.logger.debug('Session refresh token has expired.')
return {
success: false,
failureType: 'INVALID_AUTH',

View File

@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.48.3](https://github.com/standardnotes/server/compare/@standardnotes/common@1.48.2...@standardnotes/common@1.48.3) (2023-06-28)
**Note:** Version bump only for package @standardnotes/common
## [1.48.2](https://github.com/standardnotes/server/compare/@standardnotes/common@1.48.0...@standardnotes/common@1.48.2) (2023-05-31)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/common",
"version": "1.48.2",
"version": "1.48.3",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -2,6 +2,10 @@
export enum ContentType {
Any = '*',
Item = 'SF|Item',
KeySystemItemsKey = 'SN|KeySystemItemsKey',
KeySystemRootKey = 'SN|KeySystemRootKey',
TrustedContact = 'SN|TrustedContact',
VaultListing = 'SN|VaultListing',
RootKey = 'SN|RootKey|NoSync',
ItemsKey = 'SN|ItemsKey',
EncryptedStorage = 'SN|EncryptedStorage',

View File

@@ -3,6 +3,33 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.11.13](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.11.12...@standardnotes/home-server@1.11.13) (2023-06-28)
**Note:** Version bump only for package @standardnotes/home-server
## [1.11.12](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.11.11...@standardnotes/home-server@1.11.12) (2023-06-28)
**Note:** Version bump only for package @standardnotes/home-server
## [1.11.11](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.11.10...@standardnotes/home-server@1.11.11) (2023-06-22)
### Bug Fixes
* **home-server:** destroy winston loggers upon server shutdown ([c7a394c](https://github.com/standardnotes/server/commit/c7a394cd1a696305796362cca25fea93e695a86a))
## [1.11.10](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.11.9...@standardnotes/home-server@1.11.10) (2023-06-22)
### Bug Fixes
* **home-server:** pass the log stream callback before loggers are created ([1ca70c1](https://github.com/standardnotes/server/commit/1ca70c1e504257a3753203c0b5630db3d446d393))
## [1.11.9](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.11.8...@standardnotes/home-server@1.11.9) (2023-06-22)
### Bug Fixes
* **home-server:** listening on log stream ([e38a164](https://github.com/standardnotes/server/commit/e38a16404c1b335ab0ef4d8383f6f644e51934ad))
* **home-server:** passthrough stream for loggers ([f17a1f8](https://github.com/standardnotes/server/commit/f17a1f875cd087115b06c8224342f6d102042767))
## [1.11.8](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.11.7...@standardnotes/home-server@1.11.8) (2023-06-22)
### Bug Fixes

View File

@@ -2,16 +2,15 @@ import { HomeServer } from '../src/Server/HomeServer'
const homeServer = new HomeServer()
Promise.resolve(homeServer.start({ dataDirectoryPath: `${__dirname}/../data` }))
.then(() => {
const logStream = homeServer.logs()
logStream.on('data', (chunk: Buffer) => {
Promise.resolve(
homeServer.start({
dataDirectoryPath: `${__dirname}/../data`,
logStreamCallback: (chunk: Buffer) => {
// eslint-disable-next-line no-console
console.log(chunk.toString())
})
})
.catch((error) => {
// eslint-disable-next-line no-console
console.log(`Could not start server: ${error.message}`)
})
},
}),
).catch((error) => {
// eslint-disable-next-line no-console
console.log(`Could not start server: ${error.message}`)
})

View File

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

View File

@@ -25,7 +25,15 @@ import { HomeServerConfiguration } from './HomeServerConfiguration'
export class HomeServer implements HomeServerInterface {
private serverInstance: http.Server | undefined
private authService: AuthServiceInterface | undefined
private logStream: PassThrough = new PassThrough()
private logStream: PassThrough | undefined
private readonly loggerNames = [
'auth-server',
'syncing-server',
'revisions-server',
'files-server',
'api-gateway',
'home-server',
]
async start(configuration: HomeServerConfiguration): Promise<Result<string>> {
try {
@@ -47,7 +55,7 @@ export class HomeServer implements HomeServerInterface {
const env: Env = new Env(environmentOverrides)
env.load()
this.configureLoggers(env)
this.configureLoggers(env, configuration)
const apiGatewayService = new ApiGatewayService(serviceContainer)
const authService = new AuthService(serviceContainer, controllerContainer, directCallDomainEventPublisher)
@@ -165,6 +173,14 @@ export class HomeServer implements HomeServerInterface {
return Result.fail('Home server is not running.')
}
for (const loggerName of this.loggerNames) {
winston.loggers.close(loggerName)
}
if (this.logStream) {
this.logStream.end()
}
this.serverInstance.close()
this.serverInstance.unref()
@@ -192,23 +208,18 @@ export class HomeServer implements HomeServerInterface {
return this.authService.activatePremiumFeatures(username)
}
logs(): NodeJS.ReadableStream {
return this.logStream
}
private configureLoggers(env: Env, configuration: HomeServerConfiguration): void {
this.logStream = new PassThrough()
if (configuration.logStreamCallback) {
this.logStream.on('data', configuration.logStreamCallback)
}
private configureLoggers(env: Env): void {
const winstonFormatters = [winston.format.splat(), winston.format.json()]
const level = env.get('LOG_LEVEL', true) || 'info'
for (const loggerName of [
'auth-server',
'syncing-server',
'revisions-server',
'files-server',
'api-gateway',
'home-server',
]) {
for (const loggerName of this.loggerNames) {
winston.loggers.add(loggerName, {
level,
format: winston.format.combine(...winstonFormatters),

View File

@@ -1,4 +1,5 @@
export interface HomeServerConfiguration {
dataDirectoryPath: string
environment?: { [name: string]: string }
logStreamCallback?: (chunk: Buffer) => void
}

View File

@@ -6,5 +6,4 @@ export interface HomeServerInterface {
activatePremiumFeatures(username: string): Promise<Result<string>>
stop(): Promise<Result<string>>
isRunning(): Promise<boolean>
logs(): NodeJS.ReadableStream
}

View File

@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.23.3](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.23.2...@standardnotes/revisions-server@1.23.3) (2023-06-28)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.23.2](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.23.1...@standardnotes/revisions-server@1.23.2) (2023-06-22)
### Bug Fixes

View File

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

View File

@@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.44.4](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.44.3...@standardnotes/syncing-server@1.44.4) (2023-06-28)
### Bug Fixes
* add debug logs for invalid-auth responses ([d5a8409](https://github.com/standardnotes/syncing-server-js/commit/d5a8409bb5d35b9caf410a36ea0d5cb747129e8d))
## [1.44.3](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.44.2...@standardnotes/syncing-server@1.44.3) (2023-06-28)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.44.2](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.44.1...@standardnotes/syncing-server@1.44.2) (2023-06-22)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.44.2",
"version": "1.44.4",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -13,6 +13,8 @@ export class InversifyExpressAuthMiddleware extends BaseMiddleware {
async handler(request: Request, response: Response, next: NextFunction): Promise<void> {
try {
if (!request.header('X-Auth-Token')) {
this.logger.debug('Missing X-Auth-Token header')
return this.sendInvalidAuthResponse(response)
}

View File

@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.9.2](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.9.1...@standardnotes/websockets-server@1.9.2) (2023-06-28)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.9.1](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.9.0...@standardnotes/websockets-server@1.9.1) (2023-06-02)
### Bug Fixes

View File

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