npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@synet/identity

v1.0.2

Published

Simple and secure identity management library for Verifiable Identity

Readme

@synet/identity

 .d8888b.                             888                          
d88P  Y88b                            888                          
Y88b.                                 888                          
 "Y888b.   888  888 88888b.   .d88b.  888888                       
    "Y88b. 888  888 888 "88b d8P  Y8b 888                          
      "888 888  888 888  888 88888888 888                          
Y88b  d88P Y88b 888 888  888 Y8b.     Y88b.                        
 "Y8888P"   "Y88888 888  888  "Y8888   "Y888                       
                888                                                
           Y8b d88P                                                
            "Y88P"                                                 
      8888888     888                   888    d8b 888             
        888       888                   888    Y8P 888             
        888       888                   888        888             
        888   .d88888  .d88b.  88888b.  888888 888 888888 888  888 
        888  d88" 888 d8P  Y8b 888 "88b 888    888 888    888  888 
        888  888  888 88888888 888  888 888    888 888    888  888 
        888  Y88b 888 Y8b.     888  888 Y88b.  888 Y88b.  Y88b 888 
      8888888 "Y88888  "Y8888  888  888  "Y888 888  "Y888  "Y88888 
                                                               888 
                                                          Y8b d88P 
                                                           "Y88P"                              
version: 1.0.2  

Self-Sovreign Identity

A complete implementation for creating and managing decentralized identities through composition of DID, Signer, Key, and Credential units.

Features

  • Unit Architecture - Props-based construction with teaching/learning pattern
  • Complete Identity Management - DID generation, signing, and verifiable credentials
  • Unit Composition - Composes DID, Signer, Key, and Credential units
  • Result Pattern - Type-safe error handling for all operations
  • Security First - Secure cryptographic operations with ed25519

Installation

npm install @synet/identity

Quick Start

Generate New Identity

import { Identity } from '@synet/identity';

// Generate a new identity with fresh cryptographic material
const result = await Identity.generate('alice');

if (result.isSuccess) {
  const identity = result.value;
  
  console.log('Identity created:', {
    alias: identity.alias,
    did: identity.did,
    publicKey: identity.publicKeyHex
  });
}

Create from Configuration

const identity = Identity.create({
  alias: 'bob',
  publicKeyHex: '...',
  privateKeyHex: '...',
  did: 'did:key:...',
  provider: 'did:key'
});

if (identity.isSuccess) {
  console.log('Identity loaded:', identity.value.props.alias);
}

Unit Architecture API

Core Methods

// Required Unit methods
identity.whoami()          // Get unit identity
identity.capabilities()    // List all capabilities
identity.help()            // Show help information

Native Capabilities

// Identity operations
await identity.generate('alias')
identity.public(); // public identity data
identity.present(); // type of IdentityPresent { did, alias, publicKey, credential}
identity.toJSON();  // JSON object for storage
identity.toDomain(); // IIdentity domain type.

Composed Units Access

// Access composed units for direct operations
const did = identity.didUnit()
const signer = identity.signerUnit()
const key = identity.keyUnit()
const credential = identity.credentialUnit()

// Use composed unit capabilities
const signature = await signer.sign('hello world')
const publicKey = key.getPublicKeyHex()
const vc = await credential.issueCredential<CredentialSubject>()

// Docs and usage
key.help();
signer.help();
vc.help();

Props-Based Data Access 📊

// All data accessible through props (single source of truth)
const {
  alias,
  did,
  publicKeyHex,
  privateKeyHex,
  provider,
  credential,
  metadata,
  createdAt
} = identity.props

// Getters to access public properties
identity.alias
identity.did
identity.publicKeyHex
identity.credential
identity.metadata

Types


// identity.create() input signature
export interface IdentityConfig {
  alias?: string;
  did?: string;
  kid?: string;
  publicKeyHex?: string;
  privateKeyHex?: string;
  provider?: string;
  credential?: SynetVerifiableCredential<BaseCredentialSubject>;
  metadata?: Record<string, unknown>;
  createdAt?: Date;
}

// Internal state after validation
export interface IdentityProps extends UnitProps {
  dna: UnitSchema;
  alias: string;
  did: string;
  kid: string;
  publicKeyHex: string;
  privateKeyHex?: string;
  provider: string;
  credential: SynetVerifiableCredential<BaseCredentialSubject>;
  metadata: Record<string, unknown>;
  createdAt: Date;
  // Composed units for internal operations
  didUnit: DID;
  signerUnit: Signer;
  keyUnit: ReturnType<Signer["createKey"]>;
  credentialUnit: Credential;
}

// Domain interface identity.toDomain()
export interface IIdentity {
  alias: string
  did: string
  kid: string
  publicKeyHex: string
  privateKeyHex?: string 
  provider: string // did:key | did:web
  credential: SynetVerifiableCredential<BaseCredentialSubject>
  metadata?: Record<string, unknown>
  createdAt: Date 
}

// Presentation interface identity.present(); 
export interface IdentityPresent {
  did: string
  publicKeyHex: string
  credential: SynetVerifiableCredential<BaseCredentialSubject>  
}

Error handling

All async operations return Result<T> for type-safe error handling:

const result = await Identity.generate('alice')

if (result.isSuccess) {
  const identity = result.value
  // Use identity safely
} else {
  console.error('Failed:', result.error)
  console.log('Cause:', result.cause)
}

Persistance

import { IIdentity } from "@synet/identity"
import { FS } from "@synet/fs"
import { Vault } from "@synet/vault"

// Node filesystem, S3 or Github
const fs = FS.async.node();
const fs = FS.async.S3(options);

// Create anywhere
const vault = Vault.create<IIdentity>({
        path: path.join(config.vaultPath, "identity"),
        fs: fs,
        name: "Identity Vault",
});

// Run on startup 
await vault.init();

// Generate new identity
const identity = Identity.generate('neo');

// Save to vault with id = did
await vault.save(
  identity.did,
  identity.toDomain()
);

// reconstitute
const storedIdentity = vault.get(identity.did);
const result = Identity.create(identityData);

if (result.isSuccess) {
  // Use identity safely, domain object
  const identity = result.value

} else {
  console.error('Failed:', result.errorMessage)
  console.log('Cause:', result.errorCause)
}

Dependencies 📦

  • @synet/unit - Unit Architecture foundation
  • @synet/keys - Cryptographic key operations
  • @synet/did - DID generation and management
  • @synet/credential - Verifiable credential operations

License

MIT License - see LICENSE file for details.


Part of SYNET Unit Architecture Ecosystem 🌐

Built with Unit Architecture Doctrine v1.0.5 - Consciousness-based software architecture where units are self-aware, can teach capabilities to other units, learn from others, and evolve while maintaining identity.