Skip to content

Commit 0515631

Browse files
authored
Add jwsbb.HeaderParse (#1422)
1 parent 4953274 commit 0515631

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

Changes

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ v3 has many incompatibilities with v2. To see the full list of differences betwe
55
v2 and v3, please read the Changes-v3.md file (https://github.com/lestrrat-go/jwx/blob/develop/v3/Changes-v3.md)
66

77
v3.0.8 UNRELEASED
8-
* [jwe/jwebb] (EXPERIMENTAL) Add low-level functions for JWE operations
8+
* [jwe/jwebb] (EXPERIMENTAL) Add low-level functions for JWE operations.
99
* [jws/jwsbb] (EXPERIMENTAL/BREAKS COMPATIBILITY) Add io.Reader parameter
10-
so your choice of source of randomness can be passed. Defaults to crypto/rand.Reader
10+
so your choice of source of randomness can be passed. Defaults to crypto/rand.Reader.
11+
Function signatures around jwsbb.Sign() now accept an addition `rr io.Reader`,
12+
which can be nil for 99% of use cases.
13+
* [jws/jwsbb] Add HeaderParse([]byte), where it is expected that the header
14+
is already in its base64 decoded format.
1115

1216
v3.0.7 16 Jun 2025
1317
* [jws/jwsbb] (EXPERIMENTAL) Add low-level fast access to JWS headers in compact

jws/jwsbb/header.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ func HeaderParseCompact(buf []byte) Header {
4040
if err != nil {
4141
return &header{err: err}
4242
}
43+
return HeaderParse(decoded)
44+
}
45+
46+
// HeaderParse parses a JWS header from a byte slice containing the decoded JSON.
47+
// You will need to call HeaderGet* functions to extract the values from the header.
48+
//
49+
// Unlike HeaderParseCompact, this function does not perform any base64 decoding.
50+
// This function is experimental and may change or be removed in the future.
51+
func HeaderParse(decoded []byte) Header {
4352
var p fastjson.Parser
4453
v, err := p.ParseBytes(decoded)
4554
if err != nil {

0 commit comments

Comments
 (0)