Skip to content

Commit

Permalink
Merge pull request #494 from energywebfoundation/task/ICL-254-vc-poc
Browse files Browse the repository at this point in the history
feat: add VC and VP functionality
  • Loading branch information
Harasz committed Apr 8, 2022
2 parents 4dd335d + a4732e3 commit da13c0b
Show file tree
Hide file tree
Showing 36 changed files with 3,057 additions and 959 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ name: Deploy

on:
push:
branches: ["develop", "master"]
branches: ['develop', 'master']
pull_request:
branches: ["develop", "master"]

jobs:
cancel-previous:
name: "Cancel Previous Runs"
name: 'Cancel Previous Runs'
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
Expand All @@ -26,7 +25,7 @@ jobs:
token: ${{ secrets.SECRET_NAME }}
- uses: actions/setup-node@v2-beta
with:
node-version: "16.10.0"
node-version: '16.10.0'
registry-url: https://registry.npmjs.org/

- name: Configure Git
Expand Down
42 changes: 24 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,24 @@ For development purposes, please follow below steps to integrate the library wit

### Prerequisites

`iam-client-lib` is written in TypeScript. Make sure to have Node.js (>= v10) installed.
Create a folder named **_iam-client-lib_** and clone this GIT project.
`iam-client-lib` is written in TypeScript. Make sure to have Node.js (>= v10) installed. Create a folder named **_iam-client-lib_** and clone this GIT project.

Also note that having a DID document with a public key is a prerequisite for using iam-client-lib and during initialization the library with attempt to add a public key to the DID document if one doesn't exist. This addition of the public key requires the account to be funded.

`iam-client-lib` has a WebAssembly dependency. Some bundlers/frameworks doesn't support it out of the box, so some action are required. Here is a list of known problems:

- **Angular** - you'll have to add following in you `package.json`

```
"browser": {
"fs": false,
"os": false,
"path": false
}
```

- **React** - you'll have to add a `wasm-loader` for the files with `.wasm` extension to your Webpack configuration. To edit Webpack config you can use [@craco/craco](https://www.npmjs.com/package/@craco/craco) or [react-app-rewired](https://www.npmjs.com/package/react-app-rewired).

### Install

Latest stable version
Expand All @@ -49,8 +62,7 @@ Some library dependencies require Node.js built-ins. Therefore when library is u

### Initialization

Because of dependencies between modules they should be initialized in right order.
This is achieved by accessing module initializer from initialization function of required module.
Because of dependencies between modules they should be initialized in right order. This is achieved by accessing module initializer from initialization function of required module.

1. Initializing signer service. It will initialize staking and messaging services and allow to connect to cache server

Expand All @@ -68,11 +80,11 @@ This is achieved by accessing module initializer from initialization function of
// IAM has builtin default settings for VOLTA CHAIN, which can overriden
// 1111 is an example of another ChainID (https://chainlist.org/)
setChainConfig(1111, {
didContractAddress: '0x3e2fb24edc3536d655720280b427c91bcb55f3d6',
ensRegistryAddress: '0xa372d665f83197a63bbe633ebe19c7bfd4943003',
ensResolverAddress: '0xe878bdcf5148307378043bfd2b584909aa48a227',
rpcUrl: 'http://some-rpc.com',
})
didContractAddress: '0x3e2fb24edc3536d655720280b427c91bcb55f3d6',
ensRegistryAddress: '0xa372d665f83197a63bbe633ebe19c7bfd4943003',
ensResolverAddress: '0xe878bdcf5148307378043bfd2b584909aa48a227',
rpcUrl: 'http://some-rpc.com',
});

