Skip to content

Commit

Permalink
some changes and fix issue preventing compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
juanelas committed Dec 11, 2021
1 parent 119ac7c commit 07054bc
Show file tree
Hide file tree
Showing 38 changed files with 8,231 additions and 332 deletions.
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Rollup",
"program": "${workspaceFolder}/node_modules/.bin/rollup",
"args": ["-c", "build/rollup.config.js"],
"internalConsoleOptions": "openOnSessionStart"
}
]
}
36 changes: 15 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,54 @@
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)


# non-repudiation-protocol
# @i3m/non-repudiation-protocol

Library for the i3-market non-repudiation protocol that helps generate/verifying the necessary proofs and the received block of data. It is a core element of the Conflicc Resolution system in i3-MARKET. [Read more here](./conflict-resolution.md)
Library for the i3-market non-repudiation protocol that helps generate/verifying the necessary proofs and the received block of data. It is a core element of the Conflict Resolution system in i3-MARKET. [Read more here](./conflict-resolution.md)

## API reference documentation

[Check the API](./docs/API.md)

## Usage

Once you set up the i3-MARKET NPM, `non-repudiation-protocol` can be imported to your project with `npm`:
Once you set up the i3-MARKET NPM, `@i3m/non-repudiation-protocol` can be imported to your project with `npm`:

```console
npm install non-repudiation-protocol
npm install @i3m/non-repudiation-protocol
```

Alternatively, you can just download the [latest release](./releases/non-repudiation-protocol-latest.tgz) and install into your project with:
Alternatively you can just download the [latest release](./releases/@i3m/non-repudiation-protocol-latest.tgz) and install into your project with:

```console
npm install <path to non-repudiation-protocol-latest.tgz>
npm install <path to @i3m/non-repudiation-protocol-latest.tgz>
```

Then either require (Node.js CJS):

```javascript
const nonRepudiationProtocol = require('non-repudiation-protocol')
const nonRepudiationProtocol = require('@i3m/non-repudiation-protocol')
```

or import (JavaScript ES module):

```javascript
import * as nonRepudiationProtocol from 'non-repudiation-protocol'
import * as nonRepudiationProtocol from '@i3m/non-repudiation-protocol'
```

The appropriate version for browser or node is automatically exported.

You can also download the [IIFE bundle](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/raw/master/dist/dist/bundles/iife.js?inline=false), the [ESM bundle](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/raw/master/dist/dist/bundles/esm.min.js?inline=false) or the [UMD bundle](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/raw/master/dist/dist/bundles/umd.js?inline=false) and manually add it to your project, or, if you have already installed `non-repudiation-protocol` in your project, just get the bundles from `node_modules/non-repudiation-protocol/dist/bundles/`.
You can also download the IIFE bundle, the ESM bundle or the UMD bundle and manually add it to your project, or, if you have already installed `@i3m/non-repudiation-protocol` in your project, just get the bundles from `node_modules/@i3m/non-repudiation-protocol/dist/bundles/`.

### Example for an i3-MARKET Provider

Before starting the agreement you need a pair of public-private keys as JWK in one of the EC supported curves (P-256, P-384, P-521). You can easily create the key pair with the generateKeys utility function. For example, if you already have a random private key in hex:
Before starting the agreement you need a pair of public-private keys as JWK in one of the EC supported curves (P-256, P-384, P-521). You can easily create the key pair with the `generateKeys` utility function. For example, if you already have a random private key in hex:

```typescript
/** you need a pair of public-private keys as JWK in one of the EC supported
* curves (P-256, P-384, P-521).
* If you already have a random private key in hex, base64 or Uint8Array, you
* can easily create the key pair with the generateKeys utility function.
* An example with a key in hex format would be
*/
const privKey = '0x4b7903c8fe1824ba5329939c7d2c4318307794a544f2eb5fb3b6536210c98677'
const providerJwks = await nonRepudiationProtocol.generateKeys(SIGNING_ALG, providerPrivKeyHex)
const privKey = '0x4b7903c8fe1824ba5329939c7d2c4318307794a544f2eb5fb3b6536210c98677'
const providerJwks = await nonRepudiationProtocol.generateKeys(SIGNING_ALG, providerPrivKeyHex)
```

And now you are ready to start a DataExchange for a given block of a given dataExchangeAgreement.
And now you are ready to start a dataExchange for a given block of a given dataExchangeAgreement.

