fromJson static method

SecretEnvelope fromJson(
  1. Object? json
)

Implementation

static SecretEnvelope fromJson(Object? json) {
  if (json is! Map) {
    throw FormatException('SecretEnvelope: expected a Map, got $json');
  }
  final v = json['v'];
  final from = json['from'];
  final to = json['to'];
  final suite = json['suite'];
  final kid = json['kid'];
  final sealed = json['sealed'];
  if (v is! int ||
      from is! Map ||
      from['kpid'] is! String ||
      from['enrollmentId'] is! String ||
      to is! String ||
      suite is! String ||
      kid is! String ||
      sealed is! String) {
    throw FormatException('SecretEnvelope: malformed envelope $json');
  }
  return SecretEnvelope(
    v: v,
    fromKpid: from['kpid'],
    fromEnrollmentId: from['enrollmentId'],
    toKpid: to,
    suite: suite,
    kid: kid,
    sealed: sealed,
  );
}