setMessagingConfig(1111, {
messagingMethod: MessagingMethod.Nats,
Expand All @@ -84,20 +96,14 @@ setCacheConfig(1111, {
cacheServerSupportsAuth: true,
})

const {
cacheClient,
domainsService,
connectToDidRegistry
} = await connectToCacheServer()
const { cacheClient, domainsService, connectToDidRegistry } =
await connectToCacheServer();
```

3. Connecting to DID registry.

```js
const {
didRegistry,
claimsService
} = await connectToDidRegistry()
const { didRegistry, claimsService } = await connectToDidRegistry();
```

## Development
Expand Down
44 changes: 26 additions & 18 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,24 @@ For development purposes, please follow below steps to integrate the library wit

### Prerequisites

`iam-client-lib` is written in TypeScript. Make sure to have Node.js (>= v10) installed.
Create a folder named **_iam-client-lib_** and clone this GIT project.
`iam-client-lib` is written in TypeScript. Make sure to have Node.js (>= v10) installed. Create a folder named **_iam-client-lib_** and clone this GIT project.

Also note that having a DID document with a public key is a prerequisite for using iam-client-lib and during initialization the library with attempt to add a public key to the DID document if one doesn't exist. This addition of the public key requires the account to be funded.

`iam-client-lib` has a WebAssembly dependency. Some bundlers/frameworks doesn't support it out of the box, so some action are required. Here is a list of known problems:

- **Angular** - you'll have to add following in you `package.json`

```
"browser": {
"fs": false,
"os": false,
"path": false
}
```

- **React** - you'll have to add a `wasm-loader` for the files with `.wasm` extension to your Webpack configuration. To edit Webpack config you can use [@craco/craco](https://www.npmjs.com/package/@craco/craco) or [react-app-rewired](https://www.npmjs.com/package/react-app-rewired).

### Install

Latest stable version
Expand All @@ -45,10 +58,11 @@ Prerelease version
npm i iam-client-lib@canary
```

Some library dependencies require Node.js built-ins. Therefore when library is used in browser make sure they are polyfilled. If application is bundled with Webpack dependencies can be polyfilled with [node-polyfill-webpack-plugin](https://www.npmjs.com/package/node-polyfill-webpack-plugin)

### Initialization

Because of dependencies between modules they should be initialized in right order.
This is achieved by accessing module initializer from initialization function of required module.
Because of dependencies between modules they should be initialized in right order. This is achieved by accessing module initializer from initialization function of required module.

1. Initializing signer service. It will initialize staking and messaging services and allow to connect to cache server

Expand All @@ -66,11 +80,11 @@ This is achieved by accessing module initializer from initialization function of
// IAM has builtin default settings for VOLTA CHAIN, which can overriden
// 1111 is an example of another ChainID (https://chainlist.org/)
setChainConfig(1111, {
didContractAddress: '0x3e2fb24edc3536d655720280b427c91bcb55f3d6',
ensRegistryAddress: '0xa372d665f83197a63bbe633ebe19c7bfd4943003',
ensResolverAddress: '0xe878bdcf5148307378043bfd2b584909aa48a227',
rpcUrl: 'http://some-rpc.com',
})
didContractAddress: '0x3e2fb24edc3536d655720280b427c91bcb55f3d6',
ensRegistryAddress: '0xa372d665f83197a63bbe633ebe19c7bfd4943003',
ensResolverAddress: '0xe878bdcf5148307378043bfd2b584909aa48a227',
rpcUrl: 'http://some-rpc.com',
});

setMessagingConfig(1111, {
messagingMethod: MessagingMethod.Nats,
Expand All @@ -82,20 +96,14 @@ setCacheConfig(1111, {
cacheServerSupportsAuth: true,
})

const {
cacheClient,
domainsService,
connectToDidRegistry
} = await connectToCacheServer()
const { cacheClient, domainsService, connectToDidRegistry } =
await connectToCacheServer();
```

3. Connecting to DID registry.

```js
const {
didRegistry,
claimsService
} = await connectToDidRegistry()
const { didRegistry, claimsService } = await connectToDidRegistry();
```

## Development
Expand Down
4 changes: 2 additions & 2 deletions docs/api/classes/DomainsService.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ___

### changeOrgOwnership

**changeOrgOwnership**(`__namedParameters`): `Promise`<`undefined` \| { `info`: `string` ; `tx`: `EncodedCall` ; `next`: (`__namedParameters?`: { `retryCheck?`: `boolean` }) => `Promise`<`undefined` \| `TransactionReceipt`\> }[]\>
**changeOrgOwnership**(`__namedParameters`): `Promise`<`undefined` \| [`MulticallTx`](../modules.md#multicalltx)\>

changeOrgOwnership

Expand All @@ -98,7 +98,7 @@ changeOrgOwnership

#### Returns

`Promise`<`undefined` \| { `info`: `string` ; `tx`: `EncodedCall` ; `next`: (`__namedParameters?`: { `retryCheck?`: `boolean` }) => `Promise`<`undefined` \| `TransactionReceipt`\> }[]\>
`Promise`<`undefined` \| [`MulticallTx`](../modules.md#multicalltx)\>

return array of steps needed to change ownership

Expand Down
19 changes: 19 additions & 0 deletions docs/api/classes/EkcSigner.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

**`EkcSigner`**

## Implements

- `TypedDataSigner`

## Table of contents

### Constructors
Expand All @@ -19,6 +23,7 @@

### Methods

- [\_signTypedData](EkcSigner.md#_signtypeddata)
- [connect](EkcSigner.md#connect)
- [getAddress](EkcSigner.md#getaddress)
- [signMessage](EkcSigner.md#signmessage)
Expand Down Expand Up @@ -59,6 +64,20 @@ Signer.provider

## Methods

### \_signTypedData

**_signTypedData**(): `Promise`<`string`\>

#### Returns

`Promise`<`string`\>

#### Implementation of

TypedDataSigner.\_signTypedData

___

### connect

**connect**(`provider`): `Signer`
Expand Down
40 changes: 36 additions & 4 deletions docs/api/classes/SignerService.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [address](SignerService.md#address)
- [chainId](SignerService.md#chainid)
- [did](SignerService.md#did)
- [didHex](SignerService.md#didhex)
- [isEthSigner](SignerService.md#isethsigner)
- [provider](SignerService.md#provider)
- [providerType](SignerService.md#providertype)
Expand All @@ -33,6 +34,7 @@
- [publicKeyAndIdentityToken](SignerService.md#publickeyandidentitytoken)
- [send](SignerService.md#send)
- [signMessage](SignerService.md#signmessage)
- [signTypedData](SignerService.md#signtypeddata)

## Constructors

Expand All @@ -44,7 +46,7 @@

| Name | Type |
| :------ | :------ |
| `_signer` | `Required`<`Signer`\> |
| `_signer` | `Required`<[`SignerT`](../modules.md#signert)\> |
| `_providerType` | [`ProviderType`](../enums/ProviderType.md) |

## Accessors
Expand Down Expand Up @@ -89,6 +91,16 @@ ___

___

### didHex

`get` **didHex**(): `string`

#### Returns

`string`

___

### isEthSigner

`get` **isEthSigner**(): `boolean`
Expand Down Expand Up @@ -121,11 +133,11 @@ ___

### signer

`get` **signer**(): `Required`<`Signer`\>
`get` **signer**(): `Required`<[`SignerT`](../modules.md#signert)\>

#### Returns

`Required`<`Signer`\>
`Required`<[`SignerT`](../modules.md#signert)\>

## Methods

Expand Down Expand Up @@ -188,7 +200,7 @@ ___

| Name | Type |
| :------ | :------ |
| `signer` | `Required`<`Signer`\> |
| `signer` | `Required`<[`SignerT`](../modules.md#signert)\> |
| `providerType` | [`ProviderType`](../enums/ProviderType.md) |

#### Returns
Expand Down Expand Up @@ -325,3 +337,23 @@ When running in browser `isEthSigner` variable should be stored in local storage
#### Returns

`Promise`<`string`\>

___

### signTypedData

**signTypedData**(`domain`, `types`, `message`): `Promise`<`string`\>

**`description`** Tries to create conformant signature (https://eips.ethereum.org/EIPS/eip-712)

#### Parameters

| Name | Type |
| :------ | :------ |
| `domain` | `TypedDataDomain` |
| `types` | `Record`<`string`, `TypedDataField`[]\> |
| `message` | `Record`<`string`, `unknown`\> |

#### Returns

`Promise`<`string`\>
Loading

0 comments on commit da13c0b

Please sign in to comment.