From 68daa76f1289080bcd390f04851679f33fbc3354 Mon Sep 17 00:00:00 2001 From: Brandon Corbett Date: Sat, 31 Oct 2026 08:40:40 -0400 Subject: [PATCH] feat(core): take the message data shapes from @seamless-auth/types Closes #4 --- .changeset/shared-message-types.md | 5 +++++ package-lock.json | 24 ++++++++++++++++++++++++ packages/core/package.json | 3 +++ packages/core/src/messages.ts | 26 ++++++-------------------- packages/core/src/types.ts | 25 ++++--------------------- 5 files changed, 42 insertions(+), 41 deletions(-) create mode 100644 .changeset/shared-message-types.md diff --git a/.changeset/shared-message-types.md b/.changeset/shared-message-types.md new file mode 100644 index 0000000..f0601ba --- /dev/null +++ b/.changeset/shared-message-types.md @@ -0,0 +1,5 @@ +--- +"@seamless-auth/messaging": minor +--- + +The message data shapes (`MessagingChannel`, `DeliveryResult`, `EmailMessage`, `SmsMessage`, `SendOtpEmailInput`, `SendOtpSmsInput` and `SendMagicLinkEmailInput`) now come from `@seamless-auth/types`, the same definitions the auth API and server adapters use. `AuthDeliveryInstruction`, the delivery payload the API returns when the adopter owns delivery, is now exported too. The shapes are unchanged, and `@seamless-auth/types` is only referenced by the type declarations, so nothing new loads at runtime. diff --git a/package-lock.json b/package-lock.json index e5616a9..11f8515 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1289,6 +1289,18 @@ "resolved": "packages/twilio", "link": true }, + "node_modules/@seamless-auth/types": { + "version": "0.33.0", + "resolved": "https://registry.npmjs.org/@seamless-auth/types/-/types-0.33.0.tgz", + "integrity": "sha512-zg0vp+4BGH8gEktYrpU040mAuB/Ebz0orLxqNf3iOavYPzqj3ST9i12IwUKGkbu4A1455JAexrTSZH6C7400jQ==", + "license": "Apache-2.0", + "dependencies": { + "zod": "^4.5.0" + }, + "engines": { + "node": ">=22" + } + }, "node_modules/@smithy/config-resolver": { "version": "4.4.17", "resolved": "https://registry.npmjs.org/@smithy/config-resolver/-/config-resolver-4.4.17.tgz", @@ -4176,6 +4188,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + }, "packages/aws": { "name": "@seamless-auth/messaging-aws", "version": "0.2.0", @@ -4244,6 +4265,9 @@ "name": "@seamless-auth/messaging", "version": "0.2.0", "license": "Apache-2.0", + "dependencies": { + "@seamless-auth/types": "^0.33.0" + }, "engines": { "node": ">=18" } diff --git a/packages/core/package.json b/packages/core/package.json index 1a38cbe..1fabd61 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -27,5 +27,8 @@ }, "publishConfig": { "access": "public" + }, + "dependencies": { + "@seamless-auth/types": "^0.33.0" } } diff --git a/packages/core/src/messages.ts b/packages/core/src/messages.ts index 114579b..51e5343 100644 --- a/packages/core/src/messages.ts +++ b/packages/core/src/messages.ts @@ -1,23 +1,9 @@ -export interface SendOtpEmailInput { - to: string; - token: string; - from?: string; - subject?: string; -} - -export interface SendOtpSmsInput { - to: string; - token: string | number; - from?: string; -} - -export interface SendMagicLinkEmailInput { - to: string; - magicLinkUrl: string; - token?: string; - from?: string; - subject?: string; -} +export type { + AuthDeliveryInstruction, + SendMagicLinkEmailInput, + SendOtpEmailInput, + SendOtpSmsInput, +} from "@seamless-auth/types"; /** * Asks a user to sign in and add a passkey, for example after their account was diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 02b6712..4180a57 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -1,29 +1,12 @@ -export type MessagingChannel = "email" | "sms"; +import type { EmailMessage as SharedEmailMessage } from "@seamless-auth/types"; -export interface DeliveryResult { - accepted: boolean; - provider: string; - channel: MessagingChannel; - messageId?: string; - raw?: unknown; -} +export type { DeliveryResult, MessagingChannel, SmsMessage } from "@seamless-auth/types"; -export interface EmailMessage { - to: string; - from?: string; - subject: string; - text: string; - html?: string; +export type EmailMessage = SharedEmailMessage & { /** * Extra headers to send with the message, such as `List-Unsubscribe`. Names * and values are passed through as given; a transport that cannot send * custom headers ignores them. */ headers?: Record; -} - -export interface SmsMessage { - to: string; - from?: string; - body: string; -} +};