How to use the jsonld-signatures.use function in jsonld-signatures

To help you get started, we’ve selected a few jsonld-signatures examples, based on popular ways it is used in public projects.

github digitalbazaar / did-cli / lib / driver-veres.js View on Github external
// setup JSON-LD library to use
const jsonld = require('jsonld')();
// Use the local Veres One context...
const _orig_doc_loader = jsonld.documentLoader;
jsonld.documentLoader = function(url, callback) {
    if (url == 'https://w3id.org/veres-one/v1') {
        return callback(null,
                        {contextUrl: null,
                         documentUrl: url,
                         document: v1_context});
    } else {
        return _orig_doc_loader(url, callback);
    }
};
jsigs.use('jsonld', jsonld);
equihashSigs.use('jsonld', jsonld);

const api = {};
module.exports = api;

api.create = options => {
  let did = 'did:v1:testnet:' + (options.did || uuid());
  let hostname = 'testnet.veres.one';

  if(options.mode === 'dev') {
    hostname = 'veres.one.local:42443';
    request = request.defaults({json: true, strictSSL: false});
  } else if(options.mode === 'live') {
    did = 'did:v1:' + (options.did || uuid());
    hostname = 'veres.one';
  }
github digitalbazaar / did-io / tests / veres-one / veres-one.spec.js View on Github external
const jsonld = v1.injector.use('jsonld');
    const documentLoader = jsonld.documentLoader;

    jsonld.documentLoader = async url => {
      if(url in VeresOne.contexts) {
        return {
          contextUrl: null,
          documentUrl: url,
          document: VeresOne.contexts[url]
        };
      }
      return documentLoader(url);
    };
    v1.injector.use('jsonld', jsonld);
    const jsigs = require('jsonld-signatures');
    jsigs.use('jsonld', jsonld);
    const eproofs = require('equihash-signature');
    eproofs.install(jsigs);
    v1.injector.use('jsonld-signatures', jsigs);

    v1.keyStore = Store.using('mock');
    v1.didStore = Store.using('mock');
    v1.metaStore = Store.using('mock');
  });

jsonld-signatures

An implementation of the Linked Data Signatures specifications for JSON-LD in JavaScript.

BSD-3-Clause
Latest version published 1 month ago

Package Health Score

79 / 100
Full package analysis

Similar packages