Nebula
Gateway

JsonWebToken

Compact JSON Web Token (JWT) encoding: split, decode and sign.

generated from the sources
Static class in namespace Nebula · Packages/com.1by3.nebula/Runtime/Gateway/ClientAuth.cs
public static class JsonWebToken

Compact JSON Web Token (JWT) encoding: split, decode and sign. No policy lives here.

Methods

UnixNow

public static long UnixNow();

TryParse

public static bool TryParse(string token, out Dictionary<string, object> header, out Dictionary<string, object> payload, out byte[] signedBytes, out byte[] signature, out string error);

Split header.payload.signature and decode the two JSON objects. Does not verify anything.

SignHs256

public static string SignHs256(string payloadJson, byte[] key);

An HS256 token over payloadJson.

Base64UrlEncode

public static string Base64UrlEncode(byte[] bytes);

Base64UrlDecode

public static byte[] Base64UrlDecode(string s);

Claim

public static string Claim(Dictionary<string, object> claims, string name);

A claim as a string (numbers and booleans are formatted; missing = null).

NumericClaim

public static long? NumericClaim(Dictionary<string, object> claims, string name);

A numeric claim (exp, iat), or null when missing or not a number.

HasAudience

public static bool HasAudience(Dictionary<string, object> claims, string audience);

True when the aud claim (a string or an array of strings) names audience.

On this page