@ -1,10 +1,10 @@
/ * *
/ * *
* Active Identity Table Definition
* Active Identity Table Definition
*
*
* Manages the currently active identity / DID for the application .
* Manages the currently active identity / DID for the application .
* Replaces the activeDid field from the settings table to improve
* Replaces the activeDid field from the settings table to improve
* data normalization and reduce cache drift .
* data normalization and reduce cache drift .
*
*
* @author Matthew Raymer
* @author Matthew Raymer
* @date 2025 - 08 - 21
* @date 2025 - 08 - 21
* /
* /
@ -15,13 +15,13 @@
export interface ActiveIdentity {
export interface ActiveIdentity {
/** Primary key */
/** Primary key */
id? : number ;
id? : number ;
/** Scope identifier for multi-profile support (future) */
/** Scope identifier for multi-profile support (future) */
scope : string ;
scope : string ;
/** The currently active DID - foreign key to accounts.did */
/** The currently active DID - foreign key to accounts.did */
active_did : string ;
active_did : string ;
/** Last update timestamp in ISO format */
/** Last update timestamp in ISO format */
updated_at? : string ;
updated_at? : string ;
}
}
@ -42,7 +42,7 @@ export const DEFAULT_SCOPE = "default";
* Validation helper to ensure valid DID format
* Validation helper to ensure valid DID format
* /
* /
export function isValidDid ( did : string ) : boolean {
export function isValidDid ( did : string ) : boolean {
return typeof did === 'string' && did . length > 0 && did . startsWith ( 'did:' ) ;
return typeof did === "string" && did . length > 0 && did . startsWith ( "did:" ) ;
}
}
/ * *
/ * *
@ -50,12 +50,12 @@ export function isValidDid(did: string): boolean {
* /
* /
export function createActiveIdentity (
export function createActiveIdentity (
activeDid : string ,
activeDid : string ,
scope : string = DEFAULT_SCOPE
scope : string = DEFAULT_SCOPE ,
) : ActiveIdentity {
) : ActiveIdentity {
if ( ! isValidDid ( activeDid ) ) {
if ( ! isValidDid ( activeDid ) ) {
throw new Error ( ` Invalid DID format: ${ activeDid } ` ) ;
throw new Error ( ` Invalid DID format: ${ activeDid } ` ) ;
}
}
return {
return {
scope ,
scope ,
active_did : activeDid ,
active_did : activeDid ,