@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.
Files changed (57) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/components/DataTable/DataTableInput.vue.d.ts +7 -0
  3. package/dist/components/DataTable/DataTableInput.vue.d.ts.map +1 -1
  4. package/dist/components/DataTable/DataTableInput.vue.js +3 -3
  5. package/dist/components/DataTable/DataTableInput.vue2.js +33 -31
  6. package/dist/components/DataTable/DataTableInputSelect.vue.d.ts +19 -3
  7. package/dist/components/DataTable/DataTableInputSelect.vue.d.ts.map +1 -1
  8. package/dist/components/DataTable/DataTableInputSelect.vue.js +37 -35
  9. package/dist/components/DataTable/index.d.ts +1 -0
  10. package/dist/components/DataTable/index.d.ts.map +1 -1
  11. package/dist/components/DataTable/index.js +6 -4
  12. package/dist/components/SideNav/SideHelp.vue.d.ts +3 -0
  13. package/dist/components/SideNav/SideHelp.vue.d.ts.map +1 -0
  14. package/dist/components/SideNav/SideHelp.vue.js +125 -0
  15. package/dist/components/SideNav/SideHelp.vue2.js +4 -0
  16. package/dist/components/SideNav/SideNav.vue.d.ts.map +1 -1
  17. package/dist/components/SideNav/SideNav.vue.js +3 -3
  18. package/dist/components/SideNav/SideNav.vue2.js +28 -24
  19. package/dist/layouts/App/create-api-client-app.d.ts +512 -603
  20. package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
  21. package/dist/layouts/Modal/api-client-modal.d.ts +1036 -1218
  22. package/dist/layouts/Modal/api-client-modal.d.ts.map +1 -1
  23. package/dist/libs/create-client.d.ts +513 -603
  24. package/dist/libs/create-client.d.ts.map +1 -1
  25. package/dist/libs/create-client.js +58 -68
  26. package/dist/libs/local-storage.js +5 -5
  27. package/dist/libs/sendRequest.d.ts +2 -5
  28. package/dist/libs/sendRequest.d.ts.map +1 -1
  29. package/dist/libs/sendRequest.js +60 -63
  30. package/dist/store/workspace.d.ts +1037 -1219
  31. package/dist/store/workspace.d.ts.map +1 -1
  32. package/dist/store/workspace.js +350 -277
  33. package/dist/style.css +1 -1
  34. package/dist/views/Request/Request.vue.js +2 -2
  35. package/dist/views/Request/Request.vue2.js +22 -22
  36. package/dist/views/Request/RequestSection/RequestAuth.vue.d.ts.map +1 -1
  37. package/dist/views/Request/RequestSection/RequestAuth.vue.js +270 -177
  38. package/dist/views/Request/RequestSection/RequestSection.vue.d.ts.map +1 -1
  39. package/dist/views/Request/RequestSection/RequestSection.vue.js +52 -42
  40. package/dist/views/Request/RequestSidebarItemMenu.vue.d.ts.map +1 -1
  41. package/dist/views/Request/RequestSidebarItemMenu.vue.js +141 -104
  42. package/dist/views/Request/components/OAuth2.vue.d.ts +3 -9
  43. package/dist/views/Request/components/OAuth2.vue.d.ts.map +1 -1
  44. package/dist/views/Request/components/OAuth2.vue.js +141 -112
  45. package/dist/views/Request/components/OAuthScopesInput.vue.d.ts +2 -6
  46. package/dist/views/Request/components/OAuthScopesInput.vue.d.ts.map +1 -1
  47. package/dist/views/Request/components/OAuthScopesInput.vue.js +35 -39
  48. package/dist/views/Request/consts/index.d.ts +2 -0
  49. package/dist/views/Request/consts/index.d.ts.map +1 -0
  50. package/dist/views/Request/consts/index.js +5 -0
  51. package/dist/views/Request/consts/new-auth-options.d.ts +92 -0
  52. package/dist/views/Request/consts/new-auth-options.d.ts.map +1 -0
  53. package/dist/views/Request/consts/new-auth-options.js +83 -0
  54. package/dist/views/Request/libs/oauth2.d.ts +3 -16
  55. package/dist/views/Request/libs/oauth2.d.ts.map +1 -1
  56. package/dist/views/Request/libs/oauth2.js +28 -31
  57. 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, SelectedSchemeOauth2 } from '@scalar/oas-utils/entities/workspace/security';
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: (activeScheme: SelectedSchemeOauth2, schemeModel: SecuritySchemeOptionOauth) => Promise<string>;
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: (activeScheme: SelectedSchemeOauth2, code?: string) => Promise<string>;
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,EACV,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,+CAA+C,CAAA;AAEtD,MAAM,MAAM,wBAAwB,GAAG;IACrC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AACD,MAAM,MAAM,yBAAyB,GAAG,wBAAwB,GAAG;IACjE,OAAO,EAAE,MAAM,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAC5C,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,oCAAoC;AACpC,MAAM,MAAM,oBAAoB,GAC5B;IACE,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;CACd,GACD,yBAAyB,CAAA;AAE7B;;;;GAIG;AACH,eAAO,MAAM,eAAe,iBACZ,oBAAoB,eACrB,yBAAyB,oBAgFpC,CAAA;AAEJ;;;GAGG;AACH,eAAO,MAAM,gBAAgB,iBACb,oBAAoB,SAC3B,MAAM,KACZ,OAAO,CAAC,MAAM,CAwDhB,CAAA"}
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 _ = (r, n) => new Promise((t, o) => {
2
- const { flow: a, scheme: e } = r;
3
- if (n.flowKey === "clientCredentials" || n.flowKey === "password")
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 d = a.selectedScopes.join(" "), w = (Math.random() + 1).toString(36).substring(7), s = new URL(
7
- "authorizationUrl" in a ? a.authorizationUrl : a.tokenUrl
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 f = setInterval(function() {
13
- var u;
14
- let c = null, h = null;
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
- c = l.get("access_token"), h = l.get("code");
14
+ s = l.get("access_token"), c = l.get("code");
18
15
  } catch {
19
16
  }
20
- if (i.closed || c || h)
21
- if (clearInterval(f), i.close(), c) {
22
- const l = (u = i.location.href.match(/state=([^&]*)/)) == null ? void 0 : u[1];
23
- c && l === w && t(c);
24
- } else h ? p(r, h).then(t).catch(o) : (clearInterval(f), o(
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
- }), p = async (r, n) => {
31
- if (!("clientSecret" in r.flow))
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 (!r.flow) throw new Error("OAuth2 flow was not defined");
36
- const { flow: t, scheme: o } = r, a = t.selectedScopes.join(" "), e = new URLSearchParams();
37
- e.set("client_id", o.clientId), e.set("scope", a), t.clientSecret && e.set("client_secret", t.clientSecret), o.redirectUri && e.set("redirect_uri", o.redirectUri), n && (e.set("code", n), e.set("grant_type", "authorization_code")), "secondValue" in t ? (e.set("grant_type", "password"), e.set("username", t.value), e.set("password", t.secondValue)) : e.set("grant_type", "client_credentials");
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 d = {
36
+ const a = {
40
37
  "Content-Type": "application/x-www-form-urlencoded"
41
38
  };
42
- o.clientId && t.clientSecret && (d.Authorization = `Basic ${btoa(`${o.clientId}:${t.clientSecret}`)}`);
43
- const w = await fetch(t.tokenUrl, {
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: d,
42
+ headers: a,
46
43
  body: e
47
- }), { access_token: s } = await w.json();
48
- return s;
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
- _ as authorizeOauth2,
57
- p as authorizeServers
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.34",
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.21",
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-tooltip": "1.0.2",
132
- "@scalar/use-toasts": "0.7.4"
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",