Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/metro.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const extraNodeModules = {
sdkAlphaPath,
'dist/esm/constants/analytics.js',
),
'@selfxyz/mobile-sdk-alpha/stores': path.resolve(
sdkAlphaPath,
'dist/esm/stores.js',
),
Comment on lines +31 to +34
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify compiled entry exists for '@selfxyz/mobile-sdk-alpha/stores'

Metro resolves to dist/esm/stores.js. If this file isn’t emitted, bundling will fail.


🏁 Script executed:

#!/bin/bash
ls -l ../packages/mobile-sdk-alpha/dist/esm/stores.js || echo "stores.js missing"

Length of output: 112


Missing compiled entry for '@selfxyz/mobile-sdk-alpha/stores' The file dist/esm/stores.js doesn’t exist—ensure your build emits this file (or update the alias to the correct output path).

🤖 Prompt for AI Agents
In app/metro.config.cjs around lines 31 to 34, the alias maps
'@selfxyz/mobile-sdk-alpha/stores' to dist/esm/stores.js but that compiled file
does not exist; update the alias to point at the actual build output or ensure
the build produces dist/esm/stores.js. Either change the path.resolve target to
the correct emitted file (e.g., dist/index.js or dist/esm/stores/index.js) or
modify the package build config to emit stores.js at dist/esm/stores.js, and
verify the file exists before committing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm even after building?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Let's check the current build structure and then attempt to build
echo "=== Current mobile-sdk-alpha dist structure ==="
find packages/mobile-sdk-alpha/dist -name "*.js" 2>/dev/null || echo "No dist directory or JS files found"

echo -e "\n=== Checking tsup config entry points ==="
cat packages/mobile-sdk-alpha/tsup.config.ts

echo -e "\n=== Building mobile-sdk-alpha package ==="
cd packages/mobile-sdk-alpha
npm run build 2>&1 || echo "Build failed or npm run build not available"

echo -e "\n=== Post-build dist structure ==="
find dist -name "*.js" 2>/dev/null | head -10 || echo "No dist directory found after build"

echo -e "\n=== Specifically checking for stores.js ==="
ls -la dist/esm/stores.js 2>/dev/null || echo "stores.js not found at expected location"

echo -e "\n=== Checking if stores directory exists ==="
ls -la dist/esm/stores/ 2>/dev/null || echo "No stores directory found"

Length of output: 2744


🏁 Script executed:

#!/bin/bash
# Let's verify the source files exist and understand the expected structure
echo "=== Checking if source files exist ==="
ls -la packages/mobile-sdk-alpha/src/stores/

echo -e "\n=== Content of stores/index.ts ==="
cat packages/mobile-sdk-alpha/src/stores/index.ts

echo -e "\n=== Checking package.json build scripts ==="
cd packages/mobile-sdk-alpha
grep -A5 -B5 "scripts" package.json

echo -e "\n=== Checking if tsup is listed in dependencies ==="
grep -A10 -B5 "tsup\|devDependencies" package.json

Length of output: 3421


@aaronmgdr You're absolutely right! After building, the file should definitely exist.

Looking at your configuration, everything is set up correctly:

  • tsup config has stores: 'src/stores/index.ts' entry point ✅
  • Source file src/stores/index.ts exists and exports useProtocolStore
  • Build script runs tsup which should output to dist/esm/stores.js
  • tsup is listed in devDependencies

The Metro alias pointing to dist/esm/stores.js is correct. The sandbox environment I'm running in doesn't have the build tools available, so I couldn't verify by actually building, but based on your tsup configuration, running npm run build in the packages/mobile-sdk-alpha directory should indeed create the dist/esm/stores.js file that Metro is looking for.

The configuration looks solid - once you build the mobile-sdk-alpha package, the alias should resolve correctly!


