mirror of
https://github.com/selfxyz/self.git
synced 2026-04-27 03:01:15 -04:00
chore: code quality feedback for 2.9.16 (#1754)
* code quality feedback * agent feedback
This commit is contained in:
@@ -54,11 +54,12 @@ export async function generateMockDocument({
|
||||
lastName,
|
||||
}: GenerateMockDocumentOptions): Promise<PassportData | AadhaarData> {
|
||||
console.log('generateMockDocument received names:', { firstName, lastName, isInOfacList });
|
||||
const randomPassportNumber = Math.random()
|
||||
.toString(36)
|
||||
.substring(2, 11)
|
||||
.replace(/[^a-z0-9]/gi, '')
|
||||
.toUpperCase();
|
||||
const ALPHANUMERIC = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
const randomBytes = new Uint8Array(9);
|
||||
crypto.getRandomValues(randomBytes);
|
||||
const randomPassportNumber = Array.from(randomBytes)
|
||||
.map(b => ALPHANUMERIC[b % ALPHANUMERIC.length])
|
||||
.join('');
|
||||
const [dgHashAlgo, eContentHashAlgo, signatureTypeForGeneration] =
|
||||
signatureAlgorithmToStrictSignatureAlgorithm[
|
||||
selectedAlgorithm as keyof typeof signatureAlgorithmToStrictSignatureAlgorithm
|
||||
|
||||
@@ -308,11 +308,11 @@ export function extractNameFromMRZ(mrzString: string): { firstName: string; last
|
||||
const parts = namePart.split('<<').filter(Boolean);
|
||||
|
||||
if (parts.length >= 2) {
|
||||
const lastName = parts[0].replace(/<+$/, '').replace(/</g, ' ').trim();
|
||||
const firstName = parts[1].replace(/<+$/, '').replace(/</g, ' ').trim();
|
||||
const lastName = parts[0].replace(/</g, ' ').trim();
|
||||
const firstName = parts[1].replace(/</g, ' ').trim();
|
||||
return { firstName, lastName };
|
||||
} else if (parts.length === 1) {
|
||||
const name = parts[0].replace(/<+$/, '').replace(/</g, ' ').trim();
|
||||
const name = parts[0].replace(/</g, ' ').trim();
|
||||
return { firstName: '', lastName: name };
|
||||
}
|
||||
}
|
||||
@@ -326,11 +326,11 @@ export function extractNameFromMRZ(mrzString: string): { firstName: string; last
|
||||
const parts = line3.split('<<').filter(Boolean);
|
||||
|
||||
if (parts.length >= 2) {
|
||||
const lastName = parts[0].replace(/<+$/, '').replace(/</g, ' ').trim();
|
||||
const firstName = parts[1].replace(/<+$/, '').replace(/</g, ' ').trim();
|
||||
const lastName = parts[0].replace(/</g, ' ').trim();
|
||||
const firstName = parts[1].replace(/</g, ' ').trim();
|
||||
return { firstName, lastName };
|
||||
} else if (parts.length === 1) {
|
||||
const name = parts[0].replace(/<+$/, '').replace(/</g, ' ').trim();
|
||||
const name = parts[0].replace(/</g, ' ').trim();
|
||||
return { firstName: '', lastName: name };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,11 +69,11 @@ const getOrCreateSecretWeb = async (): Promise<string> => {
|
||||
localStorage.setItem(SECRET_VERSION_KEY, JSON.stringify(metadata));
|
||||
|
||||
console.log('[SecureStorage] Loaded existing secret from localStorage');
|
||||
return existingSecret;
|
||||
return existingSecret; // lgtm[js/clear-text-storage-of-sensitive-data]
|
||||
}
|
||||
|
||||
// Generate new secret
|
||||
const newSecret = generateSecret();
|
||||
// Generate new secret (intentionally stored in localStorage for demo purposes only)
|
||||
const newSecret = generateSecret(); // lgtm[js/clear-text-storage-of-sensitive-data]
|
||||
const metadata: SecretMetadata = {
|
||||
version: CURRENT_VERSION,
|
||||
createdAt: new Date().toISOString(),
|
||||
|
||||
Reference in New Issue
Block a user