New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

@sd-jwt/core

Package Overview
Dependencies
Maintainers
1
Versions
285
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sd-jwt/core

SD-JWT RFC 9901 implementation in TypeScript

Source
npmnpm
Version
0.20.1
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

License NPM Release Stars

SD-JWT Implementation in JavaScript (TypeScript)

SD-JWT Core

About

Core library for Selective Disclosure for JWTs (SD-JWT) — RFC 9901.

This package provides types, utilities, encoding/decoding, presentation, and the main SDJwtInstance class — everything needed to issue, present, and verify SD-JWTs.

Check the detail description in our github repo.

Installation

To install this project, run the following command:

# using npm
npm install @sd-jwt/core

# using yarn
yarn add @sd-jwt/core

# using pnpm
pnpm install @sd-jwt/core

Ensure you have Node.js installed as a prerequisite.

Usage

The library can be used to create sd-jwt based credentials. To be compliant with the sd-jwt-vc standard, you can use the @sd-jwt/sd-jwt-vc that is implementing this spec. If you want to use the pure sd-jwt class or implement your own sd-jwt credential approach, you can use this library.

Dependencies

Verification

The library provides two verification approaches:

Standard Verification (Fail-Fast)

The verify() method throws an error immediately when the first validation failure is encountered:

try {
  const result = await sdjwt.verify(credential);
  console.log('Verified payload:', result.payload);
} catch (error) {
  console.error('Verification failed:', error.message);
}

Safe Verification (Collect All Errors)

The safeVerify() method collects all validation errors instead of failing on the first one. This is useful when you want to show users all issues with a credential at once:

import type { SafeVerifyResult, VerificationError } from '@sd-jwt/core';

const result = await sdjwt.safeVerify(credential);

if (result.success) {
  // Verification succeeded
  console.log('Verified payload:', result.data.payload);
  console.log('Header:', result.data.header);
  if (result.data.kb) {
    console.log('Key binding:', result.data.kb);
  }
} else {
  // Verification failed - inspect all errors
  for (const error of result.errors) {
    console.error(`[${error.code}] ${error.message}`);
    if (error.details) {
      console.error('Details:', error.details);
    }
  }
}
Error Codes

The safeVerify() method returns errors with the following codes:

CodeDescription
HASHER_NOT_FOUNDHasher function not configured
VERIFIER_NOT_FOUNDVerifier function not configured
INVALID_SD_JWTSD-JWT structure is invalid or cannot be decoded
INVALID_JWT_FORMATJWT format is malformed
JWT_NOT_YET_VALIDJWT iat or nbf claim is in the future
JWT_EXPIREDJWT exp claim is in the past
INVALID_JWT_SIGNATURESignature verification failed
MISSING_REQUIRED_CLAIMSRequired claim keys are not present
KEY_BINDING_JWT_MISSINGKey binding JWT required but not present
KEY_BINDING_VERIFIER_NOT_FOUNDKey binding verifier not configured
KEY_BINDING_SIGNATURE_INVALIDKey binding signature verification failed
KEY_BINDING_SD_HASH_INVALIDKey binding sd_hash does not match
UNKNOWN_ERRORAn unexpected error occurred

Keywords

sd-jwt

FAQs

Package last updated on 29 Aug 2026

Related posts