🧠 Learnings used
Learnt from: aaronmgdr
PR: selfxyz/self#951
File: app/src/providers/authProvider.web.tsx:17-18
Timestamp: 2025-08-25T14:25:57.586Z
Learning: The selfxyz/mobile-sdk-alpha/constants/analytics import path is properly configured with SDK exports, Metro aliases, and TypeScript resolution. Import changes from @/consts/analytics to this path are part of valid analytics migration, not TypeScript resolution issues.

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/src/index.ts : Re-export new SDK modules via packages/mobile-sdk-alpha/src/index.ts

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Use actual imports from selfxyz/mobile-sdk-alpha in tests

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/package.json : Enable tree shaking for the SDK (e.g., ensure 'sideEffects' is correctly set in package.json and exports are ESM-friendly)

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/**/package.json : Ensure package exports are properly configured

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/**/*.{ts,tsx} : Avoid introducing circular dependencies

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Do NOT mock selfxyz/mobile-sdk-alpha in tests (avoid jest.mock('selfxyz/mobile-sdk-alpha') and replacing real functions with mocks)

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/**/package.json : Verify package conditions are valid (e.g., exports conditions)

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Update the app to consume the mobile-sdk-alpha package and replace local modules with SDK imports

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to app/jest.config.cjs : Configure moduleNameMapper in app/jest.config.cjs to map '@/'' to 'src/' and 'tests/' to 'tests/src/'

Learnt from: CR
PR: selfxyz/self#0
File: app/AGENTS.md:0-0
Timestamp: 2025-08-29T15:30:12.210Z
Learning: Document complex native module changes for AI review

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/README.md : Document new/updated SDK modules and usage in packages/mobile-sdk-alpha/README.md

