Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@ordinatio/email

Latest version: v1.19.0

Overview

Last scanned
13 Nov 2026
Published
13 Nov 2026
npm package Publisher: ordinatio_ai
24 Versions
2.1K Downloads

Scan summary

@ordinatio/email was last scanned on 13 Nov 2026 at version 1.19.0. Risk score 45 of 100 (medium). High-severity rules fired.

  • Releases: 24 versions; the latest 5 were published within 6 days (8–13 Nov 2026).
  • Findings: 1 rule fired in version 1.19.0 (1 high). The score describes this version only.
  • Downloads: 2,072 downloads.

Versions

24 versions published
Versions and the rules that fired in each
VersionPublishedStatus
1.19.0 LATEST 13 Nov 2026 1 rule fired
1.18.0 13 Nov 2026 1 rule fired
1.17.0 10 Nov 2026 1 rule fired
1.16.0 10 Nov 2026 Not shown
1.15.0 8 Nov 2026 Not shown

Rules fired in 1.19.0: 1

Findings

1 High

Findings for v1.19.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

Encoded data placed in a DNS lookup

A DNS lookup command (nslookup, dig or host) takes its query name from a subshell that first encodes the data, for example with base64 or xxd. Encoding the name turns a lookup into a way to send data to the nameserver of the queried domain. Ordinary diagnostic lookups have no encoding step.

HIGH
Checking access…

🔒 Create a free account to see all 1 finding with descriptions and instance counts

The score describes 1.19.0; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

@ordinatio/email

A standalone, multi-provider email engine with OAuth + IMAP/SMTP support, auto-discovery, templates, scheduled delivery, and OAEM protocol integration.

Built as a Canonical module (C-03) under the Ordinatio architecture. Zero app-layer dependencies — all side effects (activity logging, events, contact resolution) injected via callbacks.


Table of Contents

  • Architecture
  • Quick Start
  • Providers
    • Gmail (OAuth)
    • Outlook (OAuth)
    • IMAP/SMTP (Credentials)
    • Custom Providers
  • Inbox rules
  • OAuth connect state and token resolver
  • Rules form helpers and the rules sweep
  • Old mail, rule drafts and account email
  • Auto-Discovery
  • Email Operations
    • Account Management
    • Inbox & Messages
    • Sync
    • Archive
    • Reply & Compose
    • Content Fetching
  • Templates
    • Template CRUD
    • Variable Rendering
    • Default Templates
  • Scheduled Emails
  • OAEM Protocol Integration
  • Callback Injection Pattern
  • Error System
  • Validation Schemas
  • Testing
  • API Reference

Architecture

┌──────────────────────────────────────────────────┐
│              @ordinatio/email            │
│                                                  │
│  ┌──────────┐  ┌──────────┐  ┌───────────────┐  │
│  │ Providers │  │ Services │  │  Discovery    │  │
│  │           │  │          │  │               │  │
│  │  Gmail    │  │ Account  │  │ MX resolver   │  │
│  │  Outlook  │  │ Messages │  │ Autoconfig    │  │
│  │  IMAP     │  │ Sync     │  │ SRV records   │  │
│  │           │  │ Archive  │  │ Port prober   │  │
│  │           │  │ Content  │  │ Intelligence  │  │
│  │           │  │ Template │  │               │  │
│  │           │  │ Schedule │  │               │  │
│  └─────┬─────┘  └─────┬────┘  └───────┬───────┘  │
│        │              │               │          │
│  ┌─────┴──────────────┴───────────────┴───────┐  │
│  │            types / errors / schemas         │  │
│  └─────────────────────────────────────────────┘  │
└──────────────────────────────────────────────────┘
         ↕ PrismaClient        ↕ Callbacks
   (database injected)   (side effects injected)

Key design principles:

  • Provider-agnostic — Gmail, Outlook, and any IMAP/SMTP server through a unified interface
  • Callback injection — No imports from the host application; activity logging, event emission, contact resolution, and OAEM protocol support are injected at runtime
  • Database-injected — Accepts a PrismaClient instance; works with any tenant database
  • Error-coded — 179 error codes with timestamped references, severity levels, and diagnosis steps (Rule 8)
  • Schema-validated — 11 Zod schemas for all inputs

