func New(config *Config) (*Operation, error) {
	store, err := getTxnStore(config.StoreProvider)
	if err != nil {
		return nil, fmt.Errorf("issuer store provider : %w", err)
	}
	svc := &Operation{
		tokenIssuer:      config.TokenIssuer,
		tokenResolver:    config.TokenResolver,
		documentLoader:   config.DocumentLoader,
		cmsURL:           config.CMSURL,
		vcsURL:           config.VCSURL,
		didAuthHTML:      config.DIDAuthHTML,
		receiveVCHTML:    config.ReceiveVCHTML,
		vcHTML:           config.VCHTML,
		didCommHTML:      config.DIDCommHTML,
		didCommVpHTML:    config.DIDCOMMVPHTML,
		httpClient:       &http.Client{Transport: &http.Transport{TLSClientConfig: config.TLSConfig}},
		requestTokens:    config.RequestTokens,
		issuerAdapterURL: config.IssuerAdapterURL,
		store:            store,
		homePage:         config.OIDCCallbackURL,
		didcommScopes:    map[string]struct{}{},
		assuranceScopes:  map[string]string{},
	}
	if config.didcommScopes != nil {
		svc.didcommScopes = config.didcommScopes
	}
	if config.assuranceScopes != nil {
		svc.assuranceScopes = config.assuranceScopes
	}
	if config.OIDCProviderURL != "" {
		svc.oidcClient, err = oidcclient.New(&oidcclient.Config{
			OIDCClientID:     config.OIDCClientID,
			OIDCClientSecret: config.OIDCClientSecret, OIDCCallbackURL: config.OIDCCallbackURL,
			OIDCProviderURL: config.OIDCProviderURL, TLSConfig: config.TLSConfig,
		})
		if err != nil {
			return nil, fmt.Errorf("failed to create oidc client : %w", err)
		}
	}
	svc.registerHandler()
	return svc, nil
}
New returns authorization instance
package operation
import (
	"bytes"
	"context"
	"crypto/tls"
	"encoding/json"
	"errors"
	"fmt"
	"html/template"
	"io/ioutil"
	"net/http"
	"net/url"
	"strings"
	"time"
	"github.com/google/uuid"
	"github.com/hyperledger/aries-framework-go/pkg/doc/util"
	"github.com/hyperledger/aries-framework-go/pkg/doc/verifiable"
	"github.com/hyperledger/aries-framework-go/spi/storage"
	"github.com/piprate/json-gold/ld"
	"github.com/trustbloc/edge-core/pkg/log"
	vcprofile "github.com/trustbloc/edge-service/pkg/doc/vc/profile"
	"github.com/trustbloc/edge-service/pkg/doc/vc/status/csl"
	edgesvcops "github.com/trustbloc/edge-service/pkg/restapi/issuer/operation"
	"golang.org/x/oauth2"
	"github.com/trustbloc/sandbox/pkg/internal/common/support"
	oidcclient "github.com/trustbloc/sandbox/pkg/restapi/internal/common/oidc"
	"github.com/trustbloc/sandbox/pkg/token"
)
const (
	login                  = "/login"
	settings               = "/settings"
	getCreditScore         = "/getCreditScore"
	callback               = "/callback"
	generate               = "/generate"
	revoke                 = "/revoke"
	didcommInit            = "/didcomm/init"
	didcommToken           = "/didcomm/token"
	didcommCallback        = "/didcomm/cb"
	didcommCredential      = "/didcomm/data"
	didcommAssuranceData   = "/didcomm/assurance"
	didcommUserEndpoint    = "/didcomm/uid"
	oauth2GetRequestPath   = "/oauth2/request"
	oauth2CallbackPath     = "/oauth2/callback"
	verifyDIDAuthPath      = "/verify/didauth"
	createCredentialPath   = "/credential"
	authPath               = "/auth"
	searchPath             = "/search"
	generateCredentialPath = createCredentialPath + "/generate"
	oidcRedirectPath       = "/oidc/redirect" + "/{id}"
	stateQueryParam = "state"
	credentialContext = "https://www.w3.org/2018/credentials/v1"
	vcsUpdateStatusURLFormat = "%s/%s" + "/credentials/status"
	vcsProfileCookie     = "vcsProfile"
	adapterProfileCookie = "adapterProfile"
	assuranceScopeCookie = "assuranceScope"
	callbackURLCookie    = "callbackURL"
	issueCredentialURLFormat = "%s/%s" + "/credentials/issue"
	trustBlocExampleContext = "https://trustbloc.github.io/context/vc/examples-ext-v1.jsonld"
	vcsIssuerRequestTokenName = "vcs_issuer"
	txnStoreName = "issuer_txn"
	scopeQueryParam = "scope"
)
var logger = log.New("sandbox-issuer-restapi")
type Handler interface {
	Path() string
	Method() string
	Handle() http.HandlerFunc
}
type oidcClient interface {
	CreateOIDCRequest(state, scope string) (string, error)
	HandleOIDCCallback(reqContext context.Context, code string) ([]byte, error)
}
type Operation struct {
	handlers         []Handler
	tokenIssuer      tokenIssuer
	tokenResolver    tokenResolver
	documentLoader   ld.DocumentLoader
	cmsURL           string
	vcsURL           string
	receiveVCHTML    string
	didAuthHTML      string
	vcHTML           string
	didCommHTML      string
	didCommVpHTML    string
	httpClient       *http.Client
	requestTokens    map[string]string
	issuerAdapterURL string
	store            storage.Store
	oidcClient       oidcClient
	homePage         string
	didcommScopes    map[string]struct{}
	assuranceScopes  map[string]string
}
type Config struct {
	TokenIssuer      tokenIssuer
	TokenResolver    tokenResolver
	DocumentLoader   ld.DocumentLoader
	CMSURL           string
	VCSURL           string
	ReceiveVCHTML    string
	DIDAuthHTML      string
	VCHTML           string
	DIDCommHTML      string
	DIDCOMMVPHTML    string
	TLSConfig        *tls.Config
	RequestTokens    map[string]string
	IssuerAdapterURL string
	StoreProvider    storage.Provider
	OIDCProviderURL  string
	OIDCClientID     string
	OIDCClientSecret string
	OIDCCallbackURL  string
	didcommScopes    map[string]struct{}
	assuranceScopes  map[string]string
}
type vc struct {
	Msg  string `json:"msg"`
	Data string `json:"data"`
}
type tokenIssuer interface {
	AuthCodeURL(w http.ResponseWriter) string
	Exchange(r *http.Request) (*oauth2.Token, error)
	Client(t *oauth2.Token) *http.Client
}
type tokenResolver interface {
	Resolve(token string) (*token.Introspection, error)
}
type createOIDCRequestResponse struct {
	Request string `json:"request"`
}