internal: incomplete vault systems behind feature flag (#2340)
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { ContentType, ProtocolVersion } from '@standardnotes/common'
|
||||
import { ConflictStrategy, DecryptedItem } from '../../Abstract/Item'
|
||||
import { DecryptedPayloadInterface } from '../../Abstract/Payload'
|
||||
import { HistoryEntryInterface } from '../../Runtime/History'
|
||||
import { KeySystemRootKeyContent } from './KeySystemRootKeyContent'
|
||||
import { KeySystemRootKeyInterface } from './KeySystemRootKeyInterface'
|
||||
import { KeySystemIdentifier } from './KeySystemIdentifier'
|
||||
import { KeySystemRootKeyParamsInterface } from '../../Local/KeyParams/KeySystemRootKeyParamsInterface'
|
||||
|
||||
export function isKeySystemRootKey(x: { content_type: ContentType }): x is KeySystemRootKey {
|
||||
return x.content_type === ContentType.KeySystemRootKey
|
||||
}
|
||||
|
||||
export class KeySystemRootKey extends DecryptedItem<KeySystemRootKeyContent> implements KeySystemRootKeyInterface {
|
||||
keyParams: KeySystemRootKeyParamsInterface
|
||||
systemIdentifier: KeySystemIdentifier
|
||||
|
||||
key: string
|
||||
keyVersion: ProtocolVersion
|
||||
token: string
|
||||
|
||||
constructor(payload: DecryptedPayloadInterface<KeySystemRootKeyContent>) {
|
||||
super(payload)
|
||||
|
||||
this.keyParams = payload.content.keyParams
|
||||
this.systemIdentifier = payload.content.systemIdentifier
|
||||
|
||||
this.key = payload.content.key
|
||||
this.keyVersion = payload.content.keyVersion
|
||||
this.token = payload.content.token
|
||||
}
|
||||
|
||||
override strategyWhenConflictingWithItem(
|
||||
item: KeySystemRootKey,
|
||||
_previousRevision?: HistoryEntryInterface,
|
||||
): ConflictStrategy {
|
||||
const baseKeyTimestamp = this.keyParams.creationTimestamp
|
||||
const incomingKeyTimestamp = item.keyParams.creationTimestamp
|
||||
|
||||
return incomingKeyTimestamp > baseKeyTimestamp ? ConflictStrategy.KeepApply : ConflictStrategy.KeepBase
|
||||
}
|
||||
|
||||
get itemsKey(): string {
|
||||
return this.key
|
||||
}
|
||||
|
||||
override get key_system_identifier(): undefined {
|
||||
return undefined
|
||||
}
|
||||
|
||||
override get shared_vault_uuid(): undefined {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user