@scalar/api-client 2.3.32 → 2.3.34

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 (105) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/components/CodeInput/CodeInput.vue.d.ts.map +1 -1
  3. package/dist/components/CodeInput/CodeInput.vue.js +1 -1
  4. package/dist/components/CodeInput/CodeInput.vue2.js +63 -61
  5. package/dist/components/DataTable/DataTable.vue.js +1 -1
  6. package/dist/components/EnvironmentSelector/EnvironmentSelector.vue.d.ts.map +1 -1
  7. package/dist/components/EnvironmentSelector/EnvironmentSelector.vue.js +58 -48
  8. package/dist/components/Sidebar/SidebarListElement.vue.d.ts +2 -2
  9. package/dist/components/ViewLayout/ViewLayoutCollapse.vue.d.ts.map +1 -1
  10. package/dist/components/ViewLayout/ViewLayoutCollapse.vue.js +34 -32
  11. package/dist/components/ViewLayout/ViewLayoutSection.vue.d.ts.map +1 -1
  12. package/dist/components/ViewLayout/ViewLayoutSection.vue.js +6 -6
  13. package/dist/hooks/useClientConfig.d.ts +3 -0
  14. package/dist/hooks/useClientConfig.d.ts.map +1 -1
  15. package/dist/layouts/App/create-api-client-app.d.ts +64 -24
  16. package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
  17. package/dist/layouts/Modal/create-api-client-modal.d.ts +128 -48
  18. package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
  19. package/dist/layouts/Web/create-api-client-web.d.ts +64 -24
  20. package/dist/layouts/Web/create-api-client-web.d.ts.map +1 -1
  21. package/dist/libs/create-client.d.ts +64 -24
  22. package/dist/libs/create-client.d.ts.map +1 -1
  23. package/dist/libs/index.js +32 -29
  24. package/dist/libs/local-storage.d.ts +8 -0
  25. package/dist/libs/local-storage.d.ts.map +1 -1
  26. package/dist/libs/local-storage.js +28 -24
  27. package/dist/libs/send-request/create-request-operation.d.ts.map +1 -1
  28. package/dist/libs/send-request/create-request-operation.js +8 -8
  29. package/dist/libs/send-request/create-request-operation.test.d.ts +2 -2
  30. package/dist/libs/send-request/create-request-operation.test.d.ts.map +1 -1
  31. package/dist/libs/send-request/decode-buffer.js +4 -4
  32. package/dist/libs/send-request/index.d.ts +1 -0
  33. package/dist/libs/send-request/index.d.ts.map +1 -1
  34. package/dist/libs/send-request/index.js +6 -4
  35. package/dist/store/active-entities.d.ts +2 -2
  36. package/dist/store/active-entities.d.ts.map +1 -1
  37. package/dist/store/request-example.d.ts +22 -22
  38. package/dist/store/request-example.d.ts.map +1 -1
  39. package/dist/store/security-schemes.d.ts +42 -2
  40. package/dist/store/security-schemes.d.ts.map +1 -1
  41. package/dist/store/store.d.ts +64 -24
  42. package/dist/store/store.d.ts.map +1 -1
  43. package/dist/style.css +1 -1
  44. package/dist/views/Collection/CollectionAuthentication.vue.d.ts.map +1 -1
  45. package/dist/views/Collection/CollectionAuthentication.vue.js +1 -1
  46. package/dist/views/Collection/CollectionAuthentication.vue2.js +32 -32
  47. package/dist/views/Collection/CollectionEnvironment.vue.d.ts.map +1 -1
  48. package/dist/views/Collection/CollectionEnvironment.vue.js +3 -2
  49. package/dist/views/Collection/CollectionEnvironment.vue2.js +233 -9
  50. package/dist/views/Collection/CollectionNavigation.vue.js +36 -36
  51. package/dist/views/Collection/CollectionServers.vue.d.ts.map +1 -1
  52. package/dist/views/Collection/CollectionServers.vue2.js +6 -6
  53. package/dist/views/Collection/components/EnvironmentForm.vue.d.ts +13 -0
  54. package/dist/views/Collection/components/EnvironmentForm.vue.d.ts.map +1 -0
  55. package/dist/views/Collection/components/EnvironmentForm.vue.js +7 -0
  56. package/dist/views/Collection/components/EnvironmentForm.vue2.js +274 -0
  57. package/dist/views/Components/CodeSnippet/helpers/convert-to-har-request.d.ts.map +1 -1
  58. package/dist/views/Components/CodeSnippet/helpers/convert-to-har-request.js +35 -34
  59. package/dist/views/Environment/EnvironmentModal.vue.d.ts.map +1 -1
  60. package/dist/views/Environment/EnvironmentModal.vue.js +32 -28
  61. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts +1 -0
  62. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts.map +1 -1
  63. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js +67 -65
  64. package/dist/views/Request/RequestSection/RequestAuth/OAuthScopesInput.vue.d.ts.map +1 -1
  65. package/dist/views/Request/RequestSection/RequestAuth/OAuthScopesInput.vue.js +94 -97
  66. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.d.ts +1 -0
  67. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.d.ts.map +1 -1
  68. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.js +2 -2
  69. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue2.js +116 -99
  70. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue.d.ts +1 -0
  71. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue.d.ts.map +1 -1
  72. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue.js +1 -1
  73. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue2.js +27 -25
  74. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthTab.vue.d.ts +1 -0
  75. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthTab.vue.d.ts.map +1 -1
  76. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthTab.vue.js +2 -2
  77. package/dist/views/Request/RequestSection/RequestAuth/RequestAuthTab.vue2.js +114 -73
  78. package/dist/views/Request/RequestSection/RequestSection.vue.d.ts.map +1 -1
  79. package/dist/views/Request/RequestSection/RequestSection.vue.js +1 -1
  80. package/dist/views/Request/RequestSection/RequestSection.vue2.js +15 -15
  81. package/dist/views/Request/RequestSection/RequestTable.vue.d.ts.map +1 -1
  82. package/dist/views/Request/RequestSection/RequestTable.vue.js +4 -4
  83. package/dist/views/Request/RequestSection/RequestTable.vue2.js +42 -40
  84. package/dist/views/Request/RequestSection/helpers/update-scheme.d.ts +8 -0
  85. package/dist/views/Request/RequestSection/helpers/update-scheme.d.ts.map +1 -0
  86. package/dist/views/Request/RequestSection/helpers/update-scheme.js +17 -0
  87. package/dist/views/Request/RequestSection/helpers/update-scheme.test.d.ts +2 -0
  88. package/dist/views/Request/RequestSection/helpers/update-scheme.test.d.ts.map +1 -0
  89. package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
  90. package/dist/views/Request/RequestSidebar.vue.js +1 -1
  91. package/dist/views/Request/RequestSidebar.vue2.js +87 -84
  92. package/dist/views/Request/ResponseSection/ResponseBody.vue.js +2 -2
  93. package/dist/views/Request/ResponseSection/ResponseBody.vue2.js +21 -21
  94. package/dist/views/Request/ResponseSection/ResponseBodyDownload.vue.d.ts.map +1 -1
  95. package/dist/views/Request/ResponseSection/ResponseBodyDownload.vue.js +11 -11
  96. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  97. package/dist/views/Request/consts/index.js +7 -5
  98. package/dist/views/Request/consts/mediaTypes.d.ts +4 -0
  99. package/dist/views/Request/consts/mediaTypes.d.ts.map +1 -1
  100. package/dist/views/Request/consts/mediaTypes.js +21 -4
  101. package/dist/views/Request/consts/mediaTypes.test.d.ts +2 -0
  102. package/dist/views/Request/consts/mediaTypes.test.d.ts.map +1 -0
  103. package/dist/views/Request/libs/oauth2.d.ts.map +1 -1
  104. package/dist/views/Request/libs/oauth2.js +53 -47
  105. package/package.json +14 -14
