{
  "name": "bap-identity-types-migration",
  "type": "registry:component",
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "components/bap-identity/types/migration.ts",
      "type": "registry:component",
      "content": "// Master Key Migration Types\n\nexport type MigrationState = \"ready\" | \"migrating\" | \"completed\" | \"failed\";\n\nexport type BackupFormat = \"legacy\" | \"type42\";\n\nexport interface LegacyMasterBackup {\n\tids: string; // Encrypted BAP identity data\n\txprv: string; // Master extended private key (BIP32)\n\tmnemonic: string; // BIP39 mnemonic phrase\n\tlabel?: string; // Optional user label\n\tcreatedAt?: string; // ISO 8601 timestamp\n}\n\nexport interface Type42MasterBackup {\n\tids: string; // Encrypted BAP identity data\n\trootPk: string; // Master private key in WIF format (Type 42)\n\tlabel?: string; // Optional user label\n\tcreatedAt?: string; // ISO 8601 timestamp\n}\n\nexport interface MigrationResult {\n\tsuccess: boolean;\n\tnewBackup?: Type42MasterBackup;\n\terror?: Error;\n\twarning?: string;\n}\n\nexport interface MasterKeyMigrationProps {\n\t/**\n\t * Callback when migration completes successfully\n\t */\n\tonMigrationComplete?: (newBackup: Type42MasterBackup) => void;\n\n\t/**\n\t * Callback when user chooses to skip migration\n\t */\n\tonSkipMigration?: () => void;\n\n\t/**\n\t * Theme variant for the component\n\t */\n\tvariant?: \"surface\" | \"ghost\" | \"classic\";\n\n\t/**\n\t * Size of the component\n\t */\n\tsize?: \"1\" | \"2\" | \"3\";\n}\n\nexport interface BackupFormatDetectionResult {\n\tformat: BackupFormat;\n\tisValid: boolean;\n\thasEncryptedData: boolean;\n\tkeyInfo: {\n\t\thasXprv: boolean;\n\t\thasMnemonic: boolean;\n\t\thasRootPk: boolean;\n\t\thasIds: boolean;\n\t};\n\testimatedCreationDate?: string;\n}\n\nexport interface MigrationOptions {\n\t/**\n\t * Whether to preserve the original backup alongside the new one\n\t */\n\tpreserveOriginal?: boolean;\n\n\t/**\n\t * Custom label for the migrated backup\n\t */\n\tnewLabel?: string;\n\n\t/**\n\t * Whether to automatically sign in with the new backup after migration\n\t */\n\tautoSignIn?: boolean;\n\n\t/**\n\t * Custom password for the new backup (uses current password if not provided)\n\t */\n\tnewPassword?: string;\n}\n\nexport interface IdentityMigrationData {\n\tlegacyIdentities: Array<{\n\t\tidKey: string;\n\t\taddresses: string[];\n\t\tattestations: unknown[];\n\t\tcurrentPath: string;\n\t\trootPath: string;\n\t}>;\n\tnewIdentities: Array<{\n\t\tidKey: string;\n\t\tcounter: number;\n\t\taddress: string;\n\t}>;\n}\n\n// Hook return types\nexport interface UseMasterKeyMigrationResult {\n\t/**\n\t * Detect the format of a backup\n\t */\n\tdetectBackupFormat: (backup: unknown) => BackupFormatDetectionResult;\n\n\t/**\n\t * Check if current user has legacy master backup that can be migrated\n\t */\n\tcanMigrate: boolean;\n\n\t/**\n\t * Check if current user already has Type 42 backup\n\t */\n\thasType42Backup: boolean;\n\n\t/**\n\t * Perform the migration\n\t */\n\tmigrate: (options?: MigrationOptions) => Promise<MigrationResult>;\n\n\t/**\n\t * Get current backup format info\n\t */\n\tcurrentBackupInfo: BackupFormatDetectionResult | null;\n\n\t/**\n\t * Migration state\n\t */\n\tisLoading: boolean;\n\terror: Error | null;\n\tprogress: number;\n}\n\n// Component props for format detector\nexport interface BackupFormatDetectorProps {\n\t/**\n\t * Backup data to analyze\n\t */\n\tbackup: unknown;\n\n\t/**\n\t * Callback when format is detected\n\t */\n\tonFormatDetected?: (result: BackupFormatDetectionResult) => void;\n\n\t/**\n\t * Whether to show detailed information\n\t */\n\tshowDetails?: boolean;\n\n\t/**\n\t * Component size\n\t */\n\tsize?: \"1\" | \"2\" | \"3\";\n}\n\n// Enhanced backup format validation\nexport interface BackupValidationError {\n\tfield: string;\n\tmessage: string;\n\tseverity: \"error\" | \"warning\";\n}\n\nexport interface BackupValidationResult extends BackupFormatDetectionResult {\n\terrors: BackupValidationError[];\n\twarnings: BackupValidationError[];\n\tcanProceed: boolean;\n}\n\n// Migration warning types\nexport type MigrationWarning =\n\t| \"identity_keys_will_change\"\n\t| \"attestations_not_transferable\"\n\t| \"legacy_backup_preserved\"\n\t| \"new_addresses_generated\"\n\t| \"requires_new_attestations\";\n\nexport interface MigrationWarningInfo {\n\ttype: MigrationWarning;\n\ttitle: string;\n\tdescription: string;\n\tseverity: \"info\" | \"warning\" | \"critical\";\n}\n",
      "target": "<%- config.aliases.components %>/migration.tsx"
    }
  ]
}