@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.
- package/CHANGELOG.md +52 -0
- package/dist/components/CodeInput/CodeInput.vue.d.ts.map +1 -1
- package/dist/components/CodeInput/CodeInput.vue.js +1 -1
- package/dist/components/CodeInput/CodeInput.vue2.js +63 -61
- package/dist/components/DataTable/DataTable.vue.js +1 -1
- package/dist/components/EnvironmentSelector/EnvironmentSelector.vue.d.ts.map +1 -1
- package/dist/components/EnvironmentSelector/EnvironmentSelector.vue.js +58 -48
- package/dist/components/Sidebar/SidebarListElement.vue.d.ts +2 -2
- package/dist/components/ViewLayout/ViewLayoutCollapse.vue.d.ts.map +1 -1
- package/dist/components/ViewLayout/ViewLayoutCollapse.vue.js +34 -32
- package/dist/components/ViewLayout/ViewLayoutSection.vue.d.ts.map +1 -1
- package/dist/components/ViewLayout/ViewLayoutSection.vue.js +6 -6
- package/dist/hooks/useClientConfig.d.ts +3 -0
- package/dist/hooks/useClientConfig.d.ts.map +1 -1
- package/dist/layouts/App/create-api-client-app.d.ts +64 -24
- package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
- package/dist/layouts/Modal/create-api-client-modal.d.ts +128 -48
- package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
- package/dist/layouts/Web/create-api-client-web.d.ts +64 -24
- package/dist/layouts/Web/create-api-client-web.d.ts.map +1 -1
- package/dist/libs/create-client.d.ts +64 -24
- package/dist/libs/create-client.d.ts.map +1 -1
- package/dist/libs/index.js +32 -29
- package/dist/libs/local-storage.d.ts +8 -0
- package/dist/libs/local-storage.d.ts.map +1 -1
- package/dist/libs/local-storage.js +28 -24
- package/dist/libs/send-request/create-request-operation.d.ts.map +1 -1
- package/dist/libs/send-request/create-request-operation.js +8 -8
- package/dist/libs/send-request/create-request-operation.test.d.ts +2 -2
- package/dist/libs/send-request/create-request-operation.test.d.ts.map +1 -1
- package/dist/libs/send-request/decode-buffer.js +4 -4
- package/dist/libs/send-request/index.d.ts +1 -0
- package/dist/libs/send-request/index.d.ts.map +1 -1
- package/dist/libs/send-request/index.js +6 -4
- package/dist/store/active-entities.d.ts +2 -2
- package/dist/store/active-entities.d.ts.map +1 -1
- package/dist/store/request-example.d.ts +22 -22
- package/dist/store/request-example.d.ts.map +1 -1
- package/dist/store/security-schemes.d.ts +42 -2
- package/dist/store/security-schemes.d.ts.map +1 -1
- package/dist/store/store.d.ts +64 -24
- package/dist/store/store.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/views/Collection/CollectionAuthentication.vue.d.ts.map +1 -1
- package/dist/views/Collection/CollectionAuthentication.vue.js +1 -1
- package/dist/views/Collection/CollectionAuthentication.vue2.js +32 -32
- package/dist/views/Collection/CollectionEnvironment.vue.d.ts.map +1 -1
- package/dist/views/Collection/CollectionEnvironment.vue.js +3 -2
- package/dist/views/Collection/CollectionEnvironment.vue2.js +233 -9
- package/dist/views/Collection/CollectionNavigation.vue.js +36 -36
- package/dist/views/Collection/CollectionServers.vue.d.ts.map +1 -1
- package/dist/views/Collection/CollectionServers.vue2.js +6 -6
- package/dist/views/Collection/components/EnvironmentForm.vue.d.ts +13 -0
- package/dist/views/Collection/components/EnvironmentForm.vue.d.ts.map +1 -0
- package/dist/views/Collection/components/EnvironmentForm.vue.js +7 -0
- package/dist/views/Collection/components/EnvironmentForm.vue2.js +274 -0
- package/dist/views/Components/CodeSnippet/helpers/convert-to-har-request.d.ts.map +1 -1
- package/dist/views/Components/CodeSnippet/helpers/convert-to-har-request.js +35 -34
- package/dist/views/Environment/EnvironmentModal.vue.d.ts.map +1 -1
- package/dist/views/Environment/EnvironmentModal.vue.js +32 -28
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts +1 -0
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js +67 -65
- package/dist/views/Request/RequestSection/RequestAuth/OAuthScopesInput.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuthScopesInput.vue.js +94 -97
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.d.ts +1 -0
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.js +2 -2
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue2.js +116 -99
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue.d.ts +1 -0
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue.js +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuthDataTable.vue2.js +27 -25
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuthTab.vue.d.ts +1 -0
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuthTab.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuthTab.vue.js +2 -2
- package/dist/views/Request/RequestSection/RequestAuth/RequestAuthTab.vue2.js +114 -73
- package/dist/views/Request/RequestSection/RequestSection.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestSection.vue.js +1 -1
- package/dist/views/Request/RequestSection/RequestSection.vue2.js +15 -15
- package/dist/views/Request/RequestSection/RequestTable.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestTable.vue.js +4 -4
- package/dist/views/Request/RequestSection/RequestTable.vue2.js +42 -40
- package/dist/views/Request/RequestSection/helpers/update-scheme.d.ts +8 -0
- package/dist/views/Request/RequestSection/helpers/update-scheme.d.ts.map +1 -0
- package/dist/views/Request/RequestSection/helpers/update-scheme.js +17 -0
- package/dist/views/Request/RequestSection/helpers/update-scheme.test.d.ts +2 -0
- package/dist/views/Request/RequestSection/helpers/update-scheme.test.d.ts.map +1 -0
- package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSidebar.vue.js +1 -1
- package/dist/views/Request/RequestSidebar.vue2.js +87 -84
- package/dist/views/Request/ResponseSection/ResponseBody.vue.js +2 -2
- package/dist/views/Request/ResponseSection/ResponseBody.vue2.js +21 -21
- package/dist/views/Request/ResponseSection/ResponseBodyDownload.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseBodyDownload.vue.js +11 -11
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/dist/views/Request/consts/index.js +7 -5
- package/dist/views/Request/consts/mediaTypes.d.ts +4 -0
- package/dist/views/Request/consts/mediaTypes.d.ts.map +1 -1
- package/dist/views/Request/consts/mediaTypes.js +21 -4
- package/dist/views/Request/consts/mediaTypes.test.d.ts +2 -0
- package/dist/views/Request/consts/mediaTypes.test.d.ts.map +1 -0
- package/dist/views/Request/libs/oauth2.d.ts.map +1 -1
- package/dist/views/Request/libs/oauth2.js +53 -47
- package/package.json +14 -14
|
@@ -1,91 +1,97 @@
|
|
|
1
|
-
import { shouldUseProxy as
|
|
2
|
-
const
|
|
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
|
-
},
|
|
6
|
-
if (
|
|
5
|
+
}, x = async (e, l) => {
|
|
6
|
+
if (l === "plain")
|
|
7
7
|
return e;
|
|
8
|
-
const a = new TextEncoder().encode(e),
|
|
9
|
-
return btoa(String.fromCharCode(...new Uint8Array(
|
|
10
|
-
},
|
|
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
|
|
17
|
-
proxyUrl:
|
|
16
|
+
return P(e, a, {
|
|
17
|
+
proxyUrl: d
|
|
18
18
|
});
|
|
19
|
-
const
|
|
20
|
-
let
|
|
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 =
|
|
25
|
-
|
|
24
|
+
const r = S(), n = await x(r, e["x-usePkce"]);
|
|
25
|
+
u = {
|
|
26
26
|
codeVerifier: r,
|
|
27
|
-
codeChallenge:
|
|
27
|
+
codeChallenge: n,
|
|
28
28
|
codeChallengeMethod: e["x-usePkce"] === "SHA-256" ? "S256" : "plain"
|
|
29
|
-
}, t.searchParams.set("code_challenge",
|
|
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 =
|
|
33
|
-
t.searchParams.set("redirect_uri",
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
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 (
|
|
50
|
-
if (clearInterval(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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:
|
|
56
|
-
proxyUrl:
|
|
57
|
-
}).then(r) : r([new Error("State mismatch"), null]) : (clearInterval(
|
|
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
|
-
},
|
|
64
|
-
code:
|
|
69
|
+
}, P = async (e, l, {
|
|
70
|
+
code: d,
|
|
65
71
|
pkce: a,
|
|
66
|
-
proxyUrl:
|
|
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"]),
|
|
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
|
|
79
|
+
const u = {
|
|
74
80
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
75
81
|
};
|
|
76
|
-
e.clientSecret && (
|
|
77
|
-
const
|
|
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:
|
|
85
|
+
headers: u,
|
|
80
86
|
body: t
|
|
81
|
-
}), { access_token: r } = await
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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.
|
|
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.
|
|
203
|
-
"@scalar/icons": "0.3.5",
|
|
202
|
+
"@scalar/components": "0.13.59",
|
|
204
203
|
"@scalar/draggable": "0.1.11",
|
|
205
|
-
"@scalar/
|
|
206
|
-
"@scalar/
|
|
207
|
-
"@scalar/
|
|
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/
|
|
210
|
-
"@scalar/postman-to-openapi": "0.2.
|
|
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/
|
|
213
|
-
"@scalar/
|
|
214
|
-
"@scalar/
|
|
215
|
-
"@scalar/use-hooks": "0.1.
|
|
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/
|
|
233
|
-
"@scalar/
|
|
232
|
+
"@scalar/galaxy": "0.3.2",
|
|
233
|
+
"@scalar/build-tooling": "0.1.19"
|
|
234
234
|
},
|
|
235
235
|
"scripts": {
|
|
236
236
|
"build": "scalar-build-vite",
|