Compare commits

...

15 Commits

Author SHA1 Message Date
standardci
e94b0d0b02 chore(release): publish new version
- @standardnotes/analytics@2.34.1
 - @standardnotes/api-gateway@1.87.1
 - @standardnotes/auth-server@1.174.1
 - @standardnotes/common@1.52.1
 - @standardnotes/domain-core@1.41.1
 - @standardnotes/domain-events-infra@1.22.1
 - @standardnotes/domain-events@2.137.1
 - @standardnotes/files-server@1.36.1
 - @standardnotes/grpc@1.3.1
 - @standardnotes/home-server@1.22.1
 - @standardnotes/predicates@1.8.1
 - @standardnotes/revisions-server@1.51.1
 - @standardnotes/scheduler-server@1.27.6
 - @standardnotes/security@1.17.1
 - @standardnotes/settings@1.23.1
 - @standardnotes/sncrypto-node@1.16.1
 - @standardnotes/syncing-server@1.126.1
 - @standardnotes/time@1.18.1
 - @standardnotes/websockets-server@1.20.4
2023-11-27 09:14:33 +00:00
Karol Sójko
ed1bf37287 fix: repository config in package.json files 2023-11-27 09:53:23 +01:00
standardci
3946f56261 chore(release): publish new version
- @standardnotes/analytics@2.34.0
 - @standardnotes/api-gateway@1.87.0
 - @standardnotes/auth-server@1.174.0
 - @standardnotes/common@1.52.0
 - @standardnotes/domain-core@1.41.0
 - @standardnotes/domain-events-infra@1.22.0
 - @standardnotes/domain-events@2.137.0
 - @standardnotes/files-server@1.36.0
 - @standardnotes/grpc@1.3.0
 - @standardnotes/home-server@1.22.0
 - @standardnotes/predicates@1.8.0
 - @standardnotes/revisions-server@1.51.0
 - @standardnotes/scheduler-server@1.27.5
 - @standardnotes/security@1.17.0
 - @standardnotes/settings@1.23.0
 - @standardnotes/sncrypto-node@1.16.0
 - @standardnotes/syncing-server@1.126.0
 - @standardnotes/time@1.18.0
 - @standardnotes/websockets-server@1.20.3
2023-11-27 08:43:38 +00:00
Karol Sójko
fc53dab007 feat: allow github publish action permission to mint id-token 2023-11-27 09:22:22 +01:00
Karol Sójko
e836abdef7 feat: add npm provenance to published packages 2023-11-27 09:20:10 +01:00
standardci
826482b1f0 chore(release): publish new version
- @standardnotes/analytics@2.33.4
 - @standardnotes/api-gateway@1.86.6
 - @standardnotes/auth-server@1.173.2
 - @standardnotes/domain-events-infra@1.21.4
 - @standardnotes/domain-events@2.136.0
 - @standardnotes/files-server@1.35.2
 - @standardnotes/home-server@1.21.11
 - @standardnotes/revisions-server@1.50.2
 - @standardnotes/scheduler-server@1.27.4
 - @standardnotes/syncing-server@1.125.2
 - @standardnotes/websockets-server@1.20.2
2023-11-23 09:34:26 +00:00
Karol Sójko
45bd00919c feat(domain-events): add email campaign send out requested event 2023-11-23 10:13:00 +01:00
standardci
4e1bae6daf chore(release): publish new version
- @standardnotes/api-gateway@1.86.5
 - @standardnotes/auth-server@1.173.1
 - @standardnotes/home-server@1.21.10
 - @standardnotes/syncing-server@1.125.1
