Skip to content

Commit

Permalink
Merge pull request #15 from blockchain-certificates/feat/improve-resp…
Browse files Browse the repository at this point in the history
…onsability-compatibility-cvjs

Feat/improve responsability compatibility cvjs
  • Loading branch information
lemoustachiste authored Oct 10, 2022
2 parents 6792dfe + ef906a1 commit 077ebe0
Show file tree
Hide file tree
Showing 54 changed files with 19,591 additions and 9,644 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13
16
119 changes: 60 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ You will need to wrap the certificate with the Signature Suite:

```js
const myBlockcertsV3Definition = {
...
};
...
};

const verificationSuite = new MerkleProof2019({ document: myBlockcertsV3Definition });
const verificationSuite = new LDMerkleProof2019({document: myBlockcertsV3Definition});
```

In the case of vc.js, you would then pass this suite to the `verify` method, through the `suite` parameter.
Expand Down Expand Up @@ -47,29 +47,30 @@ You may provide your own explorer or even overwrite the existing ones. This is u
or if you'd like to provide identification keys to the ones provided by default.

Here is an example of how you would provide such service:

```js
const myBlockcertsV3Definition = {
...
};

const myOwnExplorerAPI: ExplorerAPI = {
serviceURL: 'path/to/distant/api', // you may need to provide identification details here according to your service pattern
priority: 0, // this is to decide if this gets called before the out-of-the-box services. 0 means your custom service is going to be called first, use 1 if you prefer the default explorers to be called first.
parsingFunction: function ({ jsonResponse: serviceReponse }: IParsingFunctionAPI): TransactionData { // only define this function when referring to a custom explorer
// parse your service response in order to return the following information:
return {
remoteHash,
issuingAddress,
time,
revokedAddresses
}
}
};
const options = {
explorerAPIs: [myOwnExplorerAPI]
};

const verificationSuite = new MerkleProof2019({ document: myBlockcertsV3Definition, options });
...
};

const myOwnExplorerAPI: ExplorerAPI = {
serviceURL: 'path/to/distant/api', // you may need to provide identification details here according to your service pattern
priority: 0, // this is to decide if this gets called before the out-of-the-box services. 0 means your custom service is going to be called first, use 1 if you prefer the default explorers to be called first.
parsingFunction: function ({jsonResponse: serviceReponse}: IParsingFunctionAPI): TransactionData { // only define this function when referring to a custom explorer
// parse your service response in order to return the following information:
return {
remoteHash,
issuingAddress,
time,
revokedAddresses
}
}
};
const options = {
explorerAPIs: [myOwnExplorerAPI]
};

const verificationSuite = new LDMerkleProof2019({document: myBlockcertsV3Definition, options});
```

## RPCs
Expand All @@ -82,47 +83,47 @@ lookup function to use:

```js
const myBlockcertsV3Definition = {
...
};

const options = {
explorerAPIs: [{
serviceURL: 'https://rpc-mumbai.maticvigil.com/',
priority: 0,
apiType: 'rpc',
chainType: 'evm'
}]
};
const verificationSuite = new MerkleProof2019({ document: myBlockcertsV3Definition, options });
...
};

const options = {
explorerAPIs: [{
serviceURL: 'https://rpc-mumbai.maticvigil.com/',
priority: 0,
apiType: 'rpc',
chainType: 'evm'
}]
};
const verificationSuite = new LDMerkleProof2019({document: myBlockcertsV3Definition, options});
```

#### Your chain is not compatible with EVM or BTC
NOTE: you can use this approach to modify the provided RPC lookup functions.

You will need to additionally provide your own lookup function. Contrary to rest APIs in this package, the parsing function needs to make the calls to the RPC service by itself.
You will need to additionally provide your own lookup function. Contrary to rest APIs in this package, the parsing function needs to make the calls to the RPC service by itself.

```js
const myBlockcertsV3Definition = {
...
};

const options = {
explorerAPIs: [{
serviceURL: 'https://rpc-mumbai.maticvigil.com/',
priority: 0,
apiType: 'rpc',
chainType: 'evm',
parsingFunction: function ({ serverUrl, transactionId }: IParsingFunctionAPI): TransactionData { // note that function signature is different than for REST parsingFunctions
// your call to the `serverUrl` with the `transaction` id
// parse your service response in order to return the following information:
return {
remoteHash,
issuingAddress,
time,
revokedAddresses
}
}
}]
};
const verificationSuite = new MerkleProof2019({ document: myBlockcertsV3Definition, options });
...
};

const options = {
explorerAPIs: [{
serviceURL: 'https://rpc-mumbai.maticvigil.com/',
priority: 0,
apiType: 'rpc',
chainType: 'evm',
parsingFunction: function ({serverUrl, transactionId}: IParsingFunctionAPI): TransactionData { // note that function signature is different than for REST parsingFunctions
// your call to the `serverUrl` with the `transaction` id
// parse your service response in order to return the following information:
return {
remoteHash,
issuingAddress,
time,
revokedAddresses
}
}
}]
};
const verificationSuite = new LDMerkleProof2019({document: myBlockcertsV3Definition, options});
```
7 changes: 5 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ module.exports = {
'<rootDir>/node_modules'
],
transform: {
'^.+\\.(ts)$': 'ts-jest'
}
'^.+\\.(js|ts)$': 'ts-jest'
},
transformIgnorePatterns: [
'node_modules/@digitalbazaar/'
]
};
Loading

0 comments on commit 077ebe0

Please sign in to comment.