@vppos/react-native-nfc 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/NFCSDK.podspec +40 -0
- package/android/build.gradle +85 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +31 -0
- package/android/src/main/AndroidManifestNew.xml +30 -0
- package/android/src/main/java/com/nfcsdk/ChipReader.kt +237 -0
- package/android/src/main/java/com/nfcsdk/NFCSDKModule.kt +78 -0
- package/android/src/main/java/com/nfcsdk/NFCSDKPackage.kt +17 -0
- package/android/src/main/java/com/nfcsdk/NFCScanActivity.kt +299 -0
- package/android/src/main/java/com/nfcsdk/utils/Dg13Parser.kt +278 -0
- package/android/src/main/java/com/nfcsdk/utils/FaceExtractor.kt +40 -0
- package/android/src/main/java/com/nfcsdk/utils/MrzUtils.kt +75 -0
- package/android/src/main/res/drawable/bg_nfc_bottom_sheet.xml +13 -0
- package/android/src/main/res/drawable/bg_nfc_sheet_handle.xml +9 -0
- package/android/src/main/res/layout/activity_nfc.xml +110 -0
- package/android/src/main/res/values/styles.xml +10 -0
- package/android/src/main/res/xml/nfc_tech_filter.xml +8 -0
- package/ios/ChipReader.swift +258 -0
- package/ios/NFCSDK-Bridging-Header.h +2 -0
- package/ios/NFCSDK.mm +9 -0
- package/ios/NFCSDK.swift +112 -0
- package/ios/NFCSDKSession.swift +5 -0
- package/ios/utils/DG13Parser.swift +302 -0
- package/ios/utils/MrzUtils.swift +49 -0
- package/lib/module/errors.js +9 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/index.js +118 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/errors.d.ts +4 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +80 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +45 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +155 -0
- package/src/errors.ts +6 -0
- package/src/index.tsx +141 -0
- package/src/types.ts +45 -0
- package/vendor/ios-passport-reader/CHANGELOG +362 -0
- package/vendor/ios-passport-reader/CODE_OF_CONDUCT.md +77 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/AppDelegate.swift +39 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/Contents.json +158 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/ios-marketing.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/Contents.json +6 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/background.imageset/Contents.json +21 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/background.imageset/background.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/head.imageset/Contents.json +21 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/head.imageset/head.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Base.lproj/LaunchScreen.storyboard +25 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Extensions/FileManagerExt.swift +16 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Extensions/StringExt.swift +40 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Extensions/UIApplicationExt.swift +21 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Info.plist +77 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Model/PassportUtils.swift +76 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Model/SettingsStore.swift +107 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/NFCPassportReader.entitlements +10 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/SceneDelegate.swift +57 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/DetailsView.swift +197 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/ExportPassportView.swift +164 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/HelperViews/CheckBoxView.swift +48 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/HelperViews/ViewExt.swift +20 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/HelperViews/ViewModifiers.swift +41 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/MRZEntryView.swift +125 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/MRZScannerViewController.swift +90 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/MainView.swift +214 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/PassportSummaryView.swift +111 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/PassportView.swift +73 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/SettingsView.swift +63 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/StoredPassportView.swift +152 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/masterList.pem +32 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/readme.md +10 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcodeproj/project.pbxproj +695 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcodeproj/xcshareddata/xcschemes/NFCPassportReader.xcscheme +106 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcworkspace/contents.xcworkspacedata +10 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/DataGroupParsingTests.swift +189 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/Info.plist +22 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/NFCPassportReaderTests.swift +260 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/PACETests.swift +112 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/Podfile +22 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/Podfile.lock +35 -0
- package/vendor/ios-passport-reader/Examples/Example_CocoaPods/README.md +2 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/AppDelegate.swift +39 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/Contents.json +158 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/ios-marketing.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@3x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad@2x.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/Contents.json +6 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/background.imageset/Contents.json +21 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/background.imageset/background.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/head.imageset/Contents.json +21 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/head.imageset/head.png +0 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Base.lproj/LaunchScreen.storyboard +25 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Extensions/FileManagerExt.swift +16 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Extensions/StringExt.swift +40 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Extensions/UIApplicationExt.swift +21 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Info.plist +79 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Model/PassportUtils.swift +99 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Model/SettingsStore.swift +98 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Model/SettingsStoreCAN.swift +75 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/LICENSE +21 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/PreviewView.swift +34 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/StringUtils.swift +160 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/ViewController.swift +320 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/VisionViewController.swift +163 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/NFCPassportReader.entitlements +10 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/SceneDelegate.swift +58 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/CANViews/CanKeyView.swift +251 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/CANViews/MRZEntryViewCanKey.swift +65 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/CANViews/PassportViewCAN.swift +73 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/DetailsView.swift +193 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/ExportPassportView.swift +164 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/HelperViews/CheckBoxView.swift +48 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/HelperViews/ViewExt.swift +20 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/HelperViews/ViewModifiers.swift +41 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/MRZEntryView.swift +125 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/MRZScannerViewController.swift +90 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/MainView.swift +264 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/PassportSummaryView.swift +111 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/PassportView.swift +73 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/SettingsView.swift +47 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/StoredPassportView.swift +149 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/masterList.pem +32 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/readme.md +10 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/project.pbxproj +683 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +25 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/xcshareddata/xcschemes/NFCPassportReader.xcscheme +106 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/DataGroupParsingTests.swift +190 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/Info.plist +22 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/NFCPassportReaderTests.swift +260 -0
- package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/PACETests.swift +112 -0
- package/vendor/ios-passport-reader/LICENSE +21 -0
- package/vendor/ios-passport-reader/NFCPassportReader.podspec +27 -0
- package/vendor/ios-passport-reader/Package.swift +29 -0
- package/vendor/ios-passport-reader/README.md +141 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/AES_3DES_DESEncryption.swift +377 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/BACHandler.swift +194 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/ChipAuthenticationHandler.swift +224 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroupHash.swift +16 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroupParser.swift +36 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/ActiveAuthenticationInfo.swift +69 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/COM.swift +61 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/CardAccess.swift +38 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/ChipAuthenticationInfo.swift +135 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/ChipAuthenticationPublicKeyInfo.swift +53 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup.swift +103 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup1.swift +111 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup11.swift +66 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup12.swift +75 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup14.swift +37 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup15.swift +46 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup2.swift +163 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup7.swift +46 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroupId.swift +105 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/NotImplementedDG.swift +16 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/PACEInfo.swift +415 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/SOD.swift +240 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/SecurityInfo.swift +136 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/Errors.swift +148 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/Logging.swift +32 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/Models/FaceImageInfo.swift +161 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/NFCPassportModel.swift +540 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/NFCViewDisplayMessage.swift +60 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/OpenSSLUtils.swift +705 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/PACEHandler.swift +627 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/PassportReader.swift +387 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/Resources/PrivacyInfo.xcprivacy +14 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/ResponseAPDU.swift +25 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/SecureMessaging.swift +301 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/SecureMessagingSessionKeyGenerator.swift +156 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/SimpleASN1DumpParser.swift +173 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/TagReader.swift +374 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/Utils.swift +430 -0
- package/vendor/ios-passport-reader/Sources/NFCPassportReader/X509Wrapper.swift +168 -0
- package/vendor/ios-passport-reader/scripts/README.md +45 -0
- package/vendor/ios-passport-reader/scripts/extract.py +197 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
struct DG13ParsedData {
|
|
4
|
+
var fullName: String = ""
|
|
5
|
+
var gender: String = ""
|
|
6
|
+
var permanentAddress: String = ""
|
|
7
|
+
var issueDate: String = ""
|
|
8
|
+
var issuePlace: String = ""
|
|
9
|
+
var expireDate: String = ""
|
|
10
|
+
var fieldMap: [Int: [String]] = [:]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
private struct ASN1Node {
|
|
14
|
+
let tagClass: Int
|
|
15
|
+
let tagNumber: Int
|
|
16
|
+
let constructed: Bool
|
|
17
|
+
let valueOffset: Int
|
|
18
|
+
let valueLength: Int
|
|
19
|
+
let nextOffset: Int
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
enum DG13Parser {
|
|
23
|
+
private static let tagClassUniversal = 0
|
|
24
|
+
private static let tagClassApplication = 1
|
|
25
|
+
private static let outputDateFormatter: DateFormatter = {
|
|
26
|
+
let formatter = DateFormatter()
|
|
27
|
+
formatter.locale = Locale(identifier: "en_US_POSIX")
|
|
28
|
+
formatter.dateFormat = "dd/MM/yyyy"
|
|
29
|
+
return formatter
|
|
30
|
+
}()
|
|
31
|
+
private static let inputDatePatterns = [
|
|
32
|
+
"dd/MM/yyyy",
|
|
33
|
+
"yyyy-MM-dd",
|
|
34
|
+
"ddMMyyyy",
|
|
35
|
+
"yyyyMMdd",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
static func parse(
|
|
39
|
+
_ data: Data,
|
|
40
|
+
fallbackIssuePlace: String = ""
|
|
41
|
+
) -> DG13ParsedData {
|
|
42
|
+
let bytes = [UInt8](data)
|
|
43
|
+
guard !bytes.isEmpty,
|
|
44
|
+
let fields = parseStructuredFields(bytes)
|
|
45
|
+
else {
|
|
46
|
+
return DG13ParsedData(issuePlace: fallbackIssuePlace)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let candidates = Array(Set(fields.values.flatMap { $0 }))
|
|
50
|
+
|
|
51
|
+
return DG13ParsedData(
|
|
52
|
+
fullName: normalizeFullName(fields[0x02]?.first ?? ""),
|
|
53
|
+
gender: normalizeGender(fields[0x04]?.first ?? ""),
|
|
54
|
+
permanentAddress: fields[0x09]?.first ?? "",
|
|
55
|
+
issueDate: normalizeDate(fields[0x0B]?.first ?? ""),
|
|
56
|
+
issuePlace: findIssuePlace(candidates) ?? fallbackIssuePlace,
|
|
57
|
+
expireDate: normalizeDate(fields[0x0C]?.first ?? ""),
|
|
58
|
+
fieldMap: fields
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static func normalizeGender(_ raw: String) -> String {
|
|
63
|
+
switch normalizeForSearch(raw) {
|
|
64
|
+
case "M", "MALE", "NAM":
|
|
65
|
+
return "Nam"
|
|
66
|
+
case "F", "FEMALE", "NU":
|
|
67
|
+
return "Nữ"
|
|
68
|
+
default:
|
|
69
|
+
return raw.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static func normalizeFullName(_ raw: String) -> String {
|
|
74
|
+
raw
|
|
75
|
+
.replacingOccurrences(of: "<", with: " ")
|
|
76
|
+
.replacingOccurrences(of: "\\s+", with: " ", options: .regularExpression)
|
|
77
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private static func parseStructuredFields(_ bytes: [UInt8]) -> [Int: [String]]? {
|
|
81
|
+
guard let root = parseNode(bytes, offset: 0),
|
|
82
|
+
root.tagClass == tagClassApplication,
|
|
83
|
+
root.tagNumber == 13
|
|
84
|
+
else {
|
|
85
|
+
return nil
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let rootChildren = parseChildren(bytes, parent: root)
|
|
89
|
+
guard let sequenceNode = rootChildren.first else {
|
|
90
|
+
return nil
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let sequenceChildren = parseChildren(bytes, parent: sequenceNode)
|
|
94
|
+
guard let setNode = sequenceChildren.first(where: {
|
|
95
|
+
$0.tagClass == tagClassUniversal && $0.tagNumber == 17
|
|
96
|
+
}) else {
|
|
97
|
+
return nil
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let fieldNodes = parseChildren(bytes, parent: setNode)
|
|
101
|
+
guard !fieldNodes.isEmpty else {
|
|
102
|
+
return nil
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
var result: [Int: [String]] = [:]
|
|
106
|
+
for fieldNode in fieldNodes {
|
|
107
|
+
guard fieldNode.tagClass == tagClassUniversal,
|
|
108
|
+
fieldNode.tagNumber == 16
|
|
109
|
+
else {
|
|
110
|
+
continue
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let parts = parseChildren(bytes, parent: fieldNode)
|
|
114
|
+
guard let indexNode = parts.first(where: {
|
|
115
|
+
$0.tagClass == tagClassUniversal && $0.tagNumber == 2
|
|
116
|
+
}),
|
|
117
|
+
let index = parseInteger(bytes, node: indexNode)
|
|
118
|
+
else {
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
let values = parts.dropFirst()
|
|
123
|
+
.flatMap { extractStrings(bytes, node: $0) }
|
|
124
|
+
.map(cleanValue)
|
|
125
|
+
.filter { !$0.isEmpty }
|
|
126
|
+
|
|
127
|
+
if !values.isEmpty {
|
|
128
|
+
result[index] = values
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return result.isEmpty ? nil : result
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private static func parseChildren(_ bytes: [UInt8], parent: ASN1Node) -> [ASN1Node] {
|
|
136
|
+
guard parent.constructed else {
|
|
137
|
+
return []
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var children: [ASN1Node] = []
|
|
141
|
+
var offset = parent.valueOffset
|
|
142
|
+
let end = parent.valueOffset + parent.valueLength
|
|
143
|
+
|
|
144
|
+
while offset < end {
|
|
145
|
+
guard let child = parseNode(bytes, offset: offset),
|
|
146
|
+
child.nextOffset <= end
|
|
147
|
+
else {
|
|
148
|
+
break
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
children.append(child)
|
|
152
|
+
offset = child.nextOffset
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return children
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
private static func parseNode(_ bytes: [UInt8], offset: Int) -> ASN1Node? {
|
|
159
|
+
guard offset < bytes.count else {
|
|
160
|
+
return nil
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
var cursor = offset
|
|
164
|
+
let firstTagByte = Int(bytes[cursor])
|
|
165
|
+
cursor += 1
|
|
166
|
+
|
|
167
|
+
let tagClass = (firstTagByte >> 6) & 0x03
|
|
168
|
+
let constructed = (firstTagByte & 0x20) != 0
|
|
169
|
+
var tagNumber = firstTagByte & 0x1F
|
|
170
|
+
|
|
171
|
+
if tagNumber == 0x1F {
|
|
172
|
+
tagNumber = 0
|
|
173
|
+
while cursor < bytes.count {
|
|
174
|
+
let next = Int(bytes[cursor])
|
|
175
|
+
cursor += 1
|
|
176
|
+
tagNumber = (tagNumber << 7) | (next & 0x7F)
|
|
177
|
+
if (next & 0x80) == 0 {
|
|
178
|
+
break
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
guard cursor < bytes.count else {
|
|
184
|
+
return nil
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
let lengthByte = Int(bytes[cursor])
|
|
188
|
+
cursor += 1
|
|
189
|
+
|
|
190
|
+
let valueLength: Int
|
|
191
|
+
if (lengthByte & 0x80) == 0 {
|
|
192
|
+
valueLength = lengthByte
|
|
193
|
+
} else {
|
|
194
|
+
let count = lengthByte & 0x7F
|
|
195
|
+
guard count > 0, count <= 4, cursor + count <= bytes.count else {
|
|
196
|
+
return nil
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var length = 0
|
|
200
|
+
for index in 0..<count {
|
|
201
|
+
length = (length << 8) | Int(bytes[cursor + index])
|
|
202
|
+
}
|
|
203
|
+
cursor += count
|
|
204
|
+
valueLength = length
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
let nextOffset = cursor + valueLength
|
|
208
|
+
guard nextOffset <= bytes.count else {
|
|
209
|
+
return nil
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return ASN1Node(
|
|
213
|
+
tagClass: tagClass,
|
|
214
|
+
tagNumber: tagNumber,
|
|
215
|
+
constructed: constructed,
|
|
216
|
+
valueOffset: cursor,
|
|
217
|
+
valueLength: valueLength,
|
|
218
|
+
nextOffset: nextOffset
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private static func parseInteger(_ bytes: [UInt8], node: ASN1Node) -> Int? {
|
|
223
|
+
guard node.tagClass == tagClassUniversal, node.tagNumber == 2 else {
|
|
224
|
+
return nil
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
var result = 0
|
|
228
|
+
for index in 0..<node.valueLength {
|
|
229
|
+
result = (result << 8) | Int(bytes[node.valueOffset + index])
|
|
230
|
+
}
|
|
231
|
+
return result
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private static func extractStrings(_ bytes: [UInt8], node: ASN1Node) -> [String] {
|
|
235
|
+
if node.constructed {
|
|
236
|
+
return parseChildren(bytes, parent: node).flatMap { child in
|
|
237
|
+
extractStrings(bytes, node: child)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
guard node.tagClass == tagClassUniversal else {
|
|
242
|
+
return []
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
let data = Data(bytes[node.valueOffset..<node.nextOffset])
|
|
246
|
+
let decoded: String
|
|
247
|
+
switch node.tagNumber {
|
|
248
|
+
case 12, 19, 20, 22:
|
|
249
|
+
decoded = String(data: data, encoding: .utf8) ?? ""
|
|
250
|
+
case 30:
|
|
251
|
+
decoded = String(data: data, encoding: .utf16BigEndian) ?? ""
|
|
252
|
+
default:
|
|
253
|
+
decoded = ""
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
let clean = cleanValue(decoded)
|
|
257
|
+
return clean.isEmpty ? [] : [clean]
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
private static func cleanValue(_ raw: String) -> String {
|
|
261
|
+
raw
|
|
262
|
+
.components(separatedBy: .whitespacesAndNewlines)
|
|
263
|
+
.filter { !$0.isEmpty }
|
|
264
|
+
.joined(separator: " ")
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
private static func normalizeForSearch(_ raw: String) -> String {
|
|
268
|
+
raw
|
|
269
|
+
.folding(options: [.diacriticInsensitive, .caseInsensitive], locale: Locale(identifier: "vi_VN"))
|
|
270
|
+
.uppercased()
|
|
271
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private static func findIssuePlace(_ candidates: [String]) -> String? {
|
|
275
|
+
candidates.first { candidate in
|
|
276
|
+
let normalized = normalizeForSearch(candidate)
|
|
277
|
+
return normalized.contains("CONG AN") || normalized.contains("CANH SAT")
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
private static func normalizeDate(_ raw: String) -> String {
|
|
282
|
+
guard let parsed = tryParseDate(raw) else {
|
|
283
|
+
return raw.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return outputDateFormatter.string(from: parsed)
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
private static func tryParseDate(_ raw: String) -> Date? {
|
|
290
|
+
let clean = raw.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
291
|
+
for pattern in inputDatePatterns {
|
|
292
|
+
let formatter = DateFormatter()
|
|
293
|
+
formatter.locale = Locale(identifier: "en_US_POSIX")
|
|
294
|
+
formatter.dateFormat = pattern
|
|
295
|
+
if let date = formatter.date(from: clean) {
|
|
296
|
+
return date
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return nil
|
|
301
|
+
}
|
|
302
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
enum MrzUtils {
|
|
4
|
+
static func formatDate(_ value: String) -> String {
|
|
5
|
+
let clean = value
|
|
6
|
+
.replacingOccurrences(of: "<", with: "")
|
|
7
|
+
.replacingOccurrences(of: ">", with: "")
|
|
8
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
9
|
+
|
|
10
|
+
if clean.count == 6 {
|
|
11
|
+
let yy = String(clean.prefix(2))
|
|
12
|
+
let mm = String(clean.dropFirst(2).prefix(2))
|
|
13
|
+
let dd = String(clean.suffix(2))
|
|
14
|
+
|
|
15
|
+
let currentYear = Calendar.current.component(.year, from: Date())
|
|
16
|
+
let currentYearShort = currentYear % 100
|
|
17
|
+
let year = (Int(yy) ?? 0) > currentYearShort ? "19\(yy)" : "20\(yy)"
|
|
18
|
+
|
|
19
|
+
return "\(dd)/\(mm)/\(year)"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if clean.count == 8 {
|
|
23
|
+
let yyyy = String(clean.prefix(4))
|
|
24
|
+
let mm = String(clean.dropFirst(4).prefix(2))
|
|
25
|
+
let dd = String(clean.suffix(2))
|
|
26
|
+
return "\(dd)/\(mm)/\(yyyy)"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return clean
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static func normalizeName(
|
|
33
|
+
firstName: String,
|
|
34
|
+
lastName: String
|
|
35
|
+
) -> String {
|
|
36
|
+
"\(firstName) \(lastName)"
|
|
37
|
+
.replacingOccurrences(of: "<", with: " ")
|
|
38
|
+
.replacingOccurrences(of: "\\s+", with: " ", options: .regularExpression)
|
|
39
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static func normalizeNationality(_ raw: String) -> String {
|
|
43
|
+
if raw.uppercased() == "VNM" || raw.isEmpty {
|
|
44
|
+
return "Việt Nam"
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return raw
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NFCSDKError","Error","constructor","message","name"],"sourceRoot":"../../src","sources":["errors.ts"],"mappings":";;AAAA,OAAO,MAAMA,WAAW,SAASC,KAAK,CAAC;EACrCC,WAAWA,CAACC,OAAe,EAAE;IAC3B,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,aAAa;EAC3B;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* react-native-nfc-sdk — Đọc thông tin CCCD qua chip NFC.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { NFCSDK, type NFCScanResult } from 'react-native-nfc-sdk';
|
|
9
|
+
*
|
|
10
|
+
* // Lắng nghe kết quả
|
|
11
|
+
* const sub = NFCSDK.onScanResult((result) => {
|
|
12
|
+
* console.log(result.fullName, result.citizenId);
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* // Quét
|
|
16
|
+
* NFCSDK.startScan({ citizenId: '001234567890' });
|
|
17
|
+
*
|
|
18
|
+
* // Cleanup
|
|
19
|
+
* sub.remove();
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
* @module react-native-nfc-sdk
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
|
|
27
|
+
import { NFCSDKError } from "./errors.js";
|
|
28
|
+
const MODULE_NAME = 'NFCSDK';
|
|
29
|
+
const LINKING_ERROR = `'react-native-nfc-sdk' is not linked. ` + Platform.select({
|
|
30
|
+
ios: "Run 'pod install'. ",
|
|
31
|
+
default: ''
|
|
32
|
+
}) + 'Rebuild your app after installing.';
|
|
33
|
+
const nativeModule = NativeModules[MODULE_NAME];
|
|
34
|
+
const emitter = nativeModule ? new NativeEventEmitter(NativeModules[MODULE_NAME]) : null;
|
|
35
|
+
function requireModule() {
|
|
36
|
+
if (!nativeModule) {
|
|
37
|
+
throw new NFCSDKError(LINKING_ERROR);
|
|
38
|
+
}
|
|
39
|
+
return nativeModule;
|
|
40
|
+
}
|
|
41
|
+
function requireEmitter() {
|
|
42
|
+
if (!emitter) {
|
|
43
|
+
throw new NFCSDKError(`${MODULE_NAME} event emitter unavailable.`);
|
|
44
|
+
}
|
|
45
|
+
return emitter;
|
|
46
|
+
}
|
|
47
|
+
export { NFCSDKError } from "./errors.js";
|
|
48
|
+
/**
|
|
49
|
+
* NFC SDK — API chính để đọc CCCD qua chip NFC.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* // 1. Lắng nghe kết quả (trong useEffect)
|
|
54
|
+
* const resultSub = NFCSDK.onScanResult((result) => {
|
|
55
|
+
* console.log(result.fullName, result.citizenId);
|
|
56
|
+
* });
|
|
57
|
+
* const progressSub = NFCSDK.onProgress((e) => {
|
|
58
|
+
* console.log(`${e.progress}% - ${e.message}`);
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* // 2. Bắt đầu quét
|
|
62
|
+
* NFCSDK.startScan({ citizenId: '001234567890' });
|
|
63
|
+
*
|
|
64
|
+
* // 3. Cleanup khi unmount
|
|
65
|
+
* resultSub.remove();
|
|
66
|
+
* progressSub.remove();
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export const NFCSDK = {
|
|
70
|
+
/** Kiểm tra SDK có sẵn sàng không. */
|
|
71
|
+
isAvailable() {
|
|
72
|
+
return !!nativeModule && typeof nativeModule.startNfcScan === 'function';
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Bắt đầu quét NFC để đọc thông tin CCCD.
|
|
76
|
+
*
|
|
77
|
+
* @param options - Object chứa `citizenId` (số CCCD, tối thiểu 6 ký tự)
|
|
78
|
+
* @throws {NFCSDKError} Nếu module chưa link hoặc citizenId không hợp lệ
|
|
79
|
+
*/
|
|
80
|
+
startScan(options) {
|
|
81
|
+
const mod = requireModule();
|
|
82
|
+
const id = options.citizenId.trim();
|
|
83
|
+
if (id.length < 6) {
|
|
84
|
+
throw new NFCSDKError('citizenId must be at least 6 characters.');
|
|
85
|
+
}
|
|
86
|
+
mod.setCitizenId(id);
|
|
87
|
+
mod.startNfcScan();
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Lắng nghe kết quả quét NFC.
|
|
91
|
+
* Gọi `.remove()` trên subscription để hủy.
|
|
92
|
+
*
|
|
93
|
+
* @param listener - Callback nhận `NFCScanResult`
|
|
94
|
+
* @returns EmitterSubscription
|
|
95
|
+
* @throws {NFCSDKError} Nếu event emitter không khả dụng
|
|
96
|
+
*/
|
|
97
|
+
onScanResult(listener) {
|
|
98
|
+
return requireEmitter().addListener('onNfcCompleted', listener);
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* Lắng nghe tiến trình quét (0–100%).
|
|
102
|
+
* Gọi `.remove()` trên subscription để hủy.
|
|
103
|
+
*
|
|
104
|
+
* @param listener - Callback nhận `NFCProgressEvent`
|
|
105
|
+
* @returns EmitterSubscription
|
|
106
|
+
* @throws {NFCSDKError} Nếu event emitter không khả dụng
|
|
107
|
+
*/
|
|
108
|
+
onProgress(listener) {
|
|
109
|
+
return requireEmitter().addListener('onNfcProgress', raw => {
|
|
110
|
+
listener({
|
|
111
|
+
progress: Math.round(Number(raw?.progress ?? 0)),
|
|
112
|
+
message: String(raw?.message ?? '')
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
export default NFCSDK;
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","Platform","NFCSDKError","MODULE_NAME","LINKING_ERROR","select","ios","default","nativeModule","emitter","requireModule","requireEmitter","NFCSDK","isAvailable","startNfcScan","startScan","options","mod","id","citizenId","trim","length","setCitizenId","onScanResult","listener","addListener","onProgress","raw","progress","Math","round","Number","message","String"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,kBAAkB,EAClBC,aAAa,EACbC,QAAQ,QAEH,cAAc;AAErB,SAASC,WAAW,QAAQ,aAAU;AAGtC,MAAMC,WAAW,GAAG,QAAQ;AAE5B,MAAMC,aAAa,GACjB,wCAAwC,GACxCH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GAAG,EAAE,qBAAqB;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GAC5D,oCAAoC;AAEtC,MAAMC,YAAY,GAAGR,aAAa,CAACG,WAAW,CAAC;AAC/C,MAAMM,OAAO,GAAGD,YAAY,GACxB,IAAIT,kBAAkB,CAACC,aAAa,CAACG,WAAW,CAAC,CAAC,GAClD,IAAI;AAER,SAASO,aAAaA,CAAA,EAAG;EACvB,IAAI,CAACF,YAAY,EAAE;IACjB,MAAM,IAAIN,WAAW,CAACE,aAAa,CAAC;EACtC;EACA,OAAOI,YAAY;AACrB;AAEA,SAASG,cAAcA,CAAA,EAAG;EACxB,IAAI,CAACF,OAAO,EAAE;IACZ,MAAM,IAAIP,WAAW,CAAC,GAAGC,WAAW,6BAA6B,CAAC;EACpE;EACA,OAAOM,OAAO;AAChB;AAEA,SAASP,WAAW,QAAQ,aAAU;AAGtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMU,MAAM,GAAG;EACpB;EACAC,WAAWA,CAAA,EAAY;IACrB,OAAO,CAAC,CAACL,YAAY,IAAI,OAAOA,YAAY,CAACM,YAAY,KAAK,UAAU;EAC1E,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEC,SAASA,CAACC,OAA8B,EAAQ;IAC9C,MAAMC,GAAG,GAAGP,aAAa,CAAC,CAAC;IAC3B,MAAMQ,EAAE,GAAGF,OAAO,CAACG,SAAS,CAACC,IAAI,CAAC,CAAC;IAEnC,IAAIF,EAAE,CAACG,MAAM,GAAG,CAAC,EAAE;MACjB,MAAM,IAAInB,WAAW,CAAC,0CAA0C,CAAC;IACnE;IAEAe,GAAG,CAACK,YAAY,CAACJ,EAAE,CAAC;IACpBD,GAAG,CAACH,YAAY,CAAC,CAAC;EACpB,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACES,YAAYA,CAACC,QAAyC,EAAuB;IAC3E,OAAOb,cAAc,CAAC,CAAC,CAACc,WAAW,CAAC,gBAAgB,EAAED,QAAQ,CAAC;EACjE,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,UAAUA,CAACF,QAA2C,EAAuB;IAC3E,OAAOb,cAAc,CAAC,CAAC,CAACc,WAAW,CACjC,eAAe,EACdE,GAA4B,IAAK;MAChCH,QAAQ,CAAC;QACPI,QAAQ,EAAEC,IAAI,CAACC,KAAK,CAACC,MAAM,CAACJ,GAAG,EAAEC,QAAQ,IAAI,CAAC,CAAC,CAAC;QAChDI,OAAO,EAAEC,MAAM,CAACN,GAAG,EAAEK,OAAO,IAAI,EAAE;MACpC,CAAC,CAAC;IACJ,CACF,CAAC;EACH;AACF,CAAC;AAED,eAAepB,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-native-nfc-sdk — Đọc thông tin CCCD qua chip NFC.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { NFCSDK, type NFCScanResult } from 'react-native-nfc-sdk';
|
|
7
|
+
*
|
|
8
|
+
* // Lắng nghe kết quả
|
|
9
|
+
* const sub = NFCSDK.onScanResult((result) => {
|
|
10
|
+
* console.log(result.fullName, result.citizenId);
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* // Quét
|
|
14
|
+
* NFCSDK.startScan({ citizenId: '001234567890' });
|
|
15
|
+
*
|
|
16
|
+
* // Cleanup
|
|
17
|
+
* sub.remove();
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @packageDocumentation
|
|
21
|
+
* @module react-native-nfc-sdk
|
|
22
|
+
*/
|
|
23
|
+
import { type EmitterSubscription } from 'react-native';
|
|
24
|
+
import type { NFCProgressEvent, NFCScanResult } from './types';
|
|
25
|
+
export { NFCSDKError } from './errors';
|
|
26
|
+
export type { NFCProgressEvent, NFCScanResult } from './types';
|
|
27
|
+
/**
|
|
28
|
+
* NFC SDK — API chính để đọc CCCD qua chip NFC.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* // 1. Lắng nghe kết quả (trong useEffect)
|
|
33
|
+
* const resultSub = NFCSDK.onScanResult((result) => {
|
|
34
|
+
* console.log(result.fullName, result.citizenId);
|
|
35
|
+
* });
|
|
36
|
+
* const progressSub = NFCSDK.onProgress((e) => {
|
|
37
|
+
* console.log(`${e.progress}% - ${e.message}`);
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* // 2. Bắt đầu quét
|
|
41
|
+
* NFCSDK.startScan({ citizenId: '001234567890' });
|
|
42
|
+
*
|
|
43
|
+
* // 3. Cleanup khi unmount
|
|
44
|
+
* resultSub.remove();
|
|
45
|
+
* progressSub.remove();
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const NFCSDK: {
|
|
49
|
+
/** Kiểm tra SDK có sẵn sàng không. */
|
|
50
|
+
isAvailable(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Bắt đầu quét NFC để đọc thông tin CCCD.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Object chứa `citizenId` (số CCCD, tối thiểu 6 ký tự)
|
|
55
|
+
* @throws {NFCSDKError} Nếu module chưa link hoặc citizenId không hợp lệ
|
|
56
|
+
*/
|
|
57
|
+
startScan(options: {
|
|
58
|
+
citizenId: string;
|
|
59
|
+
}): void;
|
|
60
|
+
/**
|
|
61
|
+
* Lắng nghe kết quả quét NFC.
|
|
62
|
+
* Gọi `.remove()` trên subscription để hủy.
|
|
63
|
+
*
|
|
64
|
+
* @param listener - Callback nhận `NFCScanResult`
|
|
65
|
+
* @returns EmitterSubscription
|
|
66
|
+
* @throws {NFCSDKError} Nếu event emitter không khả dụng
|
|
67
|
+
*/
|
|
68
|
+
onScanResult(listener: (result: NFCScanResult) => void): EmitterSubscription;
|
|
69
|
+
/**
|
|
70
|
+
* Lắng nghe tiến trình quét (0–100%).
|
|
71
|
+
* Gọi `.remove()` trên subscription để hủy.
|
|
72
|
+
*
|
|
73
|
+
* @param listener - Callback nhận `NFCProgressEvent`
|
|
74
|
+
* @returns EmitterSubscription
|
|
75
|
+
* @throws {NFCSDKError} Nếu event emitter không khả dụng
|
|
76
|
+
*/
|
|
77
|
+
onProgress(listener: (event: NFCProgressEvent) => void): EmitterSubscription;
|
|
78
|
+
};
|
|
79
|
+
export default NFCSDK;
|
|
80
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAIL,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA4B/D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,MAAM;IACjB,sCAAsC;mBACvB,OAAO;IAItB;;;;;OAKG;uBACgB;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAY/C;;;;;;;OAOG;2BACoB,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,GAAG,mBAAmB;IAI5E;;;;;;;OAOG;yBACkB,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,mBAAmB;CAW7E,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Sự kiện tiến trình quét NFC. */
|
|
2
|
+
export type NFCProgressEvent = {
|
|
3
|
+
/** Phần trăm hoàn thành (0–100). */
|
|
4
|
+
progress: number;
|
|
5
|
+
/** Mô tả bước đang thực hiện. */
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
/** Kết quả quét CCCD qua NFC. */
|
|
9
|
+
export type NFCScanResult = {
|
|
10
|
+
/** Số CCCD. */
|
|
11
|
+
citizenId?: string;
|
|
12
|
+
/** Họ và tên. */
|
|
13
|
+
fullName?: string;
|
|
14
|
+
/** Ngày sinh (DD/MM/YYYY). */
|
|
15
|
+
dob?: string;
|
|
16
|
+
/** Giới tính (Nam/Nữ/Khác). */
|
|
17
|
+
gender?: string;
|
|
18
|
+
/** Quốc tịch. */
|
|
19
|
+
nationality?: string;
|
|
20
|
+
/** Địa chỉ thường trú. */
|
|
21
|
+
permanentAddress?: string;
|
|
22
|
+
/** Ngày cấp (DD/MM/YYYY). */
|
|
23
|
+
issueDate?: string;
|
|
24
|
+
/** Nơi cấp. */
|
|
25
|
+
issuePlace?: string;
|
|
26
|
+
/** Ngày hết hạn (DD/MM/YYYY). */
|
|
27
|
+
expireDate?: string;
|
|
28
|
+
/** Ảnh chân dung từ chip (Base64). */
|
|
29
|
+
imageFromChip?: string;
|
|
30
|
+
/** Ảnh mặt trước thẻ (Base64). */
|
|
31
|
+
frontCardBase64?: string;
|
|
32
|
+
/** Ảnh mặt sau thẻ (Base64). */
|
|
33
|
+
backCardBase64?: string;
|
|
34
|
+
/** DG1 raw data (Base64). */
|
|
35
|
+
dg1DataB64?: string;
|
|
36
|
+
/** DG2 raw data (Base64). */
|
|
37
|
+
dg2DataB64?: string;
|
|
38
|
+
/** DG13 raw data (Base64). */
|
|
39
|
+
dg13DataB64?: string;
|
|
40
|
+
/** DG14 raw data (Base64). */
|
|
41
|
+
dg14DataB64?: string;
|
|
42
|
+
/** SOD security data (Base64). */
|
|
43
|
+
sodData?: string;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,iCAAiC;AACjC,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8BAA8B;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gCAAgC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
|