@scalar/api-client 2.2.4 → 2.2.7

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 (93) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/dist/components/AddressBar/AddressBar.vue.js +2 -2
  3. package/dist/components/AddressBar/AddressBar.vue2.js +1 -1
  4. package/dist/components/AddressBar/AddressBarServer.vue.d.ts.map +1 -1
  5. package/dist/components/AddressBar/AddressBarServer.vue.js +28 -28
  6. package/dist/components/CommandPalette/CommandPaletteExample.vue.js +1 -1
  7. package/dist/components/CommandPalette/CommandPaletteRequest.vue.d.ts.map +1 -1
  8. package/dist/components/CommandPalette/CommandPaletteRequest.vue.js +41 -41
  9. package/dist/components/CommandPalette/CommandPaletteServer.vue.js +2 -2
  10. package/dist/components/CommandPalette/CommandPaletteTag.vue.js +5 -5
  11. package/dist/components/DataTable/DataTableCheckbox.vue.d.ts.map +1 -1
  12. package/dist/components/DataTable/DataTableCheckbox.vue.js +5 -6
  13. package/dist/components/DataTable/DataTableInputSelect.vue.d.ts.map +1 -1
  14. package/dist/components/DataTable/DataTableInputSelect.vue.js +8 -8
  15. package/dist/components/EnvironmentSelector/EnvironmentSelector.vue.d.ts.map +1 -1
  16. package/dist/components/EnvironmentSelector/EnvironmentSelector.vue.js +9 -10
  17. package/dist/components/HttpMethod/HttpMethod.vue.d.ts.map +1 -1
  18. package/dist/components/HttpMethod/HttpMethod.vue.js +2 -2
  19. package/dist/components/HttpMethod/HttpMethod.vue2.js +24 -25
  20. package/dist/components/HttpMethod/index.d.ts +0 -1
  21. package/dist/components/HttpMethod/index.d.ts.map +1 -1
  22. package/dist/components/HttpMethod/index.js +2 -4
  23. package/dist/components/ImportCollection/ImportCollectionModal.vue.d.ts.map +1 -1
  24. package/dist/components/ImportCollection/ImportCollectionModal.vue.js +121 -103
  25. package/dist/components/ImportCollection/WorkspaceSelector.vue.d.ts.map +1 -1
  26. package/dist/components/ImportCollection/WorkspaceSelector.vue.js +24 -26
  27. package/dist/components/ImportCollection/hooks/useUrlPrefetcher.d.ts +6 -0
  28. package/dist/components/ImportCollection/hooks/useUrlPrefetcher.d.ts.map +1 -1
  29. package/dist/components/ImportCollection/hooks/useUrlPrefetcher.js +28 -23
  30. package/dist/components/OpenApiClientButton.vue.d.ts +1 -0
  31. package/dist/components/OpenApiClientButton.vue.d.ts.map +1 -1
  32. package/dist/components/OpenApiClientButton.vue.js +2 -2
  33. package/dist/components/OpenApiClientButton.vue2.js +21 -15
  34. package/dist/components/Search/useSearch.d.ts.map +1 -1
  35. package/dist/components/Search/useSearch.js +45 -41
  36. package/dist/components/ViewLayout/ViewLayoutCollapse.vue.d.ts.map +1 -1
  37. package/dist/components/ViewLayout/ViewLayoutCollapse.vue.js +5 -6
  38. package/dist/layouts/App/create-api-client-app.d.ts +1 -0
  39. package/dist/layouts/App/create-api-client-app.d.ts.map +1 -1
  40. package/dist/layouts/Modal/ApiClientModal.vue.d.ts.map +1 -1
  41. package/dist/layouts/Modal/ApiClientModal.vue.js +2 -2
  42. package/dist/layouts/Modal/ApiClientModal.vue2.js +28 -23
  43. package/dist/layouts/Modal/create-api-client-modal.d.ts +2 -0
  44. package/dist/layouts/Modal/create-api-client-modal.d.ts.map +1 -1
  45. package/dist/layouts/Web/create-api-client-web.d.ts +1 -0
  46. package/dist/layouts/Web/create-api-client-web.d.ts.map +1 -1
  47. package/dist/libs/create-client.d.ts +3 -1
  48. package/dist/libs/create-client.d.ts.map +1 -1
  49. package/dist/libs/create-client.js +50 -48
  50. package/dist/store/store.d.ts +3 -1
  51. package/dist/store/store.d.ts.map +1 -1
  52. package/dist/store/store.js +47 -45
  53. package/dist/style.css +1 -1
  54. package/dist/views/Cookies/Cookies.vue.d.ts.map +1 -1
  55. package/dist/views/Cookies/Cookies.vue2.js +18 -20
  56. package/dist/views/Environment/EnvironmentVariableDropdown.vue.d.ts.map +1 -1
  57. package/dist/views/Environment/EnvironmentVariableDropdown.vue.js +63 -60
  58. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.d.ts.map +1 -1
  59. package/dist/views/Request/RequestSection/RequestAuth/OAuth2.vue.js +20 -19
  60. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.d.ts.map +1 -1
  61. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue.js +1 -1
  62. package/dist/views/Request/RequestSection/RequestAuth/RequestAuth.vue2.js +84 -86
  63. package/dist/views/Request/RequestSection/RequestBody.vue.d.ts.map +1 -1
  64. package/dist/views/Request/RequestSection/RequestBody.vue.js +2 -2
  65. package/dist/views/Request/RequestSection/RequestBody.vue2.js +37 -36
  66. package/dist/views/Request/RequestSidebar.vue.d.ts.map +1 -1
  67. package/dist/views/Request/RequestSidebar.vue.js +3 -3
  68. package/dist/views/Request/RequestSidebar.vue2.js +60 -61
  69. package/dist/views/Request/RequestSidebarItem.vue.d.ts.map +1 -1
  70. package/dist/views/Request/RequestSidebarItem.vue.js +1 -1
  71. package/dist/views/Request/RequestSidebarItem.vue2.js +187 -195
  72. package/dist/views/Request/RequestSubpageHeader.vue.d.ts.map +1 -1
  73. package/dist/views/Request/RequestSubpageHeader.vue.js +3 -3
  74. package/dist/views/Request/RequestSubpageHeader.vue2.js +34 -36
  75. package/dist/views/Request/ResponseSection/ResponseBodyPreview.vue.d.ts.map +1 -1
  76. package/dist/views/Request/ResponseSection/ResponseBodyPreview.vue.js +1 -1
  77. package/dist/views/Request/ResponseSection/ResponseBodyPreview.vue2.js +5 -5
  78. package/dist/views/Request/ResponseSection/ResponseEmpty.vue.d.ts.map +1 -1
  79. package/dist/views/Request/ResponseSection/ResponseEmpty.vue.js +2 -2
  80. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +30 -25
  81. package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.d.ts.map +1 -1
  82. package/dist/views/Request/ResponseSection/ResponseMetaInformation.vue.js +41 -30
  83. package/dist/views/Request/components/WorkspaceDropdown.vue.d.ts.map +1 -1
  84. package/dist/views/Request/components/WorkspaceDropdown.vue.js +3 -5
  85. package/dist/views/Request/libs/live-sync.d.ts.map +1 -1
  86. package/dist/views/Request/libs/live-sync.js +77 -78
  87. package/dist/views/Request/libs/oauth2.d.ts +6 -2
  88. package/dist/views/Request/libs/oauth2.d.ts.map +1 -1
  89. package/dist/views/Request/libs/oauth2.js +43 -37
  90. package/package.json +10 -11
  91. package/dist/components/HttpMethod/helpers.d.ts +0 -4
  92. package/dist/components/HttpMethod/helpers.d.ts.map +0 -1
  93. package/dist/components/HttpMethod/helpers.js +0 -5
