diff --git a/api/spec/openapi.gen.go b/api/spec/openapi.gen.go index 9a2f62010..067a44ffd 100644 --- a/api/spec/openapi.gen.go +++ b/api/spec/openapi.gen.go @@ -120,49 +120,49 @@ var swaggerSpec = []string{ "jMp3tmOKGZd3agzVjM2Rdy86CZyYiavfRJK6TDce+3IFeSRz8T9hmRJTicTYBcMk6ClSCZIj7ZJAmnk+", "EzW0M+5stf9ByqjRO12LZeumGOQFnR03cal+/jl4zgGiTlBbQJsHAvL0XGqt3U5kndnVpg8kuUmTwNAG", "JTMEbbNRQjK+3Z0OMYDioTf6UKDkLraif84dn8WB0MkxR/I+mN+GFkzEF9kLDQgD9GAjnUQyTKz24uJC", - "KhgR6LYLQhicdse0MBwcNoYcxiN+gAhMMKk4+ORCTO/c/02IaagXQkcgiRHqmk33nVTY/MDWB6hsrekM", - "4P1zNgG0W+lx8ZNw2q65kDBTtBKZ7+rmieXz/0NsEwAIysYKEuPIMeBcrk4ho3n2hS4TgpXnZ/FLBClZ", - "6zRq1fQtkBQc5zYXXRjQJFKVJ91zIa9StmsKRZ8Ltg5uL7+mT/f02LcZ3Ur1uzpD8fpTO74fUmWARh22", - "oQJWj3P64E2Sp8iJPstgzUsRraW1pEr+3HQ3urvBP+qmkweifTu3lR/P6DzdJqfsbGOKnBnc3MM93Fqb", - "5tCdcJwxdj6tAw+gOBJd3ssnGwa5U/7YYoyPzxc96u4l6v01KYo9KDZ7YArgNgSw10RqODKvOMl0RRkN", - "Q5zw7VDgA+uS+hl8DonCeswmO2QyI+KytqE9pbWfnpxHArH+6qSnZJIDJ54n+WQqdswg2KZXMLecLiAO", - "4R7uQXg7usbPi9KiOZpnTvMY8roMVpcAnEEIVIO0doGIB2zSVSw5Tmpe/wntA+Y8Qi5oFeWEt3LeK/3K", - "uWltOVyokGjyy0aTyk7N83bTM0d4oWQnqasAJxfEcnLTRNA+cFXmbTnAvMZNDV+9RlPd0U42DqTm/fGW", - "expNUGwzVGiXlVJg9/DCZAAKEor4qSycddAWCi42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qfb", + "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", + "tZh++lf94937u/8OAAD//8p9RCN1xwAA", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/component/wallet-cli/cmd/oidc4vci_cmd.go b/component/wallet-cli/cmd/oidc4vci_cmd.go index cc893c793..9e0e77c07 100644 --- a/component/wallet-cli/cmd/oidc4vci_cmd.go +++ b/component/wallet-cli/cmd/oidc4vci_cmd.go @@ -14,11 +14,9 @@ import ( "log/slog" "net/http" "net/http/cookiejar" - "strings" "github.com/henvic/httpretty" "github.com/piprate/json-gold/ld" - "github.com/samber/lo" "github.com/spf13/cobra" vdrapi "github.com/trustbloc/did-go/vdr/api" storageapi "github.com/trustbloc/kms-go/spi/storage" @@ -294,7 +292,6 @@ func NewOIDC4VCICommand() *cobra.Command { slog.Info("credential added to wallet", "credential_id", vc.Contents().ID, - "credential_type", strings.Join(lo.Filter(vc.Contents().Types, func(item string, i int) bool { return !strings.EqualFold(item, "VerifiableCredential") }), ","), "issuer_id", vc.Contents().Issuer.ID, ) diff --git a/docs/v1/openapi.yaml b/docs/v1/openapi.yaml index a30a13704..b4fa11a26 100644 --- a/docs/v1/openapi.yaml +++ b/docs/v1/openapi.yaml @@ -81,7 +81,7 @@ paths: description: Returns openid-config. tags: - issuer - '/issuer/profiles/{profileID}/{profileVersion}/issued-credentials': + '/issuer/profiles/{profileID}/issued-credentials': parameters: - schema: type: string @@ -89,12 +89,6 @@ paths: in: path required: true description: Profile ID - - schema: - type: string - name: profileVersion - in: path - required: true - description: Profile Version get: summary: Request Credential Issuance history. responses: diff --git a/pkg/restapi/v1/issuer/controller.go b/pkg/restapi/v1/issuer/controller.go index c52f1cc82..2476ce07c 100644 --- a/pkg/restapi/v1/issuer/controller.go +++ b/pkg/restapi/v1/issuer/controller.go @@ -80,7 +80,6 @@ type credentialIssuanceHistoryStore interface { GetIssuedCredentialsMetadata( ctx context.Context, profileID string, - profileVersion string, ) ([]*credentialstatus.CredentialMetadata, error) } @@ -690,10 +689,10 @@ func (c *Controller) PrepareCredential(e echo.Context) error { } // CredentialIssuanceHistory returns Credential Issuance history. -// GET /issuer/profiles/{profileID}/{profileVersion}/issued-credentials. -func (c *Controller) CredentialIssuanceHistory(e echo.Context, profileID string, profileVersion string) error { +// GET /issuer/profiles/{profileID}/issued-credentials. +func (c *Controller) CredentialIssuanceHistory(e echo.Context, profileID string) error { credentialMetadata, err := c.credentialIssuanceHistoryStore. - GetIssuedCredentialsMetadata(e.Request().Context(), profileID, profileVersion) + GetIssuedCredentialsMetadata(e.Request().Context(), profileID) if err != nil { return err } diff --git a/pkg/restapi/v1/issuer/controller_test.go b/pkg/restapi/v1/issuer/controller_test.go index d96e3cfcc..e8c8e736b 100644 --- a/pkg/restapi/v1/issuer/controller_test.go +++ b/pkg/restapi/v1/issuer/controller_test.go @@ -1634,7 +1634,7 @@ func TestCredentialIssuanceHistory(t *testing.T) { } credentialIssuanceStore.EXPECT(). - GetIssuedCredentialsMetadata(gomock.Any(), profileID, profileVersion). + GetIssuedCredentialsMetadata(gomock.Any(), profileID). Times(1). Return([]*credentialstatus.CredentialMetadata{credentialMetadata}, nil) @@ -1646,7 +1646,7 @@ func TestCredentialIssuanceHistory(t *testing.T) { echoCtx := echoContext(withRecorder(recorder)) - err := c.CredentialIssuanceHistory(echoCtx, profileID, profileVersion) + err := c.CredentialIssuanceHistory(echoCtx, profileID) assert.NoError(t, err) var gotResponse []CredentialIssuanceHistoryData @@ -1669,7 +1669,7 @@ func TestCredentialIssuanceHistory(t *testing.T) { t.Run("credentialIssuanceHistoryStore error", func(t *testing.T) { credentialIssuanceStore.EXPECT(). - GetIssuedCredentialsMetadata(gomock.Any(), profileID, profileVersion). + GetIssuedCredentialsMetadata(gomock.Any(), profileID). Times(1). Return(nil, errors.New("some error")) @@ -1681,7 +1681,7 @@ func TestCredentialIssuanceHistory(t *testing.T) { echoCtx := echoContext(withRecorder(recorder)) - err := c.CredentialIssuanceHistory(echoCtx, profileID, profileVersion) + err := c.CredentialIssuanceHistory(echoCtx, profileID) assert.Error(t, err) }) } diff --git a/pkg/restapi/v1/issuer/openapi.gen.go b/pkg/restapi/v1/issuer/openapi.gen.go index 34e47a14a..bea41e030 100644 --- a/pkg/restapi/v1/issuer/openapi.gen.go +++ b/pkg/restapi/v1/issuer/openapi.gen.go @@ -501,6 +501,9 @@ type ClientInterface interface { ValidatePreAuthorizedCodeRequest(ctx context.Context, body ValidatePreAuthorizedCodeRequestJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // CredentialIssuanceHistory request + CredentialIssuanceHistory(ctx context.Context, profileID string, reqEditors ...RequestEditorFn) (*http.Response, error) + // PostIssueCredentials request with any body PostIssueCredentialsWithBody(ctx context.Context, profileID string, profileVersion string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -511,9 +514,6 @@ type ClientInterface interface { InitiateCredentialIssuance(ctx context.Context, profileID string, profileVersion string, body InitiateCredentialIssuanceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // CredentialIssuanceHistory request - CredentialIssuanceHistory(ctx context.Context, profileID string, profileVersion string, reqEditors ...RequestEditorFn) (*http.Response, error) - // OpenidCredentialIssuerConfig request OpenidCredentialIssuerConfig(ctx context.Context, profileID string, profileVersion string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -701,8 +701,8 @@ func (c *Client) ValidatePreAuthorizedCodeRequest(ctx context.Context, body Vali return c.Client.Do(req) } -func (c *Client) PostIssueCredentialsWithBody(ctx context.Context, profileID string, profileVersion string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostIssueCredentialsRequestWithBody(c.Server, profileID, profileVersion, contentType, body) +func (c *Client) CredentialIssuanceHistory(ctx context.Context, profileID string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCredentialIssuanceHistoryRequest(c.Server, profileID) if err != nil { return nil, err } @@ -713,8 +713,8 @@ func (c *Client) PostIssueCredentialsWithBody(ctx context.Context, profileID str return c.Client.Do(req) } -func (c *Client) PostIssueCredentials(ctx context.Context, profileID string, profileVersion string, body PostIssueCredentialsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewPostIssueCredentialsRequest(c.Server, profileID, profileVersion, body) +func (c *Client) PostIssueCredentialsWithBody(ctx context.Context, profileID string, profileVersion string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostIssueCredentialsRequestWithBody(c.Server, profileID, profileVersion, contentType, body) if err != nil { return nil, err } @@ -725,8 +725,8 @@ func (c *Client) PostIssueCredentials(ctx context.Context, profileID string, pro return c.Client.Do(req) } -func (c *Client) InitiateCredentialIssuanceWithBody(ctx context.Context, profileID string, profileVersion string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewInitiateCredentialIssuanceRequestWithBody(c.Server, profileID, profileVersion, contentType, body) +func (c *Client) PostIssueCredentials(ctx context.Context, profileID string, profileVersion string, body PostIssueCredentialsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostIssueCredentialsRequest(c.Server, profileID, profileVersion, body) if err != nil { return nil, err } @@ -737,8 +737,8 @@ func (c *Client) InitiateCredentialIssuanceWithBody(ctx context.Context, profile return c.Client.Do(req) } -func (c *Client) InitiateCredentialIssuance(ctx context.Context, profileID string, profileVersion string, body InitiateCredentialIssuanceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewInitiateCredentialIssuanceRequest(c.Server, profileID, profileVersion, body) +func (c *Client) InitiateCredentialIssuanceWithBody(ctx context.Context, profileID string, profileVersion string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewInitiateCredentialIssuanceRequestWithBody(c.Server, profileID, profileVersion, contentType, body) if err != nil { return nil, err } @@ -749,8 +749,8 @@ func (c *Client) InitiateCredentialIssuance(ctx context.Context, profileID strin return c.Client.Do(req) } -func (c *Client) CredentialIssuanceHistory(ctx context.Context, profileID string, profileVersion string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCredentialIssuanceHistoryRequest(c.Server, profileID, profileVersion) +func (c *Client) InitiateCredentialIssuance(ctx context.Context, profileID string, profileVersion string, body InitiateCredentialIssuanceJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewInitiateCredentialIssuanceRequest(c.Server, profileID, profileVersion, body) if err != nil { return nil, err } @@ -1106,19 +1106,8 @@ func NewValidatePreAuthorizedCodeRequestRequestWithBody(server string, contentTy return req, nil } -// NewPostIssueCredentialsRequest calls the generic PostIssueCredentials builder with application/json body -func NewPostIssueCredentialsRequest(server string, profileID string, profileVersion string, body PostIssueCredentialsJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewPostIssueCredentialsRequestWithBody(server, profileID, profileVersion, "application/json", bodyReader) -} - -// NewPostIssueCredentialsRequestWithBody generates requests for PostIssueCredentials with any type of body -func NewPostIssueCredentialsRequestWithBody(server string, profileID string, profileVersion string, contentType string, body io.Reader) (*http.Request, error) { +// NewCredentialIssuanceHistoryRequest generates requests for CredentialIssuanceHistory +func NewCredentialIssuanceHistoryRequest(server string, profileID string) (*http.Request, error) { var err error var pathParam0 string @@ -1128,19 +1117,12 @@ func NewPostIssueCredentialsRequestWithBody(server string, profileID string, pro return nil, err } - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "profileVersion", runtime.ParamLocationPath, profileVersion) - if err != nil { - return nil, err - } - serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/issuer/profiles/%s/%s/credentials/issue", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/issuer/profiles/%s/issued-credentials", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -1150,29 +1132,27 @@ func NewPostIssueCredentialsRequestWithBody(server string, profileID string, pro return nil, err } - req, err := http.NewRequest("POST", queryURL.String(), body) + req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } - req.Header.Add("Content-Type", contentType) - return req, nil } -// NewInitiateCredentialIssuanceRequest calls the generic InitiateCredentialIssuance builder with application/json body -func NewInitiateCredentialIssuanceRequest(server string, profileID string, profileVersion string, body InitiateCredentialIssuanceJSONRequestBody) (*http.Request, error) { +// NewPostIssueCredentialsRequest calls the generic PostIssueCredentials builder with application/json body +func NewPostIssueCredentialsRequest(server string, profileID string, profileVersion string, body PostIssueCredentialsJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewInitiateCredentialIssuanceRequestWithBody(server, profileID, profileVersion, "application/json", bodyReader) + return NewPostIssueCredentialsRequestWithBody(server, profileID, profileVersion, "application/json", bodyReader) } -// NewInitiateCredentialIssuanceRequestWithBody generates requests for InitiateCredentialIssuance with any type of body -func NewInitiateCredentialIssuanceRequestWithBody(server string, profileID string, profileVersion string, contentType string, body io.Reader) (*http.Request, error) { +// NewPostIssueCredentialsRequestWithBody generates requests for PostIssueCredentials with any type of body +func NewPostIssueCredentialsRequestWithBody(server string, profileID string, profileVersion string, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -1194,7 +1174,7 @@ func NewInitiateCredentialIssuanceRequestWithBody(server string, profileID strin return nil, err } - operationPath := fmt.Sprintf("/issuer/profiles/%s/%s/interactions/initiate-oidc", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/issuer/profiles/%s/%s/credentials/issue", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -1214,8 +1194,19 @@ func NewInitiateCredentialIssuanceRequestWithBody(server string, profileID strin return req, nil } -// NewCredentialIssuanceHistoryRequest generates requests for CredentialIssuanceHistory -func NewCredentialIssuanceHistoryRequest(server string, profileID string, profileVersion string) (*http.Request, error) { +// NewInitiateCredentialIssuanceRequest calls the generic InitiateCredentialIssuance builder with application/json body +func NewInitiateCredentialIssuanceRequest(server string, profileID string, profileVersion string, body InitiateCredentialIssuanceJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewInitiateCredentialIssuanceRequestWithBody(server, profileID, profileVersion, "application/json", bodyReader) +} + +// NewInitiateCredentialIssuanceRequestWithBody generates requests for InitiateCredentialIssuance with any type of body +func NewInitiateCredentialIssuanceRequestWithBody(server string, profileID string, profileVersion string, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -1237,7 +1228,7 @@ func NewCredentialIssuanceHistoryRequest(server string, profileID string, profil return nil, err } - operationPath := fmt.Sprintf("/issuer/profiles/%s/%s/issued-credentials", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/issuer/profiles/%s/%s/interactions/initiate-oidc", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -1247,11 +1238,13 @@ func NewCredentialIssuanceHistoryRequest(server string, profileID string, profil return nil, err } - req, err := http.NewRequest("GET", queryURL.String(), nil) + req, err := http.NewRequest("POST", queryURL.String(), body) if err != nil { return nil, err } + req.Header.Add("Content-Type", contentType) + return req, nil } @@ -1418,6 +1411,9 @@ type ClientWithResponsesInterface interface { ValidatePreAuthorizedCodeRequestWithResponse(ctx context.Context, body ValidatePreAuthorizedCodeRequestJSONRequestBody, reqEditors ...RequestEditorFn) (*ValidatePreAuthorizedCodeRequestResponse, error) + // CredentialIssuanceHistory request + CredentialIssuanceHistoryWithResponse(ctx context.Context, profileID string, reqEditors ...RequestEditorFn) (*CredentialIssuanceHistoryResponse, error) + // PostIssueCredentials request with any body PostIssueCredentialsWithBodyWithResponse(ctx context.Context, profileID string, profileVersion string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostIssueCredentialsResponse, error) @@ -1428,9 +1424,6 @@ type ClientWithResponsesInterface interface { InitiateCredentialIssuanceWithResponse(ctx context.Context, profileID string, profileVersion string, body InitiateCredentialIssuanceJSONRequestBody, reqEditors ...RequestEditorFn) (*InitiateCredentialIssuanceResponse, error) - // CredentialIssuanceHistory request - CredentialIssuanceHistoryWithResponse(ctx context.Context, profileID string, profileVersion string, reqEditors ...RequestEditorFn) (*CredentialIssuanceHistoryResponse, error) - // OpenidCredentialIssuerConfig request OpenidCredentialIssuerConfigWithResponse(ctx context.Context, profileID string, profileVersion string, reqEditors ...RequestEditorFn) (*OpenidCredentialIssuerConfigResponse, error) @@ -1613,14 +1606,14 @@ func (r ValidatePreAuthorizedCodeRequestResponse) StatusCode() int { return 0 } -type PostIssueCredentialsResponse struct { +type CredentialIssuanceHistoryResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *map[string]interface{} + JSON200 *[]CredentialIssuanceHistoryData } // Status returns HTTPResponse.Status -func (r PostIssueCredentialsResponse) Status() string { +func (r CredentialIssuanceHistoryResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -1628,21 +1621,21 @@ func (r PostIssueCredentialsResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r PostIssueCredentialsResponse) StatusCode() int { +func (r CredentialIssuanceHistoryResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type InitiateCredentialIssuanceResponse struct { +type PostIssueCredentialsResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *InitiateOIDC4CIResponse + JSON200 *map[string]interface{} } // Status returns HTTPResponse.Status -func (r InitiateCredentialIssuanceResponse) Status() string { +func (r PostIssueCredentialsResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -1650,21 +1643,21 @@ func (r InitiateCredentialIssuanceResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r InitiateCredentialIssuanceResponse) StatusCode() int { +func (r PostIssueCredentialsResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type CredentialIssuanceHistoryResponse struct { +type InitiateCredentialIssuanceResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *[]CredentialIssuanceHistoryData + JSON200 *InitiateOIDC4CIResponse } // Status returns HTTPResponse.Status -func (r CredentialIssuanceHistoryResponse) Status() string { +func (r InitiateCredentialIssuanceResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -1672,7 +1665,7 @@ func (r CredentialIssuanceHistoryResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r CredentialIssuanceHistoryResponse) StatusCode() int { +func (r InitiateCredentialIssuanceResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } @@ -1851,6 +1844,15 @@ func (c *ClientWithResponses) ValidatePreAuthorizedCodeRequestWithResponse(ctx c return ParseValidatePreAuthorizedCodeRequestResponse(rsp) } +// CredentialIssuanceHistoryWithResponse request returning *CredentialIssuanceHistoryResponse +func (c *ClientWithResponses) CredentialIssuanceHistoryWithResponse(ctx context.Context, profileID string, reqEditors ...RequestEditorFn) (*CredentialIssuanceHistoryResponse, error) { + rsp, err := c.CredentialIssuanceHistory(ctx, profileID, reqEditors...) + if err != nil { + return nil, err + } + return ParseCredentialIssuanceHistoryResponse(rsp) +} + // PostIssueCredentialsWithBodyWithResponse request with arbitrary body returning *PostIssueCredentialsResponse func (c *ClientWithResponses) PostIssueCredentialsWithBodyWithResponse(ctx context.Context, profileID string, profileVersion string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostIssueCredentialsResponse, error) { rsp, err := c.PostIssueCredentialsWithBody(ctx, profileID, profileVersion, contentType, body, reqEditors...) @@ -1885,15 +1887,6 @@ func (c *ClientWithResponses) InitiateCredentialIssuanceWithResponse(ctx context return ParseInitiateCredentialIssuanceResponse(rsp) } -// CredentialIssuanceHistoryWithResponse request returning *CredentialIssuanceHistoryResponse -func (c *ClientWithResponses) CredentialIssuanceHistoryWithResponse(ctx context.Context, profileID string, profileVersion string, reqEditors ...RequestEditorFn) (*CredentialIssuanceHistoryResponse, error) { - rsp, err := c.CredentialIssuanceHistory(ctx, profileID, profileVersion, reqEditors...) - if err != nil { - return nil, err - } - return ParseCredentialIssuanceHistoryResponse(rsp) -} - // OpenidCredentialIssuerConfigWithResponse request returning *OpenidCredentialIssuerConfigResponse func (c *ClientWithResponses) OpenidCredentialIssuerConfigWithResponse(ctx context.Context, profileID string, profileVersion string, reqEditors ...RequestEditorFn) (*OpenidCredentialIssuerConfigResponse, error) { rsp, err := c.OpenidCredentialIssuerConfig(ctx, profileID, profileVersion, reqEditors...) @@ -2110,22 +2103,22 @@ func ParseValidatePreAuthorizedCodeRequestResponse(rsp *http.Response) (*Validat return response, nil } -// ParsePostIssueCredentialsResponse parses an HTTP response from a PostIssueCredentialsWithResponse call -func ParsePostIssueCredentialsResponse(rsp *http.Response) (*PostIssueCredentialsResponse, error) { +// ParseCredentialIssuanceHistoryResponse parses an HTTP response from a CredentialIssuanceHistoryWithResponse call +func ParseCredentialIssuanceHistoryResponse(rsp *http.Response) (*CredentialIssuanceHistoryResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &PostIssueCredentialsResponse{ + response := &CredentialIssuanceHistoryResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest map[string]interface{} + var dest []CredentialIssuanceHistoryData if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -2136,22 +2129,22 @@ func ParsePostIssueCredentialsResponse(rsp *http.Response) (*PostIssueCredential return response, nil } -// ParseInitiateCredentialIssuanceResponse parses an HTTP response from a InitiateCredentialIssuanceWithResponse call -func ParseInitiateCredentialIssuanceResponse(rsp *http.Response) (*InitiateCredentialIssuanceResponse, error) { +// ParsePostIssueCredentialsResponse parses an HTTP response from a PostIssueCredentialsWithResponse call +func ParsePostIssueCredentialsResponse(rsp *http.Response) (*PostIssueCredentialsResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &InitiateCredentialIssuanceResponse{ + response := &PostIssueCredentialsResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest InitiateOIDC4CIResponse + var dest map[string]interface{} if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -2162,22 +2155,22 @@ func ParseInitiateCredentialIssuanceResponse(rsp *http.Response) (*InitiateCrede return response, nil } -// ParseCredentialIssuanceHistoryResponse parses an HTTP response from a CredentialIssuanceHistoryWithResponse call -func ParseCredentialIssuanceHistoryResponse(rsp *http.Response) (*CredentialIssuanceHistoryResponse, error) { +// ParseInitiateCredentialIssuanceResponse parses an HTTP response from a InitiateCredentialIssuanceWithResponse call +func ParseInitiateCredentialIssuanceResponse(rsp *http.Response) (*InitiateCredentialIssuanceResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CredentialIssuanceHistoryResponse{ + response := &InitiateCredentialIssuanceResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []CredentialIssuanceHistoryData + var dest InitiateOIDC4CIResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -2266,15 +2259,15 @@ type ServerInterface interface { // Validates pre-authorized code and user pin // (POST /issuer/interactions/validate-pre-authorized-code) ValidatePreAuthorizedCodeRequest(ctx echo.Context) error + // Request Credential Issuance history. + // (GET /issuer/profiles/{profileID}/issued-credentials) + CredentialIssuanceHistory(ctx echo.Context, profileID string) error // Issue credential // (POST /issuer/profiles/{profileID}/{profileVersion}/credentials/issue) PostIssueCredentials(ctx echo.Context, profileID string, profileVersion string) error // Initiate OIDC Credential Issuance // (POST /issuer/profiles/{profileID}/{profileVersion}/interactions/initiate-oidc) InitiateCredentialIssuance(ctx echo.Context, profileID string, profileVersion string) error - // Request Credential Issuance history. - // (GET /issuer/profiles/{profileID}/{profileVersion}/issued-credentials) - CredentialIssuanceHistory(ctx echo.Context, profileID string, profileVersion string) error // Request VCS IDP OIDC Configuration. // (GET /issuer/{profileID}/{profileVersion}/.well-known/openid-credential-issuer) OpenidCredentialIssuerConfig(ctx echo.Context, profileID string, profileVersion string) error @@ -2375,8 +2368,8 @@ func (w *ServerInterfaceWrapper) ValidatePreAuthorizedCodeRequest(ctx echo.Conte return err } -// PostIssueCredentials converts echo context to params. -func (w *ServerInterfaceWrapper) PostIssueCredentials(ctx echo.Context) error { +// CredentialIssuanceHistory converts echo context to params. +func (w *ServerInterfaceWrapper) CredentialIssuanceHistory(ctx echo.Context) error { var err error // ------------- Path parameter "profileID" ------------- var profileID string @@ -2386,21 +2379,13 @@ func (w *ServerInterfaceWrapper) PostIssueCredentials(ctx echo.Context) error { return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter profileID: %s", err)) } - // ------------- Path parameter "profileVersion" ------------- - var profileVersion string - - err = runtime.BindStyledParameterWithLocation("simple", false, "profileVersion", runtime.ParamLocationPath, ctx.Param("profileVersion"), &profileVersion) - if err != nil { - return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter profileVersion: %s", err)) - } - // Invoke the callback with all the unmarshalled arguments - err = w.Handler.PostIssueCredentials(ctx, profileID, profileVersion) + err = w.Handler.CredentialIssuanceHistory(ctx, profileID) return err } -// InitiateCredentialIssuance converts echo context to params. -func (w *ServerInterfaceWrapper) InitiateCredentialIssuance(ctx echo.Context) error { +// PostIssueCredentials converts echo context to params. +func (w *ServerInterfaceWrapper) PostIssueCredentials(ctx echo.Context) error { var err error // ------------- Path parameter "profileID" ------------- var profileID string @@ -2419,12 +2404,12 @@ func (w *ServerInterfaceWrapper) InitiateCredentialIssuance(ctx echo.Context) er } // Invoke the callback with all the unmarshalled arguments - err = w.Handler.InitiateCredentialIssuance(ctx, profileID, profileVersion) + err = w.Handler.PostIssueCredentials(ctx, profileID, profileVersion) return err } -// CredentialIssuanceHistory converts echo context to params. -func (w *ServerInterfaceWrapper) CredentialIssuanceHistory(ctx echo.Context) error { +// InitiateCredentialIssuance converts echo context to params. +func (w *ServerInterfaceWrapper) InitiateCredentialIssuance(ctx echo.Context) error { var err error // ------------- Path parameter "profileID" ------------- var profileID string @@ -2443,7 +2428,7 @@ func (w *ServerInterfaceWrapper) CredentialIssuanceHistory(ctx echo.Context) err } // Invoke the callback with all the unmarshalled arguments - err = w.Handler.CredentialIssuanceHistory(ctx, profileID, profileVersion) + err = w.Handler.InitiateCredentialIssuance(ctx, profileID, profileVersion) return err } @@ -2531,9 +2516,9 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL router.POST(baseURL+"/issuer/interactions/push-authorization-request", wrapper.PushAuthorizationDetails) router.POST(baseURL+"/issuer/interactions/store-authorization-code", wrapper.StoreAuthorizationCodeRequest) router.POST(baseURL+"/issuer/interactions/validate-pre-authorized-code", wrapper.ValidatePreAuthorizedCodeRequest) + router.GET(baseURL+"/issuer/profiles/:profileID/issued-credentials", wrapper.CredentialIssuanceHistory) router.POST(baseURL+"/issuer/profiles/:profileID/:profileVersion/credentials/issue", wrapper.PostIssueCredentials) router.POST(baseURL+"/issuer/profiles/:profileID/:profileVersion/interactions/initiate-oidc", wrapper.InitiateCredentialIssuance) - router.GET(baseURL+"/issuer/profiles/:profileID/:profileVersion/issued-credentials", wrapper.CredentialIssuanceHistory) router.GET(baseURL+"/issuer/:profileID/:profileVersion/.well-known/openid-credential-issuer", wrapper.OpenidCredentialIssuerConfig) router.GET(baseURL+"/oidc/idp/:profileID/:profileVersion/.well-known/openid-credential-issuer", wrapper.OpenidCredentialIssuerConfigV2) diff --git a/pkg/storage/mongodb/vcissuancehistorystore/vc_issuance_histsory_store.go b/pkg/storage/mongodb/vcissuancehistorystore/vc_issuance_histsory_store.go index 16dc697ad..db1d69a1a 100644 --- a/pkg/storage/mongodb/vcissuancehistorystore/vc_issuance_histsory_store.go +++ b/pkg/storage/mongodb/vcissuancehistorystore/vc_issuance_histsory_store.go @@ -13,6 +13,7 @@ import ( timeutil "github.com/trustbloc/did-go/doc/util/time" "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo/options" "github.com/trustbloc/vcs/pkg/service/credentialstatus" "github.com/trustbloc/vcs/pkg/storage/mongodb" @@ -73,12 +74,11 @@ func (p *Store) Put( func (p *Store) GetIssuedCredentialsMetadata( ctx context.Context, profileID string, - profileVersion string, ) ([]*credentialstatus.CredentialMetadata, error) { + opts := options.Find().SetSort(bson.D{{Key: "credentialMetadata.issuanceDate", Value: -1}}) cursor, err := p.mongoClient.Database().Collection(vcStatusStoreName).Find(ctx, bson.D{ {Key: profileIDMongoDBFieldName, Value: profileID}, - {Key: profileVersionMongoDBFieldName, Value: profileVersion}, - }) + }, opts) if err != nil { return nil, fmt.Errorf("find credential metadata list MongoDB: %w", err) } diff --git a/pkg/storage/mongodb/vcissuancehistorystore/vc_issuance_histsory_store_test.go b/pkg/storage/mongodb/vcissuancehistorystore/vc_issuance_histsory_store_test.go index 345ee330d..5abd2f8c4 100644 --- a/pkg/storage/mongodb/vcissuancehistorystore/vc_issuance_histsory_store_test.go +++ b/pkg/storage/mongodb/vcissuancehistorystore/vc_issuance_histsory_store_test.go @@ -72,25 +72,29 @@ func TestVCIssuanceHistoryStore(t *testing.T) { assert.NoError(t, err) // Get credential metadata by same profile version. - metadataFromDB, err := store.GetIssuedCredentialsMetadata(ctx, testProfile, testProfileVersion10) + metadataFromDB, err := store.GetIssuedCredentialsMetadata(ctx, testProfile) assert.NoError(t, err) assert.Equal(t, []*credentialstatus.CredentialMetadata{credentialMeta}, metadataFromDB) // Create another record. - err = store.Put(ctx, testProfile, testProfileVersion10, credentialMeta) + credentialMetaNew := &credentialstatus.CredentialMetadata{} + *credentialMetaNew = *credentialMeta + credentialMetaNew.CredentialID = "credentialIDNew" + credentialMetaNew.IssuanceDate = timeutil.NewTime(time.Now().Add(time.Hour).Round(time.Second).UTC()) + err = store.Put(ctx, testProfile, testProfileVersion10, credentialMetaNew) assert.NoError(t, err) // Get credential metadata by same profile version. - metadataFromDB, err = store.GetIssuedCredentialsMetadata(ctx, testProfile, testProfileVersion10) + metadataFromDB, err = store.GetIssuedCredentialsMetadata(ctx, testProfile) assert.NoError(t, err) - assert.Equal(t, []*credentialstatus.CredentialMetadata{credentialMeta, credentialMeta}, metadataFromDB) + assert.Equal(t, []*credentialstatus.CredentialMetadata{credentialMetaNew, credentialMeta}, metadataFromDB) }) t.Run("Find non-existing document", func(t *testing.T) { // Get credential metadata by different profile version. - metadataFromDB, err := store.GetIssuedCredentialsMetadata(ctx, testProfile+"unknown", testProfileVersion10) + metadataFromDB, err := store.GetIssuedCredentialsMetadata(ctx, testProfile+"unknown") assert.NoError(t, err) assert.Empty(t, metadataFromDB) }) @@ -123,7 +127,7 @@ func TestTimeouts(t *testing.T) { }) t.Run("Find GetIssuedCredentialsMetadata", func(t *testing.T) { - resp, err := store.GetIssuedCredentialsMetadata(ctxWithTimeout, testProfile, testProfileVersion10) + resp, err := store.GetIssuedCredentialsMetadata(ctxWithTimeout, testProfile) assert.Nil(t, resp) assert.ErrorContains(t, err, "context deadline exceeded") diff --git a/test/bdd/fixtures/krakend-config/settings/endpoint.json b/test/bdd/fixtures/krakend-config/settings/endpoint.json index d9a14da62..fb95fd11c 100644 --- a/test/bdd/fixtures/krakend-config/settings/endpoint.json +++ b/test/bdd/fixtures/krakend-config/settings/endpoint.json @@ -49,7 +49,7 @@ } }, { - "endpoint": "/issuer/profiles/{profileID}/{profileVersion}/issued-credentials", + "endpoint": "/issuer/profiles/{profileID}/issued-credentials", "method": "GET", "input_query_strings": [ "*" diff --git a/test/bdd/pkg/v1/oidc4vc/oidc4ci.go b/test/bdd/pkg/v1/oidc4vc/oidc4ci.go index 4c9a93f2a..27570422b 100644 --- a/test/bdd/pkg/v1/oidc4vc/oidc4ci.go +++ b/test/bdd/pkg/v1/oidc4vc/oidc4ci.go @@ -34,7 +34,7 @@ import ( const ( vcsAPIGateway = "https://api-gateway.trustbloc.local:5566" initiateCredentialIssuanceURLFormat = vcsAPIGateway + "/issuer/profiles/%s/%s/interactions/initiate-oidc" - issuedCredentialHistoryURL = vcsAPIGateway + "/issuer/profiles/%s/%s/issued-credentials" + issuedCredentialHistoryURL = vcsAPIGateway + "/issuer/profiles/%s/issued-credentials" vcsAuthorizeEndpoint = vcsAPIGateway + "/oidc/authorize" vcsTokenEndpoint = vcsAPIGateway + "/oidc/token" vcsIssuerURL = vcsAPIGateway + "/oidc/idp/%s/%s" @@ -535,7 +535,7 @@ func (s *Steps) checkIssuedCredentialHistory(credential *verifiable.Credential, return nil } - endpointURL := fmt.Sprintf(issuedCredentialHistoryURL, s.issuerProfile.ID, s.issuerProfile.Version) + endpointURL := fmt.Sprintf(issuedCredentialHistoryURL, s.issuerProfile.ID) token := s.bddContext.Args[getOrgAuthTokenKey(s.issuerProfile.ID+"/"+s.issuerProfile.Version)]