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,73 @@
import { ContactPublicKeySetInterface } from './ContactPublicKeySetInterface'
import { ContactPublicKeySetJsonInterface } from './ContactPublicKeySetJsonInterface'
export class ContactPublicKeySet implements ContactPublicKeySetInterface {
encryption: string
signing: string
timestamp: Date
isRevoked: boolean
previousKeySet?: ContactPublicKeySet
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
}
public findKeySetWithSigningKey(signingKey: string): ContactPublicKeySetInterface | undefined {
if (this.signing === signingKey) {
return this
}
if (this.previousKeySet) {
return this.previousKeySet.findKeySetWithSigningKey(signingKey)
}
return undefined
}
findKeySetWithPublicKey(publicKey: string): ContactPublicKeySetInterface | undefined {
if (this.encryption === publicKey) {
return this
}
if (this.previousKeySet) {
return this.previousKeySet.findKeySetWithPublicKey(publicKey)
}
return 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,
)
}
}