@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.
Files changed (223) hide show
  1. package/LICENSE +20 -0
  2. package/NFCSDK.podspec +40 -0
  3. package/android/build.gradle +85 -0
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/AndroidManifest.xml +31 -0
  6. package/android/src/main/AndroidManifestNew.xml +30 -0
  7. package/android/src/main/java/com/nfcsdk/ChipReader.kt +237 -0
  8. package/android/src/main/java/com/nfcsdk/NFCSDKModule.kt +78 -0
  9. package/android/src/main/java/com/nfcsdk/NFCSDKPackage.kt +17 -0
  10. package/android/src/main/java/com/nfcsdk/NFCScanActivity.kt +299 -0
  11. package/android/src/main/java/com/nfcsdk/utils/Dg13Parser.kt +278 -0
  12. package/android/src/main/java/com/nfcsdk/utils/FaceExtractor.kt +40 -0
  13. package/android/src/main/java/com/nfcsdk/utils/MrzUtils.kt +75 -0
  14. package/android/src/main/res/drawable/bg_nfc_bottom_sheet.xml +13 -0
  15. package/android/src/main/res/drawable/bg_nfc_sheet_handle.xml +9 -0
  16. package/android/src/main/res/layout/activity_nfc.xml +110 -0
  17. package/android/src/main/res/values/styles.xml +10 -0
  18. package/android/src/main/res/xml/nfc_tech_filter.xml +8 -0
  19. package/ios/ChipReader.swift +258 -0
  20. package/ios/NFCSDK-Bridging-Header.h +2 -0
  21. package/ios/NFCSDK.mm +9 -0
  22. package/ios/NFCSDK.swift +112 -0
  23. package/ios/NFCSDKSession.swift +5 -0
  24. package/ios/utils/DG13Parser.swift +302 -0
  25. package/ios/utils/MrzUtils.swift +49 -0
  26. package/lib/module/errors.js +9 -0
  27. package/lib/module/errors.js.map +1 -0
  28. package/lib/module/index.js +118 -0
  29. package/lib/module/index.js.map +1 -0
  30. package/lib/module/package.json +1 -0
  31. package/lib/module/types.js +2 -0
  32. package/lib/module/types.js.map +1 -0
  33. package/lib/typescript/package.json +1 -0
  34. package/lib/typescript/src/errors.d.ts +4 -0
  35. package/lib/typescript/src/errors.d.ts.map +1 -0
  36. package/lib/typescript/src/index.d.ts +80 -0
  37. package/lib/typescript/src/index.d.ts.map +1 -0
  38. package/lib/typescript/src/types.d.ts +45 -0
  39. package/lib/typescript/src/types.d.ts.map +1 -0
  40. package/package.json +155 -0
  41. package/src/errors.ts +6 -0
  42. package/src/index.tsx +141 -0
  43. package/src/types.ts +45 -0
  44. package/vendor/ios-passport-reader/CHANGELOG +362 -0
  45. package/vendor/ios-passport-reader/CODE_OF_CONDUCT.md +77 -0
  46. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/AppDelegate.swift +39 -0
  47. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/Contents.json +158 -0
  48. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40.png +0 -0
  49. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png +0 -0
  50. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png +0 -0
  51. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png +0 -0
  52. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png +0 -0
  53. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72.png +0 -0
  54. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png +0 -0
  55. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76.png +0 -0
  56. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png +0 -0
  57. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png +0 -0
  58. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50.png +0 -0
  59. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50@2x.png +0 -0
  60. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small.png +0 -0
  61. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@2x.png +0 -0
  62. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@3x.png +0 -0
  63. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon.png +0 -0
  64. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon@2x.png +0 -0
  65. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/ios-marketing.png +0 -0
  66. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@2x.png +0 -0
  67. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@3x.png +0 -0
  68. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad.png +0 -0
  69. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad@2x.png +0 -0
  70. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/Contents.json +6 -0
  71. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/background.imageset/Contents.json +21 -0
  72. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/background.imageset/background.png +0 -0
  73. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/head.imageset/Contents.json +21 -0
  74. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Assets.xcassets/head.imageset/head.png +0 -0
  75. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Base.lproj/LaunchScreen.storyboard +25 -0
  76. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Extensions/FileManagerExt.swift +16 -0
  77. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Extensions/StringExt.swift +40 -0
  78. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Extensions/UIApplicationExt.swift +21 -0
  79. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Info.plist +77 -0
  80. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Model/PassportUtils.swift +76 -0
  81. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Model/SettingsStore.swift +107 -0
  82. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/NFCPassportReader.entitlements +10 -0
  83. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/SceneDelegate.swift +57 -0
  84. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/DetailsView.swift +197 -0
  85. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/ExportPassportView.swift +164 -0
  86. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/HelperViews/CheckBoxView.swift +48 -0
  87. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/HelperViews/ViewExt.swift +20 -0
  88. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/HelperViews/ViewModifiers.swift +41 -0
  89. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/MRZEntryView.swift +125 -0
  90. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/MRZScannerViewController.swift +90 -0
  91. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/MainView.swift +214 -0
  92. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/PassportSummaryView.swift +111 -0
  93. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/PassportView.swift +73 -0
  94. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/SettingsView.swift +63 -0
  95. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/Views/StoredPassportView.swift +152 -0
  96. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/masterList.pem +32 -0
  97. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp/readme.md +10 -0
  98. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcodeproj/project.pbxproj +695 -0
  99. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcodeproj/xcshareddata/xcschemes/NFCPassportReader.xcscheme +106 -0
  100. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcworkspace/contents.xcworkspacedata +10 -0
  101. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  102. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderApp.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
  103. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/DataGroupParsingTests.swift +189 -0
  104. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/Info.plist +22 -0
  105. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/NFCPassportReaderTests.swift +260 -0
  106. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/NFCPassportReaderAppTests/PACETests.swift +112 -0
  107. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/Podfile +22 -0
  108. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/Podfile.lock +35 -0
  109. package/vendor/ios-passport-reader/Examples/Example_CocoaPods/README.md +2 -0
  110. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/AppDelegate.swift +39 -0
  111. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/Contents.json +158 -0
  112. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40.png +0 -0
  113. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png +0 -0
  114. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png +0 -0
  115. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png +0 -0
  116. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png +0 -0
  117. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72.png +0 -0
  118. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-72@2x.png +0 -0
  119. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76.png +0 -0
  120. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png +0 -0
  121. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png +0 -0
  122. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50.png +0 -0
  123. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small-50@2x.png +0 -0
  124. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small.png +0 -0
  125. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@2x.png +0 -0
  126. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon-small@3x.png +0 -0
  127. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon.png +0 -0
  128. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/icon@2x.png +0 -0
  129. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/ios-marketing.png +0 -0
  130. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@2x.png +0 -0
  131. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon@3x.png +0 -0
  132. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad.png +0 -0
  133. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/AppIcon.appiconset/notification-icon~ipad@2x.png +0 -0
  134. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/Contents.json +6 -0
  135. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/background.imageset/Contents.json +21 -0
  136. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/background.imageset/background.png +0 -0
  137. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/head.imageset/Contents.json +21 -0
  138. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Assets.xcassets/head.imageset/head.png +0 -0
  139. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Base.lproj/LaunchScreen.storyboard +25 -0
  140. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Extensions/FileManagerExt.swift +16 -0
  141. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Extensions/StringExt.swift +40 -0
  142. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Extensions/UIApplicationExt.swift +21 -0
  143. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Info.plist +79 -0
  144. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Model/PassportUtils.swift +99 -0
  145. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Model/SettingsStore.swift +98 -0
  146. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Model/SettingsStoreCAN.swift +75 -0
  147. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/LICENSE +21 -0
  148. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/PreviewView.swift +34 -0
  149. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/StringUtils.swift +160 -0
  150. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/ViewController.swift +320 -0
  151. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/MrzScanner/VisionViewController.swift +163 -0
  152. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/NFCPassportReader.entitlements +10 -0
  153. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/SceneDelegate.swift +58 -0
  154. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/CANViews/CanKeyView.swift +251 -0
  155. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/CANViews/MRZEntryViewCanKey.swift +65 -0
  156. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/CANViews/PassportViewCAN.swift +73 -0
  157. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/DetailsView.swift +193 -0
  158. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/ExportPassportView.swift +164 -0
  159. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/HelperViews/CheckBoxView.swift +48 -0
  160. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/HelperViews/ViewExt.swift +20 -0
  161. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/HelperViews/ViewModifiers.swift +41 -0
  162. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/MRZEntryView.swift +125 -0
  163. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/MRZScannerViewController.swift +90 -0
  164. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/MainView.swift +264 -0
  165. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/PassportSummaryView.swift +111 -0
  166. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/PassportView.swift +73 -0
  167. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/SettingsView.swift +47 -0
  168. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/Views/StoredPassportView.swift +149 -0
  169. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/masterList.pem +32 -0
  170. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp/readme.md +10 -0
  171. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/project.pbxproj +683 -0
  172. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  173. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +25 -0
  174. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderApp.xcodeproj/xcshareddata/xcschemes/NFCPassportReader.xcscheme +106 -0
  175. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/DataGroupParsingTests.swift +190 -0
  176. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/Info.plist +22 -0
  177. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/NFCPassportReaderTests.swift +260 -0
  178. package/vendor/ios-passport-reader/Examples/Example_SPM/NFCPassportReaderAppTests/PACETests.swift +112 -0
  179. package/vendor/ios-passport-reader/LICENSE +21 -0
  180. package/vendor/ios-passport-reader/NFCPassportReader.podspec +27 -0
  181. package/vendor/ios-passport-reader/Package.swift +29 -0
  182. package/vendor/ios-passport-reader/README.md +141 -0
  183. package/vendor/ios-passport-reader/Sources/NFCPassportReader/AES_3DES_DESEncryption.swift +377 -0
  184. package/vendor/ios-passport-reader/Sources/NFCPassportReader/BACHandler.swift +194 -0
  185. package/vendor/ios-passport-reader/Sources/NFCPassportReader/ChipAuthenticationHandler.swift +224 -0
  186. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroupHash.swift +16 -0
  187. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroupParser.swift +36 -0
  188. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/ActiveAuthenticationInfo.swift +69 -0
  189. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/COM.swift +61 -0
  190. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/CardAccess.swift +38 -0
  191. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/ChipAuthenticationInfo.swift +135 -0
  192. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/ChipAuthenticationPublicKeyInfo.swift +53 -0
  193. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup.swift +103 -0
  194. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup1.swift +111 -0
  195. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup11.swift +66 -0
  196. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup12.swift +75 -0
  197. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup14.swift +37 -0
  198. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup15.swift +46 -0
  199. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup2.swift +163 -0
  200. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroup7.swift +46 -0
  201. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/DataGroupId.swift +105 -0
  202. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/NotImplementedDG.swift +16 -0
  203. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/PACEInfo.swift +415 -0
  204. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/SOD.swift +240 -0
  205. package/vendor/ios-passport-reader/Sources/NFCPassportReader/DataGroups/SecurityInfo.swift +136 -0
  206. package/vendor/ios-passport-reader/Sources/NFCPassportReader/Errors.swift +148 -0
  207. package/vendor/ios-passport-reader/Sources/NFCPassportReader/Logging.swift +32 -0
  208. package/vendor/ios-passport-reader/Sources/NFCPassportReader/Models/FaceImageInfo.swift +161 -0
  209. package/vendor/ios-passport-reader/Sources/NFCPassportReader/NFCPassportModel.swift +540 -0
  210. package/vendor/ios-passport-reader/Sources/NFCPassportReader/NFCViewDisplayMessage.swift +60 -0
  211. package/vendor/ios-passport-reader/Sources/NFCPassportReader/OpenSSLUtils.swift +705 -0
  212. package/vendor/ios-passport-reader/Sources/NFCPassportReader/PACEHandler.swift +627 -0
  213. package/vendor/ios-passport-reader/Sources/NFCPassportReader/PassportReader.swift +387 -0
  214. package/vendor/ios-passport-reader/Sources/NFCPassportReader/Resources/PrivacyInfo.xcprivacy +14 -0
  215. package/vendor/ios-passport-reader/Sources/NFCPassportReader/ResponseAPDU.swift +25 -0
  216. package/vendor/ios-passport-reader/Sources/NFCPassportReader/SecureMessaging.swift +301 -0
  217. package/vendor/ios-passport-reader/Sources/NFCPassportReader/SecureMessagingSessionKeyGenerator.swift +156 -0
  218. package/vendor/ios-passport-reader/Sources/NFCPassportReader/SimpleASN1DumpParser.swift +173 -0
  219. package/vendor/ios-passport-reader/Sources/NFCPassportReader/TagReader.swift +374 -0
  220. package/vendor/ios-passport-reader/Sources/NFCPassportReader/Utils.swift +430 -0
  221. package/vendor/ios-passport-reader/Sources/NFCPassportReader/X509Wrapper.swift +168 -0
  222. package/vendor/ios-passport-reader/scripts/README.md +45 -0
  223. package/vendor/ios-passport-reader/scripts/extract.py +197 -0
