• Joined on 2025-12-31

@becom/graph-mail (0.1.0)

Published 2026-06-14 07:51:50 +02:00 by ralf

Installation

@becom:registry=https://git.2i.de/api/packages/ralf/npm/
npm install @becom/graph-mail@0.1.0
"@becom/graph-mail": "0.1.0"

About this package

@becom/graph-mail

Framework-agnostischer Microsoft-Graph-Mail-Adapter (OAuth + Senden + Lesen), gemeinsam genutzt von Astreo und Handled. Keine Persistenz, keine Verschlüsselung, kein Framework — die App injiziert einen TokenStore und mappt die normalisierten Typen auf ihr eigenes Modell.

Design: siehe docs/graph-mail-adapter.md im Astreo-Repo.

Status

  • v0.1 (G0+G1): OAuth (Auth-URL, Code-Tausch, Refresh mit MS-Rotation), Access-Token-Provider, Senden (sendMail/replyMail, Anhänge, Inline-CID), getMessage.
  • Geplant: syncDelta, Subscriptions/Webhooks, updateMessage/moveMessage, Ordner.

Nutzung

import { GraphAuth, GraphMailClient, makeAccessTokenProvider } from '@becom/graph-mail';

const auth = new GraphAuth({
  clientId, clientSecret,
  tenant: 'organizations',           // Single-Tenant: feste ID; SaaS: 'organizations'/'common'
  redirectUri: 'https://app.astreo.de/api/auth/microsoft/mail/callback',
  scopes: ['Mail.ReadWrite', 'Mail.Send', 'offline_access', 'openid', 'email'],
});

// OAuth-Flow
const url = auth.buildAuthUrl(state, { prompt: 'consent' });
const tokens = await auth.exchangeCode(code);      // -> TokenStore.save(accountId, tokens)

// Client (App liefert TokenStore; Provider refresht + persistiert rotierte Tokens)
const getToken = makeAccessTokenProvider(auth, store, accountId);
const client = new GraphMailClient(getToken);

await client.sendMail({ to: [{ address: 'kunde@firma.de' }], subject: 'Hallo', html: '<p>…</p>' });
await client.replyMail(messageId, { html: '<p>Antwort</p>', replyAll: true });

Entwicklung

npm install
npm test        # vitest (kein Netzwerk)
npm run build   # tsc -> dist/

Dependencies

Development Dependencies

ID Version
@types/node ^22.0.0
typescript ^5.6.0
vitest ^2.1.0
Details
npm
2026-06-14 07:51:50 +02:00
17
UNLICENSED
12 KiB
Assets (1)
Versions (2) View all
0.2.0 2026-06-23
0.1.0 2026-06-14