@sneekin/auth
v0.2.0
Published
Sneek Auth — remote client and NestJS guard for Sneek-managed authentication
Readme
@sneekin/auth
Remote Sneek Auth client. Apps no longer generate OTPs, manage refresh-token
rotation, rate-limit identifiers, or verify local JWTs. They call Sneek with
their SNEEK_API_KEY; Sneek owns auth challenges, anti-abuse controls, session
introspection, and billing.
Server Usage
import { SneekAuthClient, SneekAuthGuard, SneekAuthModule } from '@sneekin/auth';
@Module({
imports: [
SneekAuthModule.forRoot({
apiUrl: process.env.SNEEK_API_URL ?? 'https://sneek.in',
apiKey: process.env.SNEEK_API_KEY!,
}),
],
})
export class AuthModule {}Expose app login routes as thin forwards:
await sneekAuth.requestOtp({ identifier });
await sneekAuth.verifyOtp({ requestId, code });Protect app routes with the shared guard:
@UseGuards(SneekAuthGuard)
@Get('me')
me(@Req() req) {
return req.user;
}The guard accepts Authorization: Bearer <sneek-access-token>,
X-Sneek-Access-Token, or the access_token cookie. It introspects the session
against Sneek using the app API key and attaches the standard user object to
request.user.
API Contract
POST /api/v1/auth/otp/request->{ requestId, channels, expiresInSeconds }POST /api/oauth/tokenwithgrant_type=urn:sneek:params:oauth:grant-type:otp-> OAuth token response +userPOST /api/oauth/tokenwithgrant_type=refresh_token-> rotates tokensPOST /api/oauth/introspect-> RFC-7662-shaped{ active, sub?, aud?, exp?, user? }POST /api/oauth/revoke-> RFC-7009-style session revocation
All endpoints require the app's SNEEK_API_KEY; user access tokens are never
used as app credentials.
