Block a user
@becom/graph-mail (0.2.0)
Published 2026-06-23 19:02:10 +02:00 by ralf
Installation
@becom:registry=https://git.2i.de/api/packages/ralf/npm/npm install @becom/graph-mail@0.2.0"@becom/graph-mail": "0.2.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. - v0.2 (G2 — Empfang):
listMailFolders(Top-Level),syncDelta(inkrementeller Ordner-Sync viamessages/delta, liefert geänderte + entfernte Nachrichten +deltaLink),getAttachments. Threading überconversationId. - Geplant: Subscriptions/Webhooks,
updateMessage/moveMessage, verschachtelte 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
2026-06-23 19:02:10 +02:00
Assets (1)
Versions (2)
View all
npm
5
UNLICENSED
latest
16 KiB
graph-mail-0.2.0.tgz
16 KiB