chore: replace throw with error

This commit is contained in:
Mo
2023-08-12 06:14:27 -05:00
parent 4f62c7e7cd
commit c2110b7c12
3 changed files with 11 additions and 1 deletions

View File

@@ -10,12 +10,14 @@ import {
import { DecryptTypeAPayload } from './DecryptPayload' import { DecryptTypeAPayload } from './DecryptPayload'
import { RootKeyManager } from '../../../RootKeyManager/RootKeyManager' import { RootKeyManager } from '../../../RootKeyManager/RootKeyManager'
import { KeySystemKeyManagerInterface } from '../../../KeySystem/KeySystemKeyManagerInterface' import { KeySystemKeyManagerInterface } from '../../../KeySystem/KeySystemKeyManagerInterface'
import { LoggerInterface } from '@standardnotes/utils'
export class DecryptTypeAPayloadWithKeyLookup { export class DecryptTypeAPayloadWithKeyLookup {
constructor( constructor(
private operators: EncryptionOperatorsInterface, private operators: EncryptionOperatorsInterface,
private keySystemKeyManager: KeySystemKeyManagerInterface, private keySystemKeyManager: KeySystemKeyManagerInterface,
private rootKeyManager: RootKeyManager, private rootKeyManager: RootKeyManager,
private logger: LoggerInterface,
) {} ) {}
async executeOne<C extends ItemContent = ItemContent>( async executeOne<C extends ItemContent = ItemContent>(
@@ -24,7 +26,11 @@ export class DecryptTypeAPayloadWithKeyLookup {
let key: RootKeyInterface | KeySystemRootKeyInterface | undefined let key: RootKeyInterface | KeySystemRootKeyInterface | undefined
if (ContentTypeUsesKeySystemRootKeyEncryption(payload.content_type)) { if (ContentTypeUsesKeySystemRootKeyEncryption(payload.content_type)) {
if (!payload.key_system_identifier) { if (!payload.key_system_identifier) {
throw Error('Key system root key encrypted payload is missing key_system_identifier') this.logger.error('Payload is missing key system identifier', payload)
return {
uuid: payload.uuid,
errorDecrypting: true,
}
} }
key = this.keySystemKeyManager.getPrimaryKeySystemRootKey(payload.key_system_identifier) key = this.keySystemKeyManager.getPrimaryKeySystemRootKey(payload.key_system_identifier)
} else { } else {

View File

@@ -225,6 +225,9 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
this.dependencies = new Dependencies(this.options) this.dependencies = new Dependencies(this.options)
const logger = this.dependencies.get<LoggerInterface>(TYPES.Logger)
logger.setLevel('error')
this.registerServiceObservers() this.registerServiceObservers()
RegisterApplicationServicesEvents(this.dependencies, this.events) RegisterApplicationServicesEvents(this.dependencies, this.events)

View File

@@ -770,6 +770,7 @@ export class Dependencies {
this.get<EncryptionOperators>(TYPES.EncryptionOperators), this.get<EncryptionOperators>(TYPES.EncryptionOperators),
this.get<KeySystemKeyManager>(TYPES.KeySystemKeyManager), this.get<KeySystemKeyManager>(TYPES.KeySystemKeyManager),
this.get<RootKeyManager>(TYPES.RootKeyManager), this.get<RootKeyManager>(TYPES.RootKeyManager),
this.get<Logger>(TYPES.Logger),
) )
}) })