verifyExtendedClaim function

(dynamic, dynamic) verifyExtendedClaim(
  1. String claim
)

Implementation

(dynamic, dynamic) verifyExtendedClaim(String claim) {
  // Last character of each extracted_claim must be '}' or ','
  final last = claim[claim.length - 1];
  if (!(last == '}' || last == ',')) {
    throw ArgumentError('Invalid claim');
  }

  Map json = jsonDecode('{' + claim.substring(0, claim.length - 1) + '}');
  if (json.length != 1) {
    throw ArgumentError('Invalid claim');
  }
  final key = json.keys.first;
  return (key, json[key]);
}