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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@forge-os/aegis

v0.4.0

Published

Aegis trust layer — DIDs (Ed25519), Verifiable Credentials W3C 2.0, hash-chain audit.

Downloads

592

Readme

@forge-os/aegis

npm version

W3C Verifiable Credentials SDK for ArtefactForge OS.

Adoption guide: docs/aegis-sdk-adoption-2026-05-18.md — three end-to-end use cases (browser verify, sign-policy worker, audit fingerprint) with the polyfill recipe required for browser/edge runtimes today.

Aegis is the trust layer of forge-os: every meaningful agent decision can be issued as a W3C Verifiable Credential signed with Ed25519, anchored in a hash-chained audit table, and verified by anyone — including auditors and regulators with no access to the OS backend.

What this package is

A verification-only SDK for the canonical Aegis trust layer. Use it when you need to:

  • Validate a VC issued by ArtefactForge OS (verifyVc)
  • Decide whether a decision requires signing (evaluateSignPolicy, requiresSign, getSignCostThreshold)
  • Compute audit fingerprints (hashJson, hashString)
  • Work with low-level Ed25519 primitives (generateKeyPair, signMessage, verifySignature) for your own DIDs

Everything in the recommended import surface below is pure — no DB calls, no env variables required at runtime — so it works in browsers, edge runtimes, auditing tools, and offline scripts.

What this package is NOT (anymore)

Per ADR-036 (2026-05-06), the signing path for did:key:z6Mk85GCp9YIGEqeQhYKUJecqylr54fzj4DlyJsV83Ui (the canonical BOSS issuer) lives exclusively in the aegis-signer Supabase Edge Function. The keypair is held in Supabase Vault and is never exposed to any worker or client process.

Functions that perform signing or DB writes against forge_aegis.*issueVc, appendAuditChain, getOrCreateDid, getPrivateKeyFromEnv — are kept exported for backwards compatibility and for users running their own Aegis instance, but the canonical forge-os runtime does NOT use them. The llm-direct-worker calls the Edge Function over HTTP (see packages/llm-direct-worker/src/aegis-client.ts).

Recommended import surface

import {
  // Verification (the SDK use case)
  verifyVc,
  type VerifyVcResult,
  type AegisVerifiableCredential,
  type DidDocument,

  // Sign policy (worker decides whether to call the Edge Function)
  evaluateSignPolicy,
  requiresSign,
  getSignCostThreshold,
  type SignPolicyInput,
  type SignPolicyResult,

  // Audit fingerprinting
  hashJson,
  hashString,

  // Low-level Ed25519 (for advanced consumers running their own DIDs)
  generateKeyPair,
  signMessage,
  verifySignature,
  toBase64Url,
  toMultibase,
  fromMultibase,
} from '@forge-os/aegis';

Verification example

import { verifyVc } from '@forge-os/aegis';

// Fetch the credential and the issuer DID Document from wherever they live.
// They are public artefacts — no Supabase access required.
const credential = JSON.parse(vcJsonString);
const didDoc = await fetch(`https://forge.example/dids/${credential.issuer}`)
  .then(r => r.json());

const result = verifyVc(credential, didDoc);
if (result.valid) {
  console.log('VC verified for', credential.credentialSubject.decision_kind);
} else {
  console.error('VC invalid:', result.reason);
}

verifyVc() re-canonicalises the credential without the proof, decodes the Ed25519VerificationKey2020 from the DID Document, and runs an Ed25519 signature check. Returns { valid: boolean, reason?: string } — no exceptions on bad input.

Sign policy example

The policy is a deterministic, pure function. Its output is the canonical trigger for the worker to decide whether to call aegis-signer:

import { evaluateSignPolicy } from '@forge-os/aegis';

const policy = evaluateSignPolicy({
  risk_level: 'high',
  cost_usd: 2.5,
  is_irreversible: true,
});

if (policy.required) {
  // Worker code POSTs to aegis-signer Edge Function here.
  // Reason is stored on the VC subject for audit trail.
  console.log('signing required:', policy.reason);
}

Policy rules (first match wins):

| Order | Trigger | reason | |---|---|---| | 1 | explicit_user_request === true | explicit_user_request | | 2 | is_irreversible === true | external_action_irreversible | | 3 | risk_level === 'critical' | risk_level_critical | | 4 | risk_level === 'high' | risk_level_high | | 5 | cost_usd > AEGIS_SIGN_COST_THRESHOLD_USD (default 1.0) | cost_above_threshold_<value>_usd | | else | — | below_all_thresholds |

Audit chain

The hash-chained audit trail lives in the SQL table forge_aegis.audit_chain inside the forge-os Supabase project. Each row contains prev_hash and hash columns computed by an SQL trigger on insert, so the chain is tamper-evident at the database layer and verifiable end-to-end via the RPC aegis_chain_verify.

This package does not read the chain — fetch it via Supabase RPC (or the aegis-signer Edge Function endpoints /verify, /tail, /stats). The verification of individual VCs against their issuer DID Document is what this SDK provides.

Compatibility note for existing consumers

If your code currently imports issueVc or getOrCreateDid from this package and signs against forge_aegis.* directly, you have two options:

  1. Migrate to the Edge Function (recommended): import AegisSignerClient from @forge-os/llm-direct-worker (or roll your own HTTP client) and call the canonical signer.
  2. Stay on local signing (only if you run a separate Aegis instance with its own DID): functions remain exported. Be aware that any VC you produce will not chain into the canonical forge_aegis.audit_chain of forge-os.

License

Elastic License 2.0 — see LICENSE at the repo root.