@@ -1,26 +1,25 @@
1
- import { isHTTPMethod as D } from "../../../components/HttpMethod/helpers.js";
2
- import { collectionSchema as b, requestSchema as O, serverSchema as V, tagSchema as M, securitySchemeSchema as S, createExampleFromRequest as H } from "@scalar/oas-utils/entities/spec";
3
- import { schemaModel as R } from "@scalar/oas-utils/helpers";
4
- import { getNestedValue as Z } from "@scalar/object-utils/nested";
1
+ import { collectionSchema as b, requestSchema as O, serverSchema as V, tagSchema as M, securitySchemeSchema as S, createExampleFromRequest as D } from "@scalar/oas-utils/entities/spec";
2
+ import { isHttpMethod as H, schemaModel as R } from "@scalar/oas-utils/helpers";
3
+ import { getNestedValue as N } from "@scalar/object-utils/nested";
5
4
  import j from "microdiff";
6
5
  import { z as i } from "zod";
7
6
  const x = (e, s = []) => {
8
7
  const t = [];
9
8
  let a = !1;
10
- for (let n = 0; n < e.length; n++) {
9
+ for (let r = 0; r < e.length; r++) {
11
10
  if (a) {
12
11
  a = !1;
13
12
  continue;
14
13
  }
15
- const r = e[n], u = e[n + 1];
14
+ const n = e[r], u = e[r + 1];
16
15
  if (s.length)
17
- r.path = [...s, ...r.path], u && (u.path = [...s, ...u.path]);
18
- else if (r.path[0] !== "paths") {
19
- t.push(r);
16
+ n.path = [...s, ...n.path], u && (u.path = [...s, ...u.path]);
17
+ else if (n.path[0] !== "paths") {
18
+ t.push(n);
20
19
  continue;
21
20
  }
22
- if (r.type === "REMOVE" && (u == null ? void 0 : u.type) === "CREATE") {
23
- const [, l, p] = r.path, [, o, h] = u.path, c = ["paths", o];
21
+ if (n.type === "REMOVE" && (u == null ? void 0 : u.type) === "CREATE") {
22
+ const [, l, p] = n.path, [, o, h] = u.path, c = ["paths", o];
24
23
  if (l !== o && t.push({
25
24
  type: "CHANGE",
26
25
  path: ["paths", "path"],
@@ -32,20 +31,20 @@ const x = (e, s = []) => {
32
31
  oldValue: p,
33
32
  value: h
34
33
  }), c.push(h)), s.length === 0) {
35
- const y = j(r.oldValue, u.value);
34
+ const y = j(n.oldValue, u.value);
36
35
  if (y.length) {
37
- const f = x(y, c);
38
- t.push(...f);
36
+ const E = x(y, c);
37
+ t.push(...E);
39
38
  }
40
39
  }
41
40
  a = !0;
42
- } else r.type === "CREATE" && r.path.length > 3 && typeof r.path.at(-1) != "number" ? t.push({ ...r, type: "CHANGE", oldValue: void 0 }) : r.type === "REMOVE" && r.path.length > 3 && typeof r.path.at(-1) != "number" ? t.push({ ...r, type: "CHANGE", value: void 0 }) : t.push(r);
41
+ } else n.type === "CREATE" && n.path.length > 3 && typeof n.path.at(-1) != "number" ? t.push({ ...n, type: "CHANGE", oldValue: void 0 }) : n.type === "REMOVE" && n.path.length > 3 && typeof n.path.at(-1) != "number" ? t.push({ ...n, type: "CHANGE", value: void 0 }) : t.push(n);
43
42
  }
44
43
  return t;
45
44
  }, v = (e, s, t) => {
46
45
  for (const a of e) {
47
- const n = s[a];
48
- if (t(n)) return n;
46
+ const r = s[a];
47
+ if (t(r)) return r;
49
48
  }
50
49
  return null;
51
50
  }, d = (e) => e instanceof i.ZodOptional ? d(e.unwrap()) : e instanceof i.ZodDefault ? d(e._def.innerType) : e, G = (e, s) => {
@@ -75,18 +74,18 @@ const x = (e, s = []) => {
75
74
  }, m = (e, s) => {
76
75
  const t = G(e, s.path);
77
76
  if (!t) return null;
78
- const a = s.path.join("."), n = s.path.slice(0, -1).join(".");
77
+ const a = s.path.join("."), r = s.path.slice(0, -1).join(".");
79
78
  if (s.type === "REMOVE")
80
79
  return {
81
80
  path: a,
82
- pathMinusOne: n,
81
+ pathMinusOne: r,
83
82
  value: void 0
84
83
  };
85
- const r = R(s.value, t, !1);
86
- return r ? {
84
+ const n = R(s.value, t, !1);
85
+ return n ? {
87
86
  path: a,
88
- pathMinusOne: n,
89
- value: r
87
+ pathMinusOne: r,
88
+ value: n
90
89
  } : null;
91
90
  }, K = (e, { activeCollection: s }, { collectionMutators: t }) => {
92
91
  if (!s.value) return !1;
@@ -96,13 +95,13 @@ const x = (e, s = []) => {
96
95
  path: e.path
97
96
  });
98
97
  if (!a) return !1;
99
- const n = [
100
- ...Z(s.value, a.pathMinusOne)
98
+ const r = [
99
+ ...N(s.value, a.pathMinusOne)
101
100
  ];
102
- e.type === "CREATE" ? n.push(a.value) : e.type === "REMOVE" && n.pop(), t.edit(
101
+ e.type === "CREATE" ? r.push(a.value) : e.type === "REMOVE" && r.pop(), t.edit(
103
102
  s.value.uid,
104
103
  a.pathMinusOne,
105
- n
104
+ r
106
105
  );
107
106
  } else {
108
107
  const a = m(b, e);
@@ -114,90 +113,90 @@ const x = (e, s = []) => {
114
113
  );
115
114
  }
116
115
  return !0;
117
- }, T = (e, s) => {
118
- const { requests: t, requestExamples: a, requestExampleMutators: n } = s, r = t[e];
119
- r == null || r.examples.forEach((u) => {
120
- const l = H(
121
- r,
116
+ }, Z = (e, s) => {
117
+ const { requests: t, requestExamples: a, requestExampleMutators: r } = s, n = t[e];
118
+ n == null || n.examples.forEach((u) => {
119
+ const l = D(
120
+ n,
122
121
  a[u].name
123
122
  );
124
- l && n.set({
123
+ l && r.set({
125
124
  ...l,
126
125
  uid: u
127
126
  });
128
127
  });
129
128
  }, L = (e, { activeCollection: s }, t) => {
130
129
  if (!s.value) return !1;
131
- const { requests: a, requestMutators: n } = t, [, r, u, ...l] = e.path;
132
- if (r === "path" && e.type === "CHANGE")
130
+ const { requests: a, requestMutators: r } = t, [, n, u, ...l] = e.path;
131
+ if (n === "path" && e.type === "CHANGE")
133
132
  s.value.requests.forEach((p) => {
134
- a[p].path === e.oldValue && n.edit(p, "path", e.value);
133
+ a[p].path === e.oldValue && r.edit(p, "path", e.value);
135
134
  });
136
135
  else if (u === "method" && e.type === "CHANGE")
137
136
  s.value.requests.forEach((p) => {
138
- a[p].method === e.oldValue && a[p].path === r && n.edit(p, "method", e.value);
137
+ a[p].method === e.oldValue && a[p].path === n && r.edit(p, "method", e.value);
139
138
  });
140
139
  else if (e.type !== "CHANGE" && typeof l.at(-1) == "number") {
141
140
  const p = v(
142
141
  s.value.requests,
143
142
  a,
144
- (c) => c.path === r && c.method === u
143
+ (c) => c.path === n && c.method === u
145
144
  ), o = m(O, {
146
145
  ...e,
147
146
  path: e.path.slice(3)
148
147
  });
149
148
  if (!p || !o) return !1;
150
- const h = [...Z(p, o.pathMinusOne)];
151
- e.type === "CREATE" ? h.push(o.value) : e.type === "REMOVE" && h.pop(), n.edit(p.uid, o.pathMinusOne, h), (e.path[3] === "parameters" || e.path[3] === "requestBody") && T(p.uid, t);
149
+ const h = [...N(p, o.pathMinusOne)];
150
+ e.type === "CREATE" ? h.push(o.value) : e.type === "REMOVE" && h.pop(), r.edit(p.uid, o.pathMinusOne, h), (e.path[3] === "parameters" || e.path[3] === "requestBody") && Z(p.uid, t);
152
151
  } else if (e.type === "CREATE") {
153
- const [[p, o]] = Object.entries(e.value), h = u ? e.value : o, c = u || p, y = V.array().parse(h.servers ?? []), { security: f, ...N } = h, g = {
154
- ...N,
155
- method: D(c) ? c : "get",
156
- path: r,
152
+ const [[p, o]] = Object.entries(e.value), h = u ? e.value : o, c = u || p, y = V.array().parse(h.servers ?? []), { security: E, ...T } = h, g = {
153
+ ...T,
154
+ method: H(c) ? c : "get",
155
+ path: n,
157
156
  parameters: h.parameters ?? [],
158
- servers: y.map((E) => E.uid)
157
+ servers: y.map((f) => f.uid)
159
158
  };
160
- f != null && f.length && (g.security = f.map((E) => {
161
- if (Object.keys(E).length) {
162
- const [A] = Object.keys(E);
159
+ E != null && E.length && (g.security = E.map((f) => {
160
+ if (Object.keys(f).length) {
161
+ const [A] = Object.keys(f);
163
162
  return {
164
- [A]: E[A]
163
+ [A]: f[A]
165
164
  };
166
- } else return E;
165
+ } else return f;
167
166
  }));
168
167
  const q = R(g, O, !1);
169
168
  if (!q) return !1;
170
- n.add(q, s.value.uid);
169
+ r.add(q, s.value.uid);
171
170
  } else if (e.type === "REMOVE") {
172
171
  const p = v(
173
172
  s.value.requests,
174
173
  a,
175
- (o) => o.path === r && o.method === u
174
+ (o) => o.path === n && o.method === u
176
175
  );
177
176
  if (!p) return !1;
178
- n.delete(p, s.value.uid);
177
+ r.delete(p, s.value.uid);
179
178
  } else if (e.type === "CHANGE") {
180
179
  const p = v(
181
180
  s.value.requests,
182
181
  a,
183
- (h) => h.path === r && h.method === u
182
+ (h) => h.path === n && h.method === u
184
183
  ), o = m(O, { ...e, path: l });
185
184
  if (!p || !o) return !1;
186
- n.edit(p.uid, o.path, o.value), (e.path[3] === "parameters" || e.path[3] === "requestBody") && T(p.uid, t);
185
+ r.edit(p.uid, o.path, o.value), (e.path[3] === "parameters" || e.path[3] === "requestBody") && Z(p.uid, t);
187
186
  }
188
187
  return !0;
189
- }, W = (e, { activeCollection: s }, { servers: t, serverMutators: a }) => {
188
+ }, P = (e, { activeCollection: s }, { servers: t, serverMutators: a }) => {
190
189
  if (!s.value) return !1;
191
- const [, n, ...r] = e.path;
192
- if (r != null && r.length) {
193
- const u = s.value.servers[n], l = t[u], p = m(V, { ...e, path: r });
190
+ const [, r, ...n] = e.path;
191
+ if (n != null && n.length) {
192
+ const u = s.value.servers[r], l = t[u], p = m(V, { ...e, path: n });
194
193
  if (!l || !p) return !1;
195
- const h = e.type === "REMOVE" && r[r.length - 1] === "variables" ? {} : p.value;
194
+ const h = e.type === "REMOVE" && n[n.length - 1] === "variables" ? {} : p.value;
196
195
  a.edit(u, p.path, h);
197
196
  } else if (e.type === "REMOVE") {
198
- if (!s.value.servers[n]) return !1;
197
+ if (!s.value.servers[r]) return !1;
199
198
  a.delete(
200
- s.value.servers[n],
199
+ s.value.servers[r],
201
200
  s.value.uid
202
201
  );
203
202
  } else if (e.type === "CREATE") {
@@ -206,15 +205,15 @@ const x = (e, s = []) => {
206
205
  a.add(u, s.value.uid);
207
206
  }
208
207
  return !0;
209
- }, I = (e, { activeCollection: s }, { tags: t, tagMutators: a }) => {
208
+ }, W = (e, { activeCollection: s }, { tags: t, tagMutators: a }) => {
210
209
  if (!s.value) return !1;
211
- const [, n, ...r] = e.path;
212
- if (r != null && r.length) {
213
- const u = s.value.tags[n], l = t[u], p = m(M, { ...e, path: r });
210
+ const [, r, ...n] = e.path;
211
+ if (n != null && n.length) {
212
+ const u = s.value.tags[r], l = t[u], p = m(M, { ...e, path: n });
214
213
  if (!l || !p) return !1;
215
214
  a.edit(u, p.path, p.value);
216
215
  } else if (e.type === "REMOVE") {
217
- const u = s.value.tags[n], l = t[u];
216
+ const u = s.value.tags[r], l = t[u];
218
217
  if (!l) return !1;
219
218
  a.delete(l, s.value.uid);
220
219
  } else if (e.type === "CREATE") {
@@ -226,22 +225,22 @@ const x = (e, s = []) => {
226
225
  }, w = (e, s, t) => {
227
226
  const a = d(e);
228
227
  if (a instanceof i.ZodUnion || a instanceof i.ZodDiscriminatedUnion) {
229
- for (const n of a.options)
230
- if (n instanceof i.ZodObject && s in n.shape && n.shape[s] instanceof i.ZodLiteral && n.shape[s].value === t)
231
- return n;
228
+ for (const r of a.options)
229
+ if (r instanceof i.ZodObject && s in r.shape && r.shape[s] instanceof i.ZodLiteral && r.shape[s].value === t)
230
+ return r;
232
231
  }
233
232
  return null;
234
- }, J = (e, { activeCollection: s }, { securitySchemes: t, securitySchemeMutators: a }) => {
233
+ }, I = (e, { activeCollection: s }, { securitySchemes: t, securitySchemeMutators: a }) => {
235
234
  if (!s.value) return !1;
236
- const [, , n, ...r] = e.path, u = t[n] ?? v(
235
+ const [, , r, ...n] = e.path, u = t[r] ?? v(
237
236
  s.value.securitySchemes,
238
237
  t,
239
- (l) => l.nameKey === n
238
+ (l) => l.nameKey === r
240
239
  );
241
- if (r != null && r.length) {
240
+ if (n != null && n.length) {
242
241
  const l = w(S, "type", u == null ? void 0 : u.type);
243
242
  if (!l) return !1;
244
- const p = m(l, { ...e, path: r });
243
+ const p = m(l, { ...e, path: n });
245
244
  if (!p) return !1;
246
245
  const o = p.path;
247
246
  a.edit(u.uid, o, p.value);
@@ -259,9 +258,9 @@ export {
259
258
  v as findResource,
260
259
  K as mutateCollectionDiff,
261
260
  L as mutateRequestDiff,
262
- J as mutateSecuritySchemeDiff,
263
- W as mutateServerDiff,
264
- I as mutateTagDiff,
261
+ I as mutateSecuritySchemeDiff,
262
+ P as mutateServerDiff,
263
+ W as mutateTagDiff,
265
264
  w as narrowUnionSchema,
266
265
  m as parseDiff,
267
266
  G as traverseZodSchema
@@ -18,11 +18,15 @@ export declare const generateCodeChallenge: (verifier: string, encoding: "SHA-25
18
18
  *
19
19
  * @returns the accessToken
20
20
  */
21
- export declare const authorizeOauth2: (flow: Oauth2Flow, activeServer: Server) => Promise<ErrorResponse<string>>;
21
+ export declare const authorizeOauth2: (flow: Oauth2Flow, activeServer: Server, proxyUrl?: string) => Promise<ErrorResponse<string>>;
22
22
  /**
23
23
  * Makes the BE authorization call to grab the token server to server
24
24
  * Used for clientCredentials and authorizationCode
25
25
  */
26
- export declare const authorizeServers: (flow: NonImplicitFlow, scopes: string, code?: string, pkce?: PKCEState | null) => Promise<ErrorResponse<string>>;
26
+ export declare const authorizeServers: (flow: NonImplicitFlow, scopes: string, { code, pkce, proxyUrl, }?: {
27
+ code?: string;
28
+ pkce?: PKCEState | null;
29
+ proxyUrl?: string;
30
+ }) => Promise<ErrorResponse<string>>;
27
31
  export {};
28
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,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAC3C,OAAO,KAAK,EACV,UAAU,EAEV,MAAM,EACP,MAAM,iCAAiC,CAAA;AAExC,qDAAqD;AACrD,KAAK,eAAe,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAA;AAEhE,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,SACpB,UAAU,gBAEF,MAAM,KACnB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAqJ/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,SACrB,eAAe,UACb,MAAM,SACP,MAAM,SACN,SAAS,GAAG,IAAI,KACtB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAwD/B,CAAA"}
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,UAAU,EAEV,MAAM,EACP,MAAM,iCAAiC,CAAA;AAGxC,qDAAqD;AACrD,KAAK,eAAe,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAA;AAEhE,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,SACpB,UAAU,gBAEF,MAAM,aAET,MAAM,KAChB,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAsJ/B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,SACrB,eAAe,UACb,MAAM,8BAKX;IACD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,KACA,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CA6D/B,CAAA"}
@@ -1,33 +1,36 @@
1
- const w = () => {
1
+ import { shouldUseProxy as w } from "@scalar/oas-utils/helpers";
2
+ const P = () => {
2
3
  const e = new Uint8Array(32);
3
4
  return crypto.getRandomValues(e), btoa(String.fromCharCode(...e)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
4
- }, _ = async (e, i) => {
5
- if (i === "plain") return e;
6
- const s = new TextEncoder().encode(e), t = await crypto.subtle.digest("SHA-256", s);
7
- return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
8
5
  }, y = async (e, i) => {
6
+ if (i === "plain") return e;
7
+ const a = new TextEncoder().encode(e), s = await crypto.subtle.digest("SHA-256", a);
8
+ return btoa(String.fromCharCode(...new Uint8Array(s))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
9
+ }, k = async (e, i, o) => {
9
10
  try {
10
11
  if (!e) return [new Error("Flow not found"), null];
11
12
  const a = e.selectedScopes.join(" ");
12
13
  if (e.type === "clientCredentials" || e.type === "password")
13
- return m(e, a);
14
+ return _(e, a, {
15
+ proxyUrl: o
16
+ });
14
17
  {
15
18
  const s = (Math.random() + 1).toString(36).substring(7), t = new URL(e.authorizationUrl);
16
- let o = null;
19
+ let l = null;
17
20
  if (e.type === "implicit")
18
21
  t.searchParams.set("response_type", "token");
19
22
  else if (e.type === "authorizationCode" && (t.searchParams.set("response_type", "code"), e["x-usePkce"] !== "no")) {
20
- const r = w(), c = await _(
23
+ const r = P(), c = await y(
21
24
  r,
22
25
  e["x-usePkce"]
23
26
  );
24
- o = {
27
+ l = {
25
28
  codeVerifier: r,
26
29
  codeChallenge: c,
27
30
  codeChallengeMethod: e["x-usePkce"] === "SHA-256" ? "S256" : "plain"
28
31
  }, t.searchParams.set("code_challenge", c), t.searchParams.set(
29
32
  "code_challenge_method",
30
- o.codeChallengeMethod
33
+ l.codeChallengeMethod
31
34
  );
32
35
  }
33
36
  if (e["x-scalar-redirect-uri"].startsWith("/")) {
@@ -42,29 +45,28 @@ const w = () => {
42
45
  const n = window.open(t, "openAuth2Window", "left=100,top=100,width=800,height=600");
43
46
  return n ? new Promise((r) => {
44
47
  const c = setInterval(() => {
45
- var p;
46
- let d = null, u = null;
48
+ var m;
49
+ let u = null, h = null;
47
50
  try {
48
- const l = new URL(n.location.href).searchParams;
49
- d = l.get("access_token"), u = l.get("code");
51
+ const d = new URL(n.location.href).searchParams;
52
+ u = d.get("access_token"), h = d.get("code");
50
53
  const g = new URLSearchParams(
51
54
  n.location.href.split("#")[1]
52
55
  );
53
- d || (d = g.get("access_token")), u || (u = g.get("code"));
56
+ u || (u = g.get("access_token")), h || (h = g.get("code"));
54
57
  } catch {
55
58
  }
56
- if (n.closed || d || u)
57
- if (clearInterval(c), n.close(), d) {
58
- const l = (p = n.location.href.match(/state=([^&]*)/)) == null ? void 0 : p[1];
59
- r(l === s ? [null, d] : [new Error("State mismatch"), null]);
60
- } else u ? new URL(
59
+ if (n.closed || u || h)
60
+ if (clearInterval(c), n.close(), u) {
61
+ const d = (m = n.location.href.match(/state=([^&]*)/)) == null ? void 0 : m[1];
62
+ r(d === s ? [null, u] : [new Error("State mismatch"), null]);
63
+ } else h ? new URL(
61
64
  n.location.href
62
- ).searchParams.get("state") === s ? m(
63
- e,
64
- a,
65
- u,
66
- o
67
- ).then(r) : r([new Error("State mismatch"), null]) : (clearInterval(c), r([
65
+ ).searchParams.get("state") === s ? _(e, a, {
66
+ code: h,
67
+ pkce: l,
68
+ proxyUrl: o
69
+ }).then(r) : r([new Error("State mismatch"), null]) : (clearInterval(c), r([
68
70
  new Error("Window was closed without granting authorization"),
69
71
  null
70
72
  ]));
@@ -74,21 +76,25 @@ const w = () => {
74
76
  } catch {
75
77
  return [new Error("Failed to authorize oauth2 flow"), null];
76
78
  }
77
- }, m = async (e, i, a, s) => {
79
+ }, _ = async (e, i, {
80
+ code: o,
81
+ pkce: a,
82
+ proxyUrl: s
83
+ } = {}) => {
78
84
  if (!e) return [new Error("OAuth2 flow was not defined"), null];
79
85
  const t = new URLSearchParams();
80
- t.set("client_id", e["x-scalar-client-id"]), i && t.set("scope", i), e.clientSecret && t.set("client_secret", e.clientSecret), "x-scalar-redirect-uri" in e && e["x-scalar-redirect-uri"] && t.set("redirect_uri", e["x-scalar-redirect-uri"]), a ? (t.set("code", a), t.set("grant_type", "authorization_code"), s && t.set("code_verifier", s.codeVerifier)) : e.type === "password" ? (t.set("grant_type", "password"), t.set("username", e.username), t.set("password", e.password)) : t.set("grant_type", "client_credentials");
86
+ t.set("client_id", e["x-scalar-client-id"]), i && t.set("scope", i), e.clientSecret && t.set("client_secret", e.clientSecret), "x-scalar-redirect-uri" in e && e["x-scalar-redirect-uri"] && t.set("redirect_uri", e["x-scalar-redirect-uri"]), o ? (t.set("code", o), t.set("grant_type", "authorization_code"), a && t.set("code_verifier", a.codeVerifier)) : e.type === "password" ? (t.set("grant_type", "password"), t.set("username", e.username), t.set("password", e.password)) : t.set("grant_type", "client_credentials");
81
87
  try {
82
- const o = {
88
+ const l = {
83
89
  "Content-Type": "application/x-www-form-urlencoded"
84
90
  };
85
- o.Authorization = `Basic ${btoa(`${e["x-scalar-client-id"]}:${e.clientSecret}`)}`;
86
- const h = await fetch(e.tokenUrl, {
91
+ l.Authorization = `Basic ${btoa(`${e["x-scalar-client-id"]}:${e.clientSecret}`)}`;
92
+ const p = w(s, e.tokenUrl) ? `${s}?${new URLSearchParams([["scalar_url", e.tokenUrl]]).toString()}` : e.tokenUrl, n = await fetch(p, {
87
93
  method: "POST",
88
- headers: o,
94
+ headers: l,
89
95
  body: t
90
- }), { access_token: n } = await h.json();
91
- return [null, n];
96
+ }), { access_token: r } = await n.json();
97
+ return [null, r];
92
98
  } catch {
93
99
  return [
94
100
  new Error(
@@ -99,7 +105,7 @@ const w = () => {
99
105
  }
100
106
  };
101
107
  export {
102
- y as authorizeOauth2,
103
- m as authorizeServers,
104
- _ as generateCodeChallenge
108
+ k as authorizeOauth2,
109
+ _ as authorizeServers,
110
+ y as generateCodeChallenge
105
111
  };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "rest",
19
19
  "testing"
20
20
  ],
21
- "version": "2.2.4",
21
+ "version": "2.2.7",
22
22
  "engines": {
23
23
  "node": ">=18"
24
24
  },
@@ -146,7 +146,6 @@
146
146
  "@headlessui/vue": "^1.7.20",
147
147
  "@vueuse/core": "^10.10.0",
148
148
  "@vueuse/integrations": "^11.2.0",
149
- "cva": "1.0.0-beta.1",
150
149
  "focus-trap": "^7",
151
150
  "fuse.js": "^7.0.0",
152
151
  "js-cookie": "^3.0.5",
@@ -160,18 +159,18 @@
160
159
  "whatwg-mimetype": "^4.0.0",
161
160
  "yaml": "^2.4.5",
162
161
  "zod": "^3.23.8",
163
- "@scalar/components": "0.13.0",
164
- "@scalar/draggable": "0.1.7",
162
+ "@scalar/components": "0.13.2",
165
163
  "@scalar/icons": "0.1.2",
166
- "@scalar/import": "0.2.0",
164
+ "@scalar/import": "0.2.3",
165
+ "@scalar/oas-utils": "0.2.85",
167
166
  "@scalar/object-utils": "1.1.12",
168
- "@scalar/oas-utils": "0.2.82",
169
- "@scalar/openapi-types": "0.1.5",
170
- "@scalar/themes": "0.9.53",
167
+ "@scalar/draggable": "0.1.7",
171
168
  "@scalar/openapi-parser": "0.8.10",
172
- "@scalar/types": "0.0.22",
173
- "@scalar/use-codemirror": "0.11.44",
174
- "@scalar/use-hooks": "0.1.6",
169
+ "@scalar/openapi-types": "0.1.5",
170
+ "@scalar/themes": "0.9.54",
171
+ "@scalar/use-codemirror": "0.11.46",
172
+ "@scalar/types": "0.0.23",
173
+ "@scalar/use-hooks": "0.1.7",
175
174
  "@scalar/use-toasts": "0.7.7",
176
175
  "@scalar/use-tooltip": "1.0.4"
177
176
  },
@@ -1,4 +0,0 @@
1
- import { type RequestMethod } from '@scalar/oas-utils/entities/spec';
2
- /** Type guard which takes in a string and returns true if it is in fact an HTTPMethod */
3
- export declare const isHTTPMethod: (method: string) => method is RequestMethod;
4
- //# sourceMappingURL=helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/components/HttpMethod/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAEnB,MAAM,iCAAiC,CAAA;AAExC,yFAAyF;AACzF,eAAO,MAAM,YAAY,WAAY,MAAM,KAAG,MAAM,IAAI,aACN,CAAA"}
@@ -1,5 +0,0 @@
1
- import { requestMethods as o } from "@scalar/oas-utils/entities/spec";
2
- const s = (e) => o.includes(e);
3
- export {
4
- s as isHTTPMethod
5
- };