{"id":40876,"library":"ecdsa-sig-formatter","title":"ecdsa-sig-formatter","description":"Translate ECDSA signatures between ASN.1/DER and JOSE-style concatenation formats. Version 1.0.11 is the latest stable version; the package is rarely updated but widely depended on by libraries like jsonwebtoken. It converts DER-encoded signatures (common in OpenSSL, crypto libraries) to the concatenated r||s format used by JWT/JOSE standards (ES256, ES384, ES512), and vice versa. It handles base64 encoding/decoding and works with Buffer or string input. Implements no crypto logic itself, only format translation.","status":"maintenance","version":"1.0.11","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/Brightspace/node-ecdsa-sig-formatter","tags":["javascript","ecdsa","der","asn.1","jwt","jwa","jsonwebtoken","jose","typescript"],"install":[{"cmd":"npm install ecdsa-sig-formatter","lang":"bash","label":"npm"},{"cmd":"yarn add ecdsa-sig-formatter","lang":"bash","label":"yarn"},{"cmd":"pnpm add ecdsa-sig-formatter","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Named export. For TypeScript, use named import with ES module syntax.","wrong":"const derToJose = require('ecdsa-sig-formatter').derToJose;","symbol":"derToJose","correct":"import { derToJose } from 'ecdsa-sig-formatter';"},{"note":"Named export. For TypeScript, use named import with ES module syntax.","wrong":"const joseToDer = require('ecdsa-sig-formatter').joseToDer;","symbol":"joseToDer","correct":"import { joseToDer } from 'ecdsa-sig-formatter';"},{"note":"ESM namespace import works; CJS require also works but is less ideal for TypeScript.","wrong":"const format = require('ecdsa-sig-formatter');","symbol":"full module","correct":"import * as format from 'ecdsa-sig-formatter';\nformat.derToJose(derSig, 'ES256');"}],"quickstart":{"code":"import { derToJose, joseToDer } from 'ecdsa-sig-formatter';\n\n// DER-encoded signature (e.g., from crypto.createSign)\nconst derSignature = Buffer.from(\n  '304402202b3b6b8b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b022043b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b9b',\n  'hex'\n);\n\n// Convert to JOSE base64url format\nconst joseSig = derToJose(derSignature, 'ES256');\nconsole.log('JOSE signature:', joseSig);\n\n// Convert back to DER\nconst derSigAgain = joseToDer(joseSig, 'ES256');\nconsole.log('DER signature:', derSigAgain.toString('hex'));","lang":"typescript","description":"Demonstrates converting DER-encoded ECDSA signature to JOSE format and back using derToJose and joseToDer."},"warnings":[{"fix":"Ensure alg is one of the supported JOSE algorithm names.","message":"The alg parameter must be exactly one of 'ES256', 'ES384', or 'ES512'. Passing an invalid algorithm string will cause an error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use appropriate base64 encoding before passing string arguments.","message":"Input signature string must be base64 encoded (for derToJose) or base64url encoded (for joseToDer). Otherwise, conversion may silently fail or produce incorrect output.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Validate the input signature format before calling these functions.","message":"The package does not validate the signature itself; it assumes the input is a valid ECDSA signature in the expected format. Invalid DER or JOSE signatures may cause unexpected errors or buffers of wrong length.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"For new projects, evaluate if this dependency is necessary; prefer native Web Crypto API or comprehensive JWT libraries.","message":"No deprecation warnings have been noted, but the package is rarely updated and may be considered legacy. Consider using crypto.subtle or jose library for new projects.","severity":"deprecated","affected_versions":">=1.0.11"}],"env_vars":null,"search_vec":"'1.0.11':17 'asn.1':85 'asn.1/der':9 'base64':65 'buffer':70 'common':42 'concaten':14,49 'convert':37 'crypto':45,76 'depend':30 'der':39,84 'der-encod':38 'ecdsa':2,6,83 'ecdsa-sig-formatt':1 'encod':40 'encoding/decoding':66 'es256':57 'es384':58 'es512':59 'format':15,52,80 'formatt':4 'handl':64 'implement':74 'input':73 'javascript':82 'jose':12,89 'jose-styl':11 'jsonwebtoken':35,88 'jwa':87 'jwt':86 'jwt/jose':55 'latest':20 'librari':33,46 'like':34 'logic':77 'openssl':44 'packag':24 'r':50 'rare':26 'sig':3 'signatur':7,41 'stabl':21 'standard':56 'string':72 'style':13 'translat':5,81 'typescript':90 'updat':27 'use':53 'versa':62 'version':16,22 'vice':61 'wide':29 'work':68","created_at":"2026-06-04T18:49:41.798054+00:00","updated_at":"2026-06-04T18:49:41.798054+00:00","problems":[{"fix":"Use only 'ES256', 'ES384', or 'ES512' as the second argument.","cause":"Passing an unsupported algorithm name (e.g., 'ES256K') to derToJose or joseToDer.","error":"Error: Invalid algorithm. Supported algorithms: ES256, ES384, ES512"},{"fix":"Ensure the signature is either a Buffer or a string (base64 or base64url encoded).","cause":"Passing a number, null, undefined, or object as the signature argument.","error":"Error: Unsupported input type. Signature must be a Buffer or a string."},{"fix":"Ensure the string is base64 encoded (without padding or with padding) before passing to derToJose. For joseToDer, the string should be base64url encoded.","cause":"Passing a string that is not valid base64 to derToJose when signature is a string.","error":"Error: Invalid base64 string"},{"fix":"Convert Uint8Array to Buffer first: Buffer.from(uint8Array).","cause":"Calling derToJose or joseToDer with a non-string/non-Buffer argument (e.g., a Uint8Array or ArrayBuffer).","error":"TypeError: signature must be a Buffer or a string"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/Brightspace/node-ecdsa-sig-formatter#readme","github":"ssh://git@github.com/Brightspace/node-ecdsa-sig-formatter","docs":null,"changelog":null,"pypi":null,"npm":"ecdsa-sig-formatter","openapi_spec":null,"status_page":null,"smithery":null,"categories":["security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}