// Main exports
'@selfxyz/common/utils': path.resolve(
commonPath,
Expand Down Expand Up @@ -163,6 +167,10 @@ const extraNodeModules = {
commonPath,
'dist/esm/src/utils/csca.js',
),
'@selfxyz/common/utils/ofac': path.resolve(
commonPath,
'dist/esm/src/utils/ofac.js',
),
Comment on lines +170 to +173
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify compiled entry exists for '@selfxyz/common/utils/ofac'

Ensure dist/esm/src/utils/ofac.js is part of the common package build outputs.


🏁 Script executed:

#!/bin/bash
ls -l ../common/dist/esm/src/utils/ofac.js || echo "ofac.js missing"

Length of output: 99


🏁 Script executed:

#!/bin/bash
find ../common/dist -type f | grep -Ei 'ofac\.(js|mjs|cjs)$' || echo "no compiled ofac file found"

Length of output: 77


Alias for '@selfxyz/common/utils/ofac' points to a non-existent file
app/metro.config.cjs:170-173 – the alias resolves to dist/esm/src/utils/ofac.js, but no such file is emitted by the common package. Update the alias to a valid build output or include ofac.js in the common build.

🤖 Prompt for AI Agents
In app/metro.config.cjs around lines 170–173, the alias for
'@selfxyz/common/utils/ofac' points to dist/esm/src/utils/ofac.js which doesn't
exist; inspect the common package's build output to determine the actual emitted
path (for example an index.js under dist/esm/src/utils/ofac/ or a different
filename), then update the alias to that exact emitted file path OR add/export
ofac.js in the common package build and re-run the build; after changing the
alias, rebuild the common package and clear Metro cache to verify resolution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double check this. it should after we build the package

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

@aaronmgdr You're absolutely right! Let me verify the build configuration to confirm the OFAC utility will be properly built.


🏁 Script executed:

#!/bin/bash
# Check if the source file exists
echo "=== Source file check ==="
ls -la common/src/utils/ofac.ts

echo -e "\n=== Build configuration check ==="
# Check tsup.config.ts for ofac entry
cat common/tsup.config.ts | grep -A5 -B5 "ofac"

echo -e "\n=== Package.json export check ==="
# Check package.json exports for ofac
cat common/package.json | jq '.exports."./utils/ofac"'

echo -e "\n=== Current dist structure (if exists) ==="
# Check current dist structure
find common/dist -name "*ofac*" 2>/dev/null || echo "No ofac files in current dist (expected before build)"

echo -e "\n=== Verify tsup entry configuration ==="
# Show the full entry configuration from tsup.config.ts
cat common/tsup.config.ts | grep -A20 -B5 "entry.*{" | head -30

Length of output: 2918


@aaronmgdr You're absolutely correct! The build configuration is properly set up:

Source file exists: common/src/utils/ofac.ts
tsup.config.ts entry: 'src/utils/ofac': 'src/utils/ofac.ts'
package.json export: Maps ./utils/ofac to dist/esm/src/utils/ofac.js
Metro alias: Points to the correct build output path

The verification agent was checking the current state (before build), but your configuration will generate dist/esm/src/utils/ofac.js when the common package is built. The Metro alias is correctly configured for the post-build state.

The OFAC utility migration looks good to go! 🚀


🧠 Learnings used
Learnt from: transphorm
PR: selfxyz/self#795
File: app/src/screens/prove/ProveScreen.tsx:5-5
Timestamp: 2025-07-28T19:18:48.270Z
Learning: The import path 'selfxyz/common/utils/scope' is valid when the common package has a "./utils/*" export mapping in package.json, even if ESLint shows resolution errors before the package is built. The package.json exports field properly maps "./utils/*" to the compiled files in dist/.

Learnt from: aaronmgdr
PR: selfxyz/self#951
File: app/src/providers/authProvider.web.tsx:17-18
Timestamp: 2025-08-25T14:25:57.586Z
Learning: The selfxyz/mobile-sdk-alpha/constants/analytics import path is properly configured with SDK exports, Metro aliases, and TypeScript resolution. Import changes from @/consts/analytics to this path are part of valid analytics migration, not TypeScript resolution issues.

Learnt from: CR
PR: selfxyz/self#0
File: app/AGENTS.md:0-0
Timestamp: 2025-08-29T15:30:12.210Z
Learning: Document complex native module changes for AI review

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/src/index.ts : Re-export new SDK modules via packages/mobile-sdk-alpha/src/index.ts

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Use actual imports from selfxyz/mobile-sdk-alpha in tests

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/package.json : Enable tree shaking for the SDK (e.g., ensure 'sideEffects' is correctly set in package.json and exports are ESM-friendly)

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/**/*.{ts,tsx} : Avoid introducing circular dependencies

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/README.md : Document new/updated SDK modules and usage in packages/mobile-sdk-alpha/README.md

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/**/package.json : Ensure package exports are properly configured

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Update the app to consume the mobile-sdk-alpha package and replace local modules with SDK imports

// Types subpaths
'@selfxyz/common/types/passport': path.resolve(
commonPath,
Expand Down
2 changes: 1 addition & 1 deletion app/src/screens/recovery/AccountRecoveryChoiceScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useNavigation } from '@react-navigation/native';
import { isUserRegisteredWithAlternativeCSCA } from '@selfxyz/common/utils/passports/validate';
import { useSelfClient } from '@selfxyz/mobile-sdk-alpha';
import { BackupEvents } from '@selfxyz/mobile-sdk-alpha/constants/analytics';
import { useProtocolStore } from '@selfxyz/mobile-sdk-alpha/stores';

import { PrimaryButton } from '@/components/buttons/PrimaryButton';
import { SecondaryButton } from '@/components/buttons/SecondaryButton';
Expand All @@ -24,7 +25,6 @@ import {
loadPassportDataAndSecret,
reStorePassportDataWithRightCSCA,
} from '@/providers/passportDataProvider';
import { useProtocolStore } from '@/stores/protocolStore';
import { useSettingStore } from '@/stores/settingStore';
import { STORAGE_NAME, useBackupMnemonic } from '@/utils/cloudBackup';
import { black, slate500, slate600, white } from '@/utils/colors';
Expand Down
2 changes: 1 addition & 1 deletion app/src/screens/recovery/RecoverWithPhraseScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useNavigation } from '@react-navigation/native';
import { isUserRegisteredWithAlternativeCSCA } from '@selfxyz/common/utils/passports/validate';
import { useSelfClient } from '@selfxyz/mobile-sdk-alpha';
import { BackupEvents } from '@selfxyz/mobile-sdk-alpha/constants/analytics';
import { useProtocolStore } from '@selfxyz/mobile-sdk-alpha/stores';