2023-11-22 11:46:47 +00:00
Karol Sójko
8f23c8ab3f fix: error handling on gRPC (#937) 2023-11-22 12:25:42 +01:00
standardci
4d32f26631 chore(release): publish new version
- @standardnotes/analytics@2.33.3
 - @standardnotes/api-gateway@1.86.4
 - @standardnotes/auth-server@1.173.0
 - @standardnotes/domain-events-infra@1.21.3
 - @standardnotes/domain-events@2.135.0
 - @standardnotes/files-server@1.35.1
 - @standardnotes/home-server@1.21.9
 - @standardnotes/revisions-server@1.50.1
 - @standardnotes/scheduler-server@1.27.3
 - @standardnotes/syncing-server@1.125.0
 - @standardnotes/websockets-server@1.20.1
2023-11-22 10:22:09 +00:00
Karol Sójko
c11abe1bd3 feat: add verifiying if user has no items before mass deleting spam accounts (#936) 2023-11-22 11:00:56 +01:00
standardci
4d12566b0d chore(release): publish new version
- @standardnotes/home-server@1.21.8
 - @standardnotes/syncing-server@1.124.3
2023-11-21 14:59:47 +00:00
Karol Sójko
2200dca69d fix(syncing-server): front load themes and user prefs as high priority load items (#935) 2023-11-21 15:38:28 +01:00
standardci
d41dd3bdda chore(release): publish new version
- @standardnotes/api-gateway@1.86.3
 - @standardnotes/home-server@1.21.7
2023-11-21 08:42:31 +00:00
Karol Sójko
c5c24b3ac9 fix(api-gateway): add meta field to grpc sync calls (#934) 2023-11-21 09:21:54 +01:00
64 changed files with 937 additions and 182 deletions

View File

@@ -4,6 +4,9 @@ on:
push:
branches: [ main ]
permissions:
id-token: write
jobs:
build:
if: contains(github.event.head_commit.message, 'chore(release)') == false

View File

@@ -3,6 +3,26 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.34.1](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.34.0...@standardnotes/analytics@2.34.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [2.34.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.33.4...@standardnotes/analytics@2.34.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
## [2.33.4](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.33.3...@standardnotes/analytics@2.33.4) (2023-11-23)
**Note:** Version bump only for package @standardnotes/analytics
## [2.33.3](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.33.2...@standardnotes/analytics@2.33.3) (2023-11-22)
**Note:** Version bump only for package @standardnotes/analytics
## [2.33.2](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.33.1...@standardnotes/analytics@2.33.2) (2023-11-13)
**Note:** Version bump only for package @standardnotes/analytics

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "2.33.2",
"version": "2.34.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -10,7 +10,13 @@
"author": "Standard Notes",
"types": "dist/src/index.d.ts",
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/analytics"
},
"license": "AGPL-3.0-or-later",
"scripts": {

View File

@@ -3,6 +3,38 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.87.1](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.87.0...@standardnotes/api-gateway@1.87.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.87.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.86.6...@standardnotes/api-gateway@1.87.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/api-gateway/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
## [1.86.6](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.86.5...@standardnotes/api-gateway@1.86.6) (2023-11-23)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.86.5](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.86.4...@standardnotes/api-gateway@1.86.5) (2023-11-22)
### Bug Fixes
* error handling on gRPC ([#937](https://github.com/standardnotes/api-gateway/issues/937)) ([8f23c8a](https://github.com/standardnotes/api-gateway/commit/8f23c8ab3f03e9c23adfb31a33c5805492bc2f5b))
## [1.86.4](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.86.3...@standardnotes/api-gateway@1.86.4) (2023-11-22)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.86.3](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.86.2...@standardnotes/api-gateway@1.86.3) (2023-11-21)
### Bug Fixes
* **api-gateway:** add meta field to grpc sync calls ([#934](https://github.com/standardnotes/api-gateway/issues/934)) ([c5c24b3](https://github.com/standardnotes/api-gateway/commit/c5c24b3ac9dbd559d96adc56270d724a3156ebd4))
## [1.86.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.86.1...@standardnotes/api-gateway@1.86.2) (2023-11-20)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.86.2",
"version": "1.87.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -11,11 +11,16 @@
"dist/src/**/*.js",
"dist/src/**/*.d.ts"
],
"repository": "git@github.com:standardnotes/api-gateway.git",
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/api-gateway"
},
"author": "Karol Sójko <karol@standardnotes.com>",
"license": "AGPL-3.0-or-later",
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"scripts": {
"clean": "rm -fr dist",

View File

@@ -88,10 +88,24 @@ export class GRPCServiceProxy implements ServiceProxyInterface {
endpoint: string,
payload?: Record<string, unknown> | string,
): Promise<void> {
if (endpoint === 'items/sync') {
const requestIsUsingLatestApiVersions =
payload !== undefined && typeof payload !== 'string' && 'api' in payload && payload.api === '20200115'
if (requestIsUsingLatestApiVersions && endpoint === 'items/sync') {
const result = await this.gRPCSyncingServerServiceProxy.sync(request, response, payload)
response.status(result.status).send(result.data)
response.status(result.status).send({
meta: {
auth: {
userUuid: response.locals.user?.uuid,
roles: response.locals.roles,
},
server: {
filesServerUrl: this.filesServerUrl,
},
},
data: result.data,
})
return
}

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.174.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.174.0...@standardnotes/auth-server@1.174.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.174.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.173.2...@standardnotes/auth-server@1.174.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
## [1.173.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.173.1...@standardnotes/auth-server@1.173.2) (2023-11-23)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.173.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.173.0...@standardnotes/auth-server@1.173.1) (2023-11-22)
### Bug Fixes
* error handling on gRPC ([#937](https://github.com/standardnotes/server/issues/937)) ([8f23c8a](https://github.com/standardnotes/server/commit/8f23c8ab3f03e9c23adfb31a33c5805492bc2f5b))
# [1.173.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.172.2...@standardnotes/auth-server@1.173.0) (2023-11-22)
### Features
* add verifiying if user has no items before mass deleting spam accounts ([#936](https://github.com/standardnotes/server/issues/936)) ([c11abe1](https://github.com/standardnotes/server/commit/c11abe1bd36de7c0fb9850c20a8157c066fa9379))
## [1.172.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.172.1...@standardnotes/auth-server@1.172.2) (2023-11-20)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.172.2",
"version": "1.174.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -10,7 +10,13 @@
"author": "Karol Sójko <karol@standardnotes.com>",
"license": "AGPL-3.0-or-later",
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/auth"
},
"scripts": {
"clean": "rm -fr dist",

View File

@@ -280,6 +280,7 @@ import { TriggerEmailBackupForAllUsers } from '../Domain/UseCase/TriggerEmailBac
import { CSVFileReaderInterface } from '../Domain/CSV/CSVFileReaderInterface'
import { S3CsvFileReader } from '../Infra/S3/S3CsvFileReader'
import { DeleteAccountsFromCSVFile } from '../Domain/UseCase/DeleteAccountsFromCSVFile/DeleteAccountsFromCSVFile'
import { AccountDeletionVerificationPassedEventHandler } from '../Domain/Handler/AccountDeletionVerificationPassedEventHandler'
export class ContainerConfigLoader {
constructor(private mode: 'server' | 'worker' = 'server') {}
@@ -1274,7 +1275,9 @@ export class ContainerConfigLoader {
.toConstantValue(
new DeleteAccountsFromCSVFile(
container.get<CSVFileReaderInterface>(TYPES.Auth_CSVFileReader),
container.get<DeleteAccount>(TYPES.Auth_DeleteAccount),
container.get<DomainEventPublisherInterface>(TYPES.Auth_DomainEventPublisher),
container.get<DomainEventFactoryInterface>(TYPES.Auth_DomainEventFactory),
container.get<UserRepositoryInterface>(TYPES.Auth_UserRepository),
container.get<winston.Logger>(TYPES.Auth_Logger),
),
)
@@ -1328,6 +1331,14 @@ export class ContainerConfigLoader {
container.get<winston.Logger>(TYPES.Auth_Logger),
),
)
container
.bind<AccountDeletionVerificationPassedEventHandler>(TYPES.Auth_AccountDeletionVerificationPassedEventHandler)
.toConstantValue(
new AccountDeletionVerificationPassedEventHandler(
container.get<DeleteAccount>(TYPES.Auth_DeleteAccount),
container.get<winston.Logger>(TYPES.Auth_Logger),
),
)
container
.bind<SubscriptionPurchasedEventHandler>(TYPES.Auth_SubscriptionPurchasedEventHandler)
.toConstantValue(
@@ -1516,6 +1527,7 @@ export class ContainerConfigLoader {
const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([
['ACCOUNT_DELETION_REQUESTED', container.get(TYPES.Auth_AccountDeletionRequestedEventHandler)],
['ACCOUNT_DELETION_VERIFICATION_PASSED', container.get(TYPES.Auth_AccountDeletionVerificationPassedEventHandler)],
['SUBSCRIPTION_PURCHASED', container.get(TYPES.Auth_SubscriptionPurchasedEventHandler)],
['SUBSCRIPTION_CANCELLED', container.get(TYPES.Auth_SubscriptionCancelledEventHandler)],
['SUBSCRIPTION_RENEWED', container.get(TYPES.Auth_SubscriptionRenewedEventHandler)],

View File

@@ -171,6 +171,7 @@ const TYPES = {
Auth_DeleteAccountsFromCSVFile: Symbol.for('Auth_DeleteAccountsFromCSVFile'),
// Handlers
Auth_AccountDeletionRequestedEventHandler: Symbol.for('Auth_AccountDeletionRequestedEventHandler'),
Auth_AccountDeletionVerificationPassedEventHandler: Symbol.for('Auth_AccountDeletionVerificationPassedEventHandler'),
Auth_SubscriptionPurchasedEventHandler: Symbol.for('Auth_SubscriptionPurchasedEventHandler'),
Auth_SubscriptionCancelledEventHandler: Symbol.for('Auth_SubscriptionCancelledEventHandler'),
Auth_SubscriptionReassignedEventHandler: Symbol.for('Auth_SubscriptionReassignedEventHandler'),

View File

@@ -20,6 +20,7 @@ import {
StatisticPersistenceRequestedEvent,
SessionCreatedEvent,
SessionRefreshedEvent,
AccountDeletionVerificationRequestedEvent,
} from '@standardnotes/domain-events'
import { Predicate, PredicateVerificationResult } from '@standardnotes/predicates'
import { TimerInterface } from '@standardnotes/time'
@@ -33,6 +34,24 @@ import { KeyParamsData } from '@standardnotes/responses'
export class DomainEventFactory implements DomainEventFactoryInterface {
constructor(@inject(TYPES.Auth_Timer) private timer: TimerInterface) {}
createAccountDeletionVerificationRequestedEvent(dto: {
userUuid: string
email: string
}): AccountDeletionVerificationRequestedEvent {
return {
type: 'ACCOUNT_DELETION_VERIFICATION_REQUESTED',
createdAt: this.timer.getUTCDate(),
meta: {
correlation: {
userIdentifier: dto.userUuid,
userIdentifierType: 'uuid',
},
origin: DomainEventService.Auth,
},
payload: dto,
}
}
createSessionCreatedEvent(dto: { userUuid: string }): SessionCreatedEvent {
return {
type: 'SESSION_CREATED',

View File

@@ -18,6 +18,7 @@ import {
StatisticPersistenceRequestedEvent,
SessionCreatedEvent,
SessionRefreshedEvent,
AccountDeletionVerificationRequestedEvent,
} from '@standardnotes/domain-events'
import { InviteeIdentifierType } from '../SharedSubscription/InviteeIdentifierType'
import { KeyParamsData } from '@standardnotes/responses'
@@ -56,6 +57,10 @@ export interface DomainEventFactoryInterface {
ownerUuid: string
}
}): AccountDeletionRequestedEvent
createAccountDeletionVerificationRequestedEvent(dto: {
userUuid: string
email: string
}): AccountDeletionVerificationRequestedEvent
createUserRolesChangedEvent(userUuid: string, email: string, currentRoles: string[]): UserRolesChangedEvent
createUserEmailChangedEvent(userUuid: string, fromEmail: string, toEmail: string): UserEmailChangedEvent
createUserDisabledSessionUserAgentLoggingEvent(dto: {

View File

@@ -0,0 +1,21 @@
import { AccountDeletionVerificationPassedEvent, DomainEventHandlerInterface } from '@standardnotes/domain-events'
import { Logger } from 'winston'
import { DeleteAccount } from '../UseCase/DeleteAccount/DeleteAccount'
export class AccountDeletionVerificationPassedEventHandler implements DomainEventHandlerInterface {
constructor(
private deleteAccount: DeleteAccount,
private logger: Logger,
) {}
async handle(event: AccountDeletionVerificationPassedEvent): Promise<void> {
const result = await this.deleteAccount.execute({
userUuid: event.payload.userUuid,
})
if (result.isFailed()) {
this.logger.error(`AccountDeletionVerificationPassedEventHandler failed: ${result.getError()}`)
}
}
}

View File

@@ -1,33 +1,51 @@
import { Logger } from 'winston'
import { Result } from '@standardnotes/domain-core'
import { AccountDeletionVerificationRequestedEvent, DomainEventPublisherInterface } from '@standardnotes/domain-events'
import { CSVFileReaderInterface } from '../../CSV/CSVFileReaderInterface'
import { DeleteAccount } from '../DeleteAccount/DeleteAccount'
import { DeleteAccountsFromCSVFile } from './DeleteAccountsFromCSVFile'
import { UserRepositoryInterface } from '../../User/UserRepositoryInterface'
import { DomainEventFactoryInterface } from '../../Event/DomainEventFactoryInterface'
import { User } from '../../User/User'
describe('DeleteAccountsFromCSVFile', () => {
let csvFileReader: CSVFileReaderInterface
let deleteAccount: DeleteAccount
let userRepository: UserRepositoryInterface
let domainEventPublisher: DomainEventPublisherInterface
let domainEventFactory: DomainEventFactoryInterface
let logger: Logger
const createUseCase = () => new DeleteAccountsFromCSVFile(csvFileReader, deleteAccount, logger)
const createUseCase = () =>
new DeleteAccountsFromCSVFile(csvFileReader, domainEventPublisher, domainEventFactory, userRepository, logger)
beforeEach(() => {
const user = {} as jest.Mocked<User>
csvFileReader = {} as jest.Mocked<CSVFileReaderInterface>
csvFileReader.getValues = jest.fn().mockResolvedValue(Result.ok(['email1']))
deleteAccount = {} as jest.Mocked<DeleteAccount>
deleteAccount.execute = jest.fn().mockResolvedValue(Result.ok(''))
userRepository = {} as jest.Mocked<UserRepositoryInterface>
userRepository.findAllByUsernameOrEmail = jest.fn().mockResolvedValue([user])
domainEventPublisher = {} as jest.Mocked<DomainEventPublisherInterface>
domainEventPublisher.publish = jest.fn()
domainEventFactory = {} as jest.Mocked<DomainEventFactoryInterface>
domainEventFactory.createAccountDeletionVerificationRequestedEvent = jest
.fn()
.mockReturnValue({} as jest.Mocked<AccountDeletionVerificationRequestedEvent>)
logger = {} as jest.Mocked<Logger>
logger.info = jest.fn()
})
it('should delete accounts', async () => {
it('should request account deletion verification', async () => {
const useCase = createUseCase()
const result = await useCase.execute({ fileName: 'test.csv', dryRun: false })
expect(domainEventPublisher.publish).toHaveBeenCalled()
expect(result.isFailed()).toBeFalsy()
})
@@ -56,12 +74,12 @@ describe('DeleteAccountsFromCSVFile', () => {
const result = await useCase.execute({ fileName: 'test.csv', dryRun: true })
expect(deleteAccount.execute).not.toHaveBeenCalled()
expect(domainEventPublisher.publish).not.toHaveBeenCalled()
expect(result.isFailed()).toBeFalsy()
})
it('should return error if delete account fails', async () => {
deleteAccount.execute = jest.fn().mockResolvedValue(Result.fail('Oops'))
it('should return error username is invalid', async () => {
csvFileReader.getValues = jest.fn().mockResolvedValue(Result.ok(['']))
const useCase = createUseCase()
@@ -69,4 +87,15 @@ describe('DeleteAccountsFromCSVFile', () => {
expect(result.isFailed()).toBeTruthy()
})
it('should do nothing if users could not be found', async () => {
userRepository.findAllByUsernameOrEmail = jest.fn().mockResolvedValue([])
const useCase = createUseCase()
const result = await useCase.execute({ fileName: 'test.csv', dryRun: false })
expect(domainEventPublisher.publish).not.toHaveBeenCalled()
expect(result.isFailed()).toBeFalsy()
})
})

View File

@@ -1,14 +1,18 @@
import { Result, UseCaseInterface } from '@standardnotes/domain-core'
import { Result, UseCaseInterface, Username } from '@standardnotes/domain-core'
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
import { Logger } from 'winston'
import { DeleteAccount } from '../DeleteAccount/DeleteAccount'
import { CSVFileReaderInterface } from '../../CSV/CSVFileReaderInterface'
import { DeleteAccountsFromCSVFileDTO } from './DeleteAccountsFromCSVFileDTO'
import { DomainEventFactoryInterface } from '../../Event/DomainEventFactoryInterface'
import { UserRepositoryInterface } from '../../User/UserRepositoryInterface'
export class DeleteAccountsFromCSVFile implements UseCaseInterface<void> {
constructor(
private csvFileReader: CSVFileReaderInterface,
private deleteAccount: DeleteAccount,
private domainEventPublisher: DomainEventPublisherInterface,
private domainEventFactory: DomainEventFactoryInterface,
private userRepository: UserRepositoryInterface,
private logger: Logger,
) {}
@@ -33,12 +37,20 @@ export class DeleteAccountsFromCSVFile implements UseCaseInterface<void> {
}
for (const email of emails) {
const deleteAccountOrError = await this.deleteAccount.execute({
username: email,
})
const usernameOrError = Username.create(email)
if (usernameOrError.isFailed()) {
return Result.fail(usernameOrError.getError())
}
const username = usernameOrError.getValue()
if (deleteAccountOrError.isFailed()) {
return Result.fail(deleteAccountOrError.getError())
const users = await this.userRepository.findAllByUsernameOrEmail(username)
for (const user of users) {
await this.domainEventPublisher.publish(
this.domainEventFactory.createAccountDeletionVerificationRequestedEvent({
userUuid: user.uuid,
email: user.email,
}),
)
}
}

View File

@@ -8,6 +8,7 @@ export interface UserRepositoryInterface {
streamTeam(memberEmail?: Email): Promise<ReadStream>
findOneByUuid(uuid: Uuid): Promise<User | null>
findOneByUsernameOrEmail(usernameOrEmail: Email | Username): Promise<User | null>
findAllByUsernameOrEmail(usernameOrEmail: Email | Username): Promise<User[]>
findAllCreatedBetween(dto: { start: Date; end: Date; offset: number; limit: number }): Promise<User[]>
countAllCreatedBetween(start: Date, end: Date): Promise<number>
save(user: User): Promise<User>

View File

@@ -69,7 +69,13 @@ export class TypeORMUserRepository implements UserRepositoryInterface {
return this.ormRepository
.createQueryBuilder('user')
.where('user.email = :email', { email: usernameOrEmail.value })
.cache(`user_email_${usernameOrEmail.value}`, 60000)
.getOne()
}
async findAllByUsernameOrEmail(usernameOrEmail: Email | Username): Promise<User[]> {
return this.ormRepository
.createQueryBuilder('user')
.where('user.email = :email', { email: usernameOrEmail.value })
.getMany()
}
}

View File

@@ -19,62 +19,75 @@ export class SessionsServer implements ISessionsServer {
call: grpc.ServerUnaryCall<AuthorizationHeader, SessionValidationResponse>,
callback: grpc.sendUnaryData<SessionValidationResponse>,
): Promise<void> {
this.logger.debug('[SessionsServer] Validating session via gRPC')
try {
this.logger.debug('[SessionsServer] Validating session via gRPC')
const authenticateRequestResponse = await this.authenticateRequest.execute({
authorizationHeader: call.request.getBearerToken(),
})
const authenticateRequestResponse = await this.authenticateRequest.execute({
authorizationHeader: call.request.getBearerToken(),
})
if (!authenticateRequestResponse.success) {
const metadata = new grpc.Metadata()
metadata.set('x-auth-error-message', authenticateRequestResponse.errorMessage as string)
metadata.set('x-auth-error-tag', authenticateRequestResponse.errorTag as string)
metadata.set('x-auth-error-response-code', authenticateRequestResponse.responseCode.toString())
return callback(
if (!authenticateRequestResponse.success) {
const metadata = new grpc.Metadata()
metadata.set('x-auth-error-message', authenticateRequestResponse.errorMessage as string)
metadata.set('x-auth-error-tag', authenticateRequestResponse.errorTag as string)
metadata.set('x-auth-error-response-code', authenticateRequestResponse.responseCode.toString())
return callback(
{
code: Status.PERMISSION_DENIED,
message: authenticateRequestResponse.errorMessage,
name: authenticateRequestResponse.errorTag,
metadata,
},
null,
)
}
const user = authenticateRequestResponse.user as User
const sharedVaultOwnerMetadata = call.metadata.get('x-shared-vault-owner-context')
let sharedVaultOwnerContext = undefined
if (sharedVaultOwnerMetadata.length > 0 && sharedVaultOwnerMetadata[0].length > 0) {
sharedVaultOwnerContext = sharedVaultOwnerMetadata[0].toString()
}
const resultOrError = await this.createCrossServiceToken.execute({
user,
session: authenticateRequestResponse.session,
sharedVaultOwnerContext,
})
if (resultOrError.isFailed()) {
const metadata = new grpc.Metadata()
metadata.set('x-auth-error-message', resultOrError.getError())
metadata.set('x-auth-error-response-code', '400')
return callback(
{
code: Status.INVALID_ARGUMENT,
message: resultOrError.getError(),
name: 'INVALID_ARGUMENT',
metadata,
},
null,
)
}
const response = new SessionValidationResponse()
response.setCrossServiceToken(resultOrError.getValue())
this.logger.debug('[SessionsServer] Session validated via gRPC')
callback(null, response)
} catch (error) {
this.logger.error(`[SessionsServer] Error validating session via gRPC: ${(error as Error).message}`)
callback(
{
code: Status.PERMISSION_DENIED,
message: authenticateRequestResponse.errorMessage,
name: authenticateRequestResponse.errorTag,
metadata,
code: Status.UNKNOWN,
message: 'An error occurred while validating session',
name: 'UNKNOWN',
},
null,
)
}
const user = authenticateRequestResponse.user as User
const sharedVaultOwnerMetadata = call.metadata.get('x-shared-vault-owner-context')
let sharedVaultOwnerContext = undefined
if (sharedVaultOwnerMetadata.length > 0 && sharedVaultOwnerMetadata[0].length > 0) {
sharedVaultOwnerContext = sharedVaultOwnerMetadata[0].toString()
}
const resultOrError = await this.createCrossServiceToken.execute({
user,
session: authenticateRequestResponse.session,
sharedVaultOwnerContext,
})
if (resultOrError.isFailed()) {
const metadata = new grpc.Metadata()
metadata.set('x-auth-error-message', resultOrError.getError())
metadata.set('x-auth-error-response-code', '400')
return callback(
{
code: Status.INVALID_ARGUMENT,
message: resultOrError.getError(),
name: 'INVALID_ARGUMENT',
metadata,
},
null,
)
}
const response = new SessionValidationResponse()
response.setCrossServiceToken(resultOrError.getValue())
this.logger.debug('[SessionsServer] Session validated via gRPC')
callback(null, response)
}
}

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.52.1](https://github.com/standardnotes/server/compare/@standardnotes/common@1.52.0...@standardnotes/common@1.52.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.52.0](https://github.com/standardnotes/server/compare/@standardnotes/common@1.51.0...@standardnotes/common@1.52.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
# [1.51.0](https://github.com/standardnotes/server/compare/@standardnotes/common@1.50.4...@standardnotes/common@1.51.0) (2023-09-26)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/common",
"version": "1.51.0",
"version": "1.52.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -13,7 +13,13 @@
"dist/src/**/*.d.ts"
],
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/common"
},
"license": "AGPL-3.0-or-later",
"scripts": {

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.41.1](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.41.0...@standardnotes/domain-core@1.41.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.41.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.40.0...@standardnotes/domain-core@1.41.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
# [1.40.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.39.0...@standardnotes/domain-core@1.40.0) (2023-10-26)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-core",
"version": "1.40.0",
"version": "1.41.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -12,7 +12,13 @@
"dist/src/**/*.d.ts"
],
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/domain-core"
},
"author": "Standard Notes",
"license": "AGPL-3.0-or-later",

View File

@@ -3,6 +3,26 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.1](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.22.0...@standardnotes/domain-events-infra@1.22.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.22.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.21.4...@standardnotes/domain-events-infra@1.22.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
## [1.21.4](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.21.3...@standardnotes/domain-events-infra@1.21.4) (2023-11-23)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.21.3](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.21.2...@standardnotes/domain-events-infra@1.21.3) (2023-11-22)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.21.2](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.21.1...@standardnotes/domain-events-infra@1.21.2) (2023-11-13)
**Note:** Version bump only for package @standardnotes/domain-events-infra

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events-infra",
"version": "1.21.2",
"version": "1.22.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -12,7 +12,13 @@
"dist/src/**/*.d.ts"
],
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/domain-events-infra"
},
"author": "Standard Notes",
"license": "AGPL-3.0-or-later",

View File

@@ -3,6 +3,30 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.137.1](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.137.0...@standardnotes/domain-events@2.137.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [2.137.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.136.0...@standardnotes/domain-events@2.137.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
# [2.136.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.135.0...@standardnotes/domain-events@2.136.0) (2023-11-23)
### Features
* **domain-events:** add email campaign send out requested event ([45bd009](https://github.com/standardnotes/server/commit/45bd00919c0062ac4bddd3f858f3ab89166f4e69))
# [2.135.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.134.2...@standardnotes/domain-events@2.135.0) (2023-11-22)
### Features
* add verifiying if user has no items before mass deleting spam accounts ([#936](https://github.com/standardnotes/server/issues/936)) ([c11abe1](https://github.com/standardnotes/server/commit/c11abe1bd36de7c0fb9850c20a8157c066fa9379))
## [2.134.2](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.134.1...@standardnotes/domain-events@2.134.2) (2023-11-13)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events",
"version": "2.134.2",
"version": "2.137.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -12,7 +12,13 @@
"dist/src/**/*.d.ts"
],
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/domain-events"
},
"author": "Standard Notes",
"license": "AGPL-3.0-or-later",

View File

@@ -0,0 +1,7 @@
import { DomainEventInterface } from './DomainEventInterface'
import { AccountDeletionVerificationPassedEventPayload } from './AccountDeletionVerificationPassedEventPayload'
export interface AccountDeletionVerificationPassedEvent extends DomainEventInterface {
type: 'ACCOUNT_DELETION_VERIFICATION_PASSED'
payload: AccountDeletionVerificationPassedEventPayload
}

View File

@@ -0,0 +1,4 @@
export interface AccountDeletionVerificationPassedEventPayload {
userUuid: string
email: string
}

View File

@@ -0,0 +1,7 @@
import { DomainEventInterface } from './DomainEventInterface'
import { AccountDeletionVerificationRequestedEventPayload } from './AccountDeletionVerificationRequestedEventPayload'
export interface AccountDeletionVerificationRequestedEvent extends DomainEventInterface {
type: 'ACCOUNT_DELETION_VERIFICATION_REQUESTED'
payload: AccountDeletionVerificationRequestedEventPayload
}

View File

@@ -0,0 +1,4 @@
export interface AccountDeletionVerificationRequestedEventPayload {
userUuid: string
email: string
}

View File

@@ -0,0 +1,7 @@
import { DomainEventInterface } from './DomainEventInterface'
import { EmailCampaignSendOutRequestedEventPayload } from './EmailCampaignSendOutRequestedEventPayload'
export interface EmailCampaignSendOutRequestedEvent extends DomainEventInterface {
type: 'EMAIL_CAMPAIGN_SEND_OUT_REQUESTED'
payload: EmailCampaignSendOutRequestedEventPayload
}

View File

@@ -0,0 +1,5 @@
export interface EmailCampaignSendOutRequestedEventPayload {
limit: number
page: number
campaignFileName: string
}

View File

@@ -1,5 +1,9 @@
export * from './Event/AccountDeletionRequestedEvent'
export * from './Event/AccountDeletionRequestedEventPayload'
export * from './Event/AccountDeletionVerificationPassedEvent'
export * from './Event/AccountDeletionVerificationPassedEventPayload'
export * from './Event/AccountDeletionVerificationRequestedEvent'
export * from './Event/AccountDeletionVerificationRequestedEventPayload'
export * from './Event/DiscountApplyRequestedEvent'
export * from './Event/DiscountApplyRequestedEventPayload'
export * from './Event/DiscountWithdrawRequestedEvent'
@@ -12,6 +16,8 @@ export * from './Event/EmailBackupRequestedEvent'
export * from './Event/EmailBackupRequestedEventPayload'
export * from './Event/EmailBouncedEvent'
export * from './Event/EmailBouncedEventPayload'
export * from './Event/EmailCampaignSendOutRequestedEvent'
export * from './Event/EmailCampaignSendOutRequestedEventPayload'
export * from './Event/EmailRequestedEvent'
export * from './Event/EmailRequestedEventPayload'
export * from './Event/EmailSubscriptionUnsubscribedEvent'

View File

@@ -3,6 +3,26 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.36.1](https://github.com/standardnotes/server/compare/@standardnotes/files-server@1.36.0...@standardnotes/files-server@1.36.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.36.0](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.35.2...@standardnotes/files-server@1.36.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/files/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
## [1.35.2](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.35.1...@standardnotes/files-server@1.35.2) (2023-11-23)
**Note:** Version bump only for package @standardnotes/files-server
## [1.35.1](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.35.0...@standardnotes/files-server@1.35.1) (2023-11-22)
**Note:** Version bump only for package @standardnotes/files-server
# [1.35.0](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.34.2...@standardnotes/files-server@1.35.0) (2023-11-16)
### Features

View File

@@ -1,19 +1,24 @@
{
"name": "@standardnotes/files-server",
"version": "1.35.0",
"version": "1.36.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
"description": "Standard Notes Files Server",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
"repository": "git@github.com:standardnotes/files.git",
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/files"
},
"authors": [
"Karol Sójko <karol@standardnotes.com>"
],
"license": "AGPL-3.0-or-later",
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"scripts": {
"clean": "rm -fr dist",

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.3.1](https://github.com/standardnotes/server/compare/@standardnotes/grpc@1.3.0...@standardnotes/grpc@1.3.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.3.0](https://github.com/standardnotes/server/compare/@standardnotes/grpc@1.2.0...@standardnotes/grpc@1.3.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
# [1.2.0](https://github.com/standardnotes/server/compare/@standardnotes/grpc@1.1.0...@standardnotes/grpc@1.2.0) (2023-11-20)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/grpc",
"version": "1.2.0",
"version": "1.3.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -13,7 +13,13 @@
"lib/**/*.d.ts"
],
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/grpc"
},
"license": "AGPL-3.0-or-later",
"scripts": {

View File

@@ -3,6 +3,38 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.1](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.0...@standardnotes/home-server@1.22.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.22.0](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.21.11...@standardnotes/home-server@1.22.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
## [1.21.11](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.21.10...@standardnotes/home-server@1.21.11) (2023-11-23)
**Note:** Version bump only for package @standardnotes/home-server
## [1.21.10](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.21.9...@standardnotes/home-server@1.21.10) (2023-11-22)
**Note:** Version bump only for package @standardnotes/home-server
## [1.21.9](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.21.8...@standardnotes/home-server@1.21.9) (2023-11-22)
**Note:** Version bump only for package @standardnotes/home-server
## [1.21.8](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.21.7...@standardnotes/home-server@1.21.8) (2023-11-21)
**Note:** Version bump only for package @standardnotes/home-server
## [1.21.7](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.21.6...@standardnotes/home-server@1.21.7) (2023-11-21)
**Note:** Version bump only for package @standardnotes/home-server
## [1.21.6](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.21.5...@standardnotes/home-server@1.21.6) (2023-11-20)
**Note:** Version bump only for package @standardnotes/home-server

View File

@@ -1,16 +1,21 @@
{
"name": "@standardnotes/home-server",
"version": "1.21.6",
"version": "1.22.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
"description": "Standard Notes Home Server",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
"repository": "git@github.com:standardnotes/server.git",
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/home-server"
},
"author": "Karol Sójko <karol@standardnotes.com>",
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"license": "AGPL-3.0-or-later",
"scripts": {

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.8.1](https://github.com/standardnotes/server/compare/@standardnotes/predicates@1.8.0...@standardnotes/predicates@1.8.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.8.0](https://github.com/standardnotes/server/compare/@standardnotes/predicates@1.7.0...@standardnotes/predicates@1.8.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
# [1.7.0](https://github.com/standardnotes/server/compare/@standardnotes/predicates@1.6.11...@standardnotes/predicates@1.7.0) (2023-09-26)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/predicates",
"version": "1.7.0",
"version": "1.8.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -13,7 +13,13 @@
"dist/src/**/*.d.ts"
],
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/predicates"
},
"license": "AGPL-3.0-or-later",
"scripts": {

View File

@@ -3,6 +3,26 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.51.1](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.51.0...@standardnotes/revisions-server@1.51.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.51.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.50.2...@standardnotes/revisions-server@1.51.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
## [1.50.2](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.50.1...@standardnotes/revisions-server@1.50.2) (2023-11-23)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.50.1](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.50.0...@standardnotes/revisions-server@1.50.1) (2023-11-22)
**Note:** Version bump only for package @standardnotes/revisions-server
# [1.50.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.49.2...@standardnotes/revisions-server@1.50.0) (2023-11-16)
### Features

View File

@@ -1,17 +1,22 @@
{
"name": "@standardnotes/revisions-server",
"version": "1.50.0",
"version": "1.51.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
"description": "Revisions Server",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
"repository": "git@github.com:standardnotes/server.git",
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/revisions"
},
"author": "Karol Sójko <karol@standardnotes.com>",
"license": "AGPL-3.0-or-later",
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"scripts": {
"clean": "rm -fr dist",

View File

@@ -3,6 +3,24 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.27.6](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.27.5...@standardnotes/scheduler-server@1.27.6) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
## [1.27.5](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.27.4...@standardnotes/scheduler-server@1.27.5) (2023-11-27)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.27.4](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.27.3...@standardnotes/scheduler-server@1.27.4) (2023-11-23)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.27.3](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.27.2...@standardnotes/scheduler-server@1.27.3) (2023-11-22)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.27.2](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.27.1...@standardnotes/scheduler-server@1.27.2) (2023-11-13)
**Note:** Version bump only for package @standardnotes/scheduler-server

View File

@@ -1,10 +1,15 @@
{
"name": "@standardnotes/scheduler-server",
"version": "1.27.2",
"version": "1.27.6",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
"private": true,
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/scheduler"
},
"description": "Scheduler Server",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",

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.17.1](https://github.com/standardnotes/server/compare/@standardnotes/security@1.17.0...@standardnotes/security@1.17.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.17.0](https://github.com/standardnotes/server/compare/@standardnotes/security@1.16.0...@standardnotes/security@1.17.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
# [1.16.0](https://github.com/standardnotes/server/compare/@standardnotes/security@1.15.0...@standardnotes/security@1.16.0) (2023-10-19)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/security",
"version": "1.16.0",
"version": "1.17.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -13,7 +13,13 @@
"dist/src/**/*.d.ts"
],
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/security"
},
"license": "AGPL-3.0-or-later",
"scripts": {

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.23.1](https://github.com/standardnotes/server/compare/@standardnotes/settings@1.23.0...@standardnotes/settings@1.23.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.23.0](https://github.com/standardnotes/server/compare/@standardnotes/settings@1.22.0...@standardnotes/settings@1.23.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
# [1.22.0](https://github.com/standardnotes/server/compare/@standardnotes/settings@1.21.47...@standardnotes/settings@1.22.0) (2023-10-26)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/settings",
"version": "1.22.0",
"version": "1.23.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -13,7 +13,13 @@
"dist/src/**/*.d.ts"
],
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/settings"
},
"license": "AGPL-3.0-or-later",
"scripts": {

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.16.1](https://github.com/standardnotes/server/compare/@standardnotes/sncrypto-node@1.16.0...@standardnotes/sncrypto-node@1.16.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.16.0](https://github.com/standardnotes/server/compare/@standardnotes/sncrypto-node@1.15.6...@standardnotes/sncrypto-node@1.16.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
## [1.15.6](https://github.com/standardnotes/server/compare/@standardnotes/sncrypto-node@1.15.5...@standardnotes/sncrypto-node@1.15.6) (2023-09-04)
**Note:** Version bump only for package @standardnotes/sncrypto-node

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/sncrypto-node",
"version": "1.15.6",
"version": "1.16.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -14,7 +14,13 @@
],
"license": "AGPL-3.0-or-later",
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/sncrypto-node"
},
"scripts": {
"clean": "rm -fr dist",

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.126.1](https://github.com/standardnotes/server/compare/@standardnotes/syncing-server@1.126.0...@standardnotes/syncing-server@1.126.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.126.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.125.2...@standardnotes/syncing-server@1.126.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/syncing-server-js/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
## [1.125.2](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.125.1...@standardnotes/syncing-server@1.125.2) (2023-11-23)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.125.1](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.125.0...@standardnotes/syncing-server@1.125.1) (2023-11-22)
### Bug Fixes
* error handling on gRPC ([#937](https://github.com/standardnotes/syncing-server-js/issues/937)) ([8f23c8a](https://github.com/standardnotes/syncing-server-js/commit/8f23c8ab3f03e9c23adfb31a33c5805492bc2f5b))
# [1.125.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.124.3...@standardnotes/syncing-server@1.125.0) (2023-11-22)
### Features
* add verifiying if user has no items before mass deleting spam accounts ([#936](https://github.com/standardnotes/syncing-server-js/issues/936)) ([c11abe1](https://github.com/standardnotes/syncing-server-js/commit/c11abe1bd36de7c0fb9850c20a8157c066fa9379))
## [1.124.3](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.124.2...@standardnotes/syncing-server@1.124.3) (2023-11-21)
### Bug Fixes
* **syncing-server:** front load themes and user prefs as high priority load items ([#935](https://github.com/standardnotes/syncing-server-js/issues/935)) ([2200dca](https://github.com/standardnotes/syncing-server-js/commit/2200dca69dc809f45463e3338ad7a6fdc66f07d9))
## [1.124.2](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.124.1...@standardnotes/syncing-server@1.124.2) (2023-11-20)
### Bug Fixes

View File

@@ -1,17 +1,22 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.124.2",
"version": "1.126.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
"description": "Syncing Server",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",
"repository": "git@github.com:standardnotes/syncing-server-js.git",
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/syncing-server"
},
"author": "Karol Sójko <karol@standardnotes.com>",
"license": "AGPL-3.0-or-later",
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"scripts": {
"clean": "rm -fr dist",

View File

@@ -160,6 +160,7 @@ import { DumpItem } from '../Domain/UseCase/Syncing/DumpItem/DumpItem'
import { SyncResponse20200115 } from '../Domain/Item/SyncResponse/SyncResponse20200115'
import { SyncResponse } from '@standardnotes/grpc'
import { SyncResponseGRPCMapper } from '../Mapping/gRPC/SyncResponseGRPCMapper'
import { AccountDeletionVerificationRequestedEventHandler } from '../Domain/Handler/AccountDeletionVerificationRequestedEventHandler'
export class ContainerConfigLoader {
private readonly DEFAULT_CONTENT_SIZE_TRANSFER_LIMIT = 10_000_000
@@ -907,6 +908,18 @@ export class ContainerConfigLoader {
container.get<Logger>(TYPES.Sync_Logger),
),
)
container
.bind<AccountDeletionVerificationRequestedEventHandler>(
TYPES.Sync_AccountDeletionVerificationRequestedEventHandler,
)
.toConstantValue(
new AccountDeletionVerificationRequestedEventHandler(
container.get<ItemRepositoryInterface>(TYPES.Sync_SQLItemRepository),
container.get<DomainEventPublisherInterface>(TYPES.Sync_DomainEventPublisher),
container.get<DomainEventFactoryInterface>(TYPES.Sync_DomainEventFactory),
container.get<Logger>(TYPES.Sync_Logger),
),
)
container
.bind<ItemRevisionCreationRequestedEventHandler>(TYPES.Sync_ItemRevisionCreationRequestedEventHandler)
.toConstantValue(
@@ -957,6 +970,10 @@ export class ContainerConfigLoader {
const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([
['DUPLICATE_ITEM_SYNCED', container.get(TYPES.Sync_DuplicateItemSyncedEventHandler)],
['ACCOUNT_DELETION_REQUESTED', container.get(TYPES.Sync_AccountDeletionRequestedEventHandler)],
[
'ACCOUNT_DELETION_VERIFICATION_REQUESTED',
container.get(TYPES.Sync_AccountDeletionVerificationRequestedEventHandler),
],
['ITEM_REVISION_CREATION_REQUESTED', container.get(TYPES.Sync_ItemRevisionCreationRequestedEventHandler)],
[
'SHARED_VAULT_FILE_UPLOADED',

View File

@@ -85,6 +85,9 @@ const TYPES = {
Sync_DumpItem: Symbol.for('Sync_DumpItem'),
// Handlers
Sync_AccountDeletionRequestedEventHandler: Symbol.for('Sync_AccountDeletionRequestedEventHandler'),
Sync_AccountDeletionVerificationRequestedEventHandler: Symbol.for(
'Sync_AccountDeletionVerificationRequestedEventHandler',
),
Sync_DuplicateItemSyncedEventHandler: Symbol.for('Sync_DuplicateItemSyncedEventHandler'),
Sync_EmailBackupRequestedEventHandler: Symbol.for('Sync_EmailBackupRequestedEventHandler'),
Sync_ItemRevisionCreationRequestedEventHandler: Symbol.for('Sync_ItemRevisionCreationRequestedEventHandler'),

View File

@@ -1,5 +1,6 @@
/* istanbul ignore file */
import {
AccountDeletionVerificationPassedEvent,
DomainEventService,
DuplicateItemSyncedEvent,
EmailRequestedEvent,
@@ -22,6 +23,24 @@ import { DomainEventFactoryInterface } from './DomainEventFactoryInterface'
export class DomainEventFactory implements DomainEventFactoryInterface {
constructor(private timer: TimerInterface) {}
createAccountDeletionVerificationPassedEvent(dto: {
userUuid: string
email: string
}): AccountDeletionVerificationPassedEvent {
return {
type: 'ACCOUNT_DELETION_VERIFICATION_PASSED',
createdAt: this.timer.getUTCDate(),
meta: {
correlation: {
userIdentifier: dto.userUuid,
userIdentifierType: 'uuid',
},
origin: DomainEventService.SyncingServer,
},
payload: dto,
}
}
createUserDesignatedAsSurvivorInSharedVaultEvent(dto: {
sharedVaultUuid: string
userUuid: string

View File

@@ -1,4 +1,5 @@
import {
AccountDeletionVerificationPassedEvent,
DuplicateItemSyncedEvent,
EmailRequestedEvent,
ItemDumpedEvent,
@@ -93,4 +94,8 @@ export interface DomainEventFactoryInterface {
userUuid: string
timestamp: number
}): UserDesignatedAsSurvivorInSharedVaultEvent
createAccountDeletionVerificationPassedEvent(dto: {
userUuid: string
email: string
}): AccountDeletionVerificationPassedEvent
}

View File

@@ -0,0 +1,48 @@
import {
AccountDeletionVerificationRequestedEvent,
DomainEventHandlerInterface,
DomainEventPublisherInterface,
} from '@standardnotes/domain-events'
import { Uuid } from '@standardnotes/domain-core'
import { Logger } from 'winston'
import { ItemRepositoryInterface } from '../Item/ItemRepositoryInterface'
import { DomainEventFactoryInterface } from '../Event/DomainEventFactoryInterface'
export class AccountDeletionVerificationRequestedEventHandler implements DomainEventHandlerInterface {
constructor(
private itemRepository: ItemRepositoryInterface,
private domainEventPublisher: DomainEventPublisherInterface,
private domainEventFactory: DomainEventFactoryInterface,
private logger: Logger,
) {}
async handle(event: AccountDeletionVerificationRequestedEvent): Promise<void> {
const userUuidOrError = Uuid.create(event.payload.userUuid)
if (userUuidOrError.isFailed()) {
this.logger.error(`AccountDeletionVerificationRequestedEventHandler failed: ${userUuidOrError.getError()}`)
return
}
const userUuid = userUuidOrError.getValue()
const itemsCount = await this.itemRepository.countAll({
userUuid: userUuid.value,
})
if (itemsCount !== 0) {
this.logger.warn(
`AccountDeletionVerificationRequestedEventHandler: User ${userUuid.value} has ${itemsCount} items and cannot be deleted.`,
)
return
}
await this.domainEventPublisher.publish(
this.domainEventFactory.createAccountDeletionVerificationPassedEvent({
userUuid: userUuid.value,
email: event.payload.email,
}),
)
}
}

View File

@@ -59,7 +59,7 @@ export class SyncItems implements UseCaseInterface<SyncItemsResponse> {
)
const isSharedVaultExclusiveSync = dto.sharedVaultUuids && dto.sharedVaultUuids.length > 0
if (this.isFirstSync(dto) && !isSharedVaultExclusiveSync) {
retrievedItems = await this.frontLoadKeysItemsToTop(dto.userUuid, retrievedItems)
retrievedItems = await this.frontLoadHighLoadingPriorityItemsToTop(dto.userUuid, retrievedItems)
}
const sharedVaultsOrError = await this.getSharedVaultsUseCase.execute({
@@ -139,19 +139,22 @@ export class SyncItems implements UseCaseInterface<SyncItemsResponse> {
return retrievedItems.filter((item: Item) => syncConflictIds.indexOf(item.id.toString()) === -1)
}
private async frontLoadKeysItemsToTop(userUuid: string, retrievedItems: Array<Item>): Promise<Array<Item>> {
const itemsKeys = await this.itemRepository.findAll({
private async frontLoadHighLoadingPriorityItemsToTop(
userUuid: string,
retrievedItems: Array<Item>,
): Promise<Array<Item>> {
const highPriorityItems = await this.itemRepository.findAll({
userUuid,
contentType: ContentType.TYPES.ItemsKey,
contentType: [ContentType.TYPES.ItemsKey, ContentType.TYPES.UserPrefs, ContentType.TYPES.Theme],
sortBy: 'updated_at_timestamp',
sortOrder: 'ASC',
})
const retrievedItemsIds: Array<string> = retrievedItems.map((item: Item) => item.id.toString())
itemsKeys.forEach((itemKey: Item) => {
if (retrievedItemsIds.indexOf(itemKey.id.toString()) === -1) {
retrievedItems.unshift(itemKey)
highPriorityItems.forEach((highPriorityItem: Item) => {
if (retrievedItemsIds.indexOf(highPriorityItem.id.toString()) === -1) {
retrievedItems.unshift(highPriorityItem)
}
})

View File

@@ -22,38 +22,82 @@ export class SyncingServer implements ISyncingServer {
call: grpc.ServerUnaryCall<SyncRequest, SyncResponse>,
callback: grpc.sendUnaryData<SyncResponse>,
): Promise<void> {
this.logger.debug('[SyncingServer] Syncing items via gRPC')
try {
this.logger.debug('[SyncingServer] Syncing items via gRPC')
const itemHashesRPC = call.request.getItemsList()
const itemHashes: ItemHash[] = []
for (const itemHash of itemHashesRPC) {
const itemHashOrError = ItemHash.create({
uuid: itemHash.getUuid(),
content: itemHash.hasContent() ? itemHash.getContent() : undefined,
content_type: itemHash.hasContentType() ? (itemHash.getContentType() as string) : null,
deleted: itemHash.hasDeleted() ? itemHash.getDeleted() : undefined,
duplicate_of: itemHash.hasDuplicateOf() ? itemHash.getDuplicateOf() : undefined,
auth_hash: itemHash.hasAuthHash() ? itemHash.getAuthHash() : undefined,
enc_item_key: itemHash.hasEncItemKey() ? itemHash.getEncItemKey() : undefined,
items_key_id: itemHash.hasItemsKeyId() ? itemHash.getItemsKeyId() : undefined,
created_at: itemHash.hasCreatedAt() ? itemHash.getCreatedAt() : undefined,
created_at_timestamp: itemHash.hasCreatedAtTimestamp() ? itemHash.getCreatedAtTimestamp() : undefined,
updated_at: itemHash.hasUpdatedAt() ? itemHash.getUpdatedAt() : undefined,
updated_at_timestamp: itemHash.hasUpdatedAtTimestamp() ? itemHash.getUpdatedAtTimestamp() : undefined,
user_uuid: call.metadata.get('userUuid').pop() as string,
key_system_identifier: itemHash.hasKeySystemIdentifier() ? (itemHash.getKeySystemIdentifier() as string) : null,
shared_vault_uuid: itemHash.hasSharedVaultUuid() ? (itemHash.getSharedVaultUuid() as string) : null,
const itemHashesRPC = call.request.getItemsList()
const itemHashes: ItemHash[] = []
for (const itemHash of itemHashesRPC) {
const itemHashOrError = ItemHash.create({
uuid: itemHash.getUuid(),
content: itemHash.hasContent() ? itemHash.getContent() : undefined,
content_type: itemHash.hasContentType() ? (itemHash.getContentType() as string) : null,
deleted: itemHash.hasDeleted() ? itemHash.getDeleted() : undefined,
duplicate_of: itemHash.hasDuplicateOf() ? itemHash.getDuplicateOf() : undefined,
auth_hash: itemHash.hasAuthHash() ? itemHash.getAuthHash() : undefined,
enc_item_key: itemHash.hasEncItemKey() ? itemHash.getEncItemKey() : undefined,
items_key_id: itemHash.hasItemsKeyId() ? itemHash.getItemsKeyId() : undefined,
created_at: itemHash.hasCreatedAt() ? itemHash.getCreatedAt() : undefined,
created_at_timestamp: itemHash.hasCreatedAtTimestamp() ? itemHash.getCreatedAtTimestamp() : undefined,
updated_at: itemHash.hasUpdatedAt() ? itemHash.getUpdatedAt() : undefined,
updated_at_timestamp: itemHash.hasUpdatedAtTimestamp() ? itemHash.getUpdatedAtTimestamp() : undefined,
user_uuid: call.metadata.get('userUuid').pop() as string,
key_system_identifier: itemHash.hasKeySystemIdentifier()
? (itemHash.getKeySystemIdentifier() as string)
: null,
shared_vault_uuid: itemHash.hasSharedVaultUuid() ? (itemHash.getSharedVaultUuid() as string) : null,
})
if (itemHashOrError.isFailed()) {
const metadata = new grpc.Metadata()
metadata.set('x-sync-error-message', itemHashOrError.getError())
metadata.set('x-sync-error-response-code', '400')
return callback(
{
code: Status.INVALID_ARGUMENT,
message: itemHashOrError.getError(),
name: 'INVALID_ARGUMENT',
metadata,
},
null,
)
}
itemHashes.push(itemHashOrError.getValue())
}
let sharedVaultUuids: string[] | undefined = undefined
const sharedVaultUuidsList = call.request.getSharedVaultUuidsList()
if (sharedVaultUuidsList.length > 0) {
sharedVaultUuids = sharedVaultUuidsList
}
const apiVersion = call.request.hasApiVersion() ? (call.request.getApiVersion() as string) : ApiVersion.v20161215
const syncResult = await this.syncItemsUseCase.execute({
userUuid: call.metadata.get('x-user-uuid').pop() as string,
itemHashes,
computeIntegrityHash: call.request.hasComputeIntegrity() ? call.request.getComputeIntegrity() === true : false,
syncToken: call.request.hasSyncToken() ? call.request.getSyncToken() : undefined,
cursorToken: call.request.getCursorToken() ? call.request.getCursorToken() : undefined,
limit: call.request.hasLimit() ? call.request.getLimit() : undefined,
contentType: call.request.hasContentType() ? call.request.getContentType() : undefined,
apiVersion,
snjsVersion: call.metadata.get('x-snjs-version').pop() as string,
readOnlyAccess: call.metadata.get('x-read-only-access').pop() === 'true',
sessionUuid: call.metadata.get('x-session-uuid').pop() as string,
sharedVaultUuids,
})
if (itemHashOrError.isFailed()) {
if (syncResult.isFailed()) {
const metadata = new grpc.Metadata()
metadata.set('x-sync-error-message', itemHashOrError.getError())
metadata.set('x-sync-error-message', syncResult.getError())
metadata.set('x-sync-error-response-code', '400')
return callback(
{
code: Status.INVALID_ARGUMENT,
message: itemHashOrError.getError(),
message: syncResult.getError(),
name: 'INVALID_ARGUMENT',
metadata,
},
@@ -61,53 +105,24 @@ export class SyncingServer implements ISyncingServer {
)
}
itemHashes.push(itemHashOrError.getValue())
}
const syncResponse = await this.syncResponseFactoryResolver
.resolveSyncResponseFactoryVersion(apiVersion)
.createResponse(syncResult.getValue())
let sharedVaultUuids: string[] | undefined = undefined
const sharedVaultUuidsList = call.request.getSharedVaultUuidsList()
if (sharedVaultUuidsList.length > 0) {
sharedVaultUuids = sharedVaultUuidsList
}
const projection = this.mapper.toProjection(syncResponse as SyncResponse20200115)
const apiVersion = call.request.hasApiVersion() ? (call.request.getApiVersion() as string) : ApiVersion.v20161215
const syncResult = await this.syncItemsUseCase.execute({
userUuid: call.metadata.get('x-user-uuid').pop() as string,
itemHashes,
computeIntegrityHash: call.request.hasComputeIntegrity() ? call.request.getComputeIntegrity() === true : false,
syncToken: call.request.hasSyncToken() ? call.request.getSyncToken() : undefined,
cursorToken: call.request.getCursorToken() ? call.request.getCursorToken() : undefined,
limit: call.request.hasLimit() ? call.request.getLimit() : undefined,
contentType: call.request.hasContentType() ? call.request.getContentType() : undefined,
apiVersion,
snjsVersion: call.metadata.get('x-snjs-version').pop() as string,
readOnlyAccess: call.metadata.get('x-read-only-access').pop() === 'true',
sessionUuid: call.metadata.get('x-session-uuid').pop() as string,
sharedVaultUuids,
})
if (syncResult.isFailed()) {
const metadata = new grpc.Metadata()
metadata.set('x-sync-error-message', syncResult.getError())
metadata.set('x-sync-error-response-code', '400')
callback(null, projection)
} catch (error) {
this.logger.error(`[SyncingServer] Error syncing items via gRPC: ${(error as Error).message}`)
return callback(
{
code: Status.INVALID_ARGUMENT,
message: syncResult.getError(),
name: 'INVALID_ARGUMENT',
metadata,
code: Status.UNKNOWN,
message: 'An error occurred while syncing items',
name: 'UNKNOWN',
},
null,
)
}
const syncResponse = await this.syncResponseFactoryResolver
.resolveSyncResponseFactoryVersion(apiVersion)
.createResponse(syncResult.getValue())
const projection = this.mapper.toProjection(syncResponse as SyncResponse20200115)
callback(null, projection)
}
}

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.18.1](https://github.com/standardnotes/server/compare/@standardnotes/time@1.18.0...@standardnotes/time@1.18.1) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
# [1.18.0](https://github.com/standardnotes/server/compare/@standardnotes/time@1.17.0...@standardnotes/time@1.18.0) (2023-11-27)
### Features
* add npm provenance to published packages ([e836abd](https://github.com/standardnotes/server/commit/e836abdef73d246940d8fffd9e65e17c64cd35c8))
# [1.17.0](https://github.com/standardnotes/server/compare/@standardnotes/time@1.16.0...@standardnotes/time@1.17.0) (2023-09-28)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/time",
"version": "1.17.0",
"version": "1.18.1",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -12,7 +12,13 @@
"dist/src/**/*.d.ts"
],
"publishConfig": {
"access": "public"
"access": "public",
"provenance": true
},
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/time"
},
"author": "Standard Notes",
"license": "AGPL-3.0-or-later",

View File

@@ -3,6 +3,24 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.20.4](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.20.3...@standardnotes/websockets-server@1.20.4) (2023-11-27)
### Bug Fixes
* repository config in package.json files ([ed1bf37](https://github.com/standardnotes/server/commit/ed1bf37287af23a25b8388ada95f0acdec8f71ea))
## [1.20.3](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.20.2...@standardnotes/websockets-server@1.20.3) (2023-11-27)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.20.2](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.20.1...@standardnotes/websockets-server@1.20.2) (2023-11-23)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.20.1](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.20.0...@standardnotes/websockets-server@1.20.1) (2023-11-22)
**Note:** Version bump only for package @standardnotes/websockets-server
# [1.20.0](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.19.2...@standardnotes/websockets-server@1.20.0) (2023-11-16)
### Features

View File

@@ -1,10 +1,15 @@
{
"name": "@standardnotes/websockets-server",
"version": "1.20.0",
"version": "1.20.4",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
"private": true,
"repository": {
"type": "git",
"url": "git@github.com:standardnotes/server.git",
"directory": "packages/websockets"
},
"description": "Websockets Server",
"main": "dist/src/index.js",
"typings": "dist/src/index.d.ts",