Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

fixed blank credential parsing when schema_id is set #367

Merged
merged 1 commit into from
Apr 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions api/src/services/credential-exchange/credential-exchange.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,25 @@ export class CredentialExchange implements ServiceSwaggerAddon {
);
}
schema_id = default_schema.schema_id || default_schema.schema.id;

//allows blank attributes to be supplied in isser-web/admin
const schemaChunks = schema_id.split(':');
const schemaVersion = schemaChunks[schemaChunks.length - 1];
const schemaName = schemaChunks[schemaChunks.length - 2];
const schemaAttributes = getSchemaAttrsByID(schemaName, schemaVersion);
const requestAttributes = data.claims.map((claim) => claim.name);

//take the set difference
const diff = schemaAttributes.filter(attr => !requestAttributes.includes(attr));
const diffAttrs = diff.map((attr) =>
({
name: attr,
value: "",
"mime-type": "text/plain",
} as AriesCredentialAttribute));
attributes.push(...diffAttrs);
}

//allows blank attributes to be supplied in isser-web/admin
const schemaChunks = schema_id.split(':');
const schemaVersion = schemaChunks[schemaChunks.length - 1];
const schemaName = schemaChunks[schemaChunks.length - 2];
const schemaAttributes = getSchemaAttrsByID(schemaName, schemaVersion);
const requestAttributes = data.claims.map((claim) => claim.name);

//take the set difference
const diff = schemaAttributes.filter(attr => !requestAttributes.includes(attr));
const diffAttrs = diff.map((attr) =>
({
name: attr,
value: "",
"mime-type": "text/plain",
} as AriesCredentialAttribute));
attributes.push(...diffAttrs);

const cred_def_id = this.app.get("credDefs").get(schema_id) as string;

const credentialOffer = formatCredentialOffer(
Expand Down