← All projects

node

Node.js / TypeScript implementation of the aice-otp channel contract: Channel interface, typed SendError hierarchy, validator, MockChannel reference, and a YAML conformance harness.

  • TypeScript 98.28%
  • JavaScript 1.72%
git@gitlab.com:aice-lab/otp/node.git

Latest release

v1.0.0 ·

README

aice-otp — Node.js implementation

pipeline status coverage report

Node.js / TypeScript implementation of the aice-otp specification. Defines the Channel interface, request/response types, typed errors, a reference MockChannel, and a conformance harness that runs the spec’s vector suite against any adapter implementation.

Concrete provider adapters (e.g. SSL Wireless, Robi, 360dialog, Mailjet) are not bundled here — implement the Channel interface in your own package and run the conformance harness against it.

This package is published to npm as @aice-lab/otp.

Install

npm install @aice-lab/otp

Requires Node.js ≥ 20.

Quickstart

import { MockChannel } from '@aice-lab/otp';

const channel = new MockChannel();
const res = await channel.send({
  channel: 'sms',
  recipient: '+8801712345678',
  code: '123456',
  locale: 'en-US',
});

console.log(res.deliveryId, res.status);

Channel.send validates the request before contacting the provider and surfaces failures as typed errors:

  • InvalidRecipientError — recipient is not a valid E.164 phone (sms/whatsapp) or RFC-5321 mailbox (email).
  • RateLimitedError — provider asked the caller to back off; carries retryAfterSeconds.
  • ProviderUnavailableError — provider is down or unreachable.
  • QuotaExceededError — daily/monthly send quota exhausted.
  • UnsupportedLocaleError — locale not supported by the provider.
  • InternalSendError — anything else; check cause.

All extend SendError; SendError.name matches the spec error code (invalid_recipient, rate_limited, …).

Status

CapabilityShipped
Channel interface, typed request/response/error surfaceyes
validateRequest (E.164 phones, RFC-5321 mailboxes)yes
MockChannel reference adapter for testsyes
Conformance runner for spec vectorsyes
First-party provider adapters (SMS, WhatsApp, email)out of scope

License

Source: FSL-1.1-Apache-2.0 (see LICENSE and LICENSE.FAQ.md).

Documentation

Full documentation: https://otp.aice-lab.org

Contributing

See CONTRIBUTING.md. All commits require DCO sign-off.

Reporting security issues

See SECURITY.md. Do not open public issues for vulnerabilities.

This is a snapshot generated from GitLab. For the live README, see the project page.