Skip to content
On this page

Function: ocAuthExpress()

TypeScript
function ocAuthExpress(options?: WithOcAuthOptions): (req: ExpressRequestLike, res: ExpressResponseLike, next: ExpressNextLike) => Promise<void>;

Defined in: me-client/src/server.ts:815 (opens in a new tab)

Express / Connect middleware. Attaches req.ocSession (verified SessionPayload | null) and calls next(). Use it as a global middleware or per-route.

import express from 'express'; import { ocAuthExpress } from '@orangecheck/me-client/server';

const app = express(); app.use(ocAuthExpress());

app.get('/api/profile', (req, res) => { if (!req.ocSession) return res.status(401).json({ error: 'sign in' }); res.json({ address: req.ocSession.did_oc }); });

Pass { required: true } to short-circuit unauthenticated requests with a 401 before they reach your handler.

ParametersLink to this section

ParameterType
optionsWithOcAuthOptions

ReturnsLink to this section

(req: ExpressRequestLike, res: ExpressResponseLike, next: ExpressNextLike) => Promise<void>