func DecodeDocumentToken(token JwtToken, publicKeyBase58 string, audience string) (*DidDocumentClaims, error) {
	decoded, err := jwt.ParseWithClaims(string(token), &didDocumentClaims{}, func(token *jwt.Token) (interface{}, error) {
		publicKey, err := getPublicKeyFromBase58(publicKeyBase58)
		if err != nil {
			return nil, err
		}
		return publicKey, nil
	})
	if err != nil {
		return nil, err
	}
	claims, ok := decoded.Claims.(*didDocumentClaims)
	if !ok || claims.Doc == nil {
		return nil, errors.New("failed to parse token")
	}
	if len(audience) != 0 && claims.Audience != audience {
		return nil, errors.New("audience does not match")
	}
	err = docValidate(claims.Doc)
	if err != nil {
		return nil, err
	}
	issuer, err := NewIssuerFromString(claims.Issuer)
	if err != nil {
		return nil, err
	}
	result := &DidDocumentClaims{
		Doc:      claims.Doc,
		Issuer:   issuer,
		Audience: claims.Audience,
	}
	return result, nil
}
DecodeDocumentToken Decode a document token
package register
import (
	"crypto/ecdsa"
	"errors"
	"fmt"
	"time"
	"github.com/Iotic-Labs/iotics-identity-go/pkg/proof"
	"github.com/golang-jwt/jwt"
)
type AuthenticationClaims struct {
	Issuer    *Issuer
	Subject   string
	Audience  string
	IssuedAt  int64
	ExpiresAt int64
}
type challengeClaims struct {
	Proof string `json:"proof"`
	jwt.StandardClaims
}
type ChallengeClaims struct {
	Signature string
	Issuer    *Issuer
	Audience  string
}
type DidDocumentClaims struct {
	Doc      *RegisterDocument
	Issuer   *Issuer
	Audience string
}
type didDocumentClaims struct {
	Doc *RegisterDocument `json:"doc"`
	jwt.StandardClaims
}
const DefaultAuthTokenStartOffset = 30
func docValidate(doc *RegisterDocument) error {
	errs := doc.Validate()
	if len(errs) != 0 {
		errStr := ""
		for _, e := range errs {
			if len(errStr) != 0 {
				errStr = errStr + ", "
			}
			errStr = fmt.Sprintf("%s%s", errStr, e)
		}
		return fmt.Errorf("document not valid: %s", errStr)
	}
	return nil
}
func DecodeDocumentTokenNoVerify(token JwtToken) (*DidDocumentClaims, error) {
	decoded, _, err := new(jwt.Parser).ParseUnverified(string(token), &didDocumentClaims{})
	if err != nil {
		return nil, errors.New("failed to parse token")
	}
	claims, ok := decoded.Claims.(*didDocumentClaims)
	if !ok || claims.Doc == nil {
		return nil, errors.New("failed to parse token")
	}
	err = docValidate(claims.Doc)
	if err != nil {
		return nil, err
	}
	issuer, err := NewIssuerFromString(claims.Issuer)
	if err != nil {
		return nil, err
	}
	result := &DidDocumentClaims{
		Doc:      claims.Doc,
		Issuer:   issuer,
		Audience: claims.Audience,
	}
	return result, nil
}