internal: incomplete vault systems behind feature flag (#2340)

This commit is contained in:
Mo
2023-06-30 09:01:56 -05:00
committed by GitHub
parent d16e401bb9
commit b032eb9c9b
638 changed files with 20321 additions and 4813 deletions

View File

@@ -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
}
}