@@ -1,91 +1,97 @@
1
- import { shouldUseProxy as y } from "@scalar/oas-utils/helpers";
2
- const w = () => {
1
+ import { shouldUseProxy as w } from "@scalar/oas-utils/helpers";
2
+ const S = () => {
3
3
  const e = new Uint8Array(32);
4
4
  return crypto.getRandomValues(e), btoa(String.fromCharCode(...e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
5
- }, P = async (e, i) => {
6
- if (i === "plain")
5
+ }, x = async (e, l) => {
6
+ if (l === "plain")
7
7
  return e;
8
- const a = new TextEncoder().encode(e), s = await crypto.subtle.digest("SHA-256", a);
9
- return btoa(String.fromCharCode(...new Uint8Array(s))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
10
- }, C = async (e, i, o) => {
8
+ const a = new TextEncoder().encode(e), c = await crypto.subtle.digest("SHA-256", a);
9
+ return btoa(String.fromCharCode(...new Uint8Array(c))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
10
+ }, k = async (e, l, d) => {
11
11
  try {
12
12
  if (!e)
13
13
  return [new Error("Flow not found"), null];
14
14
  const a = e.selectedScopes.join(" ");
15
15
  if (e.type === "clientCredentials" || e.type === "password")
16
- return _(e, a, {
17
- proxyUrl: o
16
+ return P(e, a, {
17
+ proxyUrl: d
18
18
  });
19
- const s = (Math.random() + 1).toString(36).substring(2, 10), t = new URL(e.authorizationUrl);
20
- let l = null;
19
+ const c = (Math.random() + 1).toString(36).substring(2, 10), t = new URL(e.authorizationUrl);
20
+ let u = null;
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 = w(), c = await P(r, e["x-usePkce"]);
25
- l = {
24
+ const r = S(), n = await x(r, e["x-usePkce"]);
25
+ u = {
26
26
  codeVerifier: r,
27
- codeChallenge: c,
27
+ codeChallenge: n,
28
28
  codeChallengeMethod: e["x-usePkce"] === "SHA-256" ? "S256" : "plain"
29
- }, t.searchParams.set("code_challenge", c), t.searchParams.set("code_challenge_method", l.codeChallengeMethod);
29
+ }, t.searchParams.set("code_challenge", n), t.searchParams.set("code_challenge_method", u.codeChallengeMethod);
30
30
  }
31
31
  if (e["x-scalar-redirect-uri"].startsWith("/")) {
32
- const r = i.url || window.location.origin + window.location.pathname, c = new URL(e["x-scalar-redirect-uri"], r).toString();
33
- t.searchParams.set("redirect_uri", c);
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);
34
34
  } else
35
35
  t.searchParams.set("redirect_uri", e["x-scalar-redirect-uri"]);
36
- t.searchParams.set("client_id", e["x-scalar-client-id"]), t.searchParams.set("state", s), a && t.searchParams.set("scope", a);
37
- const n = window.open(t, "openAuth2Window", "left=100,top=100,width=800,height=600");
38
- return n ? new Promise((r) => {
39
- const c = setInterval(() => {
40
- var m;
41
- let u = null, h = null;
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(() => {
44
+ var _;
45
+ let i = null, h = null, p = null, g = null;
42
46
  try {
43
- const d = new URL(n.location.href).searchParams;
44
- u = d.get("access_token"), h = d.get("code");
45
- const g = new URLSearchParams(n.location.href.split("#")[1]);
46
- u || (u = g.get("access_token")), h || (h = g.get("code"));
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
51
  } catch {
48
52
  }
49
- if (n.closed || u || h)
50
- if (clearInterval(c), n.close(), u) {
51
- const d = (m = n.location.href.match(/state=([^&]*)/)) == null ? void 0 : m[1];
52
- r(d === s ? [null, u] : [new Error("State mismatch"), null]);
53
- } else h ? new URL(n.location.href).searchParams.get("state") === s ? _(e, a, {
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, {
54
60
  code: h,
55
- pkce: l,
56
- proxyUrl: o
57
- }).then(r) : r([new Error("State mismatch"), null]) : (clearInterval(c), r([new Error("Window was closed without granting authorization"), null]));
61
+ pkce: u,
62
+ proxyUrl: d
63
+ }).then(r) : r([new Error("State mismatch"), null]) : (clearInterval(n), r([new Error("Window was closed without granting authorization"), null]));
58
64
  }, 200);
59
65
  }) : [new Error("Failed to open auth window"), null];
60
66
  } catch {
61
67
  return [new Error("Failed to authorize oauth2 flow"), null];
62
68
  }
63
- }, _ = async (e, i, {
64
- code: o,
69
+ }, P = async (e, l, {
70
+ code: d,
65
71
  pkce: a,
66
- proxyUrl: s
72
+ proxyUrl: c
67
73
  } = {}) => {
68
74
  if (!e)
69
75
  return [new Error("OAuth2 flow was not defined"), null];
70
76
  const t = new URLSearchParams();
71
- t.set("client_id", e["x-scalar-client-id"]), i && (e.type === "clientCredentials" || e.type === "password") && t.set("scope", i), 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"]), o ? (t.set("code", o), 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"), 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");
72
78
  try {
73
- const l = {
79
+ const u = {
74
80
  "Content-Type": "application/x-www-form-urlencoded"
75
81
  };
76
- e.clientSecret && (l.Authorization = `Basic ${btoa(`${e["x-scalar-client-id"]}:${e.clientSecret}`)}`);
77
- const p = y(s, e.tokenUrl) ? `${s}?${new URLSearchParams([["scalar_url", e.tokenUrl]]).toString()}` : e.tokenUrl, n = await fetch(p, {
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, {
78
84
  method: "POST",
79
- headers: l,
85
+ headers: u,
80
86
  body: t
81
- }), { access_token: r } = await n.json();
87
+ }), { access_token: r } = await s.json();
82
88
  return [null, r];
83
89
  } catch {
84
90
  return [new Error("Failed to get an access token. Please check your credentials."), null];
85
91
  }
86
92
  };
87
93
  export {
88
- C as authorizeOauth2,
89
- _ as authorizeServers,
90
- P as generateCodeChallenge
94
+ k as authorizeOauth2,
95
+ P as authorizeServers,
96
+ x as generateCodeChallenge
91
97
  };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "rest",
19
19
  "testing"
20
20
  ],
21
- "version": "2.3.32",
21
+ "version": "2.3.34",
22
22
  "engines": {
23
23
  "node": ">=18"
24
24
  },
@@ -199,20 +199,20 @@
199
199
  "whatwg-mimetype": "^4.0.0",
200
200
  "yaml": "^2.4.5",
201
201
  "zod": "3.24.1",
202
- "@scalar/components": "0.13.57",
203
- "@scalar/icons": "0.3.5",
202
+ "@scalar/components": "0.13.59",
204
203
  "@scalar/draggable": "0.1.11",
205
- "@scalar/import": "0.3.25",
206
- "@scalar/oas-utils": "0.2.142",
207
- "@scalar/object-utils": "1.1.14",
204
+ "@scalar/icons": "0.3.7",
205
+ "@scalar/import": "0.3.27",
206
+ "@scalar/oas-utils": "0.2.144",
208
207
  "@scalar/openapi-parser": "0.10.17",
209
- "@scalar/openapi-types": "0.2.2",
210
- "@scalar/postman-to-openapi": "0.2.15",
208
+ "@scalar/object-utils": "1.1.14",
209
+ "@scalar/postman-to-openapi": "0.2.17",
210
+ "@scalar/openapi-types": "0.2.3",
211
211
  "@scalar/snippetz": "0.2.20",
212
- "@scalar/themes": "0.11.1",
213
- "@scalar/types": "0.1.14",
214
- "@scalar/use-codemirror": "0.11.102",
215
- "@scalar/use-hooks": "0.1.48",
212
+ "@scalar/types": "0.1.16",
213
+ "@scalar/use-codemirror": "0.11.104",
214
+ "@scalar/themes": "0.11.3",
215
+ "@scalar/use-hooks": "0.1.50",
216
216
  "@scalar/use-tooltip": "1.0.7",
217
217
  "@scalar/use-toasts": "0.7.10"
218
218
  },
@@ -229,8 +229,8 @@
229
229
  "vite": "5.4.19",
230
230
  "vite-svg-loader": "^5.1.0",
231
231
  "vitest": "^1.6.0",
232
- "@scalar/build-tooling": "0.1.19",
233
- "@scalar/galaxy": "0.3.2"
232
+ "@scalar/galaxy": "0.3.2",
233
+ "@scalar/build-tooling": "0.1.19"
234
234
  },
235
235
  "scripts": {
236
236
  "build": "scalar-build-vite",