Skip to content

Commit

Permalink
feat: Add local default contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Dec 10, 2021
1 parent 5c18dc2 commit da29f02
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/vc-handler-ld-local/src/ld-default-contexts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as fs from 'fs'
import * as path from 'path'
import { ContextDoc } from './types/types'

async function _read(_path: string): Promise<ContextDoc> {
const contextDefinition = await fs.promises.readFile(path.join(__dirname, '../contexts', _path), {
encoding: 'utf8',
})
return JSON.parse(contextDefinition)
}

/**
* Provides a hardcoded map of common context definitions
*/
export const LdDefaultContexts = new Map([
['https://www.w3.org/2018/credentials/v1', _read('w3_2018_credentials_v1.jsonld')],
['https://www.w3.org/ns/did/v1', _read('security_context_v1.jsonld')],
['https://w3id.org/did/v0.11', _read('did_v0.11.jsonld')],

['https://veramo.io/contexts/socialmedia/v1', _read('socialmedia-v1.jsonld')],
['https://veramo.io/contexts/kyc/v1', _read('kyc-v1.jsonld')],
['https://veramo.io/contexts/profile/v1', _read('profile-v1.jsonld')],
['https://ns.did.ai/transmute/v1', _read('transmute_v1.jsonld')],
[
'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld',
_read('lds-ecdsa-secp256k1-recovery2020-0.0.jsonld'),
],
['https://w3id.org/security/suites/ed25519-2018/v1', _read('ed25519-signature-2018-v1.jsonld')],
['https://w3id.org/security/suites/x25519-2019/v1', _read('X25519KeyAgreementKey2019.jsonld')],
['https://w3id.org/security/suites/ed25519-2020/v1', _read('ed25519-signature-2020-v1.jsonld')],
])

0 comments on commit da29f02

Please sign in to comment.