-
Notifications
You must be signed in to change notification settings - Fork 180
feat: upgrade SelfClient foundation and expose MRZ parsing #925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ae1b3fa
feat: expose MRZ parsing on client
transphorm 16be665
feat: add SelfClient provider
transphorm aa1c104
feat: add react native entry
transphorm 11bfc78
feat: add mobile sdk entry wrapper
transphorm 855be20
upgrade packages
transphorm f558df7
save wip
transphorm cc660a2
clean up tests to support new arch
transphorm 3a5efc4
abstract SelfMobileSdk
transphorm f213ad8
pr feedback
transphorm e47bb56
updates
transphorm fc850a3
pr updates
transphorm ef728f8
update lock
transphorm bfdf1e1
updates
transphorm 05a29e2
fix types
transphorm e4a0903
updates
transphorm 6f33e54
fix tests
transphorm 7c3fba8
test: verify provider memoization and add jsdoc (#929)
transphorm 74a3c07
pr feedback
transphorm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,8 +39,15 @@ export type { QRProofOptions } from './qr'; | |
| export type { SdkErrorCategory } from './errors'; | ||
|
|
||
| export { SCANNER_ERROR_CODES, notImplemented, sdkError } from './errors'; | ||
| export { SelfClientContext, SelfClientProvider, useSelfClient } from './context'; | ||
| // Browser-only high-level component (DOM-based) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah. this isnt true theres nothing about SelfMobileSdk that is browser or dom based. it supposed to be react native based |
||
| export { SelfMobileSdk as SelfMobileSdkHighLevel } from './components/SelfMobileSdk'; | ||
|
|
||
| export { createSelfClient } from './client'; | ||
|
|
||
| export { defaultConfig } from './config/defaults'; | ||
|
|
||
| /** @deprecated Use createSelfClient().extractMRZInfo or import from './mrz' */ | ||
| export { extractMRZInfo, formatDateToYYMMDD, scanMRZ } from './mrz'; | ||
transphorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Core functions | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/mobile-sdk-alpha/src/components/SelfMobileSdk.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import type { ComponentType, ReactNode } from 'react'; | ||
|
|
||
| import { SelfClientProvider } from '../context'; | ||
| import { useDocumentManager } from '../hooks/useDocumentManager'; | ||
| import type { Adapters, Config } from '../types/public'; | ||
| import type { ExternalAdapter, PassportCameraProps, ScreenProps } from '../types/ui'; | ||
| import { OnboardingFlow } from './flows/OnboardingFlow'; | ||
| import { QRCodeScreen } from './screens/QRCodeScreen'; | ||
|
|
||
| interface SelfMobileSdkProps { | ||
| config: Config; | ||
| adapters?: Partial<Adapters>; | ||
| external: ExternalAdapter; | ||
| children?: ReactNode; | ||
| // Optional custom components | ||
| customScreens?: { | ||
| PassportCamera?: ComponentType<PassportCameraProps>; | ||
| NFCScanner?: ComponentType<ScreenProps>; | ||
| QRScanner?: ReactNode; | ||
| }; | ||
| } | ||
|
|
||
| const SelfMobileSdkContent = ({ | ||
| external, | ||
| customScreens = {}, | ||
| }: { | ||
| external: ExternalAdapter; | ||
| customScreens?: SelfMobileSdkProps['customScreens']; | ||
| }) => { | ||
| const { documents, isLoading, hasRegisteredDocuments } = useDocumentManager(external); | ||
|
|
||
| if (isLoading) { | ||
| return <div>Loading documents...</div>; | ||
| } | ||
|
|
||
| // Check if user has any registered documents | ||
| const hasDocuments = Object.keys(documents).length > 0 && hasRegisteredDocuments(); | ||
|
|
||
| if (!hasDocuments) { | ||
| return ( | ||
| <OnboardingFlow | ||
| external={external} | ||
| setDocument={external.setDocument} | ||
| PassportCamera={customScreens.PassportCamera} | ||
| NFCScanner={customScreens.NFCScanner} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| // Show disclosure flow | ||
| return ( | ||
| customScreens.QRScanner || ( | ||
| <QRCodeScreen onSuccess={external.onDisclosureSuccess} onFailure={external.onDisclosureFailure} /> | ||
| ) | ||
| ); | ||
| }; | ||
|
|
||
| export const SelfMobileSdk = ({ config, adapters = {}, external, children, customScreens }: SelfMobileSdkProps) => { | ||
| return ( | ||
| <SelfClientProvider config={config} adapters={adapters}> | ||
| {children || <SelfMobileSdkContent external={external} customScreens={customScreens} />} | ||
| </SelfClientProvider> | ||
| ); | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.