Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/rev status #343

Merged
merged 5 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.2.8+2
- Fixed protocol library method for revocation status check

## 2.2.8+1
- Fixed protocol libraries that caused issues with iOS devices

Expand Down
61 changes: 61 additions & 0 deletions IDEN3MESSAGE_PARSER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Iden3Message Parser

## Introduction

With the latest update, the content of the QR code provided by the Issuer or Verifier could be in three different formats:
- Url (iden3comm://?request_uri=)
- Base64 encoded (iden3comm://?i_m=)
- RAW Json format (json)

## Code Snippet
to parse the qr code content, you can use the following code snippet as an example:

```dart
class QrcodeParserUtils {
final PolygonIdSdk _polygonIdSdk;

QrcodeParserUtils(this._polygonIdSdk);

Future<Iden3MessageEntity> getIden3MessageFromQrCode(String message) async {
try {
String rawMessage = message;
if (message.startsWith("iden3comm://?i_m")) {
rawMessage = await _getMessageFromBase64(message);
}

if (message.startsWith("iden3comm://?request_uri")) {
rawMessage = await _getMessageFromRemote(message);
}

Iden3MessageEntity? _iden3Message =
await _polygonIdSdk.iden3comm.getIden3Message(message: rawMessage);
return _iden3Message;
} catch (error) {
throw Exception("Error while processing the QR code");
}
}

Future<String> _getMessageFromRemote(String message) async {
try {
message = message.replaceAll("iden3comm://?request_uri=", "");
http.Response response = await http.get(Uri.parse(message));
if (response.statusCode != 200) {
throw Exception("Error while getting the message from the remote");
}
return response.body;
} catch (error) {
throw Exception("Error while getting the message from the remote");
}
}

Future<String> _getMessageFromBase64(String message) async {
try {
message = message.replaceAll("iden3comm://?i_m=", "");
String decodedMessage = String.fromCharCodes(base64.decode(message));
return decodedMessage;
} catch (error) {
throw Exception("Error while getting the message from the base64");
}
}
}
```
Loading
Loading