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

Commit

Permalink
fixed blank credential parsing when schema_id is set
Browse files Browse the repository at this point in the history
Signed-off-by: wadeking98 <[email protected]>
  • Loading branch information
wadeking98 committed Apr 21, 2022
1 parent ba7926e commit 650a95a
Showing 1 changed file with 18 additions and 17 deletions.
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

0 comments on commit 650a95a

Please sign in to comment.