func NewJWSSignature(requestBody string, ctx ContextInterface, alg jwt.SigningMethod) (string, error) {
	minifiedBody, err := minifiyJSONBody(requestBody)
	if err != nil {
		return "", fmt.Errorf("NewJWSSignature: minifyBody failed: %w", err)
	}

	cert, err := SigningCertFromContext(ctx)
	if err != nil {
		return "", fmt.Errorf("NewJWSSignature: unable to sign certificate from context: %w", err)
	}

	tppSignatureKID, err := ctx.GetString("tpp_signature_kid")
	if err != nil {
		return "", fmt.Errorf("missing configuration for key 'tpp_signature_kid': %w", err)
	}

	tppSignatureTAN, err := ctx.GetString("tpp_signature_tan")
	if err != nil {
		return "", fmt.Errorf("failed to populate TPP signature Trust Anchor: '%w'", err)
	}

	tppSignatureIssuer, err := ctx.GetString("tpp_signature_issuer")
	if err != nil {
		return "", fmt.Errorf("failed to populate TPP signature Issuer: '%w'", err)
	}

	version, _ := ctx.GetString("api-version")
	if version == "v3.0" {
		tppSignatureIssuer, err = legacyIssuerFromCert(cert)
	}

	logrus.WithFields(logrus.Fields{
		"kid":    tppSignatureKID,
		"issuer": tppSignatureIssuer,
		"alg":    alg.Alg(),
		"claims": minifiedBody,
		"tan":    tppSignatureTAN,
	}).Trace("jws signature creation")

	b64encoding, err := GetB64Encoding(ctx)
	if err != nil {
		return "", fmt.Errorf("NewJWSSignature: cannot GetB64Encoding: %w", err)
	}

	return buildSignature(b64encoding, tppSignatureKID, tppSignatureIssuer, tppSignatureTAN, minifiedBody, alg, cert.PrivateKey())
}
// NewJWSSignature creates a signature to be used with TPP API calls
NewJWSSignature creates a signature to be used with TPP API calls
// NewJWSSignature creates a signature to be used with TPP API calls
func NewJWSSignature(requestBody string, ctx ContextInterface, alg jwt.SigningMethod) (string, error) {
	minifiedBody, err := minifiyJSONBody(requestBody)
	if err != nil {
		return "", fmt.Errorf("NewJWSSignature: minifyBody failed: %w", err)
	}
	cert, err := SigningCertFromContext(ctx)
	if err != nil {
		return "", fmt.Errorf("NewJWSSignature: unable to sign certificate from context: %w", err)
	}
	tppSignatureKID, err := ctx.GetString("tpp_signature_kid")
	if err != nil {
		return "", fmt.Errorf("missing configuration for key 'tpp_signature_kid': %w", err)
	}
	tppSignatureTAN, err := ctx.GetString("tpp_signature_tan")
	if err != nil {
		return "", fmt.Errorf("failed to populate TPP signature Trust Anchor: '%w'", err)
	}
	tppSignatureIssuer, err := ctx.GetString("tpp_signature_issuer")
	if err != nil {
		return "", fmt.Errorf("failed to populate TPP signature Issuer: '%w'", err)
	}
	version, _ := ctx.GetString("api-version")
	if version == "v3.0" {
		tppSignatureIssuer, err = legacyIssuerFromCert(cert)
	}
	logrus.WithFields(logrus.Fields{
		"kid":    tppSignatureKID,
		"issuer": tppSignatureIssuer,
		"alg":    alg.Alg(),
		"claims": minifiedBody,
		"tan":    tppSignatureTAN,
	}).Trace("jws signature creation")
	b64encoding, err := GetB64Encoding(ctx)
	if err != nil {
		return "", fmt.Errorf("NewJWSSignature: cannot GetB64Encoding: %w", err)
	}
	return buildSignature(b64encoding, tppSignatureKID, tppSignatureIssuer, tppSignatureTAN, minifiedBody, alg, cert.PrivateKey())
}
func NewJWSSignature ( requestBody string , ctx ContextInterface , alg jwt . SigningMethod ) ( string , error ) { minifiedBody , err := minifiyJSONBody ( requestBody ) if err != nil { return " " , fmt . Errorf ( " " , err ) } cert , err := SigningCertFromContext ( ctx ) if err != nil { return " " , fmt . Errorf ( " " , err ) } tppSignatureKID , err := ctx . GetString ( " " ) if err != nil { return " " , fmt . Errorf ( " " , err ) } tppSignatureTAN , err := ctx . GetString ( " " ) if err != nil { return " " , fmt . Errorf ( " " , err ) } tppSignatureIssuer , err := ctx . GetString ( " " ) if err != nil { return " " , fmt . Errorf ( " " , err ) } version , _ := ctx . GetString ( " " ) if version == " " { tppSignatureIssuer , err = legacyIssuerFromCert ( cert ) } logrus . WithFields ( logrus . Fields { " " : tppSignatureKID , " " : tppSignatureIssuer , " " : alg . Alg ( ) , " " : minifiedBody , " " : tppSignatureTAN , } ) . Trace ( " " ) b64encoding , err := GetB64Encoding ( ctx ) if err != nil { return " " , fmt . Errorf ( " " , err ) } return buildSignature ( b64encoding , tppSignatureKID , tppSignatureIssuer , tppSignatureTAN , minifiedBody , alg , cert . PrivateKey ( ) ) }
NewJWSSignature creates a signature to be used with TPP API calls
NewJWSSignature creates a signature to be used with TPP API calls