< Summary

Information
Class: AsiBackbone.Core.CapabilityGrants.CapabilityGrantTokenDecodeResult
Assembly: AsiBackbone.Core
File(s): /home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.Core/CapabilityGrants/CapabilityGrantTokenDecodeResult.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 61
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Succeeded()100%11100%
Success(...)100%11100%
Failure(...)100%11100%

File(s)

/home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.Core/CapabilityGrants/CapabilityGrantTokenDecodeResult.cs

#LineLine coverage
 1using AsiBackbone.Core.Signing;
 2
 3namespace AsiBackbone.Core.CapabilityGrants;
 4
 5/// <summary>
 6/// Represents the outcome of decoding a capability grant token with <see cref="CapabilityGrantToken.Decode" />.
 7/// </summary>
 8/// <remarks>
 9/// A successful decode establishes only that the token is well formed. The decoded grant has not been verified: pass
 10/// <see cref="SignedGrant" /> to <see cref="CapabilityGrantValidator.ValidateAsync" /> with a proof-requiring profile
 11/// before trusting any of its values.
 12/// </remarks>
 13public sealed class CapabilityGrantTokenDecodeResult
 14{
 8715    private CapabilityGrantTokenDecodeResult(
 8716        SignedGovernanceArtifact<CapabilityGrant>? signedGrant,
 8717        string? failureCode,
 8718        string? failureMessage)
 19    {
 8720        SignedGrant = signedGrant;
 8721        FailureCode = failureCode;
 8722        FailureMessage = failureMessage;
 8723    }
 24
 25    /// <summary>
 26    /// Gets a value indicating whether the token decoded into a signed grant.
 27    /// </summary>
 8428    public bool Succeeded => SignedGrant is not null;
 29
 30    /// <summary>
 31    /// Gets the decoded, not yet verified, signed grant when decoding succeeded.
 32    /// </summary>
 33    /// <remarks>
 34    /// The canonical payload and hash are rebuilt from the decoded grant fields rather than read from the token, so a
 35    /// grant field edited after signing produces a hash the signature does not cover.
 36    /// </remarks>
 37    public SignedGovernanceArtifact<CapabilityGrant>? SignedGrant { get; }
 38
 39    /// <summary>
 40    /// Gets the machine-readable failure code, such as <c>capability.token-malformed</c>, when decoding failed.
 41    /// </summary>
 42    public string? FailureCode { get; }
 43
 44    /// <summary>
 45    /// Gets a human-readable failure message, when decoding failed.
 46    /// </summary>
 47    /// <remarks>
 48    /// The message describes the token structure only and never echoes token content.
 49    /// </remarks>
 50    public string? FailureMessage { get; }
 51
 52    internal static CapabilityGrantTokenDecodeResult Success(SignedGovernanceArtifact<CapabilityGrant> signedGrant)
 53    {
 6454        return new CapabilityGrantTokenDecodeResult(signedGrant, failureCode: null, failureMessage: null);
 55    }
 56
 57    internal static CapabilityGrantTokenDecodeResult Failure(string failureCode, string failureMessage)
 58    {
 2359        return new CapabilityGrantTokenDecodeResult(signedGrant: null, failureCode, failureMessage);
 60    }
 61}