@stripe402/core
v0.0.1
Published
Protocol types, constants, header encoding/decoding, HMAC identity derivation, and error types for the stripe402 protocol. Zero external dependencies (Node.js crypto only).
Readme
@stripe402/core
Protocol types, constants, header encoding/decoding, HMAC identity derivation, and error types for the stripe402 protocol. Zero external dependencies (Node.js crypto only).
Install
npm install @stripe402/coreUsage
Header encoding/decoding
import { encodeHeader, decodeHeader } from '@stripe402/core'
const encoded = encodeHeader({ amount: 500, currency: 'usd' })
const decoded = decodeHeader<{ amount: number; currency: string }>(encoded)Client identity derivation
import { deriveClientId } from '@stripe402/core'
// Deterministic: same card fingerprint + server secret = same client ID
const clientId = deriveClientId(cardFingerprint, serverSecret)Unit conversion
import { unitsToCents, unitsToDollars, UNITS_PER_CENT } from '@stripe402/core'
unitsToCents(500) // 5 (cents)
unitsToDollars(500) // "0.05"Types
Key types exported: PaymentRequiredResponse, PaymentPayload, PaymentResponse, RouteConfig, Stripe402ServerConfig, Stripe402ClientConfig, Stripe402Store, ClientRecord, TransactionRecord.
