mirror of
https://github.com/selfxyz/self.git
synced 2026-01-09 14:48:06 -05:00
chore: address TypeScript ESLint v8 upgrade feedback and improve type safety (#895)
* cr feedback * update based on feedback * typing updates * unify yarn package version * update lock
This commit is contained in:
@@ -153,9 +153,11 @@ module.exports = {
|
||||
'prefer-const': 'warn',
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'@typescript-eslint/no-var-requires': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'error',
|
||||
'@typescript-eslint/no-require-imports': 'error',
|
||||
'@typescript-eslint/no-empty-object-type': 'warn',
|
||||
'@typescript-eslint/no-unused-vars': 'warn',
|
||||
'@typescript-eslint/no-unused-expressions': 'warn',
|
||||
'no-redeclare': 'off',
|
||||
'@typescript-eslint/ban-types': 'off',
|
||||
'@typescript-eslint/no-namespace': 'off',
|
||||
'no-case-declarations': 'off',
|
||||
'react/no-children-prop': 'off',
|
||||
@@ -198,6 +200,10 @@ module.exports = {
|
||||
rules: {
|
||||
// Allow console logging in tests
|
||||
'no-console': 'off',
|
||||
// Allow require() imports in tests for mocking
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
// Allow any types in tests for mocking
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -208,7 +214,14 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['*.cjs'],
|
||||
// Allow require imports for dynamic imports in proving machine
|
||||
files: ['src/utils/proving/provingMachine.ts'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['*.cjs', '*.js'],
|
||||
env: {
|
||||
node: true,
|
||||
commonjs: true,
|
||||
@@ -220,6 +233,7 @@ module.exports = {
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-var-requires': 'off',
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
'no-undef': 'off',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -17,10 +17,13 @@ export function optimalLevel2Example(data: PassportData) {
|
||||
// This will result in the smallest possible bundle
|
||||
// Only the specific functions and constants we use are included
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Using API:', API_URL);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Attestation ID:', PASSPORT_ATTESTATION_ID);
|
||||
|
||||
const hashedData = hash(JSON.stringify(data));
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Hashed passport data:', hashedData);
|
||||
|
||||
return {
|
||||
|
||||
@@ -27,15 +27,19 @@ export function optimalLevel3Example(data: PassportData, secret: string) {
|
||||
// Only the specific individual functions we use are included
|
||||
// Bundle size reduction: ~75-90% compared to broad imports!
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Using API:', API_URL);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Attestation ID:', PASSPORT_ATTESTATION_ID);
|
||||
|
||||
// Use specific hash function from SHA module
|
||||
const hashedData = hash([1, 2, 3, 4], 'hex');
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('SHA hashed data:', hashedData);
|
||||
|
||||
// Use specific Poseidon function for commitment
|
||||
const poseidonHash = flexiblePoseidon([BigInt(1), BigInt(2)]);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Poseidon hash:', poseidonHash);
|
||||
|
||||
// Use specific passport functions
|
||||
|
||||
@@ -160,17 +160,17 @@
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node-forge": "^1.3.3",
|
||||
"@types/react": "^18.2.6",
|
||||
"@types/react-dom": "^19.1.6",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@types/react-native": "^0.73.0",
|
||||
"@types/react-native-dotenv": "^0.2.0",
|
||||
"@types/react-native-sqlite-storage": "^6.0.5",
|
||||
"@types/react-native-web": "^0",
|
||||
"@types/react-test-renderer": "^18",
|
||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||
"@typescript-eslint/parser": "^7.18.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
||||
"@typescript-eslint/parser": "^8.0.0",
|
||||
"@vitejs/plugin-react-swc": "^3.10.2",
|
||||
"babel-plugin-module-resolver": "^5.0.2",
|
||||
"eslint": "^8.19.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "10.1.8",
|
||||
"eslint-import-resolver-typescript": "^3.7.0",
|
||||
"eslint-plugin-header": "^3.1.1",
|
||||
@@ -186,10 +186,11 @@
|
||||
"rollup-plugin-visualizer": "^6.0.3",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"ts-morph": "^22.0.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.9.2",
|
||||
"vite": "^7.0.0"
|
||||
},
|
||||
"packageManager": "yarn@4.6.0",
|
||||
"engines": {
|
||||
"node": ">=22 <23"
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ const REGEX_PATTERNS = {
|
||||
function safeReadFile(filePath, description) {
|
||||
try {
|
||||
return fs.readFileSync(filePath, 'utf8');
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
console.warn(`Warning: Could not read ${description} at ${filePath}`);
|
||||
return null;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ function safeExecSync(command, description) {
|
||||
|
||||
try {
|
||||
return execSync(command, { encoding: 'utf8' }).trim();
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
console.warn(`Warning: Could not ${description}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ describe('Tree Shaking Infrastructure Tests', () => {
|
||||
assert(stats.isFile(), `${script} should be a file`);
|
||||
|
||||
// Check if file is executable (has execute permission)
|
||||
const isExecutable = (stats.mode & 0o111) !== 0;
|
||||
const isExecutable = (stats.mode & 0o111) !== 0; // eslint-disable-line no-bitwise
|
||||
assert(isExecutable, `${script} should be executable`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,11 +10,7 @@ const StyledAnchor = styled(Anchor, {
|
||||
textDecorationLine: 'underline',
|
||||
});
|
||||
|
||||
interface BackupDocumentationLinkProps {}
|
||||
|
||||
const BackupDocumentationLink: React.FC<
|
||||
BackupDocumentationLinkProps
|
||||
> = ({}) => {
|
||||
const BackupDocumentationLink: React.FC = () => {
|
||||
if (Platform.OS === 'ios') {
|
||||
return (
|
||||
<StyledAnchor unstyled href="https://support.apple.com/en-us/102651">
|
||||
|
||||
@@ -43,7 +43,7 @@ export default function useRecoveryPrompts() {
|
||||
if (shouldPrompt) {
|
||||
showModal();
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
// Silently fail to avoid breaking the hook
|
||||
// If we can't get documents, we shouldn't show the prompt
|
||||
return;
|
||||
|
||||
@@ -278,7 +278,7 @@ export async function clearDocumentCatalogForMigrationTesting() {
|
||||
try {
|
||||
await Keychain.resetGenericPassword({ service: `document-${doc.id}` });
|
||||
console.log(`Cleared document: ${doc.id}`);
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
console.log(`Document ${doc.id} not found or already cleared`);
|
||||
}
|
||||
}
|
||||
@@ -287,7 +287,7 @@ export async function clearDocumentCatalogForMigrationTesting() {
|
||||
try {
|
||||
await Keychain.resetGenericPassword({ service: 'documentCatalog' });
|
||||
console.log('Cleared document catalog');
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
console.log('Document catalog not found or already cleared');
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ export async function clearPassportData() {
|
||||
for (const doc of catalog.documents) {
|
||||
try {
|
||||
await Keychain.resetGenericPassword({ service: `document-${doc.id}` });
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
console.log(`Document ${doc.id} not found or already cleared`);
|
||||
}
|
||||
}
|
||||
@@ -345,7 +345,7 @@ export async function deleteDocument(documentId: string): Promise<void> {
|
||||
// Delete the actual document
|
||||
try {
|
||||
await Keychain.resetGenericPassword({ service: `document-${documentId}` });
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
console.log(`Document ${documentId} not found or already cleared`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ const SuccessScreen: React.FC = () => {
|
||||
setCountdown(5);
|
||||
setCountdownStarted(true);
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
console.warn(
|
||||
'Invalid deep link URL provided:',
|
||||
selfApp.deeplinkCallback,
|
||||
|
||||
@@ -140,7 +140,7 @@ const PassportDataSelector = () => {
|
||||
return 'IND';
|
||||
}
|
||||
return null;
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -57,7 +57,9 @@ export const useProofHistoryStore = create<ProofHistoryState>()((set, get) => {
|
||||
transports: ['websocket'],
|
||||
});
|
||||
setTimeout(() => {
|
||||
websocket.connected && websocket.disconnect();
|
||||
if (websocket.connected) {
|
||||
websocket.disconnect();
|
||||
}
|
||||
// disconnect after 2 minutes
|
||||
}, SYNC_THROTTLE_MS * 4);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export function parseMnemonic(mnemonicString: string): Mnemonic {
|
||||
|
||||
try {
|
||||
parsed = JSON.parse(mnemonicString);
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
throw new Error('Invalid JSON format in mnemonic backup');
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ const setupEventListeners = () => {
|
||||
try {
|
||||
const parsedEvent = JSON.parse(event);
|
||||
handleNativeLogEvent(parsedEvent);
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
console.warn('Failed to parse logEvent string:', event);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -422,7 +422,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
|
||||
navigationRef.navigate('Launch');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
if (navigationRef.isReady()) {
|
||||
navigationRef.navigate('Launch');
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export async function clearDocumentCatalogForMigrationTesting(): Promise<void> {
|
||||
try {
|
||||
await Keychain.resetGenericPassword({ service: `document-${doc.id}` });
|
||||
console.log(`Cleared document: ${doc.id}`);
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
console.log(`Document ${doc.id} not found or already cleared`);
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export async function clearDocumentCatalogForMigrationTesting(): Promise<void> {
|
||||
try {
|
||||
await Keychain.resetGenericPassword({ service: 'documentCatalog' });
|
||||
console.log('Cleared document catalog');
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
console.log('Document catalog not found or already cleared');
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ const ErrorBoundaryTest = () => {
|
||||
try {
|
||||
// This would normally call a context function
|
||||
return 'success';
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
return 'error';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -65,9 +65,6 @@
|
||||
"@openpassport/zk-kit-lean-imt": "^0.0.4",
|
||||
"@openpassport/zk-kit-smt": "^0.0.1",
|
||||
"@selfxyz/common": "workspace:^",
|
||||
"@types/chai-as-promised": "^7.1.6",
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/node-forge": "^1.3.5",
|
||||
"@zk-email/circuits": "^6.3.2",
|
||||
"@zk-email/helpers": "^6.1.1",
|
||||
"@zk-email/zk-regex-circom": "^1.2.1",
|
||||
@@ -110,6 +107,7 @@
|
||||
"tsx": "^4.20.3",
|
||||
"typescript": "^5.9.2"
|
||||
},
|
||||
"packageManager": "yarn@4.6.0",
|
||||
"engines": {
|
||||
"node": ">=22 <23"
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
"outDir": "./dist/esm",
|
||||
"declaration": false,
|
||||
"baseUrl": ".",
|
||||
"types": ["node"],
|
||||
"composite": false
|
||||
},
|
||||
"include": ["tests/**/*", "tests/**/*.json", "src/**/*"],
|
||||
|
||||
@@ -69,7 +69,6 @@ module.exports = {
|
||||
// TypeScript Rules - only essential ones
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-unused-vars': 'off',
|
||||
'@typescript-eslint/ban-types': 'off',
|
||||
'@typescript-eslint/no-namespace': 'off',
|
||||
'@typescript-eslint/ban-ts-comment': 'off',
|
||||
|
||||
|
||||
@@ -364,8 +364,8 @@
|
||||
"devDependencies": {
|
||||
"@types/js-sha1": "^0.6.3",
|
||||
"@types/node-forge": "^1.3.10",
|
||||
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
||||
"@typescript-eslint/parser": "^7.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
||||
"@typescript-eslint/parser": "^8.0.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
@@ -379,6 +379,7 @@
|
||||
"tsup": "^8.5.0",
|
||||
"typescript": "^5.9.2"
|
||||
},
|
||||
"packageManager": "yarn@4.6.0",
|
||||
"engines": {
|
||||
"node": ">=22 <23"
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export function sha384_512Pad(
|
||||
prehash_prepad_m_array: number[],
|
||||
maxShaBytes: number
|
||||
): [number[], number] {
|
||||
let prehash_prepad_m: any = new Uint8Array(prehash_prepad_m_array);
|
||||
let prehash_prepad_m: Uint8Array = new Uint8Array(prehash_prepad_m_array);
|
||||
// Length in bits before padding
|
||||
const length_bits = prehash_prepad_m.length * 8;
|
||||
|
||||
@@ -84,7 +84,7 @@ export function sha384_512Pad(
|
||||
// Copied from zk-email cuz it uses crypto so can't import it here.
|
||||
// Puts an end selector, a bunch of 0s, then the length, then fill the rest with 0s.
|
||||
export function shaPad(prehash_prepad_m_array: number[], maxShaBytes: number): [number[], number] {
|
||||
let prehash_prepad_m: any = new Uint8Array(prehash_prepad_m_array);
|
||||
let prehash_prepad_m: Uint8Array = new Uint8Array(prehash_prepad_m_array);
|
||||
const length_bits = prehash_prepad_m.length * 8; // bytes to bits
|
||||
const length_in_bytes = int64toBytes(length_bits);
|
||||
prehash_prepad_m = mergeUInt8Arrays(prehash_prepad_m, int8toBytes(2 ** 7)); // Add the 1 on the end, length 505
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"moduleResolution": "NodeNext",
|
||||
"types": ["node"],
|
||||
|
||||
"baseUrl": "./",
|
||||
"composite": true
|
||||
},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { HardhatUserConfig } from "hardhat/config";
|
||||
import "@nomicfoundation/hardhat-toolbox";
|
||||
require("dotenv").config({
|
||||
import dotenv from "dotenv";
|
||||
dotenv.config({
|
||||
path: process.env.CI ? ".env.test" : ".env",
|
||||
});
|
||||
import "hardhat-contract-sizer";
|
||||
|
||||
@@ -32,16 +32,16 @@
|
||||
"deploy:verifiers": "npx dotenv-cli -- bash -c 'yarn hardhat ignition deploy ignition/modules/verifiers/deployVerifiers.ts --network ${NETWORK:-localhost} ${VERIFY:+--verify}'",
|
||||
"deploy:verifiers:all": "npx dotenv-cli -- bash -c 'yarn hardhat ignition deploy ignition/modules/verifiers/deployAllVerifiers.ts --network ${NETWORK:-localhost} ${VERIFY:+--verify}'",
|
||||
"export-prod": "bash ./scripts/prod.sh",
|
||||
"find:error": "npx ts-node scripts/findErrorSelectors.ts",
|
||||
"find:error": "npx tsx scripts/findErrorSelectors.ts",
|
||||
"prettier:check": "prettier --list-different '**/*.{json,md,yml,sol,ts}'",
|
||||
"prettier:write": "prettier --write '**/*.{json,md,yml,sol,ts}'",
|
||||
"publish": "npm publish --access public",
|
||||
"set:hub:v2": "npx dotenv-cli -- bash -c 'NETWORK=${NETWORK:-alfajores} npx ts-node scripts/setHubV2.ts'",
|
||||
"set:registry": "npx dotenv-cli -- bash -c 'NETWORK=${NETWORK:-staging} npx ts-node scripts/setRegistry.ts'",
|
||||
"set:hub:v2": "npx dotenv-cli -- bash -c 'NETWORK=${NETWORK:-alfajores} npx tsx scripts/setHubV2.ts'",
|
||||
"set:registry": "npx dotenv-cli -- bash -c 'NETWORK=${NETWORK:-staging} npx tsx scripts/setRegistry.ts'",
|
||||
"set:registry:hub:v2": "npx dotenv-cli -- bash -c 'yarn hardhat ignition deploy ignition/modules/scripts/updateRegistryHubV2.ts --network ${NETWORK:-localhost} ${VERIFY:+--verify}'",
|
||||
"set:registry:idcard": "npx dotenv-cli -- bash -c 'NETWORK=${NETWORK:-staging} npx ts-node scripts/setRegistryId.ts'",
|
||||
"set:verifiers:v2": "npx dotenv-cli -- bash -c 'NETWORK=${NETWORK:-alfajores} npx ts-node scripts/setVerifiersV2.ts'",
|
||||
"show:registry": "npx ts-node scripts/showRegistryAddresses.ts",
|
||||
"set:registry:idcard": "npx dotenv-cli -- bash -c 'NETWORK=${NETWORK:-staging} npx tsx scripts/setRegistryId.ts'",
|
||||
"set:verifiers:v2": "npx dotenv-cli -- bash -c 'NETWORK=${NETWORK:-alfajores} npx tsx scripts/setVerifiersV2.ts'",
|
||||
"show:registry": "npx tsx scripts/showRegistryAddresses.ts",
|
||||
"test": "yarn hardhat test",
|
||||
"test:airdrop": "npx dotenv-cli -- bash -c 'TEST_ENV=${TEST_ENV:-local} npx hardhat test test/example/airdrop.test.ts'",
|
||||
"test:attribute": "npx dotenv-cli -- bash -c 'TEST_ENV=${TEST_ENV:-local} npx hardhat test test/unit/CircuitAttributeHandler.test.ts'",
|
||||
@@ -64,7 +64,7 @@
|
||||
"test:view": "yarn hardhat test test/view.ts",
|
||||
"types": "tsc -noEmit",
|
||||
"update:cscaroot": "npx dotenv-cli -- bash -c 'yarn hardhat ignition deploy ignition/modules/scripts/updateRegistryCscaRoot.ts --network ${NETWORK:-localhost} ${VERIFY:+--verify}'",
|
||||
"update:hub": "npx dotenv-cli -- bash -c 'NETWORK=${NETWORK:-staging} npx ts-node scripts/setRegistry.ts'",
|
||||
"update:hub": "npx dotenv-cli -- bash -c 'NETWORK=${NETWORK:-staging} npx tsx scripts/setRegistry.ts'",
|
||||
"update:ofacroot": "npx dotenv-cli -- bash -c 'NETWORK=${NETWORK:-alfajores} npx tsx scripts/updateRegistryOfacRoot.ts'",
|
||||
"update:pcr0": "npx dotenv-cli -- bash -c 'PCR0_ACTION=${PCR0_ACTION:-add} PCR0_KEY=${PCR0_KEY} yarn hardhat ignition deploy ignition/modules/scripts/updatePCR0.ts --network ${NETWORK:-localhost} --reset'",
|
||||
"upgrade:hub": "npx dotenv-cli -- bash -c 'yarn hardhat ignition deploy ignition/modules/upgrade/deployNewHubAndUpgrade.ts --network ${NETWORK:-localhost} ${VERIFY:+--verify}'",
|
||||
@@ -117,11 +117,10 @@
|
||||
"prettier": "3.5.3",
|
||||
"prettier-plugin-solidity": "^2.0.0",
|
||||
"solidity-coverage": "^0.8.14",
|
||||
"ts-node": "^10.9.1",
|
||||
"typechain": "^8.3.2",
|
||||
"typescript": "^5.9.2"
|
||||
},
|
||||
"packageManager": "yarn@4.5.3",
|
||||
"packageManager": "yarn@4.6.0",
|
||||
"engines": {
|
||||
"node": ">=22 <23"
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true,
|
||||
"types": ["node"]
|
||||
"resolveJsonModule": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
],
|
||||
"scripts": {
|
||||
"build": "yarn workspaces foreach --topological-dev --parallel --exclude @selfxyz/contracts -i --all run build",
|
||||
"find:migration": "node scripts/find-migration.mjs",
|
||||
"format": "yarn format:root && yarn format:github && yarn workspaces foreach --parallel -i --all --exclude self-workspace-root run format",
|
||||
"format:github": "prettier --parser yaml --write .github/**/*.yml --single-quote false",
|
||||
"format:root": "prettier --parser markdown --write *.md && prettier --parser yaml --write .*.{yml,yaml} --single-quote false",
|
||||
|
||||
@@ -51,6 +51,8 @@ module.exports = {
|
||||
'import/no-duplicates': 'error',
|
||||
'import/export': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-require-imports': 'error',
|
||||
'@typescript-eslint/no-empty-object-type': 'error',
|
||||
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
||||
// Add prettier rule to show prettier errors as ESLint errors
|
||||
'prettier/prettier': ['warn', {}, { usePrettierrc: true }],
|
||||
@@ -79,5 +81,12 @@ module.exports = {
|
||||
'sort-exports/sort-exports': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
// Allow require imports only in the NFC decoder shim that conditionally imports node:util
|
||||
files: ['src/processing/nfc.ts'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -54,8 +54,8 @@
|
||||
"tslib": "^2.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||
"@typescript-eslint/parser": "^7.18.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
||||
"@typescript-eslint/parser": "^8.0.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
@@ -67,6 +67,7 @@
|
||||
"typescript": "^5.9.2",
|
||||
"vitest": "^1.6.0"
|
||||
},
|
||||
"packageManager": "yarn@4.6.0",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ const createTextDecoder = (): TextDecoder => {
|
||||
return new ((globalThis as any).global as any).TextDecoder('utf-8', { fatal: true });
|
||||
}
|
||||
|
||||
// Node.js environment - try to import from util (only if we're in a Node.js context)
|
||||
// Node.js environment - try to import from built-in `node:util` (only if we're in a Node.js context)
|
||||
if (typeof (globalThis as any).process !== 'undefined' && (globalThis as any).process?.versions?.node) {
|
||||
try {
|
||||
// Use dynamic import for better compatibility
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const util = require('util');
|
||||
if (util.TextDecoder) {
|
||||
const req = typeof require === 'function' ? require : undefined;
|
||||
const util = req ? req('node:util') : undefined;
|
||||
if (util?.TextDecoder) {
|
||||
return new util.TextDecoder('utf-8', { fatal: true });
|
||||
}
|
||||
} catch {
|
||||
@@ -37,7 +37,13 @@ const createTextDecoder = (): TextDecoder => {
|
||||
);
|
||||
};
|
||||
|
||||
const DECODER = createTextDecoder();
|
||||
let DECODER: TextDecoder | undefined;
|
||||
|
||||
// Lazily initialize to avoid import-time failures in environments without a decoder.
|
||||
const getDecoder = (): TextDecoder => {
|
||||
if (!DECODER) DECODER = createTextDecoder();
|
||||
return DECODER;
|
||||
};
|
||||
|
||||
// Known LDS1 tag constants
|
||||
const TAG_DG1 = 0x61;
|
||||
@@ -95,7 +101,7 @@ export function parseNFCResponse(bytes: Uint8Array): ParsedNFCResponse {
|
||||
|
||||
switch (tag) {
|
||||
case TAG_DG1: {
|
||||
result.dg1 = { mrz: DECODER.decode(value) };
|
||||
result.dg1 = { mrz: getDecoder().decode(value) };
|
||||
break;
|
||||
}
|
||||
case TAG_DG2: {
|
||||
|
||||
@@ -66,7 +66,6 @@
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/node-forge": "^1.3.5",
|
||||
"@types/snarkjs": "^0.7.8",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"axios": "^1.7.2",
|
||||
"prettier": "^3.3.3",
|
||||
"ts-loader": "^9.5.1",
|
||||
|
||||
37
yarn.lock
37
yarn.lock
@@ -4934,8 +4934,8 @@ __metadata:
|
||||
"@openpassport/zk-kit-smt": "npm:^0.0.1"
|
||||
"@types/js-sha1": "npm:^0.6.3"
|
||||
"@types/node-forge": "npm:^1.3.10"
|
||||
"@typescript-eslint/eslint-plugin": "npm:^7.0.0"
|
||||
"@typescript-eslint/parser": "npm:^7.0.0"
|
||||
"@typescript-eslint/eslint-plugin": "npm:^8.0.0"
|
||||
"@typescript-eslint/parser": "npm:^8.0.0"
|
||||
asn1.js: "npm:^5.4.1"
|
||||
asn1js: "npm:^3.0.5"
|
||||
axios: "npm:^1.7.2"
|
||||
@@ -5022,7 +5022,6 @@ __metadata:
|
||||
prettier-plugin-solidity: "npm:^2.0.0"
|
||||
snarkjs: "npm:^0.7.4"
|
||||
solidity-coverage: "npm:^0.8.14"
|
||||
ts-node: "npm:^10.9.1"
|
||||
typechain: "npm:^8.3.2"
|
||||
typescript: "npm:^5.9.2"
|
||||
languageName: unknown
|
||||
@@ -5042,7 +5041,6 @@ __metadata:
|
||||
"@types/node": "npm:^22.0.0"
|
||||
"@types/node-forge": "npm:^1.3.5"
|
||||
"@types/snarkjs": "npm:^0.7.8"
|
||||
"@types/uuid": "npm:^10.0.0"
|
||||
axios: "npm:^1.7.2"
|
||||
ethers: "npm:^6.13.5"
|
||||
js-sha1: "npm:^0.7.0"
|
||||
@@ -5110,14 +5108,14 @@ __metadata:
|
||||
"@types/jest": "npm:^29.5.14"
|
||||
"@types/node-forge": "npm:^1.3.3"
|
||||
"@types/react": "npm:^18.2.6"
|
||||
"@types/react-dom": "npm:^19.1.6"
|
||||
"@types/react-dom": "npm:^18.3.0"
|
||||
"@types/react-native": "npm:^0.73.0"
|
||||
"@types/react-native-dotenv": "npm:^0.2.0"
|
||||
"@types/react-native-sqlite-storage": "npm:^6.0.5"
|
||||
"@types/react-native-web": "npm:^0"
|
||||
"@types/react-test-renderer": "npm:^18"
|
||||
"@typescript-eslint/eslint-plugin": "npm:^7.18.0"
|
||||
"@typescript-eslint/parser": "npm:^7.18.0"
|
||||
"@typescript-eslint/eslint-plugin": "npm:^8.0.0"
|
||||
"@typescript-eslint/parser": "npm:^8.0.0"
|
||||
"@vitejs/plugin-react-swc": "npm:^3.10.2"
|
||||
"@xstate/react": "npm:^5.0.3"
|
||||
add: "npm:^2.0.6"
|
||||
@@ -5126,7 +5124,7 @@ __metadata:
|
||||
country-emoji: "npm:^1.5.6"
|
||||
country-iso-3-to-2: "npm:^1.1.1"
|
||||
elliptic: "npm:^6.6.1"
|
||||
eslint: "npm:^8.19.0"
|
||||
eslint: "npm:^8.57.0"
|
||||
eslint-config-prettier: "npm:10.1.8"
|
||||
eslint-import-resolver-typescript: "npm:^3.7.0"
|
||||
eslint-plugin-header: "npm:^3.1.1"
|
||||
@@ -5177,7 +5175,7 @@ __metadata:
|
||||
stream-browserify: "npm:^3.0.0"
|
||||
tamagui: "npm:1.126.14"
|
||||
ts-morph: "npm:^22.0.0"
|
||||
ts-node: "npm:^10.9.1"
|
||||
ts-node: "npm:^10.9.2"
|
||||
typescript: "npm:^5.9.2"
|
||||
uuid: "npm:^11.0.5"
|
||||
vite: "npm:^7.0.0"
|
||||
@@ -5191,8 +5189,8 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@selfxyz/mobile-sdk-alpha@workspace:packages/mobile-sdk-alpha"
|
||||
dependencies:
|
||||
"@typescript-eslint/eslint-plugin": "npm:^7.18.0"
|
||||
"@typescript-eslint/parser": "npm:^7.18.0"
|
||||
"@typescript-eslint/eslint-plugin": "npm:^8.0.0"
|
||||
"@typescript-eslint/parser": "npm:^8.0.0"
|
||||
eslint: "npm:^8.57.0"
|
||||
eslint-config-prettier: "npm:^10.1.8"
|
||||
eslint-plugin-import: "npm:^2.31.0"
|
||||
@@ -9875,15 +9873,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/react-dom@npm:^19.1.6":
|
||||
version: 19.1.6
|
||||
resolution: "@types/react-dom@npm:19.1.6"
|
||||
peerDependencies:
|
||||
"@types/react": ^19.0.0
|
||||
checksum: 10c0/7ba74eee2919e3f225e898b65fdaa16e54952aaf9e3472a080ddc82ca54585e46e60b3c52018d21d4b7053f09d27b8293e9f468b85f9932ff452cd290cc131e8
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@types/react-native-dotenv@npm:^0.2.0":
|
||||
version: 0.2.2
|
||||
resolution: "@types/react-native-dotenv@npm:0.2.2"
|
||||
@@ -10032,7 +10021,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@typescript-eslint/eslint-plugin@npm:^7.0.0, @typescript-eslint/eslint-plugin@npm:^7.1.1, @typescript-eslint/eslint-plugin@npm:^7.18.0":
|
||||
"@typescript-eslint/eslint-plugin@npm:^7.1.1":
|
||||
version: 7.18.0
|
||||
resolution: "@typescript-eslint/eslint-plugin@npm:7.18.0"
|
||||
dependencies:
|
||||
@@ -10076,7 +10065,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@typescript-eslint/parser@npm:^7.0.0, @typescript-eslint/parser@npm:^7.1.1, @typescript-eslint/parser@npm:^7.18.0":
|
||||
"@typescript-eslint/parser@npm:^7.1.1":
|
||||
version: 7.18.0
|
||||
resolution: "@typescript-eslint/parser@npm:7.18.0"
|
||||
dependencies:
|
||||
@@ -15126,7 +15115,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"eslint@npm:^8.19.0, eslint@npm:^8.57.0":
|
||||
"eslint@npm:^8.57.0":
|
||||
version: 8.57.1
|
||||
resolution: "eslint@npm:8.57.1"
|
||||
dependencies:
|
||||
@@ -25279,7 +25268,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ts-node@npm:^10.9.1, ts-node@npm:^10.9.2":
|
||||
"ts-node@npm:^10.9.2":
|
||||
version: 10.9.2
|
||||
resolution: "ts-node@npm:10.9.2"
|
||||
dependencies:
|
||||
|
||||
Reference in New Issue
Block a user