@scalar/api-client 2.1.39 → 2.1.41
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 +27 -0
- package/dist/components/CodeInput/CodeInput.vue.d.ts +3 -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 +105 -84
- package/dist/components/CodeInput/codeVariableWidget.d.ts +3 -0
- package/dist/components/CodeInput/codeVariableWidget.d.ts.map +1 -1
- package/dist/components/CodeInput/codeVariableWidget.js +51 -47
- package/dist/components/ImportCollection/ImportCollectionModal.vue.d.ts.map +1 -1
- package/dist/components/ImportCollection/ImportCollectionModal.vue.js +102 -129
- package/dist/components/ImportCollection/PrefetchError.vue.d.ts +2 -3
- package/dist/components/ImportCollection/PrefetchError.vue.d.ts.map +1 -1
- package/dist/components/ImportCollection/PrefetchError.vue.js +27 -0
- package/dist/components/ImportCollection/PrefetchError.vue2.js +4 -0
- package/dist/components/ImportCollection/hooks/useUrlPrefetcher.d.ts +11 -17
- package/dist/components/ImportCollection/hooks/useUrlPrefetcher.d.ts.map +1 -1
- package/dist/components/ImportCollection/hooks/useUrlPrefetcher.js +72 -29
- package/dist/components/Sidebar/Actions/SidebarListElementForm.vue.d.ts.map +1 -1
- package/dist/components/Sidebar/Actions/SidebarListElementForm.vue.js +1 -1
- package/dist/components/Sidebar/Actions/SidebarListElementForm.vue2.js +20 -28
- package/dist/components/Sidebar/SidebarButton.vue.d.ts +5 -3
- package/dist/components/Sidebar/SidebarButton.vue.d.ts.map +1 -1
- package/dist/components/Sidebar/SidebarButton.vue.js +16 -16
- package/dist/components/Sidebar/SidebarList.vue.d.ts.map +1 -1
- package/dist/components/Sidebar/SidebarList.vue.js +5 -5
- package/dist/components/Sidebar/SidebarListElement.vue.d.ts +1 -1
- package/dist/components/Sidebar/SidebarListElement.vue.d.ts.map +1 -1
- package/dist/layouts/App/ApiClientApp.vue.d.ts.map +1 -1
- package/dist/layouts/App/ApiClientApp.vue.js +37 -37
- package/dist/layouts/Modal/ApiClientModal.vue.d.ts.map +1 -1
- package/dist/layouts/Modal/ApiClientModal.vue.js +1 -1
- package/dist/layouts/Modal/ApiClientModal.vue2.js +23 -21
- package/dist/layouts/Web/ApiClientWeb.vue.d.ts.map +1 -1
- package/dist/layouts/Web/ApiClientWeb.vue.js +30 -30
- package/dist/store/environment.js +1 -1
- package/dist/style.css +1 -1
- package/dist/views/Cookies/Cookies.vue.d.ts +1 -5
- package/dist/views/Cookies/Cookies.vue.d.ts.map +1 -1
- package/dist/views/Cookies/Cookies.vue2.js +58 -61
- package/dist/views/Environment/Environment.vue.d.ts +1 -5
- package/dist/views/Environment/Environment.vue.d.ts.map +1 -1
- package/dist/views/Environment/Environment.vue2.js +142 -96
- package/dist/views/Environment/EnvironmentVariableDropdown.vue.d.ts.map +1 -1
- package/dist/views/Environment/EnvironmentVariableDropdown.vue.js +17 -18
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js +36 -34
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue.d.ts.map +1 -1
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue.js +3 -3
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +25 -25
- 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 +45 -36
- package/package.json +7 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuth2.vue.d.ts","sourceRoot":"","sources":["../../../../../src/views/Request/RequestSection/RequestAuth/OAuth2.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OAuth2.vue.d.ts","sourceRoot":"","sources":["../../../../../src/views/Request/RequestSection/RequestAuth/OAuth2.vue"],"names":[],"mappings":"AAqNA,OAAO,KAAK,EACV,oBAAoB,EACpB,gCAAgC,EACjC,MAAM,iCAAiC,CAAA;;aAO7B,gCAAgC;YACjC,oBAAoB;;aADnB,gCAAgC;YACjC,oBAAoB;;AAshB9B,wBAMG"}
|
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as T, openBlock as s, createElementBlock as w, Fragment as y, createVNode as t, unref as d, withCtx as o, createTextVNode as u, createElementVNode as U, createBlock as f, createCommentVNode as n } from "vue";
|
|
2
2
|
import i from "../RequestAuthDataTableInput.vue.js";
|
|
3
|
-
import { useLoadingState as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { authorizeOauth2 as
|
|
7
|
-
import { useWorkspace as
|
|
8
|
-
const
|
|
3
|
+
import { useLoadingState as x, ScalarButton as c } from "@scalar/components";
|
|
4
|
+
import F from "./OAuthScopesInput.vue.js";
|
|
5
|
+
import r from "../../../../components/DataTable/DataTableRow.vue.js";
|
|
6
|
+
import { authorizeOauth2 as A } from "../../libs/oauth2.js";
|
|
7
|
+
import { useWorkspace as B } from "../../../../store/store.js";
|
|
8
|
+
const I = { class: "h-8 flex items-center justify-self-end" }, R = { class: "h-8 flex items-center justify-self-end" }, P = /* @__PURE__ */ T({
|
|
9
9
|
__name: "OAuth2",
|
|
10
10
|
props: {
|
|
11
11
|
example: {},
|
|
12
12
|
scheme: {}
|
|
13
13
|
},
|
|
14
14
|
setup($) {
|
|
15
|
-
const m = $, h =
|
|
15
|
+
const m = $, h = x(), {
|
|
16
16
|
activeCollection: V,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
activeServer: g,
|
|
18
|
+
collectionMutators: v,
|
|
19
|
+
isReadOnly: S,
|
|
20
|
+
securitySchemeMutators: z
|
|
21
|
+
} = B(), p = (l, e) => V.value && v.edit(V.value.uid, l, e), k = (l, e) => z.edit(m.scheme.uid, l, e), C = async () => {
|
|
21
22
|
var e;
|
|
22
23
|
if (h.isLoading || !((e = V.value) != null && e.uid)) return;
|
|
23
24
|
h.startLoading();
|
|
24
|
-
const l = await
|
|
25
|
+
const l = await A(
|
|
25
26
|
m.scheme,
|
|
26
|
-
m.example
|
|
27
|
+
m.example,
|
|
28
|
+
g.value
|
|
27
29
|
).finally(() => h.stopLoading());
|
|
28
30
|
l && p(`auth.${m.scheme.uid}.token`, l);
|
|
29
31
|
};
|
|
30
|
-
return (l, e) => l.example.token ? (
|
|
31
|
-
t(d(
|
|
32
|
+
return (l, e) => l.example.token ? (s(), w(y, { key: 0 }, [
|
|
33
|
+
t(d(r), null, {
|
|
32
34
|
default: o(() => [
|
|
33
35
|
t(i, {
|
|
34
36
|
id: "oauth2-access-token",
|
|
@@ -46,9 +48,9 @@ const B = { class: "h-8 flex items-center justify-self-end" }, I = { class: "h-8
|
|
|
46
48
|
]),
|
|
47
49
|
_: 1
|
|
48
50
|
}),
|
|
49
|
-
t(d(
|
|
51
|
+
t(d(r), { class: "min-w-full" }, {
|
|
50
52
|
default: o(() => [
|
|
51
|
-
U("div",
|
|
53
|
+
U("div", I, [
|
|
52
54
|
t(d(c), {
|
|
53
55
|
class: "p-0 py-0.5 px-2 mr-1",
|
|
54
56
|
loading: d(h),
|
|
@@ -65,10 +67,10 @@ const B = { class: "h-8 flex items-center justify-self-end" }, I = { class: "h-8
|
|
|
65
67
|
]),
|
|
66
68
|
_: 1
|
|
67
69
|
})
|
|
68
|
-
], 64)) : (
|
|
69
|
-
d(
|
|
70
|
+
], 64)) : (s(), w(y, { key: 1 }, [
|
|
71
|
+
d(S) ? n("", !0) : (s(), f(d(r), { key: 0 }, {
|
|
70
72
|
default: o(() => [
|
|
71
|
-
"authorizationUrl" in l.scheme.flow ? (
|
|
73
|
+
"authorizationUrl" in l.scheme.flow ? (s(), f(i, {
|
|
72
74
|
key: 0,
|
|
73
75
|
id: `oauth2-authorization-url-${l.scheme.uid}`,
|
|
74
76
|
modelValue: l.scheme.flow.authorizationUrl,
|
|
@@ -80,7 +82,7 @@ const B = { class: "h-8 flex items-center justify-self-end" }, I = { class: "h-8
|
|
|
80
82
|
])),
|
|
81
83
|
_: 1
|
|
82
84
|
}, 8, ["id", "modelValue"])) : n("", !0),
|
|
83
|
-
"tokenUrl" in l.scheme.flow ? (
|
|
85
|
+
"tokenUrl" in l.scheme.flow ? (s(), f(i, {
|
|
84
86
|
key: 1,
|
|
85
87
|
id: `oauth2-token-url-${l.scheme.uid}`,
|
|
86
88
|
modelValue: l.scheme.flow.tokenUrl,
|
|
@@ -95,7 +97,7 @@ const B = { class: "h-8 flex items-center justify-self-end" }, I = { class: "h-8
|
|
|
95
97
|
]),
|
|
96
98
|
_: 1
|
|
97
99
|
})),
|
|
98
|
-
"x-scalar-redirect-uri" in l.scheme.flow ? (
|
|
100
|
+
"x-scalar-redirect-uri" in l.scheme.flow ? (s(), f(d(r), { key: 1 }, {
|
|
99
101
|
default: o(() => [
|
|
100
102
|
t(i, {
|
|
101
103
|
id: `oauth2-redirect-uri-${l.scheme.uid}`,
|
|
@@ -111,8 +113,8 @@ const B = { class: "h-8 flex items-center justify-self-end" }, I = { class: "h-8
|
|
|
111
113
|
]),
|
|
112
114
|
_: 1
|
|
113
115
|
})) : n("", !0),
|
|
114
|
-
l.example.type === "oauth-password" ? (
|
|
115
|
-
t(d(
|
|
116
|
+
l.example.type === "oauth-password" ? (s(), w(y, { key: 2 }, [
|
|
117
|
+
t(d(r), null, {
|
|
116
118
|
default: o(() => [
|
|
117
119
|
t(i, {
|
|
118
120
|
id: `oauth2-password-username-${l.scheme.uid}`,
|
|
@@ -129,7 +131,7 @@ const B = { class: "h-8 flex items-center justify-self-end" }, I = { class: "h-8
|
|
|
129
131
|
]),
|
|
130
132
|
_: 1
|
|
131
133
|
}),
|
|
132
|
-
t(d(
|
|
134
|
+
t(d(r), null, {
|
|
133
135
|
default: o(() => [
|
|
134
136
|
t(i, {
|
|
135
137
|
id: `oauth2-password-password-${l.scheme.uid}`,
|
|
@@ -147,7 +149,7 @@ const B = { class: "h-8 flex items-center justify-self-end" }, I = { class: "h-8
|
|
|
147
149
|
_: 1
|
|
148
150
|
})
|
|
149
151
|
], 64)) : n("", !0),
|
|
150
|
-
t(d(
|
|
152
|
+
t(d(r), null, {
|
|
151
153
|
default: o(() => [
|
|
152
154
|
t(i, {
|
|
153
155
|
id: `oauth2-client-id-${l.scheme.uid}`,
|
|
@@ -163,7 +165,7 @@ const B = { class: "h-8 flex items-center justify-self-end" }, I = { class: "h-8
|
|
|
163
165
|
]),
|
|
164
166
|
_: 1
|
|
165
167
|
}),
|
|
166
|
-
"clientSecret" in l.example ? (
|
|
168
|
+
"clientSecret" in l.example ? (s(), f(d(r), { key: 3 }, {
|
|
167
169
|
default: o(() => [
|
|
168
170
|
t(i, {
|
|
169
171
|
id: `oauth2-client-secret-${l.scheme.uid}`,
|
|
@@ -180,24 +182,24 @@ const B = { class: "h-8 flex items-center justify-self-end" }, I = { class: "h-8
|
|
|
180
182
|
]),
|
|
181
183
|
_: 1
|
|
182
184
|
})) : n("", !0),
|
|
183
|
-
l.scheme.flow.scopes ? (
|
|
185
|
+
l.scheme.flow.scopes ? (s(), f(d(r), { key: 4 }, {
|
|
184
186
|
default: o(() => [
|
|
185
|
-
t(
|
|
187
|
+
t(F, {
|
|
186
188
|
activeFlow: l.scheme.flow,
|
|
187
189
|
updateScheme: k
|
|
188
190
|
}, null, 8, ["activeFlow"])
|
|
189
191
|
]),
|
|
190
192
|
_: 1
|
|
191
193
|
})) : n("", !0),
|
|
192
|
-
t(d(
|
|
194
|
+
t(d(r), { class: "min-w-full" }, {
|
|
193
195
|
default: o(() => [
|
|
194
|
-
U("div",
|
|
196
|
+
U("div", R, [
|
|
195
197
|
t(d(c), {
|
|
196
198
|
class: "p-0 py-0.5 px-2 mr-1",
|
|
197
199
|
loading: d(h),
|
|
198
200
|
size: "sm",
|
|
199
201
|
variant: "outlined",
|
|
200
|
-
onClick:
|
|
202
|
+
onClick: C
|
|
201
203
|
}, {
|
|
202
204
|
default: o(() => e[18] || (e[18] = [
|
|
203
205
|
u(" Authorize ")
|
|
@@ -212,5 +214,5 @@ const B = { class: "h-8 flex items-center justify-self-end" }, I = { class: "h-8
|
|
|
212
214
|
}
|
|
213
215
|
});
|
|
214
216
|
export {
|
|
215
|
-
|
|
217
|
+
P as default
|
|
216
218
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseEmpty.vue.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/ResponseSection/ResponseEmpty.vue"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ResponseEmpty.vue.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/ResponseSection/ResponseEmpty.vue"],"names":[],"mappings":";AA0OA,wBAKG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./ResponseEmpty.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import
|
|
4
|
-
const
|
|
3
|
+
import e from "../../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const r = /* @__PURE__ */ e(o, [["__scopeId", "data-v-8ee083e8"]]);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
r as default
|
|
7
7
|
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { defineComponent as R, inject as g, onMounted as _, onBeforeUnmount as b, openBlock as r, createElementBlock as l, createElementVNode as t, unref as o, createTextVNode as a, toDisplayString as N, createCommentVNode as u, createVNode as i } from "vue";
|
|
2
|
+
import C from "../../../assets/computer.ascii.js";
|
|
3
|
+
import q from "../../../components/ScalarAsciiArt.vue.js";
|
|
4
4
|
import p from "../../../components/ScalarHotkey.vue.js";
|
|
5
|
-
import { useRoute as
|
|
6
|
-
import { useWorkspace as
|
|
7
|
-
const
|
|
5
|
+
import { useRoute as v } from "vue-router";
|
|
6
|
+
import { useWorkspace as V } from "../../../store/store.js";
|
|
7
|
+
const B = { class: "relative col-1 flex-center gap-6 p-2 capitalize" }, S = { class: "flex h-[calc(100%_-_50px)] flex-col items-center justify-center" }, h = {
|
|
8
8
|
key: 0,
|
|
9
9
|
class: "scalar-version-number"
|
|
10
|
-
},
|
|
10
|
+
}, w = { class: "text-c-3 right-4 mt-auto flex w-full flex-col items-end gap-2 text-sm" }, z = /* @__PURE__ */ R({
|
|
11
11
|
__name: "ResponseEmpty",
|
|
12
|
-
setup(
|
|
13
|
-
const { isReadOnly: d, activeWorkspace: f, events: s } =
|
|
12
|
+
setup(E) {
|
|
13
|
+
const { isReadOnly: d, activeWorkspace: f, events: s } = V(), y = v(), x = g("layout"), m = () => {
|
|
14
14
|
s.commandPalette.emit({ commandName: "Create Request" });
|
|
15
15
|
}, c = (n) => {
|
|
16
|
-
n != null && n.createNew &&
|
|
17
|
-
},
|
|
18
|
-
return
|
|
19
|
-
t("div",
|
|
20
|
-
o(f).isReadOnly ? u("", !0) : (
|
|
21
|
-
|
|
16
|
+
n != null && n.createNew && y.name === "request" && m();
|
|
17
|
+
}, k = "2.1.41";
|
|
18
|
+
return _(() => s.hotKeys.on(c)), b(() => s.hotKeys.off(c)), (n, e) => (r(), l("div", B, [
|
|
19
|
+
t("div", S, [
|
|
20
|
+
o(f).isReadOnly ? u("", !0) : (r(), l("div", h, [
|
|
21
|
+
a(" Scalar V" + N(o(k)) + " ", 1),
|
|
22
22
|
e[1] || (e[1] = t("b", null, "Beta", -1)),
|
|
23
|
-
e[2] || (e[2] =
|
|
23
|
+
e[2] || (e[2] = a(" Release ")),
|
|
24
24
|
e[3] || (e[3] = t("div", { class: "mt-1" }, [
|
|
25
25
|
t("a", {
|
|
26
26
|
href: "https://github.com/scalar/scalar/issues/2669",
|
|
@@ -28,33 +28,33 @@ const v = { class: "relative col-1 flex-center gap-6 p-2 capitalize" }, V = { cl
|
|
|
28
28
|
}, " Roadmap ")
|
|
29
29
|
], -1))
|
|
30
30
|
])),
|
|
31
|
-
i(
|
|
32
|
-
art: o(
|
|
31
|
+
i(q, {
|
|
32
|
+
art: o(C),
|
|
33
33
|
class: "text-c-3"
|
|
34
34
|
}, null, 8, ["art"])
|
|
35
35
|
]),
|
|
36
|
-
t("div",
|
|
36
|
+
t("div", w, [
|
|
37
37
|
t("button", {
|
|
38
38
|
class: "flex items-center gap-1.5",
|
|
39
39
|
type: "button",
|
|
40
|
-
onClick: e[0] || (e[0] = (
|
|
40
|
+
onClick: e[0] || (e[0] = (K) => o(s).executeRequest.emit())
|
|
41
41
|
}, [
|
|
42
|
-
e[4] || (e[4] =
|
|
42
|
+
e[4] || (e[4] = a(" Send Request ")),
|
|
43
43
|
i(p, { hotkey: "↵" })
|
|
44
44
|
]),
|
|
45
|
-
o(d)
|
|
45
|
+
!o(d) && o(x) === "desktop" ? (r(), l("button", {
|
|
46
46
|
key: 0,
|
|
47
47
|
class: "flex items-center gap-1.5",
|
|
48
48
|
type: "button",
|
|
49
49
|
onClick: m
|
|
50
50
|
}, [
|
|
51
|
-
e[5] || (e[5] =
|
|
51
|
+
e[5] || (e[5] = a(" New Request ")),
|
|
52
52
|
i(p, { hotkey: "N" })
|
|
53
|
-
]))
|
|
53
|
+
])) : u("", !0)
|
|
54
54
|
])
|
|
55
55
|
]));
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
58
|
export {
|
|
59
|
-
|
|
59
|
+
z as default
|
|
60
60
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SecuritySchemeExampleValue, SecuritySchemeOauth2, SecuritySchemeOauth2ExampleValue } from '@scalar/oas-utils/entities/spec';
|
|
1
|
+
import type { SecuritySchemeExampleValue, SecuritySchemeOauth2, SecuritySchemeOauth2ExampleValue, Server } from '@scalar/oas-utils/entities/spec';
|
|
2
2
|
/** Oauth2 security schemes which are not implicit */
|
|
3
3
|
type SecuritySchemeOauth2NonImplicit = Omit<SecuritySchemeOauth2, 'flow'> & {
|
|
4
4
|
flow: Exclude<SecuritySchemeOauth2['flow'], {
|
|
@@ -12,7 +12,7 @@ export declare const isOauth2Example: (example: SecuritySchemeExampleValue) => e
|
|
|
12
12
|
*
|
|
13
13
|
* @returns the accessToken
|
|
14
14
|
*/
|
|
15
|
-
export declare const authorizeOauth2: (scheme: SecuritySchemeOauth2, example: SecuritySchemeOauth2ExampleValue) => Promise<string>;
|
|
15
|
+
export declare const authorizeOauth2: (scheme: SecuritySchemeOauth2, example: SecuritySchemeOauth2ExampleValue, activeServer: Server) => Promise<string>;
|
|
16
16
|
/**
|
|
17
17
|
* Makes the BE authorization call to grab the token server to server
|
|
18
18
|
* Used for clientCredentials and authorizationCode
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth2.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/libs/oauth2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,gCAAgC,
|
|
1
|
+
{"version":3,"file":"oauth2.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/libs/oauth2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,gCAAgC,EAChC,MAAM,EACP,MAAM,iCAAiC,CAAA;AAExC,qDAAqD;AACrD,KAAK,+BAA+B,GAAG,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,GAAG;IAC1E,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,CAAA;CAClE,CAAA;AAED,6CAA6C;AAC7C,eAAO,MAAM,eAAe,YACjB,0BAA0B,KAClC,OAAO,IAAI,gCACoB,CAAA;AAElC;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAClB,oBAAoB,WACnB,gCAAgC,gBAE3B,MAAM,oBA4HlB,CAAA;AAEJ;;;GAGG;AACH,eAAO,MAAM,gBAAgB,WACnB,+BAA+B,WAC9B,gCAAgC,UACjC,MAAM,SACP,MAAM,KACZ,OAAO,CAAC,MAAM,CAqDhB,CAAA"}
|
|
@@ -1,62 +1,71 @@
|
|
|
1
|
-
const y = (t) => t.type.startsWith("oauth"),
|
|
2
|
-
const
|
|
1
|
+
const y = (t) => t.type.startsWith("oauth"), P = (t, r, f) => new Promise((i, e) => {
|
|
2
|
+
const n = t.flow.selectedScopes.join(" ");
|
|
3
3
|
if (t.flow.type === "clientCredentials" || t.flow.type === "password")
|
|
4
4
|
p(
|
|
5
5
|
t,
|
|
6
6
|
r,
|
|
7
|
-
|
|
8
|
-
).then(i).catch(
|
|
7
|
+
n
|
|
8
|
+
).then(i).catch(e);
|
|
9
9
|
else {
|
|
10
|
-
const c = (Math.random() + 1).toString(36).substring(7),
|
|
11
|
-
t.flow.type === "implicit" ?
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const c = (Math.random() + 1).toString(36).substring(7), a = new URL(t.flow.authorizationUrl);
|
|
11
|
+
if (t.flow.type === "implicit" ? a.searchParams.set("response_type", "token") : t.flow.type === "authorizationCode" && a.searchParams.set("response_type", "code"), t.flow["x-scalar-redirect-uri"].startsWith("/")) {
|
|
12
|
+
const d = f.url || window.location.origin + window.location.pathname, s = new URL(
|
|
13
|
+
t.flow["x-scalar-redirect-uri"],
|
|
14
|
+
d
|
|
15
|
+
).toString();
|
|
16
|
+
a.searchParams.set("redirect_uri", s);
|
|
17
|
+
} else
|
|
18
|
+
a.searchParams.set(
|
|
19
|
+
"redirect_uri",
|
|
20
|
+
t.flow["x-scalar-redirect-uri"]
|
|
21
|
+
);
|
|
22
|
+
a.searchParams.set("client_id", t["x-scalar-client-id"]), a.searchParams.set("scope", n), a.searchParams.set("state", c);
|
|
23
|
+
const o = window.open(a, "openAuth2Window", "left=100,top=100,width=800,height=600");
|
|
24
|
+
if (o) {
|
|
25
|
+
const d = setInterval(function() {
|
|
15
26
|
var h;
|
|
16
|
-
let
|
|
27
|
+
let s = null, l = null;
|
|
17
28
|
try {
|
|
18
|
-
const w = new URL(
|
|
19
|
-
|
|
29
|
+
const w = new URL(o.location.href).searchParams;
|
|
30
|
+
s = w.get("access_token"), l = w.get("code");
|
|
20
31
|
const u = new URLSearchParams(
|
|
21
|
-
|
|
32
|
+
o.location.href.split("#")[1]
|
|
22
33
|
);
|
|
23
|
-
|
|
34
|
+
s || (s = u.get("access_token")), l || (l = u.get("code"));
|
|
24
35
|
} catch {
|
|
25
36
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
new Error("Window was closed without granting authorization")
|
|
37
|
-
));
|
|
37
|
+
(o.closed || s || l) && (clearInterval(d), o.close(), s ? ((h = o.location.href.match(/state=([^&]*)/)) == null ? void 0 : h[1]) === c ? i(s) : e(new Error("State mismatch")) : l ? new URL(o.location.href).searchParams.get(
|
|
38
|
+
"state"
|
|
39
|
+
) === c ? p(
|
|
40
|
+
t,
|
|
41
|
+
r,
|
|
42
|
+
n,
|
|
43
|
+
l
|
|
44
|
+
).then(i).catch(e) : e(new Error("State mismatch")) : (clearInterval(d), e(
|
|
45
|
+
new Error("Window was closed without granting authorization")
|
|
46
|
+
)));
|
|
38
47
|
}, 200);
|
|
39
48
|
}
|
|
40
49
|
}
|
|
41
|
-
}), p = async (t, r,
|
|
50
|
+
}), p = async (t, r, f, i) => {
|
|
42
51
|
if (!("clientSecret" in r))
|
|
43
52
|
throw new Error(
|
|
44
|
-
"Authorize Servers only works for Client Credentials or Authorization Code flow"
|
|
53
|
+
"Authorize Servers only works for Password, Client Credentials or Authorization Code flow"
|
|
45
54
|
);
|
|
46
55
|
if (!t.flow) throw new Error("OAuth2 flow was not defined");
|
|
47
56
|
const e = new URLSearchParams();
|
|
48
|
-
e.set("client_id", t["x-scalar-client-id"]), e.set("scope",
|
|
57
|
+
e.set("client_id", t["x-scalar-client-id"]), e.set("scope", f), r.clientSecret && e.set("client_secret", r.clientSecret), "x-scalar-redirect-uri" in t.flow && e.set("redirect_uri", t.flow["x-scalar-redirect-uri"]), i ? (e.set("code", i), e.set("grant_type", "authorization_code")) : r.type === "oauth-password" ? (e.set("grant_type", "password"), e.set("username", r.username), e.set("password", r.password)) : e.set("grant_type", "client_credentials");
|
|
49
58
|
try {
|
|
50
|
-
const
|
|
59
|
+
const n = {
|
|
51
60
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
52
61
|
};
|
|
53
|
-
t["x-scalar-client-id"] && r.clientSecret && (
|
|
54
|
-
const
|
|
62
|
+
t["x-scalar-client-id"] && r.clientSecret && (n.Authorization = `Basic ${btoa(`${t["x-scalar-client-id"]}:${r.clientSecret}`)}`);
|
|
63
|
+
const c = await fetch(t.flow.tokenUrl, {
|
|
55
64
|
method: "POST",
|
|
56
|
-
headers:
|
|
65
|
+
headers: n,
|
|
57
66
|
body: e
|
|
58
|
-
}), { access_token:
|
|
59
|
-
return
|
|
67
|
+
}), { access_token: a } = await c.json();
|
|
68
|
+
return a;
|
|
60
69
|
} catch {
|
|
61
70
|
throw new Error(
|
|
62
71
|
"Failed to get an access token. Please check your credentials."
|
|
@@ -64,7 +73,7 @@ const y = (t) => t.type.startsWith("oauth"), _ = (t, r) => new Promise((i, a) =>
|
|
|
64
73
|
}
|
|
65
74
|
};
|
|
66
75
|
export {
|
|
67
|
-
|
|
76
|
+
P as authorizeOauth2,
|
|
68
77
|
p as authorizeServers,
|
|
69
78
|
y as isOauth2Example
|
|
70
79
|
};
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"rest",
|
|
19
19
|
"testing"
|
|
20
20
|
],
|
|
21
|
-
"version": "2.1.
|
|
21
|
+
"version": "2.1.41",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=18"
|
|
24
24
|
},
|
|
@@ -153,18 +153,19 @@
|
|
|
153
153
|
"whatwg-mimetype": "^4.0.0",
|
|
154
154
|
"yaml": "^2.4.5",
|
|
155
155
|
"zod": "^3.23.8",
|
|
156
|
-
"@scalar/draggable": "0.1.6",
|
|
157
156
|
"@scalar/components": "0.12.63",
|
|
157
|
+
"@scalar/draggable": "0.1.6",
|
|
158
158
|
"@scalar/icons": "0.1.1",
|
|
159
|
-
"@scalar/
|
|
159
|
+
"@scalar/import": "0.0.4",
|
|
160
|
+
"@scalar/oas-utils": "0.2.67",
|
|
160
161
|
"@scalar/object-utils": "1.1.11",
|
|
161
162
|
"@scalar/openapi-parser": "0.8.8",
|
|
162
163
|
"@scalar/openapi-types": "0.1.4",
|
|
164
|
+
"@scalar/themes": "0.9.45",
|
|
163
165
|
"@scalar/types": "0.0.18",
|
|
164
166
|
"@scalar/use-codemirror": "0.11.30",
|
|
165
167
|
"@scalar/use-toasts": "0.7.7",
|
|
166
|
-
"@scalar/use-tooltip": "1.0.3"
|
|
167
|
-
"@scalar/themes": "0.9.45"
|
|
168
|
+
"@scalar/use-tooltip": "1.0.3"
|
|
168
169
|
},
|
|
169
170
|
"devDependencies": {
|
|
170
171
|
"@types/js-cookie": "^3.0.6",
|
|
@@ -182,7 +183,7 @@
|
|
|
182
183
|
"vite-svg-loader": "^5.1.0",
|
|
183
184
|
"vitest": "^1.6.0",
|
|
184
185
|
"@scalar/build-tooling": "0.1.11",
|
|
185
|
-
"@scalar/galaxy": "0.2.
|
|
186
|
+
"@scalar/galaxy": "0.2.14"
|
|
186
187
|
},
|
|
187
188
|
"scripts": {
|
|
188
189
|
"build": "vite build && pnpm types:build && tsc-alias -p tsconfig.build.json",
|