-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Overview
Implement complete backup and recovery API methods to match the ZHTP node's fully implemented backup/recovery system.
Parent Issue
Part of #17 - Priority 2 tasks
Node Status
✅ All 7 backup/recovery endpoints implemented on node (Issue #115 - CLOSED)
Missing/Incomplete Methods
Backup & Recovery (7 endpoints)
-
✅
generateRecoveryPhrase()- May need verification- POST
/api/v1/identity/backup/generate
- POST
-
✅
verifyRecoveryPhrase()- May need verification- POST
/api/v1/identity/backup/verify
- POST
-
✅
recoverIdentity()- May need verification- POST
/api/v1/identity/recover
- POST
-
❌
getBackupStatus()- MISSING- GET
/api/v1/identity/backup/status
- GET
-
✅
exportBackup()- Implemented, verify alignment- POST
/api/v1/identity/backup/export
- POST
-
✅
importBackup()- Implemented, verify alignment- POST
/api/v1/identity/backup/import
- POST
-
✅
verifySeedPhrase()- Implemented, verify alignment- POST
/api/v1/identity/seed/verify
- POST
TypeScript Types Needed
interface GenerateRecoveryPhraseRequest {
identity_id: string;
session_token: string;
}
interface GenerateRecoveryPhraseResponse {
status: string;
phrase_hash: string;
recovery_phrase?: string; // Returned ONCE only
instructions: string;
}
interface VerifyRecoveryPhraseRequest {
identity_id: string;
recovery_phrase: string; // 20 words
}
interface RecoverIdentityRequest {
recovery_phrase: string; // 20 words
}
interface BackupStatusResponse {
has_recovery_phrase: boolean;
backup_date?: number;
verified: boolean;
}
interface ExportBackupRequest {
identity_id: string;
passphrase: string; // Min 12 characters
}
interface ExportBackupResponse {
backup_data: string; // Base64 encoded
created_at: number;
}
interface ImportBackupRequest {
backup_data: string; // Base64
passphrase: string;
}
interface VerifySeedPhraseRequest {
identity_id: string;
seed_phrase: string; // 12 words BIP39
}Implementation Tasks
1. Add Missing Method
- Implement
getBackupStatus(identity_id: string): Promise<BackupStatusResponse>
2. Verify Existing Methods
- Verify
exportBackup()request/response matches node - Verify
importBackup()request/response matches node - Verify
verifySeedPhrase()for 12-word BIP39 support - Verify
recoverIdentity()uses 20-word phrases
3. Update Type Definitions
- Add/update types in
src/core/types.ts - Ensure 20-word recovery phrase support
- Ensure 12-word seed phrase support
- Add backup status types
4. Security Considerations
- Implement zeroization for passphrases (if applicable in TS)
- Add warnings about recovery phrase security
- Document passphrase minimum length (12 chars)
- Note rate limits in JSDoc comments
5. Testing
- Unit tests for all backup/recovery methods
- Integration tests with node
- Test error handling
- Test passphrase validation
Security Notes from Node
Rate Limits:
- Export: 5 requests/hour per IP
- Import: 3 requests/hour per IP
- Recovery: 3 requests/hour per IP
Passphrase Requirements:
- Minimum 12 characters
- Maximum 128 characters
- Zeroized after use on node side
Recovery Phrases:
- 20 words (not BIP39, custom system)
- Returned ONCE on generation
- Never logged or cached
Seed Phrases:
- 12 words (BIP39 compatible)
- For wallet recovery
Acceptance Criteria
- All 7 endpoints have corresponding methods
- Type definitions complete and accurate
- JSDoc documentation for all methods
- Security warnings documented
- Unit tests pass
- Integration tests pass
- README updated with backup/recovery examples
Related Issues
- Parent: [IMPLEMENTATION GUIDE] Complete ZHTP Node API Endpoint Reference #17
- Node: [API] Identity backup and recovery endpoints (7 endpoints) The-Sovereign-Network#115 (closed)
- API Client: [FRONTEND]: Backup and recovery system missing in ZHTP node #4
Estimated Effort
Medium - 4-6 hours
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request