mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
Alias app imports: @src, @tests (#852)
* Support @src alias tooling * run script and nice * convert ts script to cjs, update sources * convert to cjs * wip update paths * nice and updates * fix tests alias paths * lint fixes * add @tests alias support * update script and tests to fix remaining src alias paths * updates * update script * fix * update lock file * fix test target * update timeout * update flow * fix flow
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11
|
||||
|
||||
import { createSegmentClient } from '../Segment';
|
||||
|
||||
import type { JsonMap, JsonValue } from '@segment/analytics-react-native';
|
||||
import { createSegmentClient } from '@src/Segment';
|
||||
|
||||
/**
|
||||
* Generic reasons:
|
||||
|
||||
@@ -5,7 +5,8 @@ import { Platform } from 'react-native';
|
||||
import { CloudStorage, CloudStorageScope } from 'react-native-cloud-storage';
|
||||
|
||||
import { name } from '../../../package.json';
|
||||
import type { Mnemonic } from '../../types/mnemonic';
|
||||
|
||||
import type { Mnemonic } from '@src/types/mnemonic';
|
||||
|
||||
export const FOLDER = `/${name}`;
|
||||
export const ENCRYPTED_FILE_PATH = `/${FOLDER}/encrypted-private-key`;
|
||||
|
||||
@@ -3,15 +3,18 @@
|
||||
import { useMemo } from 'react';
|
||||
import { Platform } from 'react-native';
|
||||
|
||||
import type { Mnemonic } from '../../types/mnemonic';
|
||||
import { createGDrive } from './google';
|
||||
import { FILE_NAME, parseMnemonic, withRetries } from './helpers';
|
||||
import * as ios from './ios';
|
||||
|
||||
import {
|
||||
APP_DATA_FOLDER_ID,
|
||||
MIME_TYPES,
|
||||
} from '@robinbobin/react-native-google-drive-api-wrapper';
|
||||
import type { Mnemonic } from '@src/types/mnemonic';
|
||||
import { createGDrive } from '@src/utils/cloudBackup/google';
|
||||
import {
|
||||
FILE_NAME,
|
||||
parseMnemonic,
|
||||
withRetries,
|
||||
} from '@src/utils/cloudBackup/helpers';
|
||||
import * as ios from '@src/utils/cloudBackup/ios';
|
||||
|
||||
export const STORAGE_NAME = Platform.OS === 'ios' ? 'iCloud' : 'Google Drive';
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
import { CloudStorage } from 'react-native-cloud-storage';
|
||||
|
||||
import type { Mnemonic } from '../../types/mnemonic';
|
||||
import type { Mnemonic } from '@src/types/mnemonic';
|
||||
import {
|
||||
ENCRYPTED_FILE_PATH,
|
||||
FOLDER,
|
||||
parseMnemonic,
|
||||
withRetries,
|
||||
} from './helpers';
|
||||
} from '@src/utils/cloudBackup/helpers';
|
||||
|
||||
export async function disableBackup() {
|
||||
await withRetries(() => CloudStorage.rmdir(FOLDER, { recursive: true }));
|
||||
|
||||
@@ -11,8 +11,8 @@ export const loadCryptoUtils = async () => {
|
||||
|
||||
export const loadProvingUtils = async () => {
|
||||
return Promise.all([
|
||||
import('./proving/provingMachine'),
|
||||
import('./proving/attest'),
|
||||
import('./proving/validateDocument'),
|
||||
import('@src/utils/proving/provingMachine'),
|
||||
import('@src/utils/proving/attest'),
|
||||
import('@src/utils/proving/validateDocument'),
|
||||
]);
|
||||
};
|
||||
|
||||
@@ -6,9 +6,9 @@ import { Linking, Platform } from 'react-native';
|
||||
import { countries } from '@selfxyz/common/constants/countries';
|
||||
import type { IdDocInput } from '@selfxyz/common/utils';
|
||||
|
||||
import { navigationRef } from '../navigation';
|
||||
import { useSelfAppStore } from '../stores/selfAppStore';
|
||||
import useUserStore from '../stores/userStore';
|
||||
import { navigationRef } from '@src/navigation';
|
||||
import { useSelfAppStore } from '@src/stores/selfAppStore';
|
||||
import useUserStore from '@src/stores/userStore';
|
||||
|
||||
// Validation patterns for each expected parameter
|
||||
const VALIDATION_PATTERNS = {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { Platform, Vibration } from 'react-native';
|
||||
|
||||
import { triggerFeedback } from './trigger';
|
||||
import { triggerFeedback } from '@src/utils/haptic/trigger';
|
||||
|
||||
// Keep track of the loading screen interval
|
||||
let loadingScreenInterval: ReturnType<typeof setInterval> | null = null;
|
||||
@@ -165,4 +165,4 @@ export const notificationSuccess = () => triggerFeedback('notificationSuccess');
|
||||
|
||||
export const notificationWarning = () => triggerFeedback('notificationWarning');
|
||||
|
||||
export { triggerFeedback } from './trigger';
|
||||
export { triggerFeedback } from '@src/utils/haptic/trigger';
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import { Platform, Vibration } from 'react-native';
|
||||
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
|
||||
|
||||
import type { HapticOptions, HapticType } from './shared';
|
||||
import { defaultOptions } from './shared';
|
||||
import type { HapticOptions, HapticType } from '@src/utils/haptic/shared';
|
||||
import { defaultOptions } from '@src/utils/haptic/shared';
|
||||
/**
|
||||
* Triggers haptic feedback or vibration based on platform.
|
||||
* @param type - The haptic feedback type.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11
|
||||
|
||||
import type { HapticOptions, HapticType } from './shared';
|
||||
import { defaultOptions } from './shared';
|
||||
import type { HapticOptions, HapticType } from '@src/utils/haptic/shared';
|
||||
import { defaultOptions } from '@src/utils/haptic/shared';
|
||||
|
||||
/**
|
||||
* Triggers haptic feedback or vibration based on platform.
|
||||
|
||||
@@ -2,17 +2,16 @@
|
||||
|
||||
import { PermissionsAndroid, Platform } from 'react-native';
|
||||
|
||||
import messaging from '@react-native-firebase/messaging';
|
||||
import type {
|
||||
DeviceTokenRegistration,
|
||||
RemoteMessage,
|
||||
} from './notificationService.shared';
|
||||
} from '@src/utils/notifications/notificationService.shared';
|
||||
import {
|
||||
API_URL,
|
||||
API_URL_STAGING,
|
||||
getStateMessage,
|
||||
} from './notificationService.shared';
|
||||
|
||||
import messaging from '@react-native-firebase/messaging';
|
||||
} from '@src/utils/notifications/notificationService.shared';
|
||||
|
||||
export async function getFCMToken(): Promise<string | null> {
|
||||
try {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11
|
||||
|
||||
import type { DeviceTokenRegistration } from './notificationService.shared';
|
||||
import type { DeviceTokenRegistration } from '@src/utils/notifications/notificationService.shared';
|
||||
import {
|
||||
API_URL,
|
||||
API_URL_STAGING,
|
||||
getStateMessage,
|
||||
} from './notificationService.shared';
|
||||
} from '@src/utils/notifications/notificationService.shared';
|
||||
|
||||
export async function getFCMToken(): Promise<string | null> {
|
||||
try {
|
||||
|
||||
@@ -9,10 +9,9 @@ import { Certificate } from 'pkijs';
|
||||
|
||||
import { PCR0_MANAGER_ADDRESS, RPC_URL } from '@selfxyz/common/constants';
|
||||
|
||||
import { AWS_ROOT_PEM } from './awsRootPem';
|
||||
import cose from './cose';
|
||||
|
||||
import { X509Certificate } from '@peculiar/x509';
|
||||
import { AWS_ROOT_PEM } from '@src/utils/proving/awsRootPem';
|
||||
import cose from '@src/utils/proving/cose';
|
||||
import { decode } from '@stablelib/cbor';
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,20 +3,23 @@
|
||||
// Only export what's actually used elsewhere to enable proper tree shaking
|
||||
|
||||
// From provingMachine - used in screens and tests
|
||||
export { type ProvingStateType, useProvingStore } from './provingMachine';
|
||||
export {
|
||||
type ProvingStateType,
|
||||
useProvingStore,
|
||||
} from '@src/utils/proving/provingMachine';
|
||||
|
||||
// From provingUtils - used in tests (keeping these for testing purposes)
|
||||
export {
|
||||
encryptAES256GCM,
|
||||
getPayload,
|
||||
getWSDbRelayerUrl,
|
||||
} from './provingUtils';
|
||||
} from '@src/utils/proving/provingUtils';
|
||||
|
||||
// From loadingScreenStateText - used in loading screen
|
||||
export { getLoadingScreenText } from './loadingScreenStateText';
|
||||
export { getLoadingScreenText } from '@src/utils/proving/loadingScreenStateText';
|
||||
|
||||
// From validateDocument - used in recovery and splash screens
|
||||
export {
|
||||
hasAnyValidRegisteredDocument,
|
||||
isUserRegisteredWithAlternativeCSCA,
|
||||
} from './validateDocument';
|
||||
} from '@src/utils/proving/validateDocument';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11
|
||||
|
||||
import type { ProvingStateType } from './provingMachine';
|
||||
import type { ProvingStateType } from '@src/utils/proving/provingMachine';
|
||||
|
||||
interface LoadingScreenText {
|
||||
actionText: string;
|
||||
|
||||
@@ -20,10 +20,9 @@ import {
|
||||
hashEndpointWithScope,
|
||||
} from '@selfxyz/common/utils';
|
||||
|
||||
import { useProtocolStore } from '../../stores/protocolStore';
|
||||
|
||||
import { LeanIMT } from '@openpassport/zk-kit-lean-imt';
|
||||
import { SMT } from '@openpassport/zk-kit-smt';
|
||||
import { useProtocolStore } from '@src/stores/protocolStore';
|
||||
|
||||
export function generateTEEInputsDSC(
|
||||
passportData: PassportData,
|
||||
|
||||
@@ -15,24 +15,24 @@ import {
|
||||
getSolidityPackedUserContextData,
|
||||
} from '@selfxyz/common/utils';
|
||||
|
||||
import { PassportEvents, ProofEvents } from '../../consts/analytics';
|
||||
import { navigationRef } from '../../navigation';
|
||||
import { unsafe_getPrivateKey } from '../../providers/authProvider';
|
||||
import { PassportEvents, ProofEvents } from '@src/consts/analytics';
|
||||
import { navigationRef } from '@src/navigation';
|
||||
import { unsafe_getPrivateKey } from '@src/providers/authProvider';
|
||||
import {
|
||||
clearPassportData,
|
||||
loadSelectedDocument,
|
||||
markCurrentDocumentAsRegistered,
|
||||
reStorePassportDataWithRightCSCA,
|
||||
} from '../../providers/passportDataProvider';
|
||||
import { useProtocolStore } from '../../stores/protocolStore';
|
||||
import { useSelfAppStore } from '../../stores/selfAppStore';
|
||||
import analytics from '../analytics';
|
||||
import { getPublicKey, verifyAttestation } from './attest';
|
||||
} from '@src/providers/passportDataProvider';
|
||||
import { useProtocolStore } from '@src/stores/protocolStore';
|
||||
import { useSelfAppStore } from '@src/stores/selfAppStore';
|
||||
import analytics from '@src/utils/analytics';
|
||||
import { getPublicKey, verifyAttestation } from '@src/utils/proving/attest';
|
||||
import {
|
||||
generateTEEInputsDisclose,
|
||||
generateTEEInputsDSC,
|
||||
generateTEEInputsRegister,
|
||||
} from './provingInputs';
|
||||
} from '@src/utils/proving/provingInputs';
|
||||
import {
|
||||
clientKey,
|
||||
clientPublicKeyHex,
|
||||
@@ -40,7 +40,7 @@ import {
|
||||
encryptAES256GCM,
|
||||
getPayload,
|
||||
getWSDbRelayerUrl,
|
||||
} from './provingUtils';
|
||||
} from '@src/utils/proving/provingUtils';
|
||||
import {
|
||||
checkIfPassportDscIsInTree,
|
||||
checkPassportSupported,
|
||||
@@ -48,7 +48,7 @@ import {
|
||||
isDocumentNullified,
|
||||
isUserRegistered,
|
||||
isUserRegisteredWithAlternativeCSCA,
|
||||
} from './validateDocument';
|
||||
} from '@src/utils/proving/validateDocument';
|
||||
|
||||
const { trackEvent } = analytics();
|
||||
|
||||
@@ -879,7 +879,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
|
||||
try {
|
||||
const {
|
||||
registerDeviceToken,
|
||||
} = require('../../utils/notifications/notificationService');
|
||||
} = require('@src/utils/notifications/notificationService');
|
||||
const isMockPassport = passportData?.mock;
|
||||
trackEvent(ProofEvents.DEVICE_TOKEN_REG_STARTED);
|
||||
await registerDeviceToken(uuid, fcmToken, isMockPassport);
|
||||
|
||||
@@ -20,7 +20,8 @@ import {
|
||||
} from '@selfxyz/common/utils/passports';
|
||||
import { getLeafDscTree } from '@selfxyz/common/utils/trees';
|
||||
|
||||
import { DocumentEvents } from '../../consts/analytics';
|
||||
import { LeanIMT } from '@openpassport/zk-kit-lean-imt';
|
||||
import { DocumentEvents } from '@src/consts/analytics';
|
||||
import {
|
||||
getAllDocuments,
|
||||
loadDocumentCatalog,
|
||||
@@ -29,11 +30,9 @@ import {
|
||||
setSelectedDocument,
|
||||
storePassportData,
|
||||
updateDocumentRegistrationState,
|
||||
} from '../../providers/passportDataProvider';
|
||||
import { useProtocolStore } from '../../stores/protocolStore';
|
||||
import analytics from '../../utils/analytics';
|
||||
|
||||
import { LeanIMT } from '@openpassport/zk-kit-lean-imt';
|
||||
} from '@src/providers/passportDataProvider';
|
||||
import { useProtocolStore } from '@src/stores/protocolStore';
|
||||
import analytics from '@src/utils/analytics';
|
||||
|
||||
const { trackEvent } = analytics();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import Keychain from 'react-native-keychain';
|
||||
|
||||
import { loadDocumentCatalog } from '../providers/passportDataProvider';
|
||||
import { loadDocumentCatalog } from '@src/providers/passportDataProvider';
|
||||
|
||||
/**
|
||||
* Testing utility function to clear the document catalog for migration testing.
|
||||
|
||||
Reference in New Issue
Block a user