@scalar/api-client 2.0.33 → 2.0.35
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 +28 -0
- package/dist/components/CodeInput/CodeInput.vue.js +2 -2
- package/dist/components/CommandPalette/CommandPaletteCollection.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteCollection.vue.js +39 -31
- package/dist/components/CommandPalette/CommandPaletteExample.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteExample.vue.js +65 -55
- package/dist/components/CommandPalette/CommandPaletteFolder.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteFolder.vue.js +53 -44
- package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteImport.vue.js +42 -34
- package/dist/components/CommandPalette/CommandPaletteRequest.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteRequest.vue.js +126 -70
- package/dist/components/CommandPalette/CommandPaletteWorkspace.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPaletteWorkspace.vue.js +37 -29
- package/dist/components/CommandPalette/TheCommandPalette.vue.d.ts.map +1 -1
- package/dist/components/CommandPalette/TheCommandPalette.vue.js +4 -4
- package/dist/components/CommandPalette/TheCommandPalette.vue2.js +97 -85
- package/dist/components/CommandPalette/handleKeyDown.d.ts +2 -0
- package/dist/components/CommandPalette/handleKeyDown.d.ts.map +1 -0
- package/dist/components/CommandPalette/handleKeyDown.js +7 -0
- package/dist/components/DataTable/DataTableInput.vue.d.ts +7 -0
- package/dist/components/DataTable/DataTableInput.vue.d.ts.map +1 -1
- package/dist/components/DataTable/DataTableInput.vue.js +3 -3
- package/dist/components/DataTable/DataTableInput.vue2.js +33 -31
- package/dist/components/DataTable/DataTableInputSelect.vue.d.ts +19 -3
- package/dist/components/DataTable/DataTableInputSelect.vue.d.ts.map +1 -1
- package/dist/components/DataTable/DataTableInputSelect.vue.js +37 -35
- package/dist/components/DataTable/index.d.ts +1 -0
- package/dist/components/DataTable/index.d.ts.map +1 -1
- package/dist/components/DataTable/index.js +6 -4
- package/dist/components/Form/Form.vue.js +1 -1
- package/dist/components/Search/SearchButton.vue.d.ts.map +1 -1
- package/dist/components/Search/SearchButton.vue.js +14 -16
- package/dist/components/SideNav/SideHelp.vue.d.ts +3 -0
- package/dist/components/SideNav/SideHelp.vue.d.ts.map +1 -0
- package/dist/components/SideNav/SideHelp.vue.js +125 -0
- package/dist/components/SideNav/SideHelp.vue2.js +4 -0
- package/dist/components/SideNav/SideNav.vue.d.ts.map +1 -1
- package/dist/components/SideNav/SideNav.vue.js +3 -3
- package/dist/components/SideNav/SideNav.vue2.js +28 -24
- package/dist/components/Sidebar/SidebarButton.vue.js +1 -1
- package/dist/components/Sidebar/SidebarList.vue.d.ts.map +1 -1
- package/dist/components/Sidebar/SidebarList.vue.js +1 -1
- package/dist/components/Sidebar/SidebarListElement.vue.d.ts.map +1 -1
- package/dist/components/Sidebar/SidebarListElement.vue.js +1 -1
- package/dist/components/Sidebar/SidebarListElement.vue2.js +9 -9
- package/dist/constants.d.ts +0 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -2
- package/dist/layouts/App/create-api-client-app.d.ts +512 -603
- package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
- package/dist/layouts/Modal/api-client-modal.d.ts +1036 -1218
- package/dist/layouts/Modal/api-client-modal.d.ts.map +1 -1
- package/dist/libs/create-client.d.ts +513 -603
- package/dist/libs/create-client.d.ts.map +1 -1
- package/dist/libs/create-client.js +58 -68
- package/dist/libs/local-storage.js +5 -5
- package/dist/libs/sendRequest.d.ts +3 -5
- package/dist/libs/sendRequest.d.ts.map +1 -1
- package/dist/libs/sendRequest.js +73 -67
- package/dist/store/workspace.d.ts +1037 -1219
- package/dist/store/workspace.d.ts.map +1 -1
- package/dist/store/workspace.js +350 -277
- package/dist/style.css +1 -1
- package/dist/views/Request/Request.vue.d.ts.map +1 -1
- package/dist/views/Request/Request.vue.js +1 -1
- package/dist/views/Request/Request.vue2.js +101 -102
- package/dist/views/Request/RequestSection/RequestAuth.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestAuth.vue.js +270 -177
- package/dist/views/Request/RequestSection/RequestSection.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSection/RequestSection.vue.js +52 -42
- package/dist/views/Request/RequestSidebarItemMenu.vue.d.ts.map +1 -1
- package/dist/views/Request/RequestSidebarItemMenu.vue.js +141 -104
- package/dist/views/Request/components/OAuth2.vue.d.ts +3 -9
- package/dist/views/Request/components/OAuth2.vue.d.ts.map +1 -1
- package/dist/views/Request/components/OAuth2.vue.js +141 -112
- package/dist/views/Request/components/OAuthScopesInput.vue.d.ts +2 -6
- package/dist/views/Request/components/OAuthScopesInput.vue.d.ts.map +1 -1
- package/dist/views/Request/components/OAuthScopesInput.vue.js +35 -39
- package/dist/views/Request/consts/index.d.ts +2 -0
- package/dist/views/Request/consts/index.d.ts.map +1 -0
- package/dist/views/Request/consts/index.js +5 -0
- package/dist/views/Request/consts/new-auth-options.d.ts +92 -0
- package/dist/views/Request/consts/new-auth-options.d.ts.map +1 -0
- package/dist/views/Request/consts/new-auth-options.js +83 -0
- package/dist/views/Request/libs/oauth2.d.ts +3 -16
- package/dist/views/Request/libs/oauth2.d.ts.map +1 -1
- package/dist/views/Request/libs/oauth2.js +28 -31
- package/package.json +9 -5
|
@@ -1,59 +1,55 @@
|
|
|
1
|
-
import { defineComponent as S, computed as f, openBlock as m, createBlock as h, unref as o, withCtx as
|
|
2
|
-
import { Disclosure as
|
|
3
|
-
import { ScalarIcon as
|
|
1
|
+
import { defineComponent as S, computed as f, openBlock as m, createBlock as h, unref as o, withCtx as s, createElementVNode as l, createVNode as c, toDisplayString as p, createElementBlock as g, Fragment as b, renderList as C } from "vue";
|
|
2
|
+
import { Disclosure as F, DisclosureButton as k, DisclosurePanel as D } from "@headlessui/vue";
|
|
3
|
+
import { ScalarIcon as y } from "@scalar/components";
|
|
4
4
|
import _ from "../../../components/DataTable/DataTableCell.vue.js";
|
|
5
5
|
import V from "../../../components/DataTable/DataTableRow.vue.js";
|
|
6
|
-
import
|
|
7
|
-
const
|
|
6
|
+
import B from "../../../components/DataTable/DataTableCheckbox.vue.js";
|
|
7
|
+
const O = { class: "flex h-full w-full" }, $ = /* @__PURE__ */ l("div", { class: "text-c-2 min-w-[120px] items-center pl-2 h-full border-r-1/2" }, [
|
|
8
8
|
/* @__PURE__ */ l("span", { class: "h-8 flex items-center" }, " Scopes ")
|
|
9
|
-
], -1),
|
|
9
|
+
], -1), j = { class: "flex-1 text-c-3" }, E = {
|
|
10
10
|
class: "grid auto-rows-auto border-t-1/2",
|
|
11
11
|
style: { gridTemplateColumns: "1fr auto" }
|
|
12
|
-
},
|
|
12
|
+
}, I = { class: "font-code text-xs" }, P = /* @__PURE__ */ S({
|
|
13
13
|
__name: "OAuthScopesInput",
|
|
14
14
|
props: {
|
|
15
15
|
activeFlow: {},
|
|
16
|
-
schemeModel: {},
|
|
17
16
|
updateScheme: { type: Function }
|
|
18
17
|
},
|
|
19
18
|
setup(v) {
|
|
20
|
-
const
|
|
19
|
+
const n = v, x = f(
|
|
21
20
|
() => {
|
|
22
21
|
var e;
|
|
23
|
-
return Object.entries(((e =
|
|
24
|
-
id:
|
|
25
|
-
label:
|
|
22
|
+
return Object.entries(((e = n.activeFlow) == null ? void 0 : e.scopes) ?? {}).map(([a, t]) => ({
|
|
23
|
+
id: a,
|
|
24
|
+
label: a,
|
|
26
25
|
description: t
|
|
27
26
|
}));
|
|
28
27
|
}
|
|
29
28
|
), r = f(() => {
|
|
30
29
|
var e;
|
|
31
|
-
return ((e =
|
|
30
|
+
return ((e = n.activeFlow) == null ? void 0 : e.selectedScopes) || [];
|
|
32
31
|
});
|
|
33
|
-
function w(e,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
e
|
|
37
|
-
]) : s.updateScheme(
|
|
38
|
-
`flows.${s.schemeModel.flowKey}.selectedScopes`,
|
|
32
|
+
function w(e, a) {
|
|
33
|
+
a ? n.updateScheme("flow.selectedScopes", [...r.value, e]) : n.updateScheme(
|
|
34
|
+
"flow.selectedScopes",
|
|
39
35
|
r.value.filter((t) => t !== e)
|
|
40
36
|
);
|
|
41
37
|
}
|
|
42
|
-
return (e,
|
|
43
|
-
default:
|
|
44
|
-
l("div",
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
return (e, a) => (m(), h(o(_), { class: "items-center min-h-8 h-auto" }, {
|
|
39
|
+
default: s(() => [
|
|
40
|
+
l("div", O, [
|
|
41
|
+
$,
|
|
42
|
+
c(o(F), {
|
|
47
43
|
as: "div",
|
|
48
44
|
class: "flex flex-col w-full"
|
|
49
45
|
}, {
|
|
50
|
-
default:
|
|
51
|
-
|
|
52
|
-
default:
|
|
46
|
+
default: s(() => [
|
|
47
|
+
c(o(k), { class: "group/scopes-accordion flex items-center text-left min-h-8 gap-1.5 h-auto pl-2 hover:bg-b-2 pr-2.5 cursor-pointer" }, {
|
|
48
|
+
default: s(({ open: t }) => {
|
|
53
49
|
var i, u, d;
|
|
54
50
|
return [
|
|
55
|
-
l("div",
|
|
56
|
-
|
|
51
|
+
l("div", j, " Selected " + p(((u = (i = e.activeFlow) == null ? void 0 : i.selectedScopes) == null ? void 0 : u.length) || 0) + " / " + p(Object.keys(((d = e.activeFlow) == null ? void 0 : d.scopes) ?? {}).length || 0), 1),
|
|
52
|
+
c(o(y), {
|
|
57
53
|
class: "text-c-3 group-hover/scopes-accordion:text-c-2",
|
|
58
54
|
icon: t ? "ChevronDown" : "ChevronRight",
|
|
59
55
|
size: "xs"
|
|
@@ -62,25 +58,25 @@ const B = { class: "flex h-full w-full" }, M = /* @__PURE__ */ l("div", { class:
|
|
|
62
58
|
}),
|
|
63
59
|
_: 1
|
|
64
60
|
}),
|
|
65
|
-
|
|
66
|
-
default:
|
|
67
|
-
l("table",
|
|
68
|
-
(m(!0), g(b, null,
|
|
61
|
+
c(o(D), { as: "template" }, {
|
|
62
|
+
default: s(() => [
|
|
63
|
+
l("table", E, [
|
|
64
|
+
(m(!0), g(b, null, C(x.value, ({ id: t, label: i, description: u }) => (m(), h(o(V), {
|
|
69
65
|
key: t,
|
|
70
66
|
class: "text-c-2",
|
|
71
67
|
onClick: (d) => w(t, !r.value.includes(t))
|
|
72
68
|
}, {
|
|
73
|
-
default:
|
|
74
|
-
|
|
75
|
-
default:
|
|
69
|
+
default: s(() => [
|
|
70
|
+
c(o(_), { class: "w-full px-2 py-1.5 hover:bg-b-2 cursor-pointer" }, {
|
|
71
|
+
default: s(() => [
|
|
76
72
|
l("span", null, [
|
|
77
|
-
l("span",
|
|
73
|
+
l("span", I, p(i), 1),
|
|
78
74
|
l("span", null, " – " + p(u), 1)
|
|
79
75
|
])
|
|
80
76
|
]),
|
|
81
77
|
_: 2
|
|
82
78
|
}, 1024),
|
|
83
|
-
|
|
79
|
+
c(o(B), {
|
|
84
80
|
modelValue: r.value.includes(t),
|
|
85
81
|
"onUpdate:modelValue": () => {
|
|
86
82
|
}
|
|
@@ -102,5 +98,5 @@ const B = { class: "flex h-full w-full" }, M = /* @__PURE__ */ l("div", { class:
|
|
|
102
98
|
}
|
|
103
99
|
});
|
|
104
100
|
export {
|
|
105
|
-
|
|
101
|
+
P as default
|
|
106
102
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/consts/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { SecuritySchemePayload } from '@scalar/oas-utils/entities/workspace/security';
|
|
2
|
+
export type SecuritySchemeOption = {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
labelWithoutId: string;
|
|
6
|
+
payload?: SecuritySchemePayload;
|
|
7
|
+
};
|
|
8
|
+
export type SecuritySchemeGroup = {
|
|
9
|
+
label: string;
|
|
10
|
+
options: SecuritySchemeOption[];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Add auth options for Request Auth
|
|
14
|
+
*
|
|
15
|
+
* We store it as a dictionary first for quick lookups then convert to an array of options
|
|
16
|
+
*/
|
|
17
|
+
export declare const ADD_AUTH_DICT: {
|
|
18
|
+
readonly apiKeyCookie: {
|
|
19
|
+
readonly label: "API Key in Cookies";
|
|
20
|
+
readonly payload: {
|
|
21
|
+
readonly type: "apiKey";
|
|
22
|
+
readonly in: "cookie";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
readonly apiKeyHeader: {
|
|
26
|
+
readonly label: "API Key in Headers";
|
|
27
|
+
readonly payload: {
|
|
28
|
+
readonly type: "apiKey";
|
|
29
|
+
readonly in: "header";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
readonly apiKeyQuery: {
|
|
33
|
+
readonly label: "API Key in Query Params";
|
|
34
|
+
readonly payload: {
|
|
35
|
+
readonly type: "apiKey";
|
|
36
|
+
readonly in: "query";
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
readonly httpBasic: {
|
|
40
|
+
readonly label: "HTTP Basic";
|
|
41
|
+
readonly payload: {
|
|
42
|
+
readonly type: "http";
|
|
43
|
+
readonly scheme: "basic";
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
readonly httpBearer: {
|
|
47
|
+
readonly label: "HTTP Bearer";
|
|
48
|
+
readonly payload: {
|
|
49
|
+
readonly type: "http";
|
|
50
|
+
readonly scheme: "bearer";
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
readonly oauth2Implicit: {
|
|
54
|
+
readonly label: "Oauth2 Implicit Flow";
|
|
55
|
+
readonly payload: {
|
|
56
|
+
readonly type: "oauth2";
|
|
57
|
+
readonly flow: {
|
|
58
|
+
readonly type: "implicit";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
readonly oauth2Password: {
|
|
63
|
+
readonly label: "Oauth2 Password Flow";
|
|
64
|
+
readonly payload: {
|
|
65
|
+
readonly type: "oauth2";
|
|
66
|
+
readonly flow: {
|
|
67
|
+
readonly type: "password";
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
readonly oauth2ClientCredentials: {
|
|
72
|
+
readonly label: "Oauth2 Client Credentials";
|
|
73
|
+
readonly payload: {
|
|
74
|
+
readonly type: "oauth2";
|
|
75
|
+
readonly flow: {
|
|
76
|
+
readonly type: "clientCredentials";
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
readonly oauth2AuthorizationFlow: {
|
|
81
|
+
readonly label: "Oauth2 Authorization Code";
|
|
82
|
+
readonly payload: {
|
|
83
|
+
readonly type: "oauth2";
|
|
84
|
+
readonly flow: {
|
|
85
|
+
readonly type: "authorizationCode";
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/** Options for the dropdown to add new auth */
|
|
91
|
+
export declare const ADD_AUTH_OPTIONS: SecuritySchemeOption[];
|
|
92
|
+
//# sourceMappingURL=new-auth-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"new-auth-options.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/consts/new-auth-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAA;AAG1F,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,qBAAqB,CAAA;CAChC,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,oBAAoB,EAAE,CAAA;CAChC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwEhB,CAAA;AAIV,+CAA+C;AAC/C,eAAO,MAAM,gBAAgB,EAAE,oBAAoB,EAOlD,CAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const t = {
|
|
2
|
+
apiKeyCookie: {
|
|
3
|
+
label: "API Key in Cookies",
|
|
4
|
+
payload: {
|
|
5
|
+
type: "apiKey",
|
|
6
|
+
in: "cookie"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
apiKeyHeader: {
|
|
10
|
+
label: "API Key in Headers",
|
|
11
|
+
payload: {
|
|
12
|
+
type: "apiKey",
|
|
13
|
+
in: "header"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
apiKeyQuery: {
|
|
17
|
+
label: "API Key in Query Params",
|
|
18
|
+
payload: {
|
|
19
|
+
type: "apiKey",
|
|
20
|
+
in: "query"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
httpBasic: {
|
|
24
|
+
label: "HTTP Basic",
|
|
25
|
+
payload: {
|
|
26
|
+
type: "http",
|
|
27
|
+
scheme: "basic"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
httpBearer: {
|
|
31
|
+
label: "HTTP Bearer",
|
|
32
|
+
payload: {
|
|
33
|
+
type: "http",
|
|
34
|
+
scheme: "bearer"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
oauth2Implicit: {
|
|
38
|
+
label: "Oauth2 Implicit Flow",
|
|
39
|
+
payload: {
|
|
40
|
+
type: "oauth2",
|
|
41
|
+
flow: {
|
|
42
|
+
type: "implicit"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
oauth2Password: {
|
|
47
|
+
label: "Oauth2 Password Flow",
|
|
48
|
+
payload: {
|
|
49
|
+
type: "oauth2",
|
|
50
|
+
flow: {
|
|
51
|
+
type: "password"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
oauth2ClientCredentials: {
|
|
56
|
+
label: "Oauth2 Client Credentials",
|
|
57
|
+
payload: {
|
|
58
|
+
type: "oauth2",
|
|
59
|
+
flow: {
|
|
60
|
+
type: "clientCredentials"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
oauth2AuthorizationFlow: {
|
|
65
|
+
label: "Oauth2 Authorization Code",
|
|
66
|
+
payload: {
|
|
67
|
+
type: "oauth2",
|
|
68
|
+
flow: {
|
|
69
|
+
type: "authorizationCode"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, l = Object.entries(t), o = l.map(
|
|
74
|
+
([a, e]) => ({
|
|
75
|
+
id: a,
|
|
76
|
+
...e,
|
|
77
|
+
labelWithoutId: e.label
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
export {
|
|
81
|
+
t as ADD_AUTH_DICT,
|
|
82
|
+
o as ADD_AUTH_OPTIONS
|
|
83
|
+
};
|
|
@@ -1,26 +1,13 @@
|
|
|
1
|
-
import type { SecuritySchemeOauth2
|
|
2
|
-
export type SecuritySchemeOptionBase = {
|
|
3
|
-
id: string;
|
|
4
|
-
label: string;
|
|
5
|
-
};
|
|
6
|
-
export type SecuritySchemeOptionOauth = SecuritySchemeOptionBase & {
|
|
7
|
-
flowKey: keyof SecuritySchemeOauth2['flows'];
|
|
8
|
-
uid: string;
|
|
9
|
-
};
|
|
10
|
-
/** Type for the dropdown options */
|
|
11
|
-
export type SecuritySchemeOption = {
|
|
12
|
-
id: string;
|
|
13
|
-
label: string;
|
|
14
|
-
} | SecuritySchemeOptionOauth;
|
|
1
|
+
import type { SecuritySchemeOauth2 } from '@scalar/oas-utils/entities/workspace/security';
|
|
15
2
|
/**
|
|
16
3
|
* Authorize oauth2 flow
|
|
17
4
|
*
|
|
18
5
|
* @returns the accessToken
|
|
19
6
|
*/
|
|
20
|
-
export declare const authorizeOauth2: (
|
|
7
|
+
export declare const authorizeOauth2: (scheme: SecuritySchemeOauth2) => Promise<string>;
|
|
21
8
|
/**
|
|
22
9
|
* Makes the BE authorization call to grab the token server to server
|
|
23
10
|
* Used for clientCredentials and authorizationCode
|
|
24
11
|
*/
|
|
25
|
-
export declare const authorizeServers: (
|
|
12
|
+
export declare const authorizeServers: (scheme: SecuritySchemeOauth2, code?: string) => Promise<string>;
|
|
26
13
|
//# 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,
|
|
1
|
+
{"version":3,"file":"oauth2.d.ts","sourceRoot":"","sources":["../../../../src/views/Request/libs/oauth2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAA;AAEzF;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAAY,oBAAoB,oBA2ExD,CAAA;AAEJ;;;GAGG;AACH,eAAO,MAAM,gBAAgB,WACnB,oBAAoB,SACrB,MAAM,KACZ,OAAO,CAAC,MAAM,CAwDhB,CAAA"}
|
|
@@ -1,51 +1,48 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
p(r).then(t).catch(o);
|
|
1
|
+
const p = (t) => new Promise((r, n) => {
|
|
2
|
+
if (t.flow.type === "clientCredentials" || t.flow.type === "password")
|
|
3
|
+
u(t).then(r).catch(n);
|
|
5
4
|
else {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
);
|
|
9
|
-
n.flowKey === "implicit" ? s.searchParams.set("response_type", "token") : n.flowKey === "authorizationCode" && s.searchParams.set("response_type", "code"), s.searchParams.set("client_id", e.clientId), s.searchParams.set("redirect_uri", e.redirectUri), s.searchParams.set("scope", d), s.searchParams.set("state", w);
|
|
10
|
-
const i = window.open(s, "openAuth2Window", "left=100,top=100,width=800,height=600");
|
|
5
|
+
const e = t.flow.selectedScopes.join(" "), a = (Math.random() + 1).toString(36).substring(7), o = new URL(t.flow.authorizationUrl);
|
|
6
|
+
t.flow.type === "implicit" ? o.searchParams.set("response_type", "token") : t.flow.type === "authorizationCode" && o.searchParams.set("response_type", "code"), o.searchParams.set("client_id", t.clientId), o.searchParams.set("redirect_uri", t.flow.redirectUri), o.searchParams.set("scope", e), o.searchParams.set("state", a);
|
|
7
|
+
const i = window.open(o, "openAuth2Window", "left=100,top=100,width=800,height=600");
|
|
11
8
|
if (i) {
|
|
12
|
-
const
|
|
13
|
-
var
|
|
14
|
-
let
|
|
9
|
+
const d = setInterval(function() {
|
|
10
|
+
var f;
|
|
11
|
+
let s = null, c = null;
|
|
15
12
|
try {
|
|
16
13
|
const l = new URL(i.location.href).searchParams;
|
|
17
|
-
|
|
14
|
+
s = l.get("access_token"), c = l.get("code");
|
|
18
15
|
} catch {
|
|
19
16
|
}
|
|
20
|
-
if (i.closed ||
|
|
21
|
-
if (clearInterval(
|
|
22
|
-
const l = (
|
|
23
|
-
|
|
24
|
-
} else
|
|
17
|
+
if (i.closed || s || c)
|
|
18
|
+
if (clearInterval(d), i.close(), s) {
|
|
19
|
+
const l = (f = i.location.href.match(/state=([^&]*)/)) == null ? void 0 : f[1];
|
|
20
|
+
s && l === a && r(s);
|
|
21
|
+
} else c ? u(t, c).then(r).catch(n) : (clearInterval(d), n(
|
|
25
22
|
new Error("Window was closed without granting authorization")
|
|
26
23
|
));
|
|
27
24
|
}, 200);
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
}),
|
|
31
|
-
if (!("clientSecret" in
|
|
27
|
+
}), u = async (t, r) => {
|
|
28
|
+
if (!("clientSecret" in t.flow))
|
|
32
29
|
throw new Error(
|
|
33
30
|
"Authorize Servers only works for Client Credentials or Authorization Code flow"
|
|
34
31
|
);
|
|
35
|
-
if (!
|
|
36
|
-
const
|
|
37
|
-
e.set("client_id",
|
|
32
|
+
if (!t.flow) throw new Error("OAuth2 flow was not defined");
|
|
33
|
+
const n = t.flow.selectedScopes.join(" "), e = new URLSearchParams();
|
|
34
|
+
e.set("client_id", t.clientId), e.set("scope", n), t.flow.clientSecret && e.set("client_secret", t.flow.clientSecret), "redirectUri" in t.flow && e.set("redirect_uri", t.flow.redirectUri), r && (e.set("code", r), e.set("grant_type", "authorization_code")), "secondValue" in t.flow ? (e.set("grant_type", "password"), e.set("username", t.flow.value), e.set("password", t.flow.secondValue)) : e.set("grant_type", "client_credentials");
|
|
38
35
|
try {
|
|
39
|
-
const
|
|
36
|
+
const a = {
|
|
40
37
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
41
38
|
};
|
|
42
|
-
|
|
43
|
-
const
|
|
39
|
+
t.clientId && t.flow.clientSecret && (a.Authorization = `Basic ${btoa(`${t.clientId}:${t.flow.clientSecret}`)}`);
|
|
40
|
+
const o = await fetch(t.flow.tokenUrl, {
|
|
44
41
|
method: "POST",
|
|
45
|
-
headers:
|
|
42
|
+
headers: a,
|
|
46
43
|
body: e
|
|
47
|
-
}), { access_token:
|
|
48
|
-
return
|
|
44
|
+
}), { access_token: w } = await o.json();
|
|
45
|
+
return w;
|
|
49
46
|
} catch {
|
|
50
47
|
throw new Error(
|
|
51
48
|
"Failed to get an access token. Please check your credentials."
|
|
@@ -53,6 +50,6 @@ const _ = (r, n) => new Promise((t, o) => {
|
|
|
53
50
|
}
|
|
54
51
|
};
|
|
55
52
|
export {
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
p as authorizeOauth2,
|
|
54
|
+
u as authorizeServers
|
|
58
55
|
};
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"rest",
|
|
19
19
|
"testing"
|
|
20
20
|
],
|
|
21
|
-
"version": "2.0.
|
|
21
|
+
"version": "2.0.35",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=18"
|
|
24
24
|
},
|
|
@@ -33,6 +33,10 @@
|
|
|
33
33
|
"import": "./dist/views/Request/libs/index.js",
|
|
34
34
|
"types": "./dist/views/Request/libs/index.d.ts"
|
|
35
35
|
},
|
|
36
|
+
"./views/Request/consts": {
|
|
37
|
+
"import": "./dist/views/Request/consts/index.js",
|
|
38
|
+
"types": "./dist/views/Request/consts/index.d.ts"
|
|
39
|
+
},
|
|
36
40
|
"./views/Request/components": {
|
|
37
41
|
"import": "./dist/views/Request/components/index.js",
|
|
38
42
|
"types": "./dist/views/Request/components/index.d.ts"
|
|
@@ -122,12 +126,12 @@
|
|
|
122
126
|
"vue": "^3.4.29",
|
|
123
127
|
"vue-router": "^4.3.0",
|
|
124
128
|
"zod": "^3.22.4",
|
|
125
|
-
"@scalar/components": "0.12.
|
|
126
|
-
"@scalar/oas-utils": "0.2.17",
|
|
127
|
-
"@scalar/object-utils": "1.1.5",
|
|
129
|
+
"@scalar/components": "0.12.22",
|
|
128
130
|
"@scalar/draggable": "0.1.3",
|
|
129
|
-
"@scalar/
|
|
131
|
+
"@scalar/oas-utils": "0.2.19",
|
|
132
|
+
"@scalar/object-utils": "1.1.5",
|
|
130
133
|
"@scalar/themes": "0.9.16",
|
|
134
|
+
"@scalar/use-codemirror": "0.11.8",
|
|
131
135
|
"@scalar/use-toasts": "0.7.4",
|
|
132
136
|
"@scalar/use-tooltip": "1.0.2"
|
|
133
137
|
},
|