< Summary - Kestrun — Combined Coverage

Information
Class: Public.JWT.Update-KrJWT
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/JWT/Update-KrJWT.ps1
Tag: Kestrun/Kestrun@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
0%
Covered lines: 0
Uncovered lines: 4
Coverable lines: 4
Total lines: 54
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 09/08/2025 - 20:34:03 Line coverage: 0% (0/4) Total lines: 54 Tag: Kestrun/Kestrun@3790ee5884494a7a2a829344a47743e0bf492e72

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/JWT/Update-KrJWT.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Updates an existing JWT token.
 4    .DESCRIPTION
 5        This function updates an existing JWT token by renewing it with a new lifetime.
 6        It can either take a token directly or extract it from the current HTTP context.
 7    .PARAMETER Builder
 8        The JWT token builder used to renew the token.
 9    .PARAMETER Lifetime
 10        The new duration for which the JWT token will be valid.
 11    .PARAMETER Token
 12        The existing JWT token to update.
 13    .PARAMETER FromContext
 14        Indicates whether to extract the token from the HTTP context.
 15    .OUTPUTS
 16        [string]
 17        The updated JWT token.
 18    .EXAMPLE
 19        Update-KrJWT -Builder $jwtBuilder -Token $existingToken -Lifetime (New-TimeSpan -Minutes 30)
 20        This updates the existing JWT token with a new lifetime of 30 minutes.
 21    .EXAMPLE
 22        Update-KrJWT -Builder $jwtBuilder -FromContext -Lifetime (New-TimeSpan -Minutes 30)
 23        This updates the existing JWT token extracted from the HTTP context with a new lifetime of 30 minutes.
 24    .NOTES
 25        This function is part of the Kestrun.Jwt module and is used to manage JWT tokens.
 26        Maps to JwtBuilderResult.Renew
 27    .LINK
 28        https://docs.microsoft.com/en-us/dotnet/api/system.identitymodel.tokens.jwt.jwtsecuritytoken
 29#>
 30function Update-KrJWT {
 31    [KestrunRuntimeApi('Everywhere')]
 32    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 33    [CmdletBinding(defaultParameterSetName = 'Token')]
 34    [OutputType([string])]
 35    param(
 36        [Parameter(Mandatory = $true, ValueFromPipeline)]
 37        [Kestrun.Jwt.JwtTokenBuilder] $Builder,
 38        [Parameter(Mandatory = $true, ParameterSetName = 'Token')]
 39        [string]$Token,
 40        [Parameter(Mandatory = $true, ParameterSetName = 'Context')]
 41        [switch] $FromContext,
 42        [Parameter()]
 43        [TimeSpan] $Lifetime
 44    )
 45    process {
 046        if ($PSCmdlet.ParameterSetName -eq 'Token') {
 047            return $Builder.RenewJwt($Token, $Lifetime)
 48        }
 049        if ($FromContext.IsPresent -and $null -ne $Context.Request) {
 050            return $Builder.RenewJwt($Context, $Lifetime)
 51        }
 52    }
 53}
 54

Methods/Properties

Update-KrJWT()