@scalar/api-client 2.0.34 → 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 +11 -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/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/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 +2 -5
- package/dist/libs/sendRequest.d.ts.map +1 -1
- package/dist/libs/sendRequest.js +60 -63
- 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.js +2 -2
- package/dist/views/Request/Request.vue2.js +22 -22
- 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 +10 -6
|
@@ -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,14 +126,14 @@
|
|
|
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.18",
|
|
127
|
-
"@scalar/object-utils": "1.1.5",
|
|
129
|
+
"@scalar/components": "0.12.22",
|
|
128
130
|
"@scalar/draggable": "0.1.3",
|
|
131
|
+
"@scalar/oas-utils": "0.2.19",
|
|
132
|
+
"@scalar/object-utils": "1.1.5",
|
|
129
133
|
"@scalar/themes": "0.9.16",
|
|
130
134
|
"@scalar/use-codemirror": "0.11.8",
|
|
131
|
-
"@scalar/use-
|
|
132
|
-
"@scalar/use-
|
|
135
|
+
"@scalar/use-toasts": "0.7.4",
|
|
136
|
+
"@scalar/use-tooltip": "1.0.2"
|
|
133
137
|
},
|
|
134
138
|
"devDependencies": {
|
|
135
139
|
"@types/content-type": "^1.1.8",
|