@rineex/authentication-method-otp
v1.1.3
Published
OTP authentication method for Rineex authentication system
Maintainers
Readme
@rineex/authentication-method-otp
OTP authentication method for the Rineex auth system. Implements
AuthMethodPort from @rineex/auth-core and delegates delivery/verification to
OtpChannelPort.
Installation
pnpm add @rineex/authentication-method-otp @rineex/auth-core @rineex/dddPublic API
| Export | Description |
| ---------------- | ------------------------------- |
| OtpAuthMethod | AuthMethodPort implementation |
| OtpChannelPort | Delivery and verification seam |
Usage
import {
OtpAuthMethod,
OtpChannelPort,
} from '@rineex/authentication-method-otp';
import { OtpCode } from './otp-code'; // internal VO; provide generator
const channel: OtpChannelPort = {
async sendOtp(identityId, otp) {
// deliver via SMS, email, etc.
},
async verifyOtp(identityId, otp) {
return true;
},
};
const otpMethod = new OtpAuthMethod(channel, () => OtpCode.generate());
// Register with flow orchestration at composition root
const outcome = await otpMethod.start({
authAttemptId,
ctx: { identityId: identityId.value },
});AuthMethodPort contract
start— generates OTP viaotpGenerator, sends viaOtpChannelPortverify— parses payload, verifies viaOtpChannelPort
Returns AuthMethodOutcome: { ok: true } or { ok: false, violation }.
This is not Result<T> — the application layer wraps outcomes as needed.
Error registry
export const OtpErrorRegistry = {
AUTH_OTP: ['AUTHENTICATION_FAILED'],
} as const;OtpAuthenticationError uses code AUTH_OTP.AUTHENTICATION_FAILED.
Integration with auth-core
- Implement
OtpChannelPortin your infrastructure layer - Instantiate
OtpAuthMethodwith channel + generator - Register with
AuthenticationMethodResolver(consumer wiring) - Wire
AuthenticationAttemptRepositoryPortand flow services
Development
cd packages/authentication/methods/otp
pnpm test
pnpm lint
pnpm check-typesRelated
- @rineex/auth-core
- Passwordless method — standalone challenge flow
License
Apache-2.0