Quick Start

# Install (within pnpm workspace)
pnpm add @ordinatio/email

# Or reference as workspace dependency
# package.json: "@ordinatio/email": "workspace:*"
import {
  getProvider,
  getActiveAccount,
  syncEmails,
  getInboxEmails,
  replyToEmail,
  discoverProvider,
} from '@ordinatio/email';

// Get the active email provider
const account = await getActiveAccount(db);
const provider = getProvider(account.provider.toLowerCase());

// Sync emails from provider
await syncEmails(db, {
  onActivity: (action, desc, data) => console.log(action, desc),
  onEmailSynced: async (email) => { /* extract context */ },
});

// Read inbox
const { emails, total } = await getInboxEmails(db, {
  status: 'INBOX',
  maxResults: 50,
});

// Auto-discover provider settings for a new email address
const discovery = await discoverProvider('user@acmecorp.com');
// → { domain: 'acmecorp.com', providers: [{ type: 'imap', settings: {...} }] }

Providers

Three built-in providers, plus a registry for custom providers.

Gmail (OAuth)
import { GmailProvider } from '@ordinatio/email';

const gmail = new GmailProvider();
gmail.authType;          // 'oauth'
gmail.getCapabilities(); // { supportsLabels: true, supportsNativeThreading: true, ... }

// OAuth flow
const authUrl = gmail.getAuthUrl('state-token');
const tokens = await gmail.exchangeCodeForTokens(code);
// Token refresh — use getValidAccessToken(db, accountId) instead of calling this directly.
// It handles the 5-minute buffer, token rotation capture, and TokenRevokedError.
const refreshed = await gmail.refreshAccessToken(tokens.refreshToken);

// Operations
const { messages, nextCursor } = await gmail.listMessages(tokens.accessToken, {
  maxResults: 50,
  after: new Date('2026-01-01'),
});
const full = await gmail.getMessage(tokens.accessToken, messageId);
await gmail.archiveMessage(tokens.accessToken, messageId);
await gmail.sendMessage(tokens.accessToken, { to, subject, bodyHtml });

Requests the single gmail.modify scope (enough for every call this provider makes; see src/providers/gmail-scopes.test.ts). If the user completes Google's consent screen but unticks it, exchangeCodeForTokens throws GmailScopeNotGrantedError (test with isGmailScopeNotGrantedError(err); also exported from @ordinatio/email/client). Nothing is stored or revoked: a revoke at Google acts on the whole authorization and could kill an existing live connection. The token Google issued for that rejected grant is simply discarded unused; the user can remove the app at myaccount.google.com/permissions. Grants made under earlier versions' three scopes keep working.

Environment variables:

GOOGLE_CLIENT_ID=xxx
GOOGLE_CLIENT_SECRET=xxx
GOOGLE_REDIRECT_URI=http://localhost:3000/api/email/callback/gmail
Outlook (OAuth)
import { OutlookProvider } from '@ordinatio/email';

const outlook = new OutlookProvider();
outlook.authType;          // 'oauth'
outlook.getCapabilities(); // { supportsFolders: true, maxAttachmentSize: 157286400, ... }

// OAuth flow (Microsoft MSAL)
const authUrl = outlook.getAuthUrl('state-token');
const tokens = await outlook.exchangeCodeForTokens(code);

// Operations use Microsoft Graph API
const { messages } = await outlook.listMessages(tokens.accessToken);
await outlook.archiveMessage(tokens.accessToken, messageId); // Moves to Archive folder

Environment variables:

MICROSOFT_CLIENT_ID=xxx
MICROSOFT_CLIENT_SECRET=xxx
MICROSOFT_REDIRECT_URI=http://localhost:3000/api/email/callback/outlook
IMAP/SMTP (Credentials)

Works with any email provider that supports IMAP and SMTP.

import { ImapSmtpProvider } from '@ordinatio/email';
import type { ImapSmtpCredentials } from '@ordinatio/email';

