@veramo/credential-ld 3.1.1-next.8 → 3.1.2-next.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/build/action-handler.js +2 -2
  2. package/build/action-handler.js.map +1 -1
  3. package/build/ld-context-loader.d.ts +2 -2
  4. package/build/ld-context-loader.d.ts.map +1 -1
  5. package/build/ld-context-loader.js +9 -2
  6. package/build/ld-context-loader.js.map +1 -1
  7. package/build/ld-credential-module.d.ts +3 -3
  8. package/build/ld-credential-module.d.ts.map +1 -1
  9. package/build/ld-credential-module.js +27 -7
  10. package/build/ld-credential-module.js.map +1 -1
  11. package/build/ld-default-contexts.d.ts +5 -1
  12. package/build/ld-default-contexts.d.ts.map +1 -1
  13. package/build/ld-default-contexts.js +21 -3
  14. package/build/ld-default-contexts.js.map +1 -1
  15. package/build/tsdoc-metadata.json +1 -1
  16. package/build/types.d.ts +12 -0
  17. package/build/types.d.ts.map +1 -1
  18. package/contexts/X25519KeyAgreementKey2019.jsonld +26 -0
  19. package/contexts/did_v0.11.jsonld +58 -0
  20. package/contexts/ed25519-signature-2018-v1.jsonld +91 -0
  21. package/contexts/kyc-v1.jsonld +8 -0
  22. package/contexts/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld +60 -0
  23. package/contexts/profile-v1.jsonld +8 -0
  24. package/contexts/security_context_v1.jsonld +58 -0
  25. package/contexts/socialmedia-v1.jsonld +7 -0
  26. package/contexts/transmute_v1.jsonld +21 -0
  27. package/contexts/w3_2018_credentials_v1.jsonld +237 -0
  28. package/package.json +14 -13
  29. package/plugin.schema.json +10 -0
  30. package/src/__tests__/context.loader.test.ts +39 -0
  31. package/src/__tests__/issue-verify-flow.test.ts +84 -0
  32. package/src/action-handler.ts +2 -2
  33. package/src/ld-context-loader.ts +7 -6
  34. package/src/ld-credential-module.ts +25 -5
  35. package/src/ld-default-contexts.ts +13 -4
  36. package/src/types.ts +15 -1
@@ -1,16 +1,25 @@
1
1
  import * as fs from 'fs'
2
2
  import * as path from 'path'
3
+ import { ContextDoc } from './types'
3
4
 
4
- function _read(_path: string) {
5
- return JSON.parse(fs.readFileSync(path.join(__dirname, '../contexts', _path), { encoding: 'utf8' }))
5
+ async function _read(_path: string): Promise<ContextDoc> {
6
+ const contextDefinition = await fs.promises.readFile(path.join(__dirname, '../contexts', _path), {
7
+ encoding: 'utf8',
8
+ })
9
+ return JSON.parse(contextDefinition)
6
10
  }
7
11
 
12
+ /**
13
+ * Provides a hardcoded map of common context definitions
14
+ */
8
15
  export const LdDefaultContexts = new Map([
16
+ ['https://www.w3.org/2018/credentials/v1', _read('w3_2018_credentials_v1.jsonld')],
17
+ ['https://www.w3.org/ns/did/v1', _read('security_context_v1.jsonld')],
18
+ ['https://w3id.org/did/v0.11', _read('did_v0.11.jsonld')],
19
+
9
20
  ['https://veramo.io/contexts/socialmedia/v1', _read('socialmedia-v1.jsonld')],
10
21
  ['https://veramo.io/contexts/kyc/v1', _read('kyc-v1.jsonld')],
11
22
  ['https://veramo.io/contexts/profile/v1', _read('profile-v1.jsonld')],
12
- ['https://www.w3.org/ns/did/v1', _read('security_context_v1.jsonld')],
13
- ['https://w3id.org/did/v0.11', _read('did_v0.11.jsonld')],
14
23
  ['https://ns.did.ai/transmute/v1', _read('transmute_v1.jsonld')],
15
24
  [
16
25
  'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld',
package/src/types.ts CHANGED
@@ -160,7 +160,14 @@ export interface IVerifyCredentialLDArgs {
160
160
  * of the `credential`
161
161
  *
162
162
  */
163
- credential: VerifiableCredential
163
+ credential: VerifiableCredential,
164
+
165
+ /**
166
+ * Set this to true if you want the '@context' URLs to be fetched in case they are not pre-loaded.
167
+ *
168
+ * @default false
169
+ */
170
+ fetchRemoteContexts?: boolean
164
171
  }
165
172
 
166
173
  /**
@@ -189,6 +196,13 @@ export interface IVerifyPresentationLDArgs {
189
196
  * Optional (only for JWT) string domain parameter to verify the verifiable presentation against
190
197
  */
191
198
  domain?: string
199
+
200
+ /**
201
+ * Set this to true if you want the '@context' URLs to be fetched in case they are not pre-loaded.
202
+ *
203
+ * @default false
204
+ */
205
+ fetchRemoteContexts?: boolean
192
206
  }
193
207
 
194
208
  /**