Compare commits

...

3 Commits

34 changed files with 130 additions and 45 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.30.1](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.30.0...@standardnotes/analytics@2.30.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/analytics
# [2.30.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.29.0...@standardnotes/analytics@2.30.0) (2023-10-11)
### Features

View File

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

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.79.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.1...@standardnotes/api-gateway@1.79.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.79.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.0...@standardnotes/api-gateway@1.79.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/api-gateway

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.79.1",
"version": "1.79.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.157.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.157.0...@standardnotes/auth-server@1.157.1) (2023-10-11)
### Bug Fixes
* **auth:** reduce session select queries in favor of insert/update model ([25a875c](https://github.com/standardnotes/server/commit/25a875cbbc0f0f04d3e786da1263e6f3e5bc3b79))
# [1.157.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.156.0...@standardnotes/auth-server@1.157.0) (2023-10-11)
### Features

View File

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

View File

@@ -5,5 +5,6 @@ export interface EphemeralSessionRepositoryInterface {
findOneByUuidAndUserUuid(uuid: string, userUuid: string): Promise<EphemeralSession | null>
findAllByUserUuid(userUuid: string): Promise<Array<EphemeralSession>>
deleteOne(uuid: string, userUuid: string): Promise<void>
save(ephemeralSession: EphemeralSession): Promise<void>
insert(ephemeralSession: EphemeralSession): Promise<void>
update(ephemeralSession: EphemeralSession): Promise<void>
}

View File

@@ -3,7 +3,8 @@ import { RevokedSession } from './RevokedSession'
export interface RevokedSessionRepositoryInterface {
findOneByUuid(uuid: string): Promise<RevokedSession | null>
findAllByUserUuid(userUuid: string): Promise<Array<RevokedSession>>
save(revokedSession: RevokedSession): Promise<RevokedSession>
insert(revokedSession: RevokedSession): Promise<void>
update(revokedSession: RevokedSession): Promise<void>
remove(revokedSession: RevokedSession): Promise<RevokedSession>
clearUserAgentByUserUuid(userUuid: string): Promise<void>
}

View File

@@ -9,7 +9,8 @@ export interface SessionRepositoryInterface {
findAllByUserUuid(userUuid: string): Promise<Array<Session>>
deleteAllByUserUuidExceptOne(dto: { userUuid: Uuid; currentSessionUuid: Uuid }): Promise<void>
deleteOneByUuid(uuid: string): Promise<void>
save(session: Session): Promise<Session>
insert(session: Session): Promise<void>
update(session: Session): Promise<void>
remove(session: Session): Promise<Session>
clearUserAgentByUserUuid(userUuid: string): Promise<void>
removeExpiredBefore(date: Date): Promise<void>

View File

@@ -69,18 +69,21 @@ describe('SessionService', () => {
sessionRepository = {} as jest.Mocked<SessionRepositoryInterface>
sessionRepository.findOneByUuid = jest.fn().mockReturnValue(null)
sessionRepository.deleteOneByUuid = jest.fn()
sessionRepository.save = jest.fn().mockReturnValue(existingSession)
sessionRepository.insert = jest.fn()
sessionRepository.update = jest.fn()
settingService = {} as jest.Mocked<SettingServiceInterface>
settingService.findSettingWithDecryptedValue = jest.fn().mockReturnValue(null)
ephemeralSessionRepository = {} as jest.Mocked<EphemeralSessionRepositoryInterface>
ephemeralSessionRepository.save = jest.fn()
ephemeralSessionRepository.insert = jest.fn()
ephemeralSessionRepository.update = jest.fn()
ephemeralSessionRepository.findOneByUuid = jest.fn()
ephemeralSessionRepository.deleteOne = jest.fn()
revokedSessionRepository = {} as jest.Mocked<RevokedSessionRepositoryInterface>
revokedSessionRepository.save = jest.fn()
revokedSessionRepository.insert = jest.fn()
revokedSessionRepository.update = jest.fn()
existingEphemeralSession = {} as jest.Mocked<EphemeralSession>
existingEphemeralSession.uuid = '2-3-4'
@@ -129,7 +132,7 @@ describe('SessionService', () => {
it('should mark a revoked session as received', async () => {
await createService().markRevokedSessionAsReceived(revokedSession)
expect(revokedSessionRepository.save).toHaveBeenCalledWith({
expect(revokedSessionRepository.update).toHaveBeenCalledWith({
uuid: '2e1e43',
received: true,
receivedAt: new Date(1),
@@ -145,8 +148,8 @@ describe('SessionService', () => {
readonly_access: false,
})
expect(sessionRepository.save).toHaveBeenCalled()
expect(ephemeralSessionRepository.save).not.toHaveBeenCalled()
expect(sessionRepository.update).toHaveBeenCalled()
expect(ephemeralSessionRepository.update).not.toHaveBeenCalled()
})
it('should refresh access and refresh tokens for an ephemeral session', async () => {
@@ -158,8 +161,8 @@ describe('SessionService', () => {
readonly_access: false,
})
expect(sessionRepository.save).not.toHaveBeenCalled()
expect(ephemeralSessionRepository.save).toHaveBeenCalled()
expect(sessionRepository.update).not.toHaveBeenCalled()
expect(ephemeralSessionRepository.update).toHaveBeenCalled()
})
it('should create new session for a user', async () => {
@@ -173,8 +176,8 @@ describe('SessionService', () => {
readonlyAccess: false,
})
expect(sessionRepository.save).toHaveBeenCalledWith(expect.any(Session))
expect(sessionRepository.save).toHaveBeenCalledWith({
expect(sessionRepository.insert).toHaveBeenCalledWith(expect.any(Session))
expect(sessionRepository.insert).toHaveBeenCalledWith({
accessExpiration: expect.any(Date),
apiVersion: '003',
createdAt: expect.any(Date),
@@ -209,8 +212,8 @@ describe('SessionService', () => {
readonlyAccess: false,
})
expect(sessionRepository.save).toHaveBeenCalledWith(expect.any(Session))
expect(sessionRepository.save).toHaveBeenCalledWith({
expect(sessionRepository.insert).toHaveBeenCalledWith(expect.any(Session))
expect(sessionRepository.insert).toHaveBeenCalledWith({
accessExpiration: expect.any(Date),
apiVersion: '003',
createdAt: expect.any(Date),
@@ -248,8 +251,8 @@ describe('SessionService', () => {
readonlyAccess: false,
})
expect(sessionRepository.save).toHaveBeenCalledWith(expect.any(Session))
expect(sessionRepository.save).toHaveBeenCalledWith({
expect(sessionRepository.insert).toHaveBeenCalledWith(expect.any(Session))
expect(sessionRepository.insert).toHaveBeenCalledWith({
accessExpiration: expect.any(Date),
apiVersion: '003',
createdAt: expect.any(Date),
@@ -405,8 +408,8 @@ describe('SessionService', () => {
readonlyAccess: false,
})
expect(ephemeralSessionRepository.save).toHaveBeenCalledWith(expect.any(EphemeralSession))
expect(ephemeralSessionRepository.save).toHaveBeenCalledWith({
expect(ephemeralSessionRepository.insert).toHaveBeenCalledWith(expect.any(EphemeralSession))
expect(ephemeralSessionRepository.insert).toHaveBeenCalledWith({
accessExpiration: expect.any(Date),
apiVersion: '003',
createdAt: expect.any(Date),
@@ -684,7 +687,7 @@ describe('SessionService', () => {
it('should revoked a session', async () => {
await createService().createRevokedSession(existingSession)
expect(revokedSessionRepository.save).toHaveBeenCalledWith({
expect(revokedSessionRepository.insert).toHaveBeenCalledWith({
uuid: '2e1e43',
userUuid: '1-2-3',
userAgent: 'Chrome',

View File

@@ -57,7 +57,7 @@ export class SessionService implements SessionServiceInterface {
const sessionPayload = await this.createTokens(session)
await this.sessionRepository.save(session)
await this.sessionRepository.insert(session)
try {
const userSubscription = await this.userSubscriptionRepository.findOneByUserUuid(dto.user.uuid)
@@ -92,7 +92,7 @@ export class SessionService implements SessionServiceInterface {
const sessionPayload = await this.createTokens(ephemeralSession)
await this.ephemeralSessionRepository.save(ephemeralSession)
await this.ephemeralSessionRepository.insert(ephemeralSession)
return {
sessionHttpRepresentation: sessionPayload,
@@ -104,9 +104,9 @@ export class SessionService implements SessionServiceInterface {
const sessionPayload = await this.createTokens(dto.session)
if (dto.isEphemeral) {
await this.ephemeralSessionRepository.save(dto.session)
await this.ephemeralSessionRepository.update(dto.session)
} else {
await this.sessionRepository.save(dto.session)
await this.sessionRepository.update(dto.session)
}
return sessionPayload
@@ -221,7 +221,9 @@ export class SessionService implements SessionServiceInterface {
revokedSession.received = true
revokedSession.receivedAt = this.timer.getUTCDate()
return this.revokedSessionRepository.save(revokedSession)
await this.revokedSessionRepository.update(revokedSession)
return revokedSession
}
async deleteSessionByToken(token: string): Promise<string | null> {
@@ -248,7 +250,9 @@ export class SessionService implements SessionServiceInterface {
revokedSession.apiVersion = session.apiVersion
revokedSession.userAgent = session.userAgent
return this.revokedSessionRepository.save(revokedSession)
await this.revokedSessionRepository.insert(revokedSession)
return revokedSession
}
private async createSession(dto: {

View File

@@ -42,7 +42,7 @@ export class RedisEphemeralSessionRepository implements EphemeralSessionReposito
session.accessExpiration = accessExpiration
session.refreshExpiration = refreshExpiration
await this.save(session)
await this.update(session)
}
async findAllByUserUuid(userUuid: string): Promise<Array<EphemeralSession>> {
@@ -77,7 +77,7 @@ export class RedisEphemeralSessionRepository implements EphemeralSessionReposito
return JSON.parse(stringifiedSession)
}
async save(ephemeralSession: EphemeralSession): Promise<void> {
async insert(ephemeralSession: EphemeralSession): Promise<void> {
const ttl = this.ephemeralSessionAge
const stringifiedSession = JSON.stringify(ephemeralSession)
@@ -92,4 +92,8 @@ export class RedisEphemeralSessionRepository implements EphemeralSessionReposito
await pipeline.exec()
}
async update(ephemeralSession: EphemeralSession): Promise<void> {
return this.insert(ephemeralSession)
}
}

View File

@@ -71,7 +71,11 @@ export class TypeORMEphemeralSessionRepository implements EphemeralSessionReposi
return JSON.parse(stringifiedSession.props.value)
}
async save(ephemeralSession: EphemeralSession): Promise<void> {
async update(ephemeralSession: EphemeralSession): Promise<void> {
return this.insert(ephemeralSession)
}
async insert(ephemeralSession: EphemeralSession): Promise<void> {
const ttl = this.ephemeralSessionAge
ephemeralSession.updatedAt = this.timer.getUTCDate()

View File

@@ -12,8 +12,14 @@ export class TypeORMRevokedSessionRepository implements RevokedSessionRepository
private ormRepository: Repository<RevokedSession>,
) {}
async save(revokedSession: RevokedSession): Promise<RevokedSession> {
return this.ormRepository.save(revokedSession)
async insert(revokedSession: RevokedSession): Promise<void> {
await this.ormRepository.insert(revokedSession)
}
async update(revokedSession: RevokedSession): Promise<void> {
const { uuid, ...revokedSessionProps } = revokedSession
await this.ormRepository.update({ uuid }, revokedSessionProps)
}
async remove(revokedSession: RevokedSession): Promise<RevokedSession> {

View File

@@ -17,10 +17,18 @@ export class TypeORMSessionRepository implements SessionRepositoryInterface {
@inject(TYPES.Auth_Timer) private timer: TimerInterface,
) {}
async save(session: Session): Promise<Session> {
async insert(session: Session): Promise<void> {
session.updatedAt = this.timer.getUTCDate()
return this.ormRepository.save(session)
await this.ormRepository.insert(session)
}
async update(session: Session): Promise<void> {
session.updatedAt = this.timer.getUTCDate()
const { uuid, ...sessionProps } = session
await this.ormRepository.update({ uuid }, sessionProps)
}
async remove(session: Session): Promise<Session> {

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.37.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.36.0...@standardnotes/domain-core@1.37.0) (2023-10-11)
### Features
* **domain-core:** add email scheduled task service identifier ([af5ebb2](https://github.com/standardnotes/server/commit/af5ebb25e7fd05390089e0f7c00af50648ad49d9))
# [1.36.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.35.0...@standardnotes/domain-core@1.36.0) (2023-10-11)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-core",
"version": "1.36.0",
"version": "1.37.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -21,6 +21,7 @@ export class ServiceIdentifier extends ValueObject<ServiceIdentifierProps> {
Email: 'Email',
EmailWorker: 'EmailWorker',
EmailBounceProcessor: 'EmailBounceProcessor',
EmailScheduledTask: 'EmailScheduledTask',
Websockets: 'Websockets',
WebsocketsWorker: 'WebsocketsWorker',
}

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.13.2](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.13.1...@standardnotes/event-store@1.13.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/event-store
## [1.13.1](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.13.0...@standardnotes/event-store@1.13.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/event-store

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/event-store",
"version": "1.13.1",
"version": "1.13.2",
"description": "Event Store Service",
"private": true,
"main": "dist/src/index.js",

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.29.2](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.29.1...@standardnotes/files-server@1.29.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/files-server
## [1.29.1](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.29.0...@standardnotes/files-server@1.29.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/files-server

View File

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

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.17.3](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.2...@standardnotes/home-server@1.17.3) (2023-10-11)
**Note:** Version bump only for package @standardnotes/home-server
## [1.17.2](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.1...@standardnotes/home-server@1.17.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/home-server

View File

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

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.44.2](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.44.1...@standardnotes/revisions-server@1.44.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.44.1](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.44.0...@standardnotes/revisions-server@1.44.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/revisions-server

View File

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

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.24.1](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.24.0...@standardnotes/scheduler-server@1.24.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/scheduler-server
# [1.24.0](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.23.0...@standardnotes/scheduler-server@1.24.0) (2023-10-11)
### Features

View File

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

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.21.45](https://github.com/standardnotes/server/compare/@standardnotes/settings@1.21.44...@standardnotes/settings@1.21.45) (2023-10-11)
**Note:** Version bump only for package @standardnotes/settings
## [1.21.44](https://github.com/standardnotes/server/compare/@standardnotes/settings@1.21.43...@standardnotes/settings@1.21.44) (2023-10-11)
**Note:** Version bump only for package @standardnotes/settings

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/settings",
"version": "1.21.44",
"version": "1.21.45",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

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.116.3](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.116.2...@standardnotes/syncing-server@1.116.3) (2023-10-11)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.116.2](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.116.1...@standardnotes/syncing-server@1.116.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/syncing-server

View File

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

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.15.2](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.15.1...@standardnotes/websockets-server@1.15.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.15.1](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.15.0...@standardnotes/websockets-server@1.15.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/websockets-server

View File

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