< Summary - Kestrun — Combined Coverage

Information
Class: Public.JWT.Limit-KrJWTValidity
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/JWT/Limit-KrJWTValidity.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 61
Line coverage: 0%
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

Coverage history

Coverage history 0 25 50 75 100 08/26/2025 - 14:53:17 Line coverage: 0% (0/1) Total lines: 36 Tag: Kestrun/Kestrun@78d1e497d8ba989d121b57aa39aa3c6b22de743109/04/2025 - 18:11:31 Line coverage: 0% (0/1) Total lines: 37 Tag: Kestrun/Kestrun@de99e24698289f3f61ac7b73e96092732ae12b0511/19/2025 - 02:25:56 Line coverage: 0% (0/3) Total lines: 61 Tag: Kestrun/Kestrun@98ff905e5605a920343154665980a71211a03c6d

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/JWT/Limit-KrJWTValidity.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Sets the validity period for the JWT token.
 4    .DESCRIPTION
 5        This function sets the validity period for the JWT token, specifying how long the token will be valid.
 6        The period can be provided as a [TimeSpan] object (-Lifetime) or directly as -Hours, -Minutes, or -Seconds.
 7    .PARAMETER Builder
 8        The JWT token builder to modify.
 9    .PARAMETER Lifetime
 10        The duration for which the JWT token will be valid.
 11    .PARAMETER Hours
 12        The number of hours for which the JWT token will be valid.
 13    .PARAMETER Minutes
 14        The number of minutes for which the JWT token will be valid.
 15    .PARAMETER Seconds
 16        The number of seconds for which the JWT token will be valid.
 17    .OUTPUTS
 18        [Kestrun.Jwt.JwtTokenBuilder]
 19        The modified JWT token builder.
 20    .EXAMPLE
 21        $builder = New-KrJWTTokenBuilder | Limit-KrJWTValidity -Hours 1
 22        Creates a JWT token builder and sets its validity period to 1 hour.
 23    .EXAMPLE
 24        $builder = New-KrJWTTokenBuilder | Limit-KrJWTValidity -Lifetime (New-TimeSpan -Hours 2 -Minutes 30)
 25        Creates a JWT token builder and sets its validity period to 2 hours and 30 minutes.
 26    .NOTES
 27        This function is part of the Kestrun.Jwt module and is used to build JWT tokens.
 28        Maps to JwtTokenBuilder.ValidFor(TimeSpan).
 29    .LINK
 30        https://docs.microsoft.com/en-us/dotnet/api/system.identitymodel.tokens.jwt.jwtsecuritytoken
 31#>
 32function Limit-KrJWTValidity {
 33    [KestrunRuntimeApi('Everywhere')]
 34    [CmdletBinding(DefaultParameterSetName = 'TimeSpan')]
 35    [OutputType([Kestrun.Jwt.JwtTokenBuilder])]
 36    param(
 37        [Parameter(Mandatory, ValueFromPipeline)]
 38        [Kestrun.Jwt.JwtTokenBuilder] $Builder,
 39
 40        [Parameter(Mandatory, ParameterSetName = 'TimeSpan')]
 41        [TimeSpan] $Lifetime,
 42
 43        [Parameter(ParameterSetName = 'Discrete')]
 44        [ValidateRange(0, [double]::MaxValue)]
 45        [double] $Hours = 0,
 46
 47        [Parameter(ParameterSetName = 'Discrete')]
 48        [ValidateRange(0, [double]::MaxValue)]
 49        [double] $Minutes = 0,
 50
 51        [Parameter(ParameterSetName = 'Discrete')]
 52        [ValidateRange(0, [double]::MaxValue)]
 53        [double] $Seconds = 0
 54    )
 55    process {
 056        $ts = (($PSCmdlet.ParameterSetName -eq 'TimeSpan') ?
 057            $Lifetime : [TimeSpan]::FromSeconds(($Hours * 3600) + ($Minutes * 60) + $Seconds))
 58
 059        return $Builder.ValidFor($ts)
 60    }
 61}

Methods/Properties

Limit-KrJWTValidity()