@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.
Files changed (89) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/components/CodeInput/CodeInput.vue.js +2 -2
  3. package/dist/components/CommandPalette/CommandPaletteCollection.vue.d.ts.map +1 -1
  4. package/dist/components/CommandPalette/CommandPaletteCollection.vue.js +39 -31
  5. package/dist/components/CommandPalette/CommandPaletteExample.vue.d.ts.map +1 -1
  6. package/dist/components/CommandPalette/CommandPaletteExample.vue.js +65 -55
  7. package/dist/components/CommandPalette/CommandPaletteFolder.vue.d.ts.map +1 -1
  8. package/dist/components/CommandPalette/CommandPaletteFolder.vue.js +53 -44
  9. package/dist/components/CommandPalette/CommandPaletteImport.vue.d.ts.map +1 -1
  10. package/dist/components/CommandPalette/CommandPaletteImport.vue.js +42 -34
  11. package/dist/components/CommandPalette/CommandPaletteRequest.vue.d.ts.map +1 -1
  12. package/dist/components/CommandPalette/CommandPaletteRequest.vue.js +126 -70
  13. package/dist/components/CommandPalette/CommandPaletteWorkspace.vue.d.ts.map +1 -1
  14. package/dist/components/CommandPalette/CommandPaletteWorkspace.vue.js +37 -29
  15. package/dist/components/CommandPalette/TheCommandPalette.vue.d.ts.map +1 -1
  16. package/dist/components/CommandPalette/TheCommandPalette.vue.js +4 -4
  17. package/dist/components/CommandPalette/TheCommandPalette.vue2.js +97 -85
  18. package/dist/components/CommandPalette/handleKeyDown.d.ts +2 -0
  19. package/dist/components/CommandPalette/handleKeyDown.d.ts.map +1 -0
  20. package/dist/components/CommandPalette/handleKeyDown.js +7 -0
  21. package/dist/components/DataTable/DataTableInput.vue.d.ts +7 -0
  22. package/dist/components/DataTable/DataTableInput.vue.d.ts.map +1 -1
  23. package/dist/components/DataTable/DataTableInput.vue.js +3 -3
  24. package/dist/components/DataTable/DataTableInput.vue2.js +33 -31
  25. package/dist/components/DataTable/DataTableInputSelect.vue.d.ts +19 -3
  26. package/dist/components/DataTable/DataTableInputSelect.vue.d.ts.map +1 -1
  27. package/dist/components/DataTable/DataTableInputSelect.vue.js +37 -35
  28. package/dist/components/DataTable/index.d.ts +1 -0
  29. package/dist/components/DataTable/index.d.ts.map +1 -1
  30. package/dist/components/DataTable/index.js +6 -4
  31. package/dist/components/Form/Form.vue.js +1 -1
  32. package/dist/components/Search/SearchButton.vue.d.ts.map +1 -1
  33. package/dist/components/Search/SearchButton.vue.js +14 -16
  34. package/dist/components/SideNav/SideHelp.vue.d.ts +3 -0
  35. package/dist/components/SideNav/SideHelp.vue.d.ts.map +1 -0
  36. package/dist/components/SideNav/SideHelp.vue.js +125 -0
  37. package/dist/components/SideNav/SideHelp.vue2.js +4 -0
  38. package/dist/components/SideNav/SideNav.vue.d.ts.map +1 -1
  39. package/dist/components/SideNav/SideNav.vue.js +3 -3
  40. package/dist/components/SideNav/SideNav.vue2.js +28 -24
  41. package/dist/components/Sidebar/SidebarButton.vue.js +1 -1
  42. package/dist/components/Sidebar/SidebarList.vue.d.ts.map +1 -1
  43. package/dist/components/Sidebar/SidebarList.vue.js +1 -1
  44. package/dist/components/Sidebar/SidebarListElement.vue.d.ts.map +1 -1
  45. package/dist/components/Sidebar/SidebarListElement.vue.js +1 -1
  46. package/dist/components/Sidebar/SidebarListElement.vue2.js +9 -9
  47. package/dist/constants.d.ts +0 -4
  48. package/dist/constants.d.ts.map +1 -1
  49. package/dist/constants.js +2 -2
  50. package/dist/layouts/App/create-api-client-app.d.ts +512 -603
  51. package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
  52. package/dist/layouts/Modal/api-client-modal.d.ts +1036 -1218
  53. package/dist/layouts/Modal/api-client-modal.d.ts.map +1 -1
  54. package/dist/libs/create-client.d.ts +513 -603
  55. package/dist/libs/create-client.d.ts.map +1 -1
  56. package/dist/libs/create-client.js +58 -68
  57. package/dist/libs/local-storage.js +5 -5
  58. package/dist/libs/sendRequest.d.ts +3 -5
  59. package/dist/libs/sendRequest.d.ts.map +1 -1
  60. package/dist/libs/sendRequest.js +73 -67
  61. package/dist/store/workspace.d.ts +1037 -1219
  62. package/dist/store/workspace.d.ts.map +1 -1
  63. package/dist/store/workspace.js +350 -277
  64. package/dist/style.css +1 -1
  65. package/dist/views/Request/Request.vue.d.ts.map +1 -1
  66. package/dist/views/Request/Request.vue.js +1 -1
  67. package/dist/views/Request/Request.vue2.js +101 -102
  68. package/dist/views/Request/RequestSection/RequestAuth.vue.d.ts.map +1 -1
  69. package/dist/views/Request/RequestSection/RequestAuth.vue.js +270 -177
  70. package/dist/views/Request/RequestSection/RequestSection.vue.d.ts.map +1 -1
  71. package/dist/views/Request/RequestSection/RequestSection.vue.js +52 -42
  72. package/dist/views/Request/RequestSidebarItemMenu.vue.d.ts.map +1 -1
  73. package/dist/views/Request/RequestSidebarItemMenu.vue.js +141 -104
  74. package/dist/views/Request/components/OAuth2.vue.d.ts +3 -9
  75. package/dist/views/Request/components/OAuth2.vue.d.ts.map +1 -1
  76. package/dist/views/Request/components/OAuth2.vue.js +141 -112
  77. package/dist/views/Request/components/OAuthScopesInput.vue.d.ts +2 -6
  78. package/dist/views/Request/components/OAuthScopesInput.vue.d.ts.map +1 -1
  79. package/dist/views/Request/components/OAuthScopesInput.vue.js +35 -39
  80. package/dist/views/Request/consts/index.d.ts +2 -0
  81. package/dist/views/Request/consts/index.d.ts.map +1 -0
  82. package/dist/views/Request/consts/index.js +5 -0
  83. package/dist/views/Request/consts/new-auth-options.d.ts +92 -0
  84. package/dist/views/Request/consts/new-auth-options.d.ts.map +1 -0
  85. package/dist/views/Request/consts/new-auth-options.js +83 -0
  86. package/dist/views/Request/libs/oauth2.d.ts +3 -16
  87. package/dist/views/Request/libs/oauth2.d.ts.map +1 -1
  88. package/dist/views/Request/libs/oauth2.js +28 -31
  89. 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 c, createElementVNode as l, createVNode as a, toDisplayString as p, createElementBlock as g, Fragment as b, renderList as y } from "vue";
