buildJwsHeader function
Implementation
String buildJwsHeader(
{required String alg,
String? jku,
Map<String, dynamic>? jwk,
String? kid,
String? x5u,
List<String>? x5c,
String? x5t,
String? x5tS256,
String? typ,
Map<String, dynamic>? extra}) {
Map<String, dynamic> jsonObject = {};
jsonObject.putIfAbsent('alg', () => alg);
if (jku != null) {
jsonObject.putIfAbsent('jku', () => jku);
}
if (jwk != null) {
jsonObject.putIfAbsent('jwk', () => jwk);
}
if (kid != null) {
jsonObject.putIfAbsent('kid', () => kid);
}
if (x5u != null) {
jsonObject.putIfAbsent('x5u', () => x5u);
}
if (x5c != null) {
jsonObject.putIfAbsent('x5c', () => x5c);
}
if (x5t != null) {
jsonObject.putIfAbsent('x5t', () => x5t);
}
if (x5tS256 != null) {
jsonObject.putIfAbsent('x5t#S256', () => x5tS256);
}
if (typ != null) {
jsonObject.putIfAbsent('typ', () => typ);
}
if (extra != null) {
jsonObject.addAll(extra);
var keyList = extra.keys.toList();
jsonObject.putIfAbsent('crit', () => keyList);
}
var jsonString = jsonEncode(jsonObject);
return base64UrlEncode(utf8.encode(jsonString));
}