diff --git a/backend/business-partner-agent-core/src/main/java/org/hyperledger/bpa/core/WebhookEvent.java b/backend/business-partner-agent-core/src/main/java/org/hyperledger/bpa/core/WebhookEvent.java index 529f9a101..1a7baf2d6 100644 --- a/backend/business-partner-agent-core/src/main/java/org/hyperledger/bpa/core/WebhookEvent.java +++ b/backend/business-partner-agent-core/src/main/java/org/hyperledger/bpa/core/WebhookEvent.java @@ -17,12 +17,11 @@ */ package org.hyperledger.bpa.core; -import org.hyperledger.bpa.core.RegisteredWebhook.WebhookEventType; - import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.hyperledger.bpa.core.RegisteredWebhook.WebhookEventType; @Data @Builder diff --git a/backend/business-partner-agent/pom.xml b/backend/business-partner-agent/pom.xml index 439ac71fc..2f8e51259 100644 --- a/backend/business-partner-agent/pom.xml +++ b/backend/business-partner-agent/pom.xml @@ -149,7 +149,7 @@ network.idu.acapy aries-client-python - 0.7.29 + 0.7.30-SNAPSHOT org.hyperledger.business-partner-agent diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/MyDocumentAPI.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/MyDocumentAPI.java index 5ccc10251..5cebc3b8a 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/MyDocumentAPI.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/MyDocumentAPI.java @@ -17,14 +17,15 @@ */ package org.hyperledger.bpa.api; -import com.fasterxml.jackson.databind.JsonNode; import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.bpa.controller.api.wallet.WalletDocumentRequest; +import java.util.List; import java.util.UUID; @Data @@ -41,7 +42,7 @@ public class MyDocumentAPI { private Boolean isPublic; private String label; @Schema(example = "{}") - private JsonNode documentData; // TODO rename to document + private List documentData; // TODO rename to document public static MyDocumentAPI fromRequest(WalletDocumentRequest req) { return DocumentMapper.INSTANCE.requestToDocumentApi(req); diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/aries/AriesCredential.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/aries/AriesCredential.java index f3e77019c..72e4fcd0a 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/aries/AriesCredential.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/aries/AriesCredential.java @@ -21,12 +21,13 @@ import lombok.*; import org.apache.commons.lang3.StringUtils; import org.hyperledger.aries.api.ExchangeVersion; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeState; import org.hyperledger.bpa.api.CredentialType; import org.hyperledger.bpa.impl.aries.jsonld.LDContextHelper; import org.hyperledger.bpa.persistence.model.BPACredentialExchange; -import java.util.Map; +import java.util.List; import java.util.UUID; @Data @@ -50,7 +51,7 @@ public class AriesCredential { private String label; private String typeLabel; - private Map credentialData; + private List credentialData; public static AriesCredential fromBPACredentialExchange(@NonNull BPACredentialExchange c, @Nullable String typeLabel) { diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredEx.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredEx.java index f41f29da2..9fc86b51f 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredEx.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredEx.java @@ -21,6 +21,7 @@ import org.apache.commons.lang3.StringUtils; import org.hyperledger.aries.api.ExchangeVersion; import org.hyperledger.aries.api.credentials.Credential; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeRole; import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeState; import org.hyperledger.bpa.api.CredentialType; @@ -29,6 +30,7 @@ import org.hyperledger.bpa.controller.api.ExchangeVersionTranslator; import org.hyperledger.bpa.persistence.model.BPACredentialExchange; +import java.util.List; import java.util.Map; import java.util.UUID; @@ -44,7 +46,7 @@ public class CredEx implements ExchangeVersionTranslator { private PartnerAPI partner; private String schemaId; // TODO UI should use this id instead the one from the credential private String credentialDefinitionId; // TODO UI should use this id instead the one from the credential - private Map proposal; + private List proposal; private Credential credential; // TODO should also be Map private CredentialExchangeRole role; private CredentialExchangeState state; @@ -81,18 +83,18 @@ public static CredEx from(@NonNull BPACredentialExchange db, PartnerAPI partner) } else if (StringUtils.isNotEmpty(db.getErrorMsg())) { displayText = db.getErrorMsg(); } - Map credentialAttrs; + List credentialAttrs; if (db.stateIsProposalReceived() || db.stateIsProposalSent() || db.roleIsHolder() && db.stateIsProblem() || db.roleIsIssuer() && db.stateIsDeclined()) { - credentialAttrs = db.proposalAttributesToMap(); + credentialAttrs = db.proposalAttributesToCredentialAttributesList(); } else if (db.stateIsOfferReceived() || db.stateIsRequestSent() || db.roleIsHolder() && db.stateIsDeclined()) { - credentialAttrs = db.offerAttributesToMap(); + credentialAttrs = db.offerAttributesToCredentialAttributesList(); } else { - credentialAttrs = db.credentialAttributesToMap(); + credentialAttrs = db.credentialAttributesToCredentialAttributesList(); } return builder .id(db.getId()) @@ -101,7 +103,7 @@ public static CredEx from(@NonNull BPACredentialExchange db, PartnerAPI partner) .partner(partner) .schemaId(db.getSchema() != null ? db.getSchema().getSchemaId() : null) .credentialDefinitionId(db.getCredDef() != null ? db.getCredDef().getCredentialDefinitionId() : null) - .proposal(db.proposalAttributesToMap()) + .proposal(db.proposalAttributesToCredentialAttributesList()) .credential(Credential .builder() .schemaId(db.getSchema() != null ? db.getSchema().getSchemaId() : null) diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredentialOfferRequest.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredentialOfferRequest.java index f6dc0f30a..1efa5f8cf 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredentialOfferRequest.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredentialOfferRequest.java @@ -24,7 +24,6 @@ import javax.validation.constraints.NotEmpty; import java.util.List; -import java.util.Map; @Data @NoArgsConstructor @@ -34,16 +33,9 @@ public class CredentialOfferRequest { private String credDefId; private String schemaId; @NotEmpty - private Map attributes; + private List attributes; public boolean acceptAll() { return acceptProposal != null && acceptProposal; } - - public List toCredentialAttributes() { - if (attributes != null) { - return CredentialAttributes.fromMap(attributes); - } - return List.of(); - } } diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueCredentialRequest.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueCredentialRequest.java index 1ae5133fb..cdb059d65 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueCredentialRequest.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueCredentialRequest.java @@ -17,19 +17,19 @@ */ package org.hyperledger.bpa.controller.api.issuer; -import com.fasterxml.jackson.annotation.JsonRawValue; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.databind.JsonNode; import io.micronaut.core.annotation.Introspected; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import lombok.experimental.SuperBuilder; import org.hyperledger.aries.api.ExchangeVersion; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.bpa.api.CredentialType; import org.hyperledger.bpa.controller.api.ExchangeVersionTranslator; import javax.validation.constraints.NotBlank; +import java.util.List; import java.util.UUID; @Introspected @@ -58,10 +58,8 @@ public abstract class IssueCredentialRequest { /** credential exchange type */ private CredentialType type; - /** credential body key value pairs */ - @JsonRawValue - @Schema(example = "{}") - private JsonNode document; + /** Attribute array with name, value, mime-type */ + private List document; @Introspected @Data diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueOOBCredentialRequest.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueOOBCredentialRequest.java index ba89c3b6d..bab595a73 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueOOBCredentialRequest.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueOOBCredentialRequest.java @@ -18,12 +18,12 @@ package org.hyperledger.bpa.controller.api.issuer; import com.fasterxml.jackson.annotation.JsonRawValue; -import com.fasterxml.jackson.databind.JsonNode; import io.micronaut.core.annotation.Introspected; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.NoArgsConstructor; import org.hyperledger.aries.api.ExchangeVersion; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.bpa.controller.api.ExchangeVersionTranslator; import org.hyperledger.bpa.persistence.model.Tag; @@ -48,7 +48,7 @@ public class IssueOOBCredentialRequest implements ExchangeVersionTranslator { /** credential body key value pairs */ @JsonRawValue @Schema(example = "{}") - private JsonNode document; + private List document; private ExchangeVersion exchangeVersion; } diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/proof/PresentationRequestCredentialsIndy.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/proof/PresentationRequestCredentialsIndy.java index 5819bac35..b72903d19 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/proof/PresentationRequestCredentialsIndy.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/proof/PresentationRequestCredentialsIndy.java @@ -18,11 +18,11 @@ package org.hyperledger.bpa.controller.api.proof; import lombok.*; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.bpa.api.aries.AriesCredential; import org.hyperledger.bpa.persistence.model.BPACredentialExchange; import java.util.List; -import java.util.Map; import java.util.UUID; @Data @@ -52,7 +52,7 @@ public static final class CredentialInfo { private String referent; private Boolean revoked; - private Map attrs; + private List attrs; private String schemaId; private String schemaLabel; diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/wallet/WalletDocumentRequest.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/wallet/WalletDocumentRequest.java index daaebf0c5..bdee671f4 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/wallet/WalletDocumentRequest.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/wallet/WalletDocumentRequest.java @@ -18,11 +18,13 @@ package org.hyperledger.bpa.controller.api.wallet; import com.fasterxml.jackson.annotation.JsonRawValue; -import com.fasterxml.jackson.databind.JsonNode; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.bpa.api.CredentialType; +import java.util.List; + @Data public class WalletDocumentRequest { private CredentialType type; @@ -31,5 +33,5 @@ public class WalletDocumentRequest { private String label; @JsonRawValue @Schema(example = "{}") - private JsonNode document; + private List document; } diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/TagService.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/TagService.java index d9f400dc1..b04ee2dad 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/TagService.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/TagService.java @@ -31,7 +31,10 @@ import org.hyperledger.bpa.persistence.model.Tag; import org.hyperledger.bpa.persistence.repository.TagRepository; -import java.util.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.StreamSupport; diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/DocumentValidator.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/DocumentValidator.java index e353cbf19..071f084c0 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/DocumentValidator.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/DocumentValidator.java @@ -17,12 +17,12 @@ */ package org.hyperledger.bpa.impl.activity; -import com.fasterxml.jackson.databind.JsonNode; import jakarta.inject.Inject; import jakarta.inject.Singleton; import lombok.NonNull; import lombok.Setter; import org.apache.commons.lang3.StringUtils; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.bpa.api.CredentialType; import org.hyperledger.bpa.api.MyDocumentAPI; import org.hyperledger.bpa.api.exception.WrongApiUsageException; @@ -34,10 +34,7 @@ import org.hyperledger.bpa.persistence.repository.MyDocumentRepository; import org.jetbrains.annotations.NotNull; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.SortedSet; +import java.util.*; /** * Does some validation on incoming {@link MyDocumentAPI} objects. Like this we @@ -77,16 +74,17 @@ public void validateExisting(@NonNull Optional existing, @NonNull My validateInternal(newDocument); } - public void validateAttributesAgainstIndySchema(@NonNull JsonNode attributes, @NonNull String schemaId) { + public void validateAttributesAgainstIndySchema(@NonNull List attributes, + @NonNull String schemaId) { // validate document data against schema BPASchema schema = findSchema(schemaId); Set attributeNames = schema.getSchemaAttributeNames(); // assuming flat structure - attributes.fieldNames().forEachRemaining(fn -> { - if (!attributeNames.contains(fn)) { + attributes.forEach(attr -> { + if (!attributeNames.contains(attr.getName())) { throw new WrongApiUsageException( ms.getMessage("api.document.validation.attribute.not.in.schema", - Map.of("attr", fn))); + Map.of("attr", attr))); } }); } diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/LabelStrategy.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/LabelStrategy.java index e826bfa9f..4c9bd4ead 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/LabelStrategy.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/LabelStrategy.java @@ -17,7 +17,6 @@ */ package org.hyperledger.bpa.impl.activity; -import com.fasterxml.jackson.databind.JsonNode; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import io.micronaut.core.annotation.Nullable; @@ -27,6 +26,7 @@ import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.hyperledger.aries.api.credentials.Credential; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.issue_credential_v1.V1CredentialExchange; import org.hyperledger.aries.api.issue_credential_v2.V20CredExRecordByFormat; import org.hyperledger.bpa.api.MyDocumentAPI; @@ -37,7 +37,7 @@ import org.hyperledger.bpa.persistence.model.BPASchema; import org.hyperledger.bpa.persistence.model.converter.ExchangePayload; -import java.util.Map; +import java.util.List; import java.util.Optional; /** @@ -59,11 +59,10 @@ public class LabelStrategy { public void apply(@NonNull MyDocumentAPI document) { if (StringUtils.isBlank(document.getLabel())) { findDefaultAttribute(document.getSchemaId()).ifPresent(attr -> { - JsonNode documentData = document.getDocumentData(); - JsonNode value = documentData.findValue(attr); + List documentData = document.getDocumentData(); + String value = documentData.stream().filter(a -> a.getName().equals(attr)).findFirst().get().getValue(); if (value != null) { - String label = value.asText(); - document.setLabel(label); + document.setLabel(value); } }); } @@ -73,8 +72,8 @@ public void apply(@NonNull MyDocumentAPI document) { if (ariesCredential != null) { Optional attr = findDefaultAttribute(ariesCredential.getSchemaId()); if (attr.isPresent() && ariesCredential.getAttrs() != null) { - Map attrs = ariesCredential.getAttrs(); - return attrs.get(attr.get()); + List attrs = (List) ariesCredential.getAttrs(); + return attrs.stream().filter(a -> a.getName().equals(attr.get())).findFirst().get().getValue(); } } return null; @@ -87,8 +86,8 @@ public void apply(@NonNull MyDocumentAPI document) { } else { Optional attr = findDefaultAttribute(ariesCredential.getSchemaId()); if (attr.isPresent() && ariesCredential.getCredentialData() != null) { - Map attrs = ariesCredential.getCredentialData(); - mergedLabel = attrs.get(attr.get()); + List attrs = ariesCredential.getCredentialData(); + mergedLabel = attrs.stream().filter(a -> a.getName().equals(attr.get())).findFirst().get().getValue(); } } return mergedLabel; diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/CredentialInfoResolver.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/CredentialInfoResolver.java index 2e5b87969..49d5acc42 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/CredentialInfoResolver.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/CredentialInfoResolver.java @@ -98,7 +98,7 @@ public PresentationRequestCredentialsIndy.CredentialInfo populateCredentialInfo( holderCredExRepo.findByReferent(matchingVC.getRecordId()).ifPresent(cred -> { builder.credentialId(cred.getId()); builder.credentialLabel(cred.getLabel()); - builder.attrs(cred.credentialAttributesToMap()); + builder.attrs(cred.credentialAttributesToCredentialAttributesList()); builder.referent(matchingVC.getRecordId()); }); } diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderIndyManager.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderIndyManager.java index 0b77d0d11..a52d312e4 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderIndyManager.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderIndyManager.java @@ -50,7 +50,7 @@ import java.io.IOException; import java.time.Instant; -import java.util.Map; +import java.util.List; import java.util.Objects; /** @@ -77,7 +77,7 @@ public class HolderIndyManager { public void sendCredentialProposal( @NonNull String connectionId, @NonNull String schemaId, - @NonNull Map document, + @NonNull List document, @NonNull BPACredentialExchange.BPACredentialExchangeBuilder dbCredEx, @Nullable ExchangeVersion version) throws IOException { diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderLDManager.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderLDManager.java index 5f5f021aa..694529a28 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderLDManager.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderLDManager.java @@ -17,7 +17,6 @@ */ package org.hyperledger.bpa.impl.aries.credential; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.inject.Inject; import jakarta.inject.Singleton; @@ -26,6 +25,7 @@ import lombok.Setter; import org.hyperledger.aries.AriesClient; import org.hyperledger.aries.api.ExchangeVersion; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.issue_credential_v1.BaseCredExRecord; import org.hyperledger.aries.api.issue_credential_v2.V20CredExRecord; import org.hyperledger.aries.api.issue_credential_v2.V20CredExRecordByFormat; @@ -43,7 +43,6 @@ import java.io.IOException; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.UUID; @@ -78,13 +77,12 @@ public class HolderLDManager { public void sendCredentialProposal( @NonNull String connectionId, @NonNull BPASchema s, - @NonNull Map document, + @NonNull List document, @NonNull BPACredentialExchange.BPACredentialExchangeBuilder dbCredEx) throws IOException { - JsonNode jsonNode = mapper.valueToTree(document); V2CredentialExchangeFree v2Request = V2CredentialExchangeFree.builder() .connectionId(UUID.fromString(connectionId)) - .filter(ldHelper.buildVC(s, jsonNode, Boolean.FALSE)) + .filter(ldHelper.buildVC(s, document, Boolean.FALSE)) .build(); ac.issueCredentialV2SendProposal(v2Request).ifPresent(v2 -> dbCredEx .threadId(v2.getThreadId()) diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderManager.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderManager.java index 347e1bd0c..423bc0abe 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderManager.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderManager.java @@ -29,6 +29,7 @@ import org.apache.commons.lang3.StringUtils; import org.hyperledger.acy_py.generated.model.V20CredRequestRequest; import org.hyperledger.aries.api.ExchangeVersion; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.issue_credential_v1.BaseCredExRecord; import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeRole; import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeState; @@ -136,7 +137,7 @@ public void sendCredentialProposal(@NonNull UUID partnerId, @NonNull UUID myDocI .pushStateChange(CredentialExchangeState.PROPOSAL_SENT, Instant.now()) .role(CredentialExchangeRole.HOLDER); String connectionId = Objects.requireNonNull(dbPartner.getConnectionId()); - Map document = Objects.requireNonNull(dbDoc.getDocument()); + List document = Objects.requireNonNull(dbDoc.getDocument()); if (dbDoc.typeIsIndy()) { indy.sendCredentialProposal(connectionId, s.getSchemaId(), document, dbCredEx, version); } else { diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerIndyManager.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerIndyManager.java index d734cc306..093cca60b 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerIndyManager.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerIndyManager.java @@ -55,9 +55,7 @@ import java.io.IOException; import java.time.Instant; -import java.util.Map; -import java.util.Objects; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; /** @@ -104,7 +102,8 @@ public BPACredentialExchange issueIndyCredential( .orElseThrow(() -> new IssuerException( msg.getMessage("api.issuer.creddef.not.found", Map.of("id", request.getCredDefId())))); - Map document = conv.toStringMap(request.getDocument()); + // TODO: Use object array with name, value and mime-type instead of Map + List document = request.getDocument(); checkCredentialAttributes(document, dbCredDef); @@ -119,7 +118,7 @@ public BPACredentialExchange issueIndyCredential( .builder() .connectionId(Objects.requireNonNull(connectionId)) .schemaId(schemaId) - .credentialProposal(new CredentialPreview(CredentialAttributes.fromMap(document))) + .credentialProposal(new CredentialPreview(request.getDocument())) .credentialDefinitionId(credentialDefinitionId) .build(); @@ -156,7 +155,7 @@ public void reIssueIndyCredential(@NonNull BPACredentialExchange credEx) { issueIndyCredential(IssueCredentialRequest.IssueIndyCredentialRequest.builder() .partnerId(credEx.getPartner() != null ? credEx.getPartner().getId() : null) .credDefId(credEx.getCredDef() != null ? credEx.getCredDef().getId() : null) - .document(conv.mapToNode(Objects.requireNonNull(credEx.getIndyCredential()).getAttrs())) + .document(new ArrayList<>(Objects.requireNonNull(credEx.getIndyCredential()).getAttrs())) .exchangeVersion(credEx.getExchangeVersion()) .build()); } else { @@ -187,7 +186,7 @@ public CredEx revokeIndyCredential(BPACredentialExchange credEx) { } } - public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull Map attributes, + public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull List attributes, @NonNull IssuerManager.IdWrapper ids) throws IOException { String credDefId = credEx.getCredDef() != null ? credEx.getCredDef().getCredentialDefinitionId() : null; if (StringUtils.isNotEmpty(ids.credDefId()) && !StringUtils.equals(credDefId, ids.credDefId())) { @@ -207,9 +206,11 @@ public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull Map CredAttrSpec + .attributes(attributes.stream().map(attr -> CredAttrSpec .builder() - .name(a.getKey()).value(a.getValue()) + .name(attr.getName()) + .value(attr.getValue()) + .mimeType(attr.getMimeType()) .build()).collect(Collectors.toList())) .build()) .build()) @@ -235,8 +236,10 @@ public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull Map document, BPACredentialDefinition dbCredDef) { - Set documentAttributeNames = document.keySet(); + private void checkCredentialAttributes(List document, + BPACredentialDefinition dbCredDef) { + Set documentAttributeNames = document.stream().map(CredentialAttributes::getName) + .collect(Collectors.toSet()); Set schemaAttributeNames = dbCredDef.getSchema().getSchemaAttributeNames(); if (!documentAttributeNames.equals(schemaAttributeNames)) { throw new IssuerException(msg.getMessage("api.issuer.credential.document.mismatch", diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerLDManager.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerLDManager.java index 3cfbceef3..844f84ae2 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerLDManager.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerLDManager.java @@ -17,7 +17,6 @@ */ package org.hyperledger.bpa.impl.aries.credential; -import com.fasterxml.jackson.databind.JsonNode; import jakarta.inject.Inject; import jakarta.inject.Singleton; import lombok.NonNull; @@ -49,6 +48,7 @@ import java.io.IOException; import java.time.Instant; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.UUID; @@ -78,7 +78,8 @@ public class IssuerLDManager { @Inject BPAMessageSource.DefaultMessageSource msg; - public BPACredentialExchange issueLDCredential(UUID partnerId, UUID bpaSchemaId, JsonNode document) { + public BPACredentialExchange issueLDCredential(UUID partnerId, UUID bpaSchemaId, + List document) { Partner partner = partnerRepo.findById(partnerId).orElseThrow(EntityNotFoundException::new); BPASchema bpaSchema = schemaRepo.findById(bpaSchemaId).orElseThrow(EntityNotFoundException::new); try { @@ -116,7 +117,7 @@ public CredEx revokeLDCredential() { throw new WrongApiUsageException(msg.getMessage("api.issuer.credential.send.not.supported")); } - public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull Map attributes, + public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull List attributes, @NonNull IssuerManager.IdWrapper ids) throws IOException { String schemaId = credEx.getSchema() != null ? credEx.getSchema().getSchemaId() : null; if (StringUtils.isNotEmpty(schemaId) && !StringUtils.equals(schemaId, ids.schemaId())) { @@ -131,7 +132,7 @@ public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull Map attributes; + List attributes; if (counterOffer.acceptAll()) { - attributes = credEx.proposalAttributesToMap(); + attributes = credEx.proposalAttributesToCredentialAttributesList(); } else { attributes = counterOffer.getAttributes(); } @@ -367,7 +369,8 @@ public void handleV2CredentialExchange(@NonNull V20CredExRecord ex) { if (ex.payloadIsIndy()) { ex.getByFormat().findValuesInIndyCredIssue().ifPresent( attr -> issuerCredExRepo.updateCredential(bpaEx.getId(), - Credential.builder().attrs(attr).build())); + // TODO: Pass mime-type + Credential.builder().attrs(CredentialAttributes.from(attr)).build())); } else { issuerCredExRepo.updateCredential(bpaEx.getId(), ExchangePayload.jsonLD(ex.resolveLDCredential())); diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/jsonld/LDContextHelper.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/jsonld/LDContextHelper.java index bbf70ee13..827bdd1c5 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/jsonld/LDContextHelper.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/jsonld/LDContextHelper.java @@ -17,13 +17,13 @@ */ package org.hyperledger.bpa.impl.aries.jsonld; -import com.fasterxml.jackson.databind.JsonNode; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import io.micronaut.core.annotation.Nullable; import jakarta.inject.Inject; import jakarta.inject.Singleton; import lombok.NonNull; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.issue_credential_v2.V20CredExRecordByFormat; import org.hyperledger.aries.api.issue_credential_v2.V2CredentialExchangeFree; import org.hyperledger.aries.api.jsonld.ProofType; @@ -79,7 +79,7 @@ public static String findSchemaId(@NonNull List context) { } public V2CredentialExchangeFree.V20CredFilter buildVC( - @NonNull BPASchema bpaSchema, @NonNull JsonNode document, @NonNull Boolean issuer) { + @NonNull BPASchema bpaSchema, @NonNull List document, @NonNull Boolean issuer) { return buildVC(bpaSchema, conv.toStringMap(document), issuer); } diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/jsonld/VPManager.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/jsonld/VPManager.java index 6b1b50ee8..027322f81 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/jsonld/VPManager.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/jsonld/VPManager.java @@ -17,7 +17,6 @@ */ package org.hyperledger.bpa.impl.aries.jsonld; -import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import io.micronaut.core.annotation.Nullable; @@ -114,13 +113,11 @@ public void signVP(List vcs) { } protected VerifiableIndyCredential buildFromDocument(@NonNull MyDocument doc, @NonNull String myDid) { - final ObjectNode on = converter.fromMap(Objects.requireNonNull(doc.getDocument()), ObjectNode.class); - on.remove("id"); - on.put("id", myDid); + var document = Objects.requireNonNull(doc.getDocument()); // this is needed because the java client serializes with GSON // and cannot handle Jackson ObjectNode - JsonObject subj = GsonConfig.defaultConfig().fromJson(on.toString(), JsonObject.class); + JsonObject subj = GsonConfig.defaultConfig().fromJson(document.toString(), JsonObject.class); List types = new ArrayList<>(doc.getType().getType()); if (doc.typeIsJsonLd() && doc.getSchema() != null && doc.getSchema().getLdType() != null) { diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/proof/ProverLDManager.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/proof/ProverLDManager.java index b9da0b30e..bfdc4a14b 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/proof/ProverLDManager.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/proof/ProverLDManager.java @@ -27,6 +27,7 @@ import org.apache.commons.lang3.tuple.Pair; import org.hyperledger.acy_py.generated.model.DIFOptions; import org.hyperledger.aries.AriesClient; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.jsonld.VerifiableCredential; import org.hyperledger.aries.api.present_proof_v2.*; import org.hyperledger.bpa.api.exception.NetworkException; @@ -55,7 +56,7 @@ public class ProverLDManager extends BaseLDManager { public V20PresProposalRequest prepareProposal(@NonNull String connectionId, @NonNull BPACredentialExchange credEx) { - Map fields = buildDifFields(credEx.credentialAttributesToMap()); + Map fields = buildDifFields(credEx.credentialAttributesToCredentialAttributesList()); String descriptorId = credEx.getSchema() != null ? credEx.getSchema().resolveSchemaLabelEscaped() : UUID.randomUUID().toString(); @@ -101,12 +102,13 @@ private List buildDifFields(@NonNull Map ldAttributes) { - return ldAttributes.entrySet() + private Map buildDifFields(@NonNull List ldAttributes) { + return ldAttributes .stream() .filter(e -> StringUtils.isNotEmpty(e.getValue())) - .filter(e -> !StringUtils.equalsIgnoreCase("type", e.getKey())) - .map(e -> pair(e.getKey(), DIFField.Filter.builder() + .filter(e -> !StringUtils.equalsIgnoreCase("type", e.getName())) + // TODO: Pass mime-type + .map(e -> pair(e.getName(), DIFField.Filter.builder() ._const(e.getValue()) .build())) .collect(Collectors.toMap(Pair::getKey, Pair::getValue)); diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/oob/OOBCredentialOffer.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/oob/OOBCredentialOffer.java index 044a7dae7..c3fe5027e 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/oob/OOBCredentialOffer.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/oob/OOBCredentialOffer.java @@ -23,6 +23,7 @@ import lombok.extern.slf4j.Slf4j; import org.hyperledger.aries.AriesClient; import org.hyperledger.aries.api.credentials.Credential; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeRole; import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeState; import org.hyperledger.aries.api.issue_credential_v1.CredentialFreeOfferHelper; @@ -41,6 +42,7 @@ import org.hyperledger.bpa.persistence.repository.IssuerCredExRepository; import java.time.Instant; +import java.util.List; import java.util.Map; /** @@ -87,26 +89,24 @@ public APICreateInvitationResponse issueConnectionLess(@NonNull IssueOOBCredenti ms.getMessage("api.issuer.creddef.not.found", Map.of("id", req.getCredDefId())))); validator.validateAttributesAgainstIndySchema(req.getDocument(), dbCredDef.getSchema().getSchemaId()); - Map document = conv.toStringMap(req.getDocument()); - CredentialFreeOfferHelper.CredentialFreeOffer freeOffer; if (req.exchangeIsV1()) { - freeOffer = h.buildV1Indy(dbCredDef.getCredentialDefinitionId(), document); + freeOffer = h.buildV1Indy(dbCredDef.getCredentialDefinitionId(), req.getDocument()); } else { - freeOffer = h.buildV2Indy(dbCredDef.getCredentialDefinitionId(), document); + freeOffer = h.buildV2Indy(dbCredDef.getCredentialDefinitionId(), req.getDocument()); } log.debug("{}", GsonConfig.defaultNoEscaping().toJson(freeOffer)); Partner p = persistPartner(freeOffer.getInvitationRecord(), req.getAlias(), req.getTrustPing(), req.getTag()); - persistCredentialExchange(freeOffer, document, dbCredDef, p); + persistCredentialExchange(freeOffer, req.getDocument(), dbCredDef, p); return buildResponse(freeOffer.getInvitationRecord().getInviMsgId()); } private void persistCredentialExchange( @NonNull CredentialFreeOfferHelper.CredentialFreeOffer r, - @NonNull Map document, + @NonNull List document, @NonNull BPACredentialDefinition dbCredDef, @NonNull Partner p) { BPACredentialExchange.BPACredentialExchangeBuilder b = BPACredentialExchange diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/util/Converter.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/util/Converter.java index 8194b3689..9a8b8831c 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/util/Converter.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/util/Converter.java @@ -185,11 +185,10 @@ public MyDocument toModelObject(@NonNull MyDocumentAPI document) { * @return myCredential model object, updated */ public MyDocument updateMyCredential(@NonNull MyDocumentAPI apiDoc, @NonNull MyDocument myDoc) { - Map data = toMap(apiDoc.getDocumentData()); schemaService.getSchemaFor(apiDoc.getSchemaId()).ifPresentOrElse(myDoc::setSchema, EntityNotFoundException::new); myDoc - .setDocument(data) + .setDocument(apiDoc.getDocumentData()) .setIsPublic(apiDoc.getIsPublic()) .setType(apiDoc.getType()) .setSchemaId(apiDoc.getSchemaId()) @@ -202,7 +201,7 @@ public MyDocumentAPI toApiObject(@NonNull MyDocument myDoc) { .id(myDoc.getId()) .createdAt(myDoc.getCreatedAt().toEpochMilli()) .updatedAt(myDoc.getUpdatedAt().toEpochMilli()) - .documentData(myDoc.getDocument() != null ? fromMap(myDoc.getDocument(), JsonNode.class) : null) + .documentData(myDoc.getDocument() != null ? myDoc.getDocument() : null) .isPublic(myDoc.getIsPublic()) .type(myDoc.getType()) .typeLabel(resolveTypeLabel(myDoc.getType(), myDoc.getSchemaId(), null)) diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/persistence/model/BPACredentialExchange.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/persistence/model/BPACredentialExchange.java index 27116d0bf..6ad9c0a73 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/persistence/model/BPACredentialExchange.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/persistence/model/BPACredentialExchange.java @@ -42,6 +42,8 @@ import javax.persistence.Id; import javax.persistence.*; import java.time.Instant; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; @@ -177,53 +179,60 @@ public Instant calculateIssuedAt() { : null; } - public @io.micronaut.core.annotation.NonNull Map proposalAttributesToMap() { + public @io.micronaut.core.annotation.NonNull List proposalAttributesToCredentialAttributesList() { if (typeIsJsonLd()) { - return ldAttributesToMap(credentialProposal != null ? credentialProposal.getJsonLD() : null); + return ldAttributesToCredentialAttributesList( + credentialProposal != null ? credentialProposal.getJsonLD() : null); } - return indyAttributesToMap(credentialProposal != null ? credentialProposal.getIndy() : null); + return indyAttributesToCredentialAttributesList( + credentialProposal != null ? credentialProposal.getIndy() : null); } - public @io.micronaut.core.annotation.NonNull Map offerAttributesToMap() { + public @io.micronaut.core.annotation.NonNull List offerAttributesToCredentialAttributesList() { if (typeIsJsonLd()) { - return ldAttributesToMap(credentialOffer != null ? credentialOffer.getJsonLD() : null); + return ldAttributesToCredentialAttributesList(credentialOffer != null ? credentialOffer.getJsonLD() : null); } - return indyAttributesToMap(credentialOffer != null ? credentialOffer.getIndy() : null); + return indyAttributesToCredentialAttributesList(credentialOffer != null ? credentialOffer.getIndy() : null); } - public @io.micronaut.core.annotation.NonNull Map credentialAttributesToMap() { + public @io.micronaut.core.annotation.NonNull List credentialAttributesToCredentialAttributesList() { if (typeIsJsonLd()) { - return ldAttributesToMap(ldCredential != null ? ldCredential.getJsonLD() : null); + return ldAttributesToCredentialAttributesList(ldCredential != null ? ldCredential.getJsonLD() : null); } // TODO fallback to credential if (indyCredential == null || CollectionUtils.isEmpty(indyCredential.getAttrs())) { - return Map.of(); + return new ArrayList<>(); } - return indyCredential.getAttrs(); + return (List) indyCredential.getAttrs(); } - private Map ldAttributesToMap(V20CredExRecordByFormat.LdProof ldProof) { - return ldProof == null ? Map.of() : ldProof.toFlatMap(); + private List ldAttributesToCredentialAttributesList( + V20CredExRecordByFormat.LdProof ldProof) { + Map result = ldProof == null ? Map.of() : ldProof.toFlatMap(); + // TODO: Pass mime-type + return (List) result.entrySet() + .stream() + .map(e -> new CredentialAttributes(e.getKey(), e.getValue(), null)) + .collect(Collectors.toList()); } - private Map indyAttributesToMap(V1CredentialExchange.CredentialProposalDict.CredentialProposal p) { + private List indyAttributesToCredentialAttributesList( + V1CredentialExchange.CredentialProposalDict.CredentialProposal p) { if (p == null || CollectionUtils.isEmpty(p.getAttributes())) { - return Map.of(); + return new ArrayList<>(); } - return p.getAttributes() - .stream() - .collect(Collectors.toMap(CredentialAttributes::getName, CredentialAttributes::getValue)); + return (List) p.getAttributes(); } - public Map attributesByState() { + public List attributesByState() { if (stateIsProposalReceived()) { - return proposalAttributesToMap(); + return proposalAttributesToCredentialAttributesList(); } else if (stateIsOfferReceived()) { - return offerAttributesToMap(); + return offerAttributesToCredentialAttributesList(); } else if (stateIsDone() || stateIsCredentialAcked() || stateIsCredentialIssued()) { - return credentialAttributesToMap(); + return credentialAttributesToCredentialAttributesList(); } - return Map.of(); + return new ArrayList<>(); } public ExchangePayload exchangePayloadByState() { diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/persistence/model/MyDocument.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/persistence/model/MyDocument.java index 6859edb81..7acc932ca 100644 --- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/persistence/model/MyDocument.java +++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/persistence/model/MyDocument.java @@ -18,18 +18,20 @@ package org.hyperledger.bpa.persistence.model; import io.micronaut.core.annotation.Nullable; -import io.micronaut.data.annotation.*; -import io.micronaut.data.model.DataType; +import io.micronaut.data.annotation.AutoPopulated; +import io.micronaut.data.annotation.DateCreated; +import io.micronaut.data.annotation.DateUpdated; +import io.micronaut.data.annotation.MappedProperty; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.Accessors; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.bpa.api.CredentialType; import org.hyperledger.bpa.persistence.model.type.ExchangeTypeTranslator; -import javax.persistence.Id; import javax.persistence.*; import java.time.Instant; -import java.util.Map; +import java.util.List; import java.util.UUID; /** @@ -78,7 +80,6 @@ public class MyDocument implements ExchangeTypeTranslator { private String label; @Nullable - @TypeDef(type = DataType.JSON) - private Map document; - + // TODO: Find proper type including CredentialAttributes + private List document; } diff --git a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/activity/DocumentValidatorTest.java b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/activity/DocumentValidatorTest.java index b1701922e..b45e73f2e 100644 --- a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/activity/DocumentValidatorTest.java +++ b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/activity/DocumentValidatorTest.java @@ -18,8 +18,8 @@ package org.hyperledger.bpa.impl.activity; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.bpa.api.CredentialType; import org.hyperledger.bpa.api.MyDocumentAPI; import org.hyperledger.bpa.api.exception.WrongApiUsageException; @@ -36,10 +36,7 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.anyString; @@ -86,20 +83,22 @@ void testIndyCredentialWthNoSchemaId() { void testIndyCredentialWithSchema() throws JsonProcessingException { when(schemaService.getSchemaFor(anyString())).thenReturn(buildSchema(Set.of("iban", "bic"))); - String json = "{\"iban\": \"iban\", \"bic\": \"bic\"}"; - JsonNode jsonNode = m.readTree(json); + List document = new ArrayList<>(Arrays.asList( + new CredentialAttributes("iban", "iban", null), + new CredentialAttributes("bic", "bic", null))); - validator.validateNew(buildMyDocument(jsonNode)); + validator.validateNew(buildMyDocument(document)); } @Test void testIndyCredentialWithNoMatchingSchema() throws JsonProcessingException { when(schemaService.getSchemaFor(anyString())).thenReturn(buildSchema(Set.of("iban", "bic"))); - String json = "{\"foo\": \"iban\", \"bar\": \"bic\"}"; - JsonNode jsonNode = m.readTree(json); + List document = new ArrayList<>(Arrays.asList( + new CredentialAttributes("foo", "iban", null), + new CredentialAttributes("bar", "bic", null))); - assertThrows(WrongApiUsageException.class, () -> validator.validateNew(buildMyDocument(jsonNode))); + assertThrows(WrongApiUsageException.class, () -> validator.validateNew(buildMyDocument(document))); } @Test @@ -125,12 +124,12 @@ private Optional buildSchema(Set attr) { .build()); } - private MyDocumentAPI buildMyDocument(JsonNode jsonNode) { + private MyDocumentAPI buildMyDocument(List attributes) { return MyDocumentAPI .builder() .type(CredentialType.INDY) .schemaId("123") - .documentData(jsonNode) + .documentData(attributes) .build(); } } diff --git a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/activity/LabelStrategyTest.java b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/activity/LabelStrategyTest.java index 65be7bd56..494a8707b 100644 --- a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/activity/LabelStrategyTest.java +++ b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/activity/LabelStrategyTest.java @@ -17,10 +17,10 @@ */ package org.hyperledger.bpa.impl.activity; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.JsonObject; import org.hyperledger.aries.api.credentials.Credential; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.issue_credential_v2.V20CredExRecordByFormat; import org.hyperledger.aries.api.jsonld.VerifiableCredential; import org.hyperledger.bpa.api.MyDocumentAPI; @@ -34,8 +34,9 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.Optional; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -56,7 +57,9 @@ public class LabelStrategyTest { @InjectMocks LabelStrategy labelStrategy; - private static final String BA = "{\"bic\": \"123\", \"iban\": \"test123\"}"; + private static final List BA = new ArrayList<>(Arrays.asList( + new CredentialAttributes("bic", "123", null), + new CredentialAttributes("iban", "test123", null))); @Test void testHappyLabel() throws Exception { @@ -67,7 +70,7 @@ void testHappyLabel() throws Exception { MyDocumentAPI doc = MyDocumentAPI .builder() - .documentData(mapper.readValue(BA, JsonNode.class)) + .documentData(BA) .schemaId(SCHEMA_ID) .build(); labelStrategy.apply(doc); @@ -89,7 +92,7 @@ void testNoSchemaConfig() throws Exception { MyDocumentAPI doc = MyDocumentAPI .builder() .schemaId(SCHEMA_ID) - .documentData(mapper.readValue(BA, JsonNode.class)) + .documentData(BA) .build(); labelStrategy.apply(doc); assertNull(doc.getLabel()); @@ -104,7 +107,10 @@ void testHappyLabelFromCredential() { .build())); Credential credential = new Credential(); - credential.setAttrs(Map.of("iban", "test123", "bic", "1234")); + credential.setAttrs( + new ArrayList<>(Arrays.asList( + new CredentialAttributes("iban", "test123", null), + new CredentialAttributes("bic", "1234", null)))); credential.setSchemaId(SCHEMA_ID); String label = labelStrategy.apply(credential); assertEquals("test123", label); @@ -125,7 +131,10 @@ void testResetLabelOnCredentialUpdate() { .build())); AriesCredential credential = new AriesCredential(); credential.setSchemaId(SCHEMA_ID); - credential.setCredentialData(Map.of("iban", "test123", "bic", "1234")); + credential.setCredentialData( + new ArrayList<>(Arrays.asList( + new CredentialAttributes("iban", "test123", null), + new CredentialAttributes("bic", "1234", null)))); String label = labelStrategy.apply("", credential); assertEquals("test123", label); } diff --git a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/credential/CredentialTestUtils.java b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/credential/CredentialTestUtils.java index 0e6d4562a..27c8b1bcf 100644 --- a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/credential/CredentialTestUtils.java +++ b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/credential/CredentialTestUtils.java @@ -17,13 +17,15 @@ */ package org.hyperledger.bpa.impl.aries.credential; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.NonNull; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.bpa.api.CredentialType; import org.hyperledger.bpa.api.MyDocumentAPI; +import java.util.ArrayList; +import java.util.List; + public class CredentialTestUtils { private final ObjectMapper mapper; @@ -32,13 +34,15 @@ public CredentialTestUtils(ObjectMapper m) { mapper = m; } - public MyDocumentAPI createDummyCred(@NonNull CredentialType credType, @NonNull Boolean isPublic) - throws JsonProcessingException { - String json = "{ \"iban\":\"Hello\" }"; - JsonNode jsonNode = mapper.readTree(json); + public MyDocumentAPI createDummyCred(@NonNull CredentialType credType, @NonNull Boolean isPublic) { + CredentialAttributes dummyAttribute = new CredentialAttributes("iban", "Hello", null); + + List attributesArrayList = new ArrayList<>(); + attributesArrayList.add(dummyAttribute); + return MyDocumentAPI.builder() .type(credType) - .documentData(jsonNode) + .documentData(attributesArrayList) .isPublic(isPublic) .schemaId(CredentialType.INDY.equals(credType) ? "M6Mbe3qx7vB4wpZF4sBRjt:2:bank_account:1.0" : null) diff --git a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/jsonld/HolderLDCredentialTest.java b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/jsonld/HolderLDCredentialTest.java index 5130eb032..ed9f6f44b 100644 --- a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/jsonld/HolderLDCredentialTest.java +++ b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/jsonld/HolderLDCredentialTest.java @@ -23,6 +23,7 @@ import org.hyperledger.acy_py.generated.model.DID; import org.hyperledger.aries.AriesClient; import org.hyperledger.aries.api.ExchangeVersion; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.issue_credential_v2.V20CredExRecord; import org.hyperledger.aries.api.issue_credential_v2.V2CredentialExchangeFree; import org.hyperledger.aries.api.issue_credential_v2.V2IssueLDCredentialEvent; @@ -47,7 +48,8 @@ import org.mockito.junit.jupiter.MockitoExtension; import java.io.IOException; -import java.util.Map; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Optional; import java.util.Set; @@ -109,8 +111,9 @@ void testHolderReceivesCredentialFromIssuerAndAccepts() throws IOException { Assertions.assertTrue(ex.stateIsOfferReceived()); Assertions.assertTrue(ex.typeIsJsonLd()); Assertions.assertEquals(ExchangeVersion.V2, ex.getExchangeVersion()); - Assertions.assertEquals(2, ex.offerAttributesToMap().size()); - Assertions.assertEquals("karl", ex.offerAttributesToMap().get("name")); + Assertions.assertEquals(2, ex.offerAttributesToCredentialAttributesList().size()); + Assertions.assertEquals("karl", ex.credentialAttributesToCredentialAttributesList().stream() + .filter(attr -> attr.getName().equals("name")).findFirst().get().getValue()); holder.sendCredentialRequest(ex.getId()); @@ -129,8 +132,9 @@ void testHolderReceivesCredentialFromIssuerAndAccepts() throws IOException { aeh.handleCredentialV2(done); ex = loadCredEx(id); Assertions.assertTrue(ex.stateIsDone()); - Assertions.assertEquals(2, ex.credentialAttributesToMap().size()); - Assertions.assertEquals("karl", ex.credentialAttributesToMap().get("name")); + Assertions.assertEquals(2, ex.credentialAttributesToCredentialAttributesList().size()); + Assertions.assertEquals("karl", ex.credentialAttributesToCredentialAttributesList().stream() + .filter(attr -> attr.getName().equals("name")).findFirst().get().getValue()); } @Test @@ -176,7 +180,9 @@ void testHolderRequestsCredentialFromIssuerAndIssuerAccepts() throws IOException .schemaId(schemaId) .type(CredentialType.JSON_LD) .isPublic(Boolean.FALSE) - .documentData(conv.mapToNode(Map.of("name", "My Name", "identifier", "something"))) + .documentData(new ArrayList<>(Arrays.asList( + new CredentialAttributes("name", "My Name", null), + new CredentialAttributes("identifier", "something", null)))) .build()); holder.sendCredentialProposal(p.getId(), document.getId(), null); @@ -186,8 +192,9 @@ void testHolderRequestsCredentialFromIssuerAndIssuerAccepts() throws IOException Assertions.assertTrue(ex.stateIsProposalSent()); Assertions.assertTrue(ex.typeIsJsonLd()); Assertions.assertEquals(ExchangeVersion.V2, ex.getExchangeVersion()); - Assertions.assertEquals(2, ex.proposalAttributesToMap().size()); - Assertions.assertEquals("My Name", ex.proposalAttributesToMap().get("name")); + Assertions.assertEquals(2, ex.proposalAttributesToCredentialAttributesList().size()); + Assertions.assertEquals("My Name", ex.credentialAttributesToCredentialAttributesList().stream() + .filter(attr -> attr.getName().equals("name")).findFirst().get().getValue()); aeh.handleCredentialV2(offer); ex = loadCredEx(id); @@ -219,7 +226,9 @@ void testHolderRequestsCredentialFromIssuerAndIssuerDeclines() throws IOExceptio .schemaId(schemaId) .type(CredentialType.JSON_LD) .isPublic(Boolean.FALSE) - .documentData(conv.mapToNode(Map.of("name", "My Name", "identifier", "something"))) + .documentData(new ArrayList<>(Arrays.asList( + new CredentialAttributes("name", "My Name", null), + new CredentialAttributes("identifier", "something", null)))) .build()); holder.sendCredentialProposal(p.getId(), document.getId(), null); diff --git a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/jsonld/IssuerLDCredentialTest.java b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/jsonld/IssuerLDCredentialTest.java index 43af3a816..39a28eb61 100644 --- a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/jsonld/IssuerLDCredentialTest.java +++ b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/jsonld/IssuerLDCredentialTest.java @@ -23,6 +23,7 @@ import org.hyperledger.acy_py.generated.model.DID; import org.hyperledger.aries.AriesClient; import org.hyperledger.aries.api.ExchangeVersion; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.issue_credential_v2.V20CredBoundOfferRequest; import org.hyperledger.aries.api.issue_credential_v2.V20CredExRecord; import org.hyperledger.aries.api.issue_credential_v2.V2CredentialExchangeFree; @@ -47,7 +48,8 @@ import org.mockito.junit.jupiter.MockitoExtension; import java.io.IOException; -import java.util.Map; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Optional; import java.util.Set; @@ -103,7 +105,9 @@ void testHandleIssuerSendCredential() throws IOException { issuer.issueCredential(IssueCredentialRequest.IssueLDCredentialRequest.builder() .schemaId(schemaAPI.getId()) .partnerId(p.getId()) - .document(conv.mapToNode(Map.of("name", "555", "identifier", "1234"))) + .document(new ArrayList<>(Arrays.asList( + new CredentialAttributes("name", "555", null), + new CredentialAttributes("identifier", "1234", null)))) .type(CredentialType.JSON_LD) .build()); @@ -112,8 +116,9 @@ void testHandleIssuerSendCredential() throws IOException { Assertions.assertTrue(ex.stateIsOfferSent()); Assertions.assertTrue(ex.typeIsJsonLd()); Assertions.assertEquals(ExchangeVersion.V2, ex.getExchangeVersion()); - Assertions.assertEquals(2, ex.credentialAttributesToMap().size()); - Assertions.assertEquals("555", ex.credentialAttributesToMap().get("name")); + Assertions.assertEquals(2, ex.credentialAttributesToCredentialAttributesList().size()); + Assertions.assertEquals("555", ex.credentialAttributesToCredentialAttributesList().stream() + .filter(attr -> attr.getName().equals("name")).findFirst().get().getValue()); aeh.handleCredentialV2(received); ex = credExRepo.findById(ex.getId()).orElseThrow(); @@ -147,7 +152,9 @@ void testHandleIssuerSendCredentialHolderDeclines() throws IOException { issuer.issueCredential(IssueCredentialRequest.IssueLDCredentialRequest.builder() .schemaId(schemaAPI.getId()) .partnerId(p.getId()) - .document(conv.mapToNode(Map.of("name", "555", "identifier", "1234"))) + .document(new ArrayList<>(Arrays.asList( + new CredentialAttributes("name", "555", null), + new CredentialAttributes("identifier", "1234", null)))) .type(CredentialType.JSON_LD) .build()); @@ -188,9 +195,10 @@ void testHandleIssuerProposalReceived() throws IOException { Assertions.assertTrue(ex.stateIsProposalReceived()); Assertions.assertTrue(ex.typeIsJsonLd()); Assertions.assertEquals(ExchangeVersion.V2, ex.getExchangeVersion()); - Assertions.assertEquals(2, ex.proposalAttributesToMap().size()); - Assertions.assertEquals("Name", ex.proposalAttributesToMap().get("name")); - Assertions.assertEquals(0, ex.offerAttributesToMap().size()); + Assertions.assertEquals(2, ex.proposalAttributesToCredentialAttributesList().size()); + Assertions.assertEquals("Name", ex.credentialAttributesToCredentialAttributesList().stream() + .filter(attr -> attr.getName().equals("name")).findFirst().get().getValue()); + Assertions.assertEquals(0, ex.offerAttributesToCredentialAttributesList().size()); CredentialOfferRequest req = new CredentialOfferRequest(); req.setAcceptProposal(Boolean.TRUE); @@ -206,8 +214,9 @@ void testHandleIssuerProposalReceived() throws IOException { ex = loadCredEx(id); Assertions.assertTrue(ex.stateIsCredentialIssued()); - Assertions.assertEquals(2, ex.credentialAttributesToMap().size()); - Assertions.assertEquals("Other Name", ex.credentialAttributesToMap().get("name")); + Assertions.assertEquals(2, ex.credentialAttributesToCredentialAttributesList().size()); + Assertions.assertEquals("Other Name", ex.credentialAttributesToCredentialAttributesList().stream() + .filter(attr -> attr.getName().equals("name")).findFirst().get().getValue()); } @Test diff --git a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/jsonld/VPManagerTest.java b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/jsonld/VPManagerTest.java index 5d582e122..659147fb0 100644 --- a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/jsonld/VPManagerTest.java +++ b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/aries/jsonld/VPManagerTest.java @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import org.hyperledger.aries.api.credentials.Credential; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.jsonld.VerifiableCredential; import org.hyperledger.aries.config.GsonConfig; import org.hyperledger.bpa.api.CredentialType; @@ -75,8 +76,9 @@ void setup() { @Test void testBuildFromDocumentOrg() throws Exception { - String json = "{\"id\":\"did:sov:sadfafs\",\"type\":\"LegalEntity\"}"; - final Map d = createMap(json); + List d = new ArrayList<>(Arrays.asList( + new CredentialAttributes("id", "did:sov:sadfafs", null), + new CredentialAttributes("type", "LegalEntity", null))); MyDocument doc = buildDefault() .setType(CredentialType.ORGANIZATIONAL_PROFILE_CREDENTIAL) @@ -91,8 +93,9 @@ void testBuildFromDocumentOrg() throws Exception { @Test void testBuildFromDocumentIndyNoSchema() throws Exception { - String json = "{\"iban\":\"1234\",\"bic\":\"4321\"}"; - final Map d = createMap(json); + List d = new ArrayList<>(Arrays.asList( + new CredentialAttributes("iban", "1234", null), + new CredentialAttributes("bic", "4321", null))); MyDocument doc = buildDefault() .setType(CredentialType.INDY) @@ -109,8 +112,9 @@ void testBuildFromDocumentIndyNoSchema() throws Exception { @Test void testBuildFromDocumentIndyWithSchema() throws Exception { - String json = "{\"key1\":\"1234\",\"key2\":\"4321\"}"; - final Map d = createMap(json); + List d = new ArrayList<>(Arrays.asList( + new CredentialAttributes("key1", "1234", null), + new CredentialAttributes("key2", "4321", null))); Set attributeNames = new LinkedHashSet<>(); attributeNames.add("key1"); diff --git a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/util/ConverterTest.java b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/util/ConverterTest.java index fefa25aa5..25429c4df 100644 --- a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/util/ConverterTest.java +++ b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/impl/util/ConverterTest.java @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.JsonNode; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import jakarta.inject.Inject; +import org.hyperledger.aries.api.credentials.CredentialAttributes; import org.hyperledger.aries.api.jsonld.VerifiableCredential.VerifiableIndyCredential; import org.hyperledger.aries.api.jsonld.VerifiablePresentation; import org.hyperledger.bpa.BaseTest; @@ -130,7 +131,7 @@ void testConvertCredentialToModelObject() throws Exception { assertEquals(c.getType(), result.getType()); assertEquals(c.getIsPublic(), result.getIsPublic()); assertNotNull(result.getDocument()); - assertTrue(result.getDocument().containsValue("Hello")); + assertTrue(result.getDocument().stream().map(CredentialAttributes::getValue).toList().contains("Hello")); assertEquals(c.getIsPublic(), result.getIsPublic()); assertNull(result.getCreatedAt()); assertNotEquals(c.getId(), result.getId()); diff --git a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/persistence/repository/BPASchemaRepositoryTest.java b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/persistence/repository/BPASchemaRepositoryTest.java index f5974b351..b767cdb0d 100644 --- a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/persistence/repository/BPASchemaRepositoryTest.java +++ b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/persistence/repository/BPASchemaRepositoryTest.java @@ -23,6 +23,7 @@ import org.hyperledger.bpa.persistence.model.BPASchema; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; + import java.util.List; @MicronautTest diff --git a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/persistence/repository/IssuerCredExRepositoryTest.java b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/persistence/repository/IssuerCredExRepositoryTest.java index e97a239da..5236aa3c7 100644 --- a/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/persistence/repository/IssuerCredExRepositoryTest.java +++ b/backend/business-partner-agent/src/test/java/org/hyperledger/bpa/persistence/repository/IssuerCredExRepositoryTest.java @@ -29,6 +29,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.util.List; import java.util.Map; import java.util.UUID; @@ -58,12 +59,13 @@ void testUpdateCredential() { .build()); issuerCredExRepo.updateCredential(exchange.getId(), Credential.builder() - .attrs(Map.of("attr1", "val1")) + .attrs(List.of(new CredentialAttributes("attr1", "val1", null))) .build()); exchange = issuerCredExRepo.findById(exchange.getId()).orElseThrow(); Assertions.assertNotNull(exchange.getIndyCredential()); - Assertions.assertEquals("val1", exchange.getIndyCredential().getAttrs().get("attr1")); + Assertions.assertEquals("val1", exchange.getIndyCredential().getAttrs().stream() + .filter(attr -> attr.getName().equals("attr1")).findFirst().get().getValue()); } @Test diff --git a/frontend/backend-types.ts b/frontend/backend-types.ts index 908dddaa7..cd5a9e3db 100644 --- a/frontend/backend-types.ts +++ b/frontend/backend-types.ts @@ -423,7 +423,7 @@ export interface components { type?: components["schemas"]["CredentialType"]; label?: string; typeLabel?: string; - credentialData?: { [key: string]: string }; + credentialData?: components["schemas"]["CredentialAttributes"][]; }; AriesProofExchange: { /** Format: uuid */ @@ -557,7 +557,7 @@ export interface components { partner?: components["schemas"]["PartnerAPI"]; schemaId?: string; credentialDefinitionId?: string; - proposal?: { [key: string]: string }; + proposal?: components["schemas"]["CredentialAttributes"][]; credential?: components["schemas"]["Credential"]; role?: components["schemas"]["CredentialExchangeRole"]; state?: components["schemas"]["CredentialExchangeState"]; @@ -572,13 +572,18 @@ export interface components { credDef?: components["schemas"]["CredDef"]; }; Credential: { - attrs?: { [key: string]: string }; + attrs?: components["schemas"]["CredentialAttributes"][]; credentialDefinitionId?: string; credRevId?: string; referent?: string; revRegId?: string; schemaId?: string; }; + CredentialAttributes: { + mimeType: string; + name: string; + value: string; + }; /** @enum {string} */ CredentialExchangeRole: "ISSUER" | "HOLDER"; /** @enum {string} */ @@ -601,7 +606,7 @@ export interface components { acceptProposal?: boolean; credDefId?: string; schemaId?: string; - attributes: { [key: string]: string }; + attributes: components["schemas"]["CredentialAttributes"][]; }; /** @enum {string} */ CredentialType: "ORGANIZATIONAL_PROFILE_CREDENTIAL" | "INDY" | "JSON_LD"; @@ -686,11 +691,8 @@ export interface components { partnerId: string; /** @description credential exchange type */ type?: unknown; - /** - * @description credential body key value pairs - * @example {} - */ - document?: { [key: string]: unknown }[]; + /** @description Attribute array with name, value, mime-type */ + document?: components["schemas"]["CredentialAttributes"][]; }; // @ts-ignore "IssueCredentialRequest.IssueIndyCredentialRequest": components["schemas"]["IssueCredentialRequest"] & { @@ -714,7 +716,7 @@ export interface components { * @description credential body key value pairs * @example {} */ - document?: { [key: string]: unknown }[]; + document?: components["schemas"]["CredentialAttributes"][]; exchangeVersion?: components["schemas"]["ExchangeVersion"]; }; JsonArray: components["schemas"]["JsonElement"] & { @@ -872,7 +874,7 @@ export interface components { isPublic?: boolean; label?: string; /** @example {} */ - documentData?: { [key: string]: unknown }[]; + documentData?: components["schemas"]["CredentialAttributes"][]; }; Number: { [key: string]: unknown }; Object: { [key: string]: unknown }; @@ -1085,7 +1087,7 @@ export interface components { credentialLabel?: string; referent?: string; revoked?: boolean; - attrs?: { [key: string]: string }; + attrs?: components["schemas"]["CredentialAttributes"][]; schemaId?: string; schemaLabel?: string; credentialDefinitionId?: string; @@ -1436,7 +1438,7 @@ export interface components { isPublic?: boolean; label?: string; /** @example {} */ - document?: { [key: string]: unknown }[]; + document?: components["schemas"]["CredentialAttributes"][]; }; }; } @@ -2206,7 +2208,7 @@ export interface operations { /** schema id */ schemaId?: string | null; /** Filter Partners by connection state */ - showInvitations: boolean; + showInvitations?: boolean | null; }; }; responses: {