internal: incomplete vault systems behind feature flag (#2340)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user