@@ -0,0 +1,374 @@
1
+ //
2
+ // TagHandler.swift
3
+ // NFCTest
4
+ //
5
+ // Created by Andy Qua on 09/06/2019.
6
+ // Copyright © 2019 Andy Qua. All rights reserved.
7
+ //
8
+
9
+ import Foundation
10
+ import OSLog
11
+
12
+ #if !os(macOS)
13
+ import CoreNFC
14
+
15
+ @available(iOS 15, *)
16
+ public class TagReader {
17
+ var tag : NFCISO7816Tag
18
+ var secureMessaging : SecureMessaging?
19
+ var maxDataLengthToRead : Int = 0xA0 // Should be able to use 256 to read arbitrary amounts of data at full speed BUT this isn't supported across all passports so for reliability just use the smaller amount.
20
+
21
+ var progress : ((Int)->())?
22
+
23
+ init( tag: NFCISO7816Tag ) {
24
+ self.tag = tag
25
+ }
26
+
27
+ func overrideDataAmountToRead( newAmount : Int ) {
28
+ maxDataLengthToRead = newAmount
29
+ }
30
+
31
+ func reduceDataReadingAmount() {
32
+ if maxDataLengthToRead > 0xA0 {
33
+ maxDataLengthToRead = 0xA0
34
+ }
35
+ }
36
+
37
+
38
+ func readDataGroup( dataGroup: DataGroupId ) async throws -> [UInt8] {
39
+ guard let tag = dataGroup.getFileIDTag() else {
40
+ throw NFCPassportReaderError.UnsupportedDataGroup
41
+ }
42
+
43
+ return try await selectFileAndRead(tag: tag )
44
+ }
45
+
46
+ func getChallenge() async throws -> ResponseAPDU{
47
+ let cmd : NFCISO7816APDU = NFCISO7816APDU(instructionClass: 00, instructionCode: 0x84, p1Parameter: 0, p2Parameter: 0, data: Data(), expectedResponseLength: 8)
48
+
49
+ return try await send( cmd: cmd )
50
+ }
51
+
52
+ func doInternalAuthentication( challenge: [UInt8], useExtendedMode: Bool ) async throws -> ResponseAPDU {
53
+ let randNonce = Data(challenge)
54
+
55
+ var responseLength = 256
56
+ if useExtendedMode {
57
+ responseLength = 65535
58
+ }
59
+
60
+ let cmd = NFCISO7816APDU(instructionClass: 00, instructionCode: 0x88, p1Parameter: 0, p2Parameter: 0, data: randNonce, expectedResponseLength: responseLength)
61
+
62
+ return try await send( cmd: cmd, useExtendedMode: useExtendedMode )
63
+ }
64
+
65
+ func doMutualAuthentication( cmdData : Data ) async throws -> ResponseAPDU{
66
+ let cmd : NFCISO7816APDU = NFCISO7816APDU(instructionClass: 00, instructionCode: 0x82, p1Parameter: 0, p2Parameter: 0, data: cmdData, expectedResponseLength: 256)
67
+
68
+ return try await send( cmd: cmd )
69
+ }
70
+
71
+ /// The MSE KAT APDU, see EAC 1.11 spec, Section B.1.
72
+ /// This command is sent in the "DESede" case.
73
+ /// - Parameter keyData key data object (tag 0x91)
74
+ /// - Parameter idData key id data object (tag 0x84), can be null
75
+ /// - Parameter completed the complete handler - returns the success response or an error
76
+ func sendMSEKAT( keyData : Data, idData: Data? ) async throws -> ResponseAPDU {
77
+
78
+ var data = keyData
79
+ if let idData = idData {
80
+ data += idData
81
+ }
82
+
83
+ let cmd : NFCISO7816APDU = NFCISO7816APDU(instructionClass: 00, instructionCode: 0x22, p1Parameter: 0x41, p2Parameter: 0xA6, data: data, expectedResponseLength: 256)
84
+
85
+ return try await send( cmd: cmd )
86
+ }
87
+
88
+ /// The MSE Set AT for Chip Authentication.
89
+ /// This command is the first command that is sent in the "AES" case.
90
+ /// For Chip Authentication. We prefix 0x80 for OID and 0x84 for keyId.
91
+ ///
92
+ /// NOTE THIS IS CURRENTLY UNTESTED
93
+ /// - Parameter oid the OID
94
+ /// - Parameter keyId the keyId or {@code null}
95
+ /// - Parameter completed the complete handler - returns the success response or an error
96
+ func sendMSESetATIntAuth( oid: String, keyId: Int? ) async throws -> ResponseAPDU {
97
+
98
+ let cmd : NFCISO7816APDU
99
+ let oidBytes = oidToBytes(oid: oid, replaceTag: true)
100
+
101
+ if let keyId = keyId, keyId != 0 {
102
+ let keyIdBytes = wrapDO(b:0x84, arr:intToBytes(val:keyId, removePadding: true))
103
+ let data = oidBytes + keyIdBytes
104
+
105
+ cmd = NFCISO7816APDU(instructionClass: 00, instructionCode: 0x22, p1Parameter: 0x41, p2Parameter: 0xA4, data: Data(data), expectedResponseLength: 256)
106
+
107
+ } else {
108
+ cmd = NFCISO7816APDU(instructionClass: 00, instructionCode: 0x22, p1Parameter: 0x41, p2Parameter: 0xA4, data: Data(oidBytes), expectedResponseLength: 256)
109
+ }
110
+
111
+ return try await send( cmd: cmd )
112
+ }
113
+
114
+ func sendMSESetATMutualAuth( oid: String, keyType: UInt8 ) async throws -> ResponseAPDU {
115
+
116
+ let oidBytes = oidToBytes(oid: oid, replaceTag: true)
117
+ let keyTypeBytes = wrapDO( b: 0x83, arr:[keyType])
118
+
119
+ let data = oidBytes + keyTypeBytes
120
+
121
+ let cmd = NFCISO7816APDU(instructionClass: 00, instructionCode: 0x22, p1Parameter: 0xC1, p2Parameter: 0xA4, data: Data(data), expectedResponseLength: -1)
122
+
123
+ return try await send( cmd: cmd )
124
+ }
125
+
126
+
127
+ /// Sends a General Authenticate command.
128
+ /// This command is the second command that is sent in the "AES" case.
129
+ /// - Parameter data data to be sent, without the {@code 0x7C} prefix (this method will add it)
130
+ /// - Parameter lengthExpected the expected length defaults to 256
131
+ /// - Parameter isLast indicates whether this is the last command in the chain
132
+ /// - Parameter completed the complete handler - returns the dynamic authentication data without the {@code 0x7C} prefix (this method will remove it) or an error
133
+ func sendGeneralAuthenticate( data : [UInt8], lengthExpected : Int = 256, isLast: Bool) async throws -> ResponseAPDU {
134
+
135
+ let wrappedData = wrapDO(b:0x7C, arr:data)
136
+ let commandData = Data(wrappedData)
137
+
138
+ // NOTE: Support of Protocol Response Data is CONDITIONAL:
139
+ // It MUST be provided for version 2 but MUST NOT be provided for version 1.
140
+ // So, we are expecting 0x7C (= tag), 0x00 (= length) here.
141
+
142
+ // 0x10 is class command chaining
143
+ let instructionClass : UInt8 = isLast ? 0x00 : 0x10
144
+ let INS_BSI_GENERAL_AUTHENTICATE : UInt8 = 0x86
145
+
146
+ let cmd : NFCISO7816APDU = NFCISO7816APDU(instructionClass: instructionClass, instructionCode: INS_BSI_GENERAL_AUTHENTICATE, p1Parameter: 0x00, p2Parameter: 0x00, data: commandData, expectedResponseLength: lengthExpected)
147
+ var response : ResponseAPDU
148
+ do {
149
+ response = try await send( cmd: cmd )
150
+ response.data = try unwrapDO( tag:0x7c, wrappedData:response.data)
151
+ } catch {
152
+ // If wrong length error
153
+ if case NFCPassportReaderError.ResponseError(_, let sw1, let sw2) = error,
154
+ sw1 == 0x67, sw2 == 0x00 {
155
+
156
+ // Resend
157
+ let cmd : NFCISO7816APDU = NFCISO7816APDU(instructionClass: instructionClass, instructionCode: INS_BSI_GENERAL_AUTHENTICATE, p1Parameter: 0x00, p2Parameter: 0x00, data: commandData, expectedResponseLength: 256)
158
+ response = try await send( cmd: cmd )
159
+ response.data = try unwrapDO( tag:0x7c, wrappedData:response.data)
160
+ } else {
161
+ throw error
162
+ }
163
+ }
164
+ return response
165
+ }
166
+
167
+
168
+ func selectFileAndRead( tag: [UInt8]) async throws -> [UInt8] {
169
+ var resp = try await selectFile(tag: tag )
170
+
171
+ // Read first 4 bytes of header to see how big the data structure is
172
+ guard let readHeaderCmd = NFCISO7816APDU(data:Data([0x00, 0xB0, 0x00, 0x00, 0x00, 0x00,0x04])) else {
173
+ throw NFCPassportReaderError.UnexpectedError
174
+ }
175
+ resp = try await self.send( cmd: readHeaderCmd )
176
+
177
+ // Header looks like: <tag><length of data><nextTag> e.g.60145F01 -
178
+ // the total length is the 2nd value plus the two header 2 bytes
179
+ // We've read 4 bytes so we now need to read the remaining bytes from offset 4
180
+ let (len, o) = try! asn1Length([UInt8](resp.data[1..<4]))
181
+ var remaining = Int(len)
182
+ var amountRead = o + 1
183
+
184
+ var data = [UInt8](resp.data[..<amountRead])
185
+
186
+ Logger.tagReader.debug( "TagReader - Number of data bytes to read - \(remaining)" )
187
+
188
+ var readAmount : Int = maxDataLengthToRead
189
+ while remaining > 0 {
190
+ if maxDataLengthToRead != 256 && remaining < maxDataLengthToRead {
191
+ readAmount = remaining
192
+ }
193
+
194
+ self.progress?( Int(Float(amountRead) / Float(remaining+amountRead ) * 100))
195
+ let offset = intToBin(amountRead, pad:4)
196
+
197
+ Logger.tagReader.debug( "TagReader - data bytes remaining: \(remaining), will read : \(readAmount)" )
198
+ let cmd = NFCISO7816APDU(
199
+ instructionClass: 00,
200
+ instructionCode: 0xB0,
201
+ p1Parameter: offset[0],
202
+ p2Parameter: offset[1],
203
+ data: Data(),
204
+ expectedResponseLength: readAmount
205
+ )
206
+ resp = try await self.send( cmd: cmd )
207
+
208
+ Logger.tagReader.debug( "TagReader - got resp - \(binToHexRep(resp.data, asArray: true)), sw1 : \(resp.sw1), sw2 : \(resp.sw2)" )
209
+ data += resp.data
210
+
211
+ remaining -= resp.data.count
212
+ amountRead += resp.data.count
213
+ Logger.tagReader.debug( "TagReader - Amount of data left to read - \(remaining)" )
214
+ }
215
+
216
+ return data
217
+ }
218
+
219
+
220
+ func readCardAccess() async throws -> [UInt8]{
221
+ // Info provided by @smulu
222
+ // By default NFCISO7816Tag requirers a list of ISO/IEC 7816 applets (AIDs). Upon discovery of NFC tag the first found applet from this list is automatically selected (and you have no way of changing this).
223
+ // This is a problem for PACE protocol becaues it requires reading parameters from file EF.CardAccess which lies outside of eMRTD applet (AID: A0000002471001) in the master file.
224
+
225
+ // Now, the ICAO 9303 standard does specify command for selecting master file by sending SELECT APDU with P1=0x00, P2=0x0C and empty data field (see part 10 page 8). But after some testing I found out this command doesn't work on some passports (European passports) and although receiving success (sw=9000) from passport the master file is not selected.
226
+
227
+ // After a bit of researching standard ISO/IEC 7816 I found there is an alternative SELECT command for selecting master file. The command doesn't differ much from the command specified in ICAO 9303 doc with only difference that data field is set to: 0x3F00. See section 6.11.3 of ISO/IEC 7816-4.
228
+ // By executing above SELECT command (with data=0x3F00) master file should be selected and you should be able to read EF.CardAccess from passport.
229
+
230
+ // First select master file
231
+ let cmd : NFCISO7816APDU = NFCISO7816APDU(instructionClass: 0x00, instructionCode: 0xA4, p1Parameter: 0x00, p2Parameter: 0x0C, data: Data([0x3f,0x00]), expectedResponseLength: -1)
232
+
233
+ _ = try await send( cmd: cmd)
234
+
235
+ // Now read EC.CardAccess
236
+ let data = try await self.selectFileAndRead(tag: [0x01,0x1C])
237
+ return data
238
+ }
239
+
240
+ func selectPassportApplication() async throws -> ResponseAPDU {
241
+ // Finally reselect the eMRTD application so the rest of the reading works as normal
242
+ Logger.tagReader.debug( "Re-selecting eMRTD Application" )
243
+ let cmd : NFCISO7816APDU = NFCISO7816APDU(instructionClass: 0x00, instructionCode: 0xA4, p1Parameter: 0x04, p2Parameter: 0x0C, data: Data([0xA0, 0x00, 0x00, 0x02, 0x47, 0x10, 0x01]), expectedResponseLength: -1)
244
+
245
+ let response = try await self.send( cmd: cmd)
246
+ return response
247
+ }
248
+
249
+ func selectFile( tag: [UInt8] ) async throws -> ResponseAPDU {
250
+
251
+ let data : [UInt8] = [0x00, 0xA4, 0x02, 0x0C, 0x02] + tag
252
+ let cmd = NFCISO7816APDU(data:Data(data))!
253
+
254
+ return try await send( cmd: cmd )
255
+ }
256
+
257
+ func send( cmd: NFCISO7816APDU, useExtendedMode : Bool = false ) async throws -> ResponseAPDU {
258
+ Logger.tagReader.debug( "TagReader - sending \(cmd)" )
259
+ var toSend = cmd
260
+ if let sm = secureMessaging {
261
+ toSend = try sm.protect(apdu:cmd, useExtendedMode: useExtendedMode)
262
+ Logger.tagReader.debug("TagReader - [SM] \(toSend)" )
263
+ }
264
+
265
+ var (data, sw1, sw2) = try await tag.sendCommand(apdu: toSend)
266
+ Logger.tagReader.debug( "TagReader - Received response, size \(data.count)b" )
267
+
268
+ // Some commands may have bigger response than expected. Read the whole response using INS 0xC0 (GET RESPONSE).
269
+ while (sw1 == 0x61) {
270
+ let getResponseCmd = NFCISO7816APDU(instructionClass: 0x0, instructionCode: 0xC0, p1Parameter: 0x0, p2Parameter: 0x0, data: Data(), expectedResponseLength: Int(sw2))
271
+ let nextSegment: Data
272
+ // Overwrite sw1 and sw2.
273
+ (nextSegment, sw1, sw2) = try await tag.sendCommand(apdu: getResponseCmd)
274
+ Logger.tagReader.debug("Read remaining data. Accumulated: \(data.count + nextSegment.count)b. Last batch \(nextSegment.count)b. Still remaining: \(sw2)b")
275
+ data += nextSegment
276
+ }
277
+
278
+ var rep = ResponseAPDU(data: [UInt8](data), sw1: sw1, sw2: sw2)
279
+
280
+ if let sm = self.secureMessaging {
281
+ rep = try sm.unprotect(rapdu:rep)
282
+ Logger.tagReader.debug("\(String(format:"TagReader [SM - unprotected] \(binToHexRep(rep.data, asArray:true)), sw1:0x%02x sw2:0x%02x", rep.sw1, rep.sw2))" )
283
+ } else {
284
+ Logger.tagReader.debug("\(String(format:"TagReader [unprotected] \(binToHexRep(rep.data, asArray:true)), sw1:0x%02x sw2:0x%02x", rep.sw1, rep.sw2))" )
285
+
286
+ }
287
+
288
+ if rep.sw1 != 0x90 && rep.sw2 != 0x00 {
289
+ Logger.tagReader.error( "Error reading tag: sw1 - 0x\(binToHexRep(sw1)), sw2 - 0x\(binToHexRep(sw2))" )
290
+ let tagError: NFCPassportReaderError
291
+ if (rep.sw1 == 0x63 && rep.sw2 == 0x00) {
292
+ tagError = NFCPassportReaderError.InvalidMRZKey
293
+ } else {
294
+ let errorMsg = self.decodeError(sw1: rep.sw1, sw2: rep.sw2)
295
+ Logger.tagReader.error( "reason: \(errorMsg)" )
296
+ tagError = NFCPassportReaderError.ResponseError( errorMsg, sw1, sw2 )
297
+ }
298
+ throw tagError
299
+ }
300
+
301
+ return rep
302
+ }
303
+
304
+ private func decodeError( sw1: UInt8, sw2:UInt8 ) -> String {
305
+
306
+ let errors : [UInt8 : [UInt8:String]] = [
307
+ 0x62: [0x00:"No information given",
308
+ 0x81:"Part of returned data may be corrupted",
309
+ 0x82:"End of file/record reached before reading Le bytes",
310
+ 0x83:"Selected file invalidated",
311
+ 0x84:"FCI not formatted according to ISO7816-4 section 5.1.5"],
312
+
313
+ 0x63: [0x81:"File filled up by the last write",
314
+ 0x82:"Card Key not supported",
315
+ 0x83:"Reader Key not supported",
316
+ 0x84:"Plain transmission not supported",
317
+ 0x85:"Secured Transmission not supported",
318
+ 0x86:"Volatile memory not available",
319
+ 0x87:"Non Volatile memory not available",
320
+ 0x88:"Key number not valid",
321
+ 0x89:"Key length is not correct",
322
+ 0xC:"Counter provided by X (valued from 0 to 15) (exact meaning depending on the command)"],
323
+ 0x65: [0x00:"No information given",
324
+ 0x81:"Memory failure"],
325
+ 0x67: [0x00:"Wrong length"],
326
+ 0x68: [0x00:"No information given",
327
+ 0x81:"Logical channel not supported",
328
+ 0x82:"Secure messaging not supported",
329
+ 0x83:"Last command of the chain expected",
330
+ 0x84:"Command chaining not supported"],
331
+ 0x69: [0x00:"No information given",
332
+ 0x81:"Command incompatible with file structure",
333
+ 0x82:"Security status not satisfied",
334
+ 0x83:"Authentication method blocked",
335
+ 0x84:"Referenced data invalidated",
336
+ 0x85:"Conditions of use not satisfied",
337
+ 0x86:"Command not allowed (no current EF)",
338
+ 0x87:"Expected SM data objects missing",
339
+ 0x88:"SM data objects incorrect"],
340
+ 0x6A: [0x00:"No information given",
341
+ 0x80:"Incorrect parameters in the data field",
342
+ 0x81:"Function not supported",
343
+ 0x82:"File not found",
344
+ 0x83:"Record not found",
345
+ 0x84:"Not enough memory space in the file",
346
+ 0x85:"Lc inconsistent with TLV structure",
347
+ 0x86:"Incorrect parameters P1-P2",
348
+ 0x87:"Lc inconsistent with P1-P2",
349
+ 0x88:"Referenced data not found"],
350
+ 0x6B: [0x00:"Wrong parameter(s) P1-P2]"],
351
+ 0x6D: [0x00:"Instruction code not supported or invalid"],
352
+ 0x6E: [0x00:"Class not supported"],
353
+ 0x6F: [0x00:"No precise diagnosis"],
354
+ 0x90: [0x00:"Success"] //No further qualification
355
+ ]
356
+
357
+ // Special cases - where sw2 isn't an error but contains a value
358
+ if sw1 == 0x61 {
359
+ return "SW2 indicates the number of response bytes still available - (\(sw2) bytes still available)"
360
+ } else if sw1 == 0x64 {
361
+ return "State of non-volatile memory unchanged (SW2=00, other values are RFU)"
362
+ } else if sw1 == 0x6C {
363
+ return "Wrong length Le: SW2 indicates the exact length - (exact length :\(sw2))"
364
+ }
365
+
366
+ if let dict = errors[sw1], let errorMsg = dict[sw2] {
367
+ return errorMsg
368
+ }
369
+
370
+ return "Unknown error - sw1: 0x\(binToHexRep(sw1)), sw2 - 0x\(binToHexRep(sw2)) "
371
+ }
372
+ }
373
+
374
+ #endif