Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ReactNative. #1

Merged
merged 8 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package-lock.json
yarn-lock.json
*.sublime-project
*.sublime-workspace
*.sw[nop]
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# jsonld-signatures ChangeLog

## 9.3.1 -

### Changed
- Update `jsonld` (and `rdf-canonize`) dependency, to enable use with React
Native.
- Switch to `@digitalbazaar/security-context` (more compact, no fs dependency).

## 9.3.0 - 2021-07-10

### Added
Expand Down
30 changes: 13 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# JSON-LD Signatures _(jsonld-signatures)_
# JSON-LD Signatures _(@digitalcredentials/jsonld-signatures)_

[![Build status](https://img.shields.io/github/workflow/status/digitalbazaar/jsonld-signatures/Node.js%20CI)](https://github.com/digitalbazaar/jsonld-signatures/actions?query=workflow%3A%22Node.js+CI%22)
[![Coverage status](https://img.shields.io/codecov/c/github/digitalbazaar/jsonld-signatures)](https://codecov.io/gh/digitalbazaar/jsonld-signatures)
[![Dependency Status](https://img.shields.io/david/digitalbazaar/jsonld-signatures.svg)](https://david-dm.org/digitalbazaar/jsonld-signatures)
[![NPM Version](https://img.shields.io/npm/v/jsonld-signatures.svg)](https://npm.im/jsonld-signatures)
[![NPM Version](https://img.shields.io/npm/v/@digitalcredentials/jsonld-signatures.svg)](https://npm.im/digitalcredentials/jsonld-signatures)

> An implementation of the Linked Data Signatures specification for JSON-LD, for Node.js and browsers.

Expand All @@ -19,17 +16,20 @@

## Version Compatibility

(Forked from [`jsonld-signatures` v9.0.0](https://github.com/digitalbazaar/jsonld-signatures)
to provide TypeScript compatibility.)

`jsonld-signatures` **v9.0** is compatible with the following signature suites:

* [`ed25519-signature-2020`](https://github.com/digitalbazaar/ed25519-signature-2020)
* [`ed25519-signature-2020`](https://github.com/digitalcredentials/ed25519-signature-2020)
`>= 2.1.0`.

and the following related libraries:

* `crypto-ld` `>= 5.0.0` (and related key crypto suites such as
[`ed25519-verification-key-2020`](https://github.com/digitalbazaar/ed25519-verification-key-2020)
`>= 2.1.0`).
* `vc-js` `>= 7.0` (currently, [branch `v7.x`](https://github.com/digitalbazaar/vc-js/pull/83))
* `@digitalcredentials/vc` `>= 1.0`

## Background

Expand Down Expand Up @@ -61,7 +61,7 @@ document.
One common use case for creating these signatures is for use with
[Verifiable Credentials](https://w3c.github.io/vc-data-model) (VCs). If you're
working with those, you should use a higher-level library that's specifically
made for that purpose, such as [`vc-js`](https://github.com/digitalbazaar/vc-js).
made for that purpose, such as [`@digitalcredentials/vc`](https://github.com/digitalcredentials/vc-js).
(Incidentally, `vc-js` uses this library, `jsonld-signatures`, under the hood.)

## Security
Expand Down Expand Up @@ -104,7 +104,7 @@ security, or business rules.
To install locally (for development):

```
git clone https://github.com/digitalbazaar/jsonld-signatures.git
git clone https://github.com/digitalcredentials/jsonld-signatures.git
cd jsonld-signatures
npm install
```
Expand All @@ -115,7 +115,7 @@ npm install
Instead, it's generally used through an individual _crypto suite_.
For detailed usage instructions, see the READMEs of the supported suites:

* [`Ed25519Signature2020`](https://github.com/digitalbazaar/ed25519-signature-2020)
* [`Ed25519Signature2020`](https://github.com/digitalcredentials/ed25519-signature-2020)
* [`Ed25519Signature2018`](https://github.com/digitalbazaar/ed25519-signature-2018)

Most of the usages with individual suites and key types will have elements in
Expand All @@ -129,7 +129,7 @@ common. You'll need to:
them for (see section on Proof Purpose below), using a Controller Document
(such as a DID Document or similar).
* Pair those keys with a corresponding cryptographic Signature Suite.
For greenfield development, we recommend the [`Ed25519Signature2020`](https://github.com/digitalbazaar/ed25519-signature-2020)
For greenfield development, we recommend the [`Ed25519Signature2020`](https://github.com/digitalcredentials/ed25519-signature-2020)
suite, and for legacy/compatibility work, you can use
[`Ed25519Signature2018`](https://github.com/digitalbazaar/ed25519-signature-2018) suite.
See also the [Choosing a Key Type](https://github.com/digitalbazaar/crypto-ld#choosing-a-key-type)
Expand All @@ -153,11 +153,7 @@ PRs accepted.
If editing the Readme, please conform to the
[standard-readme](https://github.com/RichardLitt/standard-readme) specification.

## Commercial Support

Commercial support for this library is available upon request from
Digital Bazaar: [email protected]

## License

[New BSD License (3-clause)](LICENSE) © Digital Bazaar
* MIT License - DCC - TypeScript compatibility.
* New BSD License (3-clause) © 2020-2021 Digital Bazaar - Initial implementation.
2 changes: 1 addition & 1 deletion lib/ProofSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

const constants = require('./constants');
const jsonld = require('jsonld');
const jsonld = require('@digitalcredentials/jsonld');
const {extendContextLoader, strictDocumentLoader} = require('./documentLoader');
const {serializeError} = require('serialize-error');
const strictExpansionMap = require('./expansionMap');
Expand Down
4 changes: 3 additions & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
*/
'use strict';

const {constants: securityConstants} = require('security-context');
const {
constants: securityConstants
} = require('@digitalbazaar/security-context');

module.exports = {
SECURITY_CONTEXT_URL: securityConstants.SECURITY_CONTEXT_V2_URL,
Expand Down
2 changes: 1 addition & 1 deletion lib/contexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

const constants = require('./constants');
const {contexts: securityContexts} = require('security-context');
const {contexts: securityContexts} = require('@digitalbazaar/security-context');

module.exports = new Map([
[constants.SECURITY_CONTEXT_V1_URL,
Expand Down
2 changes: 1 addition & 1 deletion lib/purposes/ControllerProofPurpose.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

const constants = require('../constants');
const jsonld = require('jsonld');
const jsonld = require('@digitalcredentials/jsonld');
const ProofPurpose = require('./ProofPurpose');

// DID documents can be specially optimized
Expand Down
23 changes: 23 additions & 0 deletions lib/sha256digest-reactnative.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
*/
'use strict';

const crypto = require('isomorphic-webcrypto');
require('fast-text-encoding');

module.exports = {
/**
* Hashes a string of data using SHA-256.
*
* @param {string} string - the string to hash.
*
* @return {Uint8Array} the hash digest.
*/
async sha256digest({string}) {
const bytes = new TextEncoder().encode(string);
return new Uint8Array(
await crypto.subtle.digest({name: 'SHA-256'}, bytes)
);
}
};
2 changes: 1 addition & 1 deletion lib/suites/LinkedDataSignature.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

const constants = require('../constants');
const jsonld = require('jsonld');
const jsonld = require('@digitalcredentials/jsonld');
const util = require('../util');
const {sha256digest} = require('../sha256digest');
const LinkedDataProof = require('./LinkedDataProof');
Expand Down
38 changes: 16 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
{
"name": "jsonld-signatures",
"version": "9.3.1-0",
"name": "@digitalcredentials/jsonld-signatures",
"version": "9.3.1",
"description": "An implementation of the Linked Data Signatures specifications for JSON-LD in JavaScript.",
"homepage": "https://github.com/digitalbazaar/jsonld-signatures",
"author": {
"name": "Digital Bazaar, Inc.",
"email": "[email protected]",
"url": "https://digitalbazaar.com/"
},
"contributors": [
"Dave Longley <[email protected]>",
"Manu Sporny <[email protected]>",
"David I. Lehn <[email protected]>",
"Dmitri Zagidulin <[email protected]>"
],
"homepage": "https://github.com/digitalcredentials/jsonld-signatures",
"repository": {
"type": "git",
"url": "https://github.com/digitalbazaar/jsonld-signatures"
},
"bugs": {
"url": "https://github.com/digitalbazaar/jsonld-signatures/issues",
"email": "[email protected]"
"url": "https://github.com/digitalcredentials/jsonld-signatures"
},
"license": "BSD-3-Clause",
"main": "lib/jsonld-signatures.js",
Expand All @@ -29,8 +14,10 @@
"lib/**/*.js"
],
"dependencies": {
"jsonld": "^5.0.0",
"security-context": "^4.0.0",
"@digitalbazaar/security-context": "^1.0.0",
"@digitalcredentials/jsonld": "^5.2.1",
"fast-text-encoding": "^1.0.3",
"isomorphic-webcrypto": "^2.3.8",
"serialize-error": "^8.0.1"
},
"devDependencies": {
Expand Down Expand Up @@ -79,6 +66,13 @@
},
"browser": {
"crypto": false,
"./lib/sha256digest.js": "./lib/sha256digest-browser.js"
"./lib/sha256digest.js": "./lib/sha256digest-browser.js",
"fast-text-encoding": false,
"isomorphic-webcrypto": false
},
"react-native": {
"crypto": false,
"./lib/sha256digest.js": "./lib/sha256digest-reactnative.js",
"./lib/sha256digest-browser.js": false
}
}