headers method

Future<Map<String, String>> headers({
  1. required String method,
  2. required Uri url,
  3. List<int>? body,
})

Headers proving THIS request comes from this device: X-Nexus-Shield (the token) and DPoP (a single-use proof for exactly method + url). Pass body to also bind the proof to the payload. Returns {} when no token can be had — never throws.

Implementation

Future<Map<String, String>> headers({required String method, required Uri url, List<int>? body}) async {
  try {
    final t = await token();
    final key = _key;
    if (t == null || key == null) return const {};
    final proof = await _proof(key, method: method, url: url, accessToken: t.value, body: body);
    if (proof == null) return const {};
    return {'X-Nexus-Shield': t.value, 'DPoP': proof};
  } catch (e, st) {
    NexusLog.error('shield: could not sign request', e, st);
    return const {};
  }
}