@odysseon/whoami-adapter-webcrypto
v6.0.0
Published
Native WebCrypto deterministic hashing adapter for Odysseon Whoami
Readme
@odysseon/whoami-adapter-webcrypto
The official WebCrypto hashing adapter for the Odysseon Whoami identity core.
Overview
This package provides a blazing-fast, deterministic hashing implementation using the native Web Crypto API. It strictly implements the ITokenHasher interface required by @odysseon/whoami-core.
By using native platform APIs (globalThis.crypto), this adapter requires zero external dependencies and runs natively in Node.js, Deno, Bun, and modern browsers/edge environments.
Note: This adapter is designed for fast, deterministic hashing (like hashing opaque Refresh Tokens before storing them in a database to prevent database-breach token theft). It is not designed for password hashing. For user passwords, use @odysseon/whoami-adapter-argon2.
Installation
npm install @odysseon/whoami-core @odysseon/whoami-adapter-webcryptoUsage
Inject this adapter into your WhoamiService configuration to enable secure refresh token hashing.
import { WhoamiService } from "@odysseon/whoami-core";
import { WebCryptoTokenHasher } from "@odysseon/whoami-adapter-webcrypto";
// Initialize your core service with the WebCrypto adapter
const authService = new WhoamiService({
tokenHasher: new WebCryptoTokenHasher(),
// ... other dependencies
});