feat: add models package
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
KeyParamsContent001,
|
||||
KeyParamsContent002,
|
||||
KeyParamsContent003,
|
||||
KeyParamsContent004,
|
||||
AnyKeyParamsContent,
|
||||
ProtocolVersion,
|
||||
KeyParamsOrigination,
|
||||
} from '@standardnotes/common'
|
||||
|
||||
/**
|
||||
* Key params are public data that contain information about how a root key was created.
|
||||
* Given a keyParams object and a password, clients can compute a root key that was created
|
||||
* previously.
|
||||
*/
|
||||
export interface RootKeyParamsInterface {
|
||||
readonly content: AnyKeyParamsContent
|
||||
|
||||
/**
|
||||
* For consumers to determine whether the object they are
|
||||
* working with is a proper RootKeyParams object.
|
||||
*/
|
||||
get isKeyParamsObject(): boolean
|
||||
|
||||
get identifier(): string
|
||||
|
||||
get version(): ProtocolVersion
|
||||
get origination(): KeyParamsOrigination | undefined
|
||||
|
||||
get content001(): KeyParamsContent001
|
||||
|
||||
get content002(): KeyParamsContent002
|
||||
|
||||
get content003(): KeyParamsContent003
|
||||
|
||||
get content004(): KeyParamsContent004
|
||||
|
||||
get createdDate(): Date | undefined
|
||||
|
||||
compare(other: RootKeyParamsInterface): boolean
|
||||
|
||||
/**
|
||||
* When saving in a file or communicating with server,
|
||||
* use the original values.
|
||||
*/
|
||||
getPortableValue(): AnyKeyParamsContent
|
||||
}
|
||||
31
packages/models/src/Domain/Local/RootKey/KeychainTypes.ts
Normal file
31
packages/models/src/Domain/Local/RootKey/KeychainTypes.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { ApplicationIdentifier, ProtocolVersion } from '@standardnotes/common'
|
||||
import { RootKeyContentSpecialized } from './RootKeyContent'
|
||||
|
||||
export type RawKeychainValue = Record<ApplicationIdentifier, NamespacedRootKeyInKeychain>
|
||||
|
||||
export interface NamespacedRootKeyInKeychain {
|
||||
version: ProtocolVersion
|
||||
masterKey: string
|
||||
dataAuthenticationKey?: string
|
||||
}
|
||||
|
||||
export type RootKeyContentInStorage = RootKeyContentSpecialized
|
||||
|
||||
export interface LegacyRawKeychainValue {
|
||||
mk: string
|
||||
ak: string
|
||||
version: ProtocolVersion
|
||||
}
|
||||
|
||||
export type LegacyMobileKeychainStructure = {
|
||||
offline?: {
|
||||
timing?: unknown
|
||||
pw?: string
|
||||
}
|
||||
encryptedAccountKeys?: unknown
|
||||
mk: string
|
||||
pw: string
|
||||
ak: string
|
||||
version?: string
|
||||
jwt?: string
|
||||
}
|
||||
12
packages/models/src/Domain/Local/RootKey/RootKeyContent.ts
Normal file
12
packages/models/src/Domain/Local/RootKey/RootKeyContent.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { ItemContent } from '../../Abstract/Content/ItemContent'
|
||||
import { ProtocolVersion, AnyKeyParamsContent } from '@standardnotes/common'
|
||||
|
||||
export interface RootKeyContentSpecialized {
|
||||
version: ProtocolVersion
|
||||
masterKey: string
|
||||
serverPassword?: string
|
||||
dataAuthenticationKey?: string
|
||||
keyParams: AnyKeyParamsContent
|
||||
}
|
||||
|
||||
export type RootKeyContent = RootKeyContentSpecialized & ItemContent
|
||||
17
packages/models/src/Domain/Local/RootKey/RootKeyInterface.ts
Normal file
17
packages/models/src/Domain/Local/RootKey/RootKeyInterface.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { ProtocolVersion } from '@standardnotes/common'
|
||||
import { DecryptedItemInterface } from '../../Abstract/Item/Interfaces/DecryptedItem'
|
||||
import { RootKeyParamsInterface } from '../KeyParams/RootKeyParamsInterface'
|
||||
import { NamespacedRootKeyInKeychain, RootKeyContentInStorage } from './KeychainTypes'
|
||||
import { RootKeyContent } from './RootKeyContent'
|
||||
|
||||
export interface RootKeyInterface extends DecryptedItemInterface<RootKeyContent> {
|
||||
readonly keyParams: RootKeyParamsInterface
|
||||
get keyVersion(): ProtocolVersion
|
||||
get itemsKey(): string
|
||||
get masterKey(): string
|
||||
get serverPassword(): string | undefined
|
||||
get dataAuthenticationKey(): string | undefined
|
||||
compare(otherKey: RootKeyInterface): boolean
|
||||
persistableValueWhenWrapping(): RootKeyContentInStorage
|
||||
getKeychainValue(): NamespacedRootKeyInKeychain
|
||||
}
|
||||
Reference in New Issue
Block a user