const imap = new ImapSmtpProvider();
imap.authType; // 'credentials'

// Test connection before saving
const credentials: ImapSmtpCredentials = {
  imapHost: 'imap.fastmail.com',
  imapPort: 993,
  imapSecurity: 'ssl',
  smtpHost: 'smtp.fastmail.com',
  smtpPort: 465,
  smtpSecurity: 'ssl',
  username: 'user@fastmail.com',
  password: 'app-password-here',
};

const test = await imap.testConnection(credentials);
// → { success: true, imapConnected: true, smtpConnected: true, folderCount: 12, messageCount: 1847 }

// Operations
const { messages } = await imap.listMessages(JSON.stringify(credentials));
Custom Providers

Register your own provider implementation:

import { registerProvider } from '@ordinatio/email';
import type { EmailProvider } from '@ordinatio/email';

class ProtonMailProvider implements EmailProvider {
  readonly providerId = 'protonmail';
  readonly authType = 'credentials' as const;
  // ... implement required methods
}

registerProvider('protonmail', () => new ProtonMailProvider());
Provider Capabilities

Each provider declares its capabilities:

interface ProviderCapabilities {
  supportsOAuth: boolean;
  supportsPushNotifications: boolean;
  supportsNativeArchive: boolean;
  supportsNativeThreading: boolean;
  supportsServerSearch: boolean;
  supportsLabels: boolean;      // Gmail-specific
  supportsFolders: boolean;     // IMAP-specific
  archiveAction: 'label_remove' | 'move_folder' | 'flag';
  maxAttachmentSize: number;    // bytes
}
Capability Gmail Outlook IMAP/SMTP
OAuth Yes Yes No
Push notifications Yes Yes (webhooks) No
Native threading Yes (threadId) Yes (conversationId) No
Native archive Yes (remove INBOX label) Yes (move to Archive folder) Flag-based
Server search Yes (full-text) Yes (OData filter) IMAP SEARCH
Max attachment 25 MB 150 MB Varies

Revoking Google access

When a mailbox is deleted, the stored sign-in goes with it, but the grant at Google stays listed under the user's Google account permissions until it is revoked. revokeGoogleToken asks Google to revoke it:

import { revokeGoogleToken } from '@ordinatio/email';

