refactor: application dependency management (#2363)
This commit is contained in:
@@ -23,7 +23,7 @@ export class DecryptedItemMutator<
|
||||
this.mutableContent = mutableCopy
|
||||
}
|
||||
|
||||
public override getResult() {
|
||||
public override getResult(): DecryptedPayloadInterface<C> {
|
||||
if (this.type === MutationType.NonDirtying) {
|
||||
return this.immutablePayload.copy({
|
||||
content: this.mutableContent,
|
||||
|
||||
@@ -3,7 +3,6 @@ export enum AsymmetricMessagePayloadType {
|
||||
SharedVaultRootKeyChanged = 'shared-vault-root-key-changed',
|
||||
SenderKeypairChanged = 'sender-keypair-changed',
|
||||
SharedVaultMetadataChanged = 'shared-vault-metadata-changed',
|
||||
|
||||
/**
|
||||
* Shared Vault Invites conform to the asymmetric message protocol, but are sent via the dedicated
|
||||
* SharedVaultInvite model and not the AsymmetricMessage model on the server side.
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
import { KeySystemRootKeyContentSpecialized } from '../../../Syncable/KeySystemRootKey/KeySystemRootKeyContent'
|
||||
import { TrustedContactContentSpecialized } from '../../../Syncable/TrustedContact/TrustedContactContent'
|
||||
import { ContactPublicKeySetJsonInterface } from '../../../Syncable/TrustedContact/PublicKeySet/ContactPublicKeySetJsonInterface'
|
||||
import { AsymmetricMessageDataCommon } from '../AsymmetricMessageDataCommon'
|
||||
import { AsymmetricMessagePayloadType } from '../AsymmetricMessagePayloadType'
|
||||
|
||||
export type VaultInviteDelegatedContact = {
|
||||
name?: string
|
||||
contactUuid: string
|
||||
publicKeySet: ContactPublicKeySetJsonInterface
|
||||
}
|
||||
|
||||
export type AsymmetricMessageSharedVaultInvite = {
|
||||
type: AsymmetricMessagePayloadType.SharedVaultInvite
|
||||
data: AsymmetricMessageDataCommon & {
|
||||
rootKey: KeySystemRootKeyContentSpecialized
|
||||
trustedContacts: TrustedContactContentSpecialized[]
|
||||
trustedContacts: VaultInviteDelegatedContact[]
|
||||
metadata: {
|
||||
name: string
|
||||
description?: string
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TrustedContactContentSpecialized } from '../../../Syncable/TrustedContact/TrustedContactContent'
|
||||
import { TrustedContactContentSpecialized } from '../../../Syncable/TrustedContact/Content/TrustedContactContent'
|
||||
import { AsymmetricMessageDataCommon } from '../AsymmetricMessageDataCommon'
|
||||
import { AsymmetricMessagePayloadType } from '../AsymmetricMessagePayloadType'
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { ItemContent } from '../../../Abstract/Content/ItemContent'
|
||||
import { ContactPublicKeySetJsonInterface } from '../PublicKeySet/ContactPublicKeySetJsonInterface'
|
||||
|
||||
export type TrustedContactContentSpecialized = {
|
||||
name: string
|
||||
contactUuid: string
|
||||
publicKeySet: ContactPublicKeySetJsonInterface
|
||||
isMe: boolean
|
||||
}
|
||||
|
||||
export type TrustedContactContent = TrustedContactContentSpecialized & ItemContent
|
||||
@@ -0,0 +1,93 @@
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { DecryptedPayload, PayloadTimestampDefaults } from '../../../Abstract/Payload'
|
||||
import { TrustedContact } from '../TrustedContact'
|
||||
import { TrustedContactInterface } from '../TrustedContactInterface'
|
||||
import { TrustedContactMutator } from './TrustedContactMutator'
|
||||
import { ContactPublicKeySet } from '../PublicKeySet/ContactPublicKeySet'
|
||||
import { FillItemContentSpecialized } from '../../../Abstract/Content/ItemContent'
|
||||
import { TrustedContactContentSpecialized } from '../Content/TrustedContactContent'
|
||||
import { MutationType } from '../../../Abstract/Item'
|
||||
import { PortablePublicKeySet } from '../Types/PortablePublicKeySet'
|
||||
import { ContactPublicKeySetInterface } from '../PublicKeySet/ContactPublicKeySetInterface'
|
||||
|
||||
function createMockPublicKeySetChain(): ContactPublicKeySetInterface {
|
||||
const nMinusOne = new ContactPublicKeySet({
|
||||
encryption: 'encryption-public-key-n-1',
|
||||
signing: 'signing-public-key-n-1',
|
||||
timestamp: new Date(-1),
|
||||
previousKeySet: undefined,
|
||||
})
|
||||
|
||||
const root = new ContactPublicKeySet({
|
||||
encryption: 'encryption-public-key',
|
||||
signing: 'signing-public-key',
|
||||
timestamp: new Date(),
|
||||
previousKeySet: nMinusOne,
|
||||
})
|
||||
|
||||
return root
|
||||
}
|
||||
|
||||
describe('TrustedContactMutator', () => {
|
||||
let contact: TrustedContactInterface
|
||||
let mutator: TrustedContactMutator
|
||||
|
||||
beforeEach(() => {
|
||||
contact = new TrustedContact(
|
||||
new DecryptedPayload({
|
||||
uuid: 'item-uuid',
|
||||
content_type: ContentType.TYPES.TrustedContact,
|
||||
...PayloadTimestampDefaults(),
|
||||
content: FillItemContentSpecialized<TrustedContactContentSpecialized, TrustedContactInterface>({
|
||||
name: 'test',
|
||||
contactUuid: 'contact-uuid',
|
||||
isMe: true,
|
||||
publicKeySet: createMockPublicKeySetChain(),
|
||||
}),
|
||||
}),
|
||||
)
|
||||
|
||||
mutator = new TrustedContactMutator(contact, MutationType.UpdateUserTimestamps)
|
||||
})
|
||||
|
||||
it('should set name', () => {
|
||||
mutator.name = 'new name'
|
||||
|
||||
const result = mutator.getResult()
|
||||
|
||||
expect(result.content.name).toEqual('new name')
|
||||
})
|
||||
|
||||
it('should add public key', () => {
|
||||
const currentKeySet = contact.publicKeySet
|
||||
|
||||
const newKeySet: PortablePublicKeySet = {
|
||||
encryption: 'new-encryption-public-key',
|
||||
signing: 'new-signing-public-key',
|
||||
}
|
||||
|
||||
mutator.addPublicKey(newKeySet)
|
||||
|
||||
const result = new TrustedContact(mutator.getResult())
|
||||
|
||||
expect(result.publicKeySet.encryption).toEqual(newKeySet.encryption)
|
||||
expect(result.publicKeySet.signing).toEqual(newKeySet.signing)
|
||||
expect(result.publicKeySet.previousKeySet).toEqual(currentKeySet)
|
||||
})
|
||||
|
||||
it('should replace public key set', () => {
|
||||
const replacement = new ContactPublicKeySet({
|
||||
encryption: 'encryption-public-key-replacement',
|
||||
signing: 'signing-public-key-replacement',
|
||||
timestamp: new Date(),
|
||||
previousKeySet: undefined,
|
||||
})
|
||||
|
||||
mutator.replacePublicKeySet(replacement.asJson())
|
||||
|
||||
const result = new TrustedContact(mutator.getResult())
|
||||
|
||||
expect(result.publicKeySet.encryption).toEqual(replacement.encryption)
|
||||
expect(result.publicKeySet.signing).toEqual(replacement.signing)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,27 @@
|
||||
import { DecryptedItemMutator } from '../../../Abstract/Item'
|
||||
import { TrustedContactContent } from '../Content/TrustedContactContent'
|
||||
import { TrustedContactInterface } from '../TrustedContactInterface'
|
||||
import { ContactPublicKeySet } from '../PublicKeySet/ContactPublicKeySet'
|
||||
import { PortablePublicKeySet } from '../Types/PortablePublicKeySet'
|
||||
import { ContactPublicKeySetJsonInterface } from '../PublicKeySet/ContactPublicKeySetJsonInterface'
|
||||
|
||||
export class TrustedContactMutator extends DecryptedItemMutator<TrustedContactContent, TrustedContactInterface> {
|
||||
set name(newName: string) {
|
||||
this.mutableContent.name = newName
|
||||
}
|
||||
|
||||
addPublicKey(keySet: PortablePublicKeySet): void {
|
||||
const newKey = new ContactPublicKeySet({
|
||||
encryption: keySet.encryption,
|
||||
signing: keySet.signing,
|
||||
timestamp: new Date(),
|
||||
previousKeySet: this.immutableItem.publicKeySet,
|
||||
})
|
||||
|
||||
this.mutableContent.publicKeySet = newKey
|
||||
}
|
||||
|
||||
replacePublicKeySet(publicKeySet: ContactPublicKeySetJsonInterface): void {
|
||||
this.mutableContent.publicKeySet = publicKeySet
|
||||
}
|
||||
}
|
||||
@@ -5,36 +5,18 @@ export class ContactPublicKeySet implements ContactPublicKeySetInterface {
|
||||
encryption: string
|
||||
signing: string
|
||||
timestamp: Date
|
||||
isRevoked: boolean
|
||||
previousKeySet?: ContactPublicKeySet
|
||||
previousKeySet?: ContactPublicKeySetInterface
|
||||
|
||||
constructor(
|
||||
encryption: string,
|
||||
signing: string,
|
||||
timestamp: Date,
|
||||
isRevoked: boolean,
|
||||
previousKeySet: ContactPublicKeySet | undefined,
|
||||
) {
|
||||
this.encryption = encryption
|
||||
this.signing = signing
|
||||
this.timestamp = timestamp
|
||||
this.isRevoked = isRevoked
|
||||
this.previousKeySet = previousKeySet
|
||||
}
|
||||
|
||||
public findKeySet(params: {
|
||||
targetEncryptionPublicKey: string
|
||||
targetSigningPublicKey: string
|
||||
}): ContactPublicKeySetInterface | undefined {
|
||||
if (this.encryption === params.targetEncryptionPublicKey && this.signing === params.targetSigningPublicKey) {
|
||||
return this
|
||||
}
|
||||
|
||||
if (this.previousKeySet) {
|
||||
return this.previousKeySet.findKeySet(params)
|
||||
}
|
||||
|
||||
return undefined
|
||||
constructor(dto: {
|
||||
encryption: string
|
||||
signing: string
|
||||
timestamp: Date
|
||||
previousKeySet: ContactPublicKeySetInterface | undefined
|
||||
}) {
|
||||
this.encryption = dto.encryption
|
||||
this.signing = dto.signing
|
||||
this.timestamp = dto.timestamp
|
||||
this.previousKeySet = dto.previousKeySet
|
||||
}
|
||||
|
||||
public findKeySetWithSigningKey(signingKey: string): ContactPublicKeySetInterface | undefined {
|
||||
@@ -61,13 +43,30 @@ export class ContactPublicKeySet implements ContactPublicKeySetInterface {
|
||||
return undefined
|
||||
}
|
||||
|
||||
asJson(): ContactPublicKeySetJsonInterface {
|
||||
return {
|
||||
encryption: this.encryption,
|
||||
signing: this.signing,
|
||||
timestamp: this.timestamp,
|
||||
previousKeySet: this.previousKeySet ? this.previousKeySet.asJson() : undefined,
|
||||
}
|
||||
}
|
||||
|
||||
mutableCopy(): ContactPublicKeySetInterface {
|
||||
return new ContactPublicKeySet({
|
||||
encryption: this.encryption,
|
||||
signing: this.signing,
|
||||
timestamp: this.timestamp,
|
||||
previousKeySet: this.previousKeySet ? ContactPublicKeySet.FromJson(this.previousKeySet.asJson()) : undefined,
|
||||
})
|
||||
}
|
||||
|
||||
static FromJson(json: ContactPublicKeySetJsonInterface): ContactPublicKeySetInterface {
|
||||
return new ContactPublicKeySet(
|
||||
json.encryption,
|
||||
json.signing,
|
||||
new Date(json.timestamp),
|
||||
json.isRevoked,
|
||||
json.previousKeySet ? ContactPublicKeySet.FromJson(json.previousKeySet) : undefined,
|
||||
)
|
||||
return new ContactPublicKeySet({
|
||||
encryption: json.encryption,
|
||||
signing: json.signing,
|
||||
timestamp: new Date(json.timestamp),
|
||||
previousKeySet: json.previousKeySet ? ContactPublicKeySet.FromJson(json.previousKeySet) : undefined,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { ContactPublicKeySetJsonInterface } from './ContactPublicKeySetJsonInterface'
|
||||
|
||||
export interface ContactPublicKeySetInterface {
|
||||
encryption: string
|
||||
signing: string
|
||||
timestamp: Date
|
||||
isRevoked: boolean
|
||||
previousKeySet?: ContactPublicKeySetInterface
|
||||
|
||||
findKeySet(params: {
|
||||
targetEncryptionPublicKey: string
|
||||
targetSigningPublicKey: string
|
||||
}): ContactPublicKeySetInterface | undefined
|
||||
|
||||
findKeySetWithPublicKey(publicKey: string): ContactPublicKeySetInterface | undefined
|
||||
findKeySetWithSigningKey(signingKey: string): ContactPublicKeySetInterface | undefined
|
||||
|
||||
asJson(): ContactPublicKeySetJsonInterface
|
||||
mutableCopy(): ContactPublicKeySetInterface
|
||||
}
|
||||
|
||||
@@ -2,6 +2,5 @@ export interface ContactPublicKeySetJsonInterface {
|
||||
encryption: string
|
||||
signing: string
|
||||
timestamp: Date
|
||||
isRevoked: boolean
|
||||
previousKeySet?: ContactPublicKeySetJsonInterface
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import { ContactPublicKeySetInterface } from './ContactPublicKeySetInterface'
|
||||
|
||||
export type FindPublicKeySetResult =
|
||||
| {
|
||||
publicKeySet: ContactPublicKeySetInterface
|
||||
current: boolean
|
||||
}
|
||||
| undefined
|
||||
@@ -0,0 +1,109 @@
|
||||
import { ContentType } from '@standardnotes/domain-core'
|
||||
import { DecryptedPayload, PayloadTimestampDefaults } from '../../Abstract/Payload'
|
||||
import { ContactPublicKeySet } from './PublicKeySet/ContactPublicKeySet'
|
||||
import { ContactPublicKeySetInterface } from './PublicKeySet/ContactPublicKeySetInterface'
|
||||
import { TrustedContact } from './TrustedContact'
|
||||
import { TrustedContactInterface } from './TrustedContactInterface'
|
||||
import { FillItemContentSpecialized } from '../../Abstract/Content/ItemContent'
|
||||
import { ConflictStrategy } from '../../Abstract/Item'
|
||||
import { TrustedContactContentSpecialized } from './Content/TrustedContactContent'
|
||||
import { PublicKeyTrustStatus } from './Types/PublicKeyTrustStatus'
|
||||
|
||||
function createMockPublicKeySetChain(): ContactPublicKeySetInterface {
|
||||
const nMinusOne = new ContactPublicKeySet({
|
||||
encryption: 'encryption-public-key-n-1',
|
||||
signing: 'signing-public-key-n-1',
|
||||
timestamp: new Date(-1),
|
||||
previousKeySet: undefined,
|
||||
})
|
||||
|
||||
const root = new ContactPublicKeySet({
|
||||
encryption: 'encryption-public-key',
|
||||
signing: 'signing-public-key',
|
||||
timestamp: new Date(),
|
||||
previousKeySet: nMinusOne,
|
||||
})
|
||||
|
||||
return root
|
||||
}
|
||||
|
||||
function CreateContact(params: {
|
||||
name?: string
|
||||
contactUuid?: string
|
||||
isMe?: boolean
|
||||
publicKeySet?: ContactPublicKeySetInterface
|
||||
}): TrustedContactInterface {
|
||||
return new TrustedContact(
|
||||
new DecryptedPayload({
|
||||
uuid: 'item-uuid',
|
||||
content_type: ContentType.TYPES.TrustedContact,
|
||||
...PayloadTimestampDefaults(),
|
||||
content: FillItemContentSpecialized<TrustedContactContentSpecialized, TrustedContactInterface>({
|
||||
name: params.name ?? 'test',
|
||||
contactUuid: params.contactUuid ?? 'contact-uuid',
|
||||
isMe: params.isMe ?? false,
|
||||
publicKeySet: params.publicKeySet ?? createMockPublicKeySetChain(),
|
||||
}),
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
describe('isSingleton', () => {
|
||||
it('should be true', () => {
|
||||
const contact = CreateContact({})
|
||||
|
||||
expect(contact.isSingleton).toEqual(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('strategyWhenConflictingWithItem', () => {
|
||||
it('should be KeepBase', () => {
|
||||
const contact = CreateContact({})
|
||||
|
||||
expect(contact.strategyWhenConflictingWithItem({} as unknown as TrustedContactInterface)).toEqual(
|
||||
ConflictStrategy.KeepBase,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('TrustedContact', () => {
|
||||
describe('getTrustStatusForPublicKey', () => {
|
||||
it('should be trusted if key set is root', () => {
|
||||
const contact = CreateContact({ publicKeySet: createMockPublicKeySetChain() })
|
||||
|
||||
expect(contact.getTrustStatusForPublicKey('encryption-public-key')).toEqual(PublicKeyTrustStatus.Trusted)
|
||||
})
|
||||
|
||||
it('should be semi-trusted if key set is previous', () => {
|
||||
const contact = CreateContact({ publicKeySet: createMockPublicKeySetChain() })
|
||||
|
||||
expect(contact.getTrustStatusForPublicKey('encryption-public-key-n-1')).toEqual(PublicKeyTrustStatus.Previous)
|
||||
})
|
||||
|
||||
it('should return not trusted if public key is not found', () => {
|
||||
const contact = CreateContact({ publicKeySet: createMockPublicKeySetChain() })
|
||||
|
||||
expect(contact.getTrustStatusForPublicKey('not-found-public-key')).toEqual(PublicKeyTrustStatus.NotTrusted)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getTrustStatusForSigningPublicKey', () => {
|
||||
it('should be trusted if key set is root', () => {
|
||||
const contact = CreateContact({ publicKeySet: createMockPublicKeySetChain() })
|
||||
|
||||
expect(contact.getTrustStatusForSigningPublicKey('signing-public-key')).toEqual(PublicKeyTrustStatus.Trusted)
|
||||
})
|
||||
|
||||
it('should be semi-trusted if key set is previous', () => {
|
||||
const contact = CreateContact({ publicKeySet: createMockPublicKeySetChain() })
|
||||
|
||||
expect(contact.getTrustStatusForSigningPublicKey('signing-public-key-n-1')).toEqual(PublicKeyTrustStatus.Previous)
|
||||
})
|
||||
|
||||
it('should return not trusted if public key is not found', () => {
|
||||
const contact = CreateContact({ publicKeySet: createMockPublicKeySetChain() })
|
||||
|
||||
expect(contact.getTrustStatusForSigningPublicKey('not-found-public-key')).toEqual(PublicKeyTrustStatus.NotTrusted)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,12 +1,12 @@
|
||||
import { ConflictStrategy, DecryptedItem, DecryptedItemInterface } from '../../Abstract/Item'
|
||||
import { DecryptedPayloadInterface } from '../../Abstract/Payload'
|
||||
import { HistoryEntryInterface } from '../../Runtime/History'
|
||||
import { TrustedContactContent } from './TrustedContactContent'
|
||||
import { TrustedContactContent } from './Content/TrustedContactContent'
|
||||
import { TrustedContactInterface } from './TrustedContactInterface'
|
||||
import { FindPublicKeySetResult } from './PublicKeySet/FindPublicKeySetResult'
|
||||
import { ContactPublicKeySet } from './PublicKeySet/ContactPublicKeySet'
|
||||
import { ContactPublicKeySetInterface } from './PublicKeySet/ContactPublicKeySetInterface'
|
||||
import { Predicate } from '../../Runtime/Predicate/Predicate'
|
||||
import { PublicKeyTrustStatus } from './Types/PublicKeyTrustStatus'
|
||||
|
||||
export class TrustedContact extends DecryptedItem<TrustedContactContent> implements TrustedContactInterface {
|
||||
static singletonPredicate = new Predicate<TrustedContact>('isMe', '=', true)
|
||||
@@ -33,39 +33,36 @@ export class TrustedContact extends DecryptedItem<TrustedContactContent> impleme
|
||||
return TrustedContact.singletonPredicate
|
||||
}
|
||||
|
||||
public findKeySet(params: {
|
||||
targetEncryptionPublicKey: string
|
||||
targetSigningPublicKey: string
|
||||
}): FindPublicKeySetResult {
|
||||
const set = this.publicKeySet.findKeySet(params)
|
||||
if (!set) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return {
|
||||
publicKeySet: set,
|
||||
current: set === this.publicKeySet,
|
||||
}
|
||||
hasCurrentOrPreviousSigningPublicKey(signingPublicKey: string): boolean {
|
||||
return this.publicKeySet.findKeySetWithSigningKey(signingPublicKey) !== undefined
|
||||
}
|
||||
|
||||
isPublicKeyTrusted(encryptionPublicKey: string): boolean {
|
||||
const keySet = this.publicKeySet.findKeySetWithPublicKey(encryptionPublicKey)
|
||||
|
||||
if (keySet && !keySet.isRevoked) {
|
||||
return true
|
||||
getTrustStatusForPublicKey(encryptionPublicKey: string): PublicKeyTrustStatus {
|
||||
if (this.publicKeySet.encryption === encryptionPublicKey) {
|
||||
return PublicKeyTrustStatus.Trusted
|
||||
}
|
||||
|
||||
return false
|
||||
const previous = this.publicKeySet.findKeySetWithPublicKey(encryptionPublicKey)
|
||||
|
||||
if (previous) {
|
||||
return PublicKeyTrustStatus.Previous
|
||||
}
|
||||
|
||||
return PublicKeyTrustStatus.NotTrusted
|
||||
}
|
||||
|
||||
isSigningKeyTrusted(signingKey: string): boolean {
|
||||
const keySet = this.publicKeySet.findKeySetWithSigningKey(signingKey)
|
||||
|
||||
if (keySet && !keySet.isRevoked) {
|
||||
return true
|
||||
getTrustStatusForSigningPublicKey(signingPublicKey: string): PublicKeyTrustStatus {
|
||||
if (this.publicKeySet.signing === signingPublicKey) {
|
||||
return PublicKeyTrustStatus.Trusted
|
||||
}
|
||||
|
||||
return false
|
||||
const previous = this.publicKeySet.findKeySetWithSigningKey(signingPublicKey)
|
||||
|
||||
if (previous) {
|
||||
return PublicKeyTrustStatus.Previous
|
||||
}
|
||||
|
||||
return PublicKeyTrustStatus.NotTrusted
|
||||
}
|
||||
|
||||
override strategyWhenConflictingWithItem(
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { ItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { ContactPublicKeySetInterface } from './PublicKeySet/ContactPublicKeySetInterface'
|
||||
|
||||
export type TrustedContactContentSpecialized = {
|
||||
name: string
|
||||
contactUuid: string
|
||||
publicKeySet: ContactPublicKeySetInterface
|
||||
isMe: boolean
|
||||
}
|
||||
|
||||
export type TrustedContactContent = TrustedContactContentSpecialized & ItemContent
|
||||
@@ -1,7 +1,7 @@
|
||||
import { DecryptedItemInterface } from '../../Abstract/Item/Interfaces/DecryptedItem'
|
||||
import { FindPublicKeySetResult } from './PublicKeySet/FindPublicKeySetResult'
|
||||
import { TrustedContactContent } from './TrustedContactContent'
|
||||
import { TrustedContactContent } from './Content/TrustedContactContent'
|
||||
import { ContactPublicKeySetInterface } from './PublicKeySet/ContactPublicKeySetInterface'
|
||||
import { PublicKeyTrustStatus } from './Types/PublicKeyTrustStatus'
|
||||
|
||||
export interface TrustedContactInterface extends DecryptedItemInterface<TrustedContactContent> {
|
||||
name: string
|
||||
@@ -9,8 +9,7 @@ export interface TrustedContactInterface extends DecryptedItemInterface<TrustedC
|
||||
publicKeySet: ContactPublicKeySetInterface
|
||||
isMe: boolean
|
||||
|
||||
findKeySet(params: { targetEncryptionPublicKey: string; targetSigningPublicKey: string }): FindPublicKeySetResult
|
||||
|
||||
isPublicKeyTrusted(encryptionPublicKey: string): boolean
|
||||
isSigningKeyTrusted(signingKey: string): boolean
|
||||
getTrustStatusForPublicKey(encryptionPublicKey: string): PublicKeyTrustStatus
|
||||
getTrustStatusForSigningPublicKey(signingPublicKey: string): PublicKeyTrustStatus
|
||||
hasCurrentOrPreviousSigningPublicKey(signingPublicKey: string): boolean
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import { DecryptedItemMutator } from '../../Abstract/Item'
|
||||
import { TrustedContactContent } from './TrustedContactContent'
|
||||
import { TrustedContactInterface } from './TrustedContactInterface'
|
||||
import { ContactPublicKeySet } from './PublicKeySet/ContactPublicKeySet'
|
||||
|
||||
export class TrustedContactMutator extends DecryptedItemMutator<TrustedContactContent, TrustedContactInterface> {
|
||||
set name(newName: string) {
|
||||
this.mutableContent.name = newName
|
||||
}
|
||||
|
||||
addPublicKey(params: { encryption: string; signing: string }): void {
|
||||
const newKey = new ContactPublicKeySet(
|
||||
params.encryption,
|
||||
params.signing,
|
||||
new Date(),
|
||||
false,
|
||||
this.immutableItem.publicKeySet,
|
||||
)
|
||||
|
||||
this.mutableContent.publicKeySet = newKey
|
||||
}
|
||||
|
||||
replacePublicKeySet(publicKeySet: ContactPublicKeySet): void {
|
||||
this.mutableContent.publicKeySet = publicKeySet
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export type PortablePublicKeySet = {
|
||||
encryption: string
|
||||
signing: string
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export enum PublicKeyTrustStatus {
|
||||
Trusted = 'Trusted',
|
||||
Previous = 'Previous',
|
||||
NotTrusted = 'NotTrusted',
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import { EncryptedItemInterface } from '../../Abstract/Item/Interfaces/Encrypted
|
||||
import { DeletedItemInterface } from '../../Abstract/Item/Interfaces/DeletedItem'
|
||||
import { SmartViewMutator } from '../../Syncable/SmartView'
|
||||
import { TrustedContact } from '../../Syncable/TrustedContact/TrustedContact'
|
||||
import { TrustedContactMutator } from '../../Syncable/TrustedContact/TrustedContactMutator'
|
||||
import { TrustedContactMutator } from '../../Syncable/TrustedContact/Mutator/TrustedContactMutator'
|
||||
import { KeySystemRootKey } from '../../Syncable/KeySystemRootKey/KeySystemRootKey'
|
||||
import { KeySystemRootKeyMutator } from '../../Syncable/KeySystemRootKey/KeySystemRootKeyMutator'
|
||||
import { VaultListing } from '../../Syncable/VaultListing/VaultListing'
|
||||
|
||||
@@ -97,11 +97,13 @@ export * from './Syncable/Theme'
|
||||
export * from './Syncable/UserPrefs'
|
||||
|
||||
export * from './Syncable/TrustedContact/TrustedContact'
|
||||
export * from './Syncable/TrustedContact/TrustedContactMutator'
|
||||
export * from './Syncable/TrustedContact/TrustedContactContent'
|
||||
export * from './Syncable/TrustedContact/Mutator/TrustedContactMutator'
|
||||
export * from './Syncable/TrustedContact/Content/TrustedContactContent'
|
||||
export * from './Syncable/TrustedContact/TrustedContactInterface'
|
||||
export * from './Syncable/TrustedContact/PublicKeySet/ContactPublicKeySetInterface'
|
||||
export * from './Syncable/TrustedContact/PublicKeySet/ContactPublicKeySet'
|
||||
export * from './Syncable/TrustedContact/Types/PortablePublicKeySet'
|
||||
export * from './Syncable/TrustedContact/Types/PublicKeyTrustStatus'
|
||||
|
||||
export * from './Syncable/KeySystemRootKey/KeySystemRootKey'
|
||||
export * from './Syncable/KeySystemRootKey/KeySystemRootKeyMutator'
|
||||
|
||||
Reference in New Issue
Block a user