refactor(model): ♻️ rename type string to Base64String where is meaningful

This commit is contained in:
Julien Oculi 2024-06-17 13:40:18 +02:00
parent dda72bf67d
commit 3c773bca6b
2 changed files with 26 additions and 15 deletions

View file

@ -1,4 +1,4 @@
import { ToJson } from '@/types.ts' import type { Base64String, ToJson, UUID } from '@/types.ts'
import { Ressource } from '@models/ressource.ts' import { Ressource } from '@models/ressource.ts'
export class Credential extends Ressource { export class Credential extends Ressource {
@ -77,29 +77,38 @@ export interface Credential extends Ressource {
type CredentialCategory<T extends 'password' | 'ssh' | 'passkey'> = T extends type CredentialCategory<T extends 'password' | 'ssh' | 'passkey'> = T extends
'password' ? { 'password' ? {
store: { store: {
hash: string //hex or b64 of Uint8Array hash: Base64String
alg: string alg: string
salt: string //hex or b64 of Uint8Array salt: Base64String
} }
} }
: T extends 'ssh' ? { : T extends 'ssh' ? {
store: { store: {
publicKey: string publicKey: Base64String
} }
} }
: T extends 'passkey' ? { : T extends 'passkey' ? {
store: Record<string, unknown> store: Passkey
} }
: never : never
/* /** Passkey store */
PassKey store: type Passkey = {
{ /** User UUID */
publicKey: Uint8Array user: UUID
keyId: string /** WebAuthn registration key id */
transport: string webAuthnUserID: string
/** Passkey credential unique id */
id: string
/** Passkey user public key */
publicKey: Base64String
/** Number of times the authenticator has been used */
counter: number counter: number
/** Whether the passkey is single-device or multi-device */
deviceType: 'singleDevice' | 'multiDevice'
/** Whether the passkey has been backed up in some way */
backedUp: boolean
/** Passkey physical transport layer */
transports?:
('ble' | 'cable' | 'hybrid' | 'internal' | 'nfc' | 'smart-card' | 'usb')[]
} }
*/
//new Uint8Array(Object.values(JSON.parse(JSON.stringify(new Uint8Array([1, 2, 3])))))

View file

@ -26,3 +26,5 @@ export type Posix = {
home: string home: string
shell: string shell: string
} }
export type Base64String = string