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
- Host: GitHub
- URL: https://github.com/block-core/blockcore-identity
- Owner: block-core
- License: mit
- Created: 2021-04-04T17:43:54.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-07-20T00:09:12.000Z (almost 3 years ago)
- Last Synced: 2024-10-29T10:44:56.038Z (over 1 year ago)
- Topics: web3, web5
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@blockcore/identity
- Size: 475 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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/