Skip to content

Commit

Permalink
Add linkedDomain context
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Oct 17, 2024
1 parent 10c3b05 commit 40d9258
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 29 deletions.
61 changes: 32 additions & 29 deletions src/services/identity/agent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
import type { CheqdNetwork } from '@cheqd/sdk';
import type { ICheqdCreateLinkedResourceArgs } from '@cheqd/did-provider-cheqd';
import type { TPublicKeyEd25519 } from '@cheqd/did-provider-cheqd';
import type {
ResourcePayload,
ICheqdBroadcastStatusList2021Args,
ICheqdCheckCredentialStatusWithStatusList2021Args,
ICheqdCreateStatusList2021Args,
ICheqdDeactivateIdentifierArgs,
ICheqdRevokeBulkCredentialsWithStatusList2021Args,
ICheqdUpdateIdentifierArgs,
ICheqdVerifyCredentialWithStatusList2021Args,
ICheqdVerifyPresentationWithStatusList2021Args,
PaymentCondition,
} from '@cheqd/did-provider-cheqd';
import type { VerificationOptions } from '../../types/shared.js';
import type { FeePaymentOptions } from '../../types/credential-status.js';
import type { CredentialRequest } from '../../types/credential.js';
import type { CheckStatusListOptions } from '../../types/credential-status.js';
import type { RevocationStatusOptions, StatusOptions, SuspensionStatusOptions } from '../../types/credential-status.js';
import type {
BroadcastStatusListOptions,
CreateUnencryptedStatusListOptions,
UpdateUnencryptedStatusListOptions,
CreateEncryptedStatusListOptions,
UpdateEncryptedStatusListOptions,
SearchStatusListResult,
} from '../../types/credential-status.js';
import {
createAgent,
CredentialPayload,
Expand Down Expand Up @@ -34,16 +62,6 @@ import {
Cheqd,
getResolver as CheqdDidResolver,
DefaultResolverUrl,
type ResourcePayload,
type ICheqdBroadcastStatusList2021Args,
type ICheqdCheckCredentialStatusWithStatusList2021Args,
type ICheqdCreateStatusList2021Args,
type ICheqdDeactivateIdentifierArgs,
type ICheqdRevokeBulkCredentialsWithStatusList2021Args,
type ICheqdUpdateIdentifierArgs,
type ICheqdVerifyCredentialWithStatusList2021Args,
type ICheqdVerifyPresentationWithStatusList2021Args,
type PaymentCondition,
DefaultStatusList2021ResourceTypes,
DefaultStatusList2021StatusPurposeTypes,
DefaultStatusList2021Encodings,
Expand All @@ -55,30 +73,15 @@ import {
DefaultStatusList2021StatusPurposeType,
TransactionResult,
} from '@cheqd/did-provider-cheqd';
import type { CheqdNetwork } from '@cheqd/sdk';
import { jwtDecode } from 'jwt-decode';
import { SupportedKeyTypes } from '@veramo/utils';
import { getDidKeyResolver as KeyDidResolver } from '@veramo/did-provider-key';
import { Resolver, ResolverRegistry } from 'did-resolver';
import { DefaultDidUrlPattern, CreateAgentRequest, VeramoAgent } from '../../types/shared.js';
import type { VerificationOptions } from '../../types/shared.js';
import type { FeePaymentOptions } from '../../types/credential-status.js';
import type { CredentialRequest } from '../../types/credential.js';
import { DefaultStatusActions } from '../../types/credential-status.js';
import type { CheckStatusListOptions } from '../../types/credential-status.js';
import type { RevocationStatusOptions, StatusOptions, SuspensionStatusOptions } from '../../types/credential-status.js';
import type {
BroadcastStatusListOptions,
CreateUnencryptedStatusListOptions,
UpdateUnencryptedStatusListOptions,
CreateEncryptedStatusListOptions,
UpdateEncryptedStatusListOptions,
SearchStatusListResult,
} from '../../types/credential-status.js';
import { MINIMAL_DENOM, VC_PROOF_FORMAT, VC_REMOVE_ORIGINAL_FIELDS } from '../../types/constants.js';
import { toCoin, toDefaultDkg, toMinimalDenom } from '../../helpers/helpers.js';
import { jwtDecode } from 'jwt-decode';
import type { ICheqdCreateLinkedResourceArgs } from '@cheqd/did-provider-cheqd';
import type { TPublicKeyEd25519 } from '@cheqd/did-provider-cheqd';
import { SupportedKeyTypes } from '@veramo/utils';
import { customContexts } from '../../types/context.js';

// dynamic import to avoid circular dependency
const VeridaResolver =
Expand Down Expand Up @@ -151,7 +154,7 @@ export class Veramo {
plugins.push(
new CredentialPlugin(),
new CredentialIssuerLD({
contextMaps: [LdDefaultContexts],
contextMaps: [LdDefaultContexts, customContexts],
suites: [
new VeramoJsonWebSignature2020(),
new VeramoEd25519Signature2018(),
Expand Down
15 changes: 15 additions & 0 deletions src/types/context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const customContexts = {
'https://identity.foundation/.well-known/did-configuration/v1': {
'@context': [
{
'@version': 1.1,
'@protected': true,
LinkedDomains: 'https://identity.foundation/.well-known/resources/did-configuration/#LinkedDomains',
DomainLinkageCredential:
'https://identity.foundation/.well-known/resources/did-configuration/#DomainLinkageCredential',
origin: 'https://identity.foundation/.well-known/resources/did-configuration/#origin',
linked_dids: 'https://identity.foundation/.well-known/resources/did-configuration/#linked_dids',
},
],
},
};

0 comments on commit 40d9258

Please sign in to comment.