refactor: remove Uuid from @standardnotes/common in favour of @standardnotes/domain-core definition
This commit is contained in:
parent
0e3cbfc40b
commit
aaf42e4693
121 changed files with 196 additions and 439 deletions
9
.pnp.cjs
generated
9
.pnp.cjs
generated
|
@ -2862,7 +2862,6 @@ const RAW_RUNTIME_STATE =
|
|||
"packageLocation": "./packages/domain-events/",\
|
||||
"packageDependencies": [\
|
||||
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
||||
["@standardnotes/common", "workspace:packages/common"],\
|
||||
["@standardnotes/features", "npm:1.53.1"],\
|
||||
["@standardnotes/predicates", "workspace:packages/predicates"],\
|
||||
["@standardnotes/security", "workspace:packages/security"],\
|
||||
|
@ -2870,7 +2869,6 @@ const RAW_RUNTIME_STATE =
|
|||
["@typescript-eslint/eslint-plugin", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:5.30.5"],\
|
||||
["eslint-plugin-prettier", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:4.2.1"],\
|
||||
["jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.1.2"],\
|
||||
["reflect-metadata", "npm:0.1.13"],\
|
||||
["ts-jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.0.3"],\
|
||||
["typescript", "patch:typescript@npm%3A4.8.4#optional!builtin<compat/typescript>::version=4.8.4&hash=701156"]\
|
||||
],\
|
||||
|
@ -2988,8 +2986,8 @@ const RAW_RUNTIME_STATE =
|
|||
"packageDependencies": [\
|
||||
["@standardnotes/files-server", "workspace:packages/files"],\
|
||||
["@sentry/node", "npm:7.28.1"],\
|
||||
["@standardnotes/common", "workspace:packages/common"],\
|
||||
["@standardnotes/config", "npm:2.4.3"],\
|
||||
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
||||
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
||||
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
||||
["@standardnotes/security", "workspace:packages/security"],\
|
||||
|
@ -3081,12 +3079,10 @@ const RAW_RUNTIME_STATE =
|
|||
"packageLocation": "./packages/predicates/",\
|
||||
"packageDependencies": [\
|
||||
["@standardnotes/predicates", "workspace:packages/predicates"],\
|
||||
["@standardnotes/common", "workspace:packages/common"],\
|
||||
["@types/jest", "npm:29.1.1"],\
|
||||
["@typescript-eslint/eslint-plugin", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:5.30.5"],\
|
||||
["eslint-plugin-prettier", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:4.2.1"],\
|
||||
["jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.1.2"],\
|
||||
["reflect-metadata", "npm:0.1.13"],\
|
||||
["ts-jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.0.3"],\
|
||||
["typescript", "patch:typescript@npm%3A4.8.4#optional!builtin<compat/typescript>::version=4.8.4&hash=701156"]\
|
||||
],\
|
||||
|
@ -3169,7 +3165,6 @@ const RAW_RUNTIME_STATE =
|
|||
["@standardnotes/scheduler-server", "workspace:packages/scheduler"],\
|
||||
["@newrelic/winston-enricher", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.0.0"],\
|
||||
["@sentry/node", "npm:7.28.1"],\
|
||||
["@standardnotes/common", "workspace:packages/common"],\
|
||||
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
||||
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
||||
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
||||
|
@ -3205,7 +3200,6 @@ const RAW_RUNTIME_STATE =
|
|||
"packageLocation": "./packages/security/",\
|
||||
"packageDependencies": [\
|
||||
["@standardnotes/security", "workspace:packages/security"],\
|
||||
["@standardnotes/common", "workspace:packages/common"],\
|
||||
["@types/jest", "npm:29.1.1"],\
|
||||
["@types/jsonwebtoken", "npm:9.0.1"],\
|
||||
["@typescript-eslint/eslint-plugin", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:5.30.5"],\
|
||||
|
@ -3398,7 +3392,6 @@ const RAW_RUNTIME_STATE =
|
|||
["@newrelic/winston-enricher", "virtual:c66bf20e88479ada0172094776519a9f51acc4731d22079b60a295bcec7ea42d5545cbce58a77a50d932bf953298799135e99707486e343da6d99ba1d167bdbd#npm:4.0.0"],\
|
||||
["@sentry/node", "npm:7.28.1"],\
|
||||
["@standardnotes/api", "npm:1.19.0"],\
|
||||
["@standardnotes/common", "workspace:packages/common"],\
|
||||
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
|
||||
["@standardnotes/domain-events", "workspace:packages/domain-events"],\
|
||||
["@standardnotes/domain-events-infra", "workspace:packages/domain-events-infra"],\
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { AnalyticsEntity } from './AnalyticsEntity'
|
||||
|
||||
export interface AnalyticsEntityRepositoryInterface {
|
||||
save(analyticsEntity: AnalyticsEntity): Promise<AnalyticsEntity>
|
||||
remove(analyticsEntity: AnalyticsEntity): Promise<void>
|
||||
findOneByUserUuid(userUuid: Uuid): Promise<AnalyticsEntity | null>
|
||||
findOneByUserUuid(userUuid: string): Promise<AnalyticsEntity | null>
|
||||
findOneByUserEmail(email: string): Promise<AnalyticsEntity | null>
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Either, Uuid } from '@standardnotes/common'
|
||||
import { Either } from '@standardnotes/common'
|
||||
|
||||
export type GetUserAnalyticsIdDTO = Either<
|
||||
{
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
},
|
||||
{
|
||||
userEmail: string
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { inject, injectable } from 'inversify'
|
||||
import { Repository } from 'typeorm'
|
||||
|
||||
|
@ -20,7 +19,7 @@ export class MySQLAnalyticsEntityRepository implements AnalyticsEntityRepository
|
|||
.getOne()
|
||||
}
|
||||
|
||||
async findOneByUserUuid(userUuid: Uuid): Promise<AnalyticsEntity | null> {
|
||||
async findOneByUserUuid(userUuid: string): Promise<AnalyticsEntity | null> {
|
||||
return this.ormRepository
|
||||
.createQueryBuilder('analytics_entity')
|
||||
.where('analytics_entity.user_uuid = :userUuid', { userUuid })
|
||||
|
|
|
@ -121,14 +121,7 @@ import { RedisOfflineSubscriptionTokenRepository } from '../Infra/Redis/RedisOff
|
|||
import { CreateOfflineSubscriptionToken } from '../Domain/UseCase/CreateOfflineSubscriptionToken/CreateOfflineSubscriptionToken'
|
||||
import { AuthenticateOfflineSubscriptionToken } from '../Domain/UseCase/AuthenticateOfflineSubscriptionToken/AuthenticateOfflineSubscriptionToken'
|
||||
import { SubscriptionCancelledEventHandler } from '../Domain/Handler/SubscriptionCancelledEventHandler'
|
||||
import {
|
||||
ContentDecoder,
|
||||
ContentDecoderInterface,
|
||||
ProtocolVersion,
|
||||
Uuid,
|
||||
UuidValidator,
|
||||
ValidatorInterface,
|
||||
} from '@standardnotes/common'
|
||||
import { ContentDecoder, ContentDecoderInterface, ProtocolVersion } from '@standardnotes/common'
|
||||
import { GetUserOfflineSubscription } from '../Domain/UseCase/GetUserOfflineSubscription/GetUserOfflineSubscription'
|
||||
import { ApiGatewayOfflineAuthMiddleware } from '../Controller/ApiGatewayOfflineAuthMiddleware'
|
||||
import { UserEmailChangedEventHandler } from '../Domain/Handler/UserEmailChangedEventHandler'
|
||||
|
@ -532,7 +525,6 @@ export class ContainerConfigLoader {
|
|||
.bind<SelectorInterface<boolean>>(TYPES.BooleanSelector)
|
||||
.toConstantValue(new DeterministicSelector<boolean>())
|
||||
container.bind<UserSubscriptionServiceInterface>(TYPES.UserSubscriptionService).to(UserSubscriptionService)
|
||||
container.bind<ValidatorInterface<Uuid>>(TYPES.UuidValidator).toConstantValue(new UuidValidator())
|
||||
|
||||
if (env.get('SNS_TOPIC_ARN', true)) {
|
||||
container
|
||||
|
|
|
@ -207,7 +207,6 @@ const TYPES = {
|
|||
ProtocolVersionSelector: Symbol.for('ProtocolVersionSelector'),
|
||||
BooleanSelector: Symbol.for('BooleanSelector'),
|
||||
UserSubscriptionService: Symbol.for('UserSubscriptionService'),
|
||||
UuidValidator: Symbol.for('UuidValidator'),
|
||||
}
|
||||
|
||||
export default TYPES
|
||||
|
|
|
@ -4,27 +4,22 @@ import { Request, Response } from 'express'
|
|||
import { results } from 'inversify-express-utils'
|
||||
import { ValetTokenController } from './ValetTokenController'
|
||||
import { CreateValetToken } from '../Domain/UseCase/CreateValetToken/CreateValetToken'
|
||||
import { Uuid, ValidatorInterface } from '@standardnotes/common'
|
||||
|
||||
describe('ValetTokenController', () => {
|
||||
let createValetToken: CreateValetToken
|
||||
let uuidValidator: ValidatorInterface<Uuid>
|
||||
let request: Request
|
||||
let response: Response
|
||||
|
||||
const createController = () => new ValetTokenController(createValetToken, uuidValidator)
|
||||
const createController = () => new ValetTokenController(createValetToken)
|
||||
|
||||
beforeEach(() => {
|
||||
createValetToken = {} as jest.Mocked<CreateValetToken>
|
||||
createValetToken.execute = jest.fn().mockReturnValue({ success: true, valetToken: 'foobar' })
|
||||
|
||||
uuidValidator = {} as jest.Mocked<ValidatorInterface<Uuid>>
|
||||
uuidValidator.validate = jest.fn().mockReturnValue(true)
|
||||
|
||||
request = {
|
||||
body: {
|
||||
operation: 'write',
|
||||
resources: ['1-2-3/2-3-4'],
|
||||
resources: [{ remoteIdentifier: '00000000-0000-0000-0000-000000000000' }],
|
||||
},
|
||||
} as jest.Mocked<Request>
|
||||
|
||||
|
@ -42,13 +37,13 @@ describe('ValetTokenController', () => {
|
|||
expect(createValetToken.execute).toHaveBeenCalledWith({
|
||||
operation: 'write',
|
||||
userUuid: '1-2-3',
|
||||
resources: ['1-2-3/2-3-4'],
|
||||
resources: [{ remoteIdentifier: '00000000-0000-0000-0000-000000000000' }],
|
||||
})
|
||||
expect(await result.content.readAsStringAsync()).toEqual('{"success":true,"valetToken":"foobar"}')
|
||||
})
|
||||
|
||||
it('should not create a valet token if the remote resource identifier is not a valid uuid', async () => {
|
||||
uuidValidator.validate = jest.fn().mockReturnValue(false)
|
||||
request.body.resources = ['00000000-0000-0000-0000-000000000000', 'invalid-uuid']
|
||||
|
||||
const httpResponse = <results.JsonResult>await createController().create(request, response)
|
||||
const result = await httpResponse.executeAsync()
|
||||
|
@ -68,7 +63,7 @@ describe('ValetTokenController', () => {
|
|||
expect(createValetToken.execute).toHaveBeenCalledWith({
|
||||
operation: 'read',
|
||||
userUuid: '1-2-3',
|
||||
resources: ['1-2-3/2-3-4'],
|
||||
resources: [{ remoteIdentifier: '00000000-0000-0000-0000-000000000000' }],
|
||||
})
|
||||
expect(await result.content.readAsStringAsync()).toEqual('{"success":true,"valetToken":"foobar"}')
|
||||
})
|
||||
|
@ -106,7 +101,7 @@ describe('ValetTokenController', () => {
|
|||
expect(createValetToken.execute).toHaveBeenCalledWith({
|
||||
operation: 'write',
|
||||
userUuid: '1-2-3',
|
||||
resources: ['1-2-3/2-3-4'],
|
||||
resources: [{ remoteIdentifier: '00000000-0000-0000-0000-000000000000' }],
|
||||
})
|
||||
|
||||
expect(await result.content.readAsStringAsync()).toEqual('{"success":false}')
|
||||
|
|
|
@ -11,15 +11,13 @@ import { CreateValetTokenPayload } from '@standardnotes/responses'
|
|||
|
||||
import TYPES from '../Bootstrap/Types'
|
||||
import { CreateValetToken } from '../Domain/UseCase/CreateValetToken/CreateValetToken'
|
||||
import { ErrorTag, Uuid, ValidatorInterface } from '@standardnotes/common'
|
||||
import { ErrorTag } from '@standardnotes/common'
|
||||
import { ValetTokenOperation } from '@standardnotes/security'
|
||||
import { Uuid } from '@standardnotes/domain-core'
|
||||
|
||||
@controller('/valet-tokens', TYPES.ApiGatewayAuthMiddleware)
|
||||
export class ValetTokenController extends BaseHttpController {
|
||||
constructor(
|
||||
@inject(TYPES.CreateValetToken) private createValetKey: CreateValetToken,
|
||||
@inject(TYPES.UuidValidator) private uuidValitor: ValidatorInterface<Uuid>,
|
||||
) {
|
||||
constructor(@inject(TYPES.CreateValetToken) private createValetKey: CreateValetToken) {
|
||||
super()
|
||||
}
|
||||
|
||||
|
@ -40,7 +38,8 @@ export class ValetTokenController extends BaseHttpController {
|
|||
}
|
||||
|
||||
for (const resource of payload.resources) {
|
||||
if (!this.uuidValitor.validate(resource.remoteIdentifier)) {
|
||||
const resourceUuidOrError = Uuid.create(resource.remoteIdentifier)
|
||||
if (resourceUuidOrError.isFailed()) {
|
||||
return this.json(
|
||||
{
|
||||
error: {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { ProtocolVersion, Uuid } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
|
||||
export interface AuthResponse {
|
||||
user: {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
email: string
|
||||
protocolVersion: ProtocolVersion
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { SessionTokenData, TokenEncoderInterface } from '@standardnotes/security'
|
||||
import { ProtocolVersion, Uuid } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
import * as crypto from 'crypto'
|
||||
|
||||
import { inject, injectable } from 'inversify'
|
||||
|
@ -40,7 +40,7 @@ export class AuthResponseFactory20161215 implements AuthResponseFactoryInterface
|
|||
|
||||
return {
|
||||
user: this.userProjector.projectSimple(dto.user) as {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
email: string
|
||||
protocolVersion: ProtocolVersion
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@ import {
|
|||
SessionTokenData,
|
||||
TokenEncoderInterface,
|
||||
} from '@standardnotes/security'
|
||||
import { ProtocolVersion, Uuid } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
import { SessionBody } from '@standardnotes/responses'
|
||||
import { inject, injectable } from 'inversify'
|
||||
import { Logger } from 'winston'
|
||||
|
@ -49,7 +49,7 @@ export class AuthResponseFactory20200115 extends AuthResponseFactory20190520 {
|
|||
session: sessionPayload,
|
||||
key_params: this.keyParamsFactory.create(dto.user, true),
|
||||
user: this.userProjector.projectSimple(dto.user) as {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
email: string
|
||||
protocolVersion: ProtocolVersion
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* istanbul ignore file */
|
||||
|
||||
import { JSONString, ProtocolVersion, Uuid } from '@standardnotes/common'
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
import {
|
||||
AccountDeletionRequestedEvent,
|
||||
UserEmailChangedEvent,
|
||||
|
@ -105,7 +105,7 @@ export class DomainEventFactory implements DomainEventFactoryInterface {
|
|||
}
|
||||
}
|
||||
|
||||
createWebSocketMessageRequestedEvent(dto: { userUuid: Uuid; message: JSONString }): WebSocketMessageRequestedEvent {
|
||||
createWebSocketMessageRequestedEvent(dto: { userUuid: string; message: string }): WebSocketMessageRequestedEvent {
|
||||
return {
|
||||
type: 'WEB_SOCKET_MESSAGE_REQUESTED',
|
||||
createdAt: this.timer.getUTCDate(),
|
||||
|
@ -142,7 +142,7 @@ export class DomainEventFactory implements DomainEventFactoryInterface {
|
|||
}
|
||||
|
||||
createPredicateVerifiedEvent(dto: {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
predicate: Predicate
|
||||
predicateVerificationResult: PredicateVerificationResult
|
||||
}): PredicateVerifiedEvent {
|
||||
|
@ -164,10 +164,10 @@ export class DomainEventFactory implements DomainEventFactoryInterface {
|
|||
createSharedSubscriptionInvitationCanceledEvent(dto: {
|
||||
inviterEmail: string
|
||||
inviterSubscriptionId: number
|
||||
inviterSubscriptionUuid: Uuid
|
||||
inviterSubscriptionUuid: string
|
||||
inviteeIdentifier: string
|
||||
inviteeIdentifierType: InviteeIdentifierType
|
||||
sharedSubscriptionInvitationUuid: Uuid
|
||||
sharedSubscriptionInvitationUuid: string
|
||||
}): SharedSubscriptionInvitationCanceledEvent {
|
||||
return {
|
||||
type: 'SHARED_SUBSCRIPTION_INVITATION_CANCELED',
|
||||
|
@ -291,9 +291,9 @@ export class DomainEventFactory implements DomainEventFactoryInterface {
|
|||
}
|
||||
|
||||
createAccountDeletionRequestedEvent(dto: {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
userCreatedAtTimestamp: number
|
||||
regularSubscriptionUuid: Uuid | undefined
|
||||
regularSubscriptionUuid: string | undefined
|
||||
}): AccountDeletionRequestedEvent {
|
||||
return {
|
||||
type: 'ACCOUNT_DELETION_REQUESTED',
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Uuid, ProtocolVersion, JSONString } from '@standardnotes/common'
|
||||
import { ProtocolVersion, JSONString } from '@standardnotes/common'
|
||||
import { Predicate, PredicateVerificationResult } from '@standardnotes/predicates'
|
||||
import {
|
||||
AccountDeletionRequestedEvent,
|
||||
|
@ -23,7 +23,7 @@ import { InviteeIdentifierType } from '../SharedSubscription/InviteeIdentifierTy
|
|||
|
||||
export interface DomainEventFactoryInterface {
|
||||
createUserContentSizeRecalculationRequestedEvent(userUuid: string): UserContentSizeRecalculationRequestedEvent
|
||||
createWebSocketMessageRequestedEvent(dto: { userUuid: Uuid; message: JSONString }): WebSocketMessageRequestedEvent
|
||||
createWebSocketMessageRequestedEvent(dto: { userUuid: string; message: JSONString }): WebSocketMessageRequestedEvent
|
||||
createEmailRequestedEvent(dto: {
|
||||
userEmail: string
|
||||
messageIdentifier: string
|
||||
|
@ -50,14 +50,14 @@ export interface DomainEventFactoryInterface {
|
|||
userHasEmailsMuted: boolean,
|
||||
): CloudBackupRequestedEvent
|
||||
createAccountDeletionRequestedEvent(dto: {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
userCreatedAtTimestamp: number
|
||||
regularSubscriptionUuid: Uuid | undefined
|
||||
regularSubscriptionUuid: string | undefined
|
||||
}): AccountDeletionRequestedEvent
|
||||
createUserRolesChangedEvent(userUuid: string, email: string, currentRoles: string[]): UserRolesChangedEvent
|
||||
createUserEmailChangedEvent(userUuid: string, fromEmail: string, toEmail: string): UserEmailChangedEvent
|
||||
createUserDisabledSessionUserAgentLoggingEvent(dto: {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
email: string
|
||||
}): UserDisabledSessionUserAgentLoggingEvent
|
||||
createSharedSubscriptionInvitationCreatedEvent(dto: {
|
||||
|
@ -70,13 +70,13 @@ export interface DomainEventFactoryInterface {
|
|||
createSharedSubscriptionInvitationCanceledEvent(dto: {
|
||||
inviterEmail: string
|
||||
inviterSubscriptionId: number
|
||||
inviterSubscriptionUuid: Uuid
|
||||
inviterSubscriptionUuid: string
|
||||
inviteeIdentifier: string
|
||||
inviteeIdentifierType: InviteeIdentifierType
|
||||
sharedSubscriptionInvitationUuid: Uuid
|
||||
sharedSubscriptionInvitationUuid: string
|
||||
}): SharedSubscriptionInvitationCanceledEvent
|
||||
createPredicateVerifiedEvent(dto: {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
predicate: Predicate
|
||||
predicateVerificationResult: PredicateVerificationResult
|
||||
}): PredicateVerifiedEvent
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
import { DomainEventHandlerInterface, SubscriptionExpiredEvent } from '@standardnotes/domain-events'
|
||||
import { inject, injectable } from 'inversify'
|
||||
import { Logger } from 'winston'
|
||||
|
@ -38,10 +37,7 @@ export class SubscriptionExpiredEventHandler implements DomainEventHandlerInterf
|
|||
await this.removeRoleFromSubscriptionUsers(event.payload.subscriptionId, event.payload.subscriptionName)
|
||||
}
|
||||
|
||||
private async removeRoleFromSubscriptionUsers(
|
||||
subscriptionId: number,
|
||||
subscriptionName: SubscriptionName,
|
||||
): Promise<void> {
|
||||
private async removeRoleFromSubscriptionUsers(subscriptionId: number, subscriptionName: string): Promise<void> {
|
||||
const userSubscriptions = await this.userSubscriptionRepository.findBySubscriptionId(subscriptionId)
|
||||
for (const userSubscription of userSubscriptions) {
|
||||
await this.roleService.removeUserRole(await userSubscription.user, subscriptionName)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
import { DomainEventHandlerInterface, SubscriptionPurchasedEvent } from '@standardnotes/domain-events'
|
||||
import { inject, injectable } from 'inversify'
|
||||
import { Logger } from 'winston'
|
||||
|
@ -65,7 +64,7 @@ export class SubscriptionPurchasedEventHandler implements DomainEventHandlerInte
|
|||
)
|
||||
}
|
||||
|
||||
private async addUserRole(user: User, subscriptionName: SubscriptionName): Promise<void> {
|
||||
private async addUserRole(user: User, subscriptionName: string): Promise<void> {
|
||||
await this.roleService.addUserRole(user, subscriptionName)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
import { DomainEventHandlerInterface, SubscriptionReassignedEvent } from '@standardnotes/domain-events'
|
||||
import { inject, injectable } from 'inversify'
|
||||
import { Logger } from 'winston'
|
||||
|
@ -62,7 +61,7 @@ export class SubscriptionReassignedEventHandler implements DomainEventHandlerInt
|
|||
)
|
||||
}
|
||||
|
||||
private async addUserRole(user: User, subscriptionName: SubscriptionName): Promise<void> {
|
||||
private async addUserRole(user: User, subscriptionName: string): Promise<void> {
|
||||
await this.roleService.addUserRole(user, subscriptionName)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
import { DomainEventHandlerInterface, SubscriptionRefundedEvent } from '@standardnotes/domain-events'
|
||||
import { inject, injectable } from 'inversify'
|
||||
import { Logger } from 'winston'
|
||||
|
@ -38,10 +37,7 @@ export class SubscriptionRefundedEventHandler implements DomainEventHandlerInter
|
|||
await this.removeRoleFromSubscriptionUsers(event.payload.subscriptionId, event.payload.subscriptionName)
|
||||
}
|
||||
|
||||
private async removeRoleFromSubscriptionUsers(
|
||||
subscriptionId: number,
|
||||
subscriptionName: SubscriptionName,
|
||||
): Promise<void> {
|
||||
private async removeRoleFromSubscriptionUsers(subscriptionId: number, subscriptionName: string): Promise<void> {
|
||||
const userSubscriptions = await this.userSubscriptionRepository.findBySubscriptionId(subscriptionId)
|
||||
for (const userSubscription of userSubscriptions) {
|
||||
await this.roleService.removeUserRole(await userSubscription.user, subscriptionName)
|
||||
|
|
|
@ -4,7 +4,6 @@ import { inject, injectable } from 'inversify'
|
|||
import TYPES from '../../Bootstrap/Types'
|
||||
import { UserSubscriptionRepositoryInterface } from '../Subscription/UserSubscriptionRepositoryInterface'
|
||||
import { OfflineUserSubscriptionRepositoryInterface } from '../Subscription/OfflineUserSubscriptionRepositoryInterface'
|
||||
import { SubscriptionName } from '@standardnotes/common'
|
||||
import { RoleServiceInterface } from '../Role/RoleServiceInterface'
|
||||
import { UserRepositoryInterface } from '../User/UserRepositoryInterface'
|
||||
import { Logger } from 'winston'
|
||||
|
@ -61,7 +60,7 @@ export class SubscriptionRenewedEventHandler implements DomainEventHandlerInterf
|
|||
await this.addRoleToSubscriptionUsers(event.payload.subscriptionId, event.payload.subscriptionName)
|
||||
}
|
||||
|
||||
private async addRoleToSubscriptionUsers(subscriptionId: number, subscriptionName: SubscriptionName): Promise<void> {
|
||||
private async addRoleToSubscriptionUsers(subscriptionId: number, subscriptionName: string): Promise<void> {
|
||||
const userSubscriptions = await this.userSubscriptionRepository.findBySubscriptionId(subscriptionId)
|
||||
for (const userSubscription of userSubscriptions) {
|
||||
const user = await userSubscription.user
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
import { PermissionName } from '@standardnotes/features'
|
||||
import { OfflineUserSubscription } from '../Subscription/OfflineUserSubscription'
|
||||
import { User } from '../User/User'
|
||||
|
||||
export interface RoleServiceInterface {
|
||||
addUserRole(user: User, subscriptionName: SubscriptionName): Promise<void>
|
||||
addUserRole(user: User, subscriptionName: string): Promise<void>
|
||||
setOfflineUserRole(offlineUserSubscription: OfflineUserSubscription): Promise<void>
|
||||
removeUserRole(user: User, subscriptionName: SubscriptionName): Promise<void>
|
||||
removeUserRole(user: User, subscriptionName: string): Promise<void>
|
||||
userHasPermission(userUuid: string, permissionName: PermissionName): Promise<boolean>
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { RevokedSession } from './RevokedSession'
|
||||
|
||||
export interface RevokedSessionRepositoryInterface {
|
||||
|
@ -6,5 +5,5 @@ export interface RevokedSessionRepositoryInterface {
|
|||
findAllByUserUuid(userUuid: string): Promise<Array<RevokedSession>>
|
||||
save(revokedSession: RevokedSession): Promise<RevokedSession>
|
||||
remove(revokedSession: RevokedSession): Promise<RevokedSession>
|
||||
clearUserAgentByUserUuid(userUuid: Uuid): Promise<void>
|
||||
clearUserAgentByUserUuid(userUuid: string): Promise<void>
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { Session } from './Session'
|
||||
|
||||
export interface SessionRepositoryInterface {
|
||||
|
@ -12,5 +11,5 @@ export interface SessionRepositoryInterface {
|
|||
updatedTokenExpirationDates(uuid: string, accessExpiration: Date, refreshExpiration: Date): Promise<void>
|
||||
save(session: Session): Promise<Session>
|
||||
remove(session: Session): Promise<Session>
|
||||
clearUserAgentByUserUuid(userUuid: Uuid): Promise<void>
|
||||
clearUserAgentByUserUuid(userUuid: string): Promise<void>
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import { TimerInterface } from '@standardnotes/time'
|
|||
import { Logger } from 'winston'
|
||||
import { LogSessionUserAgentOption, SettingName } from '@standardnotes/settings'
|
||||
import { SessionBody } from '@standardnotes/responses'
|
||||
import { Uuid } from '@standardnotes/common'
|
||||
import { CryptoNode } from '@standardnotes/sncrypto-node'
|
||||
|
||||
import TYPES from '../../Bootstrap/Types'
|
||||
|
@ -226,7 +225,7 @@ export class SessionService implements SessionServiceInterface {
|
|||
return this.revokedSessionRepository.save(revokedSession)
|
||||
}
|
||||
|
||||
async deleteSessionByToken(token: string): Promise<Uuid | null> {
|
||||
async deleteSessionByToken(token: string): Promise<string | null> {
|
||||
const session = await this.getSessionFromToken(token)
|
||||
|
||||
if (session) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { SessionBody } from '@standardnotes/responses'
|
||||
import { User } from '../User/User'
|
||||
import { RevokedSession } from './RevokedSession'
|
||||
|
@ -21,7 +20,7 @@ export interface SessionServiceInterface {
|
|||
getSessionFromToken(token: string): Promise<Session | undefined>
|
||||
getRevokedSessionFromToken(token: string): Promise<RevokedSession | null>
|
||||
markRevokedSessionAsReceived(revokedSession: RevokedSession): Promise<RevokedSession>
|
||||
deleteSessionByToken(token: string): Promise<Uuid | null>
|
||||
deleteSessionByToken(token: string): Promise<string | null>
|
||||
isRefreshTokenValid(session: Session, token: string): boolean
|
||||
getDeviceInfo(session: Session): string
|
||||
getOperatingSystemInfoFromUserAgent(userAgent: string): string
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type DeleteSettingDto = {
|
||||
settingName: string
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { SettingName } from '@standardnotes/settings'
|
||||
|
||||
export type FindSettingDTO = {
|
||||
userUuid: string
|
||||
settingName: SettingName
|
||||
settingUuid?: Uuid
|
||||
settingUuid?: string
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { SubscriptionSettingName } from '@standardnotes/settings'
|
||||
|
||||
export type FindSubscriptionSettingDTO = {
|
||||
userUuid: Uuid
|
||||
userSubscriptionUuid: Uuid
|
||||
userUuid: string
|
||||
userSubscriptionUuid: string
|
||||
subscriptionSettingName: SubscriptionSettingName
|
||||
settingUuid?: Uuid
|
||||
settingUuid?: string
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { Setting } from './Setting'
|
||||
import { SubscriptionSetting } from './SubscriptionSetting'
|
||||
|
||||
export interface SettingDecrypterInterface {
|
||||
decryptSettingValue(setting: Setting | SubscriptionSetting, userUuid: Uuid): Promise<string | null>
|
||||
decryptSettingValue(setting: Setting | SubscriptionSetting, userUuid: string): Promise<string | null>
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { SubscriptionName, Uuid } from '@standardnotes/common'
|
||||
import { SubscriptionName } from '@standardnotes/common'
|
||||
import { SubscriptionSettingName } from '@standardnotes/settings'
|
||||
import { inject, injectable } from 'inversify'
|
||||
import { Logger } from 'winston'
|
||||
|
@ -34,7 +34,7 @@ export class SubscriptionSettingService implements SubscriptionSettingServiceInt
|
|||
async applyDefaultSubscriptionSettingsForSubscription(
|
||||
userSubscription: UserSubscription,
|
||||
subscriptionName: SubscriptionName,
|
||||
userUuid: Uuid,
|
||||
userUuid: string,
|
||||
): Promise<void> {
|
||||
const defaultSettingsWithValues =
|
||||
await this.subscriptionSettingAssociationService.getDefaultSettingsAndValuesForSubscriptionName(subscriptionName)
|
||||
|
@ -129,8 +129,8 @@ export class SubscriptionSettingService implements SubscriptionSettingServiceInt
|
|||
|
||||
private async findPreviousSubscriptionSetting(
|
||||
settingName: SubscriptionSettingName,
|
||||
currentUserSubscriptionUuid: Uuid,
|
||||
userUuid: Uuid,
|
||||
currentUserSubscriptionUuid: string,
|
||||
userUuid: string,
|
||||
): Promise<SubscriptionSetting | null> {
|
||||
const userSubscriptions = await this.userSubscriptionRepository.findByUserUuid(userUuid)
|
||||
const previousSubscriptions = userSubscriptions.filter(
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { SubscriptionName, Uuid } from '@standardnotes/common'
|
||||
import { UserSubscription } from '../Subscription/UserSubscription'
|
||||
|
||||
import { CreateOrReplaceSubscriptionSettingDTO } from './CreateOrReplaceSubscriptionSettingDTO'
|
||||
|
@ -9,8 +8,8 @@ import { SubscriptionSetting } from './SubscriptionSetting'
|
|||
export interface SubscriptionSettingServiceInterface {
|
||||
applyDefaultSubscriptionSettingsForSubscription(
|
||||
userSubscription: UserSubscription,
|
||||
subscriptionName: SubscriptionName,
|
||||
userUuid: Uuid,
|
||||
subscriptionName: string,
|
||||
userUuid: string,
|
||||
): Promise<void>
|
||||
createOrReplace(dto: CreateOrReplaceSubscriptionSettingDTO): Promise<CreateOrReplaceSubscriptionSettingResponse>
|
||||
findSubscriptionSettingWithDecryptedValue(dto: FindSubscriptionSettingDTO): Promise<SubscriptionSetting | null>
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { InvitationStatus } from './InvitationStatus'
|
||||
import { SharedSubscriptionInvitation } from './SharedSubscriptionInvitation'
|
||||
|
||||
export interface SharedSubscriptionInvitationRepositoryInterface {
|
||||
save(sharedSubscriptionInvitation: SharedSubscriptionInvitation): Promise<SharedSubscriptionInvitation>
|
||||
findOneByUuidAndStatus(uuid: Uuid, status: InvitationStatus): Promise<SharedSubscriptionInvitation | null>
|
||||
findOneByUuid(uuid: Uuid): Promise<SharedSubscriptionInvitation | null>
|
||||
findOneByUuidAndStatus(uuid: string, status: InvitationStatus): Promise<SharedSubscriptionInvitation | null>
|
||||
findOneByUuid(uuid: string): Promise<SharedSubscriptionInvitation | null>
|
||||
findByInviterEmail(inviterEmail: string): Promise<SharedSubscriptionInvitation[]>
|
||||
findOneByInviteeAndInviterEmail(
|
||||
inviteeEmail: string,
|
||||
inviterEmail: string,
|
||||
): Promise<SharedSubscriptionInvitation | null>
|
||||
countByInviterEmailAndStatus(inviterEmail: Uuid, statuses: InvitationStatus[]): Promise<number>
|
||||
countByInviterEmailAndStatus(inviterEmail: string, statuses: InvitationStatus[]): Promise<number>
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { SubscriptionToken } from './SubscriptionToken'
|
||||
|
||||
export interface SubscriptionTokenRepositoryInterface {
|
||||
save(subscriptionToken: SubscriptionToken): Promise<boolean>
|
||||
getUserUuidByToken(token: string): Promise<Uuid | undefined>
|
||||
getUserUuidByToken(token: string): Promise<string | undefined>
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { UserSubscription } from './UserSubscription'
|
||||
import { UserSubscriptionType } from './UserSubscriptionType'
|
||||
|
||||
export interface UserSubscriptionRepositoryInterface {
|
||||
findOneByUuid(uuid: Uuid): Promise<UserSubscription | null>
|
||||
countByUserUuid(userUuid: Uuid): Promise<number>
|
||||
findOneByUserUuid(userUuid: Uuid): Promise<UserSubscription | null>
|
||||
findByUserUuid(userUuid: Uuid): Promise<UserSubscription[]>
|
||||
findOneByUserUuidAndSubscriptionId(userUuid: Uuid, subscriptionId: number): Promise<UserSubscription | null>
|
||||
findOneByUuid(uuid: string): Promise<UserSubscription | null>
|
||||
countByUserUuid(userUuid: string): Promise<number>
|
||||
findOneByUserUuid(userUuid: string): Promise<UserSubscription | null>
|
||||
findByUserUuid(userUuid: string): Promise<UserSubscription[]>
|
||||
findOneByUserUuidAndSubscriptionId(userUuid: string, subscriptionId: number): Promise<UserSubscription | null>
|
||||
findBySubscriptionIdAndType(subscriptionId: number, type: UserSubscriptionType): Promise<UserSubscription[]>
|
||||
findBySubscriptionId(subscriptionId: number): Promise<UserSubscription[]>
|
||||
updateEndsAt(subscriptionId: number, endsAt: number, updatedAt: number): Promise<void>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { inject, injectable } from 'inversify'
|
||||
|
||||
import TYPES from '../../Bootstrap/Types'
|
||||
|
@ -21,7 +20,7 @@ export class UserSubscriptionService implements UserSubscriptionServiceInterface
|
|||
return this.findRegularSubscription(userSubscription)
|
||||
}
|
||||
|
||||
async findRegularSubscriptionForUuid(uuid: Uuid): Promise<FindRegularSubscriptionResponse> {
|
||||
async findRegularSubscriptionForUuid(uuid: string): Promise<FindRegularSubscriptionResponse> {
|
||||
const userSubscription = await this.userSubscriptionRepository.findOneByUuid(uuid)
|
||||
|
||||
return this.findRegularSubscription(userSubscription)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { FindRegularSubscriptionResponse } from './FindRegularSubscriptionResponse'
|
||||
|
||||
export interface UserSubscriptionServiceInterface {
|
||||
findRegularSubscriptionForUuid(uuid: Uuid): Promise<FindRegularSubscriptionResponse>
|
||||
findRegularSubscriptionForUserUuid(userUuid: Uuid): Promise<FindRegularSubscriptionResponse>
|
||||
findRegularSubscriptionForUuid(uuid: string): Promise<FindRegularSubscriptionResponse>
|
||||
findRegularSubscriptionForUserUuid(userUuid: string): Promise<FindRegularSubscriptionResponse>
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type CancelSharedSubscriptionInvitationDTO = {
|
||||
sharedSubscriptionInvitationUuid: Uuid
|
||||
sharedSubscriptionInvitationUuid: string
|
||||
inviterEmail: string
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Either, Uuid } from '@standardnotes/common'
|
||||
import { Either } from '@standardnotes/common'
|
||||
import { Session } from '../../Session/Session'
|
||||
import { User } from '../../User/User'
|
||||
|
||||
|
@ -8,6 +8,6 @@ export type CreateCrossServiceTokenDTO = Either<
|
|||
session?: Session
|
||||
},
|
||||
{
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
}
|
||||
>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type DeleteSettingDto = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
settingName: string
|
||||
uuid?: string
|
||||
timestamp?: number
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type DeleteSettingResponse =
|
||||
| {
|
||||
success: true
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
settingName: string
|
||||
}
|
||||
| {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type GetSettingDto = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
settingName: string
|
||||
allowSensitiveRetrieval?: boolean
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { SimpleSetting } from '../../Setting/SimpleSetting'
|
||||
|
||||
export type GetSettingResponse =
|
||||
| {
|
||||
success: true
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
setting: SimpleSetting
|
||||
}
|
||||
| {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type GetSettingsDto = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
settingName?: string
|
||||
allowSensitiveRetrieval?: boolean
|
||||
updatedAfter?: number
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { SimpleSetting } from '../../Setting/SimpleSetting'
|
||||
|
||||
export type GetSettingsResponse =
|
||||
| {
|
||||
success: true
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
settings: SimpleSetting[]
|
||||
}
|
||||
| {
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { SubscriptionSettingName } from '@standardnotes/settings'
|
||||
|
||||
export type GetSubscriptionSettingDTO = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
subscriptionSettingName: SubscriptionSettingName
|
||||
allowSensitiveRetrieval?: boolean
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type GetUserFeaturesDto =
|
||||
| {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
offline: false
|
||||
}
|
||||
| {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type GetUserSubscriptionDto = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type InviteToSharedSubscriptionDTO = {
|
||||
inviterEmail: string
|
||||
inviterUuid: Uuid
|
||||
inviterUuid: string
|
||||
inviterRoles: string[]
|
||||
inviteeIdentifier: string
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type InviteToSharedSubscriptionResult =
|
||||
| {
|
||||
success: true
|
||||
sharedSubscriptionInvitationUuid: Uuid
|
||||
sharedSubscriptionInvitationUuid: string
|
||||
}
|
||||
| {
|
||||
success: false
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { UserRequestType, Uuid } from '@standardnotes/common'
|
||||
import { UserRequestType } from '@standardnotes/common'
|
||||
|
||||
export type ProcessUserRequestDTO = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
userEmail: string
|
||||
requestType: UserRequestType
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { SettingProps } from '../../Setting/SettingProps'
|
||||
|
||||
export type UpdateSettingDto = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
props: SettingProps
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { PredicateName, PredicateVerificationResult } from '@standardnotes/predicates'
|
||||
import { EmailBackupFrequency, SettingName } from '@standardnotes/settings'
|
||||
import { inject, injectable } from 'inversify'
|
||||
|
@ -33,13 +32,13 @@ export class VerifyPredicate implements UseCaseInterface {
|
|||
}
|
||||
}
|
||||
|
||||
private async hasUserBoughtASubscription(userUuid: Uuid): Promise<boolean> {
|
||||
private async hasUserBoughtASubscription(userUuid: string): Promise<boolean> {
|
||||
const subscription = await this.userSubscriptionRepository.findOneByUserUuid(userUuid)
|
||||
|
||||
return subscription !== null
|
||||
}
|
||||
|
||||
private async hasUserEnabledEmailBackups(userUuid: Uuid): Promise<boolean> {
|
||||
private async hasUserEnabledEmailBackups(userUuid: string): Promise<boolean> {
|
||||
const setting = await this.settingRepository.findOneByNameAndUserUuid(SettingName.EmailBackupFrequency, userUuid)
|
||||
|
||||
if (setting === null || setting.value === EmailBackupFrequency.Disabled) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { Predicate } from '@standardnotes/predicates'
|
||||
|
||||
export type VerifyPredicateDTO = {
|
||||
predicate: Predicate
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { TimerInterface } from '@standardnotes/time'
|
||||
import { inject, injectable } from 'inversify'
|
||||
import { Repository } from 'typeorm'
|
||||
|
@ -34,7 +33,7 @@ export class MySQLUserSubscriptionRepository implements UserSubscriptionReposito
|
|||
.getMany()
|
||||
}
|
||||
|
||||
async countByUserUuid(userUuid: Uuid): Promise<number> {
|
||||
async countByUserUuid(userUuid: string): Promise<number> {
|
||||
return await this.ormRepository
|
||||
.createQueryBuilder()
|
||||
.where('user_uuid = :user_uuid', {
|
||||
|
@ -47,7 +46,7 @@ export class MySQLUserSubscriptionRepository implements UserSubscriptionReposito
|
|||
return this.ormRepository.save(subscription)
|
||||
}
|
||||
|
||||
async findOneByUserUuidAndSubscriptionId(userUuid: Uuid, subscriptionId: number): Promise<UserSubscription | null> {
|
||||
async findOneByUserUuidAndSubscriptionId(userUuid: string, subscriptionId: number): Promise<UserSubscription | null> {
|
||||
return await this.ormRepository
|
||||
.createQueryBuilder()
|
||||
.where('user_uuid = :userUuid AND subscription_id = :subscriptionId', {
|
||||
|
@ -78,7 +77,7 @@ export class MySQLUserSubscriptionRepository implements UserSubscriptionReposito
|
|||
.getMany()
|
||||
}
|
||||
|
||||
async findOneByUuid(uuid: Uuid): Promise<UserSubscription | null> {
|
||||
async findOneByUuid(uuid: string): Promise<UserSubscription | null> {
|
||||
return await this.ormRepository
|
||||
.createQueryBuilder()
|
||||
.where('uuid = :uuid', {
|
||||
|
@ -87,7 +86,7 @@ export class MySQLUserSubscriptionRepository implements UserSubscriptionReposito
|
|||
.getOne()
|
||||
}
|
||||
|
||||
async findOneByUserUuid(userUuid: Uuid): Promise<UserSubscription | null> {
|
||||
async findOneByUserUuid(userUuid: string): Promise<UserSubscription | null> {
|
||||
const subscriptions = await this.ormRepository
|
||||
.createQueryBuilder()
|
||||
.where('user_uuid = :user_uuid', {
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export type Uuid = string
|
|
@ -1,34 +0,0 @@
|
|||
import { UuidValidator } from './UuidValidator'
|
||||
|
||||
describe('UuidValidator', () => {
|
||||
const createValidator = () => new UuidValidator()
|
||||
|
||||
const validUuids = [
|
||||
'2221101c-1da9-4d2b-9b32-b8be2a8d1c82',
|
||||
'c08f2f29-a74b-42b4-aefd-98af9832391c',
|
||||
'b453fa64-1493-443b-b5bb-bca7b9c696c7',
|
||||
]
|
||||
|
||||
const invalidUuids = [
|
||||
123,
|
||||
'someone@127.0.0.1',
|
||||
'',
|
||||
null,
|
||||
'b453fa64-1493-443b-b5bb-ca7b9c696c7',
|
||||
'c08f*f29-a74b-42b4-aefd-98af9832391c',
|
||||
'c08f*f29-a74b-42b4-aefd-98af9832391c',
|
||||
'../../escaped.sh',
|
||||
]
|
||||
|
||||
it('should validate proper uuids', () => {
|
||||
for (const validUuid of validUuids) {
|
||||
expect(createValidator().validate(validUuid)).toBeTruthy()
|
||||
}
|
||||
})
|
||||
|
||||
it('should not validate invalid uuids', () => {
|
||||
for (const invalidUuid of invalidUuids) {
|
||||
expect(createValidator().validate(invalidUuid as string)).toBeFalsy()
|
||||
}
|
||||
})
|
||||
})
|
|
@ -1,10 +0,0 @@
|
|||
import { Uuid } from '../DataType/Uuid'
|
||||
import { ValidatorInterface } from './ValidatorInterface'
|
||||
|
||||
export class UuidValidator implements ValidatorInterface<Uuid> {
|
||||
private readonly UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i
|
||||
|
||||
validate(data: Uuid): boolean {
|
||||
return String(data).toLowerCase().match(this.UUID_REGEX) !== null
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
export interface ValidatorInterface<T> {
|
||||
validate(data: T): boolean
|
||||
}
|
|
@ -4,7 +4,6 @@ export * from './Content/ContentDecoderInterface'
|
|||
export * from './DataType/AnyRecord'
|
||||
export * from './DataType/JSONString'
|
||||
export * from './DataType/MicrosecondsTimestamp'
|
||||
export * from './DataType/Uuid'
|
||||
export * from './DataType/ApplicationIdentifier'
|
||||
export * from './Email/EmailMessageIdentifier'
|
||||
export * from './Error/ErrorTag'
|
||||
|
@ -22,8 +21,6 @@ export * from './Subscription/SubscriptionName'
|
|||
export * from './Type/Either'
|
||||
export * from './Type/Only'
|
||||
export * from './User/UserRequestType'
|
||||
export * from './Validator/UuidValidator'
|
||||
export * from './Validator/ValidatorInterface'
|
||||
export * from './Workspace/WorkspaceAccessLevel'
|
||||
export * from './Workspace/WorkspaceType'
|
||||
export * from './Workspace/WorkspaceUserStatus'
|
||||
|
|
|
@ -23,11 +23,9 @@
|
|||
"test": "jest spec --coverage --passWithNoTests"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "workspace:*",
|
||||
"@standardnotes/features": "^1.52.1",
|
||||
"@standardnotes/predicates": "workspace:*",
|
||||
"@standardnotes/security": "workspace:*",
|
||||
"reflect-metadata": "^0.1.13"
|
||||
"@standardnotes/security": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.1.1",
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export interface AccountDeletionRequestedEventPayload {
|
||||
userUuid: string
|
||||
userCreatedAtTimestamp: number
|
||||
regularSubscriptionUuid: Uuid | undefined
|
||||
regularSubscriptionUuid: string | undefined
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
|
||||
export interface ExtensionKeyGrantedEventPayload {
|
||||
userEmail: string
|
||||
extensionKey: string
|
||||
timestamp: number
|
||||
offline: boolean
|
||||
origin: 'create-user' | 'update-subscription'
|
||||
subscriptionName: SubscriptionName | null
|
||||
subscriptionName: string | null
|
||||
offlineFeaturesToken: string | null
|
||||
payAmount: number | null
|
||||
billingEveryNMonths: number | null
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export interface FileRemovedEventPayload {
|
||||
userUuid: Uuid
|
||||
regularSubscriptionUuid: Uuid
|
||||
userUuid: string
|
||||
regularSubscriptionUuid: string
|
||||
fileByteSize: number
|
||||
filePath: string
|
||||
fileName: string
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export interface SharedSubscriptionInvitationCanceledEventPayload {
|
||||
inviterEmail: string
|
||||
inviterSubscriptionId: number
|
||||
inviterSubscriptionUuid: Uuid
|
||||
inviterSubscriptionUuid: string
|
||||
inviteeIdentifier: string
|
||||
inviteeIdentifierType: 'email' | 'hash' | 'uuid'
|
||||
sharedSubscriptionInvitationUuid: string
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
|
||||
export interface SubscriptionCancelledEventPayload {
|
||||
userEmail: string
|
||||
subscriptionId: number
|
||||
subscriptionName: SubscriptionName
|
||||
subscriptionName: string
|
||||
subscriptionCreatedAt: number
|
||||
subscriptionUpdatedAt: number
|
||||
lastPayedAt: number
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
|
||||
export interface SubscriptionExpiredEventPayload {
|
||||
userEmail: string
|
||||
subscriptionId: number
|
||||
subscriptionName: SubscriptionName
|
||||
subscriptionName: string
|
||||
timestamp: number
|
||||
offline: boolean
|
||||
totalActiveSubscriptionsCount: number
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
|
||||
export interface SubscriptionPurchasedEventPayload {
|
||||
userEmail: string
|
||||
subscriptionId: number
|
||||
subscriptionName: SubscriptionName
|
||||
subscriptionName: string
|
||||
subscriptionExpiresAt: number
|
||||
timestamp: number
|
||||
offline: boolean
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
|
||||
export interface SubscriptionReactivatedEventPayload {
|
||||
userEmail: string
|
||||
previousSubscriptionId: number
|
||||
currentSubscriptionId: number
|
||||
subscriptionName: SubscriptionName
|
||||
subscriptionName: string
|
||||
subscriptionExpiresAt: number
|
||||
discountCode: string | null
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
|
||||
export interface SubscriptionReassignedEventPayload {
|
||||
userEmail: string
|
||||
extensionKey: string
|
||||
offline: boolean
|
||||
subscriptionId: number
|
||||
subscriptionName: SubscriptionName
|
||||
subscriptionName: string
|
||||
subscriptionExpiresAt: number
|
||||
timestamp: number
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
|
||||
export interface SubscriptionRefundedEventPayload {
|
||||
userEmail: string
|
||||
subscriptionId: number
|
||||
subscriptionName: SubscriptionName
|
||||
subscriptionName: string
|
||||
userExistingSubscriptionsCount: number
|
||||
totalActiveSubscriptionsCount: number
|
||||
timestamp: number
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
|
||||
export interface SubscriptionRenewedEventPayload {
|
||||
userEmail: string
|
||||
subscriptionId: number
|
||||
subscriptionName: SubscriptionName
|
||||
subscriptionName: string
|
||||
subscriptionExpiresAt: number
|
||||
timestamp: number
|
||||
offline: boolean
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
|
||||
export interface SubscriptionSyncRequestedEventPayload {
|
||||
userEmail: string
|
||||
subscriptionId: number
|
||||
subscriptionName: SubscriptionName
|
||||
subscriptionName: string
|
||||
subscriptionExpiresAt: number
|
||||
timestamp: number
|
||||
offline: boolean
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export interface UserContentSizeRecalculationRequestedEventPayload {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import { JSONString, Uuid } from '@standardnotes/common'
|
||||
|
||||
export interface WebSocketMessageRequestedEventPayload {
|
||||
userUuid: Uuid
|
||||
message: JSONString
|
||||
userUuid: string
|
||||
message: string
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@sentry/node": "^7.28.1",
|
||||
"@standardnotes/common": "workspace:*",
|
||||
"@standardnotes/domain-core": "workspace:^",
|
||||
"@standardnotes/domain-events": "workspace:*",
|
||||
"@standardnotes/domain-events-infra": "workspace:*",
|
||||
"@standardnotes/security": "workspace:*",
|
||||
|
|
|
@ -44,7 +44,6 @@ import {
|
|||
import { MarkFilesToBeRemoved } from '../Domain/UseCase/MarkFilesToBeRemoved/MarkFilesToBeRemoved'
|
||||
import { AccountDeletionRequestedEventHandler } from '../Domain/Handler/AccountDeletionRequestedEventHandler'
|
||||
import { SharedSubscriptionInvitationCanceledEventHandler } from '../Domain/Handler/SharedSubscriptionInvitationCanceledEventHandler'
|
||||
import { Uuid, UuidValidator, ValidatorInterface } from '@standardnotes/common'
|
||||
|
||||
export class ContainerConfigLoader {
|
||||
async load(): Promise<Container> {
|
||||
|
@ -108,7 +107,6 @@ export class ContainerConfigLoader {
|
|||
.toConstantValue(new FSFileUploader(container.get(TYPES.FILE_UPLOAD_PATH), container.get(TYPES.Logger)))
|
||||
container.bind<FileRemoverInterface>(TYPES.FileRemover).to(FSFileRemover)
|
||||
}
|
||||
container.bind<ValidatorInterface<Uuid>>(TYPES.UuidValidator).toConstantValue(new UuidValidator())
|
||||
|
||||
if (env.get('SNS_TOPIC_ARN', true)) {
|
||||
const snsConfig: AWS.SNS.Types.ClientConfiguration = {
|
||||
|
|
|
@ -23,7 +23,6 @@ const TYPES = {
|
|||
FileUploader: Symbol.for('FileUploader'),
|
||||
FileDownloader: Symbol.for('FileDownloader'),
|
||||
FileRemover: Symbol.for('FileRemover'),
|
||||
UuidValidator: Symbol.for('UuidValidator'),
|
||||
|
||||
// repositories
|
||||
UploadRepository: Symbol.for('UploadRepository'),
|
||||
|
|
|
@ -4,11 +4,9 @@ import { ValetTokenAuthMiddleware } from './ValetTokenAuthMiddleware'
|
|||
import { NextFunction, Request, Response } from 'express'
|
||||
import { Logger } from 'winston'
|
||||
import { TokenDecoderInterface, ValetTokenData } from '@standardnotes/security'
|
||||
import { Uuid, ValidatorInterface } from '@standardnotes/common'
|
||||
|
||||
describe('ValetTokenAuthMiddleware', () => {
|
||||
let tokenDecoder: TokenDecoderInterface<ValetTokenData>
|
||||
let uuidValidator: ValidatorInterface<Uuid>
|
||||
let request: Request
|
||||
let response: Response
|
||||
let next: NextFunction
|
||||
|
@ -17,7 +15,7 @@ describe('ValetTokenAuthMiddleware', () => {
|
|||
debug: jest.fn(),
|
||||
} as unknown as jest.Mocked<Logger>
|
||||
|
||||
const createMiddleware = () => new ValetTokenAuthMiddleware(tokenDecoder, uuidValidator, logger)
|
||||
const createMiddleware = () => new ValetTokenAuthMiddleware(tokenDecoder, logger)
|
||||
|
||||
beforeEach(() => {
|
||||
tokenDecoder = {} as jest.Mocked<TokenDecoderInterface<ValetTokenData>>
|
||||
|
@ -25,7 +23,7 @@ describe('ValetTokenAuthMiddleware', () => {
|
|||
userUuid: '1-2-3',
|
||||
permittedResources: [
|
||||
{
|
||||
remoteIdentifier: '1-2-3/2-3-4',
|
||||
remoteIdentifier: '00000000-0000-0000-0000-000000000000',
|
||||
unencryptedFileSize: 30,
|
||||
},
|
||||
],
|
||||
|
@ -34,9 +32,6 @@ describe('ValetTokenAuthMiddleware', () => {
|
|||
uploadBytesUsed: 80,
|
||||
})
|
||||
|
||||
uuidValidator = {} as jest.Mocked<ValidatorInterface<Uuid>>
|
||||
uuidValidator.validate = jest.fn().mockReturnValue(true)
|
||||
|
||||
request = {
|
||||
headers: {},
|
||||
query: {},
|
||||
|
@ -55,7 +50,7 @@ describe('ValetTokenAuthMiddleware', () => {
|
|||
userUuid: '1-2-3',
|
||||
permittedResources: [
|
||||
{
|
||||
remoteIdentifier: '1-2-3/2-3-4',
|
||||
remoteIdentifier: '00000000-0000-0000-0000-000000000000',
|
||||
unencryptedFileSize: 30,
|
||||
},
|
||||
],
|
||||
|
@ -73,7 +68,7 @@ describe('ValetTokenAuthMiddleware', () => {
|
|||
permittedOperation: 'write',
|
||||
permittedResources: [
|
||||
{
|
||||
remoteIdentifier: '1-2-3/2-3-4',
|
||||
remoteIdentifier: '00000000-0000-0000-0000-000000000000',
|
||||
unencryptedFileSize: 30,
|
||||
},
|
||||
],
|
||||
|
@ -90,7 +85,7 @@ describe('ValetTokenAuthMiddleware', () => {
|
|||
userUuid: '1-2-3',
|
||||
permittedResources: [
|
||||
{
|
||||
remoteIdentifier: '1-2-3/2-3-4',
|
||||
remoteIdentifier: '00000000-0000-0000-0000-000000000000',
|
||||
unencryptedFileSize: 10,
|
||||
},
|
||||
],
|
||||
|
@ -106,7 +101,7 @@ describe('ValetTokenAuthMiddleware', () => {
|
|||
permittedOperation: 'write',
|
||||
permittedResources: [
|
||||
{
|
||||
remoteIdentifier: '1-2-3/2-3-4',
|
||||
remoteIdentifier: '00000000-0000-0000-0000-000000000000',
|
||||
unencryptedFileSize: 10,
|
||||
},
|
||||
],
|
||||
|
@ -123,7 +118,7 @@ describe('ValetTokenAuthMiddleware', () => {
|
|||
userUuid: '1-2-3',
|
||||
permittedResources: [
|
||||
{
|
||||
remoteIdentifier: '1-2-3/2-3-4',
|
||||
remoteIdentifier: '00000000-0000-0000-0000-000000000000',
|
||||
unencryptedFileSize: 21,
|
||||
},
|
||||
],
|
||||
|
@ -145,7 +140,7 @@ describe('ValetTokenAuthMiddleware', () => {
|
|||
userUuid: '1-2-3',
|
||||
permittedResources: [
|
||||
{
|
||||
remoteIdentifier: '1-2-3/2-3-4',
|
||||
remoteIdentifier: '00000000-0000-0000-0000-000000000000',
|
||||
unencryptedFileSize: 21,
|
||||
},
|
||||
],
|
||||
|
@ -161,7 +156,7 @@ describe('ValetTokenAuthMiddleware', () => {
|
|||
permittedOperation: 'read',
|
||||
permittedResources: [
|
||||
{
|
||||
remoteIdentifier: '1-2-3/2-3-4',
|
||||
remoteIdentifier: '00000000-0000-0000-0000-000000000000',
|
||||
unencryptedFileSize: 21,
|
||||
},
|
||||
],
|
||||
|
@ -184,7 +179,7 @@ describe('ValetTokenAuthMiddleware', () => {
|
|||
userUuid: '1-2-3',
|
||||
permittedResources: [
|
||||
{
|
||||
remoteIdentifier: '1-2-3/2-3-4',
|
||||
remoteIdentifier: '1-2-3',
|
||||
unencryptedFileSize: 30,
|
||||
},
|
||||
],
|
||||
|
@ -195,8 +190,6 @@ describe('ValetTokenAuthMiddleware', () => {
|
|||
|
||||
request.headers['x-valet-token'] = 'valet-token'
|
||||
|
||||
uuidValidator.validate = jest.fn().mockReturnValue(false)
|
||||
|
||||
await createMiddleware().handler(request, response, next)
|
||||
|
||||
expect(response.status).toHaveBeenCalledWith(401)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Uuid, ValidatorInterface } from '@standardnotes/common'
|
||||
import { TokenDecoderInterface, ValetTokenData } from '@standardnotes/security'
|
||||
import { Uuid } from '@standardnotes/domain-core'
|
||||
import { NextFunction, Request, Response } from 'express'
|
||||
import { inject, injectable } from 'inversify'
|
||||
import { BaseMiddleware } from 'inversify-express-utils'
|
||||
|
@ -10,7 +10,6 @@ import TYPES from '../Bootstrap/Types'
|
|||
export class ValetTokenAuthMiddleware extends BaseMiddleware {
|
||||
constructor(
|
||||
@inject(TYPES.ValetTokenDecoder) private tokenDecoder: TokenDecoderInterface<ValetTokenData>,
|
||||
@inject(TYPES.UuidValidator) private uuidValidator: ValidatorInterface<Uuid>,
|
||||
@inject(TYPES.Logger) private logger: Logger,
|
||||
) {
|
||||
super()
|
||||
|
@ -48,7 +47,8 @@ export class ValetTokenAuthMiddleware extends BaseMiddleware {
|
|||
}
|
||||
|
||||
for (const resource of valetTokenData.permittedResources) {
|
||||
if (!this.uuidValidator.validate(resource.remoteIdentifier)) {
|
||||
const resourceUuidOrError = Uuid.create(resource.remoteIdentifier)
|
||||
if (resourceUuidOrError.isFailed()) {
|
||||
this.logger.debug('Invalid remote resource identifier in token.')
|
||||
|
||||
response.status(401).send({
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { FileUploadedEvent, FileRemovedEvent, DomainEventService } from '@standardnotes/domain-events'
|
||||
import { TimerInterface } from '@standardnotes/time'
|
||||
import { inject, injectable } from 'inversify'
|
||||
|
@ -15,7 +14,7 @@ export class DomainEventFactory implements DomainEventFactoryInterface {
|
|||
filePath: string
|
||||
fileName: string
|
||||
fileByteSize: number
|
||||
regularSubscriptionUuid: Uuid
|
||||
regularSubscriptionUuid: string
|
||||
}): FileRemovedEvent {
|
||||
return {
|
||||
type: 'FILE_REMOVED',
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { FileUploadedEvent, FileRemovedEvent } from '@standardnotes/domain-events'
|
||||
|
||||
export interface DomainEventFactoryInterface {
|
||||
|
@ -13,6 +12,6 @@ export interface DomainEventFactoryInterface {
|
|||
filePath: string
|
||||
fileName: string
|
||||
fileByteSize: number
|
||||
regularSubscriptionUuid: Uuid
|
||||
regularSubscriptionUuid: string
|
||||
}): FileRemovedEvent
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type RemovedFileDescription = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
filePath: string
|
||||
fileName: string
|
||||
fileByteSize: number
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type CreateUploadSessionDTO = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
resourceRemoteIdentifier: string
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type FinishUploadSessionDTO = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
resourceRemoteIdentifier: string
|
||||
uploadBytesUsed: number
|
||||
uploadBytesLimit: number
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type MarkFilesToBeRemovedDTO = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type RemoveFileDTO = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
resourceRemoteIdentifier: string
|
||||
regularSubscriptionUuid: Uuid
|
||||
regularSubscriptionUuid: string
|
||||
}
|
||||
|
|
|
@ -31,9 +31,5 @@
|
|||
"jest": "^29.1.2",
|
||||
"ts-jest": "^29.0.3",
|
||||
"typescript": "^4.8.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "workspace:*",
|
||||
"reflect-metadata": "^0.1.13"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { PredicateAuthority } from './PredicateAuthority'
|
||||
import { PredicateName } from './PredicateName'
|
||||
|
||||
export type Predicate = {
|
||||
jobUuid: Uuid
|
||||
jobUuid: string
|
||||
name: PredicateName
|
||||
authority: PredicateAuthority
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
"dependencies": {
|
||||
"@newrelic/winston-enricher": "^4.0.0",
|
||||
"@sentry/node": "^7.28.1",
|
||||
"@standardnotes/common": "workspace:*",
|
||||
"@standardnotes/domain-core": "workspace:^",
|
||||
"@standardnotes/domain-events": "workspace:*",
|
||||
"@standardnotes/domain-events-infra": "workspace:*",
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export interface JobDoneInterpreterInterface {
|
||||
interpret(jobUuid: Uuid): Promise<void>
|
||||
interpret(jobUuid: string): Promise<void>
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { Job } from './Job'
|
||||
|
||||
export interface JobRepositoryInterface {
|
||||
markJobAsDone(jobUuid: Uuid): Promise<void>
|
||||
findOneByUuid(uuid: Uuid): Promise<Job | null>
|
||||
markJobAsDone(jobUuid: string): Promise<void>
|
||||
findOneByUuid(uuid: string): Promise<Job | null>
|
||||
findPendingOverdue(timestamp: number): Promise<Job[]>
|
||||
save(job: Job): Promise<Job>
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { Predicate } from './Predicate'
|
||||
|
||||
export interface PredicateRepositoryInterface {
|
||||
findByJobUuid(jobUuid: Uuid): Promise<Predicate[]>
|
||||
findByJobUuid(jobUuid: string): Promise<Predicate[]>
|
||||
save(predicate: Predicate): Promise<Predicate>
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
"test": "jest spec --coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"@standardnotes/common": "workspace:*",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
"reflect-metadata": "^0.1.13"
|
||||
},
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type Role = {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
name: string
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import { SubscriptionName } from '@standardnotes/common'
|
||||
|
||||
export type Subscription = {
|
||||
planName: SubscriptionName
|
||||
planName: string
|
||||
endsAt: number
|
||||
createdAt: number
|
||||
updatedAt: number
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { Role } from '../Role/Role'
|
||||
|
||||
export type CrossServiceTokenData = {
|
||||
user: {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
email: string
|
||||
}
|
||||
roles: Array<Role>
|
||||
session?: {
|
||||
uuid: Uuid
|
||||
uuid: string
|
||||
api_version: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { ValetTokenOperation } from './ValetTokenOperation'
|
||||
|
||||
export type ValetTokenData = {
|
||||
userUuid: Uuid
|
||||
sharedSubscriptionUuid: Uuid | undefined
|
||||
regularSubscriptionUuid: Uuid
|
||||
userUuid: string
|
||||
sharedSubscriptionUuid: string | undefined
|
||||
regularSubscriptionUuid: string
|
||||
permittedOperation: ValetTokenOperation
|
||||
permittedResources: Array<{
|
||||
remoteIdentifier: string
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
export type WebSocketConnectionTokenData = {
|
||||
userUuid: Uuid
|
||||
userUuid: string
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { Column, Entity, Index, OneToMany, PrimaryGeneratedColumn } from 'typeorm'
|
||||
import { Revision } from '../Revision/Revision'
|
||||
|
||||
|
@ -124,5 +124,5 @@ export class Item {
|
|||
length: 36,
|
||||
nullable: true,
|
||||
})
|
||||
declare updatedWithSession: Uuid | null
|
||||
declare updatedWithSession: string | null
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
import { TimerInterface } from '@standardnotes/time'
|
||||
import { inject, injectable } from 'inversify'
|
||||
|
||||
|
@ -16,7 +15,7 @@ export class ItemFactory implements ItemFactoryInterface {
|
|||
@inject(TYPES.ItemProjector) private itemProjector: ProjectorInterface<Item, ItemProjection>,
|
||||
) {}
|
||||
|
||||
createStub(dto: { userUuid: string; itemHash: ItemHash; sessionUuid: Uuid | null }): Item {
|
||||
createStub(dto: { userUuid: string; itemHash: ItemHash; sessionUuid: string | null }): Item {
|
||||
const item = this.create(dto)
|
||||
|
||||
if (dto.itemHash.content === undefined) {
|
||||
|
@ -34,7 +33,7 @@ export class ItemFactory implements ItemFactoryInterface {
|
|||
return item
|
||||
}
|
||||
|
||||
create(dto: { userUuid: string; itemHash: ItemHash; sessionUuid: Uuid | null }): Item {
|
||||
create(dto: { userUuid: string; itemHash: ItemHash; sessionUuid: string | null }): Item {
|
||||
const newItem = new Item()
|
||||
newItem.uuid = dto.itemHash.uuid
|
||||
newItem.updatedWithSession = dto.sessionUuid
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { Uuid } from '@standardnotes/common'
|
||||
|
||||
import { Item } from './Item'
|
||||
import { ItemHash } from './ItemHash'
|
||||
|
||||
export interface ItemFactoryInterface {
|
||||
create(dto: { userUuid: string; itemHash: ItemHash; sessionUuid: Uuid | null }): Item
|
||||
createStub(dto: { userUuid: string; itemHash: ItemHash; sessionUuid: Uuid | null }): Item
|
||||
create(dto: { userUuid: string; itemHash: ItemHash; sessionUuid: string | null }): Item
|
||||
createStub(dto: { userUuid: string; itemHash: ItemHash; sessionUuid: string | null }): Item
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { DomainEventPublisherInterface } from '@standardnotes/domain-events'
|
||||
import { Time, TimerInterface } from '@standardnotes/time'
|
||||
import { ContentType, Uuid } from '@standardnotes/common'
|
||||
import { ContentType } from '@standardnotes/common'
|
||||
import { inject, injectable } from 'inversify'
|
||||
import { Logger } from 'winston'
|
||||
|
||||
|
@ -193,7 +193,7 @@ export class ItemService implements ItemServiceInterface {
|
|||
private async updateExistingItem(dto: {
|
||||
existingItem: Item
|
||||
itemHash: ItemHash
|
||||
sessionUuid: Uuid | null
|
||||
sessionUuid: string | null
|
||||
}): Promise<Item> {
|
||||
dto.existingItem.updatedWithSession = dto.sessionUuid
|
||||
dto.existingItem.contentSize = 0
|
||||
|
@ -267,7 +267,7 @@ export class ItemService implements ItemServiceInterface {
|
|||
return savedItem
|
||||
}
|
||||
|
||||
private async saveNewItem(dto: { userUuid: string; itemHash: ItemHash; sessionUuid: Uuid | null }): Promise<Item> {
|
||||
private async saveNewItem(dto: { userUuid: string; itemHash: ItemHash; sessionUuid: string | null }): Promise<Item> {
|
||||
const newItem = this.itemFactory.create(dto)
|
||||
|
||||
const savedItem = await this.itemRepository.save(newItem)
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue