1using System.Globalization;
2using System.Runtime.ExceptionServices;
57 if (Interface2 == Interface)
67 IsoDep.SetTimeout(300000);
71 if (!
string.IsNullOrEmpty(Mrz) &&
74 StringBuilder XmlBuilder =
new();
75 XmlWriter XmlOutput = XmlWriter.Create(XmlBuilder,
XML.
WriterSettings(
false,
true));
80 XmlOutput.WriteStartDocument();
81 XmlOutput.WriteStartElement(
"SnifferOutput",
"http://waher.se/Schema/SnifferOutput.xsd");
91 using TravelDocumentsClient Client =
new(IsoDep, DocInfo,
null, Sniffers);
95 Client.Information(
"Starting readout.");
97 Client.StateChanged += (
_, e) =>
100 return Task.CompletedTask;
107 switch (await Client.Authenticate())
135 Client.AppInfoUpdated += (
_, e) =>
138 return Task.CompletedTask;
141 Client.SecurityInfoUpdated += (
_, e) =>
144 return Task.CompletedTask;
147 Client.MrzUpdated += (
_, e) =>
152 return Task.CompletedTask;
155 Client.BiometricEncodingFaceUpdated += (
_, e) =>
158 if (Client.BiometricEncodingFace is not
null)
160 Representation? Face = Client.BiometricEncodingFace[0].BiometricDataBlock?.Record?.Representations[0];
162 if (Face is not
null)
164 Client.Warning(
"Face Image (type: " + Face.
ImageDataType.ToString() +
"):\r\n\r\n" +
165 Convert.ToBase64String(Face.
ImageData, Base64FormattingOptions.InsertLineBreaks));
170 return Task.CompletedTask;
173 Client.BiometricEncodingFingersUpdated += (
_, e) =>
176 if (Client.BiometricEncodingFingers is not
null)
178 Representation? Fingers = Client.BiometricEncodingFingers[0].BiometricDataBlock?.Record?.Representations[0];
180 if (Fingers is not
null)
182 Client.Warning(
"Fingers Image (type: " + Fingers.
ImageDataType.ToString() +
"):\r\n\r\n" +
183 Convert.ToBase64String(Fingers.
ImageData, Base64FormattingOptions.InsertLineBreaks));
188 return Task.CompletedTask;
191 Client.BiometricEncodingIrisesUpdated += (
_, e) =>
194 if (Client.BiometricEncodingIrises is not
null)
196 Representation? Irises = Client.BiometricEncodingIrises[0].BiometricDataBlock?.Record?.Representations[0];
198 if (Irises is not
null)
200 Client.Warning(
"Irises Image (type: " + Irises.
ImageDataType.ToString() +
"):\r\n\r\n" +
201 Convert.ToBase64String(Irises.
ImageData, Base64FormattingOptions.InsertLineBreaks));
206 return Task.CompletedTask;
209 Client.DisplayedSignaturesUpdated += (
_, e) =>
212 if (Client.DisplayedSignatures?.Signatures is not
null)
216 if (Signature is not
null)
218 Client.Warning(
"Signature Image (type: JPEG or JPEG2000):\r\n\r\n" +
219 Convert.ToBase64String(Signature.
ImageData, Base64FormattingOptions.InsertLineBreaks));
224 return Task.CompletedTask;
227 Client.PersonalInformationUpdated += (
_, e) =>
230 return Task.CompletedTask;
283 Client.Information(
"Readout completed.");
287 XmlOutput.WriteEndElement();
288 XmlOutput.WriteEndDocument();
291 string Xml = XmlBuilder.ToString();
299 Client.Exception(ex);
303 IsoDep.CloseIfOpen();
309 bool CanMakeReadOnly = await Ndef.CanMakeReadOnly();
310 bool IsWritable = await Ndef.IsWritable();
313 if (Records.Length == 0 && IsWritable)
315 await
ProgramNfc(Items => Ndef.SetMessage(Items));
329 if (await
App.OpenUrlAsync(UriRecord.Uri))
340 await
ProgramNfc(Items => NdefFormatable.Format(
false, Items));
345 byte[] Atqa = await NfcA.GetAtqa();
346 short Sqk = await NfcA.GetSqk();
352 byte[] ApplicationData = await NfcB.GetApplicationData();
353 byte[] ProtocolInfo = await NfcB.GetProtocolInfo();
359 byte[] Manufacturer = await NfcF.GetManufacturer();
360 byte[] SystemCode = await NfcF.GetSystemCode();
366 sbyte DsfId = await NfcV.GetDsfId();
367 short ResponseFlags = await NfcV.GetResponseFlags();
373 byte[] Data = await Barcode.ReadAllData();
379 byte[] Data = await MifareUltralight.ReadAllData();
385 byte[] Data = await MifareClassic.ReadAllData();
397 public delegate Task<bool> WriteItems(
object[] Items);
404 public static async Task<bool>
ProgramNfc(WriteItems Callback)
411 string? Link = LinkableView.Link;
414 List<object> Items = [];
416 if (LinkableView.EncodeAppLinks)
419 if (!
string.IsNullOrEmpty(Link))
420 Items.Add(
new Uri(Link));
422 if (LinkableView.EncodeAppLinks)
428 if (LinkableView.HasMedia)
429 Items.Add(
new KeyValuePair<
byte[],
string>(LinkableView.Media!, LinkableView.MediaContentType!));
434 bool Ok = await Callback([.. Items]);
436 if (!Ok && Items[^1] is KeyValuePair<
byte[],
string>)
438 Items.RemoveAt(Items.Count - 1);
439 Ok = await Callback([.. Items]);
444 while (Items.Count > 2)
447 Ok = await Callback([.. Items]);
452 Ok = await Callback([.. Items]);
Displayed Signatures or Usual Marks (DG7). Reference: §4.7.7, EF.DG7, ICAO Doc 9303-10,...
byte[] ImageData
Raw image data of signature (May be JPEG or JPEG2000).
Contains a representation of biometric data.
ImageDataType ImageDataType
Image data type.
byte[] ImageData
Raw binary image data.
Contains MRZ-related Extensions for Machine-Readable Travel Documents.
static bool ParseMrz(string MRZ, [NotNullWhen(true)] out DocumentInformation? Info)
Derives Basic Access Control Keys from the second row of the Machine-Readable string in passport (MRZ...
Represents an instance of the Neuro-Access app.
const string IdDomain
Neuro-Access domain.
References to external resources
const string IPhoneApp
Resource where iPhone App can be downloaded.
const string AndroidApp
Resource where Android App can be downloaded.
static ? string GetScheme(string Url)
Gets the predefined scheme from an IoT Code
A set of never changing property constants and helpful values.
A strongly-typed resource class, for looking up localized strings, etc.
static string TagEngraved
Looks up a localized string similar to Tag Engraved with link to {0}..
static string TagNotEngraved
Looks up a localized string similar to Unable to engrave tag with link to {0}..
static string SuccessTitle
Looks up a localized string similar to Success.
static string ErrorTitle
Looks up a localized string similar to An error has occurred.
Near-Field Communication (NFC) Service.
NfcService()
Near-Field Communication (NFC) Service.
static async Task< bool > ProgramNfc(WriteItems Callback)
Programs an NFC tag.
async Task TagDetected(INfcTag Tag)
Method called when a new NFC Tag has been detected.
Contains information about a contact.
static Task< NfcTagReference > FindByTagId(CaseInsensitiveString TagId)
Finds information about a contact, given its Bare JID.
Base class that references services in the app.
static IServiceProvider Provider
The service provider for the app. This is set before the app is started, and will be used to resolve ...
static IUiService UiService
Service serializing and managing UI-related tasks.
static IReportingStringLocalizer Localizer
Localization service
static IXmppService XmppService
The XMPP service for XMPP communication.
A base class for all pages, intended for custom navigation with explicit life-cycle events.
A base class for all view models, inheriting from the BindableObject. NOTE: using this class requir...
Helps with common XML-related tasks.
static XmlWriterSettings WriterSettings(bool Indent, bool OmitXmlDeclaration)
Gets an XML writer settings object.
async Task FlushAsync()
Waits until pending sniffer events have been processed.
void Information(string Comment)
Called to inform the viewer of something.
Outputs sniffed data to an XML writer.
Static class managing persistent settings.
static async Task< string > GetAsync(string Key, string DefaultValue)
Gets a string-valued setting.
Contains methods for simple hash calculations.
static string BinaryToString(byte[] Data)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).
ISO DEP interface, for communication with an NFC Tag.
Mifare Classic interface, for communication with an NFC Tag.
Mifare Ultralight interface, for communication with an NFC Tag.
NDEF interface, for communication with an NFC Tag.
NFC A interface, for communication with an NFC Tag.
NFC B interface, for communication with an NFC Tag.
NFC Barcode interface, for communication with an NFC Tag.
NFC F interface, for communication with an NFC Tag.
Specific Interface (technology) for communication with an NFC Tag.
void CloseIfOpen()
Closes the interface, if connected.
Task OpenIfClosed()
Connects the interface, if not connected.
Interface for an NFC Tag.
INfcInterface[] Interfaces
Communication interfaces available on the NFC Tag.
NFC V interface, for communication with an NFC Tag.
Interface for NDEF records
Interface for NDEF URI records
Interface for the Near-Field Communication (NFC) Service.
Service for navigating between pages using route-based navigation.
BaseContentPage? CurrentPage
Gets the current visible view.
Task DisplayException(Exception Exception, string? Title=null)
Displays an alert/message box to the user.
Task< bool > DisplayAlert(string Title, string Message, string? Accept=null, string? Cancel=null)
Displays an alert/message box to the user.
Interface for linkable views.
bool IsLinkable
If the current view is linkable.
Interface for sniffers. Sniffers can be added to ICommunicationLayer classes to eavesdrop on communic...
ReadTravelDocumentResult
Enumerations of possible results when reading a travel document.
AuthenticateResult
Enumerations of possible results when authenticating the app with the travel document.
AuthenticationPurpose
Purpose for requesting the user to authenticate itself.
BinaryPresentationMethod
How binary data is to be presented.