TypeScript library to be used within decentralized applications for authentication and authorization using DIDs (Decentralized Identifiers) and VCs (Verifiable Credentials)
React Demo /
Angular Demo /
Vue Demo
Demo source code: iam-client-examples
For development purposes, please follow below steps to integrate the library with your dApps.
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.
Latest stable version
$ npm i iam-client-lib Prerelease version
$ npm i iam-client-lib@canaryimport {
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();
}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'
});
}
async initializeIAM() {
// this will authenticate
const { did, connected } = await this._iam.initializeConnection();
// after successfully authentication you can retrieve the signer
const signer = this._iam.getSigner();
}For testing use npm run test:watch
Using npm to install dependencies:
$ npm installTo generate bundled JS files and types, use the following command. Generated files are located in the dist folder.
$ npm run buildPlease read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project is licensed under the GNU General Public License v3.0 or later - see the LICENSE file for details
Frequently asked questions and their answers will be collected here.