@scalar/api-client 2.1.42 → 2.1.43
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 +11 -0
- package/dist/components/DataTable/DataTableInputSelect.vue.d.ts.map +1 -1
- package/dist/components/DataTable/DataTableInputSelect.vue.js +54 -53
- package/dist/components/Sidebar/Sidebar.vue.js +1 -1
- package/dist/components/Sidebar/Sidebar.vue2.js +1 -1
- package/dist/components/ViewLayout/ViewLayoutSection.vue.js +1 -1
- package/dist/layouts/App/create-api-client-app.d.ts +12 -2
- package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
- package/dist/layouts/Modal/create-api-client-modal.d.ts +24 -4
- package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
- package/dist/layouts/Web/create-api-client-web.d.ts +12 -2
- package/dist/layouts/Web/create-api-client-web.d.ts.map +1 -1
- package/dist/libs/create-client.d.ts +12 -2
- package/dist/libs/create-client.d.ts.map +1 -1
- package/dist/store/security-schemes.d.ts +12 -2
- package/dist/store/security-schemes.d.ts.map +1 -1
- package/dist/store/store.d.ts +24 -4
- package/dist/store/store.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js +88 -69
- package/dist/views/Request/RequestSection/RequestAuthDataTableInput.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuthDataTableInput.vue.js +19 -18
- package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
- package/dist/views/Request/libs/index.js +5 -4
- package/dist/views/Request/libs/oauth2.d.ts +12 -2
- package/dist/views/Request/libs/oauth2.d.ts.map +1 -1
- package/dist/views/Request/libs/oauth2.js +107 -66
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SecuritySchemeOauth2, type SecuritySchemeOauth2ExampleValue } from '@scalar/oas-utils/entities/spec';
|
|
2
2
|
declare const _default: import("vue").DefineComponent<{
|
|
3
3
|
example: SecuritySchemeOauth2ExampleValue;
|
|
4
4
|
scheme: SecuritySchemeOauth2;
|
|
@@ -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":"AA4OA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,EAEtC,MAAM,iCAAiC,CAAA;;aAQ7B,gCAAgC;YACjC,oBAAoB;;aADnB,gCAAgC;YACjC,oBAAoB;;AAwkB9B,wBAMG"}
|
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as F, openBlock as r, createElementBlock as w, Fragment as y, createVNode as d, unref as a, withCtx as o, createTextVNode as u, createElementVNode as U, createBlock as m, createCommentVNode as n } from "vue";
|
|
2
2
|
import i from "../RequestAuthDataTableInput.vue.js";
|
|
3
3
|
import { useLoadingState as x, ScalarButton as c } from "@scalar/components";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
4
|
+
import { pkceOptions as P } from "@scalar/oas-utils/entities/spec";
|
|
5
|
+
import { useToasts as A } from "@scalar/use-toasts";
|
|
6
|
+
import B from "./OAuthScopesInput.vue.js";
|
|
7
|
+
import s from "../../../../components/DataTable/DataTableRow.vue.js";
|
|
8
|
+
import { authorizeOauth2 as O } from "../../libs/oauth2.js";
|
|
9
|
+
import { useWorkspace as I } from "../../../../store/store.js";
|
|
10
|
+
const R = { class: "h-8 flex items-center justify-self-end" }, b = { class: "h-8 flex items-center justify-self-end" }, W = /* @__PURE__ */ F({
|
|
9
11
|
__name: "OAuth2",
|
|
10
12
|
props: {
|
|
11
13
|
example: {},
|
|
12
14
|
scheme: {}
|
|
13
15
|
},
|
|
14
|
-
setup(
|
|
15
|
-
const
|
|
16
|
+
setup(g) {
|
|
17
|
+
const p = g, h = x(), { toast: $ } = A(), {
|
|
16
18
|
activeCollection: V,
|
|
17
|
-
activeServer:
|
|
18
|
-
collectionMutators:
|
|
19
|
-
isReadOnly:
|
|
20
|
-
securitySchemeMutators:
|
|
21
|
-
} =
|
|
22
|
-
var
|
|
23
|
-
if (h.isLoading || !((
|
|
19
|
+
activeServer: v,
|
|
20
|
+
collectionMutators: S,
|
|
21
|
+
isReadOnly: z,
|
|
22
|
+
securitySchemeMutators: C
|
|
23
|
+
} = I(), f = (l, e) => V.value && S.edit(V.value.uid, l, e), k = (l, e) => C.edit(p.scheme.uid, l, e), T = async () => {
|
|
24
|
+
var t;
|
|
25
|
+
if (h.isLoading || !((t = V.value) != null && t.uid)) return;
|
|
24
26
|
h.startLoading();
|
|
25
|
-
const l = await
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const [l, e] = await O(
|
|
28
|
+
p.scheme,
|
|
29
|
+
p.example,
|
|
30
|
+
v.value
|
|
29
31
|
).finally(() => h.stopLoading());
|
|
30
|
-
|
|
32
|
+
e ? f(`auth.${p.scheme.uid}.token`, e) : (console.error(l), $((l == null ? void 0 : l.message) ?? "Failed to authorize", "error"));
|
|
31
33
|
};
|
|
32
|
-
return (l, e) => l.example.token ? (
|
|
33
|
-
|
|
34
|
+
return (l, e) => l.example.token ? (r(), w(y, { key: 0 }, [
|
|
35
|
+
d(a(s), null, {
|
|
34
36
|
default: o(() => [
|
|
35
|
-
|
|
37
|
+
d(i, {
|
|
36
38
|
id: "oauth2-access-token",
|
|
37
39
|
class: "border-r-transparent",
|
|
38
40
|
modelValue: l.example.token,
|
|
39
41
|
placeholder: "QUxMIFlPVVIgQkFTRSBBUkUgQkVMT05HIFRPIFVT",
|
|
40
42
|
type: "password",
|
|
41
|
-
"onUpdate:modelValue": e[0] || (e[0] = (
|
|
43
|
+
"onUpdate:modelValue": e[0] || (e[0] = (t) => f(`auth.${p.scheme.uid}.token`, t))
|
|
42
44
|
}, {
|
|
43
|
-
default: o(() => e[
|
|
45
|
+
default: o(() => e[10] || (e[10] = [
|
|
44
46
|
u(" Access Token ")
|
|
45
47
|
])),
|
|
46
48
|
_: 1
|
|
@@ -48,17 +50,17 @@ const I = { class: "h-8 flex items-center justify-self-end" }, R = { class: "h-8
|
|
|
48
50
|
]),
|
|
49
51
|
_: 1
|
|
50
52
|
}),
|
|
51
|
-
|
|
53
|
+
d(a(s), { class: "min-w-full" }, {
|
|
52
54
|
default: o(() => [
|
|
53
|
-
U("div",
|
|
54
|
-
|
|
55
|
+
U("div", R, [
|
|
56
|
+
d(a(c), {
|
|
55
57
|
class: "p-0 py-0.5 px-2 mr-1",
|
|
56
|
-
loading:
|
|
58
|
+
loading: a(h),
|
|
57
59
|
size: "sm",
|
|
58
60
|
variant: "outlined",
|
|
59
|
-
onClick: e[1] || (e[1] = (
|
|
61
|
+
onClick: e[1] || (e[1] = (t) => f(`auth.${p.scheme.uid}.token`, ""))
|
|
60
62
|
}, {
|
|
61
|
-
default: o(() => e[
|
|
63
|
+
default: o(() => e[11] || (e[11] = [
|
|
62
64
|
u(" Clear ")
|
|
63
65
|
])),
|
|
64
66
|
_: 1
|
|
@@ -67,29 +69,29 @@ const I = { class: "h-8 flex items-center justify-self-end" }, R = { class: "h-8
|
|
|
67
69
|
]),
|
|
68
70
|
_: 1
|
|
69
71
|
})
|
|
70
|
-
], 64)) : (
|
|
71
|
-
|
|
72
|
+
], 64)) : (r(), w(y, { key: 1 }, [
|
|
73
|
+
a(z) ? n("", !0) : (r(), m(a(s), { key: 0 }, {
|
|
72
74
|
default: o(() => [
|
|
73
|
-
"authorizationUrl" in l.scheme.flow ? (
|
|
75
|
+
"authorizationUrl" in l.scheme.flow ? (r(), m(i, {
|
|
74
76
|
key: 0,
|
|
75
77
|
id: `oauth2-authorization-url-${l.scheme.uid}`,
|
|
76
78
|
modelValue: l.scheme.flow.authorizationUrl,
|
|
77
79
|
placeholder: "https://galaxy.scalar.com/authorize",
|
|
78
|
-
"onUpdate:modelValue": e[2] || (e[2] = (
|
|
80
|
+
"onUpdate:modelValue": e[2] || (e[2] = (t) => k("flow.authorizationUrl", t))
|
|
79
81
|
}, {
|
|
80
|
-
default: o(() => e[
|
|
82
|
+
default: o(() => e[12] || (e[12] = [
|
|
81
83
|
u(" Auth Url ")
|
|
82
84
|
])),
|
|
83
85
|
_: 1
|
|
84
86
|
}, 8, ["id", "modelValue"])) : n("", !0),
|
|
85
|
-
"tokenUrl" in l.scheme.flow ? (
|
|
87
|
+
"tokenUrl" in l.scheme.flow ? (r(), m(i, {
|
|
86
88
|
key: 1,
|
|
87
89
|
id: `oauth2-token-url-${l.scheme.uid}`,
|
|
88
90
|
modelValue: l.scheme.flow.tokenUrl,
|
|
89
91
|
placeholder: "https://galaxy.scalar.com/token",
|
|
90
|
-
"onUpdate:modelValue": e[3] || (e[3] = (
|
|
92
|
+
"onUpdate:modelValue": e[3] || (e[3] = (t) => k("flow.tokenUrl", t))
|
|
91
93
|
}, {
|
|
92
|
-
default: o(() => e[
|
|
94
|
+
default: o(() => e[13] || (e[13] = [
|
|
93
95
|
u(" Token Url ")
|
|
94
96
|
])),
|
|
95
97
|
_: 1
|
|
@@ -97,15 +99,15 @@ const I = { class: "h-8 flex items-center justify-self-end" }, R = { class: "h-8
|
|
|
97
99
|
]),
|
|
98
100
|
_: 1
|
|
99
101
|
})),
|
|
100
|
-
"x-scalar-redirect-uri" in l.scheme.flow ? (
|
|
102
|
+
"x-scalar-redirect-uri" in l.scheme.flow ? (r(), m(a(s), { key: 1 }, {
|
|
101
103
|
default: o(() => [
|
|
102
|
-
|
|
104
|
+
d(i, {
|
|
103
105
|
id: `oauth2-redirect-uri-${l.scheme.uid}`,
|
|
104
106
|
modelValue: l.scheme.flow["x-scalar-redirect-uri"],
|
|
105
107
|
placeholder: "https://galaxy.scalar.com/callback",
|
|
106
|
-
"onUpdate:modelValue": e[4] || (e[4] = (
|
|
108
|
+
"onUpdate:modelValue": e[4] || (e[4] = (t) => k("flow.x-scalar-redirect-uri", t))
|
|
107
109
|
}, {
|
|
108
|
-
default: o(() => e[
|
|
110
|
+
default: o(() => e[14] || (e[14] = [
|
|
109
111
|
u(" Redirect Url ")
|
|
110
112
|
])),
|
|
111
113
|
_: 1
|
|
@@ -113,17 +115,17 @@ const I = { class: "h-8 flex items-center justify-self-end" }, R = { class: "h-8
|
|
|
113
115
|
]),
|
|
114
116
|
_: 1
|
|
115
117
|
})) : n("", !0),
|
|
116
|
-
l.example.type === "oauth-password" ? (
|
|
117
|
-
|
|
118
|
+
l.example.type === "oauth-password" ? (r(), w(y, { key: 2 }, [
|
|
119
|
+
d(a(s), null, {
|
|
118
120
|
default: o(() => [
|
|
119
|
-
|
|
121
|
+
d(i, {
|
|
120
122
|
id: `oauth2-password-username-${l.scheme.uid}`,
|
|
121
123
|
class: "text-c-2",
|
|
122
124
|
modelValue: l.example.username,
|
|
123
125
|
placeholder: "ScalarEnjoyer01",
|
|
124
|
-
"onUpdate:modelValue": e[5] || (e[5] = (
|
|
126
|
+
"onUpdate:modelValue": e[5] || (e[5] = (t) => f(`auth.${l.scheme.uid}.username`, t))
|
|
125
127
|
}, {
|
|
126
|
-
default: o(() => e[
|
|
128
|
+
default: o(() => e[15] || (e[15] = [
|
|
127
129
|
u(" Username ")
|
|
128
130
|
])),
|
|
129
131
|
_: 1
|
|
@@ -131,16 +133,16 @@ const I = { class: "h-8 flex items-center justify-self-end" }, R = { class: "h-8
|
|
|
131
133
|
]),
|
|
132
134
|
_: 1
|
|
133
135
|
}),
|
|
134
|
-
|
|
136
|
+
d(a(s), null, {
|
|
135
137
|
default: o(() => [
|
|
136
|
-
|
|
138
|
+
d(i, {
|
|
137
139
|
id: `oauth2-password-password-${l.scheme.uid}`,
|
|
138
140
|
modelValue: l.example.password,
|
|
139
141
|
placeholder: "xxxxxx",
|
|
140
142
|
type: "password",
|
|
141
|
-
"onUpdate:modelValue": e[6] || (e[6] = (
|
|
143
|
+
"onUpdate:modelValue": e[6] || (e[6] = (t) => f(`auth.${l.scheme.uid}.password`, t))
|
|
142
144
|
}, {
|
|
143
|
-
default: o(() => e[
|
|
145
|
+
default: o(() => e[16] || (e[16] = [
|
|
144
146
|
u(" Password ")
|
|
145
147
|
])),
|
|
146
148
|
_: 1
|
|
@@ -149,15 +151,15 @@ const I = { class: "h-8 flex items-center justify-self-end" }, R = { class: "h-8
|
|
|
149
151
|
_: 1
|
|
150
152
|
})
|
|
151
153
|
], 64)) : n("", !0),
|
|
152
|
-
|
|
154
|
+
d(a(s), null, {
|
|
153
155
|
default: o(() => [
|
|
154
|
-
|
|
156
|
+
d(i, {
|
|
155
157
|
id: `oauth2-client-id-${l.scheme.uid}`,
|
|
156
158
|
modelValue: l.scheme["x-scalar-client-id"],
|
|
157
159
|
placeholder: "12345",
|
|
158
|
-
"onUpdate:modelValue": e[7] || (e[7] = (
|
|
160
|
+
"onUpdate:modelValue": e[7] || (e[7] = (t) => k("x-scalar-client-id", t))
|
|
159
161
|
}, {
|
|
160
|
-
default: o(() => e[
|
|
162
|
+
default: o(() => e[17] || (e[17] = [
|
|
161
163
|
u(" Client ID ")
|
|
162
164
|
])),
|
|
163
165
|
_: 1
|
|
@@ -165,16 +167,16 @@ const I = { class: "h-8 flex items-center justify-self-end" }, R = { class: "h-8
|
|
|
165
167
|
]),
|
|
166
168
|
_: 1
|
|
167
169
|
}),
|
|
168
|
-
"clientSecret" in l.example ? (
|
|
170
|
+
"clientSecret" in l.example ? (r(), m(a(s), { key: 3 }, {
|
|
169
171
|
default: o(() => [
|
|
170
|
-
|
|
172
|
+
d(i, {
|
|
171
173
|
id: `oauth2-client-secret-${l.scheme.uid}`,
|
|
172
174
|
modelValue: l.example.clientSecret,
|
|
173
175
|
placeholder: "XYZ123",
|
|
174
176
|
type: "password",
|
|
175
|
-
"onUpdate:modelValue": e[8] || (e[8] = (
|
|
177
|
+
"onUpdate:modelValue": e[8] || (e[8] = (t) => f(`auth.${l.scheme.uid}.clientSecret`, t))
|
|
176
178
|
}, {
|
|
177
|
-
default: o(() => e[
|
|
179
|
+
default: o(() => e[18] || (e[18] = [
|
|
178
180
|
u(" Client Secret ")
|
|
179
181
|
])),
|
|
180
182
|
_: 1
|
|
@@ -182,26 +184,43 @@ const I = { class: "h-8 flex items-center justify-self-end" }, R = { class: "h-8
|
|
|
182
184
|
]),
|
|
183
185
|
_: 1
|
|
184
186
|
})) : n("", !0),
|
|
185
|
-
l.scheme.flow
|
|
187
|
+
"x-usePkce" in l.scheme.flow ? (r(), m(a(s), { key: 4 }, {
|
|
186
188
|
default: o(() => [
|
|
187
|
-
|
|
189
|
+
d(i, {
|
|
190
|
+
id: `oauth2-use-pkce-${l.scheme.uid}`,
|
|
191
|
+
enum: a(P),
|
|
192
|
+
modelValue: l.scheme.flow["x-usePkce"],
|
|
193
|
+
readOnly: "",
|
|
194
|
+
"onUpdate:modelValue": e[9] || (e[9] = (t) => k("flow.x-usePkce", t))
|
|
195
|
+
}, {
|
|
196
|
+
default: o(() => e[19] || (e[19] = [
|
|
197
|
+
u(" Use PKCE ")
|
|
198
|
+
])),
|
|
199
|
+
_: 1
|
|
200
|
+
}, 8, ["id", "enum", "modelValue"])
|
|
201
|
+
]),
|
|
202
|
+
_: 1
|
|
203
|
+
})) : n("", !0),
|
|
204
|
+
Object.keys(l.scheme.flow.scopes ?? {}).length ? (r(), m(a(s), { key: 5 }, {
|
|
205
|
+
default: o(() => [
|
|
206
|
+
d(B, {
|
|
188
207
|
activeFlow: l.scheme.flow,
|
|
189
208
|
updateScheme: k
|
|
190
209
|
}, null, 8, ["activeFlow"])
|
|
191
210
|
]),
|
|
192
211
|
_: 1
|
|
193
212
|
})) : n("", !0),
|
|
194
|
-
|
|
213
|
+
d(a(s), { class: "min-w-full" }, {
|
|
195
214
|
default: o(() => [
|
|
196
|
-
U("div",
|
|
197
|
-
|
|
215
|
+
U("div", b, [
|
|
216
|
+
d(a(c), {
|
|
198
217
|
class: "p-0 py-0.5 px-2 mr-1",
|
|
199
|
-
loading:
|
|
218
|
+
loading: a(h),
|
|
200
219
|
size: "sm",
|
|
201
220
|
variant: "outlined",
|
|
202
|
-
onClick:
|
|
221
|
+
onClick: T
|
|
203
222
|
}, {
|
|
204
|
-
default: o(() => e[
|
|
223
|
+
default: o(() => e[20] || (e[20] = [
|
|
205
224
|
u(" Authorize ")
|
|
206
225
|
])),
|
|
207
226
|
_: 1
|
|
@@ -214,5 +233,5 @@ const I = { class: "h-8 flex items-center justify-self-end" }, R = { class: "h-8
|
|
|
214
233
|
}
|
|
215
234
|
});
|
|
216
235
|
export {
|
|
217
|
-
|
|
236
|
+
W as default
|
|
218
237
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestAuthDataTableInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/RequestSection/RequestAuthDataTableInput.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RequestAuthDataTableInput.vue.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/RequestSection/RequestAuthDataTableInput.vue"],"names":[],"mappings":"AAoFA,iBAAS,cAAc;qBAiGO,GAAG;kBACN,GAAG;EAuB7B;AACD,QAAA,MAAM,eAAe;QAzJb,MAAM;WACH,MAAM;qBACI,MAAM;eACZ,OAAO;gBACN,MAAM,GAAG,MAAM;eAChB,OAAO;;;;;;;QALd,MAAM;WACH,MAAM;qBACI,MAAM;eACZ,OAAO;gBACN,MAAM,GAAG,MAAM;eAChB,OAAO;;;;;;;cAFP,OAAO;cAEP,OAAO;6EAiKpB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAAvG,wBAAwG;AAexG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACpC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as s, openBlock as i, createBlock as p, mergeProps as m, withCtx as a, createElementVNode as f, renderSlot as r } from "vue";
|
|
2
2
|
import V from "../../../components/DataTable/DataTableInput.vue.js";
|
|
3
|
-
const y = ["for"],
|
|
3
|
+
const y = ["for"], B = /* @__PURE__ */ s({
|
|
4
4
|
__name: "RequestAuthDataTableInput",
|
|
5
5
|
props: {
|
|
6
6
|
id: {},
|
|
@@ -11,24 +11,25 @@ const y = ["for"], C = /* @__PURE__ */ d({
|
|
|
11
11
|
readOnly: { type: Boolean, default: !1 }
|
|
12
12
|
},
|
|
13
13
|
emits: ["update:modelValue", "inputFocus", "inputBlur", "selectVariable"],
|
|
14
|
-
setup(u, { emit:
|
|
15
|
-
const
|
|
16
|
-
return (n,
|
|
17
|
-
id:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
setup(u, { emit: d }) {
|
|
15
|
+
const e = u, o = d;
|
|
16
|
+
return (n, t) => (i(), p(V, m({
|
|
17
|
+
id: e.id,
|
|
18
|
+
canAddCustomEnumValue: !e.readOnly,
|
|
19
|
+
containerClass: e.containerClass,
|
|
20
|
+
modelValue: e.modelValue,
|
|
21
|
+
readOnly: e.readOnly,
|
|
22
|
+
required: e.required,
|
|
23
|
+
type: e.type
|
|
23
24
|
}, n.$attrs, {
|
|
24
|
-
onInputBlur:
|
|
25
|
-
onInputFocus:
|
|
26
|
-
onSelectVariable:
|
|
27
|
-
"onUpdate:modelValue":
|
|
25
|
+
onInputBlur: t[0] || (t[0] = (l) => o("inputBlur")),
|
|
26
|
+
onInputFocus: t[1] || (t[1] = (l) => o("inputFocus")),
|
|
27
|
+
onSelectVariable: t[2] || (t[2] = (l) => o("selectVariable", l)),
|
|
28
|
+
"onUpdate:modelValue": t[3] || (t[3] = (l) => o("update:modelValue", l))
|
|
28
29
|
}), {
|
|
29
30
|
default: a(() => [
|
|
30
31
|
f("label", {
|
|
31
|
-
for:
|
|
32
|
+
for: e.id
|
|
32
33
|
}, [
|
|
33
34
|
r(n.$slots, "default")
|
|
34
35
|
], 8, y)
|
|
@@ -37,9 +38,9 @@ const y = ["for"], C = /* @__PURE__ */ d({
|
|
|
37
38
|
r(n.$slots, "icon")
|
|
38
39
|
]),
|
|
39
40
|
_: 3
|
|
40
|
-
}, 16, ["id", "containerClass", "modelValue", "readOnly", "required", "type"]));
|
|
41
|
+
}, 16, ["id", "canAddCustomEnumValue", "containerClass", "modelValue", "readOnly", "required", "type"]));
|
|
41
42
|
}
|
|
42
43
|
});
|
|
43
44
|
export {
|
|
44
|
-
|
|
45
|
+
B as default
|
|
45
46
|
};
|
|
@@ -14,7 +14,7 @@ const B = { class: "relative col-1 flex-center gap-6 p-2 capitalize" }, S = { cl
|
|
|
14
14
|
s.commandPalette.emit({ commandName: "Create Request" });
|
|
15
15
|
}, c = (n) => {
|
|
16
16
|
n != null && n.createNew && y.name === "request" && m();
|
|
17
|
-
}, k = "2.1.
|
|
17
|
+
}, k = "2.1.43";
|
|
18
18
|
return _(() => s.hotKeys.on(c)), b(() => s.hotKeys.off(c)), (n, e) => (r(), l("div", B, [
|
|
19
19
|
t("div", S, [
|
|
20
20
|
o(f).isReadOnly ? u("", !0) : (r(), l("div", h, [
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { createSchemeValueSet as
|
|
2
|
-
import { authorizeOauth2 as h, authorizeServers as m, isOauth2Example as u } from "./oauth2.js";
|
|
1
|
+
import { createSchemeValueSet as a, displaySchemeFormatter as t } from "./auth.js";
|
|
2
|
+
import { authorizeOauth2 as h, authorizeServers as m, generateCodeChallenge as l, isOauth2Example as u } from "./oauth2.js";
|
|
3
3
|
export {
|
|
4
4
|
h as authorizeOauth2,
|
|
5
5
|
m as authorizeServers,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
a as createSchemeValueSet,
|
|
7
|
+
t as displaySchemeFormatter,
|
|
8
|
+
l as generateCodeChallenge,
|
|
8
9
|
u as isOauth2Example
|
|
9
10
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ErrorResponse } from '../../../libs/index.js';
|
|
1
2
|
import type { SecuritySchemeExampleValue, SecuritySchemeOauth2, SecuritySchemeOauth2ExampleValue, Server } from '@scalar/oas-utils/entities/spec';
|
|
2
3
|
/** Oauth2 security schemes which are not implicit */
|
|
3
4
|
type SecuritySchemeOauth2NonImplicit = Omit<SecuritySchemeOauth2, 'flow'> & {
|
|
@@ -7,16 +8,25 @@ type SecuritySchemeOauth2NonImplicit = Omit<SecuritySchemeOauth2, 'flow'> & {
|
|
|
7
8
|
};
|
|
8
9
|
/** Type guard to check for oauth2 example */
|
|
9
10
|
export declare const isOauth2Example: (example: SecuritySchemeExampleValue) => example is SecuritySchemeOauth2ExampleValue;
|
|
11
|
+
type PKCEState = {
|
|
12
|
+
codeVerifier: string;
|
|
13
|
+
codeChallenge: string;
|
|
14
|
+
codeChallengeMethod: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Creates a code challenge from the code verifier
|
|
18
|
+
*/
|
|
19
|
+
export declare const generateCodeChallenge: (verifier: string, encoding: "SHA-256" | "plain") => Promise<string>;
|
|
10
20
|
/**
|
|
11
21
|
* Authorize oauth2 flow
|
|
12
22
|
*
|
|
13
23
|
* @returns the accessToken
|
|
14
24
|
*/
|
|
15
|
-
export declare const authorizeOauth2: (scheme: SecuritySchemeOauth2, example: SecuritySchemeOauth2ExampleValue, activeServer: Server) => Promise<string
|
|
25
|
+
export declare const authorizeOauth2: (scheme: SecuritySchemeOauth2, example: SecuritySchemeOauth2ExampleValue, activeServer: Server) => Promise<ErrorResponse<string>>;
|
|
16
26
|
/**
|
|
17
27
|
* Makes the BE authorization call to grab the token server to server
|
|
18
28
|
* Used for clientCredentials and authorizationCode
|
|
19
29
|
*/
|
|
20
|
-
export declare const authorizeServers: (scheme: SecuritySchemeOauth2NonImplicit, example: SecuritySchemeOauth2ExampleValue, scopes: string, code?: string) => Promise<string
|
|
30
|
+
export declare const authorizeServers: (scheme: SecuritySchemeOauth2NonImplicit, example: SecuritySchemeOauth2ExampleValue, scopes: string, code?: string, pkce?: PKCEState | null) => Promise<ErrorResponse<string>>;
|
|
21
31
|
export {};
|
|
22
32
|
//# sourceMappingURL=oauth2.d.ts.map
|
|
@@ -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,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,
|
|
1
|
+
{"version":3,"file":"oauth2.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/libs/oauth2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAC3C,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,KAAK,SAAS,GAAG;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,mBAAmB,EAAE,MAAM,CAAA;CAC5B,CAAA;AAmBD;;GAEG;AACH,eAAO,MAAM,qBAAqB,aACtB,MAAM,YACN,SAAS,GAAG,OAAO,KAC5B,OAAO,CAAC,MAAM,CAahB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAClB,oBAAoB,WACnB,gCAAgC,gBAE3B,MAAM,KACnB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CA8J/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,WACnB,+BAA+B,WAC9B,gCAAgC,UACjC,MAAM,SACP,MAAM,SACN,SAAS,GAAG,IAAI,KACtB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAgE/B,CAAA"}
|
|
@@ -1,79 +1,120 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
a.searchParams.set("redirect_uri", s);
|
|
17
|
-
} else
|
|
18
|
-
a.searchParams.set(
|
|
19
|
-
"redirect_uri",
|
|
20
|
-
t.flow["x-scalar-redirect-uri"]
|
|
1
|
+
const P = (e) => e.type.startsWith("oauth"), y = () => {
|
|
2
|
+
const e = new Uint8Array(32);
|
|
3
|
+
return crypto.getRandomValues(e), btoa(String.fromCharCode(...e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
4
|
+
}, _ = async (e, r) => {
|
|
5
|
+
if (r === "plain") return e;
|
|
6
|
+
const a = new TextEncoder().encode(e), s = await crypto.subtle.digest("SHA-256", a);
|
|
7
|
+
return btoa(String.fromCharCode(...new Uint8Array(s))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
8
|
+
}, S = async (e, r, d) => {
|
|
9
|
+
try {
|
|
10
|
+
const a = e.flow.selectedScopes.join(" ");
|
|
11
|
+
if (e.flow.type === "clientCredentials" || e.flow.type === "password")
|
|
12
|
+
return g(
|
|
13
|
+
e,
|
|
14
|
+
r,
|
|
15
|
+
a
|
|
21
16
|
);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
-
}
|
|
17
|
+
{
|
|
18
|
+
const s = (Math.random() + 1).toString(36).substring(7), t = new URL(e.flow.authorizationUrl);
|
|
19
|
+
let c = null;
|
|
20
|
+
if (e.flow.type === "implicit")
|
|
21
|
+
t.searchParams.set("response_type", "token");
|
|
22
|
+
else if (e.flow.type === "authorizationCode" && (t.searchParams.set("response_type", "code"), e.flow["x-usePkce"] !== "no")) {
|
|
23
|
+
const o = y(), i = await _(
|
|
24
|
+
o,
|
|
25
|
+
e.flow["x-usePkce"]
|
|
26
|
+
);
|
|
27
|
+
c = {
|
|
28
|
+
codeVerifier: o,
|
|
29
|
+
codeChallenge: i,
|
|
30
|
+
codeChallengeMethod: e.flow["x-usePkce"] === "SHA-256" ? "S256" : "plain"
|
|
31
|
+
}, t.searchParams.set("code_challenge", i), t.searchParams.set(
|
|
32
|
+
"code_challenge_method",
|
|
33
|
+
c.codeChallengeMethod
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
if (e.flow["x-scalar-redirect-uri"].startsWith("/")) {
|
|
37
|
+
const o = d.url || window.location.origin + window.location.pathname, i = new URL(
|
|
38
|
+
e.flow["x-scalar-redirect-uri"],
|
|
39
|
+
o
|
|
40
|
+
).toString();
|
|
41
|
+
t.searchParams.set("redirect_uri", i);
|
|
42
|
+
} else
|
|
43
|
+
t.searchParams.set(
|
|
44
|
+
"redirect_uri",
|
|
45
|
+
e.flow["x-scalar-redirect-uri"]
|
|
46
|
+
);
|
|
47
|
+
t.searchParams.set("client_id", e["x-scalar-client-id"]), t.searchParams.set("state", s), a && t.searchParams.set("scope", a);
|
|
48
|
+
const n = window.open(t, "openAuth2Window", "left=100,top=100,width=800,height=600");
|
|
49
|
+
return n ? new Promise((o) => {
|
|
50
|
+
const i = setInterval(() => {
|
|
51
|
+
var h;
|
|
52
|
+
let w = null, u = null;
|
|
53
|
+
try {
|
|
54
|
+
const l = new URL(n.location.href).searchParams;
|
|
55
|
+
w = l.get("access_token"), u = l.get("code");
|
|
56
|
+
const p = new URLSearchParams(
|
|
57
|
+
n.location.href.split("#")[1]
|
|
58
|
+
);
|
|
59
|
+
w || (w = p.get("access_token")), u || (u = p.get("code"));
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
if (n.closed || w || u)
|
|
63
|
+
if (clearInterval(i), n.close(), w) {
|
|
64
|
+
const l = (h = n.location.href.match(/state=([^&]*)/)) == null ? void 0 : h[1];
|
|
65
|
+
o(l === s ? [null, w] : [new Error("State mismatch"), null]);
|
|
66
|
+
} else u ? new URL(
|
|
67
|
+
n.location.href
|
|
68
|
+
).searchParams.get("state") === s ? g(
|
|
69
|
+
e,
|
|
70
|
+
r,
|
|
71
|
+
a,
|
|
72
|
+
u,
|
|
73
|
+
c
|
|
74
|
+
).then(o) : o([new Error("State mismatch"), null]) : (clearInterval(i), o([
|
|
75
|
+
new Error("Window was closed without granting authorization"),
|
|
76
|
+
null
|
|
77
|
+
]));
|
|
78
|
+
}, 200);
|
|
79
|
+
}) : [new Error("Failed to open auth window"), null];
|
|
48
80
|
}
|
|
81
|
+
} catch {
|
|
82
|
+
return [new Error("Failed to authorize oauth2 flow"), null];
|
|
49
83
|
}
|
|
50
|
-
}
|
|
84
|
+
}, g = async (e, r, d, a, s) => {
|
|
51
85
|
if (!("clientSecret" in r))
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
86
|
+
return [
|
|
87
|
+
new Error(
|
|
88
|
+
"Authorize Servers only works for Password, Client Credentials or Authorization Code flow"
|
|
89
|
+
),
|
|
90
|
+
null
|
|
91
|
+
];
|
|
92
|
+
if (!e.flow) return [new Error("OAuth2 flow was not defined"), null];
|
|
93
|
+
const t = new URLSearchParams();
|
|
94
|
+
t.set("client_id", e["x-scalar-client-id"]), d && t.set("scope", d), r.clientSecret && t.set("client_secret", r.clientSecret), "x-scalar-redirect-uri" in e.flow && t.set("redirect_uri", e.flow["x-scalar-redirect-uri"]), a ? (t.set("code", a), t.set("grant_type", "authorization_code"), s && t.set("code_verifier", s.codeVerifier)) : r.type === "oauth-password" ? (t.set("grant_type", "password"), t.set("username", r.username), t.set("password", r.password)) : t.set("grant_type", "client_credentials");
|
|
58
95
|
try {
|
|
59
|
-
const
|
|
96
|
+
const c = {
|
|
60
97
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
61
98
|
};
|
|
62
|
-
|
|
63
|
-
const
|
|
99
|
+
e["x-scalar-client-id"] && r.clientSecret && (c.Authorization = `Basic ${btoa(`${e["x-scalar-client-id"]}:${r.clientSecret}`)}`);
|
|
100
|
+
const f = await fetch(e.flow.tokenUrl, {
|
|
64
101
|
method: "POST",
|
|
65
|
-
headers:
|
|
66
|
-
body:
|
|
67
|
-
}), { access_token:
|
|
68
|
-
return
|
|
102
|
+
headers: c,
|
|
103
|
+
body: t
|
|
104
|
+
}), { access_token: n } = await f.json();
|
|
105
|
+
return [null, n];
|
|
69
106
|
} catch {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
107
|
+
return [
|
|
108
|
+
new Error(
|
|
109
|
+
"Failed to get an access token. Please check your credentials."
|
|
110
|
+
),
|
|
111
|
+
null
|
|
112
|
+
];
|
|
73
113
|
}
|
|
74
114
|
};
|
|
75
115
|
export {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
116
|
+
S as authorizeOauth2,
|
|
117
|
+
g as authorizeServers,
|
|
118
|
+
_ as generateCodeChallenge,
|
|
119
|
+
P as isOauth2Example
|
|
79
120
|
};
|