wrapAndSignAndJsonEncode method

FutureOr<String> wrapAndSignAndJsonEncode(
  1. Object? payload, {
  2. Object? toEncodable(
    1. Object? nonEncodable
    )?,
  3. EnvelopeType type = EnvelopeType.app,
})

Same as wrapAndSign but we also call jsonEncode for you :)

Implementation

FutureOr<String> wrapAndSignAndJsonEncode(
  Object? payload, {
  Object? Function(Object? nonEncodable)? toEncodable,
  EnvelopeType type = EnvelopeType.app,
}) async {
  final envelope =
      await wrapAndSign(payload, toEncodable: toEncodable, type: type);
  // NOTE: no toEncodable — the signing already encoded the payload to
  // base64url, so what is left is strings.
  return jsonEncode(envelope.toJson());
}