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,41 @@
import { ContentType, ProtocolVersion } from '@standardnotes/common'
import {
ConflictStrategy,
DecryptedItem,
DecryptedItemInterface,
DecryptedPayloadInterface,
HistoryEntryInterface,
KeySystemItemsKeyContent,
KeySystemItemsKeyInterface,
} from '@standardnotes/models'
export function isKeySystemItemsKey(x: unknown): x is KeySystemItemsKeyInterface {
return (x as KeySystemItemsKeyInterface).content_type === ContentType.KeySystemItemsKey
}
/**
* A key used to encrypt other items. Items keys are synced and persisted.
*/
export class KeySystemItemsKey extends DecryptedItem<KeySystemItemsKeyContent> implements KeySystemItemsKeyInterface {
creationTimestamp: number
keyVersion: ProtocolVersion
itemsKey: string
rootKeyToken: string
constructor(payload: DecryptedPayloadInterface<KeySystemItemsKeyContent>) {
super(payload)
this.creationTimestamp = payload.content.creationTimestamp
this.keyVersion = payload.content.version
this.itemsKey = this.payload.content.itemsKey
this.rootKeyToken = this.payload.content.rootKeyToken
}
/** Do not duplicate vault items keys. Always keep original */
override strategyWhenConflictingWithItem(
_item: DecryptedItemInterface,
_previousRevision?: HistoryEntryInterface,
): ConflictStrategy {
return ConflictStrategy.KeepBase
}
}