didsignjwt

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveSigningVM

func ResolveSigningVM(kid string, didResolver didResolver) (*did.VerificationMethod, string, error)

ResolveSigningVM resolves a DID KeyID using the given did resolver, and returns either:

  • the Verification Method identified by the given key ID, or
  • the first Assertion Method in the DID doc, if the DID provided has no fragment component.

Returns:

  • a verification method suitable for signing.
  • the full DID#KID identifier of the returned verification method.

func SignJWT

func SignJWT(
	headers,
	claims map[string]interface{},
	kid string,
	signerProvider SignerGetter,
	didResolver didResolver,
) (string, error)

SignJWT signs a JWT using a key in the given KMS, identified by an owned DID.

Args:
	- Headers to include in the created JWT.
	- Claims for the created JWT.
	- The ID of the key to use for signing, as a DID, either with a fragment identifier to specify a verification
	  method, or without, in which case the first Authentication or Assertion verification method is used.
	- A SignerGetter that can provide a signer when given the key ID for the signing key.
	- A VDR that can resolve the provided DID.

func VerifyJWT

func VerifyJWT(compactJWT string,
	didResolver didResolver) error

VerifyJWT verifies a JWT that was signed with a DID.

Args:

  • JWT to verify.
  • A VDR that can resolve the JWT's signing DID.

Types

type Signer

type Signer interface {
	// Sign provides a signature for msg.
	Sign(msg []byte) ([]byte, error)
}

A Signer is capable of signing data.

type SignerGetter

type SignerGetter func(vm *did.VerificationMethod) (Signer, error)

SignerGetter creates a signer that signs with the private key corresponding to the given public key.

func UseDefaultSigner

func UseDefaultSigner(r keyReader, s cryptoSigner) SignerGetter

UseDefaultSigner provides SignJWT with a signer that uses the given KMS and Crypto instances.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL