Documentation ¶
Overview ¶
Package go_sd_jwt provides a library for creating and validating SD-JWTs. The resulting SdJwt object exposes methods for retrieving the claims and disclosures as well as retrieving all disclosed claims in line with the specification.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SdJwt ¶
type SdJwt struct { Head map[string]any Body map[string]any Signature string KbJwt *kbjwt.KbJwt Disclosures []disclosure.Disclosure }
SdJwt this object represents a valid SD-JWT. Created using the FromToken function which performs the required validation. Helper methods are provided for retrieving the contents
func New ¶
New Creates a new SD-JWT from a JWT format token. The token is validated inline with the SD-JWT specification. If the token is valid, a new SdJwt object is returned. If a kb-jwt is included, the contents of this too will be validated.
func NewFromComponents ¶
func NewFromComponents(protected, payload, signature string, disclosures []string, kbJwt *string) (*SdJwt, error)
NewFromComponents Creates a new SD-JWT from the individual components optionally taking in a kbJwt. The token is validated inline with the SD-JWT specification. If the token is valid, a new SdJwt object is returned. If a kb-jwt is included, the contents of this too will be validated. This function is designed to cater for the much more free-form JSON serialization options on offer
func (*SdJwt) AddKeyBindingJwt ¶
AddKeyBindingJwt This method adds a keybinding jwt signed with the provided signer interface and hash If the provided hash does not match the hash algorithm specified in the SD Jwt (or isn't sha256 if no _sd_alg claim present), an error will be thrown The sd_hash value will be set based off of all disclosures present in the current sd jwt object
func (*SdJwt) GetDisclosedClaims ¶
GetDisclosedClaims returns the claims that were disclosed in the token or included as plaintext values. This function will error one of the following scenarios is encountered: 1. The SD-JWT contains a disclosure that does not match an included digest 2. The SD-JWT contains a malformed _sd claim 3. The SD-JWT contains an unsupported value for the _sd_alg claim 4. The SD-JWT has a disclosure that is malformed for the use (e.g. doesn't contain a claim name for a non-array digest)