@scalar/api-client 2.13.0 → 2.14.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 +24 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts +2 -2
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +90 -75
- package/dist/v2/features/operation/Operation.vue.js +1 -1
- package/dist/v2/helpers/drag-handle-factory.d.ts.map +1 -1
- package/dist/v2/helpers/drag-handle-factory.js +72 -71
- package/dist/v2/hooks/use-sidebar-state.d.ts.map +1 -1
- package/dist/v2/hooks/use-sidebar-state.js +23 -19
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/dist/views/Request/libs/oauth2.d.ts +2 -2
- package/dist/views/Request/libs/oauth2.d.ts.map +1 -1
- package/dist/views/Request/libs/oauth2.js +66 -53
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @scalar/api-client
|
|
2
2
|
|
|
3
|
+
## 2.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#7477](https://github.com/scalar/scalar/pull/7477) [`9ec8adf`](https://github.com/scalar/scalar/commit/9ec8adfea017333dee5bc3949104232f7dc57f4a) Thanks [@DemonHa](https://github.com/DemonHa)! - fix: correctly sort documents on the workspace
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#7483](https://github.com/scalar/scalar/pull/7483) [`f446bbc`](https://github.com/scalar/scalar/commit/f446bbc0b8aec7fa7314603fd48471f06c1318d5) Thanks [@hanspagel](https://github.com/hanspagel)! - fix: can not use relative URLs in oauth security schemes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`8842799`](https://github.com/scalar/scalar/commit/884279984b144082e85b699014e77ed71e9ae6a5), [`18a7bcd`](https://github.com/scalar/scalar/commit/18a7bcd8ad00f9f7ee09a562167593c7ed07e01d), [`18a7bcd`](https://github.com/scalar/scalar/commit/18a7bcd8ad00f9f7ee09a562167593c7ed07e01d), [`9ec8adf`](https://github.com/scalar/scalar/commit/9ec8adfea017333dee5bc3949104232f7dc57f4a), [`cc4de25`](https://github.com/scalar/scalar/commit/cc4de2587b36f0d169b01c1bf312ba91b67e3e0c)]:
|
|
14
|
+
- @scalar/workspace-store@0.22.1
|
|
15
|
+
- @scalar/use-codemirror@0.13.0
|
|
16
|
+
- @scalar/helpers@0.2.0
|
|
17
|
+
- @scalar/use-hooks@0.3.2
|
|
18
|
+
- @scalar/oas-utils@0.6.6
|
|
19
|
+
- @scalar/sidebar@0.5.1
|
|
20
|
+
- @scalar/components@0.16.6
|
|
21
|
+
- @scalar/import@0.4.37
|
|
22
|
+
- @scalar/json-magic@0.8.4
|
|
23
|
+
- @scalar/object-utils@1.2.14
|
|
24
|
+
- @scalar/postman-to-openapi@0.3.47
|
|
25
|
+
- @scalar/openapi-parser@0.23.5
|
|
26
|
+
|
|
3
27
|
## 2.13.0
|
|
4
28
|
|
|
5
29
|
### Minor Changes
|
|
@@ -25,10 +25,10 @@ proxyUrl?: string) => Promise<ErrorResponse<string>>;
|
|
|
25
25
|
* Makes the BE authorization call to grab the token server to server
|
|
26
26
|
* Used for clientCredentials and authorizationCode
|
|
27
27
|
*/
|
|
28
|
-
export declare const authorizeServers: (flows: NonImplicitFlow, type: keyof NonImplicitFlow, scopes: string, { code, pkce, proxyUrl, }
|
|
28
|
+
export declare const authorizeServers: (flows: NonImplicitFlow, type: keyof NonImplicitFlow, scopes: string, { code, pkce, proxyUrl, }: {
|
|
29
29
|
code?: string;
|
|
30
30
|
pkce?: PKCEState | null;
|
|
31
31
|
proxyUrl?: string | undefined;
|
|
32
|
-
}) => Promise<ErrorResponse<string>>;
|
|
32
|
+
} | undefined, activeServer: ServerObject | undefined) => Promise<ErrorResponse<string>>;
|
|
33
33
|
export {};
|
|
34
34
|
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/helpers/oauth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/helpers/oauth.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAGlH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,qDAAqD;AACrD,KAAK,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAA;AAEzD,KAAK,SAAS,GAAG;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,mBAAmB,EAAE,MAAM,CAAA;CAC5B,CAAA;AAgBD;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAU,UAAU,MAAM,EAAE,UAAU,SAAS,GAAG,OAAO,KAAG,OAAO,CAAC,MAAM,CAkB3G,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,gBAAgB,EACvB,MAAM,MAAM,gBAAgB,EAC5B,gBAAgB,MAAM,EAAE;AACxB,wEAAwE;AACxE,cAAc,YAAY,GAAG,SAAS;AACtC,kCAAkC;AAClC,WAAW,MAAM,KAChB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAmL/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,OAAO,eAAe,EACtB,MAAM,MAAM,eAAe,EAC3B,QAAQ,MAAM,EACd,2BAIG;IACD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,YAAK,EACN,cAAc,YAAY,GAAG,SAAS,KACrC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CA+F/B,CAAA"}
|
|
@@ -1,113 +1,128 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { makeUrlAbsolute as A } from "@scalar/helpers/url/make-url-absolute";
|
|
2
|
+
import { shouldUseProxy as b } from "@scalar/oas-utils/helpers";
|
|
3
|
+
import { encode as C, fromUint8Array as S } from "js-base64";
|
|
4
|
+
const E = () => {
|
|
5
|
+
const r = new Uint8Array(32);
|
|
6
|
+
return crypto.getRandomValues(r), S(r, !0);
|
|
7
|
+
}, z = async (r, t) => {
|
|
7
8
|
if (t === "plain")
|
|
8
|
-
return
|
|
9
|
+
return r;
|
|
9
10
|
if (typeof crypto?.subtle?.digest != "function")
|
|
10
|
-
return console.warn("SHA-256 is only supported when using https, using a plain text code challenge instead."),
|
|
11
|
-
const
|
|
12
|
-
return S(new Uint8Array(
|
|
13
|
-
},
|
|
14
|
-
const
|
|
11
|
+
return console.warn("SHA-256 is only supported when using https, using a plain text code challenge instead."), r;
|
|
12
|
+
const l = new TextEncoder().encode(r), w = await crypto.subtle.digest("SHA-256", l);
|
|
13
|
+
return S(new Uint8Array(w), !0);
|
|
14
|
+
}, $ = async (r, t, p, l, w) => {
|
|
15
|
+
const d = r[t];
|
|
15
16
|
try {
|
|
16
|
-
if (!
|
|
17
|
+
if (!d)
|
|
17
18
|
return [new Error("Flow not found"), null];
|
|
18
|
-
const
|
|
19
|
+
const f = p.join(" ");
|
|
19
20
|
if (t === "clientCredentials" || t === "password")
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
return U(
|
|
22
|
+
r,
|
|
23
|
+
t,
|
|
24
|
+
f,
|
|
25
|
+
{
|
|
26
|
+
proxyUrl: w
|
|
27
|
+
},
|
|
28
|
+
l
|
|
29
|
+
);
|
|
30
|
+
const e = (Math.random() + 1).toString(36).substring(2, 10), a = A(r[t].authorizationUrl, {
|
|
31
|
+
baseUrl: l?.url
|
|
32
|
+
}), n = new URL(a);
|
|
24
33
|
let o = null;
|
|
25
34
|
if (t === "implicit")
|
|
26
|
-
|
|
35
|
+
n.searchParams.set("response_type", "token");
|
|
27
36
|
else if (t === "authorizationCode") {
|
|
28
|
-
const s =
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
37
|
+
const s = r[t];
|
|
38
|
+
if (n.searchParams.set("response_type", "code"), s["x-usePkce"] !== "no") {
|
|
39
|
+
const c = E(), i = await z(c, s["x-usePkce"]);
|
|
31
40
|
o = {
|
|
32
|
-
codeVerifier:
|
|
33
|
-
codeChallenge:
|
|
41
|
+
codeVerifier: c,
|
|
42
|
+
codeChallenge: i,
|
|
34
43
|
codeChallengeMethod: s["x-usePkce"] === "SHA-256" ? "S256" : "plain"
|
|
35
|
-
},
|
|
44
|
+
}, n.searchParams.set("code_challenge", i), n.searchParams.set("code_challenge_method", o.codeChallengeMethod);
|
|
36
45
|
}
|
|
37
46
|
}
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
const s =
|
|
41
|
-
|
|
47
|
+
const m = r[t];
|
|
48
|
+
if (m["x-scalar-secret-redirect-uri"].startsWith("/")) {
|
|
49
|
+
const s = l?.url || window.location.origin + window.location.pathname, c = new URL(m["x-scalar-secret-redirect-uri"], s).toString();
|
|
50
|
+
n.searchParams.set("redirect_uri", c);
|
|
42
51
|
} else
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
}),
|
|
48
|
-
const
|
|
49
|
-
return
|
|
50
|
-
const
|
|
51
|
-
let
|
|
52
|
+
n.searchParams.set("redirect_uri", m["x-scalar-secret-redirect-uri"]);
|
|
53
|
+
d["x-scalar-security-query"] && Object.keys(d["x-scalar-security-query"]).forEach((s) => {
|
|
54
|
+
const c = d["x-scalar-security-query"]?.[s];
|
|
55
|
+
c && n.searchParams.set(s, c);
|
|
56
|
+
}), n.searchParams.set("client_id", d["x-scalar-secret-client-id"]), n.searchParams.set("state", e), f && n.searchParams.set("scope", f);
|
|
57
|
+
const u = window.open(n, "openAuth2Window", "left=100,top=100,width=800,height=600");
|
|
58
|
+
return u ? new Promise((s) => {
|
|
59
|
+
const c = setInterval(() => {
|
|
60
|
+
let i = null, g = null, x = null, P = null;
|
|
52
61
|
try {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
62
|
+
const h = new URL(u.location.href).searchParams, k = d["x-tokenName"] || "access_token";
|
|
63
|
+
i = h.get(k), g = h.get("code"), x = h.get("error"), P = h.get("error_description");
|
|
64
|
+
const y = new URLSearchParams(u.location.href.split("#")[1]);
|
|
65
|
+
i ||= y.get(k), g ||= y.get("code"), x ||= y.get("error"), P ||= y.get("error_description");
|
|
57
66
|
} catch {
|
|
58
67
|
}
|
|
59
|
-
if (
|
|
60
|
-
if (clearInterval(
|
|
61
|
-
s([new Error(`OAuth error: ${x}${
|
|
62
|
-
else if (
|
|
63
|
-
const
|
|
64
|
-
s(
|
|
65
|
-
} else g && t === "authorizationCode" ? new URL(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
if (u.closed || i || g || x)
|
|
69
|
+
if (clearInterval(c), u.close(), x)
|
|
70
|
+
s([new Error(`OAuth error: ${x}${P ? ` (${P})` : ""}`), null]);
|
|
71
|
+
else if (i) {
|
|
72
|
+
const h = u.location.href.match(/state=([^&]*)/)?.[1];
|
|
73
|
+
s(h === e ? [null, i] : [new Error("State mismatch"), null]);
|
|
74
|
+
} else g && t === "authorizationCode" ? new URL(u.location.href).searchParams.get("state") === e ? U(
|
|
75
|
+
r,
|
|
76
|
+
t,
|
|
77
|
+
f,
|
|
78
|
+
{
|
|
79
|
+
code: g,
|
|
80
|
+
pkce: o,
|
|
81
|
+
proxyUrl: w
|
|
82
|
+
},
|
|
83
|
+
l
|
|
84
|
+
).then(s) : s([new Error("State mismatch"), null]) : (clearInterval(c), s([new Error("Window was closed without granting authorization"), null]));
|
|
70
85
|
}, 200);
|
|
71
86
|
}) : [new Error("Failed to open auth window"), null];
|
|
72
87
|
} catch {
|
|
73
88
|
return [new Error("Failed to authorize oauth2 flow"), null];
|
|
74
89
|
}
|
|
75
|
-
},
|
|
76
|
-
code:
|
|
77
|
-
pkce:
|
|
78
|
-
proxyUrl:
|
|
79
|
-
} = {}) => {
|
|
80
|
-
const e =
|
|
90
|
+
}, U = async (r, t, p, {
|
|
91
|
+
code: l,
|
|
92
|
+
pkce: w,
|
|
93
|
+
proxyUrl: d
|
|
94
|
+
} = {}, f) => {
|
|
95
|
+
const e = r[t];
|
|
81
96
|
if (!e)
|
|
82
97
|
return [new Error("OAuth2 flow was not defined"), null];
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
98
|
+
const a = new URLSearchParams();
|
|
99
|
+
if (a.set("client_id", e["x-scalar-secret-client-id"]), p && (t === "clientCredentials" || t === "password") && a.set("scope", p), e["x-scalar-secret-client-secret"] && (!e["x-scalar-credentials-location"] || e["x-scalar-credentials-location"] === "body") && a.set("client_secret", e["x-scalar-secret-client-secret"]), "x-scalar-secret-redirect-uri" in e && e["x-scalar-secret-redirect-uri"] && a.set("redirect_uri", e["x-scalar-secret-redirect-uri"]), l)
|
|
100
|
+
a.set("code", l), a.set("grant_type", "authorization_code"), w && a.set("code_verifier", w.codeVerifier);
|
|
86
101
|
else if (t === "password") {
|
|
87
|
-
const o =
|
|
88
|
-
|
|
102
|
+
const o = r[t];
|
|
103
|
+
a.set("grant_type", "password"), a.set("username", o["x-scalar-secret-username"]), a.set("password", o["x-scalar-secret-password"]);
|
|
89
104
|
} else
|
|
90
|
-
|
|
91
|
-
e["x-scalar-security-body"] && Object.entries(e["x-scalar-security-body"]).forEach(([o,
|
|
92
|
-
|
|
105
|
+
a.set("grant_type", "client_credentials");
|
|
106
|
+
e["x-scalar-security-body"] && Object.entries(e["x-scalar-security-body"]).forEach(([o, m]) => {
|
|
107
|
+
m && a.set(o, m);
|
|
93
108
|
});
|
|
94
109
|
try {
|
|
95
110
|
const o = {
|
|
96
111
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
97
112
|
};
|
|
98
|
-
e["x-scalar-secret-client-secret"] && (!e["x-scalar-credentials-location"] || e["x-scalar-credentials-location"] === "header") && (o.Authorization = `Basic ${
|
|
99
|
-
const
|
|
113
|
+
e["x-scalar-secret-client-secret"] && (!e["x-scalar-credentials-location"] || e["x-scalar-credentials-location"] === "header") && (o.Authorization = `Basic ${C(`${e["x-scalar-secret-client-id"]}:${e["x-scalar-secret-client-secret"]}`)}`);
|
|
114
|
+
const _ = A(e.tokenUrl, { baseUrl: f?.url }), u = b(d, _) ? `${d}?${new URLSearchParams([["scalar_url", _]]).toString()}` : _, c = await (await fetch(u, {
|
|
100
115
|
method: "POST",
|
|
101
116
|
headers: o,
|
|
102
|
-
body:
|
|
103
|
-
})).json(),
|
|
104
|
-
return [null,
|
|
117
|
+
body: a
|
|
118
|
+
})).json(), i = e["x-tokenName"] || "access_token";
|
|
119
|
+
return [null, c[i]];
|
|
105
120
|
} catch {
|
|
106
121
|
return [new Error("Failed to get an access token. Please check your credentials."), null];
|
|
107
122
|
}
|
|
108
123
|
};
|
|
109
124
|
export {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
$ as authorizeOauth2,
|
|
126
|
+
U as authorizeServers,
|
|
127
|
+
z as generateCodeChallenge
|
|
113
128
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drag-handle-factory.d.ts","sourceRoot":"","sources":["../../../src/v2/helpers/drag-handle-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"drag-handle-factory.d.ts","sourceRoot":"","sources":["../../../src/v2/helpers/drag-handle-factory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAc,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAIpE,OAAO,KAAK,EAEV,cAAc,EAGf,MAAM,4CAA4C,CAAA;AAGnD,OAAO,EAAE,KAAK,gBAAgB,EAAW,MAAM,KAAK,CAAA;AAiTpD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,kCAG/B;IACD,KAAK,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IAC9C,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC,CAAA;CAC3C;mCAKuC,YAAY,gBAAgB,WAAW,KAAG,OAAO;iCA2DnD,YAAY,gBAAgB,WAAW,KAAG,OAAO;CAwEtF,CAAA"}
|
|
@@ -1,119 +1,120 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sortByOrder as B } from "@scalar/helpers/array/sort-by-order";
|
|
2
|
+
import { dereference as k, escapeJsonPointer as j } from "@scalar/openapi-parser";
|
|
2
3
|
import { unpackProxyObject as x } from "@scalar/workspace-store/helpers/unpack-proxy";
|
|
3
|
-
import { getParentEntry as
|
|
4
|
+
import { getParentEntry as d, getOpenapiObject as h } from "@scalar/workspace-store/navigation";
|
|
4
5
|
import { toValue as b } from "vue";
|
|
5
|
-
import { removeCircular as
|
|
6
|
-
const P = (r, t, n,
|
|
6
|
+
import { removeCircular as A } from "./remove-circular.js";
|
|
7
|
+
const P = (r, t, n, a) => {
|
|
7
8
|
if (t === -1 || n === -1 || t === n)
|
|
8
9
|
return null;
|
|
9
|
-
const o = [...r], [
|
|
10
|
-
if (
|
|
10
|
+
const o = [...r], [e] = o.splice(t, 1);
|
|
11
|
+
if (e === void 0)
|
|
11
12
|
return null;
|
|
12
|
-
const u =
|
|
13
|
-
return o.splice(u, 0,
|
|
14
|
-
},
|
|
13
|
+
const u = R(t, n, a, o.length);
|
|
14
|
+
return o.splice(u, 0, e), x(o, { depth: 1 });
|
|
15
|
+
}, R = (r, t, n, a) => {
|
|
15
16
|
const o = r < t;
|
|
16
|
-
return n === "after" ? o ? t : t + 1 : n === "before" ? o ? t - 1 : t : n === "into" ?
|
|
17
|
-
}, y = (r, t) => t.includes(r.type),
|
|
18
|
-
const n =
|
|
17
|
+
return n === "after" ? o ? t : t + 1 : n === "before" ? o ? t - 1 : t : n === "into" ? a : t;
|
|
18
|
+
}, y = (r, t) => t.includes(r.type), p = (r) => r.offset === "before" || r.offset === "after", m = (r) => r.offset === "into", l = (r, t) => !r.parent || !t.parent ? !1 : r.parent.id === t.parent.id, O = ({ store: r, entry: t }) => {
|
|
19
|
+
const n = d("document", t);
|
|
19
20
|
n && r.buildSidebar(n.name);
|
|
20
|
-
},
|
|
21
|
+
}, M = (r, t) => r["x-scalar-order"] ?? t.children?.map((a) => a.id) ?? [], w = (r, t, n, a) => {
|
|
21
22
|
const o = t.parent;
|
|
22
23
|
if (!o || !y(o, ["tag", "document"]))
|
|
23
24
|
return !1;
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
25
|
+
const e = h({ store: r, entry: o });
|
|
26
|
+
if (!e)
|
|
26
27
|
return !1;
|
|
27
|
-
const u =
|
|
28
|
-
return
|
|
29
|
-
},
|
|
30
|
-
const
|
|
31
|
-
n &&
|
|
32
|
-
},
|
|
33
|
-
r.paths?.[n.path]?.[n.method] && delete r.paths[n.path][n.method], t.paths ? (t.paths[n.path] || (t.paths[n.path] = {}), t.paths[n.path][n.method] =
|
|
28
|
+
const u = M(e, o), s = u.findIndex((f) => f === t.id), c = u.findIndex((f) => f === n.id), i = P(u, s, c, a);
|
|
29
|
+
return i ? (e["x-scalar-order"] = i, O({ store: r, entry: o }), !0) : !1;
|
|
30
|
+
}, T = (r, t, n) => {
|
|
31
|
+
const a = new Set(r.tags ?? []);
|
|
32
|
+
n && a.add(n.name), t && a.delete(t.name), r.tags = Array.from(a);
|
|
33
|
+
}, $ = (r, t, n, a) => {
|
|
34
|
+
r.paths?.[n.path]?.[n.method] && delete r.paths[n.path][n.method], t.paths ? (t.paths[n.path] || (t.paths[n.path] = {}), t.paths[n.path][n.method] = a) : t.paths = {
|
|
34
35
|
[n.path]: {
|
|
35
|
-
[n.method]:
|
|
36
|
+
[n.method]: a
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
|
-
}, $ = (r, t, n) => {
|
|
39
|
-
const o = B(r).schema.paths?.[t]?.[n];
|
|
40
|
-
return j(o, { prefix: `#/paths/${k(t)}/${n}` });
|
|
41
39
|
}, C = (r, t, n) => {
|
|
42
|
-
const
|
|
43
|
-
|
|
40
|
+
const o = k(r).schema.paths?.[t]?.[n];
|
|
41
|
+
return A(o, { prefix: `#/paths/${j(t)}/${n}` });
|
|
42
|
+
}, F = (r, t, n) => {
|
|
43
|
+
const a = d("document", t), o = d("document", n);
|
|
44
|
+
if (!a || !o)
|
|
44
45
|
return !1;
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
46
|
+
const e = h({ store: r, entry: a }), u = h({ store: r, entry: o });
|
|
47
|
+
if (!e || !u)
|
|
47
48
|
return !1;
|
|
48
|
-
const
|
|
49
|
-
x(
|
|
49
|
+
const s = C(
|
|
50
|
+
x(e),
|
|
50
51
|
t.path,
|
|
51
52
|
t.method
|
|
52
53
|
);
|
|
53
|
-
if (!
|
|
54
|
+
if (!s)
|
|
54
55
|
return !1;
|
|
55
|
-
const
|
|
56
|
-
return
|
|
57
|
-
},
|
|
58
|
-
const o = r.workspace["x-scalar-order"] ?? Object.keys(r.workspace.documents), s =
|
|
59
|
-
return
|
|
60
|
-
},
|
|
56
|
+
const c = d("tag", t) ?? null, i = d("tag", n) ?? null;
|
|
57
|
+
return T(s, c, i), $(e, u, t, s), O({ store: r, entry: t }), O({ store: r, entry: n }), !0;
|
|
58
|
+
}, H = (r, t, n, a) => {
|
|
59
|
+
const o = r.workspace["x-scalar-order"] ?? [], e = Object.keys(r.workspace.documents), u = B(e, o, (f) => f), s = u.findIndex((f) => f === t.id), c = u.findIndex((f) => f === n.id), i = P(u, s, c, a);
|
|
60
|
+
return i ? (r.update("x-scalar-order", i), !0) : !1;
|
|
61
|
+
}, G = ({
|
|
61
62
|
store: r,
|
|
62
63
|
sidebarState: t
|
|
63
64
|
}) => ({
|
|
64
|
-
handleDragEnd: (o,
|
|
65
|
+
handleDragEnd: (o, e) => {
|
|
65
66
|
const u = b(r);
|
|
66
67
|
if (!u)
|
|
67
68
|
return !1;
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
69
|
+
const s = t.getEntryById(o.id), c = t.getEntryById(e.id);
|
|
70
|
+
if (!s || !c)
|
|
70
71
|
return !1;
|
|
71
|
-
if (
|
|
72
|
-
return
|
|
73
|
-
if (
|
|
74
|
-
return
|
|
72
|
+
if (s.type === "document")
|
|
73
|
+
return c.type !== "document" || !p(e) ? !1 : H(u, s, c, e.offset);
|
|
74
|
+
if (s.type === "tag")
|
|
75
|
+
return c.type !== "tag" || !p(e) || !l(s, c) ? !1 : w(
|
|
75
76
|
u,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
s,
|
|
78
|
+
c,
|
|
79
|
+
e.offset
|
|
79
80
|
);
|
|
80
|
-
if (
|
|
81
|
-
if (
|
|
81
|
+
if (s.type === "operation") {
|
|
82
|
+
if (p(e) && l(s, c))
|
|
82
83
|
return w(
|
|
83
84
|
u,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
s,
|
|
86
|
+
c,
|
|
87
|
+
e.offset
|
|
87
88
|
);
|
|
88
|
-
if (y(
|
|
89
|
-
return
|
|
89
|
+
if (y(c, ["tag", "document"]) && m(e))
|
|
90
|
+
return F(u, s, c);
|
|
90
91
|
}
|
|
91
92
|
return !1;
|
|
92
93
|
},
|
|
93
|
-
isDroppable: (o,
|
|
94
|
+
isDroppable: (o, e) => {
|
|
94
95
|
const u = b(r);
|
|
95
96
|
if (!u)
|
|
96
97
|
return !1;
|
|
97
|
-
const
|
|
98
|
-
if (!
|
|
98
|
+
const s = t.getEntryById(o.id), c = t.getEntryById(e.id);
|
|
99
|
+
if (!s || !c || s.type === "example")
|
|
99
100
|
return !1;
|
|
100
|
-
if (
|
|
101
|
-
return
|
|
102
|
-
if (
|
|
103
|
-
return
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
if (!
|
|
101
|
+
if (s.type === "document")
|
|
102
|
+
return c.type === "document" && p(e);
|
|
103
|
+
if (s.type === "tag")
|
|
104
|
+
return p(e) && l(s, c);
|
|
105
|
+
if (s.type === "operation") {
|
|
106
|
+
const i = d("document", c), f = d("document", s);
|
|
107
|
+
if (!i || !f)
|
|
107
108
|
return !1;
|
|
108
|
-
const
|
|
109
|
-
if (!
|
|
109
|
+
const E = h({ store: u, entry: i });
|
|
110
|
+
if (!E)
|
|
110
111
|
return !1;
|
|
111
|
-
const D = l(
|
|
112
|
-
return
|
|
112
|
+
const D = l(s, c);
|
|
113
|
+
return p(e) && !D ? !1 : D ? p(e) || m(e) && y(c, ["tag", "document"]) : m(e) && y(c, ["tag", "document"]) && (f.id === i.id || E.paths?.[s.path]?.[s.method] === void 0);
|
|
113
114
|
}
|
|
114
115
|
return !1;
|
|
115
116
|
}
|
|
116
117
|
});
|
|
117
118
|
export {
|
|
118
|
-
|
|
119
|
+
G as dragHandleFactory
|
|
119
120
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-sidebar-state.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/use-sidebar-state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-sidebar-state.d.ts","sourceRoot":"","sources":["../../../src/v2/hooks/use-sidebar-state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAwB,MAAM,iBAAiB,CAAA;AAC1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAEpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAA;AAChF,OAAO,EAAE,KAAK,gBAAgB,EAA4B,MAAM,KAAK,CAAA;AAGrE,MAAM,MAAM,qBAAqB,GAAG;IAClC,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC,KAAK,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAA;IAC5D,kBAAkB,EAAE,CAAC,QAAQ,EAAE;QAC7B,QAAQ,EAAE,MAAM,CAAA;QAChB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,MAAM,CAAC,EAAE,UAAU,CAAA;QACnB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,KAAK,cAAc,GAAG,SAAS,CAAA;CACjC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,GAAI,8DAM7B;IACD,cAAc,EAAE,gBAAgB,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACvD,aAAa,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IACnD,YAAY,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAClD,IAAI,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC1C,MAAM,EAAE,gBAAgB,CAAC,UAAU,GAAG,SAAS,CAAC,CAAA;IAChD,WAAW,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CAClD,KAAG,qBAoOH,CAAA"}
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { isDefined as h } from "@scalar/helpers/array/is-defined";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { sortByOrder as w } from "@scalar/helpers/array/sort-by-order";
|
|
3
|
+
import { createSidebarState as b, generateReverseIndex as k } from "@scalar/sidebar";
|
|
4
|
+
import { getParentEntry as o } from "@scalar/workspace-store/navigation";
|
|
4
5
|
import { computed as x, toValue as c, watch as f } from "vue";
|
|
5
|
-
import { useRouter as
|
|
6
|
-
const
|
|
6
|
+
import { useRouter as O } from "vue-router";
|
|
7
|
+
const W = ({
|
|
7
8
|
workspaceStore: d,
|
|
8
9
|
documentSlug: y,
|
|
9
10
|
path: E,
|
|
10
11
|
method: S,
|
|
11
12
|
exampleName: g
|
|
12
13
|
}) => {
|
|
13
|
-
const m =
|
|
14
|
+
const m = O(), u = x(() => {
|
|
14
15
|
const e = c(d);
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
if (!e)
|
|
17
|
+
return [];
|
|
18
|
+
const t = e.workspace["x-scalar-order"] ?? Object.keys(e.workspace.documents);
|
|
19
|
+
return w(Object.keys(e.workspace.documents), t, (r) => r).map((r) => e.workspace.documents[r]?.["x-scalar-navigation"]).filter(h);
|
|
20
|
+
}), n = b(u);
|
|
17
21
|
f(
|
|
18
22
|
() => c(d),
|
|
19
23
|
() => {
|
|
@@ -27,14 +31,14 @@ const U = ({
|
|
|
27
31
|
document: e,
|
|
28
32
|
path: t,
|
|
29
33
|
method: r,
|
|
30
|
-
example:
|
|
31
|
-
}) => JSON.stringify([e, t, r,
|
|
32
|
-
() =>
|
|
34
|
+
example: a
|
|
35
|
+
}) => JSON.stringify([e, t, r, a].filter(h)), i = x(
|
|
36
|
+
() => k({
|
|
33
37
|
items: u.value,
|
|
34
38
|
nestedKey: "children",
|
|
35
39
|
filter: (e) => e.type === "document" || e.type === "operation" || e.type === "example",
|
|
36
40
|
getId: (e) => {
|
|
37
|
-
const t =
|
|
41
|
+
const t = o("document", e), r = o("operation", e);
|
|
38
42
|
return p({
|
|
39
43
|
document: t?.name ?? "",
|
|
40
44
|
path: r?.path,
|
|
@@ -68,11 +72,11 @@ const U = ({
|
|
|
68
72
|
n.setExpanded(e, !n.isExpanded(e));
|
|
69
73
|
return;
|
|
70
74
|
}
|
|
71
|
-
const r = t.children?.find((
|
|
75
|
+
const r = t.children?.find((a) => a.type === "example");
|
|
72
76
|
return r ? (n.setSelected(r.id), n.setExpanded(r.id, !0)) : n.setSelected(e), m.push({
|
|
73
77
|
name: "example",
|
|
74
78
|
params: {
|
|
75
|
-
documentSlug:
|
|
79
|
+
documentSlug: o("document", t)?.name,
|
|
76
80
|
pathEncoded: encodeURIComponent(t.path),
|
|
77
81
|
method: t.method,
|
|
78
82
|
exampleName: r?.name ?? "default"
|
|
@@ -81,11 +85,11 @@ const U = ({
|
|
|
81
85
|
}
|
|
82
86
|
if (t.type === "example") {
|
|
83
87
|
n.setSelected(e), n.setExpanded(e, !0);
|
|
84
|
-
const r =
|
|
88
|
+
const r = o("operation", t);
|
|
85
89
|
return m.push({
|
|
86
90
|
name: "example",
|
|
87
91
|
params: {
|
|
88
|
-
documentSlug:
|
|
92
|
+
documentSlug: o("document", t)?.name,
|
|
89
93
|
pathEncoded: encodeURIComponent(r?.path ?? ""),
|
|
90
94
|
method: r?.method,
|
|
91
95
|
exampleName: t.name
|
|
@@ -96,14 +100,14 @@ const U = ({
|
|
|
96
100
|
return m.push({
|
|
97
101
|
name: "document.overview",
|
|
98
102
|
params: {
|
|
99
|
-
documentSlug:
|
|
103
|
+
documentSlug: o("document", t)?.name
|
|
100
104
|
}
|
|
101
105
|
});
|
|
102
106
|
n.setExpanded(e, !n.isExpanded(e));
|
|
103
107
|
};
|
|
104
108
|
return f(
|
|
105
109
|
[() => c(d), y, E, S, g],
|
|
106
|
-
([e, t, r,
|
|
110
|
+
([e, t, r, a, I]) => {
|
|
107
111
|
if (!t) {
|
|
108
112
|
n.setSelected(null);
|
|
109
113
|
return;
|
|
@@ -111,7 +115,7 @@ const U = ({
|
|
|
111
115
|
const s = l({
|
|
112
116
|
document: t,
|
|
113
117
|
path: r,
|
|
114
|
-
method:
|
|
118
|
+
method: a,
|
|
115
119
|
example: I
|
|
116
120
|
});
|
|
117
121
|
s && (n.setSelected(s.id), n.setExpanded(s.id, !0));
|
|
@@ -126,5 +130,5 @@ const U = ({
|
|
|
126
130
|
};
|
|
127
131
|
};
|
|
128
132
|
export {
|
|
129
|
-
|
|
133
|
+
W as useSidebarState
|
|
130
134
|
};
|
|
@@ -33,7 +33,7 @@ const W = { class: "flex-center relative flex flex-1 flex-col gap-6 p-2 capitali
|
|
|
33
33
|
}));
|
|
34
34
|
}, f = (o) => {
|
|
35
35
|
o?.createNew && g.name === "request" && d();
|
|
36
|
-
}, v = "2.
|
|
36
|
+
}, v = "2.14.0";
|
|
37
37
|
return q(() => a.hotKeys.on(f)), R(() => a.hotKeys.off(f)), (o, e) => (i(), l("div", W, [
|
|
38
38
|
s("div", {
|
|
39
39
|
class: y(["flex h-[calc(100%_-_50px)] flex-col items-center justify-center", {
|
|
@@ -27,10 +27,10 @@ proxyUrl?: string) => Promise<ErrorResponse<string>>;
|
|
|
27
27
|
* Makes the BE authorization call to grab the token server to server
|
|
28
28
|
* Used for clientCredentials and authorizationCode
|
|
29
29
|
*/
|
|
30
|
-
export declare const authorizeServers: (flow: NonImplicitFlow, scopes: string, { code, pkce, proxyUrl, }
|
|
30
|
+
export declare const authorizeServers: (flow: NonImplicitFlow, scopes: string, { code, pkce, proxyUrl, }: {
|
|
31
31
|
code?: string;
|
|
32
32
|
pkce?: PKCEState | null;
|
|
33
33
|
proxyUrl?: string | undefined;
|
|
34
|
-
}) => Promise<ErrorResponse<string>>;
|
|
34
|
+
} | undefined, activeServer: Server | undefined) => Promise<ErrorResponse<string>>;
|
|
35
35
|
export {};
|
|
36
36
|
//# sourceMappingURL=oauth2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth2.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/libs/oauth2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"oauth2.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/libs/oauth2.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AAIzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,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;AAgBD;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAU,UAAU,MAAM,EAAE,UAAU,SAAS,GAAG,OAAO,KAAG,OAAO,CAAC,MAAM,CAkB3G,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,MAAM,UAAU;AAChB,wEAAwE;AACxE,cAAc,MAAM;AACpB,kCAAkC;AAClC,WAAW,MAAM,KAChB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CA4K/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,MAAM,eAAe,EACrB,QAAQ,MAAM,EACd,2BAIG;IACD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,YAAK,EACN,cAAc,MAAM,GAAG,SAAS,KAC/B,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CA2F/B,CAAA"}
|
|
@@ -1,100 +1,113 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { makeUrlAbsolute as x } from "@scalar/helpers/url/make-url-absolute";
|
|
2
|
+
import { shouldUseProxy as U } from "@scalar/oas-utils/helpers";
|
|
3
|
+
import { fromUint8Array as S, encode as w } from "js-base64";
|
|
4
|
+
const A = () => {
|
|
4
5
|
const e = new Uint8Array(32);
|
|
5
|
-
return crypto.getRandomValues(e),
|
|
6
|
-
},
|
|
7
|
-
if (
|
|
6
|
+
return crypto.getRandomValues(e), S(e, !0);
|
|
7
|
+
}, b = async (e, c) => {
|
|
8
|
+
if (c === "plain")
|
|
8
9
|
return e;
|
|
9
10
|
if (typeof crypto?.subtle?.digest != "function")
|
|
10
11
|
return console.warn("SHA-256 is only supported when using https, using a plain text code challenge instead."), e;
|
|
11
|
-
const n = new TextEncoder().encode(e),
|
|
12
|
-
return
|
|
13
|
-
},
|
|
12
|
+
const n = new TextEncoder().encode(e), o = await crypto.subtle.digest("SHA-256", n);
|
|
13
|
+
return S(new Uint8Array(o), !0);
|
|
14
|
+
}, T = async (e, c, u) => {
|
|
14
15
|
try {
|
|
15
16
|
if (!e)
|
|
16
17
|
return [new Error("Flow not found"), null];
|
|
17
18
|
const n = e.selectedScopes.join(" ");
|
|
18
19
|
if (e.type === "clientCredentials" || e.type === "password")
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
return k(
|
|
21
|
+
e,
|
|
22
|
+
n,
|
|
23
|
+
{
|
|
24
|
+
proxyUrl: u
|
|
25
|
+
},
|
|
26
|
+
c
|
|
27
|
+
);
|
|
28
|
+
const o = (Math.random() + 1).toString(36).substring(2, 10), _ = x(e.authorizationUrl, {
|
|
29
|
+
baseUrl: c?.url
|
|
30
|
+
}), t = new URL(_);
|
|
31
|
+
let y = null;
|
|
24
32
|
if (e.type === "implicit")
|
|
25
33
|
t.searchParams.set("response_type", "token");
|
|
26
34
|
else if (e.type === "authorizationCode" && (t.searchParams.set("response_type", "code"), e["x-usePkce"] !== "no")) {
|
|
27
|
-
const r =
|
|
28
|
-
|
|
35
|
+
const r = A(), a = await b(r, e["x-usePkce"]);
|
|
36
|
+
y = {
|
|
29
37
|
codeVerifier: r,
|
|
30
|
-
codeChallenge:
|
|
38
|
+
codeChallenge: a,
|
|
31
39
|
codeChallengeMethod: e["x-usePkce"] === "SHA-256" ? "S256" : "plain"
|
|
32
|
-
}, t.searchParams.set("code_challenge",
|
|
40
|
+
}, t.searchParams.set("code_challenge", a), t.searchParams.set("code_challenge_method", y.codeChallengeMethod);
|
|
33
41
|
}
|
|
34
42
|
if (e["x-scalar-redirect-uri"].startsWith("/")) {
|
|
35
|
-
const r =
|
|
36
|
-
t.searchParams.set("redirect_uri",
|
|
43
|
+
const r = c?.url || window.location.origin + window.location.pathname, a = x(e["x-scalar-redirect-uri"], { baseUrl: r });
|
|
44
|
+
t.searchParams.set("redirect_uri", a);
|
|
37
45
|
} else
|
|
38
46
|
t.searchParams.set("redirect_uri", e["x-scalar-redirect-uri"]);
|
|
39
47
|
e["x-scalar-security-query"] && Object.keys(e["x-scalar-security-query"]).forEach((r) => {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
}), t.searchParams.set("client_id", e["x-scalar-client-id"]), t.searchParams.set("state",
|
|
43
|
-
const
|
|
44
|
-
return
|
|
45
|
-
const
|
|
46
|
-
let
|
|
48
|
+
const a = e["x-scalar-security-query"]?.[r];
|
|
49
|
+
a && t.searchParams.set(r, a);
|
|
50
|
+
}), t.searchParams.set("client_id", e["x-scalar-client-id"]), t.searchParams.set("state", o), n && t.searchParams.set("scope", n);
|
|
51
|
+
const s = window.open(t, "openAuth2Window", "left=100,top=100,width=800,height=600");
|
|
52
|
+
return s ? new Promise((r) => {
|
|
53
|
+
const a = setInterval(() => {
|
|
54
|
+
let h = null, l = null, d = null, m = null;
|
|
47
55
|
try {
|
|
48
|
-
const i = new URL(
|
|
49
|
-
|
|
50
|
-
const g = new URLSearchParams(
|
|
51
|
-
|
|
56
|
+
const i = new URL(s.location.href).searchParams, P = e["x-tokenName"] || "access_token";
|
|
57
|
+
h = i.get(P), l = i.get("code"), d = i.get("error"), m = i.get("error_description");
|
|
58
|
+
const g = new URLSearchParams(s.location.href.split("#")[1]);
|
|
59
|
+
h ||= g.get(P), l ||= g.get("code"), d ||= g.get("error"), m ||= g.get("error_description");
|
|
52
60
|
} catch {
|
|
53
61
|
}
|
|
54
|
-
if (
|
|
55
|
-
if (clearInterval(
|
|
56
|
-
r([new Error(`OAuth error: ${
|
|
57
|
-
else if (
|
|
58
|
-
const i =
|
|
59
|
-
r(i ===
|
|
60
|
-
} else
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
if (s.closed || h || l || d)
|
|
63
|
+
if (clearInterval(a), s.close(), d)
|
|
64
|
+
r([new Error(`OAuth error: ${d}${m ? ` (${m})` : ""}`), null]);
|
|
65
|
+
else if (h) {
|
|
66
|
+
const i = s.location.href.match(/state=([^&]*)/)?.[1];
|
|
67
|
+
r(i === o ? [null, h] : [new Error("State mismatch"), null]);
|
|
68
|
+
} else l ? new URL(s.location.href).searchParams.get("state") === o ? k(
|
|
69
|
+
e,
|
|
70
|
+
n,
|
|
71
|
+
{
|
|
72
|
+
code: l,
|
|
73
|
+
pkce: y,
|
|
74
|
+
proxyUrl: u
|
|
75
|
+
},
|
|
76
|
+
c
|
|
77
|
+
).then(r) : r([new Error("State mismatch"), null]) : (clearInterval(a), r([new Error("Window was closed without granting authorization"), null]));
|
|
65
78
|
}, 200);
|
|
66
79
|
}) : [new Error("Failed to open auth window"), null];
|
|
67
80
|
} catch {
|
|
68
81
|
return [new Error("Failed to authorize oauth2 flow"), null];
|
|
69
82
|
}
|
|
70
|
-
},
|
|
83
|
+
}, k = async (e, c, {
|
|
71
84
|
code: u,
|
|
72
85
|
pkce: n,
|
|
73
|
-
proxyUrl:
|
|
74
|
-
} = {}) => {
|
|
86
|
+
proxyUrl: o
|
|
87
|
+
} = {}, _) => {
|
|
75
88
|
if (!e)
|
|
76
89
|
return [new Error("OAuth2 flow was not defined"), null];
|
|
77
90
|
const t = new URLSearchParams();
|
|
78
|
-
t.set("client_id", e["x-scalar-client-id"]),
|
|
79
|
-
|
|
91
|
+
t.set("client_id", e["x-scalar-client-id"]), c && (e.type === "clientCredentials" || e.type === "password") && t.set("scope", c), e.clientSecret && (!e["x-scalar-credentials-location"] || e["x-scalar-credentials-location"] === "body") && 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"]), u ? (t.set("code", u), 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"), e["x-scalar-security-body"] && Object.entries(e["x-scalar-security-body"]).forEach(([p, s]) => {
|
|
92
|
+
s && t.set(p, s);
|
|
80
93
|
});
|
|
81
94
|
try {
|
|
82
95
|
const p = {
|
|
83
96
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
84
97
|
};
|
|
85
|
-
e.clientSecret && (!e["x-scalar-credentials-location"] || e["x-scalar-credentials-location"] === "header") && (p.Authorization = `Basic ${
|
|
86
|
-
const r =
|
|
98
|
+
e.clientSecret && (!e["x-scalar-credentials-location"] || e["x-scalar-credentials-location"] === "header") && (p.Authorization = `Basic ${w(`${e["x-scalar-client-id"]}:${e.clientSecret}`)}`);
|
|
99
|
+
const r = x(e.tokenUrl, { baseUrl: _?.url }), a = U(o, r) ? `${o}?${new URLSearchParams([["scalar_url", r]]).toString()}` : r, l = await (await fetch(a, {
|
|
87
100
|
method: "POST",
|
|
88
101
|
headers: p,
|
|
89
102
|
body: t
|
|
90
103
|
})).json(), d = e["x-tokenName"] || "access_token";
|
|
91
|
-
return [null,
|
|
104
|
+
return [null, l[d]];
|
|
92
105
|
} catch {
|
|
93
106
|
return [new Error("Failed to get an access token. Please check your credentials."), null];
|
|
94
107
|
}
|
|
95
108
|
};
|
|
96
109
|
export {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
110
|
+
T as authorizeOauth2,
|
|
111
|
+
k as authorizeServers,
|
|
112
|
+
b as generateCodeChallenge
|
|
100
113
|
};
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"rest",
|
|
19
19
|
"testing"
|
|
20
20
|
],
|
|
21
|
-
"version": "2.
|
|
21
|
+
"version": "2.14.0",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=20"
|
|
24
24
|
},
|
|
@@ -321,26 +321,26 @@
|
|
|
321
321
|
"whatwg-mimetype": "^4.0.0",
|
|
322
322
|
"yaml": "2.8.0",
|
|
323
323
|
"zod": "4.1.11",
|
|
324
|
-
"@scalar/components": "0.16.5",
|
|
325
|
-
"@scalar/draggable": "0.3.0",
|
|
326
324
|
"@scalar/analytics-client": "1.0.0",
|
|
327
|
-
"@scalar/
|
|
325
|
+
"@scalar/draggable": "0.3.0",
|
|
326
|
+
"@scalar/helpers": "0.2.0",
|
|
327
|
+
"@scalar/components": "0.16.6",
|
|
328
328
|
"@scalar/icons": "0.5.0",
|
|
329
|
-
"@scalar/import": "0.4.
|
|
330
|
-
"@scalar/
|
|
331
|
-
"@scalar/object-utils": "1.2.
|
|
332
|
-
"@scalar/json-magic": "0.8.3",
|
|
333
|
-
"@scalar/openapi-parser": "0.23.4",
|
|
329
|
+
"@scalar/import": "0.4.37",
|
|
330
|
+
"@scalar/json-magic": "0.8.4",
|
|
331
|
+
"@scalar/object-utils": "1.2.14",
|
|
334
332
|
"@scalar/openapi-types": "0.5.2",
|
|
335
|
-
"@scalar/
|
|
336
|
-
"@scalar/
|
|
333
|
+
"@scalar/oas-utils": "0.6.6",
|
|
334
|
+
"@scalar/openapi-parser": "0.23.5",
|
|
335
|
+
"@scalar/postman-to-openapi": "0.3.47",
|
|
336
|
+
"@scalar/sidebar": "0.5.1",
|
|
337
337
|
"@scalar/snippetz": "0.5.4",
|
|
338
338
|
"@scalar/types": "0.5.1",
|
|
339
339
|
"@scalar/themes": "0.13.25",
|
|
340
|
-
"@scalar/use-
|
|
341
|
-
"@scalar/use-hooks": "0.3.1",
|
|
340
|
+
"@scalar/use-hooks": "0.3.2",
|
|
342
341
|
"@scalar/use-toasts": "0.9.1",
|
|
343
|
-
"@scalar/workspace-store": "0.22.
|
|
342
|
+
"@scalar/workspace-store": "0.22.1",
|
|
343
|
+
"@scalar/use-codemirror": "0.13.0"
|
|
344
344
|
},
|
|
345
345
|
"devDependencies": {
|
|
346
346
|
"@tailwindcss/vite": "^4.1.7",
|
|
@@ -355,8 +355,8 @@
|
|
|
355
355
|
"vite": "7.1.11",
|
|
356
356
|
"vite-svg-loader": "5.1.0",
|
|
357
357
|
"vitest": "3.2.4",
|
|
358
|
-
"@scalar/
|
|
359
|
-
"@scalar/
|
|
358
|
+
"@scalar/galaxy": "0.5.12",
|
|
359
|
+
"@scalar/build-tooling": "0.3.1"
|
|
360
360
|
},
|
|
361
361
|
"scripts": {
|
|
362
362
|
"build": "scalar-build-vite",
|