Skip to content

Commit

Permalink
Merge pull request #427 from energywebfoundation/develop
Browse files Browse the repository at this point in the history
v4.1
  • Loading branch information
JGiter committed Jan 14, 2022
2 parents d519795 + c0005e0 commit 016a2b4
Show file tree
Hide file tree
Showing 275 changed files with 52,193 additions and 15,737 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ compiled
.awcache
.rpt2_cache
docs
jest.setup.js
23 changes: 9 additions & 14 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,26 @@
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
"overrides": [
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off"
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
}
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"rules": {
"semi": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"quotes": ["warn", "double"]
"quotes": ["warn", "double"],
"no-empty": ["error", { "allowEmptyCatch": true }]
}
}
13 changes: 0 additions & 13 deletions .github/dependabot.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"assignees": ["JGiter"],
"reviewers": ["JGiter", "jrhender"],
"semanticCommits": "enabled",
"semanticCommitType": "build",
"labels": ["dependencies"],
"ignoreDeps": [
"@ensdomains/ens",
"@gnosis.pm/safe-apps-provider",
"@gnosis.pm/safe-apps-sdk",
"ethers",
"@typechain/ethers-v5",
"typechain"
],
"major": {
"enabled": false
},
"packageRules": [
{
"matchPackagePatterns": ["(.*?)"],
"groupName": "Dependencies"
}
]
}
11 changes: 11 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Lint Commit Messages
on: [pull_request]

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v4
7 changes: 4 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: styfle/cancel-workflow-action@0.8.0
- uses: styfle/cancel-workflow-action@0.9.1
with:
access_token: ${{ github.token }}

Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
run: npm run build

- name: Npm Run Test
run: npm run test:prod
run: npm run test

- name: Deploy on develop branch
if: github.ref == 'refs/heads/develop'
Expand All @@ -63,7 +63,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.SECRET_NAME }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Commit to develop branch and merge to master branch
- name: Merge master into develop
if: github.ref == 'refs/heads/master'
run: |
git checkout develop
sudo chown $(id -u) .git/logs/refs/heads/develop
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ compiled
.rpt2_cache
ethers
site
ethers-staking
141 changes: 49 additions & 92 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<p align="center">
<img src="https://github.com/energywebfoundation/iam-client-lib/actions/workflows/deploy.yml/badge.svg" />
</p>

# Identity and Access Management (IAM) Client Library

TypeScript library to be used within decentralized applications for authentication and authorization using DIDs (Decentralized Identifiers) and VCs (Verifiable Credentials)
Expand Down Expand Up @@ -44,103 +45,59 @@ Prerelease version
npm i iam-client-lib@canary
```

### Sample Config for browsers (TypeScript)

```js
import {
IAM,
WalletProvider,
setCacheClientOptions,
setChainConfig,
setMessagingOptions,
MessagingMethod,
} from 'iam-client-lib'

export class App {
private _iam: IAM;

constructor() {
// IAM has builtin default settings for VOLTA CHAIN

// If you want to change default cache server config or add config for your network
setCacheClientOptions(1111, {
url: 'https://some-cache-server.com/',
cacheServerSupportsAuth: true,
})

// If you want to change default chain config or add config for your network
setChainConfig(1111, {
didContractAddress: '0x3e2fb24edc3536d655720280b427c91bcb55f3d6',
ensRegistryAddress: '0xa372d665f83197a63bbe633ebe19c7bfd4943003',
ensResolverAddress: '0xe878bdcf5148307378043bfd2b584909aa48a227',
rpcUrl: 'http://some-rpc.com',
})

// If you want to change default messaging config or add config for your network
setMessagingOptions(1111, {
messagingMethod: MessagingMethod.Nats,
natsServerUrl: 'https://some-exchange-server.com',
})

// create IAM instance
this._iam = new IAM();
}

async initializeIAM() {
// this will show connection modal and authenticate
const { did, connected } = await this._iam.initializeConnection({
walletProvider: WalletProvider.MetaMask,
});

// after successfully authentication you can retrieve the signer
const signer = this._iam.getSigner();
}
### 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.

### Sample Config for Node.js (TypeScript)
1. Initializing signer service. It will initialize staking and messaging services and allow to connect to cache server

```js
import { IAM } from 'iam-client-lib'

export class App {
private _iam: IAM;

constructor() {
// IAM has builtin default settings for VOLTA CHAIN

// If you want to change default cache server config or add config for your network
setCacheClientOptions(1111, {
url: 'https://some-cache-server.com/',
cacheServerSupportsAuth: true,
})

// If you want to change default chain config or add config for your network
setChainConfig(1111, {
didContractAddress: '0x3e2fb24edc3536d655720280b427c91bcb55f3d6',
ensRegistryAddress: '0xa372d665f83197a63bbe633ebe19c7bfd4943003',
ensResolverAddress: '0xe878bdcf5148307378043bfd2b584909aa48a227',
rpcUrl: 'http://some-rpc.com',
})

// create IAM instance
this._iam = new IAM({
// only for Node.js env you need to pass rpcUrl in the constructor
rpcUrl: 'http://some-rpc.com',
privateKey: '9945c05be0b1b7b35b7cec937e78c6552ecedca764b53a772547d94a687db929'
});
}

const {
signerService,
stakingService,
messagingService,
connectToCacheServer,
isSessionActive,
storeSession
} = await initWithPrivateKeySigner(privateKey, rpcUrl)
```

2. Connecting to cache server. Depending on signer type signature might be requested

async initializeIAM() {
// this will authenticate
const { did, connected } = await this._iam.initializeConnection();
```js
// IAM has builtin default settings for VOLTA CHAIN, which can overriden
setChainConfig(1111, {
didContractAddress: '0x3e2fb24edc3536d655720280b427c91bcb55f3d6',
ensRegistryAddress: '0xa372d665f83197a63bbe633ebe19c7bfd4943003',
ensResolverAddress: '0xe878bdcf5148307378043bfd2b584909aa48a227',
rpcUrl: 'http://some-rpc.com',
})

setMessagingOptions(1111, {
messagingMethod: MessagingMethod.Nats,
natsServerUrl: 'https://some-exchange-server.com'
})

setCacheClientOptions(1111, {
url: 'https://some-cache-server.com/',
cacheServerSupportsAuth: true,
})

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

// after successfully authentication you can retrieve the signer
const signer = this._iam.getSigner();
}
3. Connecting to DID registry.

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

## Development
Expand Down Expand Up @@ -173,9 +130,9 @@ npm run build

## Active Maintainers

- [Ahmed Ibrahim](https://github.com/ahmedolaibrahim)
- [John Henderson](https://github.com/jrhender)
- [Dmitry Fesenko](https://github.com/JGiter)
* [Ahmed Ibrahim](https://github.com/ahmedolaibrahim)
* [John Henderson](https://github.com/jrhender)
* [Dmitry Fesenko](https://github.com/JGiter)

## Contributing

Expand Down
3 changes: 2 additions & 1 deletion bili.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const config: Config = {
typescript2: {
tsconfigOverride: {
include: ["src", "ethers"],
exclude: ["e2e"],
},
},
},
Expand All @@ -18,7 +19,7 @@ const config: Config = {
// nat.ws only provides a .mjs file which cannot be required.
// include tslib for clients using older version of tslib
bundleNodeModules: ["tslib"],
input: "src/iam-client-lib.ts",
input: "src/index.ts",
output: {
minify: false,
},
Expand Down

0 comments on commit 016a2b4

Please sign in to comment.