Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web-ledger-client

Package Overview
Dependencies
Maintainers
6
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web-ledger-client - npm Package Compare versions

Comparing version 4.0.0 to 6.0.0

.github/workflows/main.yml

5

CHANGELOG.md
# web-ledger-client ChangeLog
### 5.0.0 - 2021-07-23
### Changed
- **BREAKING**: Add ZCAP context to operation invocations.
### 4.0.0 - 2021-06-11

@@ -4,0 +9,0 @@

1

lib/constants.js

@@ -9,2 +9,3 @@ /*!

WEB_LEDGER_CONTEXT_V1_URL: 'https://w3id.org/webledger/v1',
ZCAP_CONTEXT_V1_URL: 'https://w3id.org/zcap/v1'
};

73

lib/WebLedgerClient.js

@@ -13,20 +13,24 @@ /*!

* A SSL capable HTTP Agent.
*
* @see https://nodejs.org/api/https.html
* @typedef {Object} Agent
* @typedef {object} Agent
*/
/* eslint-disable jsdoc/valid-types -- jsdoc can't parse @context and @id */
/**
* A Document used by the Ledger.
*
* @see https://w3c.github.io/json-ld-syntax/
* @see https://w3c-dvcg.github.io/ld-signatures/
* @typedef {Object} JSON-LD
* @typedef {object} JSON-LD
* @property {string} @context - Used to define the terms in the document.
* @property {string} @id - A unique id for the document.
*/
/* eslint-enable jsdoc/valid-types */
class WebLedgerClient {
/**
* @param {Object} options - Options for the WebLedgerClient.
* @param {object} options - Options for the WebLedgerClient.
* @param {string} options.hostname - The hostname of the ledger node.
* @param {Object} [options.logger] - The logger to use.
* @param {object} [options.logger] - The logger to use.
* @param {Agent} [options.httpsAgent] - A NodeJS HTTPS Agent (`https.Agent`)

@@ -53,6 +57,6 @@ * instance.

*
* @param {Object} options - Options for getRecord.
* @param {object} options - Options for getRecord.
* @param {string} options.id - The ID URI for the record.
*
* @returns {Promise<Object>} - The record object.
* @returns {Promise<object>} - The record object.
*/

@@ -122,7 +126,7 @@ async getRecord({id}) {

*
* @param {Object} options - Options for getDocument.
* @param {Object} [options.headers={}] - Headers for the request.
* @param {object} options - Options for getDocument.
* @param {object} [options.headers={}] - Headers for the request.
* @param {string} options.service - The name of the service to use.
*
* @returns {Promise<Object>} The requested document.
* @returns {Promise<object>} The requested document.
*/

@@ -163,3 +167,3 @@ async getDocument({headers = {}, service}) {

*
* @returns {Promise<Object>} The genesis block.
* @returns {Promise<object>} The genesis block.
*/

@@ -175,3 +179,3 @@ async getGenesisBlock() {

*
* @param {Object} options - The options to use.
* @param {object} options - The options to use.
* @param {string} options.serviceId - The ID for the service of interest.

@@ -197,6 +201,6 @@ *

*
* @param {Object} [options={}] - Options for getStatus.
* @param {Object} [options.headers = {}] - Headers for the request.
* @param {object} [options={}] - Options for getStatus.
* @param {object} [options.headers = {}] - Headers for the request.
*
* @returns {Promise<Object>} A document with a status.
* @returns {Promise<object>} A document with a status.
*/

@@ -229,6 +233,6 @@ async getStatus({headers = {}} = {}) {

*
* @param {Object} options - Options for sendConfig.
* @param {object} options - Options for sendConfig.
* @param {JSON-LD} options.ledgerConfiguration - Doc with config options.
*
* @returns {Promise<Object>} The result of the send.
* @returns {Promise<object>} The result of the send.
*/

@@ -243,9 +247,9 @@ async sendConfig({ledgerConfiguration}) {

*
* @param {Object} options - Options for sendDocument.
* @param {object} options - Options for sendDocument.
* @param {JSON-LD} options.document - A valid document for the ledger.
* @param {string} options.service - The name of a ledger service.
* @param {Object} [options.headers={}] - Headers for the request.
* @param {object} [options.headers={}] - Headers for the request.
* @throws {WebLedgerClientError}
*
* @returns {Promise<Object>} The result of the send.
* @returns {Promise<object>} The result of the send.
*/

@@ -287,7 +291,7 @@ async sendDocument({document, service, headers = {}}) {

*
* @param {Object} options - Options for this function.
* @param {Object} options.operation - The operation to send.
* @param {Object} [options.headers={}] - The headers for the request.
* @param {object} options - Options for this function.
* @param {object} options.operation - The operation to send.
* @param {object} [options.headers={}] - The headers for the request.
*
* @returns {Promise<Object>} A response object.
* @returns {Promise<object>} A response object.
*/

@@ -302,6 +306,6 @@ async sendOperation({operation, headers = {}}) {

*
* @param {Object} [options={}] - Options for getAgents.
* @param {Object} [options.headers={}] - The headers for the request.
* @param {object} [options={}] - Options for getAgents.
* @param {object} [options.headers={}] - The headers for the request.
*
* @returns {Promise<Array<Object>>} An array of ledger agents.
* @returns {Promise<Array<object>>} An array of ledger agents.
*/

@@ -343,6 +347,6 @@ async getAgents({headers = {}} = {}) {

*
* @param {Object} [options={}] - Options for getAgent.
* @param {object} [options={}] - Options for getAgent.
* @param {string} [options.id] - The ledger agent ID.
*
* @returns {Promise<Object>} A ledger agent.
* @returns {Promise<object>} A ledger agent.
*/

@@ -372,4 +376,4 @@ async getAgent({id} = {}) {

*
* @param {Object} options - Options for wrap.
* @param {Object} options.record - The record to wrap into an operation.
* @param {object} options - Options for wrap.
* @param {object} options.record - The record to wrap into an operation.
* @param {boolean} [options.addCreator=true]

@@ -381,3 +385,3 @@ * - Assign the ledger agent's `targetNode`

*
* @returns {Promise<Object>} - The wrapped record.
* @returns {Promise<object>} - The wrapped record.
*/

@@ -388,3 +392,8 @@ async wrap({addCreator = true, record, operationType = 'create'}) {

}
const operation = {'@context': constants.WEB_LEDGER_CONTEXT_V1_URL};
const operation = {
'@context': [
constants.WEB_LEDGER_CONTEXT_V1_URL,
constants.ZCAP_CONTEXT_V1_URL
]
};

@@ -391,0 +400,0 @@ // TODO: throw here if targetNode is not defined?

{
"name": "web-ledger-client",
"version": "4.0.0",
"version": "6.0.0",
"description": "A WebLedger client.",

@@ -45,13 +45,16 @@ "homepage": "https://github.com/digitalbazaar/web-ledger-client",

"chai": "^4.2.0",
"eslint": "^7.17.0",
"eslint-config-digitalbazaar": "^2.0.0",
"eslint-plugin-jsdoc": "^4.6.0",
"cross-env": "^7.0.3",
"eslint": "^7.21.0",
"eslint-config-digitalbazaar": "^2.6.1",
"eslint-plugin-jsdoc": "^35.2.0",
"jsdoc-to-markdown": "^7.0.1",
"mocha": "^8.2.1",
"mocha": "^9.0.0",
"mocha-lcov-reporter": "^1.3.0",
"nock": "^13.1.0",
"nyc": "^15.1.0",
"sinon": "^7.1.1",
"sinon-chai": "^3.2.0"
"nyc": "^15.1.0"
},
"nyc": {
"exclude": [
"tests"
],
"reporter": [

@@ -73,5 +76,8 @@ "html",

"generate-docs": "jsdoc2md lib/*.js > ./docs/api.md",
"test": "npm run lint && npm run test-node",
"test-node": "cross-env NODE_ENV=test mocha --preserve-symlinks -t 10000 tests/*.spec.js",
"coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text-summary npm run test-node",
"coverage-ci": "cross-env NODE_ENV=test nyc --reporter=lcovonly npm run test-node",
"coverage-report": "nyc report",
"lint": "eslint .",
"mocha": "nyc mocha ./tests/**/*.spec.js ./tests/*.spec.js",
"test": "npm run mocha",
"preversion": "npm test",

@@ -78,0 +84,0 @@ "postversion": "git push --follow-tags"

# Web Ledger Client _(web-ledger-client)_
[![NPM Version](https://img.shields.io/npm/v/web-ledger-client.svg?style=flat-square)](https://npm.im/web-ledger-client)
[![Build Status](https://travis-ci.org/digitalbazaar/web-ledger-client.png?branch=master)](https://travis-ci.org/digitalbazaar/web-ledger-client)
[![Build status](https://img.shields.io/github/workflow/status/digitalbazaar/web-ledger-client/Node.js%20CI)](https://github.com/digitalbazaar/web-ledger-client/actions?query=workflow%3A%22Node.js+CI%22)
[![NPM Version](https://img.shields.io/npm/v/web-ledger-client.svg)](https://npm.im/web-ledger-client)

@@ -6,0 +6,0 @@ A JavaScript HTTP client library for communicating with Web Ledger nodes.

@@ -57,3 +57,3 @@ {

},
"targetNode": "https://genesis.testnet.veres.one/consensus/continuity2017/voters/z6Mkr6HD7yRn6BtRE2HGFcfzWf25ce9p4nSSWZkVXfQekAoX"
"targetNode": "https://genesis.testnet.veres.one/consensus/continuity2017/peers/z6Mkr6HD7yRn6BtRE2HGFcfzWf25ce9p4nSSWZkVXfQekAoX"
}

@@ -305,3 +305,6 @@ /*!

result.should.be.an('object');
result['@context'].should.equal(constants.WEB_LEDGER_CONTEXT_V1_URL);
result['@context'].should.eql([
constants.WEB_LEDGER_CONTEXT_V1_URL,
constants.ZCAP_CONTEXT_V1_URL
]);
result.record.should.eql(record);

@@ -315,3 +318,6 @@ result.type.should.equal('CreateWebLedgerRecord');

result.should.be.an('object');
result['@context'].should.equal(constants.WEB_LEDGER_CONTEXT_V1_URL);
result['@context'].should.eql([
constants.WEB_LEDGER_CONTEXT_V1_URL,
constants.ZCAP_CONTEXT_V1_URL
]);
result.record.should.eql(record);

@@ -325,3 +331,6 @@ result.type.should.equal('CreateWebLedgerRecord');

result.should.be.an('object');
result['@context'].should.equal(constants.WEB_LEDGER_CONTEXT_V1_URL);
result['@context'].should.eql([
constants.WEB_LEDGER_CONTEXT_V1_URL,
constants.ZCAP_CONTEXT_V1_URL
]);
expect(result.record).not.to.exist;

@@ -328,0 +337,0 @@ result.recordPatch.should.eql(record);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc