mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
[SELF-830] feat: demo app nfc scanning (#1236)
* save wip demo app nfc scanning * save wip * fix types * Fix Android NFC scanning in demo app (#1241) * fix tests * fix pipelines * fix linting * WIP move to flows/onboarding/scan-nfc * prettier and fix test * fix test * update lock * update deps * Feat/android prebuilt modules (#1292) * move entire screen * remove redundancy in components and utils * fixes * lint * ignore * remove unneeded * fix imports * remove unused * Update packages/mobile-sdk-alpha/src/types/events.ts Co-authored-by: Aaron DeRuvo <aaron.deruvo@clabs.co> * uuid not needed for demo app * android: update ci check * timeout fix, image temp fix * prettier fix * try rebuild deps every time * Temporarily disable cache check in CI * Revert "try rebuild deps every time" This reverts commita5c97210a5. * ignore false positive * Revert "Revert "try rebuild deps every time"" This reverts commit4f44615fd6. * fix? * sanitize error message first * remove TODO that has been taken care of * MSDK: add ios prebuilts (#1308) * add ios prebuilt * remove outdate readme * remove duplicates * comment out unused * add prettier ignore * Update .gitguardian.yml to ignore iOS frameworks and build artifacts * update gitguardian ignore paths * migrate config version * add ignored-matches --------- Co-authored-by: Justin Hernandez <justin.hernandez@self.xyz> * remove duplicated code * exclude mobile-sdk native modules when `E2E_TESTING` flag is set * app: disable ios msdk auto-linking * add E2E_TESTING flag --------- Co-authored-by: Leszek Stachowski <leszek.stachowski@self.xyz> Co-authored-by: seshanthS <seshanth@protonmail.com> Co-authored-by: Seshanth.S <35675963+seshanthS@users.noreply.github.com> Co-authored-by: Aaron DeRuvo <aaron.deruvo@clabs.co>
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
|
||||
|
||||
import { sanitizeErrorMessage } from '@/utils/utils';
|
||||
|
||||
describe('sanitizeErrorMessage', () => {
|
||||
it('redacts sequences of 9+ digits', () => {
|
||||
const input = 'Passport number 123456789 should be hidden';
|
||||
const result = sanitizeErrorMessage(input);
|
||||
expect(result).toBe('Passport number [REDACTED] should be hidden');
|
||||
});
|
||||
|
||||
it('does not redact short numbers (<9 digits)', () => {
|
||||
const input = 'Retry in 120 seconds. Code 12345678 only';
|
||||
const result = sanitizeErrorMessage(input);
|
||||
expect(result).toBe('Retry in 120 seconds. Code 12345678 only');
|
||||
});
|
||||
|
||||
it('redacts MRZ-like long blocks (>=30 chars of A-Z0-9<)', () => {
|
||||
const mrzLike = 'P<USADOE<<JOHN<<<<<<<<<<<<<<<<<<<<<<<<<<<<';
|
||||
const suffix = ' additional context';
|
||||
const input = `${mrzLike}${suffix}`;
|
||||
const result = sanitizeErrorMessage(input);
|
||||
expect(result).toBe('[MRZ_REDACTED]' + suffix);
|
||||
});
|
||||
|
||||
it('redacts multi-line MRZ (two lines of 44 chars)', () => {
|
||||
const line1 = 'A'.repeat(44);
|
||||
const line2 = 'B'.repeat(44);
|
||||
const suffix = ' context';
|
||||
const input = `${line1}\n${line2}${suffix}`;
|
||||
const result = sanitizeErrorMessage(input);
|
||||
expect(result).toBe('[MRZ_REDACTED]\n[MRZ_REDACTED]' + suffix);
|
||||
});
|
||||
|
||||
it('redacts multiple occurrences in the same string', () => {
|
||||
const input = 'ids 123456789 and 987654321 are present';
|
||||
const result = sanitizeErrorMessage(input);
|
||||
expect(result).toBe('ids [REDACTED] and [REDACTED] are present');
|
||||
});
|
||||
|
||||
it('returns "redacted" on unexpected errors', () => {
|
||||
// Simulate a failure by monkey-patching String.prototype.replace temporarily
|
||||
const originalReplace = (String.prototype as any).replace;
|
||||
(String.prototype as any).replace = () => {
|
||||
throw new Error('boom');
|
||||
};
|
||||
try {
|
||||
const result = sanitizeErrorMessage('any');
|
||||
expect(result).toBe('redacted');
|
||||
} finally {
|
||||
(String.prototype as any).replace = originalReplace;
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user