integration-tour 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/dist/cli.js +42 -13
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -5281,7 +5281,26 @@ function secretName(name) {
5281
5281
  if (/idempotency/i.test(name)) return false;
5282
5282
  return /secret|passw(or)?d|pwd|token|api[-_]?key|apikey|credential|signature|session|cookie|bearer|jwt|^auth(orization)?$/i.test(name) || /(^|[_-])key$|[a-z0-9]Key$|^key$/i.test(name);
5283
5283
  }
5284
- var SECRET_VALUE = /^(sk|rk)_(live|test)_|^gh[pousr]_|^github_pat_|^xox[abposr]-|^AKIA[0-9A-Z]{12,}|^eyJ[\w-]+\.[\w-]+|^(bearer|basic)\s/i;
5284
+ var SECRET_VALUE = /^(sk|rk)_(live|test)_|^whsec_|^gh[pousr]_|^github_pat_|^xox[abposr]-|^(AKIA|ASIA)[0-9A-Z]{12,}|^eyJ[\w-]+\.[\w-]+|^(bearer|basic)\s|^sk-[\w-]{20,}|^AIza[\w-]{30,}|^ya29\.[\w-]{20,}|^SG\.[\w-]{16,}\.[\w-]{16,}|^npm_[A-Za-z0-9]{30,}|^glpat-[\w-]{20,}|^hf_[A-Za-z0-9]{30,}|^shp(at|ss|ca|pa)_[a-fA-F0-9]{32}|^sq0(atp|csp)-[\w-]{20,}|^-----BEGIN [A-Z ]*PRIVATE KEY-----/i;
5285
+ function credentialName(name) {
5286
+ if (/^key$/i.test(name.trim()) || /(type|kind|url|uri|endpoint|expires?(_?(in|at))?|name|count|length|hint|prefix)$/i.test(name)) return false;
5287
+ return secretName(name) || /(^|[^a-z])auth([^a-z]|$)/i.test(name);
5288
+ }
5289
+ function hiddenAs(name) {
5290
+ return /passw(or)?d|pwd/i.test(name) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : placeholder(name || "secret");
5291
+ }
5292
+ function withoutCredential(name, value, hid) {
5293
+ if (!given(value) || !(credentialName(name) || SECRET_VALUE.test(value.trim()))) return value;
5294
+ hid.add(name || "a value");
5295
+ return hiddenAs(name);
5296
+ }
5297
+ function withoutCredentials(value, hid, name = "", depth = 0) {
5298
+ if (depth > 40) return value;
5299
+ if (typeof value === "string") return withoutCredential(name, value, hid);
5300
+ if (Array.isArray(value)) return value.map((v) => withoutCredentials(v, hid, name, depth + 1));
5301
+ if (isObj(value)) return Object.fromEntries(Object.entries(value).map(([key, v]) => [key, withoutCredentials(v, hid, key, depth + 1)]));
5302
+ return value;
5303
+ }
5285
5304
  function readVariables(list7, into) {
5286
5305
  if (!Array.isArray(list7)) return;
5287
5306
  for (const v of list7) {
@@ -5662,7 +5681,7 @@ function payloadOf(value, required) {
5662
5681
  if (holdsPlaceholder(value)) return { schema: schemaOf(value, { required, examples: true }) };
5663
5682
  return { schema: schemaOf(value, { required }), example: value };
5664
5683
  }
5665
- function bodyOf(raw, contentType, vars) {
5684
+ function bodyOf(raw, contentType, vars, hid) {
5666
5685
  if (!isObj(raw) || raw.disabled === true) return void 0;
5667
5686
  const mode = typeof raw.mode === "string" ? raw.mode : "";
5668
5687
  switch (mode) {
@@ -5674,7 +5693,7 @@ function bodyOf(raw, contentType, vars) {
5674
5693
  const type2 = contentType ?? RAW_TYPES[language] ?? (looksJson(text3) ? "application/json" : "text/plain");
5675
5694
  if (/json/i.test(type2)) {
5676
5695
  const value = jsonBody(text3, vars);
5677
- if (value !== void 0) return { media: type2, ...payloadOf(value, true) };
5696
+ if (value !== void 0) return { media: type2, ...payloadOf(withoutCredentials(value, hid), true) };
5678
5697
  return { media: "text/plain", schema: { type: "string" }, example: vars.fill(text3) };
5679
5698
  }
5680
5699
  return { media: type2, schema: { type: "string" }, example: vars.fill(text3) };
@@ -5685,7 +5704,10 @@ function bodyOf(raw, contentType, vars) {
5685
5704
  const fields = pairs(raw[mode]);
5686
5705
  if (!fields.length) return void 0;
5687
5706
  const files = new Set(Array.isArray(raw[mode]) ? raw[mode].flatMap((f) => multipart && isObj(f) && f.type === "file" && typeof f.key === "string" ? [f.key.trim()] : []) : []);
5688
- const entries = fields.map((f) => ({ key: vars.fill(f.key, false), file: files.has(f.key), value: vars.fill(f.value, !f.disabled), field: f }));
5707
+ const entries = fields.map((f) => {
5708
+ const key = vars.fill(f.key, false);
5709
+ return { key, file: files.has(f.key), value: withoutCredential(key, vars.fill(f.value, !f.disabled), hid), field: f };
5710
+ });
5689
5711
  const properties = Object.fromEntries(
5690
5712
  entries.map(({ key, file, value, field }) => {
5691
5713
  if (file) return [key, { type: "string", format: "binary" }];
@@ -5706,7 +5728,8 @@ function bodyOf(raw, contentType, vars) {
5706
5728
  const g = isObj(raw.graphql) ? raw.graphql : {};
5707
5729
  const query = typeof g.query === "string" ? vars.fill(g.query) : "";
5708
5730
  if (!query.trim()) return void 0;
5709
- const variables = typeof g.variables === "string" && g.variables.trim() ? jsonBody(g.variables, vars) : isObj(g.variables) ? g.variables : void 0;
5731
+ const sent = typeof g.variables === "string" && g.variables.trim() ? jsonBody(g.variables, vars) : isObj(g.variables) ? g.variables : void 0;
5732
+ const variables = sent === void 0 ? void 0 : withoutCredentials(sent, hid);
5710
5733
  const example = { query, ...variables !== void 0 ? { variables } : {} };
5711
5734
  return { media: "application/json", ...payloadOf(example, true) };
5712
5735
  }
@@ -5714,7 +5737,7 @@ function bodyOf(raw, contentType, vars) {
5714
5737
  return void 0;
5715
5738
  }
5716
5739
  }
5717
- function responsesOf(saved, requestName) {
5740
+ function responsesOf(saved, requestName, hid) {
5718
5741
  const out = {};
5719
5742
  for (const r of saved) {
5720
5743
  if (!isObj(r)) continue;
@@ -5729,7 +5752,7 @@ function responsesOf(saved, requestName) {
5729
5752
  const body = typeof r.body === "string" ? r.body : "";
5730
5753
  if (body.trim()) {
5731
5754
  const value = (type2 ? /json/i.test(type2) : looksJson(body)) ? parseJson(body) : void 0;
5732
- if (value !== void 0) response.content = { [type2 ?? "application/json"]: payloadOf(value, "all") };
5755
+ if (value !== void 0) response.content = { [type2 ?? "application/json"]: payloadOf(withoutCredentials(value, hid), "all") };
5733
5756
  else response.content = { [type2 && !/json/i.test(type2) ? type2 : "text/plain"]: { schema: { type: "string" }, example: body } };
5734
5757
  }
5735
5758
  out[status] = response;
@@ -5807,6 +5830,7 @@ function convertPostman(raw, environments = [], source) {
5807
5830
  collect(collection.item, void 0, ownAuth(collection.auth), saved, counts);
5808
5831
  const schemes = new Schemes();
5809
5832
  const notes = /* @__PURE__ */ new Set();
5833
+ const hid = /* @__PURE__ */ new Set();
5810
5834
  const requirementOf = (auth, headers) => {
5811
5835
  const scheme = auth ? schemeOf(auth, vars, notes) : void 0;
5812
5836
  const parts = [];
@@ -5851,7 +5875,7 @@ function convertPostman(raw, environments = [], source) {
5851
5875
  const item = paths[path] ??= {};
5852
5876
  const slots = FIXED_METHODS.has(method) ? item : item.additionalOperations ??= {};
5853
5877
  const name = bareName(vars.fill(r.name, false));
5854
- const responses = responsesOf(r.responses, r.name);
5878
+ const responses = responsesOf(r.responses, r.name, hid);
5855
5879
  const success = Object.keys(responses).some((s) => /^2/.test(s));
5856
5880
  const existing = slots[method];
5857
5881
  if (isObj(existing)) {
@@ -5876,15 +5900,19 @@ function convertPostman(raw, environments = [], source) {
5876
5900
  else if (/^cookie$/i.test(h.key)) {
5877
5901
  for (const part of h.value.split(";")) {
5878
5902
  const eq = part.indexOf("=");
5879
- if (eq > 0) parameters.push({ name: part.slice(0, eq).trim(), in: "cookie", required: true, schema: { type: "string" }, example: vars.fill(part.slice(eq + 1).trim()) });
5903
+ if (eq <= 0) continue;
5904
+ const cookie = part.slice(0, eq).trim();
5905
+ const value = vars.fill(part.slice(eq + 1).trim());
5906
+ if (given(value)) hid.add(cookie);
5907
+ parameters.push({ name: cookie, in: "cookie", required: true, schema: { type: "string" }, example: given(value) ? hiddenAs(cookie) : value });
5880
5908
  }
5881
- } else parameters.push({ name: h.key, in: "header", required: true, ...valueOf(vars.fill(h.value)), ...h.description ? { description: h.description } : {} });
5909
+ } else parameters.push({ name: h.key, in: "header", required: true, ...valueOf(withoutCredential(h.key, vars.fill(h.value), hid)), ...h.description ? { description: h.description } : {} });
5882
5910
  }
5883
5911
  const query = /* @__PURE__ */ new Map();
5884
5912
  for (const q of url.query) {
5885
5913
  const key = vars.fill(q.key, false).trim();
5886
5914
  if (!key) continue;
5887
- const value = vars.fill(q.value, !q.disabled);
5915
+ const value = withoutCredential(key, vars.fill(q.value, !q.disabled), hid);
5888
5916
  const entry = query.get(key);
5889
5917
  if (!entry) query.set(key, { values: [value], required: !q.disabled, ...q.description ? { description: q.description } : {} });
5890
5918
  else if (!q.disabled) {
@@ -5898,7 +5926,7 @@ function convertPostman(raw, environments = [], source) {
5898
5926
  const value = many ? { schema: { type: "array", items: { type: "string" } }, example: q.values } : valueOf(q.values[0]);
5899
5927
  parameters.push({ name: key, in: "query", required: q.required, ...value, ...q.description ? { description: q.description } : {} });
5900
5928
  }
5901
- const body = bodyOf(r.request.body, contentType, vars);
5929
+ const body = bodyOf(r.request.body, contentType, vars, hid);
5902
5930
  const lowered = method.toLowerCase();
5903
5931
  const operationId = namesUrl(name) ? void 0 : operationIdFor(name, usedIds);
5904
5932
  const op = {
@@ -5937,6 +5965,7 @@ function convertPostman(raw, environments = [], source) {
5937
5965
  else if (unsetHosts.has("")) warnings.push("Some requests give no host, so the video puts them on api.example.com.");
5938
5966
  const unset = [...vars.unset].filter((n) => !unsetHosts.has(n));
5939
5967
  if (unset.length) warnings.push(`Some variables have no value in the collection, so the video shows them as written, or an id an earlier call returned: ${list2(unset.map((n) => `{{${n}}}`))}.`);
5968
+ if (hid.size) warnings.push(`Credentials written out in the requests or their saved responses, rather than kept in variables, show hidden: ${list2([...hid])}.`);
5940
5969
  if (vars.secret.size) warnings.push(`Variables that look like credentials aren't filled in, so the video shows them as written: ${list2([...vars.secret].map((n) => `{{${n}}}`))}.`);
5941
5970
  if (placed.length && unsaved === placed.length && app !== "Postman") warnings.push(`${app}'s exports hold no responses, so the calls show no response body. A design document's spec gives them.`);
5942
5971
  else if (placed.length && unsaved === placed.length) warnings.push("None of the requests has a successful response saved as an example, so the calls show no response body. Save a response as an example in Postman to show it.");
@@ -11022,7 +11051,7 @@ function unknownKeys(raw, known, where, problems) {
11022
11051
  }
11023
11052
 
11024
11053
  // package.json
11025
- var version = "1.0.7";
11054
+ var version = "1.0.8";
11026
11055
 
11027
11056
  // src/files.ts
11028
11057
  var import_node_fs = require("node:fs");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "integration-tour",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Renders integration videos of your API or MCP server from its OpenAPI spec or tools, in your own build, so they stay in step with it.",
5
5
  "keywords": [
6
6
  "openapi",