import { SecondaryButton } from '@/components/buttons/SecondaryButton';
import Description from '@/components/typography/Description';
Expand All @@ -21,7 +22,6 @@ import {
loadPassportDataAndSecret,
reStorePassportDataWithRightCSCA,
} from '@/providers/passportDataProvider';
import { useProtocolStore } from '@/stores/protocolStore';
import {
black,
slate300,
Expand Down
15 changes: 2 additions & 13 deletions app/src/utils/proving/provingInputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,9 @@

import type { DocumentCategory, PassportData } from '@selfxyz/common/types';
import type { SelfApp } from '@selfxyz/common/utils';
import {
generateCircuitInputsRegister,
generateTEEInputsDiscloseStateless,
generateTEEInputsDSC,
generateTEEInputsRegister,
} from '@selfxyz/common/utils/circuits/registerInputs';
import { generateTEEInputsDiscloseStateless } from '@selfxyz/common/utils/circuits/registerInputs';
import { useProtocolStore } from '@selfxyz/mobile-sdk-alpha/stores';

import { useProtocolStore } from '@/stores/protocolStore';

export {
generateCircuitInputsRegister,
generateTEEInputsDSC,
generateTEEInputsRegister,
};
export function generateTEEInputsDisclose(
secret: string,
passportData: PassportData,
Expand Down
12 changes: 6 additions & 6 deletions app/src/utils/proving/provingMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import {
getSolidityPackedUserContextData,
} from '@selfxyz/common/utils';
import { getPublicKey, verifyAttestation } from '@selfxyz/common/utils/attest';
import {
generateTEEInputsDSC,
generateTEEInputsRegister,
} from '@selfxyz/common/utils/circuits/registerInputs';
import {
checkDocumentSupported,
checkIfPassportDscIsInTree,
Expand All @@ -41,6 +45,7 @@ import {
PassportEvents,
ProofEvents,
} from '@selfxyz/mobile-sdk-alpha/constants/analytics';
import { useProtocolStore } from '@selfxyz/mobile-sdk-alpha/stores';

import { navigationRef } from '@/navigation';
// will need to be passed in from selfClient
Expand All @@ -49,14 +54,9 @@ import {
markCurrentDocumentAsRegistered,
reStorePassportDataWithRightCSCA,
} from '@/providers/passportDataProvider';
import { useProtocolStore } from '@/stores/protocolStore';
import { useSelfAppStore } from '@/stores/selfAppStore';
import analytics from '@/utils/analytics';
import {
generateTEEInputsDisclose,
generateTEEInputsDSC,
generateTEEInputsRegister,
} from '@/utils/proving/provingInputs';
import { generateTEEInputsDisclose } from '@/utils/proving/provingInputs';

const { trackEvent } = analytics();

Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/proving/validateDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { isUserRegistered } from '@selfxyz/common/utils/passports/validate';
import type { PassportValidationCallbacks } from '@selfxyz/mobile-sdk-alpha';
import { isPassportDataValid } from '@selfxyz/mobile-sdk-alpha';
import { DocumentEvents } from '@selfxyz/mobile-sdk-alpha/constants/analytics';
import { useProtocolStore } from '@selfxyz/mobile-sdk-alpha/stores';

import {
getAllDocumentsDirectlyFromKeychain,
Expand All @@ -16,7 +17,6 @@ import {
storePassportData,
updateDocumentRegistrationState,
} from '@/providers/passportDataProvider';
import { useProtocolStore } from '@/stores/protocolStore';
import analytics from '@/utils/analytics';

const { trackEvent } = analytics();
Expand Down
2 changes: 1 addition & 1 deletion app/tests/src/utils/proving/validateDocument.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jest.mock('@/providers/passportDataProvider', () => ({
}));

// Mock the protocol store to avoid complex state management
jest.mock('@/stores/protocolStore', () => ({
jest.mock('@selfxyz/mobile-sdk-alpha/stores', () => ({
useProtocolStore: {
getState: jest.fn(() => ({
passport: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// SPDX-License-Identifier: BUSL-1.1
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.

import { useProtocolStore } from '@/stores/protocolStore';
import { useProtocolStore } from '@selfxyz/mobile-sdk-alpha/stores';

import { useSelfAppStore } from '@/stores/selfAppStore';
import { useProvingStore } from '@/utils/proving/provingMachine';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// 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 { SelfClient } from '@selfxyz/mobile-sdk-alpha';
import { useProtocolStore } from '@selfxyz/mobile-sdk-alpha/stores';

import { useProtocolStore } from '@/stores/protocolStore';
import { useProvingStore } from '@/utils/proving/provingMachine';

import { actorMock } from './actorMock';
Expand Down
3 changes: 3 additions & 0 deletions app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"@selfxyz/mobile-sdk-alpha/constants/analytics": [
"../packages/mobile-sdk-alpha/dist/esm/constants/analytics.js"
],
"@selfxyz/mobile-sdk-alpha/stores": [
"../packages/mobile-sdk-alpha/dist/esm/stores.js"
],
Comment on lines +20 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Ensure type declarations exist for the new alias target

The alias maps directly to dist/esm/stores.js. If dist/esm/stores.d.ts isn’t emitted, consumers lose types and IDE tooling.

Run:

If stores.d.ts is missing, ensure tsup/tsconfig emits declarations for the stores entry.


🏁 Script executed:

#!/bin/bash
# Verify compiled JS and DTS exist for the alias
ls -l ../packages/mobile-sdk-alpha/dist/esm/stores.js || echo "stores.js missing"
ls -l ../packages/mobile-sdk-alpha/dist/esm/stores.d.ts || echo "stores.d.ts missing"

Length of output: 229


Fix missing build artifacts for stores alias
The path mapping in app/tsconfig.json (lines 20–22) points at ../packages/mobile-sdk-alpha/dist/esm/stores.js, but neither stores.js nor stores.d.ts exists in that directory. This breaks module resolution and strips away type definitions. Ensure your build emits both the JS and DTS for stores (e.g., via tsup’s entry/dts config) or update the alias to the actual output location (for example, dist/esm/stores/index.js and its corresponding .d.ts).

🤖 Prompt for AI Agents
In app/tsconfig.json around lines 20–22, the path mapping points to
../packages/mobile-sdk-alpha/dist/esm/stores.js but that file (and its .d.ts)
are missing which breaks module resolution; either adjust the alias to the
actual build output (e.g., ../packages/mobile-sdk-alpha/dist/esm/stores/index.js
and corresponding .d.ts) or update the mobile-sdk-alpha build (tsup/tsconfig) to
emit stores.js and stores.d.ts (add the stores entry to tsup entries and enable
dts output) so both JS and type artifacts exist at the mapped path.

"@/*": ["./src/*"]
}
},
Expand Down
5 changes: 5 additions & 0 deletions common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@
"types": "./dist/esm/src/utils/passports/format.d.ts",
"import": "./dist/esm/src/utils/passports/format.js",
"require": "./dist/cjs/src/utils/passports/format.cjs"
},
"./utils/ofac": {
"types": "./dist/esm/src/utils/ofac.d.ts",
"import": "./dist/esm/src/utils/ofac.js",
"require": "./dist/cjs/src/utils/ofac.cjs"
}
},
"main": "./dist/cjs/index.cjs",
Expand Down
5 changes: 5 additions & 0 deletions common/scripts/shimConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ export const shimConfigs = [
targetPath: '../../esm/src/utils/certificate_parsing/oids.js',
name: 'utils/oids',
},
{
shimPath: 'utils/ofac',
targetPath: '../../esm/src/utils/ofac.js',
name: 'utils/ofac',
},
{
shimPath: 'utils/passportDg1',
targetPath: '../../esm/src/utils/passports/dg1.js',
Expand Down
2 changes: 1 addition & 1 deletion common/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type {
export type { DocumentCategory, PassportData } from './types.js';
export type { IdDocInput } from './passports/genMockIdDoc.js';
export type { PassportMetadata } from './passports/passport_parsing/parsePassportData.js';
export type { TEEPayload, TEEPayloadBase, TEEPayloadDisclose } from './proving.js';
export type { UserIdType } from './circuits/uuid.js';
export {
EndpointType,
Expand Down Expand Up @@ -41,7 +42,6 @@ export {
generateNullifier,
initPassportDataParsing,
} from './passports/passport.js';
export type { TEEPayload, TEEPayloadBase, TEEPayloadDisclose } from './proving.js';
export { formatMrz } from './passports/format.js';
export { genAndInitMockPassportData } from './passports/genMockPassportData.js';
export {
Expand Down
18 changes: 6 additions & 12 deletions app/src/utils/ofac.ts → common/src/utils/ofac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: BUSL-1.1
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.

import { TREE_URL, TREE_URL_STAGING } from '@selfxyz/common/constants';
import type { OfacTree } from '@selfxyz/common/utils/types';
import { TREE_URL, TREE_URL_STAGING } from '../constants/constants.js';
import type { OfacTree } from './types.js';

export type OfacVariant = 'passport' | 'id_card';

Expand All @@ -16,9 +16,7 @@ const fetchTree = async (url: string): Promise<any> => {
const responseData = await res.json();
if (responseData.status !== 'success' || !responseData.data) {
throw new Error(
`Failed to fetch tree from ${url}: ${
responseData.message || 'Invalid response format'
}`,
`Failed to fetch tree from ${url}: ${responseData.message || 'Invalid response format'}`
);
}
return responseData.data;
Expand All @@ -27,17 +25,13 @@ const fetchTree = async (url: string): Promise<any> => {
// Main public helper that retrieves the three OFAC trees depending on the variant (passport vs id_card).
export const fetchOfacTrees = async (
environment: 'prod' | 'stg',
variant: OfacVariant = 'passport',
variant: OfacVariant = 'passport'
): Promise<OfacTree> => {
const baseUrl = environment === 'prod' ? TREE_URL : TREE_URL_STAGING;

const ppNoNatUrl = `${baseUrl}/ofac/passport-no-nationality`;
const nameDobUrl = `${baseUrl}/ofac/name-dob${
variant === 'id_card' ? '-id' : ''
}`;
const nameYobUrl = `${baseUrl}/ofac/name-yob${
variant === 'id_card' ? '-id' : ''
}`;
const nameDobUrl = `${baseUrl}/ofac/name-dob${variant === 'id_card' ? '-id' : ''}`;
const nameYobUrl = `${baseUrl}/ofac/name-yob${variant === 'id_card' ? '-id' : ''}`;

// For ID cards, we intentionally skip fetching the (large) passport-number-tree.
if (variant === 'id_card') {
Expand Down
1 change: 1 addition & 0 deletions common/src/utils/passportData.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-require-imports */
import type { PassportData } from './types.js';

const fs = require('fs');
Expand Down
1 change: 1 addition & 0 deletions common/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const entry = {
'src/utils/contracts/index': 'src/utils/contracts/index.ts',
'src/utils/contracts/forbiddenCountries': 'src/utils/contracts/forbiddenCountries.ts',
'src/utils/csca': 'src/utils/csca.ts',
'src/utils/ofac': 'src/utils/ofac.ts',
// Level 3 Hash Function Exports
'src/utils/hash/poseidon': 'src/utils/hash/poseidon.ts',
'src/utils/hash/sha': 'src/utils/hash/sha.ts',
Expand Down
12 changes: 9 additions & 3 deletions packages/mobile-sdk-alpha/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@selfxyz/mobile-sdk-alpha",
"version": "2.6.4",
"version": "0.0.1",
"description": "Self SDK (alpha) for registering and proving. Adapters-first, RN-first with web shims.",
"keywords": [
"self",
Expand All @@ -24,6 +24,11 @@
"import": "./dist/esm/browser.js",
"require": "./dist/cjs/browser.cjs"
},
"./stores": {
"types": "./dist/esm/stores.d.ts",
"import": "./dist/esm/stores.js",
"require": "./dist/cjs/stores.cjs"
},
"./constants/analytics": {
"types": "./dist/esm/constants/analytics.d.ts",
"import": "./dist/esm/constants/analytics.js",
Expand Down Expand Up @@ -64,10 +69,11 @@
"validate:pkg": "node ./scripts/verify-conditions.mjs"
},
"dependencies": {
"tslib": "^2.6.2"
"@selfxyz/common": "workspace:^",
"tslib": "^2.6.2",
"zustand": "^4.5.2"
},
Comment on lines +72 to 75
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Avoid bundling zustand inside the SDK to prevent duplicate copies in apps.

Bundling zustand increases bundle size and risks multiple store instances. Externalize it in tsup so consumers reuse a single copy.

Apply this in tsup configs:

// packages/mobile-sdk-alpha/tsup.config.ts (both ESM and CJS configs)
-    external: ['react', 'react-native', '@selfxyz/common'],
+    external: ['react', 'react-native', '@selfxyz/common', 'zustand'],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@selfxyz/common": "workspace:^",
"tslib": "^2.6.2",
"zustand": "^4.5.2"
},
// packages/mobile-sdk-alpha/tsup.config.ts (both ESM and CJS configs)
external: ['react', 'react-native', '@selfxyz/common', 'zustand'],
🤖 Prompt for AI Agents
In packages/mobile-sdk-alpha/package.json around lines 72 to 75, the dependency
"zustand" is currently listed in dependencies which causes it to be bundled into
the SDK; change the packaging so consumers share a single copy by removing or
moving "zustand" out of runtime bundling: add "zustand" to peerDependencies (and
devDependencies for local builds) in package.json and update the tsup build
config to mark "zustand" as external (e.g., add "zustand" to external/
noExternal settings) so it is not bundled into the final artifact.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ill keep for now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaronmgdr Understood! I'll note that you prefer to keep zustand bundled in the SDK for now.

🐰
╭─────╮
│ ◕ ◕ │
│ ︶ │ (respecting your decision)
╰─────╯


🧠 Learnings used
Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/**/package.json : Verify package conditions are valid (e.g., exports conditions)

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/**/package.json : Ensure package exports are properly configured

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Use actual imports from selfxyz/mobile-sdk-alpha in tests

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/package.json : Enable tree shaking for the SDK (e.g., ensure 'sideEffects' is correctly set in package.json and exports are ESM-friendly)

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/**/*.{ts,tsx} : Avoid introducing circular dependencies

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/package.json : Expose a 'test:build' script in the SDK's package.json that runs build, test, types, and lint

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Do NOT mock selfxyz/mobile-sdk-alpha in tests (avoid jest.mock('selfxyz/mobile-sdk-alpha') and replacing real functions with mocks)

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/**/*.{ts,tsx} : Use strict TypeScript type checking across the codebase

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/src/index.ts : Re-export new SDK modules via packages/mobile-sdk-alpha/src/index.ts

Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/**/*.{ts,tsx} : Follow ESLint TypeScript-specific rules

Learnt from: CR
PR: selfxyz/self#0
File: .cursorrules:0-0
Timestamp: 2025-08-24T18:52:25.796Z
Learning: Applies to src/**/*.{ts,tsx} : Use Zustand for global state management

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Update the app to consume the mobile-sdk-alpha package and replace local modules with SDK imports

Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/README.md : Document new/updated SDK modules and usage in packages/mobile-sdk-alpha/README.md

"devDependencies": {
"@selfxyz/common": "workspace:^",
"@testing-library/react": "^14.1.2",
"@types/react": "^18.3.4",
"@typescript-eslint/eslint-plugin": "^8.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/mobile-sdk-alpha/scripts/postBuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const distPackageJson = {
'.': './esm/index.js',
'./browser': './esm/browser.js',
'./constants/analytics': './esm/constants/analytics.js',
'./stores': './esm/stores.js',
},
};
try {
Expand Down
1 change: 1 addition & 0 deletions packages/mobile-sdk-alpha/scripts/shimConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
export const shimConfigs = [
{ shimPath: 'browser', targetPath: '../esm/browser.js', name: 'browser' },
{ shimPath: 'constants/analytics', targetPath: '../../esm/constants/analytics.js', name: 'constants/analytics' },
{ shimPath: 'stores', targetPath: '../esm/stores.js', name: 'stores' },
];
2 changes: 2 additions & 0 deletions packages/mobile-sdk-alpha/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,7 @@ export { reactNativeScannerAdapter } from './adapters/react-native/scanner';

export { scanQRProof } from './qr';

export { useProtocolStore } from './stores/protocolStore';

// Error handling
export { webScannerShim } from './adapters/web/shims';
5 changes: 5 additions & 0 deletions packages/mobile-sdk-alpha/src/stores/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// 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.

export { useProtocolStore } from './protocolStore';
Loading
Loading