Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

Commit

Permalink
fix: add DIDcommv1 flag
Browse files Browse the repository at this point in the history
Signed-off-by: Firas Qutishat <[email protected]>
  • Loading branch information
fqutishat committed Feb 16, 2022
1 parent da606ee commit 5d85243
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 104 deletions.
122 changes: 75 additions & 47 deletions cmd/issuer-adapter-vue/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/db/rp/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Tenant struct {
Scopes []string
RequiresBlindedRoute bool
SupportsWACI bool
IsDIDCommV2 bool
IsDIDCommV1 bool
LinkedWalletURL string
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/profile/issuer/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type ProfileData struct {
IssuerID string `json:"issuerID,omitempty"`
CMStyle cm.Styles `json:"styles,omitempty"`
PublicDID string `json:"publicDID,omitempty"`
IsDIDCommV2 bool `json:"isDIDCommV2,omitempty"`
IsDIDCommV1 bool `json:"isDIDCommV1,omitempty"`
}

// OIDCClientParams optional set of oidc client parameters that the issuer may set, for static client registration.
Expand Down
2 changes: 1 addition & 1 deletion pkg/restapi/issuer/operation/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type ProfileDataRequest struct {
OIDCClientParams *OIDCClientParams `json:"oidcParams,omitempty"`
CredentialScopes []string `json:"scopes,omitempty"`
LinkedWalletURL string `json:"linkedWallet,omitempty"`
IsDIDCommV2 bool `json:"isDIDCommV2,omitempty"`
IsDIDCommV1 bool `json:"isDIDCommV1,omitempty"`
// Issuer ID identifies who is the issuer of the credential manifests being issued.
IssuerID string `json:"issuerID,omitempty"`
// CMStyle represents an entity styles object as defined in credential manifest spec.
Expand Down
28 changes: 14 additions & 14 deletions pkg/restapi/issuer/operation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@ func (o *Operation) createIssuerProfileHandler( // nolint:funlen,gocyclo,cyclop

var err error

if data.IsDIDCommV2 {
newDidDoc, err = o.publicDIDCreator.CreateV2()
} else {
if data.IsDIDCommV1 {
newDidDoc, err = o.publicDIDCreator.Create()
} else {
newDidDoc, err = o.publicDIDCreator.CreateV2()
}

if err != nil {
Expand Down Expand Up @@ -1063,28 +1063,28 @@ func (o *Operation) createTxn( // nolint:funlen
) (string, error) {
var invBytes []byte

if profile.IsDIDCommV2 { // nolint:nestif
invitationV2, err := o.oobV2Client.CreateInvitation(
outofbandv2.WithFrom(profile.PublicDID),
outofbandv2.WithLabel("issuer"),
outofbandv2.WithGoal("", oobGoalCode),
)
if profile.IsDIDCommV1 { // nolint:nestif
invitationV1, err := o.oobClient.CreateInvitation(nil, outofband.WithLabel("issuer"),
outofband.WithGoal("", oobGoalCode))
if err != nil {
return "", fmt.Errorf("failed to create invitation : %w", err)
}

invBytes, err = json.Marshal(invitationV2)
invBytes, err = json.Marshal(invitationV1)
if err != nil {
return "", fmt.Errorf("marshal invitation: %w", err)
}
} else {
invitationV1, err := o.oobClient.CreateInvitation(nil, outofband.WithLabel("issuer"),
outofband.WithGoal("", oobGoalCode))
invitationV2, err := o.oobV2Client.CreateInvitation(
outofbandv2.WithFrom(profile.PublicDID),
outofbandv2.WithLabel("issuer"),
outofbandv2.WithGoal("", oobGoalCode),
)
if err != nil {
return "", fmt.Errorf("failed to create invitation : %w", err)
}

invBytes, err = json.Marshal(invitationV1)
invBytes, err = json.Marshal(invitationV2)
if err != nil {
return "", fmt.Errorf("marshal invitation: %w", err)
}
Expand Down Expand Up @@ -2302,6 +2302,6 @@ func mapProfileReqToData(data *ProfileDataRequest, didDoc *did.Doc) (*issuer.Pro
IssuerID: data.IssuerID,
CMStyle: data.CMStyle,
PublicDID: didDoc.ID,
IsDIDCommV2: data.IsDIDCommV2,
IsDIDCommV1: data.IsDIDCommV1,
}, nil
}
6 changes: 3 additions & 3 deletions pkg/restapi/issuer/operation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ func TestCreateProfile(t *testing.T) {
SecretExpiry: 0,
}

vReq.IsDIDCommV2 = true
vReq.IsDIDCommV1 = false

vReqBytes, err := json.Marshal(vReq)
require.NoError(t, err)
Expand All @@ -589,7 +589,7 @@ func TestCreateProfile(t *testing.T) {
require.Equal(t, vReq.SupportsAssuranceCredential, profileRes.SupportsAssuranceCredential)
require.Equal(t, vReq.IssuerID, profileRes.IssuerID)
require.Equal(t, vReq.SupportsWACI, profileRes.SupportsWACI)
require.Equal(t, vReq.IsDIDCommV2, profileRes.IsDIDCommV2)
require.Equal(t, vReq.IsDIDCommV1, profileRes.IsDIDCommV1)
})

t.Run("create profile - success with default oidc", func(t *testing.T) {
Expand Down Expand Up @@ -1311,7 +1311,7 @@ func TestValidateWalletResponse(t *testing.T) {

data := createProfileData(profileID)
data.URL = callbackURL
data.IsDIDCommV2 = true
data.IsDIDCommV1 = false

err = c.profileStore.SaveProfile(data)
require.NoError(t, err)
Expand Down
1 change: 1 addition & 0 deletions pkg/restapi/issuer/operation/support_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func createProfileData(profileID string) *issuer.ProfileData {
PresentationSigningKey: "did:example:123xyz#key-1",
SupportsWACI: false,
IssuerID: uuid.New().String(),
IsDIDCommV1: true,
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/restapi/rp/operation/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type CreateRPTenantRequest struct {
RequiresBlindedRoute bool `json:"requiresBlindedRoute"`
SupportsWACI bool `json:"supportsWACI"`
LinkedWalletURL string `json:"linkedWalletURL"`
IsDIDCommV2 bool `json:"isDIDCommV2"`
IsDIDCommV1 bool `json:"isDIDCommV1"`
}

// CreateRPTenantResponse API response body to register an RP tenant.
Expand All @@ -52,7 +52,7 @@ type CreateRPTenantResponse struct {
RequiresBlindedRoute bool `json:"requiresBlindedRoute"`
SupportsWACI bool `json:"supportsWACI"`
LinkedWalletURL string `json:"linkedWalletURL"`
IsDIDCommV2 bool `json:"isDIDCommV2"`
IsDIDCommV1 bool `json:"isDIDCommV1"`
}

// HandleCHAPIResponse is the input message to the chapiResponseHandler handler.
Expand Down
Loading

0 comments on commit 5d85243

Please sign in to comment.