DIDAuthMessage.fromJson constructor

DIDAuthMessage.fromJson(
  1. Map<String, dynamic> json
)

Constructs a DIDAuthMessage instance from a JSON map.

Implementation

factory DIDAuthMessage.fromJson(Map<String, dynamic> json) {
  try {
    if (json.containsKey("type") && json["type"] != "DIDAuth") {
      throw Exception("Invalid type");
    }
    return DIDAuthMessage(
      id: json["id"],
      from: json["from"],
      to: json["to"],
      createdTime: json.containsKey("createdTime") ? json["createdTime"] : 0,
      expiresTime: json.containsKey("expiresTime") ? json["expiresTime"] : 0,
      context: json["body"].containsKey("context")
          ? Context.fromJson(json["body"]["context"])
          : Context.fromCompactJson(json["body"]["c"]),
      socketId: json["body"].containsKey("socketId")
          ? json["body"]["socketId"]
          : null,
      peerSocketId: json["body"]["peerSocketId"],
    );
  } catch (e) {
    rethrow;
  }
}