This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

fix revoke

+72 -35
+72 -35
src/components/Verifier/Verifier.js
··· 940 940 } 941 941 942 942 setIsRevoking(true); 943 - setBulkRevokeStatus(`Fetching members of list: ${selectedList.name}...`); 943 + setBulkRevokeStatus(`Fetching members of ${sourceDescription}...`); 944 944 setBulkRevokeProgress(''); 945 945 setRevokeStatusMessage(''); // Clear single revoke status 946 946 ··· 986 986 return; 987 987 } 988 988 989 - // Filter existing verifications to find those matching list members 990 - const verificationsToRevoke = verifications.filter(verification => 991 - listMemberDids.has(verification.subject) 989 + // *** Fetch ALL existing verification records *** 990 + setBulkRevokeStatus(`Fetching all your existing verification records...`); 991 + const allVerificationRecords = await fetchAllPaginated( 992 + agent.api.com.atproto.repo, // Context: repo API 993 + 'listRecords', // Method: listRecords 994 + { // Params: 995 + repo: session.did, 996 + collection: 'app.bsky.graph.verification', 997 + limit: 100 // fetchAllPaginated handles pagination 998 + }, 999 + false // Use agent method 1000 + ); 1001 + console.log(`Fetched ${allVerificationRecords.length} total verification records.`); 1002 + 1003 + // Filter the *complete* list of verifications to find those matching list members 1004 + const verificationsToRevoke = allVerificationRecords.filter(record => 1005 + record.value?.subject && listMemberDids.has(record.value.subject) 992 1006 ); 993 1007 994 1008 totalToRevoke = verificationsToRevoke.length; ··· 1002 1016 1003 1017 // Iterate and revoke each matching verification 1004 1018 for (let i = 0; i < verificationsToRevoke.length; i++) { 1005 - const verification = verificationsToRevoke[i]; 1006 - const handle = verification.handle || verification.subject; // Use handle if available 1019 + const verificationRecord = verificationsToRevoke[i]; 1020 + // Use handle from record value if available, fallback to subject DID 1021 + const handle = verificationRecord.value?.handle || verificationRecord.value?.subject || 'unknown'; 1007 1022 setBulkRevokeProgress(`Revoking ${i + 1} of ${totalToRevoke}: @${handle}`); 1008 1023 1009 1024 try { 1010 - const parts = verification.uri.split('/'); 1025 + const parts = verificationRecord.uri.split('/'); 1011 1026 const rkey = parts[parts.length - 1]; 1012 1027 1013 1028 await agent.api.com.atproto.repo.deleteRecord({ ··· 1017 1032 }); 1018 1033 successCount++; 1019 1034 } catch (error) { 1020 - console.error(`Failed to revoke @${handle} (URI: ${verification.uri}):`, error); 1035 + console.error(`Failed to revoke @${handle} (URI: ${verificationRecord.uri}):`, error); 1021 1036 failureCount++; 1022 1037 errors.push(`@${handle}: ${error.message || 'Unknown error'}`); 1023 1038 } ··· 1032 1047 finalMessage += `Check console for details on failures.`; 1033 1048 } 1034 1049 setBulkRevokeStatus(finalMessage); 1035 - fetchVerifications(); // Refresh the list of verified accounts 1050 + fetchVerifications(); // Refresh the list of verified accounts displayed in UI 1036 1051 setSelectedListUriForRevoke(''); // Reset selection 1037 1052 1038 1053 } catch (error) { ··· 1046 1061 1047 1062 // Handler for revoking by time range 1048 1063 const handleRevokeByTime = async () => { 1049 - if (!agent || !session || !revokeTimeRange || verifications.length === 0) { 1050 - setBulkRevokeStatus('Cannot revoke by time: Missing agent, session, time range, or no verifications found.'); 1064 + if (!agent || !session || !revokeTimeRange) { 1065 + setBulkRevokeStatus('Cannot revoke by time: Missing agent, session, or time range.'); 1051 1066 return; 1052 1067 } 1053 1068 ··· 1069 1084 return; 1070 1085 } 1071 1086 1072 - // Filter verifications created after the cutoff time 1073 - const verificationsToRevoke = verifications.filter(v => 1074 - new Date(v.createdAt) > cutoffTime 1075 - ); 1076 - 1077 - const count = verificationsToRevoke.length; 1078 - if (count === 0) { 1079 - setBulkRevokeStatus(`No verifications found created within the selected time range (${revokeTimeRange}).`); 1080 - return; 1081 - } 1082 - 1083 - // Confirmation dialog 1084 - if (!window.confirm(`Are you sure you want to revoke ${count} verification(s) created in the last ${revokeTimeRange}? This cannot be undone.`)) { 1085 - return; 1086 - } 1087 - 1088 1087 setIsRevoking(true); 1089 - setBulkRevokeStatus(`Starting revocation for ${count} record(s) created in the last ${revokeTimeRange}...`); 1088 + setBulkRevokeStatus('Fetching all your verification records...'); 1090 1089 setBulkRevokeProgress(''); 1091 - setRevokeStatusMessage(''); // Clear single revoke status 1090 + setRevokeStatusMessage(''); 1092 1091 1093 1092 let successCount = 0; 1094 1093 let failureCount = 0; 1095 1094 const errors = []; 1095 + let verificationsToRevoke = []; 1096 + let count = 0; 1096 1097 1097 1098 try { 1099 + // *** Fetch ALL existing verification records *** 1100 + const allVerificationRecords = await fetchAllPaginated( 1101 + agent.api.com.atproto.repo, // Context: repo API 1102 + 'listRecords', // Method: listRecords 1103 + { // Params: 1104 + repo: session.did, 1105 + collection: 'app.bsky.graph.verification', 1106 + limit: 100 // fetchAllPaginated handles pagination 1107 + }, 1108 + false // Use agent method 1109 + ); 1110 + console.log(`Fetched ${allVerificationRecords.length} total verification records for time-based revocation.`); 1111 + 1112 + // Filter the *complete* list based on creation time 1113 + verificationsToRevoke = allVerificationRecords.filter(record => 1114 + record.value?.createdAt && new Date(record.value.createdAt) > cutoffTime 1115 + ); 1116 + 1117 + count = verificationsToRevoke.length; 1118 + if (count === 0) { 1119 + setBulkRevokeStatus(`No verifications found created within the selected time range (${revokeTimeRange}).`); 1120 + setIsRevoking(false); // Stop early 1121 + return; 1122 + } 1123 + 1124 + // Confirmation dialog (now that we know the count) 1125 + if (!window.confirm(`Are you sure you want to revoke ${count} verification(s) created in the last ${revokeTimeRange}? This cannot be undone.`)) { 1126 + setIsRevoking(false); // User cancelled 1127 + setBulkRevokeStatus('Time-based revocation cancelled.'); 1128 + return; 1129 + } 1130 + 1131 + setBulkRevokeStatus(`Starting revocation for ${count} record(s) created in the last ${revokeTimeRange}...`); 1132 + 1098 1133 // Iterate and revoke each matching verification 1099 1134 for (let i = 0; i < verificationsToRevoke.length; i++) { 1100 - const verification = verificationsToRevoke[i]; 1101 - const handle = verification.handle || verification.subject; // Use handle if available 1102 - setBulkRevokeProgress(`Revoking ${i + 1} of ${count}: @${handle} (Created: ${new Date(verification.createdAt).toLocaleTimeString()})`); 1135 + const verificationRecord = verificationsToRevoke[i]; 1136 + // Use handle from record value if available, fallback to subject DID 1137 + const handle = verificationRecord.value?.handle || verificationRecord.value?.subject || 'unknown'; 1138 + const createdAtStr = verificationRecord.value?.createdAt ? new Date(verificationRecord.value.createdAt).toLocaleTimeString() : 'unknown time'; 1139 + setBulkRevokeProgress(`Revoking ${i + 1} of ${count}: @${handle} (Created: ${createdAtStr})`); 1103 1140 1104 1141 try { 1105 - const parts = verification.uri.split('/'); 1142 + const parts = verificationRecord.uri.split('/'); 1106 1143 const rkey = parts[parts.length - 1]; 1107 1144 1108 1145 await agent.api.com.atproto.repo.deleteRecord({ ··· 1112 1149 }); 1113 1150 successCount++; 1114 1151 } catch (error) { 1115 - console.error(`Failed to revoke @${handle} (URI: ${verification.uri}):`, error); 1152 + console.error(`Failed to revoke @${handle} (URI: ${verificationRecord.uri}):`, error); 1116 1153 failureCount++; 1117 1154 errors.push(`@${handle}: ${error.message || 'Unknown error'}`); 1118 1155 } ··· 1127 1164 finalMessage += `Check console for details on failures.`; 1128 1165 } 1129 1166 setBulkRevokeStatus(finalMessage); 1130 - fetchVerifications(); // Refresh the list of verified accounts 1167 + fetchVerifications(); // Refresh the list of verified accounts displayed in UI 1131 1168 1132 1169 } catch (error) { 1133 1170 console.error('Error during time-based revocation process:', error);