3.3.0 • Published 5 months ago

@empe/identity v3.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@empe/identity

A TypeScript implementation of Self-Sovereign Identity (SSI) components following W3C standards for Decentralized Identifiers (DIDs) and Verifiable Credentials (VCs).

Overview

This package provides comprehensive functionality for working with decentralized identity, including:

  • Decentralized Identifiers (DIDs): Creation, management, and resolution of DIDs
  • Verifiable Credentials (VCs): Issuance, verification, and storage of credentials
  • Verifiable Presentations (VPs): Creation and verification of credential presentations
  • Cryptographic Primitives: Key management, signatures, and proofs

The implementation follows the W3C Decentralized Identifiers and W3C Verifiable Credentials Data Model specifications.

Key Components

Decentralized Identifiers (DIDs)

  • CoreDID: Core implementation of DIDs following the standard format did:method:id
  • CoreDocument: Basic DID Document implementation
  • EmpeDocument: Extended DID Document for the Empe method

Verifiable Credentials

  • VerifiableCredential: Implementation of the W3C Verifiable Credential data model
  • VerifiablePresentation: Container for presenting one or more credentials with proof of ownership

Identity Roles

  • Issuer: Entity that creates and signs verifiable credentials
  • Holder: Entity that receives and stores credentials and can create presentations
  • Verifier: Entity that verifies credentials and presentations (implicit in the verification methods)

Key Management

  • KeyService: Management of cryptographic keys
  • JwkService: JSON Web Key operations
  • MnemonicService: Mnemonic phrase generation and handling

Cryptography

  • Proof: Cryptographic proofs for credentials and presentations
  • JWS: JSON Web Signature implementation
  • Signature: Digital signature creation and verification

Usage

Creating a DID

import { CoreDID, JwkService, Secp256k1Factory } from '@empe/identity';
import { MemKeyStorageAdapter } from '@empe/common';

// Create a new DID
const storage = new MemKeyStorageAdapter();
const keyService = new JwkService(storage, new Secp256k1Factory());
const did = await CoreDID.from(keyService);

Creating a Verifiable Credential

import { VerifiableCredential, Issuer, IssuerConfiguration, Client, Network, CoreDID } from '@empe/identity';
import { MemKeyStorageAdapter } from '@empe/common';

// Create a client and document
const storage = new MemKeyStorageAdapter();
const client = new Client({ storage, network: Network.TESTNET });
const document = await client.createEmpeDocument();

// Configure issuer
const config: IssuerConfiguration = {
    document: document,
};
const issuer = client.issuerFromConfiguration(config);

// Issue a verifiable credential
const holderDid = CoreDID.parse('did:empe:testnet:example');
const credential = await issuer.issueVerifiableCredential(holderDid, {
    name: 'John Doe',
    degree: 'Bachelor of Science',
});

Creating a Verifiable Presentation

import { Holder, HolderConfiguration, VerifiablePresentation } from '@empe/identity';
import { MemKeyStorageAdapter } from '@empe/common';

// Configure holder
const config: HolderConfiguration = {
    document: document,
};
const holder = new Holder(config, keyService);

// Create and sign a presentation
const presentation = await holder.issueVerifiablePresentation(
    recipientDid, // DID of the entity receiving the presentation
    holderDid, // DID of the holder creating the presentation
    [credential] // Array of credentials to include
);

Core Standards Support

  • DID Core: Support for did:empe method
  • VC Data Model: Implementation of Verifiable Credentials and Presentations
  • Cryptographic Suites: Support for various cryptographic algorithms
  • JSON-LD Context: Standard contexts for semantic interoperability
  • Proof Formats: JWT and JSON-LD proof formats

Additional Features

  • Schema validation for credentials
  • Key derivation and management
  • Mnemonics for key recovery
  • JWT serialization

Related Packages

This package is part of a larger SSI ecosystem and works with other packages like @empe/common for shared functionality.

License

MIT

3.3.0

5 months ago

3.2.0

5 months ago

3.1.0

5 months ago

3.0.0

8 months ago

2.4.0

8 months ago

2.3.0

9 months ago

2.2.0

9 months ago

2.1.0

9 months ago

2.0.0

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

11 months ago

1.0.0

11 months ago

0.0.14

11 months ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1-alpha

1 year ago