2
- import { Disclosure as C, DisclosureButton as F, DisclosurePanel as k } from "@headlessui/vue";
3
- import { ScalarIcon as D } from "@scalar/components";
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 $ from "../../../components/DataTable/DataTableCheckbox.vue.js";
7
- const B = { class: "flex h-full w-full" }, M = /* @__PURE__ */ l("div", { class: "text-c-2 min-w-[100px] items-center pl-2 h-full border-r-1/2" }, [
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), O = { class: "flex-1 text-c-3" }, j = {
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
- }, E = { class: "font-code text-xs" }, A = /* @__PURE__ */ S({
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 s = v, x = f(
19
+ const n = v, x = f(
21
20
  () => {
22
21
  var e;
23
- return Object.entries(((e = s.activeFlow) == null ? void 0 : e.scopes) ?? {}).map(([n, t]) => ({
24
- id: n,
25
- label: n,
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 = s.activeFlow) == null ? void 0 : e.selectedScopes) || [];
30
+ return ((e = n.activeFlow) == null ? void 0 : e.selectedScopes) || [];
32
31
  });
33
- function w(e, n) {
34
- n ? s.updateScheme(`flows.${s.schemeModel.flowKey}.selectedScopes`, [
35
- ...r.value,
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, n) => (m(), h(o(_), { class: "items-center min-h-8 h-auto" }, {
43
- default: c(() => [
44
- l("div", B, [
45
- M,
46
- a(o(C), {
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: c(() => [
51
- a(o(F), { 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" }, {
52
- default: c(({ open: t }) => {
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", O, " 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),
56
- a(o(D), {
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
- a(o(k), { as: "template" }, {
66
- default: c(() => [
67
- l("table", j, [
68
- (m(!0), g(b, null, y(x.value, ({ id: t, label: i, description: u }) => (m(), h(o(V), {
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: c(() => [
74
- a(o(_), { class: "w-full px-2 py-1.5 hover:bg-b-2 cursor-pointer" }, {
75
- default: c(() => [
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", E, p(i), 1),
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
- a(o($), {
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
- A as default
101
+ P as default
106
102
  };
@@ -0,0 +1,2 @@
1
+ export * from './new-auth-options.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -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,5 @@
1
+ import { ADD_AUTH_DICT as T, ADD_AUTH_OPTIONS as _ } from "./new-auth-options.js";
2
+ export {
3
+ T as ADD_AUTH_DICT,
4
+ _ as ADD_AUTH_OPTIONS
5
+ };
@@ -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, 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.33",
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.20",
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/use-codemirror": "0.11.8",
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
  },