@scalar/api-client 2.5.15 → 2.5.17

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 (29) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/components/CodeInput/CodeInput.vue.js +2 -2
  3. package/dist/components/CodeInput/CodeInput.vue2.js +1 -1
  4. package/dist/components/Form/Form.vue.js +1 -1
  5. package/dist/components/HttpMethod/HttpMethod.vue.d.ts +2 -2
  6. package/dist/components/Server/ServerVariablesSelect.vue.d.ts.map +1 -1
  7. package/dist/components/Server/ServerVariablesSelect.vue.js +3 -3
  8. package/dist/layouts/App/create-api-client-app.d.ts +42 -2
  9. package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
  10. package/dist/layouts/Modal/create-api-client-modal.d.ts +84 -4
  11. package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
  12. package/dist/layouts/Web/create-api-client-web.d.ts +42 -2
  13. package/dist/layouts/Web/create-api-client-web.d.ts.map +1 -1
  14. package/dist/libs/create-client.d.ts +42 -2
  15. package/dist/libs/create-client.d.ts.map +1 -1
  16. package/dist/libs/get-request-uid-by-path-method.d.ts.map +1 -1
  17. package/dist/libs/get-request-uid-by-path-method.js +15 -7
  18. package/dist/store/security-schemes.d.ts +42 -2
  19. package/dist/store/security-schemes.d.ts.map +1 -1
  20. package/dist/store/store.d.ts +42 -2
  21. package/dist/store/store.d.ts.map +1 -1
  22. package/dist/style.css +1 -1
  23. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.d.ts.map +1 -1
  24. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.js +2 -2
  25. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue2.js +1 -1
  26. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  27. package/dist/views/Request/libs/oauth2.d.ts.map +1 -1
  28. package/dist/views/Request/libs/oauth2.js +39 -39
  29. package/package.json +12 -12
@@ -1 +1 @@
1
- {"version":3,"file":"RequestAuth.vue.d.ts","sourceRoot":"","sources":["../../../../../src/views/Request/RequestSection/RequestAuth/RequestAuth.vue"],"names":[],"mappings":"AA+XA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAA;AACzE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAA;AACnF,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EAET,MAAM,EACP,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAA;AAMrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAe1D,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE,WAAW,CAAA;IACxB,YAAY,EAAE,WAAW,EAAE,CAAA;IAC3B,MAAM,EAAE,QAAQ,GAAG,WAAW,CAAA;IAC9B,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IACjC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,0BAA0B,EAAE,0BAA0B,CAAA;IACtD,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,SAAS,CAAA;CACrB,CAAC;;AAwbF,wBAOG"}
1
+ {"version":3,"file":"RequestAuth.vue.d.ts","sourceRoot":"","sources":["../../../../../src/views/Request/RequestSection/RequestAuth/RequestAuth.vue"],"names":[],"mappings":"AA+XA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAA;AACzE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAA;AACnF,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EAET,MAAM,EACP,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAA;AAMrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAe1D,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE,WAAW,CAAA;IACxB,YAAY,EAAE,WAAW,EAAE,CAAA;IAC3B,MAAM,EAAE,QAAQ,GAAG,WAAW,CAAA;IAC9B,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IACjC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,0BAA0B,EAAE,0BAA0B,CAAA;IACtD,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,SAAS,CAAA;CACrB,CAAC;;AAybF,wBAOG"}
@@ -1,7 +1,7 @@
1
1
  import t from "./RequestAuth.vue2.js";
2
2
  /* empty css */
3
3
  import o from "../../../../_virtual/_plugin-vue_export-helper.js";
4
- const m = /* @__PURE__ */ o(t, [["__scopeId", "data-v-c19d214a"]]);
4
+ const f = /* @__PURE__ */ o(t, [["__scopeId", "data-v-0b3f2a3a"]]);
5
5
  export {
6
- m as default
6
+ f as default
7
7
  };
@@ -110,7 +110,7 @@ const se = ["id"], re = { class: "absolute right-1 flex flex-1" }, ie = { class:
110
110
  V.value && t.stopPropagation(), (e = S.value) == null || e.$el.click();
111
111
  };