const outcome = await revokeGoogleToken(refreshToken, { tokenKind: 'refresh' });
// outcome.result: 'revoked' | 'already-gone' | 'failed'
  • It never throws, never logs, and never puts the token in the outcome (only Google's short error code, status or an error name), so the outcome is safe to log and to store in an audit entry.
  • Revoke the REFRESH token when you have one: it ends the whole grant. An access token is only a fallback (tokenKind: 'access'); Google's invalid_token reply to one proves nothing about the grant, so it is reported as failed, never already-gone.
  • Bounded by a 4s timeout by default (timeoutMs to change it), so a slow Google cannot stall a deletion.
  • Decide before calling whether another connection to the same Google account and OAuth client exists elsewhere: a revoke acts on the user-and-app authorization as a whole and can cut that connection off too.
  • Decrypting the stored token is the caller's job; this function takes a plain token.

Sync planning

planSync, runPages, syncResultData, isRejectedPageToken and arrivalsToLog decide how to sync one mailbox and what to save afterwards. They have no database, network or clock of their own: you pass the time and supply storage, locking and the provider calls (runPages only calls the callbacks you give it).

import { planSync, runPages, syncResultData, arrivalsToLog, isRejectedPageToken, getProvider } from '@ordinatio/email';
import type { ProviderType } from '@ordinatio/email';

const startedAt = Date.now();
const emailProvider = getProvider(account.provider.toLowerCase() as ProviderType); // 'imap' | 'gmail' | 'outlook'
const plan = planSync({ provider: account.provider, syncCursor: account.syncCursor, lastSyncAt: account.lastSyncAt }, new Date());
const listing = await runPages({
  plan,
  // accessToken: whatever your provider's listMessages takes (for IMAP, the serialized credentials string).
  listPage: (cursor) => emailProvider.listMessages(accessToken, { ...plan.listOptions, cursor }),
  storePage: async (messages) => storeIdempotently(messages), // count stored, or null if the account changed meanwhile
  elapsedMs: () => Date.now() - startedAt,
  perCallTimeoutMs: 20_000, // worst case for ONE listing
  budgetMs: 55_000,         // how long the whole sync may take (e.g. your lock's lifetime minus a reserve)
  onFirstPageFailure: async (error) => { if (isRejectedPageToken(error)) await clearSavedPageToken(account.id); },
});
if (!listing.discarded) {
  await saveAccount(account.id, syncResultData(plan, listing.nextCursor, new Date(startedAt))); // the time the sync BEGAN
  const newMail = arrivalsToLog({ skipped: false, isBackfill: plan.isBackfill, created: listing.created });
}

Inputs (SyncAccountState):

  • provider: 'IMAP' | 'GMAIL' | 'OUTLOOK', either case. Any other value is treated as a cursor-model provider.
  • syncCursor: opaque and provider-specific: the provider's own cursor for IMAP/Outlook, a JSON scan state (written by syncResultData) for Gmail. Never mix them. A Gmail scan state on a non-Gmail account, or a non-scan cursor on a Gmail account, is ignored; reset the cursor on reconnect all the same.
  • lastSyncAt: when the last COMPLETED sync (Gmail: scan) started; null = never synced. An invalid date counts as null; a future one is clamped to now.

How it works:

  • IMAP and Outlook: one page of up to 500 from the stored cursor. Gmail: a bounded after: window (first sync: last 30 days, never further), 100 per page, up to 2 pages per call, resumed across calls through the JSON kept in syncCursor. Gmail cannot use the cursor model: its listing is newest-first and costs one API call per message.
  • runPages stores each page before fetching the next, so a later failure keeps earlier progress (optional onLaterPageFailure is told; with none, the error name is logged); it only fetches another page while the worst case fits budgetMs; if your storePage returns null (the account changed mid-sync) it stops and sets discarded: do not write sync state then.
  • Your storePage must be idempotent (insert if absent): re-listing overlapping mail is expected. Throttling repeat syncs is yours: each Gmail message listed costs an API call.
  • lastSyncAt means "when the last COMPLETED scan started" for Gmail. A reconnect should reset it and the cursor (the next sync is then a backfill and arrivalsToLog reports nothing).
  • isRejectedPageToken is true only when Google REJECTED a saved page token: an HTTP 400 (on status, response.status or code) whose message names the page token, or, for an error with no status at all, a message that says the page token is invalid. A timeout, 429 or 5xx is never one, so a long scan's progress is not thrown away. It relies on Google's error wording naming the token; see the comment in the source.
  • Known gaps: the Gmail scan lists by internal date, so mail that enters the inbox later with an OLDER date (moved out of spam, unarchived) is not seen, and mail older than the 30-day window that arrived while the mailbox sat idle is never imported. After an idle gap longer than the window the next scan is not a backfill: mail from the last 30 days that you did not already have is stored and reported by arrivalsToLog as new.
  • Relationship to syncEmails: the package's bundled single-account syncEmails keeps its own simpler model (50 per page, its own page-token check) and is unchanged. Use this planner when you own storage and need Gmail scans that are bounded and resumable.

People: every email gets a Person

Every stored email corresponds to a Person: the SENDER of received mail, the first recipient of mail you sent. If no Person exists for the address, one is created. A message links to ONE Person (the first counterparty); every other recipient of mail you sent still becomes a Person (up to the cap below). The logic lives here; your app keeps its tables, tenancy and locking, and plugs in through a small PeopleStore.

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @ordinatio/email

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Vulnerability Insights

OpenSSH Password Authentication Bypass on Alpine Linux (*sshole) – CVE-2026-123158

Plug and Pray: Your AI Agents Are Taking Orders From Strangers
Research

Plug and Pray: Your AI Agents Are Taking Orders From Strangers

Copy of Template Design OX Blog (1)
Research

Thousands Of GitHub Accounts Hijacked With wfx-loot CI Secret Stealing Malware Via GitHub Actions & npm

Frame 2085668439 (1)
Group 1261154229