Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
jsonld-document-loader
Advanced tools
Changelog
2.0.0 - 2023-02-06
c8@7.12.0
for coverage.Readme
A document loader API for jsonld.js.
TBD
TBD
To install via NPM:
npm install --save jsonld-document-loader
To install locally (for development):
git clone https://github.com/digitalbazaar/jsonld-document-loader.git
cd jsonld-document-loader
npm install
import {JsonLdDocumentLoader} from 'jsonld-document-loader';
const loader = new JsonLdDocumentLoader();
addStatic()
The addStatic()
method allows developers to load fixed static contexts and
documents, to ensure known versions and contents, without going out to the
network.
For example, to add support for the DID Core context, the VC context, and crypto suite specific contexts:
import cred from 'credentials-context';
import didContext from 'did-context';
import ed25519Ctx from 'ed25519-signature-2020-context';
const {contexts: credentialsContexts, constants: {CREDENTIALS_CONTEXT_V1_URL}} =
cred;
const jdl = new JsonLdDocumentLoader();
jdl.addStatic(ed25519Ctx.CONTEXT_URL, ed25519Ctx.CONTEXT);
jdl.addStatic(
didContext.constants.DID_CONTEXT_URL,
didContext.contexts.get(didContext.constants.DID_CONTEXT_URL)
);
jdl.addStatic(
CREDENTIALS_CONTEXT_V1_URL,
credentialsContexts.get(CREDENTIALS_CONTEXT_V1_URL)
);
const documentLoader = jdl.build();
// Pass to jsonld, jsonld-signatures, vc-js and similar libraries
setDidResolver()
To add support for resolving DIDs and DID-related key ids:
import * as didKey from '@digitalbazaar/did-method-key';
import {CachedResolver} from '@digitalbazaar/did-io';
const cachedResolver = new CachedResolver();
const jdl = new JsonLdDocumentLoader();
cachedResolver.use(didKey.driver());
jdl.setDidResolver(cachedResolver);
// Now you can resolve did:key type DIDs and key objects
const verificationKeyId = 'did:key:z6MkuBLrjSGt1PPADAvuv6rmvj4FfSAfffJotC6K8ZEorYmv#z6MkuBLrjSGt1PPADAvuv6rmvj4FfSAfffJotC6K8ZEorYmv';
await jdl.documentLoader(verificationKeyId);
// ->
{
documentUrl: 'did:key:z6MkuBLrjSGt1PPADAvuv6rmvj4FfSAfffJotC6K8ZEorYmv#z6MkuBLrjSGt1PPADAvuv6rmvj4FfSAfffJotC6K8ZEorYmv',
document: {
"@context": "https://w3id.org/security/suites/ed25519-2020/v1",
"type": "Ed25519VerificationKey2020",
"controller": "did:key:z6MkuBLrjSGt1PPADAvuv6rmvj4FfSAfffJotC6K8ZEorYmv",
"publicKeyMultibase": "zFj5p9C2Sfqth6g6DEXtw5dWFqrtpFn4TCBBPJHGnwKzY",
// ...
}
}
setProtocolHandler()
You can also add support for a custom protocol handler:
const customHandler = {
get({url}) {
// return document
}
}
jdl.setProtocolHandler({protocol: 'ipfs', handler: customHandler});
See the contribute file!
PRs accepted.
If editing the Readme, please conform to the standard-readme specification.
Commercial support for this library is available upon request from Digital Bazaar: support@digitalbazaar.com
New BSD License (3-clause) © Digital Bazaar
FAQs
A document loader API for jsonld.js.
The npm package jsonld-document-loader receives a total of 1,021 weekly downloads. As such, jsonld-document-loader popularity was classified as popular.
We found that jsonld-document-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.