112
112
  return (t, e) => (m(), K(Q, {
113
- class: "group/params",
113
+ class: "group/params relative",
114
114
  itemCount: u.value.length,
115
115
  layout: t.layout,
116
116
  "onUpdate:modelValue": e[2] || (e[2] = (o) => V.value = o)
@@ -34,7 +34,7 @@ const W = { class: "flex-center relative flex flex-1 flex-col gap-6 p-2 capitali
34
34
  }));
35
35
  }, k = (o) => {
36
36
  o != null && o.createNew && g.name === "request" && f();
37
- }, w = "2.5.15";
37
+ }, w = "2.5.17";
38
38
  return R(() => a.hotKeys.on(k)), v(() => a.hotKeys.off(k)), (o, e) => (u(), i("div", W, [
39
39
  s("div", {
40
40
  class: y(["flex h-[calc(100%_-_50px)] flex-col items-center justify-center", {
@@ -1 +1 @@
1
- {"version":3,"file":"oauth2.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/libs/oauth2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AAGzE,qDAAqD;AACrD,KAAK,eAAe,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAA;AAEhE,KAAK,SAAS,GAAG;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,mBAAmB,EAAE,MAAM,CAAA;CAC5B,CAAA;AAmBD;;GAEG;AACH,eAAO,MAAM,qBAAqB,aAAoB,MAAM,YAAY,SAAS,GAAG,OAAO,KAAG,OAAO,CAAC,MAAM,CAe3G,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,SACpB,UAAU,gBAEF,MAAM,aAET,MAAM,KAChB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CA6J/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,SACrB,eAAe,UACb,MAAM,8BAKX;IACD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,KACA,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAmE/B,CAAA"}
1
+ {"version":3,"file":"oauth2.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/libs/oauth2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AAGzE,qDAAqD;AACrD,KAAK,eAAe,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAA;AAEhE,KAAK,SAAS,GAAG;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,mBAAmB,EAAE,MAAM,CAAA;CAC5B,CAAA;AAmBD;;GAEG;AACH,eAAO,MAAM,qBAAqB,aAAoB,MAAM,YAAY,SAAS,GAAG,OAAO,KAAG,OAAO,CAAC,MAAM,CAe3G,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,SACpB,UAAU,gBAEF,MAAM,aAET,MAAM,KAChB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CA8J/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,SACrB,eAAe,UACb,MAAM,8BAKX;IACD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,KACA,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAwE/B,CAAA"}
@@ -1,19 +1,19 @@
1
- import { shouldUseProxy as w } from "@scalar/oas-utils/helpers";
2
- const S = () => {
1
+ import { shouldUseProxy as k } from "@scalar/oas-utils/helpers";
2
+ const w = () => {
3
3
  const e = new Uint8Array(32);
4
4
  return crypto.getRandomValues(e), btoa(String.fromCharCode(...e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
5
5
  }, x = async (e, l) => {
6
6
  if (l === "plain")
7
7
  return e;
8
- const a = new TextEncoder().encode(e), c = await crypto.subtle.digest("SHA-256", a);
8
+ const n = new TextEncoder().encode(e), c = await crypto.subtle.digest("SHA-256", n);
9
9
  return btoa(String.fromCharCode(...new Uint8Array(c))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
10
- }, k = async (e, l, d) => {
10
+ }, U = async (e, l, d) => {
11
11
  try {
12
12
  if (!e)
13
13
  return [new Error("Flow not found"), null];
14
- const a = e.selectedScopes.join(" ");
14
+ const n = e.selectedScopes.join(" ");
15
15
  if (e.type === "clientCredentials" || e.type === "password")
16
- return P(e, a, {
16
+ return S(e, n, {
17
17
  proxyUrl: d
18
18
  });
19
19
  const c = (Math.random() + 1).toString(36).substring(2, 10), t = new URL(e.authorizationUrl);
@@ -21,77 +21,77 @@ const S = () => {
21
21
  if (e.type === "implicit")
22
22
  t.searchParams.set("response_type", "token");
23
23
  else if (e.type === "authorizationCode" && (t.searchParams.set("response_type", "code"), e["x-usePkce"] !== "no")) {
24
- const r = S(), n = await x(r, e["x-usePkce"]);
24
+ const r = w(), a = await x(r, e["x-usePkce"]);
25
25
  u = {
26
26
  codeVerifier: r,
27
- codeChallenge: n,
27
+ codeChallenge: a,
28
28
  codeChallengeMethod: e["x-usePkce"] === "SHA-256" ? "S256" : "plain"
29
- }, t.searchParams.set("code_challenge", n), t.searchParams.set("code_challenge_method", u.codeChallengeMethod);
29
+ }, t.searchParams.set("code_challenge", a), t.searchParams.set("code_challenge_method", u.codeChallengeMethod);
30
30
  }
31
31
  if (e["x-scalar-redirect-uri"].startsWith("/")) {
32
- const r = l.url || window.location.origin + window.location.pathname, n = new URL(e["x-scalar-redirect-uri"], r).toString();
33
- t.searchParams.set("redirect_uri", n);
32
+ const r = l.url || window.location.origin + window.location.pathname, a = new URL(e["x-scalar-redirect-uri"], r).toString();
33
+ t.searchParams.set("redirect_uri", a);
34
34
  } else
35
35
  t.searchParams.set("redirect_uri", e["x-scalar-redirect-uri"]);
36
36
  e["x-scalar-security-query"] && Object.keys(e["x-scalar-security-query"]).forEach((r) => {
37
- var i;
38
- const n = (i = e["x-scalar-security-query"]) == null ? void 0 : i[r];
39
- n && t.searchParams.set(r, n);
40
- }), t.searchParams.set("client_id", e["x-scalar-client-id"]), t.searchParams.set("state", c), a && t.searchParams.set("scope", a);
41
- const s = window.open(t, "openAuth2Window", "left=100,top=100,width=800,height=600");
42
- return s ? new Promise((r) => {
43
- const n = setInterval(() => {
37
+ var s;
38
+ const a = (s = e["x-scalar-security-query"]) == null ? void 0 : s[r];
39
+ a && t.searchParams.set(r, a);
40
+ }), t.searchParams.set("client_id", e["x-scalar-client-id"]), t.searchParams.set("state", c), n && t.searchParams.set("scope", n);
41
+ const i = window.open(t, "openAuth2Window", "left=100,top=100,width=800,height=600");
42
+ return i ? new Promise((r) => {
43
+ const a = setInterval(() => {
44
44
  var _;
45
- let i = null, h = null, p = null, g = null;
45
+ let s = null, h = null, p = null, m = null;
46
46
  try {
47
- const o = new URL(s.location.href).searchParams;
48
- i = o.get("access_token"), h = o.get("code"), p = o.get("error"), g = o.get("error_description");
49
- const m = new URLSearchParams(s.location.href.split("#")[1]);
50
- i || (i = m.get("access_token")), h || (h = m.get("code")), p || (p = m.get("error")), g || (g = m.get("error_description"));
47
+ const o = new URL(i.location.href).searchParams, P = e["x-tokenName"] || "access_token";
48
+ s = o.get(P), h = o.get("code"), p = o.get("error"), m = o.get("error_description");
49
+ const g = new URLSearchParams(i.location.href.split("#")[1]);
50
+ s || (s = g.get(P)), h || (h = g.get("code")), p || (p = g.get("error")), m || (m = g.get("error_description"));
51
51
  } catch {
52
52
  }
53
- if (s.closed || i || h || p)
54
- if (clearInterval(n), s.close(), p)
55
- r([new Error(`OAuth error: ${p}${g ? ` (${g})` : ""}`), null]);
56
- else if (i) {
57
- const o = (_ = s.location.href.match(/state=([^&]*)/)) == null ? void 0 : _[1];
58
- r(o === c ? [null, i] : [new Error("State mismatch"), null]);
59
- } else h ? new URL(s.location.href).searchParams.get("state") === c ? P(e, a, {
53
+ if (i.closed || s || h || p)
54
+ if (clearInterval(a), i.close(), p)
55
+ r([new Error(`OAuth error: ${p}${m ? ` (${m})` : ""}`), null]);
56
+ else if (s) {
57
+ const o = (_ = i.location.href.match(/state=([^&]*)/)) == null ? void 0 : _[1];
58
+ r(o === c ? [null, s] : [new Error("State mismatch"), null]);
59
+ } else h ? new URL(i.location.href).searchParams.get("state") === c ? S(e, n, {
60
60
  code: h,
61
61
  pkce: u,
62
62
  proxyUrl: d
63
- }).then(r) : r([new Error("State mismatch"), null]) : (clearInterval(n), r([new Error("Window was closed without granting authorization"), null]));
63
+ }).then(r) : r([new Error("State mismatch"), null]) : (clearInterval(a), r([new Error("Window was closed without granting authorization"), null]));
64
64
  }, 200);
65
65
  }) : [new Error("Failed to open auth window"), null];
66
66
  } catch {
67
67
  return [new Error("Failed to authorize oauth2 flow"), null];
68
68
  }
69
- }, P = async (e, l, {
69
+ }, S = async (e, l, {
70
70
  code: d,
71
- pkce: a,
71
+ pkce: n,
72
72
  proxyUrl: c
73
73
  } = {}) => {
74
74
  if (!e)
75
75
  return [new Error("OAuth2 flow was not defined"), null];
76
76
  const t = new URLSearchParams();
77
- t.set("client_id", e["x-scalar-client-id"]), l && (e.type === "clientCredentials" || e.type === "password") && t.set("scope", l), e.clientSecret && t.set("client_secret", e.clientSecret), "x-scalar-redirect-uri" in e && e["x-scalar-redirect-uri"] && t.set("redirect_uri", e["x-scalar-redirect-uri"]), d ? (t.set("code", d), t.set("grant_type", "authorization_code"), a && t.set("code_verifier", a.codeVerifier)) : e.type === "password" ? (t.set("grant_type", "password"), t.set("username", e.username), t.set("password", e.password)) : t.set("grant_type", "client_credentials");
77
+ t.set("client_id", e["x-scalar-client-id"]), l && (e.type === "clientCredentials" || e.type === "password") && t.set("scope", l), e.clientSecret && t.set("client_secret", e.clientSecret), "x-scalar-redirect-uri" in e && e["x-scalar-redirect-uri"] && t.set("redirect_uri", e["x-scalar-redirect-uri"]), d ? (t.set("code", d), t.set("grant_type", "authorization_code"), n && t.set("code_verifier", n.codeVerifier)) : e.type === "password" ? (t.set("grant_type", "password"), t.set("username", e.username), t.set("password", e.password)) : t.set("grant_type", "client_credentials");
78
78
  try {
79
79
  const u = {
80
80
  "Content-Type": "application/x-www-form-urlencoded"
81
81
  };
82
82
  e.clientSecret && (u.Authorization = `Basic ${btoa(`${e["x-scalar-client-id"]}:${e.clientSecret}`)}`);
83
- const y = w(c, e.tokenUrl) ? `${c}?${new URLSearchParams([["scalar_url", e.tokenUrl]]).toString()}` : e.tokenUrl, s = await fetch(y, {
83
+ const y = k(c, e.tokenUrl) ? `${c}?${new URLSearchParams([["scalar_url", e.tokenUrl]]).toString()}` : e.tokenUrl, r = await (await fetch(y, {
84
84
  method: "POST",
85
85
  headers: u,
86
86
  body: t
87
- }), { access_token: r } = await s.json();
88
- return [null, r];
87
+ })).json(), a = e["x-tokenName"] || "access_token";
88
+ return [null, r[a]];
89
89
  } catch {
90
90
  return [new Error("Failed to get an access token. Please check your credentials."), null];
91
91
  }
92
92
  };
93
93
  export {
94
- k as authorizeOauth2,
95
- P as authorizeServers,
94
+ U as authorizeOauth2,
95
+ S as authorizeServers,
96
96
  x as generateCodeChallenge
97
97
  };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "rest",
19
19
  "testing"
20
20
  ],
21
- "version": "2.5.15",
21
+ "version": "2.5.17",
22
22
  "engines": {
23
23
  "node": ">=20"
24
24
  },
@@ -205,23 +205,23 @@
205
205
  "whatwg-mimetype": "^4.0.0",
206
206
  "yaml": "2.8.0",
207
207
  "zod": "3.24.1",
208
- "@scalar/icons": "0.4.6",
208
+ "@scalar/components": "0.14.18",
209
209
  "@scalar/draggable": "0.2.0",
210
+ "@scalar/icons": "0.4.6",
211
+ "@scalar/oas-utils": "0.4.13",
212
+ "@scalar/object-utils": "1.2.2",
210
213
  "@scalar/helpers": "0.0.6",
211
- "@scalar/components": "0.14.16",
212
214
  "@scalar/import": "0.4.13",
213
- "@scalar/oas-utils": "0.4.11",
214
- "@scalar/object-utils": "1.2.2",
215
- "@scalar/openapi-parser": "0.18.1",
216
215
  "@scalar/openapi-types": "0.3.5",
217
- "@scalar/snippetz": "0.4.0",
218
- "@scalar/types": "0.2.7",
219
- "@scalar/postman-to-openapi": "0.3.14",
220
- "@scalar/use-codemirror": "0.12.17",
216
+ "@scalar/openapi-parser": "0.18.1",
217
+ "@scalar/postman-to-openapi": "0.3.16",
218
+ "@scalar/snippetz": "0.4.1",
221
219
  "@scalar/use-hooks": "0.2.4",
222
- "@scalar/themes": "0.13.8",
223
220
  "@scalar/use-toasts": "0.8.0",
224
- "@scalar/use-tooltip": "1.1.0"
221
+ "@scalar/themes": "0.13.9",
222
+ "@scalar/use-codemirror": "0.12.19",
223
+ "@scalar/use-tooltip": "1.1.0",
224
+ "@scalar/types": "0.2.8"
225
225
  },
226
226
  "devDependencies": {
227
227
  "@tailwindcss/vite": "^4.1.7",