Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -1,8 +1,12 @@
|
||||
import { createHash } from "node:crypto";
|
||||
|
||||
import { MailProviderError, type MailAddress, type MailAddressInput, type MailProvider, type SendMailInput, type SendMailResult } from "./types.js";
|
||||
|
||||
export const mailjetApiBaseUrl = "https://api.mailjet.com";
|
||||
const DEFAULT_MAILJET_TIMEOUT_MS = 10_000;
|
||||
const DEFAULT_RESPONSE_BODY_LIMIT_BYTES = 4_096;
|
||||
const MAILJET_CUSTOM_ID_MAX_LENGTH = 64;
|
||||
const MAILJET_CUSTOM_ID_HASH_PREFIX = "hivegrid-id:";
|
||||
|
||||
type Fetch = typeof fetch;
|
||||
|
||||
@@ -131,7 +135,7 @@ export class MailjetProvider implements MailProvider {
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
},
|
||||
this.timeoutMs,
|
||||
this.timeoutMs
|
||||
);
|
||||
} catch (error) {
|
||||
this.emitMetric("failed");
|
||||
@@ -292,7 +296,7 @@ function normalizeAttachments(attachments: SendMailInput["attachments"]): { atta
|
||||
ContentType: guessContentType(attachment.filename),
|
||||
Filename: attachment.filename,
|
||||
Base64Content: attachment.content,
|
||||
ContentID: attachment.disposition === "inline" ? attachment.id ?? attachment.filename : undefined,
|
||||
ContentID: attachment.disposition === "inline" ? (attachment.id ?? attachment.filename) : undefined,
|
||||
});
|
||||
|
||||
if (attachment.disposition === "inline") {
|
||||
@@ -345,8 +349,16 @@ function normalizeCustomId(idempotencyKey: string | undefined): string | undefin
|
||||
if (!idempotencyKey) {
|
||||
return undefined;
|
||||
}
|
||||
// Mailjet caps CustomID at 100 characters.
|
||||
return idempotencyKey.slice(0, 100);
|
||||
if (idempotencyKey.length <= MAILJET_CUSTOM_ID_MAX_LENGTH) {
|
||||
return idempotencyKey;
|
||||
}
|
||||
|
||||
// Mailjet rejects CustomID values longer than 64 characters. Preserve short
|
||||
// operational IDs verbatim and compact longer replay keys without truncation
|
||||
// collisions so signup retries keep the same provider correlation value.
|
||||
const digestLength = MAILJET_CUSTOM_ID_MAX_LENGTH - MAILJET_CUSTOM_ID_HASH_PREFIX.length;
|
||||
const digest = createHash("sha256").update(idempotencyKey, "utf8").digest("hex").slice(0, digestLength);
|
||||
return `${MAILJET_CUSTOM_ID_HASH_PREFIX}${digest}`;
|
||||
}
|
||||
|
||||
type MailjetResponseMessage = {
|
||||
|
||||
Reference in new issue
Block a user