Skip to content

Commit

Permalink
add custom context
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-basiuk committed Sep 5, 2024
1 parent b1535cc commit 7959ede
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/credentials/credential-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
CredentialStatus,
RevocationStatus,
CredentialStatusType,
State
State,
DisplayMethodType
} from './../verifiable';

import { JSONSchema } from '../schema-processor';
Expand Down Expand Up @@ -265,14 +266,21 @@ export class CredentialWallet implements ICredentialWallet {
if (!schema.$metadata.uris['jsonLdContext']) {
throw new Error('jsonLdContext is missing is the schema');
}
if (!request.context) {
request.context = [];
}
if (
request.displayMethod?.type === DisplayMethodType.Iden3BasicDisplayMethodV1 &&
!request.context.includes(VerifiableConstants.JSONLD_SCHEMA.IDEN3_BASIC_DISPLAY_METHOD_V1)
) {
request.context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN3_BASIC_DISPLAY_METHOD_V1);
}
const context = [
...request.context,
VerifiableConstants.JSONLD_SCHEMA.W3C_CREDENTIAL_2018,
VerifiableConstants.JSONLD_SCHEMA.IDEN3_CREDENTIAL
VerifiableConstants.JSONLD_SCHEMA.IDEN3_CREDENTIAL,
schema.$metadata.uris['jsonLdContext']
];
if (request.displayMethod) {
context.push(VerifiableConstants.JSONLD_SCHEMA.IDEN3_BASIC_DISPLAY_METHOD_V1);
}
context.push(schema.$metadata.uris['jsonLdContext']);

const credentialType = [
VerifiableConstants.CREDENTIAL_TYPE.W3C_VERIFIABLE_CREDENTIAL,
Expand Down
4 changes: 4 additions & 0 deletions src/credentials/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export interface CredentialRequest {
* displayMethod
*/
displayMethod?: DisplayMethod;
/**
* optional custrom context (for not iden3 refres service or display method)
*/
context?: string[];
/**
* claim version
*/
Expand Down

0 comments on commit 7959ede

Please sign in to comment.