Skip to content

Commit 45e8cad

Browse files
authored
[P2] Implement Backup & Recovery API Methods (#27)
* Implement backup & recovery API methods matching ZHTP node endpoints Added missing getBackupStatus() method and fixed parameter/type mismatches: - Added getBackupStatus(identityId) method for GET /api/v1/identity/backup/status - Fixed exportBackup() and importBackup() to use 'passphrase' instead of 'password' - Updated BackupData type to match node response: { backup_data, created_at } - Updated SeedVerification type to match node response: { verified } - Added ImportBackupResponse type for proper import response handling - Added comprehensive tests for all backup/recovery methods - Fixed existing tests to match updated parameter names and response types All backup/recovery methods now match ZHTP node implementation exactly. * Add security improvements and validation to backup/recovery methods Addresses code review feedback by adding: Security Documentation: - Added comprehensive JSDoc comments with security warnings - Documented rate limiting (3 attempts/hour for import/recovery) - Added passphrase strength requirements - Warned about sensitive data handling Client-side Validation: - exportBackup: Validates passphrase minimum 12 characters - importBackup: Validates passphrase minimum 12 characters - verifySeedPhrase: Validates seed phrase has exactly 12 words Test Coverage: - Added 4 new test cases for validation errors - Tests for short passphrase rejection - Tests for invalid seed phrase word count All 63 tests passing. Ready for production use.
1 parent 19fa5ba commit 45e8cad

File tree

11 files changed

+405
-57
lines changed

11 files changed

+405
-57
lines changed

dist/core/types.d.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,8 @@ export interface CitizenshipResult {
249249
};
250250
}
251251
export interface BackupData {
252-
version: string;
253-
encrypted_data: string;
254-
metadata: {
255-
created_at: number;
256-
identity_id: string;
257-
backup_type: string;
258-
};
252+
backup_data: string;
253+
created_at: number;
259254
}
260255
export interface BackupVerification {
261256
valid: boolean;
@@ -265,17 +260,28 @@ export interface BackupVerification {
265260
errors: string[];
266261
warnings: string[];
267262
}
263+
export interface ImportBackupResponse {
264+
status: string;
265+
identity: {
266+
identity_id: string;
267+
did: string;
268+
};
269+
session_token: string;
270+
}
268271
export interface SeedVerification {
269-
valid: boolean;
270-
wallet_id?: string;
271-
wallet_type?: string;
272+
verified: boolean;
272273
}
273274
export interface SeedPhrases {
274275
primary?: string[];
275276
ubi?: string[];
276277
savings?: string[];
277278
master?: string[];
278279
}
280+
export interface BackupStatus {
281+
has_recovery_phrase: boolean;
282+
backup_date: number | null;
283+
verified: boolean;
284+
}
279285
export interface Guardian {
280286
guardian_id: string;
281287
guardian_name?: string;

dist/core/types.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)