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
14 changes: 10 additions & 4 deletions app/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// 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

module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -26,9 +28,6 @@ module.exports = {
'web/dist/',
'.tamagui/*',
'*.js.map',
'*.d.ts',
'metro.config.cjs',
'docs/examples/',
'tests/e2e/',
],
settings: {
Expand Down Expand Up @@ -169,6 +168,14 @@ module.exports = {
'@typescript-eslint/indent': 'off',
},
overrides: [
{
files: ['docs/examples/**/*.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'no-unused-vars': 'off',
'import/no-unresolved': 'off',
},
},
{
// Disable export sorting for files with dependency issues
files: [
Expand Down Expand Up @@ -212,7 +219,6 @@ module.exports = {
sourceType: 'script',
},
rules: {
'header/header': 'off',
'@typescript-eslint/no-var-requires': 'off',
'no-undef': 'off',
},
Expand Down
2 changes: 2 additions & 0 deletions app/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// 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

module.exports = {
presets: ['module:@react-native/babel-preset'],
plugins: [
Expand Down
5 changes: 3 additions & 2 deletions app/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ declare module '*.jpeg' {
}

declare module '*.svg' {
import React from 'react';
import { SvgProps } from 'react-native-svg';
import type React from 'react';
import type { SvgProps } from 'react-native-svg';

const content: React.FC<SvgProps>;
export default content;
}
4 changes: 3 additions & 1 deletion app/docs/examples/tree-shaking/granular-circuits-example.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// 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

// Granular import example: Circuit utilities only
// This will tree-shake out passport parsing, certificate parsing, etc.

import { generateCircuitInputsDSC } from '@selfxyz/common/utils/circuits';
import type { PassportData } from '@selfxyz/common/types/passport';
import { generateCircuitInputsDSC } from '@selfxyz/common/utils/circuits';

export function exampleCircuitUsage(passportData: PassportData) {
// Only circuit-related utilities are bundled
Expand Down
8 changes: 4 additions & 4 deletions app/docs/examples/tree-shaking/level2-optimal-example.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// 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

// Level 2 Granular Import Example - Optimal Tree Shaking
// This demonstrates the new file-based imports for maximum optimization

Expand All @@ -6,22 +8,20 @@
API_URL,
PASSPORT_ATTESTATION_ID,
} from '@selfxyz/common/constants/core';

// Import only hash utilities (no bytes, trees, circuits, etc.)
import { hash } from '@selfxyz/common/utils/hash';

// Import only passport types (no app types, certificate types, etc.)
import type { PassportData } from '@selfxyz/common/types/passport';
// Import only hash utilities (no bytes, trees, circuits, etc.)
import { hash } from '@selfxyz/common/utils/hash';

export function optimalLevel2Example(data: PassportData) {
// This will result in the smallest possible bundle
// Only the specific functions and constants we use are included

console.log('Using API:', API_URL);

Check warning on line 20 in app/docs/examples/tree-shaking/level2-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 20 in app/docs/examples/tree-shaking/level2-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
console.log('Attestation ID:', PASSPORT_ATTESTATION_ID);

Check warning on line 21 in app/docs/examples/tree-shaking/level2-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 21 in app/docs/examples/tree-shaking/level2-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

const hashedData = hash(JSON.stringify(data));
console.log('Hashed passport data:', hashedData);

Check warning on line 24 in app/docs/examples/tree-shaking/level2-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 24 in app/docs/examples/tree-shaking/level2-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

return {
api: API_URL,
Expand Down
68 changes: 33 additions & 35 deletions app/docs/examples/tree-shaking/level3-migration-guide.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// 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

/**
* LEVEL 3 MIGRATION GUIDE - Function-Level Granular Imports
*
Expand Down Expand Up @@ -25,45 +27,38 @@
// ============================================================================

// ✅ Hash Functions - Import only what you need
import { hash } from '@selfxyz/common/utils/hash/sha'; // ~3KB instead of 15KB
import { flexiblePoseidon } from '@selfxyz/common/utils/hash/poseidon'; // ~2KB instead of 15KB
import type { CertificateData } from '@selfxyz/common/types/certificates';
// ✅ Types - Import specific type categories
import type { PassportData } from '@selfxyz/common/types/passport'; // Types are tree-shaken automatically
import { identifyCurve } from '@selfxyz/common/utils/certificates/curveUtils'; // ~3KB instead of 20KB
import { initElliptic } from '@selfxyz/common/utils/certificates/ellipticInit'; // ~2KB instead of 20KB
// No need to import disclose or OFAC inputs if not used
// ✅ Certificate Functions - Import specific parsing operations
import { parseCertificateSimple } from '@selfxyz/common/utils/certificates/parseSimple'; // ~5KB instead of 20KB
// No need to import custom hash functions if not used

// ✅ Circuit Functions - Import specific circuit generators
import { generateCircuitInputsDSC } from '@selfxyz/common/utils/circuits/dscInputs'; // ~8KB instead of 25KB
import { generateCircuitInputsRegister } from '@selfxyz/common/utils/circuits/registerInputs'; // ~7KB instead of 25KB
// No need to import disclose or OFAC inputs if not used

// ✅ Certificate Functions - Import specific parsing operations
import { parseCertificateSimple } from '@selfxyz/common/utils/certificates/parseSimple'; // ~5KB instead of 20KB
import { initElliptic } from '@selfxyz/common/utils/certificates/ellipticInit'; // ~2KB instead of 20KB
import { identifyCurve } from '@selfxyz/common/utils/certificates/curveUtils'; // ~3KB instead of 20KB

import { flexiblePoseidon } from '@selfxyz/common/utils/hash/poseidon'; // ~2KB instead of 15KB
import { hash } from '@selfxyz/common/utils/hash/sha'; // ~3KB instead of 15KB
// ✅ Passport Functions - Import specific operations
import { generateCommitment } from '@selfxyz/common/utils/passports/commitment'; // ~3KB instead of 15KB
import { initPassportDataParsing } from '@selfxyz/common/utils/passports/core'; // ~4KB instead of 15KB
import { getPassportSignatureInfos } from '@selfxyz/common/utils/passports/signature'; // ~5KB instead of 15KB

// ✅ Types - Import specific type categories
import type { PassportData } from '@selfxyz/common/types/passport'; // Types are tree-shaken automatically
import type { CertificateData } from '@selfxyz/common/types/certificates';

// ============================================================================
// MIGRATION EXAMPLES BY USE CASE
// ============================================================================
import { getPassportSignatureInfos } from '@selfxyz/common/utils/passports/signature';

/**
* USE CASE 1: Frontend App - Only needs basic hash and passport parsing
* Bundle size reduction: ~60KB → ~15KB (75% smaller!)
* USE CASE 3: Certificate Parser - Only needs certificate operations
* Bundle size reduction: ~35KB → ~10KB (71% smaller!)
*/
export function frontendOptimalImports() {
// Only import what this specific frontend component needs
// import { hash } from '@selfxyz/common/utils/hash/sha';
// import { initPassportDataParsing } from '@selfxyz/common/utils/passports/core';
// import type { PassportData } from '@selfxyz/common/types/passport';
// Your component code here...
export function certificateParserOptimalImports() {
// Only import certificate-specific functions
// import { parseCertificateSimple } from '@selfxyz/common/utils/certificates/parseSimple';
// import { identifyCurve } from '@selfxyz/common/utils/certificates/curveUtils';
// import { getFriendlyName } from '@selfxyz/common/utils/certificates/oidUtils';
// Your certificate parsing code here...
}

// ~5KB instead of 15KB
/**
* USE CASE 2: Circuit Worker - Only needs circuit generation
* Bundle size reduction: ~45KB → ~8KB (82% smaller!)
Expand All @@ -75,16 +70,19 @@ export function circuitWorkerOptimalImports() {
// Your circuit generation code here...
}

// ============================================================================
// MIGRATION EXAMPLES BY USE CASE
// ============================================================================
/**
* USE CASE 3: Certificate Parser - Only needs certificate operations
* Bundle size reduction: ~35KB → ~10KB (71% smaller!)
* USE CASE 1: Frontend App - Only needs basic hash and passport parsing
* Bundle size reduction: ~60KB → ~15KB (75% smaller!)
*/
export function certificateParserOptimalImports() {
// Only import certificate-specific functions
// import { parseCertificateSimple } from '@selfxyz/common/utils/certificates/parseSimple';
// import { identifyCurve } from '@selfxyz/common/utils/certificates/curveUtils';
// import { getFriendlyName } from '@selfxyz/common/utils/certificates/oidUtils';
// Your certificate parsing code here...
export function frontendOptimalImports() {
// Only import what this specific frontend component needs
// import { hash } from '@selfxyz/common/utils/hash/sha';
// import { initPassportDataParsing } from '@selfxyz/common/utils/passports/core';
// import type { PassportData } from '@selfxyz/common/types/passport';
// Your component code here...
}

/**
Expand Down
25 changes: 11 additions & 14 deletions app/docs/examples/tree-shaking/level3-optimal-example.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
// 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

// Level 3 Function-Based Import Example - Maximum Tree Shaking
// This demonstrates the new function-level imports for ultimate optimization
// ✅ Uses clean re-exports (safe, no regression risk)

// ✅ LEVEL 3: Import only specific hash functions (not entire hash module)
import { hash } from '@selfxyz/common/utils/hash/sha';
import { flexiblePoseidon } from '@selfxyz/common/utils/hash/poseidon';

// ✅ LEVEL 3: Import only specific circuit generator (not entire circuits module)
import { generateCircuitInputsDSC } from '@selfxyz/common/utils/circuits/dscInputs';

// ✅ LEVEL 3: Import only specific passport functions (not entire passports module)
import { generateCommitment } from '@selfxyz/common/utils/passports/commitment';
import { initPassportDataParsing } from '@selfxyz/common/utils/passports/core';

// ✅ LEVEL 3: Import only specific certificate parsing (not entire certificates module)
import { parseCertificateSimple } from '@selfxyz/common/utils/certificate_parsing/parseSimple';

// Import only core constants (same as Level 2)
import {
API_URL,
PASSPORT_ATTESTATION_ID,
} from '@selfxyz/common/constants/constants';

// Import only passport types (same as Level 2)
import type { PassportData } from '@selfxyz/common/types/passport';
// ✅ LEVEL 3: Import only specific certificate parsing (not entire certificates module)
import { parseCertificateSimple } from '@selfxyz/common/utils/certificate_parsing/parseSimple';
// ✅ LEVEL 3: Import only specific circuit generator (not entire circuits module)
import { generateCircuitInputsDSC } from '@selfxyz/common/utils/circuits/dscInputs';
import { flexiblePoseidon } from '@selfxyz/common/utils/hash/poseidon';
import { hash } from '@selfxyz/common/utils/hash/sha';
// ✅ LEVEL 3: Import only specific passport functions (not entire passports module)
import { generateCommitment } from '@selfxyz/common/utils/passports/commitment';
import { initPassportDataParsing } from '@selfxyz/common/utils/passports/core';

export function optimalLevel3Example(data: PassportData, secret: string) {
// This will result in the smallest possible bundle
// Only the specific individual functions we use are included
// Bundle size reduction: ~75-90% compared to broad imports!

console.log('Using API:', API_URL);

Check warning on line 30 in app/docs/examples/tree-shaking/level3-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 30 in app/docs/examples/tree-shaking/level3-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
console.log('Attestation ID:', PASSPORT_ATTESTATION_ID);

Check warning on line 31 in app/docs/examples/tree-shaking/level3-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 31 in app/docs/examples/tree-shaking/level3-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

// Use specific hash function from SHA module
const hashedData = hash([1, 2, 3, 4], 'hex');
console.log('SHA hashed data:', hashedData);

Check warning on line 35 in app/docs/examples/tree-shaking/level3-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 35 in app/docs/examples/tree-shaking/level3-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

// Use specific Poseidon function for commitment
const poseidonHash = flexiblePoseidon([BigInt(1), BigInt(2)]);
console.log('Poseidon hash:', poseidonHash);

Check warning on line 39 in app/docs/examples/tree-shaking/level3-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 39 in app/docs/examples/tree-shaking/level3-optimal-example.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

// Use specific passport functions
const parsedData = initPassportDataParsing(data);
Expand Down
1 change: 1 addition & 0 deletions app/env.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// 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

export const DEFAULT_DOB = undefined;

export const DEFAULT_DOE = undefined;
Expand Down
1 change: 1 addition & 0 deletions app/fastlane/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: BUSL-1.1

require "bundler/setup"
require "fastlane"
require "tempfile"
Expand Down
2 changes: 2 additions & 0 deletions app/fastlane/helpers/android.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 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

module Fastlane
module Helpers
module Android
Expand Down
2 changes: 2 additions & 0 deletions app/fastlane/helpers/common.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 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

module Fastlane
module Helpers
module Common
Expand Down
8 changes: 5 additions & 3 deletions app/fastlane/helpers/ios.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 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

module Fastlane
module Helpers
module IOS
Expand All @@ -8,7 +10,7 @@ def ios_verify_app_store_build_number(xcodeproj)
latest = Fastlane::Actions::LatestTestflightBuildNumberAction.run(
api_key: api_key,
app_identifier: ENV["IOS_APP_IDENTIFIER"],
platform: "ios"
platform: "ios",
)

project = Xcodeproj::Project.open(xcodeproj)
Expand Down Expand Up @@ -64,13 +66,13 @@ def ios_increment_build_number(xcodeproj)
latest = Fastlane::Actions::LatestTestflightBuildNumberAction.run(
api_key: api_key,
app_identifier: ENV["IOS_APP_IDENTIFIER"],
platform: "ios"
platform: "ios",
)

new_number = latest + 1
Fastlane::Actions::IncrementBuildNumberAction.run(
build_number: new_number,
xcodeproj: xcodeproj
xcodeproj: xcodeproj,
)
report_success("Incremented build number to #{new_number} (previous #{latest})")
new_number
Expand Down
2 changes: 2 additions & 0 deletions app/fastlane/helpers/slack.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 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

module Fastlane
module Helpers
module Slack
Expand Down
Loading
Loading