Skip to content

Commit 01e348b

Browse files
committed
feat: expose MRZ parsing on client
1 parent 61d405f commit 01e348b

File tree

6 files changed

+15
-3
lines changed

6 files changed

+15
-3
lines changed

packages/mobile-sdk-alpha/src/browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export type { SdkErrorCategory } from './errors';
4141
export { SCANNER_ERROR_CODES, notImplemented, sdkError } from './errors';
4242
export { createSelfClient } from './client';
4343
export { defaultConfig } from './config/defaults';
44-
export { extractMRZInfo, formatDateToYYMMDD, scanMRZ } from './mrz';
44+
export { formatDateToYYMMDD, scanMRZ } from './mrz';
4545

4646
// Core functions
4747
export { isPassportDataValid } from './validation/document';

packages/mobile-sdk-alpha/src/client.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defaultConfig } from './config/defaults';
22
import { mergeConfig } from './config/merge';
33
import { notImplemented } from './errors';
4+
import { extractMRZInfo as parseMRZInfo } from './processing/mrz';
45
import type {
56
Adapters,
67
Config,
@@ -102,6 +103,7 @@ export function createSelfClient({ config, adapters }: { config: Config; adapter
102103
validateDocument,
103104
checkRegistration,
104105
generateProof,
106+
extractMRZInfo: parseMRZInfo,
105107
on,
106108
emit,
107109
};

packages/mobile-sdk-alpha/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export { createSelfClient } from './client';
5757

5858
export { defaultConfig } from './config/defaults';
5959

60-
export { extractMRZInfo, formatDateToYYMMDD, scanMRZ } from './mrz';
60+
export { formatDateToYYMMDD, scanMRZ } from './mrz';
6161

6262
// Core functions
6363
export { isPassportDataValid } from './validation/document';

packages/mobile-sdk-alpha/src/types/public.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export interface SelfClient {
128128
timeoutMs?: number;
129129
},
130130
): Promise<ProofHandle>;
131+
extractMRZInfo(mrz: string): MRZInfo;
131132
on<E extends SDKEvent>(event: E, cb: (payload: SDKEventMap[E]) => void): Unsubscribe;
132133
emit<E extends SDKEvent>(event: E, payload: SDKEventMap[E]): void;
133134
}

packages/mobile-sdk-alpha/tests/client.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ describe('createSelfClient', () => {
7777
eventSet?.forEach(fn => fn({ step: 'two' }));
7878
expect(cb).toHaveBeenCalledTimes(1);
7979
});
80+
81+
it('parses MRZ via client', () => {
82+
const client = createSelfClient({ config: {}, adapters: { scanner, network, crypto } });
83+
const sample = `P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<\nL898902C36UTO7408122F1204159ZE184226B<<<<<10`;
84+
const info = client.extractMRZInfo(sample);
85+
expect(info.passportNumber).toBe('L898902C3');
86+
expect(info.validation.overall).toBe(true);
87+
});
8088
});
8189

8290
const scanner: ScannerAdapter = {

packages/mobile-sdk-alpha/tests/processing/mrz.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, expect, it } from 'vitest';
22

3-
import { extractMRZInfo, formatDateToYYMMDD, MrzParseError } from '../../src';
3+
import { formatDateToYYMMDD, MrzParseError } from '../../src';
4+
import { extractMRZInfo } from '../../src/mrz';
45

56
const sample = `P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<
67
L898902C36UTO7408122F1204159ZE184226B<<<<<10`;

0 commit comments

Comments
 (0)