@ -137,18 +137,18 @@ class SecureElementStorage implements CredentialStorage {
private async writeToSecureElement ( key : string , _data : string ) : Promise < void > {
private async writeToSecureElement ( key : string , _data : string ) : Promise < void > {
// Mock secure element write - in production would use platform APIs
// Mock secure element write - in production would use platform APIs
console . log ( ` Mock secure element write: ${ key } ` ) ;
// Mock secure element write operation
}
}
private async readFromSecureElement ( key : string ) : Promise < string | null > {
private async readFromSecureElement ( key : string ) : Promise < string | null > {
// Mock secure element read - in production would use platform APIs
// Mock secure element read - in production would use platform APIs
console . log ( ` Mock secure element read: ${ key } ` ) ;
// Mock secure element read operation
return ` {"did":" ${ key } ", "keyType":"secp256k1", "timestamp": ${ Date . now ( ) } , "encrypted":true} ` ;
return ` {"did":" ${ key } ", "keyType":"secp256k1", "timestamp": ${ Date . now ( ) } , "encrypted":true} ` ;
}
}
private async deleteFromSecureElement ( key : string ) : Promise < void > {
private async deleteFromSecureElement ( key : string ) : Promise < void > {
// Mock secure element delete - in production would use platform APIs
// Mock secure element delete - in production would use platform APIs
console . log ( ` Mock secure element delete: ${ key } ` ) ;
// Mock secure element delete operation
}
}
}
}
@ -172,7 +172,7 @@ export class SecurityManager {
* /
* /
async initialize ( activeDid : string ) : Promise < boolean > {
async initialize ( activeDid : string ) : Promise < boolean > {
try {
try {
console . log ( 'Initializing SecurityManager for DID:' , activeDid ) ;
// Initializing SecurityManager for DID
this . activeDid = activeDid ;
this . activeDid = activeDid ;
@ -180,7 +180,7 @@ export class SecurityManager {
this . activeCredentials = await this . credentialStorage . retrieveCredentials ( activeDid ) ;
this . activeCredentials = await this . credentialStorage . retrieveCredentials ( activeDid ) ;
if ( ! this . activeCredentials ) {
if ( ! this . activeCredentials ) {
console . log ( 'No stored credentials found, initializing new ones' ) ;
// No stored credentials found, initializing new ones
const newCredentials = await this . generateNewCredentials ( activeDid ) ;
const newCredentials = await this . generateNewCredentials ( activeDid ) ;
if ( newCredentials ) {
if ( newCredentials ) {
@ -189,7 +189,7 @@ export class SecurityManager {
}
}
}
}
console . log ( 'SecurityManager initialized successfully' ) ;
// SecurityManager initialized successfully
return true ;
return true ;
} catch ( error ) {
} catch ( error ) {
@ -203,7 +203,7 @@ export class SecurityManager {
* /
* /
async generateNewCredentials ( did : string ) : Promise < DIDCredentials | null > {
async generateNewCredentials ( did : string ) : Promise < DIDCredentials | null > {
try {
try {
console . log ( 'Generating new credentials for DID:' , did ) ;
// Generating new credentials for DID
const credentials : DIDCredentials = {
const credentials : DIDCredentials = {
did ,
did ,
@ -254,7 +254,7 @@ export class SecurityManager {
publicKey : ` mock_public_key_ ${ keyType } _ ${ timestamp } `
publicKey : ` mock_public_key_ ${ keyType } _ ${ timestamp } `
} ;
} ;
console . log ( ` Generated ${ keyType } keys for secure operations ` ) ;
// Generated keys for secure operations
return mockKeys ;
return mockKeys ;
} catch ( error ) {
} catch ( error ) {
@ -272,7 +272,7 @@ export class SecurityManager {
throw new Error ( 'No active DID or credentials available' ) ;
throw new Error ( 'No active DID or credentials available' ) ;
}
}
console . log ( 'Generating JWT for DID:' , this . activeDid ) ;
// Generating JWT for DID
const now = Math . floor ( Date . now ( ) / 1000 ) ;
const now = Math . floor ( Date . now ( ) / 1000 ) ;
const fullClaims : JWTClaims = {
const fullClaims : JWTClaims = {
@ -304,7 +304,7 @@ export class SecurityManager {
operation : 'generate_jwt'
operation : 'generate_jwt'
} ) ;
} ) ;
console . log ( 'JWT generated successfully' ) ;
// JWT generated successfully
return jwt ;
return jwt ;
} catch ( error ) {
} catch ( error ) {
@ -340,7 +340,7 @@ export class SecurityManager {
const jwt = ` ${ encodedHeader } . ${ encodedPayload } . ${ signature } ` ;
const jwt = ` ${ encodedHeader } . ${ encodedPayload } . ${ signature } ` ;
console . log ( ` Generated signed JWT with ${ this . config . signatureAlgorithm } ` ) ;
// Generated signed JWT
return jwt ;
return jwt ;
} catch ( error ) {
} catch ( error ) {
@ -364,7 +364,7 @@ export class SecurityManager {
const jwt = ` ${ encodedHeader } . ${ encodedPayload } . ` ;
const jwt = ` ${ encodedHeader } . ${ encodedPayload } . ` ;
console . log ( 'Generated unsigned JWT (development mode)' ) ;
// Generated unsigned JWT (development mode)
return jwt ;
return jwt ;
} catch ( error ) {
} catch ( error ) {
@ -378,7 +378,7 @@ export class SecurityManager {
* /
* /
async verifyJWT ( token : string ) : Promise < JWTClaims | null > {
async verifyJWT ( token : string ) : Promise < JWTClaims | null > {
try {
try {
console . log ( 'Verifying JWT token' ) ;
// Verifying JWT token
const parts = token . split ( '.' ) ;
const parts = token . split ( '.' ) ;
if ( parts . length !== 3 ) {
if ( parts . length !== 3 ) {
@ -409,7 +409,7 @@ export class SecurityManager {
operation : 'verify_jwt'
operation : 'verify_jwt'
} ) ;
} ) ;
console . log ( 'JWT verified successfully' ) ;
// JWT verified successfully
return claims ;
return claims ;
} catch ( error ) {
} catch ( error ) {
@ -489,7 +489,7 @@ export class SecurityManager {
// Clear operation history
// Clear operation history
this . operationHistory = [ ] ;
this . operationHistory = [ ] ;
console . log ( 'SecurityManager reset completed' ) ;
// SecurityManager reset completed
} catch ( error ) {
} catch ( error ) {
console . error ( 'Error resetting SecurityManager:' , error ) ;
console . error ( 'Error resetting SecurityManager:' , error ) ;
@ -501,13 +501,13 @@ export class SecurityManager {
* /
* /
async updateActiveDid ( newActiveDid : string ) : Promise < boolean > {
async updateActiveDid ( newActiveDid : string ) : Promise < boolean > {
try {
try {
console . log ( 'Updating active DID to:' , newActiveDid ) ;
// Updating active DID
// Retrieve credentials for new DID
// Retrieve credentials for new DID
const credentials = await this . credentialStorage . retrieveCredentials ( newActiveDid ) ;
const credentials = await this . credentialStorage . retrieveCredentials ( newActiveDid ) ;
if ( ! credentials ) {
if ( ! credentials ) {
console . log ( 'No credentials found for new DID, generating new ones' ) ;
// No credentials found for new DID, generating new ones
const newCredentials = await this . generateNewCredentials ( newActiveDid ) ;
const newCredentials = await this . generateNewCredentials ( newActiveDid ) ;
if ( newCredentials ) {
if ( newCredentials ) {
@ -522,7 +522,7 @@ export class SecurityManager {
this . activeDid = newActiveDid ;
this . activeDid = newActiveDid ;
console . log ( 'Active DID updated successfully' ) ;
// Active DID updated successfully
return true ;
return true ;
} catch ( error ) {
} catch ( error ) {