github.com/hyperledger/aries-framework-go@v0.3.2/pkg/wallet/jwt.go (about)

     1  /*
     2  Copyright Avast Software. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package wallet
     8  
     9  import (
    10  	"github.com/hyperledger/aries-framework-go/pkg/doc/util/didsignjwt"
    11  )
    12  
    13  // SignJWT creates a JWT signed by the wallet's KMS using a key from an owned DID.
    14  //
    15  //	Args:
    16  //		- auth token for unlocking kms.
    17  //		- Headers to include in the created JWT.
    18  //		- Claims for the created JWT.
    19  //		- the ID of the key to use for signing, as a DID, either with a fragment identifier to specify a verification
    20  //		  method, or without, in which case the first Authentication or Assertion verification method is used.
    21  func (c *Wallet) SignJWT(authToken string, headers, claims map[string]interface{}, kid string) (string, error) {
    22  	session, err := sessionManager().getSession(authToken)
    23  	if err != nil {
    24  		return "", wrapSessionError(err)
    25  	}
    26  
    27  	return didsignjwt.SignJWT(headers, claims, kid,
    28  		didsignjwt.UseDefaultSigner(session.KeyManager, c.walletCrypto), c.vdr)
    29  }
    30  
    31  // VerifyJWT verifies a JWT signed by a DID;
    32  //
    33  // Args:
    34  //   - JWT to verify.
    35  func (c *Wallet) VerifyJWT(compactJWT string) error {
    36  	return didsignjwt.VerifyJWT(compactJWT, c.vdr)
    37  }