@repost/client 1.1.2 → 1.3.0

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = require('./version-Fs1Fdaqh.cjs');
3
+ var version = require('./version-D2hJn-Q1.cjs');
4
4
  var observer = require('./observer-dykSFHYi.cjs');
5
5
 
6
6
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -1401,7 +1401,7 @@ function resolveDefaultTransport(options = {}) {
1401
1401
  function createNodeTransport(options = {}) {
1402
1402
  rejectRuntimeOptions(options);
1403
1403
  let loaded;
1404
- const load = () => loaded ?? (loaded = Promise.resolve().then(function () { return require('./node-Cfq41Fkv.cjs'); }).then((module) => module.createNodeTransport(options)));
1404
+ const load = () => loaded ?? (loaded = Promise.resolve().then(function () { return require('./node-CmUdEVdy.cjs'); }).then((module) => module.createNodeTransport(options)));
1405
1405
  return {
1406
1406
  async send(request) {
1407
1407
  return (await load()).send(request);
@@ -2124,6 +2124,55 @@ function validateAcceptedResponse(outcome, envelope, customerId) {
2124
2124
  return null;
2125
2125
  }
2126
2126
  }
2127
+ const RFC3339 = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[Zz]|([+-])(\d{2}):(\d{2}))$/;
2128
+ /** RFC 3339 `date-time`: shape, field ranges, and a real calendar date. */
2129
+ function isRfc3339(value) {
2130
+ const match = RFC3339.exec(value);
2131
+ if (!match)
2132
+ return false;
2133
+ const [, year, month, day, hour, minute, second, , offsetHour, offsetMinute] = match;
2134
+ const y = Number(year), m = Number(month), d = Number(day);
2135
+ if (m < 1 || m > 12 || d < 1 || Number(hour) > 23 || Number(minute) > 59 || Number(second) > 60)
2136
+ return false;
2137
+ if (offsetHour !== undefined && (Number(offsetHour) > 23 || Number(offsetMinute) > 59))
2138
+ return false;
2139
+ const date = new Date(Date.UTC(y, m - 1, d));
2140
+ return date.getUTCFullYear() === y && date.getUTCMonth() === m - 1 && date.getUTCDate() === d;
2141
+ }
2142
+ /**
2143
+ * The Send log shape answers a duplicate idempotency key with 409 and the
2144
+ * original message id (spec 2026-09-16 §9): an accepted replay, read with
2145
+ * the same limits and strictness as a 2xx body, requiring only `id`; type
2146
+ * and customer are the sent envelope's. The timestamp is the body's own when
2147
+ * it carries one that is valid RFC 3339 (the accepted message's original
2148
+ * timestamp), else the envelope's; a stray value is ignored rather than
2149
+ * demoting the replay to a conflict. `null` means the 409 is not that answer
2150
+ * and keeps today's conflict handling.
2151
+ */
2152
+ function validateDuplicateResponse(outcome, envelope, customerId) {
2153
+ if (outcome.bodyBytes.length > RESPONSE_LIMIT_BYTES
2154
+ || (!outcome.transportLimitsApplied && outcome.compressedBytes > RESPONSE_LIMIT_BYTES)
2155
+ || (!outcome.transportLimitsApplied && outcome.decompressedBytes > RESPONSE_LIMIT_BYTES))
2156
+ return "LIMIT_EXCEEDED";
2157
+ const contentTypes = headerValues(outcome.headers, "content-type");
2158
+ if (contentTypes.length !== 1
2159
+ || !/^[\t ]*application\/json[\t ]*(?:;[\t ]*charset[\t ]*=[\t ]*(?:utf-8|"utf-8")[\t ]*)?$/i.test(contentTypes[0] ?? ""))
2160
+ return null;
2161
+ try {
2162
+ const value = parseStrictJson(outcome.bodyBytes);
2163
+ if (!value || typeof value !== "object" || Array.isArray(value))
2164
+ return null;
2165
+ if (typeof value.id !== "string" || !/^msg_[A-Za-z0-9_-]{1,124}$/.test(value.id))
2166
+ return null;
2167
+ const timestamp = typeof value.timestamp === "string" && isRfc3339(value.timestamp) ? value.timestamp : envelope.timestamp;
2168
+ return Object.freeze({ id: value.id, type: envelope.type, customerId, timestamp });
2169
+ }
2170
+ catch (error) {
2171
+ if (error instanceof StrictJsonLimitError)
2172
+ return "LIMIT_EXCEEDED";
2173
+ return null;
2174
+ }
2175
+ }
2127
2176
  function headerValues(headers, name) {
2128
2177
  const entry = Object.entries(headers).find(([key]) => key.toLowerCase() === name);
2129
2178
  return entry?.[1] ?? [];
@@ -2289,7 +2338,8 @@ class TelemetryInvoker {
2289
2338
  }
2290
2339
  }
2291
2340
 
2292
- const REQUEST_LIMIT_BYTES = 1048576;
2341
+ // Publish request cap: 256 KiB (the server rejects larger bodies with 413).
2342
+ const REQUEST_LIMIT_BYTES = 262144;
2293
2343
  const encoder = new TextEncoder();
2294
2344
  function createSendOperation(config, schema, state) {
2295
2345
  const ownsTransport = config.transport === undefined;
@@ -2519,8 +2569,10 @@ async function send(config, schema, state, transport, observers, telemetry, even
2519
2569
  throw error;
2520
2570
  }
2521
2571
  let classifiedOutcome = outcome;
2522
- if (outcome.kind === "response" && outcome.status >= 200 && outcome.status <= 299) {
2523
- const result = validateAcceptedResponse(outcome, envelope, input.customerId);
2572
+ if (outcome.kind === "response" && ((outcome.status >= 200 && outcome.status <= 299) || outcome.status === 409)) {
2573
+ const result = outcome.status === 409
2574
+ ? validateDuplicateResponse(outcome, envelope, input.customerId)
2575
+ : validateAcceptedResponse(outcome, envelope, input.customerId);
2524
2576
  if (result === "LIMIT_EXCEEDED") {
2525
2577
  classifiedOutcome = { ...outcome, limitExceeded: true };
2526
2578
  }
@@ -2984,4 +3036,4 @@ exports.errorCode = errorCode;
2984
3036
  exports.httpTransport = httpTransport;
2985
3037
  exports.serializeModel = serializeModel;
2986
3038
  exports.stubTransport = stubTransport;
2987
- //# sourceMappingURL=index-DMRwPCbH.cjs.map
3039
+ //# sourceMappingURL=index-D8savdEr.cjs.map