Skip to content
Draft
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
1 change: 1 addition & 0 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export {
commonNames,
countries,
countryCodes,
getCountryISO2,
} from './src/constants/index.js';

// Type exports
Expand Down
8 changes: 7 additions & 1 deletion common/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ export {
} from './constants.js';

// Re-export from other constant files
export { alpha2ToAlpha3, alpha3ToAlpha2, commonNames, countries } from './countries.js';
export {
alpha2ToAlpha3,
alpha3ToAlpha2,
commonNames,
countries,
getCountryISO2,
} from './countries.js';
3 changes: 2 additions & 1 deletion common/src/utils/attest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ethers } from 'ethers';
import forge from 'node-forge';
import { PCR0_MANAGER_ADDRESS, RPC_URL } from 'src/constants/constants.js';

import { PCR0_MANAGER_ADDRESS, RPC_URL } from '../constants/constants.js';

const GCP_ROOT_CERT = `
-----BEGIN CERTIFICATE-----
Expand Down
10 changes: 7 additions & 3 deletions packages/mobile-sdk-alpha/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,17 @@ dependencies {

// NFC and Passport Reading dependencies
// implementation 'org.jmrtd:jmrtd:1.7.4'
implementation 'org.jmrtd:jmrtd:0.7.35'
// implementation 'org.jmrtd:jmrtd:0.7.35'
implementation 'org.jmrtd:jmrtd:0.8.3'

implementation 'net.sf.scuba:scuba-sc-android:0.0.23'

// Bouncy Castle for cryptography
implementation 'org.bouncycastle:bcprov-jdk18on:1.78.1'
implementation 'org.bouncycastle:bcpkix-jdk18on:1.78.1'
implementation 'org.bouncycastle:bcprov-jdk18on:1.82'
implementation 'org.bouncycastle:bcpkix-jdk18on:1.82'
implementation ('org.ejbca.cvc:cert-cvc:1.4.13'){
exclude group: 'org.bouncycastle', module: 'bcprov-jdk15on'
}

// Commons IO for utilities
implementation 'commons-io:commons-io:2.11.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import java.io.ByteArrayOutputStream
import java.io.File
import java.security.KeyStore
import java.security.MessageDigest
import java.security.Security
import java.security.Signature
import java.security.cert.CertPathValidator
import java.security.cert.CertificateFactory
Expand Down Expand Up @@ -919,6 +920,10 @@ class RNSelfPassportReaderModule(private val reactContext: ReactApplicationConte
}

companion object {
init {
Security.insertProviderAt(org.bouncycastle.jce.provider.BouncyCastleProvider(), 1)
}

private val TAG = RNSelfPassportReaderModule::class.java.simpleName
private const val PARAM_DOC_NUM = "documentNumber";
private const val PARAM_DOB = "dateOfBirth";
Expand Down
1 change: 1 addition & 0 deletions packages/mobile-sdk-alpha/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export {
loadSelectedDocument,
markCurrentDocumentAsRegistered,
reStorePassportDataWithRightCSCA,
storePassportData,
} from './documents/utils';

/** @deprecated Use createSelfClient().extractMRZInfo or import from './mrz' */
Expand Down
26 changes: 20 additions & 6 deletions packages/mobile-sdk-demo/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ type SelectedDocumentState = {
metadata: DocumentMetadata;
};

function DemoApp() {
type NavigationState = {
screen: ScreenRoute;
setScreen: (screen: ScreenRoute, params?: any) => void;
screenParams: any;
};

function DemoApp({ navigationState }: { navigationState: NavigationState }) {
const selfClient = useSelfClient();
const { screen, setScreen, screenParams } = navigationState;

const [screen, setScreen] = useState<ScreenRoute>('home');
const [catalog, setCatalog] = useState<DocumentCatalog>({ documents: [] });
const [selectedDocument, setSelectedDocument] = useState<SelectedDocumentState | null>(null);

Expand All @@ -36,7 +42,7 @@ function DemoApp() {
}
}, [selfClient]);

const navigate = (next: ScreenRoute) => setScreen(next);
const navigate = useCallback((next: ScreenRoute, params?: any) => setScreen(next, params), [setScreen]);

const screenContext: ScreenContext = {
navigate,
Expand Down Expand Up @@ -67,15 +73,23 @@ function DemoApp() {
}

const ScreenComponent = descriptor.load();
const props = descriptor.getProps?.(screenContext) ?? {};
const props = descriptor.getProps?.(screenContext, screenParams) ?? {};

return <ScreenComponent {...props} />;
}

function App() {
const [screen, setScreen] = useState<ScreenRoute>('home');
const [screenParams, setScreenParams] = useState<any>(undefined);

const handleSetScreen = useCallback((nextScreen: ScreenRoute, params?: any) => {
setScreen(nextScreen);
setScreenParams(params);
}, []);

return (
<SelfClientProvider>
<DemoApp />
<SelfClientProvider onNavigate={screenId => handleSetScreen(screenId as ScreenRoute)}>
<DemoApp navigationState={{ screen, setScreen: handleSetScreen, screenParams }} />
</SelfClientProvider>
);
}
Expand Down
10 changes: 10 additions & 0 deletions packages/mobile-sdk-demo/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.VIBRATE" />

<uses-feature
android:name="android.hardware.nfc"
android:required="false" />

<application
android:name=".MainApplication"
Expand All @@ -22,6 +28,10 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.selfxyz.demoapp

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import android.content.Intent
import android.util.Log
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate
import com.selfxyz.selfSDK.RNSelfPassportReaderModule

class MainActivity : ReactActivity() {
/**
Expand All @@ -21,4 +22,15 @@ class MainActivity : ReactActivity() {
override fun createReactActivityDelegate(): ReactActivityDelegate {
return DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
Log.d("MAIN_ACTIVITY", "onNewIntent: " + intent.action)
try {
RNSelfPassportReaderModule.getInstance().receiveIntent(intent)
} catch (e: IllegalStateException) {
Log.w("MAIN_ACTIVITY", "RNSelfPassportReaderModule not ready; deferring NFC intent")
setIntent(intent)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
<tech>android.nfc.tech.IsoDep</tech>
</tech-list>
</resources>
21 changes: 16 additions & 5 deletions packages/mobile-sdk-demo/src/providers/SelfClientProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import React, { useMemo } from 'react';
import {
SelfClientProvider as SdkSelfClientProvider,
createListenersMap,
SdkEvents,
type Adapters,
type TrackEventParams,
type WsConn,
webNFCScannerShim,
reactNativeScannerAdapter,
} from '@selfxyz/mobile-sdk-alpha';

import { persistentDocumentsAdapter } from '../utils/documentStore';
Expand Down Expand Up @@ -110,12 +111,16 @@ const createWsAdapter = () => {

const hash = (data: Uint8Array): Uint8Array => sha256(data);

export function SelfClientProvider({ children }: PropsWithChildren) {
type SelfClientProviderProps = PropsWithChildren<{
onNavigate?: (screen: string) => void;
}>;

export function SelfClientProvider({ children, onNavigate }: SelfClientProviderProps) {
const config = useMemo(() => ({}), []);

const adapters: Adapters = useMemo(
() => ({
scanner: webNFCScannerShim,
scanner: reactNativeScannerAdapter,
network: {
http: {
fetch: createFetch(),
Expand Down Expand Up @@ -153,9 +158,15 @@ export function SelfClientProvider({ children }: PropsWithChildren) {
);

const listeners = useMemo(() => {
const { map } = createListenersMap();
const { map, addListener } = createListenersMap();

// Auto-navigate from MRZ scan to NFC scan
addListener(SdkEvents.DOCUMENT_MRZ_READ_SUCCESS, () => {
onNavigate?.('nfc');
});

return map;
}, []);
}, [onNavigate]);

return (
<SdkSelfClientProvider config={config} adapters={adapters} listeners={listeners}>
Expand Down
Loading
Loading