@dhaneshpurohit/mockstar 0.1.3 → 0.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,49 @@
1
+ # [0.3.0](https://github.com/dhanesh/mockstar/compare/v0.2.2...v0.3.0) (2026-09-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **webhooks:** close signing-config validation gaps from review round 2 ([62f6cf3](https://github.com/dhanesh/mockstar/commit/62f6cf37b8e157494076257213ebbcde56783cf0)), closes [#30](https://github.com/dhanesh/mockstar/issues/30) [#30](https://github.com/dhanesh/mockstar/issues/30)
7
+ * **webhooks:** convert JSDoc comments to line comments for RT-9 compliance ([70840e4](https://github.com/dhanesh/mockstar/commit/70840e4f6e1e0ac16e58611a94e818c75425fa18))
8
+ * **webhooks:** correct stale signing docs, reject {{ }} in signing templates, guard superRefine for future modes ([f62b1b0](https://github.com/dhanesh/mockstar/commit/f62b1b0f5b30d3091b791820ef796f03e36b76e4)), closes [#30](https://github.com/dhanesh/mockstar/issues/30)
9
+ * **webhooks:** give signing.mode a default so the emitted JSON Schema matches parse behaviour ([9a86781](https://github.com/dhanesh/mockstar/commit/9a8678131b88271671282fdd4a600d95edb22f15)), closes [#30](https://github.com/dhanesh/mockstar/issues/30)
10
+ * **webhooks:** tighten [#30](https://github.com/dhanesh/mockstar/issues/30) signing-scheme validation per code review ([b0b0ff7](https://github.com/dhanesh/mockstar/commit/b0b0ff752e358e35ff3965e7ec6c45df9ab8899d))
11
+
12
+
13
+ ### Features
14
+
15
+ * **webhooks:** add signature-scheme placeholder engine ([4c8f01c](https://github.com/dhanesh/mockstar/commit/4c8f01c23289d097a37474018eb14bd0b3fdc225)), closes [#30](https://github.com/dhanesh/mockstar/issues/30)
16
+ * **webhooks:** allow suppressing the standalone timestamp header ([#30](https://github.com/dhanesh/mockstar/issues/30)) ([661ec59](https://github.com/dhanesh/mockstar/commit/661ec5903084a8a684b5c34948ae40afe91b6bff))
17
+ * **webhooks:** emit the configured signature wire format ([762a794](https://github.com/dhanesh/mockstar/commit/762a7947455ae68bf8ff5f78dfe5ae3e08741a18)), closes [#30](https://github.com/dhanesh/mockstar/issues/30)
18
+ * **webhooks:** make signPayload/verifySignature scheme-aware ([f5c69ef](https://github.com/dhanesh/mockstar/commit/f5c69ef53367f9f73c06e25770516d2e91e3800e)), closes [#30](https://github.com/dhanesh/mockstar/issues/30)
19
+ * **webhooks:** model signing as a discriminated union on mode ([2890f36](https://github.com/dhanesh/mockstar/commit/2890f3649e9086856b44c517cd5e49c1e6c84f15)), closes [#30](https://github.com/dhanesh/mockstar/issues/30)
20
+
21
+ ## [0.2.2](https://github.com/dhanesh/mockstar/compare/v0.2.1...v0.2.2) (2026-07-06)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * **pkg:** add repository/homepage/bugs so provenance validation passes ([c07a6e0](https://github.com/dhanesh/mockstar/commit/c07a6e0c8682c170ce75b5eb84fa0cfb3f1ae32f))
27
+
28
+ ## [0.2.1](https://github.com/dhanesh/mockstar/compare/v0.2.0...v0.2.1) (2026-07-06)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **ci:** sudo the global npm upgrade in publish-npm (EACCES on runner) ([3b96c45](https://github.com/dhanesh/mockstar/commit/3b96c45244ba1670df38af5f0ce637905bf3f450))
34
+
35
+ # [0.2.0](https://github.com/dhanesh/mockstar/compare/v0.1.3...v0.2.0) (2026-07-06)
36
+
37
+
38
+ ### Bug Fixes
39
+
40
+ * **release:** publish via workflow_call (decouple from tag-push trigger) ([#23](https://github.com/dhanesh/mockstar/issues/23)) ([c8dda75](https://github.com/dhanesh/mockstar/commit/c8dda755ae3fbba1e90d51044471777de47ab72c))
41
+
42
+
43
+ ### Features
44
+
45
+ * **openapi:** synthesise schema-derived response bodies on import ([768560f](https://github.com/dhanesh/mockstar/commit/768560f8c0673a59a47327371a32b1626b990fc4))
46
+
1
47
  ## [0.1.3](https://github.com/dhanesh/mockstar/compare/v0.1.2...v0.1.3) (2026-06-23)
2
48
 
3
49
 
package/dist/cli.js CHANGED
@@ -1060,9 +1060,13 @@ function compileOne(spec) {
1060
1060
  jitterRatio: spec.retry.jitterRatio
1061
1061
  },
1062
1062
  signing: spec.signing ? {
1063
+ mode: spec.signing.mode,
1063
1064
  enabled: spec.signing.enabled,
1064
1065
  algorithm: spec.signing.algorithm,
1065
1066
  secretRef: spec.signing.secretRef,
1067
+ signedPayload: spec.signing.signedPayload,
1068
+ signatureTemplate: spec.signing.signatureTemplate,
1069
+ digestEncoding: spec.signing.digestEncoding,
1066
1070
  signatureHeader: spec.signing.signatureHeader,
1067
1071
  timestampHeader: spec.signing.timestampHeader,
1068
1072
  replayWindowMs: spec.signing.replayWindowMs
@@ -6926,6 +6930,63 @@ var coerce = {
6926
6930
  date: (arg) => ZodDate.create({ ...arg, coerce: true })
6927
6931
  };
6928
6932
  var NEVER = INVALID;
6933
+ // src/features/webhooks/scheme.ts
6934
+ var DEFAULT_SIGNED_PAYLOAD = "{timestamp}.{body}";
6935
+ var DEFAULT_SIGNATURE_TEMPLATE = "{algorithm}={signature}";
6936
+ var SIGNED_PAYLOAD_PLACEHOLDERS = ["body", "timestamp", "timestampSeconds"];
6937
+ var SIGNATURE_TEMPLATE_PLACEHOLDERS = [
6938
+ "signature",
6939
+ "algorithm",
6940
+ "timestamp",
6941
+ "timestampSeconds"
6942
+ ];
6943
+ var PLACEHOLDER_RE = /\{([A-Za-z][A-Za-z0-9]*)\}/g;
6944
+ var UNKNOWN_PLACEHOLDER_SCAN_RE = /\{[^{}]*\}/g;
6945
+ function unknownPlaceholders(template, allowed) {
6946
+ const seen = new Set;
6947
+ const out = [];
6948
+ for (const match of template.matchAll(UNKNOWN_PLACEHOLDER_SCAN_RE)) {
6949
+ const name = match[0].slice(1, -1);
6950
+ if (name === "")
6951
+ continue;
6952
+ if (allowed.includes(name) || seen.has(name))
6953
+ continue;
6954
+ seen.add(name);
6955
+ out.push(name);
6956
+ }
6957
+ return out;
6958
+ }
6959
+ function hasUnbalancedPlaceholder(template) {
6960
+ const residue = template.replace(UNKNOWN_PLACEHOLDER_SCAN_RE, "");
6961
+ return /\{[A-Za-z]/.test(residue);
6962
+ }
6963
+ function substitute(template, values) {
6964
+ return template.replace(PLACEHOLDER_RE, (match, name) => Object.hasOwn(values, name) ? values[name] : match);
6965
+ }
6966
+ function renderSignedPayload(template, v) {
6967
+ return substitute(template, {
6968
+ body: v.body,
6969
+ timestamp: String(v.timestampMs),
6970
+ timestampSeconds: String(Math.floor(v.timestampMs / 1000))
6971
+ });
6972
+ }
6973
+ function renderSignatureHeader(template, v) {
6974
+ return substitute(template, {
6975
+ signature: v.signature,
6976
+ algorithm: v.algorithm,
6977
+ timestamp: String(v.timestampMs),
6978
+ timestampSeconds: String(Math.floor(v.timestampMs / 1000))
6979
+ });
6980
+ }
6981
+ function timestampUnitFor(scheme) {
6982
+ const combined = `${scheme.signedPayload} ${scheme.signatureTemplate}`;
6983
+ if (combined.includes("{timestamp}"))
6984
+ return "ms";
6985
+ if (combined.includes("{timestampSeconds}"))
6986
+ return "s";
6987
+ return null;
6988
+ }
6989
+
6929
6990
  // src/core/config/schema.ts
6930
6991
  var MatchMethod = exports_external.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "*"]);
6931
6992
  var StringMatch = exports_external.union([
@@ -7007,16 +7068,105 @@ var ScenarioRule = exports_external.object({
7007
7068
  response: ScenarioResponse
7008
7069
  }).strict();
7009
7070
  var SECRET_REF_RE = /^(\{\{\s*env\.[A-Z_][A-Z0-9_]*\s*\}\}|file:.+)$/;
7010
- var WebhookSigning = exports_external.object({
7071
+ var HmacSigning = exports_external.object({
7072
+ mode: exports_external.literal("hmac").default("hmac"),
7011
7073
  enabled: exports_external.boolean().default(false),
7012
7074
  algorithm: exports_external.literal("sha256").default("sha256"),
7013
7075
  secretRef: exports_external.string().regex(SECRET_REF_RE, {
7014
7076
  message: "webhook signing.secretRef must be `{{ env.NAME }}` or `file:/path`; inline secrets rejected (S3)"
7015
7077
  }),
7078
+ signedPayload: exports_external.string().min(1).default(DEFAULT_SIGNED_PAYLOAD),
7079
+ signatureTemplate: exports_external.string().min(1).default(DEFAULT_SIGNATURE_TEMPLATE),
7080
+ digestEncoding: exports_external.enum(["hex", "base64"]).default("hex"),
7016
7081
  signatureHeader: exports_external.string().min(1).default("x-mockstar-signature"),
7017
- timestampHeader: exports_external.string().min(1).default("x-mockstar-timestamp"),
7082
+ timestampHeader: exports_external.string().min(1).nullable().default("x-mockstar-timestamp"),
7018
7083
  replayWindowMs: exports_external.number().int().positive().default(300000)
7019
7084
  }).strict();
7085
+ var WebhookSigning = exports_external.preprocess((raw) => raw !== null && typeof raw === "object" && !Array.isArray(raw) && !("mode" in raw) ? { ...raw, mode: "hmac" } : raw, exports_external.discriminatedUnion("mode", [HmacSigning])).superRefine((v, ctx) => {
7086
+ if (typeof v.signedPayload !== "string" || typeof v.signatureTemplate !== "string")
7087
+ return;
7088
+ const fmt = (names) => names.map((n) => `{${n}}`).join(", ");
7089
+ const signedPayloadHasDoubleBrace = v.signedPayload.includes("{{");
7090
+ if (signedPayloadHasDoubleBrace) {
7091
+ ctx.addIssue({
7092
+ code: exports_external.ZodIssueCode.custom,
7093
+ path: ["signedPayload"],
7094
+ message: "signedPayload uses single-brace placeholders (e.g. {body}), not the {{ }} request-template syntax \u2014 did you mean {body} instead of {{ body }}?"
7095
+ });
7096
+ }
7097
+ const signatureTemplateHasDoubleBrace = v.signatureTemplate.includes("{{");
7098
+ if (signatureTemplateHasDoubleBrace) {
7099
+ ctx.addIssue({
7100
+ code: exports_external.ZodIssueCode.custom,
7101
+ path: ["signatureTemplate"],
7102
+ message: "signatureTemplate uses single-brace placeholders (e.g. {signature}), not the {{ }} request-template syntax \u2014 did you mean {signature} instead of {{ signature }}?"
7103
+ });
7104
+ }
7105
+ const signedPayloadHasTemplateLiteral = v.signedPayload.includes("${");
7106
+ if (signedPayloadHasTemplateLiteral) {
7107
+ ctx.addIssue({
7108
+ code: exports_external.ZodIssueCode.custom,
7109
+ path: ["signedPayload"],
7110
+ message: "signedPayload uses single-brace placeholders (e.g. {body}), not JS template-literal syntax \u2014 did you mean {body} instead of ${body}?"
7111
+ });
7112
+ }
7113
+ const signatureTemplateHasTemplateLiteral = v.signatureTemplate.includes("${");
7114
+ if (signatureTemplateHasTemplateLiteral) {
7115
+ ctx.addIssue({
7116
+ code: exports_external.ZodIssueCode.custom,
7117
+ path: ["signatureTemplate"],
7118
+ message: "signatureTemplate uses single-brace placeholders (e.g. {signature}), not JS template-literal syntax \u2014 did you mean {signature} instead of ${signature}?"
7119
+ });
7120
+ }
7121
+ if (!signedPayloadHasDoubleBrace && !signedPayloadHasTemplateLiteral) {
7122
+ const badPayload = unknownPlaceholders(v.signedPayload, SIGNED_PAYLOAD_PLACEHOLDERS);
7123
+ if (badPayload.length > 0) {
7124
+ ctx.addIssue({
7125
+ code: exports_external.ZodIssueCode.custom,
7126
+ path: ["signedPayload"],
7127
+ message: `unknown placeholder(s) ${fmt(badPayload)} \u2014 allowed: ${fmt(SIGNED_PAYLOAD_PLACEHOLDERS)}`
7128
+ });
7129
+ }
7130
+ if (!v.signedPayload.includes("{body}")) {
7131
+ ctx.addIssue({
7132
+ code: exports_external.ZodIssueCode.custom,
7133
+ path: ["signedPayload"],
7134
+ message: "signedPayload must contain {body} \u2014 otherwise the signature covers no request content"
7135
+ });
7136
+ }
7137
+ if (hasUnbalancedPlaceholder(v.signedPayload)) {
7138
+ ctx.addIssue({
7139
+ code: exports_external.ZodIssueCode.custom,
7140
+ path: ["signedPayload"],
7141
+ message: "signedPayload has an unmatched { that looks like an unterminated placeholder \u2014 check for a missing closing brace"
7142
+ });
7143
+ }
7144
+ }
7145
+ if (!signatureTemplateHasDoubleBrace && !signatureTemplateHasTemplateLiteral) {
7146
+ const badTemplate = unknownPlaceholders(v.signatureTemplate, SIGNATURE_TEMPLATE_PLACEHOLDERS);
7147
+ if (badTemplate.length > 0) {
7148
+ ctx.addIssue({
7149
+ code: exports_external.ZodIssueCode.custom,
7150
+ path: ["signatureTemplate"],
7151
+ message: `unknown placeholder(s) ${fmt(badTemplate)} \u2014 allowed: ${fmt(SIGNATURE_TEMPLATE_PLACEHOLDERS)}`
7152
+ });
7153
+ }
7154
+ if (!v.signatureTemplate.includes("{signature}")) {
7155
+ ctx.addIssue({
7156
+ code: exports_external.ZodIssueCode.custom,
7157
+ path: ["signatureTemplate"],
7158
+ message: "signatureTemplate must contain {signature} \u2014 otherwise the signature header carries no digest"
7159
+ });
7160
+ }
7161
+ if (hasUnbalancedPlaceholder(v.signatureTemplate)) {
7162
+ ctx.addIssue({
7163
+ code: exports_external.ZodIssueCode.custom,
7164
+ path: ["signatureTemplate"],
7165
+ message: "signatureTemplate has an unmatched { that looks like an unterminated placeholder \u2014 check for a missing closing brace"
7166
+ });
7167
+ }
7168
+ }
7169
+ });
7020
7170
  var WebhookRetry = exports_external.object({
7021
7171
  attempts: exports_external.number().int().min(1).max(20).default(6),
7022
7172
  backoff: exports_external.array(exports_external.number().int().nonnegative()).default([1000, 2000, 4000, 8000, 16000]),
@@ -11502,7 +11652,7 @@ function adminRouter(deps) {
11502
11652
  entryId,
11503
11653
  id: spec.id,
11504
11654
  method: spec.method,
11505
- signing: spec.signing ? { enabled: spec.signing.enabled, algorithm: spec.signing.algorithm } : null,
11655
+ signing: spec.signing ? { mode: spec.signing.mode, enabled: spec.signing.enabled, algorithm: spec.signing.algorithm } : null,
11506
11656
  retry: { attempts: spec.retry.attempts },
11507
11657
  circuit: spec.circuit,
11508
11658
  timeoutMs: spec.timeoutMs,
@@ -12578,9 +12728,33 @@ class WebhookJournalRegistry {
12578
12728
  }
12579
12729
  // src/features/webhooks/signing.ts
12580
12730
  import { createHmac, timingSafeEqual as timingSafeEqual2 } from "crypto";
12581
- function signPayload(rawBody, secret, timestampMs) {
12582
- const stringToSign = `${timestampMs}.${rawBody}`;
12583
- return createHmac("sha256", secret).update(stringToSign, "utf8").digest("hex");
12731
+ var LEGACY_SCHEME = Object.freeze({
12732
+ signedPayload: DEFAULT_SIGNED_PAYLOAD,
12733
+ signatureTemplate: DEFAULT_SIGNATURE_TEMPLATE,
12734
+ digestEncoding: "hex",
12735
+ algorithm: "sha256"
12736
+ });
12737
+ function signPayload(rawBody, secret, timestampMs, scheme = LEGACY_SCHEME) {
12738
+ const stringToSign = renderSignedPayload(scheme.signedPayload, { body: rawBody, timestampMs });
12739
+ return createHmac(scheme.algorithm, secret).update(stringToSign, "utf8").digest(scheme.digestEncoding);
12740
+ }
12741
+ function verifySignature(rawBody, secret, timestampMs, signature, scheme = LEGACY_SCHEME) {
12742
+ try {
12743
+ const expected = signPayload(rawBody, secret, timestampMs, scheme);
12744
+ if (expected.length !== signature.length)
12745
+ return false;
12746
+ const a2 = Buffer.from(expected, scheme.digestEncoding);
12747
+ const b2 = Buffer.from(signature, scheme.digestEncoding);
12748
+ if (a2.length !== b2.length || a2.length === 0)
12749
+ return false;
12750
+ return timingSafeEqual2(a2, b2);
12751
+ } catch {
12752
+ return false;
12753
+ }
12754
+ }
12755
+ function withinReplayWindow(timestampMs, windowMs, nowMs = Date.now(), futureSkewMs = 60000) {
12756
+ const delta = nowMs - timestampMs;
12757
+ return delta <= windowMs && delta >= -futureSkewMs;
12584
12758
  }
12585
12759
  function resolveSecret(secretRef) {
12586
12760
  const envMatch = secretRef.match(/^\{\{\s*env\.([A-Z_][A-Z0-9_]*)\s*\}\}$/);
@@ -12661,9 +12835,23 @@ async function performAttempt(spec, input, _deps) {
12661
12835
  if (spec.signing?.enabled) {
12662
12836
  const secret = resolveSecret(spec.signing.secretRef);
12663
12837
  const timestampMs = Date.now();
12664
- const signature = signPayload(rawBody, secret, timestampMs);
12665
- renderedHeaders.set(spec.signing.signatureHeader, `${spec.signing.algorithm}=${signature}`);
12666
- renderedHeaders.set(spec.signing.timestampHeader, String(timestampMs));
12838
+ const scheme = {
12839
+ signedPayload: spec.signing.signedPayload,
12840
+ signatureTemplate: spec.signing.signatureTemplate,
12841
+ digestEncoding: spec.signing.digestEncoding,
12842
+ algorithm: spec.signing.algorithm
12843
+ };
12844
+ const signature = signPayload(rawBody, secret, timestampMs, scheme);
12845
+ renderedHeaders.set(spec.signing.signatureHeader, renderSignatureHeader(scheme.signatureTemplate, {
12846
+ signature,
12847
+ algorithm: scheme.algorithm,
12848
+ timestampMs
12849
+ }));
12850
+ const unit = timestampUnitFor(scheme);
12851
+ if (unit !== null && spec.signing.timestampHeader !== null) {
12852
+ const value = unit === "s" ? Math.floor(timestampMs / 1000) : timestampMs;
12853
+ renderedHeaders.set(spec.signing.timestampHeader, String(value));
12854
+ }
12667
12855
  }
12668
12856
  if (!renderedHeaders.has("x-mockstar-delivery-id")) {
12669
12857
  renderedHeaders.set("x-mockstar-delivery-id", input.triggerRequestId);
@@ -13742,7 +13930,7 @@ function convertOpenApi(doc, opts = {}) {
13742
13930
  if (!/^(get|post|put|patch|delete|head|options)$/i.test(method))
13743
13931
  continue;
13744
13932
  const operation = op;
13745
- const { status, example, contentType } = pickExemplar(operation);
13933
+ const { status, example, contentType } = pickExemplar(operation, doc);
13746
13934
  const entry = {
13747
13935
  id: operation.operationId ?? `${method.toUpperCase()}-${safePath}`,
13748
13936
  match: {
@@ -13777,7 +13965,7 @@ function findRefs(value, acc = []) {
13777
13965
  }
13778
13966
  return acc;
13779
13967
  }
13780
- function pickExemplar(op) {
13968
+ function pickExemplar(op, doc) {
13781
13969
  const responses = op.responses ?? {};
13782
13970
  const preferred = ["200", "201", "202", "204", "default"];
13783
13971
  for (const code of preferred) {
@@ -13795,7 +13983,7 @@ function pickExemplar(op) {
13795
13983
  const media = content[ct];
13796
13984
  if (!media)
13797
13985
  continue;
13798
- const example = media.example ?? firstExample(media.examples);
13986
+ const example = media.example ?? firstExample(media.examples) ?? (media.schema !== undefined ? synthesizeFromSchema(media.schema, doc) : undefined);
13799
13987
  return { status, example, contentType: ct };
13800
13988
  }
13801
13989
  }
@@ -13809,13 +13997,99 @@ function firstExample(examples) {
13809
13997
  return v3.value;
13810
13998
  return;
13811
13999
  }
14000
+ function synthesizeFromSchema(schema2, doc, seen = new Set, depth = 0) {
14001
+ if (depth > 8 || schema2 === null || typeof schema2 !== "object")
14002
+ return null;
14003
+ const s2 = schema2;
14004
+ if (typeof s2.$ref === "string") {
14005
+ if (seen.has(s2.$ref))
14006
+ return null;
14007
+ const resolved = resolveRef(s2.$ref, doc);
14008
+ if (resolved === undefined)
14009
+ return null;
14010
+ return synthesizeFromSchema(resolved, doc, new Set(seen).add(s2.$ref), depth + 1);
14011
+ }
14012
+ if (s2.example !== undefined)
14013
+ return s2.example;
14014
+ if (s2.default !== undefined)
14015
+ return s2.default;
14016
+ if (Array.isArray(s2.enum) && s2.enum.length > 0)
14017
+ return s2.enum[0];
14018
+ if (Array.isArray(s2.allOf)) {
14019
+ const merged = {};
14020
+ for (const sub of s2.allOf) {
14021
+ const part = synthesizeFromSchema(sub, doc, seen, depth + 1);
14022
+ if (part && typeof part === "object" && !Array.isArray(part))
14023
+ Object.assign(merged, part);
14024
+ }
14025
+ return merged;
14026
+ }
14027
+ const oneOf = s2.oneOf ?? s2.anyOf;
14028
+ if (Array.isArray(oneOf) && oneOf.length > 0) {
14029
+ return synthesizeFromSchema(oneOf[0], doc, seen, depth + 1);
14030
+ }
14031
+ const type = Array.isArray(s2.type) ? s2.type[0] : s2.type;
14032
+ if (type === "object" || s2.properties) {
14033
+ const out = {};
14034
+ const props = s2.properties ?? {};
14035
+ for (const [key, propSchema] of Object.entries(props)) {
14036
+ out[key] = synthesizeFromSchema(propSchema, doc, seen, depth + 1);
14037
+ }
14038
+ return out;
14039
+ }
14040
+ if (type === "array") {
14041
+ const item = s2.items !== undefined ? synthesizeFromSchema(s2.items, doc, seen, depth + 1) : null;
14042
+ return item === null ? [] : [item];
14043
+ }
14044
+ if (type === "string")
14045
+ return placeholderForString(typeof s2.format === "string" ? s2.format : "");
14046
+ if (type === "integer" || type === "number")
14047
+ return 0;
14048
+ if (type === "boolean")
14049
+ return true;
14050
+ if (type === "null")
14051
+ return null;
14052
+ return null;
14053
+ }
14054
+ function placeholderForString(format) {
14055
+ switch (format) {
14056
+ case "date-time":
14057
+ return "1970-01-01T00:00:00Z";
14058
+ case "date":
14059
+ return "1970-01-01";
14060
+ case "uuid":
14061
+ return "00000000-0000-0000-0000-000000000000";
14062
+ case "email":
14063
+ return "user@example.com";
14064
+ case "uri":
14065
+ case "url":
14066
+ return "https://example.com";
14067
+ case "byte":
14068
+ case "binary":
14069
+ return "";
14070
+ default:
14071
+ return "string";
14072
+ }
14073
+ }
14074
+ function resolveRef(ref, doc) {
14075
+ if (!ref.startsWith("#/"))
14076
+ return;
14077
+ let node = doc;
14078
+ for (const raw2 of ref.slice(2).split("/")) {
14079
+ const key = raw2.replace(/~1/g, "/").replace(/~0/g, "~");
14080
+ if (node === null || typeof node !== "object")
14081
+ return;
14082
+ node = node[key];
14083
+ }
14084
+ return node;
14085
+ }
13812
14086
  function encodePathTemplate(openapiPath) {
13813
14087
  const parts = openapiPath.split("/").map((seg) => {
13814
14088
  if (seg === "")
13815
14089
  return seg;
13816
- const paramMatch = seg.match(/^\{([^}]+)\}$/);
13817
- if (paramMatch?.[1]) {
13818
- const name = paramMatch[1].replace(/[^a-zA-Z0-9_]/g, "_");
14090
+ const firstParam = seg.match(/\{([^}]+)\}/);
14091
+ if (firstParam?.[1]) {
14092
+ const name = firstParam[1].replace(/[^a-zA-Z0-9_]/g, "_");
13819
14093
  return `:${name}`;
13820
14094
  }
13821
14095
  return encodeURIComponent(seg);
@@ -14828,7 +15102,7 @@ function proxyHelp() {
14828
15102
  }
14829
15103
 
14830
15104
  // src/version.ts
14831
- var MOCKSTAR_VERSION = "0.1.3";
15105
+ var MOCKSTAR_VERSION = "0.3.0";
14832
15106
 
14833
15107
  // src/cli.ts
14834
15108
  function parseArgs(argv) {