{"id":18180,"library":"brightspace-auth-keys","title":"Brightspace Auth Keys","description":"Library for generating, storing, and retrieving keypairs (RSA/ECDSA) for Brightspace's auth framework. Current stable version is 9.0.1, requires Node >=20.x. Key differentiator: provides abstract store pattern for pluggable backends (Redis, SQL, etc.) and integrates with D2L Auth Token Provisioner. Release cadence is irregular, mostly breaking changes for Node version bumps.","status":"active","version":"9.0.1","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/Brightspace/node-auth","tags":["javascript"],"install":[{"cmd":"npm install brightspace-auth-keys","lang":"bash","label":"npm"},{"cmd":"yarn add brightspace-auth-keys","lang":"bash","label":"yarn"},{"cmd":"pnpm add brightspace-auth-keys","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v9; CommonJS require still works in Node 20+","wrong":"const KeyGenerator = require('brightspace-auth-keys').KeyGenerator","symbol":"KeyGenerator","correct":"import { KeyGenerator } from 'brightspace-auth-keys'"},{"note":"ESM-only since v9","wrong":"const { AbstractPublicKeyStore } = require('brightspace-auth-keys')","symbol":"AbstractPublicKeyStore","correct":"import { AbstractPublicKeyStore } from 'brightspace-auth-keys'"},{"note":"Package has no default export; import * from or named imports required","wrong":"const brightspaceAuthKeys = require('brightspace-auth-keys')","symbol":"default import","correct":"import brightspaceAuthKeys from 'brightspace-auth-keys'"}],"quickstart":{"code":"import { KeyGenerator, AbstractPublicKeyStore } from 'brightspace-auth-keys';\n\nclass MyStore extends AbstractPublicKeyStore {\n  async _storePublicKey(key, expiry) {\n    // store key string with expiry\n  }\n  async _lookupPublicKeys() {\n    // return array of key strings\n    return [];\n  }\n}\n\nconst store = new MyStore();\nconst keyGenerator = new KeyGenerator({\n  signingKeyType: 'EC',\n  ec: { crv: 'P-256' },\n  lifetimes: { keyUse: 3600, token: 300 },\n  publicKeyStore: store\n});\n\nconst privateKey = await keyGenerator.getCurrentPrivateKey();\nconsole.log('Private key obtained:', privateKey);","lang":"typescript","description":"Shows subclassing AbstractPublicKeyStore, instantiating KeyGenerator with EC settings, and retrieving the current private key."},"warnings":[{"fix":"Upgrade Node.js to 20.x or later, or pin to v8.x","message":"Node.js version requirement changed from >=12 to >=20 in v9","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Use ES module imports (import ... from 'brightspace-auth-keys') or dynamic import","message":"Package is ESM-only since v9; no CommonJS default export","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Always provide both signingKeyType and publicKeyStore in constructor options","message":"KeyGenerator requires both signingKeyType and publicKeyStore options; missing one throws immediately","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Ensure _lookupPublicKeys returns an array of opaque strings (e.g., JSON.stringify of JWK)","message":"AbstractPublicKeyStore._lookupPublicKeys must return an array of strings, not objects; non-string items cause runtime errors","severity":"gotcha","affected_versions":">=7.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use class extends AbstractPublicKeyStore { ... } and instantiate with new MyStore()","cause":"Calling AbstractPublicKeyStore as a function without new in ES module context","error":"TypeError: Class constructor AbstractPublicKeyStore cannot be invoked without 'new'"},{"fix":"Set signingKeyType: 'EC' or signingKeyType: 'RSA' in options","cause":"Missing or invalid signingKeyType option in KeyGenerator constructor","error":"Error: signingKeyType must be either 'RSA' or 'EC'"},{"fix":"Implement _storePublicKey(key, expiry) method returning a Promise","cause":"Store instance does not implement _storePublicKey method required by AbstractPublicKeyStore","error":"TypeError: store._storePublicKey is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}