@cosmicdrift/kumiko-bundled-features 0.392.0 → 0.392.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,7 +41,7 @@ function ViewAllLink() {
41
41
  const { Link } = usePrimitives();
42
42
  const nav = useNav();
43
43
  const target = { screenId: MY_CAPS_SCREEN_ID };
44
- return (_jsx(Link, { href: nav.hrefFor(target), onPress: () => nav.navigate(target), variant: "muted", testId: "cap-cards-view-all", children: t("cap-overview.cards.viewAll") }));
44
+ return (_jsx(Link, { href: nav.hrefFor(target), onPress: () => nav.navigate(target), testId: "cap-cards-view-all", children: t("cap-overview.cards.viewAll") }));
45
45
  }
46
46
  function CapUsageSummaryRow({ cap }) {
47
47
  const t = useTranslation();
@@ -1,5 +1,18 @@
1
1
  import * as z from "zod";
2
+ import { type ImapCredentialDocument } from "./credential-document.ts";
3
+ declare const connectMailboxSchema: z.ZodObject<{
4
+ host: z.ZodString;
5
+ port: z.ZodDefault<z.ZodNumber>;
6
+ user: z.ZodString;
7
+ displayName: z.ZodString;
8
+ address: z.ZodEmail;
9
+ password: z.ZodString;
10
+ smtpHost: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>>;
11
+ smtpPort: z.ZodNumber;
12
+ }, z.core.$strip>;
13
+ type ConnectMailboxPayload = z.infer<typeof connectMailboxSchema>;
2
14
  export declare function deriveSmtpHost(imapHost: string): string;
15
+ export declare function credentialDocumentOf(payload: ConnectMailboxPayload): ImapCredentialDocument;
3
16
  export declare const connectMailboxHandler: import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"connect-mailbox", z.ZodObject<{
4
17
  host: z.ZodString;
5
18
  port: z.ZodDefault<z.ZodNumber>;
@@ -8,6 +21,8 @@ export declare const connectMailboxHandler: import("@cosmicdrift/kumiko-types/de
8
21
  address: z.ZodEmail;
9
22
  password: z.ZodString;
10
23
  smtpHost: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>>;
24
+ smtpPort: z.ZodNumber;
11
25
  }, z.core.$strip>, {
12
26
  accountId: string;
13
27
  }, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, null>;
28
+ export {};
@@ -8,12 +8,12 @@ import { defineWriteHandler, } from "@cosmicdrift/kumiko-framework/engine";
8
8
  import { UnprocessableError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
9
9
  import * as z from "zod";
10
10
  import { IMAP_CONNECT_ERRORS, IMAP_PROVIDER_KEY, SMTP_CONNECT_ERRORS } from "./constants.js";
11
- import { imapCredentialDocumentSchema, SMTP_IMPLICIT_TLS_PORT, smtpHostSchema, } from "./credential-document.js";
11
+ import { imapCredentialDocumentSchema, smtpHostSchema, } from "./credential-document.js";
12
12
  import { connectOnce, IMAP_HOST_UNREACHABLE_MESSAGE } from "./imap-client.js";
13
13
  import { SmtpFailureError, verifySmtpLogin } from "./smtp-client.js";
14
- // No `secure` and no SMTP port input: the password never crosses the wire in clear text, so a
15
- // payload's secure:false or smtpPort is stripped like any unknown key and both logins always use
16
- // implicit TLS (SMTP on port 465).
14
+ // No `secure`: the password never crosses the wire in clear text, so a payload's secure:false is
15
+ // stripped like any unknown key. IMAP uses implicit TLS; SMTP uses implicit TLS on 465 and
16
+ // enforced STARTTLS on every other port.
17
17
  const connectMailboxSchema = imapCredentialDocumentSchema
18
18
  .pick({ host: true, port: true, user: true })
19
19
  .extend({
@@ -21,6 +21,7 @@ const connectMailboxSchema = imapCredentialDocumentSchema
21
21
  address: z.email().max(320),
22
22
  password: z.string().min(1).max(1000),
23
23
  smtpHost: z.union([z.literal(""), smtpHostSchema]).nullish(),
24
+ smtpPort: z.number().int().min(1).max(65535),
24
25
  });
25
26
  const connectedAccountSchema = z.object({ accountId: z.string() });
26
27
  // Matched on the mapped error text, which also carries the host, so only markers no host name
@@ -34,10 +35,10 @@ const SECRET_TRANSACTION_REASON = "the credential secret is written on the reque
34
35
  export function deriveSmtpHost(imapHost) {
35
36
  return /^imap\./i.test(imapHost) ? `smtp.${imapHost.slice("imap.".length)}` : imapHost;
36
37
  }
37
- function credentialDocumentOf(payload) {
38
- const { host, port, user, password } = payload;
38
+ export function credentialDocumentOf(payload) {
39
+ const { host, port, user, password, smtpPort } = payload;
39
40
  const smtpHost = payload.smtpHost || deriveSmtpHost(host);
40
- return { host, port, secure: true, user, password, smtpHost, smtpPort: SMTP_IMPLICIT_TLS_PORT };
41
+ return { host, port, secure: true, user, password, smtpHost, smtpPort };
41
42
  }
42
43
  // The raw error carries the host and the server response; the tenant only gets the category.
43
44
  // A blocked host and an unresolvable one share one text on purpose (see createImapClient).
@@ -97,7 +98,7 @@ export const connectMailboxHandler = defineWriteHandler({
97
98
  if (smtpFailure) {
98
99
  const { reason, i18nKey } = SMTP_CONNECT_ERRORS[smtpFailure];
99
100
  ctx.obs.log.warn("smtp connect check failed", { reason });
100
- return writeFailure(new UnprocessableError(reason, { i18nKey }));
101
+ return writeFailure(new UnprocessableError(reason, { i18nKey, i18nParams: { port: doc.smtpPort } }));
101
102
  }
102
103
  return { isSuccess: true, data: null };
103
104
  },
@@ -39,3 +39,4 @@ export declare const SMTP_CONNECT_ERRORS: {
39
39
  readonly i18nKey: "inboundMail.imap.connect.errors.smtpConnectFailed";
40
40
  };
41
41
  };
42
+ export declare const SMTP_SUBMISSION_PORT = 587;
@@ -37,3 +37,4 @@ export const SMTP_CONNECT_ERRORS = {
37
37
  i18nKey: "inboundMail.imap.connect.errors.smtpConnectFailed",
38
38
  },
39
39
  };
40
+ export const SMTP_SUBMISSION_PORT = 587;
@@ -1,6 +1,5 @@
1
1
  import { type InboundMailContext, type MailAccountRecord } from "@cosmicdrift/kumiko-bundled-features/inbound-mail-foundation";
2
2
  import * as z from "zod";
3
- export declare const SMTP_IMPLICIT_TLS_PORT = 465;
4
3
  export declare const smtpHostSchema: z.ZodString;
5
4
  export declare const imapCredentialDocumentSchema: z.ZodObject<{
6
5
  host: z.ZodString;
@@ -21,8 +21,7 @@
21
21
  import { InboundAuthError, inboundCredentialSecretKey, } from "@cosmicdrift/kumiko-bundled-features/inbound-mail-foundation";
22
22
  import { requireSecretsContext } from "@cosmicdrift/kumiko-bundled-features/secrets";
23
23
  import * as z from "zod";
24
- import { FEATURE_NAME } from "./constants.js";
25
- export const SMTP_IMPLICIT_TLS_PORT = 465;
24
+ import { FEATURE_NAME, SMTP_SUBMISSION_PORT } from "./constants.js";
26
25
  // A bare host name: a port, path or whitespace would point the connect somewhere the guard did
27
26
  // not check.
28
27
  export const smtpHostSchema = z
@@ -38,7 +37,7 @@ export const imapCredentialDocumentSchema = z.object({
38
37
  password: z.string().min(1).optional(),
39
38
  accessToken: z.string().min(1).optional(),
40
39
  smtpHost: smtpHostSchema.optional(),
41
- smtpPort: z.number().int().min(1).max(65535).default(SMTP_IMPLICIT_TLS_PORT),
40
+ smtpPort: z.number().int().min(1).max(65535).default(SMTP_SUBMISSION_PORT),
42
41
  });
43
42
  export function parseImapCredentialDocument(raw) {
44
43
  let json;
@@ -12,10 +12,11 @@ export const INBOUND_PROVIDER_IMAP_I18N = {
12
12
  [formFieldKey("user")]: { en: "User name" },
13
13
  [formFieldKey("password")]: { en: "Password" },
14
14
  [formFieldKey("smtpHost")]: { en: "Outgoing server (SMTP)" },
15
+ [formFieldKey("smtpPort")]: { en: "SMTP port" },
15
16
  "inboundMail.imap.connect.server": { en: "Server sign-in" },
16
17
  "inboundMail.imap.connect.outgoing": { en: "Sending" },
17
18
  "inboundMail.imap.connect.outgoingHint": {
18
- en: "Replies go out from this address over your own mail server, with the same user name and password. Leave the field empty if the server is called like the IMAP server, with smtp. instead of imap.",
19
+ en: "Replies go out from this address over your own mail server, with the same user name and password. Leave the field empty if the server is called like the IMAP server, with smtp. instead of imap. Usually 587, even when your provider lists 465/SSL.",
19
20
  },
20
21
  "inboundMail.imap.connect.submit": { en: "Check and connect" },
21
22
  [IMAP_CONNECT_ERRORS.hostUnreachable.i18nKey]: {
@@ -37,9 +38,9 @@ export const INBOUND_PROVIDER_IMAP_I18N = {
37
38
  en: "Receiving works, but sending does not: the outgoing server rejected the sign-in.",
38
39
  },
39
40
  [SMTP_CONNECT_ERRORS.tlsFailed.i18nKey]: {
40
- en: "Receiving works, but sending does not: the encrypted connection to the outgoing server on port 465 failed.",
41
+ en: "Receiving works, but sending does not: the encrypted connection to the outgoing server on port {port} failed.",
41
42
  },
42
43
  [SMTP_CONNECT_ERRORS.connectFailed.i18nKey]: {
43
- en: "Receiving works, but sending does not: no connection to the outgoing server on port 465.",
44
+ en: "Receiving works, but sending does not: no connection to the outgoing server on port {port}.",
44
45
  },
45
46
  };
@@ -1,6 +1,6 @@
1
1
  import { IMAP_CONNECT_SCREEN_ID, MAIL_ACCOUNT_LIST_SCREEN_QN, } from "@cosmicdrift/kumiko-bundled-features/inbound-mail-foundation";
2
2
  import { i18nKey } from "@cosmicdrift/kumiko-framework/engine";
3
- import { ImapHandlers } from "./constants.js";
3
+ import { ImapHandlers, SMTP_SUBMISSION_PORT } from "./constants.js";
4
4
  // Reached from the toolbar of the foundation's mail account list, never from the nav.
5
5
  export const imapConnectScreen = {
6
6
  id: IMAP_CONNECT_SCREEN_ID,
@@ -15,6 +15,14 @@ export const imapConnectScreen = {
15
15
  user: { type: "text", required: true, maxLength: 320 },
16
16
  password: { type: "text", required: true, format: "password", sensitive: true },
17
17
  smtpHost: { type: "text", maxLength: 255 },
18
+ smtpPort: {
19
+ type: "number",
20
+ integer: true,
21
+ required: true,
22
+ min: 1,
23
+ max: 65535,
24
+ default: SMTP_SUBMISSION_PORT,
25
+ },
18
26
  },
19
27
  layout: {
20
28
  sections: [
@@ -27,7 +35,7 @@ export const imapConnectScreen = {
27
35
  {
28
36
  title: i18nKey("inboundMail.imap.connect.outgoing"),
29
37
  description: i18nKey("inboundMail.imap.connect.outgoingHint"),
30
- fields: ["smtpHost"],
38
+ fields: ["smtpHost", "smtpPort"],
31
39
  },
32
40
  ],
33
41
  },
@@ -1,4 +1,5 @@
1
1
  import { type MailConnectTarget } from "@cosmicdrift/kumiko-bundled-features/foundation-shared";
2
+ export declare const SMTP_IMPLICIT_TLS_PORT = 465;
2
3
  export type SmtpLogin = {
3
4
  readonly host: string;
4
5
  readonly port: number;
@@ -14,7 +15,8 @@ export declare function classifySmtpError(err: unknown): SmtpFailure;
14
15
  export declare function smtpTransportOptions(login: SmtpLogin, target: MailConnectTarget): {
15
16
  readonly host: string;
16
17
  readonly port: number;
17
- readonly secure: true;
18
+ readonly secure: boolean;
19
+ readonly requireTLS?: boolean | undefined;
18
20
  readonly servername?: string | undefined;
19
21
  readonly auth: {
20
22
  readonly user: string;
@@ -1,11 +1,12 @@
1
1
  // nodemailer wiring for sending from a connected mailbox: one short-lived, non-pooled connection
2
- // per call, always implicit TLS, pinned to the address the mail host guard approved.
2
+ // per call, TLS enforced (implicit on 465, STARTTLS otherwise), pinned to the address the mail host guard approved.
3
3
  import { BlockedHostError, resolveMailConnectTarget, } from "@cosmicdrift/kumiko-bundled-features/foundation-shared";
4
4
  import { createFallbackLogger } from "@cosmicdrift/kumiko-framework/logging";
5
5
  import { errorCodeOf, propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
6
6
  import { createTransport } from "nodemailer";
7
7
  import { imapMailHostGuard } from "./imap-client.js";
8
8
  const log = createFallbackLogger("inbound-provider-imap");
9
+ export const SMTP_IMPLICIT_TLS_PORT = 465;
9
10
  // nodemailer's defaults wait minutes; the connect form holds a request open meanwhile.
10
11
  const CONNECTION_TIMEOUT_MS = 10_000;
11
12
  const GREETING_TIMEOUT_MS = 10_000;
@@ -43,7 +44,9 @@ export function smtpTransportOptions(login, target) {
43
44
  return {
44
45
  host: target.host,
45
46
  port: login.port,
46
- secure: true,
47
+ secure: login.port === SMTP_IMPLICIT_TLS_PORT,
48
+ // Without it nodemailer sends AUTH in clear text when the server offers no STARTTLS.
49
+ ...(login.port !== SMTP_IMPLICIT_TLS_PORT && { requireTLS: true }),
47
50
  ...(target.servername && { servername: target.servername }),
48
51
  auth: { user: login.user, pass: login.password },
49
52
  connectionTimeout: CONNECTION_TIMEOUT_MS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmicdrift/kumiko-bundled-features",
3
- "version": "0.392.0",
3
+ "version": "0.392.1",
4
4
  "description": "Built-in features — tenant, user, auth, delivery. The stuff you'd rewrite anyway, already typed.",
5
5
  "license": "MIT",
6
6
  "author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
@@ -558,9 +558,9 @@
558
558
  }
559
559
  },
560
560
  "dependencies": {
561
- "@cosmicdrift/kumiko-framework": "0.392.0",
562
- "@cosmicdrift/kumiko-renderer": "0.392.0",
563
- "@cosmicdrift/kumiko-types": "0.392.0",
561
+ "@cosmicdrift/kumiko-framework": "0.392.1",
562
+ "@cosmicdrift/kumiko-renderer": "0.392.1",
563
+ "@cosmicdrift/kumiko-types": "0.392.1",
564
564
  "@mollie/api-client": "^4.5.0",
565
565
  "@node-rs/argon2": "^2.0.2",
566
566
  "@tiptap/core": "^3.31.3",
@@ -1142,17 +1142,17 @@
1142
1142
  ],
1143
1143
  "devDependencies": {
1144
1144
  "@testing-library/user-event": "^14.6.1",
1145
- "@cosmicdrift/kumiko-locale-de": "0.392.0",
1146
- "@cosmicdrift/kumiko-locale-es": "0.392.0",
1147
- "@cosmicdrift/kumiko-locale-fr": "0.392.0",
1148
- "@cosmicdrift/kumiko-locale-it": "0.392.0",
1149
- "@cosmicdrift/kumiko-renderer-mail-html": "0.392.0",
1145
+ "@cosmicdrift/kumiko-locale-de": "0.392.1",
1146
+ "@cosmicdrift/kumiko-locale-es": "0.392.1",
1147
+ "@cosmicdrift/kumiko-locale-fr": "0.392.1",
1148
+ "@cosmicdrift/kumiko-locale-it": "0.392.1",
1149
+ "@cosmicdrift/kumiko-renderer-mail-html": "0.392.1",
1150
1150
  "jsqr": "^1.4.0",
1151
1151
  "unpdf": "^1.8.1",
1152
- "@cosmicdrift/kumiko-testing": "0.392.0"
1152
+ "@cosmicdrift/kumiko-testing": "0.392.1"
1153
1153
  },
1154
1154
  "peerDependencies": {
1155
- "@cosmicdrift/kumiko-testing": "0.392.0"
1155
+ "@cosmicdrift/kumiko-testing": "0.392.1"
1156
1156
  },
1157
1157
  "peerDependenciesMeta": {
1158
1158
  "@cosmicdrift/kumiko-testing": {
@@ -1,4 +1,10 @@
1
1
  [
2
+ {
3
+ "version": "0.392.1",
4
+ "type": "fix",
5
+ "title": "Cap cards \"view all\" link uses the primary link style",
6
+ "detail": "The link under the cap cards no longer renders in muted grey; it uses the default link variant like other text links."
7
+ },
2
8
  {
3
9
  "version": "0.392.0",
4
10
  "type": "improvement",
@@ -1,4 +1,10 @@
1
1
  [
2
+ {
3
+ "version": "0.392.1",
4
+ "type": "fix",
5
+ "title": "Mailboxes connect and send over SMTP port 587 with STARTTLS",
6
+ "detail": "The connect form gets a required field \"SMTP port\", preset to 587, and stores it as smtpPort in the credential document (the schema still accepts any stored port, default now 587). Port 465 uses implicit TLS; every other port uses STARTTLS with requireTLS, so the password is never sent in clear text and the connection fails when the server offers no STARTTLS. The certificate is checked against the host name on the STARTTLS upgrade as well. The SMTP failure texts name the entered port. New key for the field label in all locale packages."
7
+ },
2
8
  {
3
9
  "version": "0.392.0",
4
10
  "type": "improvement",