JsonWebEncryption.fromCompactSerialization constructor

JsonWebEncryption.fromCompactSerialization(
  1. String serialization
)

Constructs a JsonWebEncryption from its compact serialization

Implementation

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