@interop/security-document-loader 9.0.0
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.
- package/LICENSE.md +21 -0
- package/README.md +135 -0
- package/dist/documentLoader.d.ts +31 -0
- package/dist/documentLoader.d.ts.map +1 -0
- package/dist/documentLoader.js +91 -0
- package/dist/documentLoader.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/parseResponse.d.ts +2 -0
- package/dist/parseResponse.d.ts.map +1 -0
- package/dist/parseResponse.js +7 -0
- package/dist/parseResponse.js.map +1 -0
- package/package.json +88 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Digital Credentials Consortium
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# JSON-LD Document Loader _(interop/security-document-loader)_
|
|
2
|
+
|
|
3
|
+
[](https://github.com/interop-alliance/security-document-loader/actions?query=workflow%3A%22CI%22)
|
|
4
|
+
[](https://npm.im/@interop/security-document-loader)
|
|
5
|
+
|
|
6
|
+
> A secure and convenient JSON-LD document loader for Node.js, browsers, and React Native.
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Background](#background)
|
|
11
|
+
- [Security](#security)
|
|
12
|
+
- [Install](#install)
|
|
13
|
+
- [Usage](#usage)
|
|
14
|
+
- [Contribute](#contribute)
|
|
15
|
+
- [License](#license)
|
|
16
|
+
|
|
17
|
+
## Background
|
|
18
|
+
|
|
19
|
+
Included functionality:
|
|
20
|
+
|
|
21
|
+
* Bundled contexts:
|
|
22
|
+
- DID, VC 1.0, DCC, Open Badges v3, ed25519 and x25519 crypto suite contexts
|
|
23
|
+
* DID resolver for `did:key` and `did:web`
|
|
24
|
+
* Optional loading of arbitrary contexts from the web (see Usage).
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
- Node.js 20+ is recommended.
|
|
29
|
+
|
|
30
|
+
### NPM
|
|
31
|
+
|
|
32
|
+
To install via NPM:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
npm install @interop/security-document-loader
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Development
|
|
39
|
+
|
|
40
|
+
To install locally (for development):
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
git clone https://github.com/interop-alliance/security-document-loader.git
|
|
44
|
+
cd security-document-loader
|
|
45
|
+
npm install
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
To get a default document loader (with the stock set of bundled contexts):
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import { securityLoader } from '@interop/security-document-loader'
|
|
54
|
+
|
|
55
|
+
const documentLoader = securityLoader().build()
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
To add additional contexts:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
import { securityLoader } from 'interop/security-document-loader'
|
|
62
|
+
|
|
63
|
+
const loader = securityLoader()
|
|
64
|
+
loader.addStatic('https://example.com/my-context/v1', contextObject)
|
|
65
|
+
|
|
66
|
+
const documentLoader = loader.build()
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Fetching From the Web
|
|
70
|
+
To enable fetching arbitrary contexts from the web (not recommended, if you can
|
|
71
|
+
avoid it):
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
const documentLoader = securityLoader({ fetchRemoteContexts: true }).build()
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Supported URL Protocol Handlers
|
|
78
|
+
|
|
79
|
+
Out of the box, this library supports loading the following documents:
|
|
80
|
+
|
|
81
|
+
* Explicitly added URLs from static local caches (that is, ones that you
|
|
82
|
+
explicitly add via `loader.addStatic`)
|
|
83
|
+
* DID Documents using the `did:key` and `did:web` methods.
|
|
84
|
+
|
|
85
|
+
Additionally, if your use case allows it, you can enable `fetchRemoteContexts`,
|
|
86
|
+
which will add support for URLs using the `http` and `https` protocols (see
|
|
87
|
+
previous section).
|
|
88
|
+
|
|
89
|
+
#### Adding Custom Protocol Handlers
|
|
90
|
+
Sometimes you will need to add documents with other URL protocols. If you have
|
|
91
|
+
internal code to resolve those protocols (for example, you can fetch some
|
|
92
|
+
`urn:` documents from a local database), you can write a custom protocol
|
|
93
|
+
handler:
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
import { securityLoader } from 'interop/security-document-loader'
|
|
97
|
+
|
|
98
|
+
function getDocument (url) {
|
|
99
|
+
// Some internal function that fetches or creates documents
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const customResolver = {
|
|
103
|
+
/**
|
|
104
|
+
* @param {object} options - Options hashmap.
|
|
105
|
+
* @param {string} options.url - Document URL (here `urn:...` key id)
|
|
106
|
+
* @returns {Promise<object>} - Resolves with key object document.
|
|
107
|
+
*/
|
|
108
|
+
async get(params: Record<string, string>): Promise<unknown> {
|
|
109
|
+
let document
|
|
110
|
+
try {
|
|
111
|
+
document = await getDocument(params.url)
|
|
112
|
+
} catch(e) {
|
|
113
|
+
throw new Error('NotFoundError')
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return document
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// For example, use your `getDocument` function to resolve all `urn:` URIs:
|
|
121
|
+
securityLoader.setProtocolHandler({protocol: 'urn', handler: customResolver})
|
|
122
|
+
|
|
123
|
+
const documentLoader = securityLoader().build()
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Contribute
|
|
127
|
+
|
|
128
|
+
PRs accepted.
|
|
129
|
+
|
|
130
|
+
If editing the Readme, please conform to the
|
|
131
|
+
[standard-readme](https://github.com/RichardLitt/standard-readme) specification.
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
[MIT License](LICENSE.md) © 2022 Digital Credentials Consortium.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const httpClientHandler: {
|
|
2
|
+
/**
|
|
3
|
+
* @param {object} options - Options hashmap.
|
|
4
|
+
* @param {string} options.url - Document URL.
|
|
5
|
+
* @returns {Promise<{contextUrl: null, document, documentUrl}>} - Resolves
|
|
6
|
+
* with documentLoader document.
|
|
7
|
+
*/
|
|
8
|
+
get(params: {
|
|
9
|
+
url: string;
|
|
10
|
+
}): Promise<unknown>;
|
|
11
|
+
};
|
|
12
|
+
declare interface IDocumentLoaderResult {
|
|
13
|
+
contextUrl?: string;
|
|
14
|
+
documentUrl?: string;
|
|
15
|
+
document: any;
|
|
16
|
+
}
|
|
17
|
+
type documentLoader = (url: string) => Promise<IDocumentLoaderResult>;
|
|
18
|
+
declare class IJsonLdDocumentLoader {
|
|
19
|
+
addStatic: (contextUrl: string, context: any) => void;
|
|
20
|
+
setDidResolver: any;
|
|
21
|
+
setProtocolHandler: any;
|
|
22
|
+
documentLoader: any;
|
|
23
|
+
build: () => documentLoader;
|
|
24
|
+
}
|
|
25
|
+
interface SecurityLoaderParams {
|
|
26
|
+
fetchRemoteContexts?: boolean;
|
|
27
|
+
useOBv3BetaContext?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare function securityLoader({ fetchRemoteContexts, useOBv3BetaContext }?: SecurityLoaderParams): IJsonLdDocumentLoader;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=documentLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentLoader.d.ts","sourceRoot":"","sources":["../src/documentLoader.ts"],"names":[],"mappings":"AA+BA,eAAO,MAAM,iBAAiB;IAC5B;;;;;OAKG;gBACe;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAiBrD,CAAC;AAEF,OAAO,WAAW,qBAAqB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,GAAG,CAAC;CACf;AAED,KAAK,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAEtE,OAAO,OAAO,qBAAqB;IACjC,SAAS,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACtD,cAAc,EAAE,GAAG,CAAC;IACpB,kBAAkB,EAAE,GAAG,CAAC;IACxB,cAAc,EAAE,GAAG,CAAC;IACpB,KAAK,EAAE,MAAM,cAAc,CAAC;CAC7B;AAED,UAAU,oBAAoB;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,wBAAgB,cAAc,CAAC,EAAE,mBAA2B,EAAE,kBAA0B,EAAE,GAAE,oBAAyB,GAAG,qBAAqB,CA6D5I"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2021 Interop Alliance and Dmitri Zagidulin. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { driver } from '@interop/did-method-key';
|
|
5
|
+
import * as didWeb from '@interop/did-web-resolver';
|
|
6
|
+
import * as vc2Context from '@digitalcredentials/credentials-v2-context';
|
|
7
|
+
import * as vcBitstringStatusListContext from '@digitalbazaar/vc-bitstring-status-list-context';
|
|
8
|
+
import vc1Context from 'credentials-context';
|
|
9
|
+
import vcStatusListContext from '@digitalbazaar/vc-status-list-context';
|
|
10
|
+
import dataIntegrityContext from '@digitalbazaar/data-integrity-context';
|
|
11
|
+
import { Ed25519VerificationKey } from '@interop/ed25519-verification-key';
|
|
12
|
+
import { CachedResolver } from '@interop/did-io';
|
|
13
|
+
import didContext from 'did-context';
|
|
14
|
+
import ed25519Context from 'ed25519-signature-2020-context';
|
|
15
|
+
import x25519Context from 'x25519-key-agreement-2020-context';
|
|
16
|
+
import zcapContext from '@digitalbazaar/zcap-context';
|
|
17
|
+
import { JsonLdDocumentLoader } from 'jsonld-document-loader';
|
|
18
|
+
import obContext from '@digitalcredentials/open-badges-context';
|
|
19
|
+
import { httpClient } from '@interop/http-client';
|
|
20
|
+
import { parseResponseBody } from './parseResponse.js';
|
|
21
|
+
const resolver = new CachedResolver();
|
|
22
|
+
const didKeyDriver = driver();
|
|
23
|
+
const didWebDriver = didWeb.driver();
|
|
24
|
+
resolver.use(didKeyDriver);
|
|
25
|
+
resolver.use(didWebDriver);
|
|
26
|
+
didWebDriver.use({ keyPairClass: Ed25519VerificationKey });
|
|
27
|
+
didKeyDriver.use({ keyPairClass: Ed25519VerificationKey });
|
|
28
|
+
export const httpClientHandler = {
|
|
29
|
+
/**
|
|
30
|
+
* @param {object} options - Options hashmap.
|
|
31
|
+
* @param {string} options.url - Document URL.
|
|
32
|
+
* @returns {Promise<{contextUrl: null, document, documentUrl}>} - Resolves
|
|
33
|
+
* with documentLoader document.
|
|
34
|
+
*/
|
|
35
|
+
async get(params) {
|
|
36
|
+
if (!params.url.startsWith('http')) {
|
|
37
|
+
throw new Error('NotFoundError');
|
|
38
|
+
}
|
|
39
|
+
let result;
|
|
40
|
+
try {
|
|
41
|
+
const headers = {
|
|
42
|
+
'Cache-Control': 'no-cache',
|
|
43
|
+
'Pragma': 'no-cache'
|
|
44
|
+
};
|
|
45
|
+
result = await httpClient.get(params.url, { headers, parseBody: false });
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
throw new Error(`NotFoundError loading "${params.url}": ${e.message}`, { cause: e });
|
|
49
|
+
}
|
|
50
|
+
return parseResponseBody(result);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export function securityLoader({ fetchRemoteContexts = false, useOBv3BetaContext = false } = {}) {
|
|
54
|
+
const loader = new JsonLdDocumentLoader();
|
|
55
|
+
// Ed25519 Signature 2020 Context
|
|
56
|
+
loader.addStatic(ed25519Context.constants.CONTEXT_URL, ed25519Context.contexts.get(ed25519Context.constants.CONTEXT_URL));
|
|
57
|
+
// X25519 Key Agreement 2020 Context
|
|
58
|
+
loader.addStatic(x25519Context.constants.CONTEXT_URL, x25519Context.contexts.get(x25519Context.constants.CONTEXT_URL));
|
|
59
|
+
// DID Context
|
|
60
|
+
loader.addStatic(didContext.constants.DID_CONTEXT_URL, didContext.contexts.get(didContext.constants.DID_CONTEXT_URL));
|
|
61
|
+
// Verifiable Credentials Data Model 1.0 Context
|
|
62
|
+
loader.addStatic(vc1Context.CONTEXT_URL, vc1Context.CONTEXT);
|
|
63
|
+
// Verifiable Credentials Data Model 2.0 Context - BETA / non-final
|
|
64
|
+
loader.addStatic(vc2Context.CONTEXT_URL, vc2Context.CONTEXT);
|
|
65
|
+
// Data Integrity Context
|
|
66
|
+
for (const [url, context] of dataIntegrityContext.contexts) {
|
|
67
|
+
loader.addStatic(url, context);
|
|
68
|
+
}
|
|
69
|
+
// Bitstring Status List Context
|
|
70
|
+
loader.addStatic(vcBitstringStatusListContext.CONTEXT_URL, vcBitstringStatusListContext.CONTEXT);
|
|
71
|
+
// Status List 2021 Context (DEPRECATED)
|
|
72
|
+
loader.addStatic(vcStatusListContext.CONTEXT_URL_V1, vcStatusListContext.CONTEXT_V1);
|
|
73
|
+
// zCap Context (Authorization Capabilities v0.3)
|
|
74
|
+
loader.addStatic(zcapContext.CONTEXT_URL, zcapContext.CONTEXT);
|
|
75
|
+
// Open Badges v3 Contexts, includes OBv3 Beta, 3.0, 3.0.1, 3.0.2, etc.
|
|
76
|
+
for (const [url, context] of obContext.contexts) {
|
|
77
|
+
loader.addStatic(url, context);
|
|
78
|
+
}
|
|
79
|
+
if (useOBv3BetaContext) {
|
|
80
|
+
// Workaround to validate legacy OBv3 BETA context VCs
|
|
81
|
+
loader.addStatic(obContext.CONTEXT_URL_V3_0_0, obContext.contexts.get(obContext.CONTEXT_URL_V3_BETA));
|
|
82
|
+
}
|
|
83
|
+
loader.setDidResolver(resolver);
|
|
84
|
+
// Enable loading of arbitrary contexts from web
|
|
85
|
+
if (fetchRemoteContexts) {
|
|
86
|
+
loader.setProtocolHandler({ protocol: 'http', handler: httpClientHandler });
|
|
87
|
+
loader.setProtocolHandler({ protocol: 'https', handler: httpClientHandler });
|
|
88
|
+
}
|
|
89
|
+
return loader;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=documentLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentLoader.js","sourceRoot":"","sources":["../src/documentLoader.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD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E,OAAO,EAAE,iBAAiB,EAAC,CAAC,CAAC;QAC1E,MAAM,CAAC,kBAAkB,CAAC,EAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAC,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseResponse.d.ts","sourceRoot":"","sources":["../src/parseResponse.ts"],"names":[],"mappings":"AAEA,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAI5F"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as HtmlEntities from 'html-entities';
|
|
2
|
+
export async function parseResponseBody(response) {
|
|
3
|
+
const responseText = await response.text();
|
|
4
|
+
const responseTextDecoded = HtmlEntities.decode(responseText);
|
|
5
|
+
return JSON.parse(responseTextDecoded);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=parseResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseResponse.js","sourceRoot":"","sources":["../src/parseResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,QAAkB;IACxD,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC3C,MAAM,mBAAmB,GAAG,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;AACzC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@interop/security-document-loader",
|
|
3
|
+
"description": "A secure and convenient JSON-LD document loader for Node.js, browsers, and React Native.",
|
|
4
|
+
"version": "9.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "pnpm run clear && tsc",
|
|
8
|
+
"clear": "rimraf dist/*",
|
|
9
|
+
"dev": "vite",
|
|
10
|
+
"fix": "eslint --fix src test && pnpm run format",
|
|
11
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
12
|
+
"lint": "eslint src test",
|
|
13
|
+
"prepare": "pnpm run build",
|
|
14
|
+
"rebuild": "pnpm run clear && pnpm run build",
|
|
15
|
+
"test": "pnpm run lint && pnpm run test-node && pnpm run test-browser",
|
|
16
|
+
"test-browser": "playwright test",
|
|
17
|
+
"test-node": "vitest run",
|
|
18
|
+
"test-coverage": "vitest run --coverage"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE.md"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"react-native": "./dist/index.js",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"module": "dist/index.js",
|
|
33
|
+
"browser": "dist/index.js",
|
|
34
|
+
"types": "dist/index.d.ts",
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@digitalbazaar/data-integrity-context": "^2.0.0",
|
|
38
|
+
"@digitalbazaar/vc-bitstring-status-list-context": "^1.0.0",
|
|
39
|
+
"@digitalbazaar/vc-status-list-context": "^3.0.1",
|
|
40
|
+
"@digitalbazaar/zcap-context": "^2.0.1",
|
|
41
|
+
"@digitalcredentials/credentials-v2-context": "^1.0.0",
|
|
42
|
+
"@interop/did-method-key": "^6.1.0",
|
|
43
|
+
"@interop/did-web-resolver": "^6.0.0",
|
|
44
|
+
"@interop/ed25519-verification-key": "^6.2.0",
|
|
45
|
+
"@digitalcredentials/open-badges-context": "^3.0.0",
|
|
46
|
+
"@interop/did-io": "^2.0.1",
|
|
47
|
+
"@interop/http-client": "^1.0.3",
|
|
48
|
+
"credentials-context": "^2.0.0",
|
|
49
|
+
"did-context": "^3.1.1",
|
|
50
|
+
"ed25519-signature-2020-context": "^1.1.0",
|
|
51
|
+
"html-entities": "^2.3.3",
|
|
52
|
+
"jsonld-document-loader": "^1.2.1",
|
|
53
|
+
"x25519-key-agreement-2020-context": "^1.0.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@eslint/js": "^10.0.1",
|
|
57
|
+
"@playwright/test": "^1.60.0",
|
|
58
|
+
"@types/node": "^24.0.0",
|
|
59
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
60
|
+
"eslint": "^10.4.0",
|
|
61
|
+
"eslint-config-prettier": "^10.1.8",
|
|
62
|
+
"globals": "^17.6.0",
|
|
63
|
+
"prettier": "^3.8.3",
|
|
64
|
+
"rimraf": "^6.1.3",
|
|
65
|
+
"typescript": "^5.5.0",
|
|
66
|
+
"typescript-eslint": "^8.59.4",
|
|
67
|
+
"vite": "^8.0.14",
|
|
68
|
+
"vitest": "^4.1.7"
|
|
69
|
+
},
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public"
|
|
72
|
+
},
|
|
73
|
+
"packageManager": "pnpm@11.3.0",
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": ">=24.0"
|
|
76
|
+
},
|
|
77
|
+
"author": {
|
|
78
|
+
"name": "Interop Alliance",
|
|
79
|
+
"url": "https://github.com/interop-alliance/"
|
|
80
|
+
},
|
|
81
|
+
"license": "MIT",
|
|
82
|
+
"repository": {
|
|
83
|
+
"type": "git",
|
|
84
|
+
"url": "https://github.com/interop-alliance/security-document-loader"
|
|
85
|
+
},
|
|
86
|
+
"homepage": "https://github.com/interop-alliance/security-document-loader",
|
|
87
|
+
"bugs": "https://github.com/interop-alliance/security-document-loader/issues"
|
|
88
|
+
}
|