```typescript
async nrp() => {
Expand Down Expand Up @@ -87,7 +81,7 @@ async nrp() => {
}

/**
* Intialize the non-repudiation protocol as the origin. Internally, a one-time secret is created and the block is encrypted.
* Intialize the non-repudiation protocol as the origin. Internally, a one-time secret is created and the block is encrypted. They could be found in npProvider.block.secret and npProvide.block.jwe respectively.
* You need:
* - the data agreement
* - the private key of the provider. It is used to sign the proofs and to sign transactions to the ledger (if not stated otherwise)
Expand Down Expand Up @@ -120,7 +114,7 @@ nrp()
### Example for an i3-MARKET Consumer
Before starting the agreement you need a pair of public private keys. You can easily create the key pair with the generateKeys utility function:
Before starting the agreement, you need a pair of public private keys. You can easily create the key pair with the `generateKeys` utility function:
```typescript
const consumerJwks = await nonRepudiationProtocol.generateKeys('ES256', providerPrivKeyHex)
Expand Down
3 changes: 2 additions & 1 deletion build/build.docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ async function typedoc () {
includeVersion: true,
entryDocument: 'API.md',
readme: 'none',
hideBreadcrumbs: true
hideBreadcrumbs: true,
excludePrivate: true
})

const project = app.convert()
Expand Down
2 changes: 1 addition & 1 deletion dist/bundles/esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/index.node.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/index.browser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/esm/index.node.js

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions docs/API.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# non-repudiation-protocol - v1.0.0
# @i3m/non-repudiation-protocol - v1.0.0

i3-Market implementation of the non-repudiation proofs of a data exchange

Expand Down Expand Up @@ -70,7 +70,7 @@ ___

#### Defined in

[src/ts/types.ts:9](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/29e9a91/src/ts/types.ts#L9)
[src/ts/types.ts:9](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/97869db/src/ts/types.ts#L9)

___

Expand All @@ -80,7 +80,7 @@ ___

#### Defined in

[src/ts/types.ts:7](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/29e9a91/src/ts/types.ts#L7)
[src/ts/types.ts:7](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/97869db/src/ts/types.ts#L7)

___

Expand All @@ -90,7 +90,7 @@ ___

#### Defined in

[src/ts/types.ts:8](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/29e9a91/src/ts/types.ts#L8)
[src/ts/types.ts:8](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/97869db/src/ts/types.ts#L8)

## Functions

Expand All @@ -115,7 +115,7 @@ a proof as a compact JWS formatted JWT string

#### Defined in

[src/ts/createProof.ts:13](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/29e9a91/src/ts/createProof.ts#L13)
[src/ts/createProof.ts:13](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/97869db/src/ts/createProof.ts#L13)

___

Expand All @@ -139,7 +139,7 @@ Generates a pair of JWK signing/verification keys

#### Defined in

[src/ts/generateKeys.ts:15](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/29e9a91/src/ts/generateKeys.ts#L15)
[src/ts/generateKeys.ts:15](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/97869db/src/ts/generateKeys.ts#L15)

___

Expand All @@ -165,7 +165,7 @@ the plaintext

#### Defined in

[src/ts/jwe.ts:28](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/29e9a91/src/ts/jwe.ts#L28)
[src/ts/jwe.ts:28](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/97869db/src/ts/jwe.ts#L28)

___

Expand All @@ -191,7 +191,7 @@ a Compact JWE

#### Defined in

[src/ts/jwe.ts:13](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/29e9a91/src/ts/jwe.ts#L13)
[src/ts/jwe.ts:13](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/97869db/src/ts/jwe.ts#L13)

___

Expand All @@ -217,7 +217,7 @@ a promise that resolves to the secret in JWK and raw hex string

#### Defined in

[src/ts/oneTimeSecret.ts:16](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/29e9a91/src/ts/oneTimeSecret.ts#L16)
[src/ts/oneTimeSecret.ts:16](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/97869db/src/ts/oneTimeSecret.ts#L16)

___

Expand All @@ -237,7 +237,7 @@ ___

#### Defined in

[src/ts/utils.ts:1](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/29e9a91/src/ts/utils.ts#L1)
[src/ts/utils.ts:1](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/97869db/src/ts/utils.ts#L1)

___

Expand All @@ -258,7 +258,7 @@ ___

#### Defined in

[src/ts/sha.ts:3](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/29e9a91/src/ts/sha.ts#L3)
[src/ts/sha.ts:3](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/97869db/src/ts/sha.ts#L3)

___

Expand All @@ -279,7 +279,7 @@ ___

#### Defined in

[src/ts/verifyKeyPair.ts:5](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/29e9a91/src/ts/verifyKeyPair.ts#L5)
[src/ts/verifyKeyPair.ts:5](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/97869db/src/ts/verifyKeyPair.ts#L5)

___

Expand All @@ -306,4 +306,4 @@ The JWT protected header and payload if the proof is validated

#### Defined in

[src/ts/verifyProof.ts:31](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/29e9a91/src/ts/verifyProof.ts#L31)
[src/ts/verifyProof.ts:31](https://gitlab.com/i3-market/code/wp3/t3.2/conflict-resolution/non-repudiation-protocol/-/blob/97869db/src/ts/verifyProof.ts#L31)
Loading

0 comments on commit 07054bc

Please sign in to comment.