build method

  1. @override
JsonWebSignature build()
override

Implementation

@override
JsonWebSignature build() {
  if (recipients.isEmpty) {
    throw StateError('Need at least one recipient');
  }
  var payload = this.payload;
  if (payload == null) {
    throw StateError('No payload set');
  }

  var signatures = recipients.map((r) {
    var key = r['_jwk'];
    var algorithm = r['alg'];
    return _JwsRecipient._sign(payload.data, payload.protectedHeader!, key,
        algorithm: algorithm, protectAll: recipients.length == 1);
  }).toList();

  return JsonWebSignature._(payload.data, signatures);
}