An open API service indexing awesome lists of open source software.

https://github.com/block-core/blockcore-identity

JavaScript Library for Decentralized Identity on Blockcore
https://github.com/block-core/blockcore-identity

web3 web5

Last synced: about 1 year ago
JSON representation

JavaScript Library for Decentralized Identity on Blockcore

Awesome Lists containing this project

README

          

# Blockcore Identity Library (JS)

Library that helps working with DIDs (decentralized identities) on Blockcore and the Blockcore DID Server ("did:is" DID Method).

## Usage

```sh
npm install @blockcore/identity
```

Example usage:

```ts
const privateKey = Uint8Array.from([
224, 238, 59, 150, 73, 84, 228, 234, 104, 62, 83, 160, 122, 31, 108, 129, 74, 29, 104, 195, 192, 81, 158, 11, 167,
100, 217, 121, 110, 12, 178, 14,
]);

const tool = new BlockcoreIdentityTools();
const signer = tool.getSigner(privateKey);
const publicKey = tool.getSchnorrPublicKeyFromPrivateKey(privateKey);
const verificationMethod = tool.getVerificationMethod(publicKey, 1);

const identity = new BlockcoreIdentity(verificationMethod);
const didDocument = identity.document({
service: [
{
id: '#blockexplorer',
type: 'BlockExplorer',
serviceEndpoint: 'https://explorer.blockcore.net',
},
],
});

const jws = await identity.sign(signer, { version: 0, didDocument: didDocument });
```

## Building and Testing

The library can be built using TypeScript Compiler, either directly or through npm:

```
npm run build
```

To generate and update the example documents, use this command:

```
npm run examples
```

This will update the example documents available at [test/examples](test/examples)

## Examples created by the library

[did-configuration.json](https://www.blockcore.net/.well-known/did-configuration.json)

[did.json](https://www.blockcore.net/.well-known/did.json)

(These documents are no longer generated by this library, but a prevoius version)

## Resources

https://w3c.github.io/did-core/