JsonWebSignature.fromCompactSerialization constructor

JsonWebSignature.fromCompactSerialization(
  1. String serialization
)

Constructs a JsonWebSignature from its compact serialization

Implementation

factory JsonWebSignature.fromCompactSerialization(String serialization) {
  var parts = serialization.split('.');
  if (parts.length != 3) {
    throw ArgumentError.value(
        serialization, 'Compact serialization should have 3 parts.');
  }
  return JsonWebSignature._(
      decodeBase64EncodedBytes(parts[1]),
      List.unmodifiable([
        _JwsRecipient(
            protectedHeader: JsonObject.decode(parts[0]),
            data: decodeBase64EncodedBytes(parts[2]))
      ]));
}