@scalar/api-client 2.32.0 → 2.34.0

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 (114) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/assets/yaml.worker-CcQnAKCg.js +490 -0
  3. package/dist/style.css +1 -1
  4. package/dist/v2/blocks/request-block/helpers/get-default-headers.js +1 -1
  5. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -1
  6. package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js +45 -39
  7. package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts.map +1 -1
  8. package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.js +41 -34
  9. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts +6 -2
  10. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -1
  11. package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +66 -66
  12. package/dist/v2/blocks/scalar-auth-selector-block/helpers/secret-types.d.ts +2 -2
  13. package/dist/v2/blocks/scalar-auth-selector-block/helpers/secret-types.d.ts.map +1 -1
  14. package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts +1 -0
  15. package/dist/v2/blocks/scalar-auth-selector-block/index.d.ts.map +1 -1
  16. package/dist/v2/features/app/App.vue.d.ts +0 -5
  17. package/dist/v2/features/app/App.vue.d.ts.map +1 -1
  18. package/dist/v2/features/app/App.vue.js +57 -60
  19. package/dist/v2/features/app/app-state.d.ts +17 -2
  20. package/dist/v2/features/app/app-state.d.ts.map +1 -1
  21. package/dist/v2/features/app/app-state.js +114 -102
  22. package/dist/v2/features/app/helpers/create-api-client-app.d.ts +1 -1
  23. package/dist/v2/features/app/helpers/create-api-client-app.d.ts.map +1 -1
  24. package/dist/v2/features/app/helpers/create-api-client-app.js +2 -4
  25. package/dist/v2/features/app/helpers/routes.d.ts +17 -0
  26. package/dist/v2/features/app/helpers/routes.d.ts.map +1 -1
  27. package/dist/v2/features/app/helpers/routes.js +8 -2
  28. package/dist/v2/features/app/hooks/use-theme.d.ts +14 -0
  29. package/dist/v2/features/app/hooks/use-theme.d.ts.map +1 -1
  30. package/dist/v2/features/app/hooks/use-theme.js +42 -28
  31. package/dist/v2/features/collection/DocumentCollection.vue.js +8 -6
  32. package/dist/v2/features/collection/OperationCollection.vue.js +14 -12
  33. package/dist/v2/features/collection/WorkspaceCollection.vue.js +9 -7
  34. package/dist/v2/features/collection/components/Authentication.vue2.js +19 -17
  35. package/dist/v2/features/collection/components/Cookies.vue.js +10 -8
  36. package/dist/v2/features/collection/components/Editor/Editor.vue.d.ts +16 -0
  37. package/dist/v2/features/collection/components/Editor/Editor.vue.d.ts.map +1 -0
  38. package/dist/v2/features/collection/components/Editor/Editor.vue.js +7 -0
  39. package/dist/v2/features/collection/components/Editor/Editor.vue2.js +333 -0
  40. package/dist/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue.d.ts +19 -0
  41. package/dist/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue.d.ts.map +1 -0
  42. package/dist/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue.js +78 -0
  43. package/dist/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue2.js +4 -0
  44. package/dist/v2/features/collection/components/Editor/components/EditorSavePanel.vue.d.ts +16 -0
  45. package/dist/v2/features/collection/components/Editor/components/EditorSavePanel.vue.d.ts.map +1 -0
  46. package/dist/v2/features/collection/components/Editor/components/EditorSavePanel.vue.js +83 -0
  47. package/dist/v2/features/collection/components/Editor/components/EditorSavePanel.vue2.js +4 -0
  48. package/dist/v2/features/collection/components/Editor/helpers/apply-scalar-theme.d.ts +16 -0
  49. package/dist/v2/features/collection/components/Editor/helpers/apply-scalar-theme.d.ts.map +1 -0
  50. package/dist/v2/features/collection/components/Editor/helpers/apply-scalar-theme.js +56 -0
  51. package/dist/v2/features/collection/components/Editor/helpers/configure-language-support.d.ts +7 -0
  52. package/dist/v2/features/collection/components/Editor/helpers/configure-language-support.d.ts.map +1 -0
  53. package/dist/v2/features/collection/components/Editor/helpers/configure-language-support.js +40 -0
  54. package/dist/v2/features/collection/components/Editor/helpers/ensure-monaco-environment.d.ts +6 -0
  55. package/dist/v2/features/collection/components/Editor/helpers/ensure-monaco-environment.d.ts.map +1 -0
  56. package/dist/v2/features/collection/components/Editor/helpers/ensure-monaco-environment.js +23 -0
  57. package/dist/v2/features/collection/components/Editor/helpers/get-diagnostic-counts.d.ts +12 -0
  58. package/dist/v2/features/collection/components/Editor/helpers/get-diagnostic-counts.d.ts.map +1 -0
  59. package/dist/v2/features/collection/components/Editor/helpers/get-diagnostic-counts.js +10 -0
  60. package/dist/v2/features/collection/components/Editor/helpers/get-json-ast-node-from-path.d.ts +14 -0
  61. package/dist/v2/features/collection/components/Editor/helpers/get-json-ast-node-from-path.d.ts.map +1 -0
  62. package/dist/v2/features/collection/components/Editor/helpers/get-json-ast-node-from-path.js +9 -0
  63. package/dist/v2/features/collection/components/Editor/helpers/get-operation-context.d.ts +11 -0
  64. package/dist/v2/features/collection/components/Editor/helpers/get-operation-context.d.ts.map +1 -0
  65. package/dist/v2/features/collection/components/Editor/helpers/get-operation-context.js +5 -0
  66. package/dist/v2/features/collection/components/Editor/helpers/get-visible-diagnostics.d.ts +7 -0
  67. package/dist/v2/features/collection/components/Editor/helpers/get-visible-diagnostics.d.ts.map +1 -0
  68. package/dist/v2/features/collection/components/Editor/helpers/get-visible-diagnostics.js +5 -0
  69. package/dist/v2/features/collection/components/Editor/helpers/get-yaml-node-range-from-path.d.ts +19 -0
  70. package/dist/v2/features/collection/components/Editor/helpers/get-yaml-node-range-from-path.d.ts.map +1 -0
  71. package/dist/v2/features/collection/components/Editor/helpers/get-yaml-node-range-from-path.js +50 -0
  72. package/dist/v2/features/collection/components/Editor/helpers/json-ast.d.ts +12 -0
  73. package/dist/v2/features/collection/components/Editor/helpers/json-ast.d.ts.map +1 -0
  74. package/dist/v2/features/collection/components/Editor/helpers/json-ast.js +24 -0
  75. package/dist/v2/features/collection/components/Editor/helpers/json-pointer-links.d.ts +15 -0
  76. package/dist/v2/features/collection/components/Editor/helpers/json-pointer-links.d.ts.map +1 -0
  77. package/dist/v2/features/collection/components/Editor/helpers/json-pointer-links.js +72 -0
  78. package/dist/v2/features/collection/components/Editor/helpers/json-pointer-path.d.ts +7 -0
  79. package/dist/v2/features/collection/components/Editor/helpers/json-pointer-path.d.ts.map +1 -0
  80. package/dist/v2/features/collection/components/Editor/helpers/json-pointer-path.js +20 -0
  81. package/dist/v2/features/collection/components/Editor/helpers/load-css-variables.d.ts +14 -0
  82. package/dist/v2/features/collection/components/Editor/helpers/load-css-variables.d.ts.map +1 -0
  83. package/dist/v2/features/collection/components/Editor/helpers/load-css-variables.js +21 -0
  84. package/dist/v2/features/collection/components/Editor/helpers/parse-editor-object.d.ts +10 -0
  85. package/dist/v2/features/collection/components/Editor/helpers/parse-editor-object.d.ts.map +1 -0
  86. package/dist/v2/features/collection/components/Editor/helpers/parse-editor-object.js +21 -0
  87. package/dist/v2/features/collection/components/Editor/helpers/stringify-document.d.ts +10 -0
  88. package/dist/v2/features/collection/components/Editor/helpers/stringify-document.d.ts.map +1 -0
  89. package/dist/v2/features/collection/components/Editor/helpers/stringify-document.js +5 -0
  90. package/dist/v2/features/collection/components/Editor/helpers/yaml.worker.d.ts +2 -0
  91. package/dist/v2/features/collection/components/Editor/helpers/yaml.worker.d.ts.map +1 -0
  92. package/dist/v2/features/collection/components/Editor/helpers/yaml.worker.js +11 -0
  93. package/dist/v2/features/collection/components/Editor/hooks/use-editor-markers.d.ts +152 -0
  94. package/dist/v2/features/collection/components/Editor/hooks/use-editor-markers.d.ts.map +1 -0
  95. package/dist/v2/features/collection/components/Editor/hooks/use-editor-markers.js +34 -0
  96. package/dist/v2/features/collection/components/Editor/hooks/use-editor-state.d.ts +14 -0
  97. package/dist/v2/features/collection/components/Editor/hooks/use-editor-state.d.ts.map +1 -0
  98. package/dist/v2/features/collection/components/Editor/hooks/use-editor-state.js +25 -0
  99. package/dist/v2/features/collection/components/Editor/hooks/use-editor.d.ts +39 -0
  100. package/dist/v2/features/collection/components/Editor/hooks/use-editor.d.ts.map +1 -0
  101. package/dist/v2/features/collection/components/Editor/hooks/use-editor.js +153 -0
  102. package/dist/v2/features/collection/components/Editor/index.d.ts +2 -0
  103. package/dist/v2/features/collection/components/Editor/index.d.ts.map +1 -0
  104. package/dist/v2/features/collection/components/Editor/index.js +4 -0
  105. package/dist/v2/features/collection/components/Editor/schemas/openapi-3.1-schema.json.js +25 -0
  106. package/dist/v2/features/collection/components/Environment.vue.js +8 -6
  107. package/dist/v2/features/collection/components/Overview.vue2.js +16 -14
  108. package/dist/v2/features/collection/components/Servers.vue.js +18 -16
  109. package/dist/v2/features/collection/components/Settings.vue.d.ts.map +1 -1
  110. package/dist/v2/features/collection/components/Settings.vue.js +6 -4
  111. package/dist/v2/features/collection/components/Tabs.vue.js +4 -4
  112. package/dist/v2/features/operation/Operation.vue.js +9 -7
  113. package/dist/views/Request/ResponseSection/ResponseEmpty.vue2.js +1 -1
  114. package/package.json +20 -13
@@ -1,7 +1,7 @@
1
1
  import { canMethodHaveBody as m } from "@scalar/helpers/http/can-method-have-body";
2
2
  import { getResolvedRef as r } from "@scalar/workspace-store/helpers/get-resolved-ref";
3
3
  import { isElectron as y } from "../../../../libs/electron.js";
4
- const l = "2.32.0", T = "application/json", C = "*/*", a = (n, s, o) => ({
4
+ const l = "2.34.0", T = "application/json", C = "*/*", a = (n, s, o) => ({
5
5
  name: n,
6
6
  defaultValue: s,
7
7
  isOverridden: o.has(n.toLowerCase())
@@ -1 +1 @@
1
- {"version":3,"file":"OAuth2.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue"],"names":[],"mappings":"AAoYA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AAGnH,OAAO,KAAK,EAEV,YAAY,EACb,MAAM,8DAA8D,CAAA;AAOrE,OAAO,KAAK,EAIV,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,6DAA6D,CAAA;AAIpE,KAAK,WAAW,GAAG;IACjB,wCAAwC;IACxC,WAAW,EAAE,kBAAkB,CAAA;IAC/B,kBAAkB;IAClB,KAAK,EAAE,sBAAsB,CAAA;IAC7B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,sBAAsB,CAAA;IAClC,sBAAsB;IACtB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,sBAAsB;IACtB,MAAM,EAAE,0BAA0B,CAAA;IAClC,mCAAmC;IACnC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,2CAA2C;IAC3C,QAAQ,EAAE,iBAAiB,CAAA;CAC5B,CAAC;AA+uBF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"OAuth2.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue"],"names":[],"mappings":"AA6YA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AAGnH,OAAO,KAAK,EAEV,YAAY,EACb,MAAM,8DAA8D,CAAA;AAOrE,OAAO,KAAK,EAIV,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,6DAA6D,CAAA;AAIpE,KAAK,WAAW,GAAG;IACjB,wCAAwC;IACxC,WAAW,EAAE,kBAAkB,CAAA;IAC/B,kBAAkB;IAClB,KAAK,EAAE,sBAAsB,CAAA;IAC7B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,sBAAsB,CAAA;IAClC,sBAAsB;IACtB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,sBAAsB;IACtB,MAAM,EAAE,0BAA0B,CAAA;IAClC,mCAAmC;IACnC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,2CAA2C;IAC3C,QAAQ,EAAE,iBAAiB,CAAA;CAC5B,CAAC;AAwvBF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1,14 +1,14 @@
1
- import { defineComponent as P, computed as C, ref as R, watch as I, createElementBlock as p, openBlock as m, Fragment as V, createVNode as r, unref as o, withCtx as l, createTextVNode as d, createElementVNode as S, createBlock as f, createCommentVNode as v } from "vue";
2
- import { useLoadingState as L, ScalarButton as k } from "@scalar/components";
3
- import { pkceOptions as F } from "@scalar/oas-utils/entities/spec";
4
- import { useToasts as A } from "@scalar/use-toasts";
5
- import { getEnvironmentVariables as h } from "../../operation-block/helpers/get-environment-variables.js";
1
+ import { defineComponent as O, computed as C, ref as P, watch as R, createElementBlock as k, openBlock as m, Fragment as p, createVNode as r, unref as o, withCtx as l, createTextVNode as d, createElementVNode as S, createBlock as v, createCommentVNode as f } from "vue";
2
+ import { useLoadingState as I, ScalarButton as V } from "@scalar/components";
3
+ import { pkceOptions as L } from "@scalar/oas-utils/entities/spec";
4
+ import { useToasts as F } from "@scalar/use-toasts";
5
+ import { getEnvironmentVariables as A } from "../../operation-block/helpers/get-environment-variables.js";
6
6
  import E from "./OAuthScopesInput.vue.js";
7
7
  /* empty css */
8
8
  import { authorizeOauth2 as N } from "../helpers/oauth.js";
9
9
  import c from "./RequestAuthDataTableInput.vue.js";
10
10
  import u from "../../../../components/DataTable/DataTableRow.vue.js";
11
- const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { class: "flex h-8 w-full items-center justify-end border-t" }, J = /* @__PURE__ */ P({
11
+ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { class: "flex h-8 w-full items-center justify-end border-t" }, J = /* @__PURE__ */ O({
12
12
  __name: "OAuth2",
13
13
  props: {
14
14
  environment: {},
@@ -22,8 +22,8 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
22
22
  eventBus: {}
23
23
  },
24
24
  emits: ["update:selectedScopes"],
25
- setup(t, { emit: g }) {
26
- const z = g, y = L(), { toast: B } = A(), n = C(() => t.flows[t.type]), U = C(
25
+ setup(t, { emit: T }) {
26
+ const g = T, y = I(), { toast: z } = F(), n = C(() => t.flows[t.type]), U = C(
27
27
  () => t.selectedScopes.filter((s) => s in (n.value.scopes ?? {}))
28
28
  ), x = (s) => {
29
29
  if (t.scheme.type === "openIdConnect")
@@ -43,10 +43,10 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
43
43
  [t.type]: s
44
44
  },
45
45
  name: t.name
46
- }), T = () => t.eventBus.emit("auth:clear:security-scheme-secrets", {
46
+ }), B = () => t.eventBus.emit("auth:clear:security-scheme-secrets", {
47
47
  name: t.name
48
- }), w = R(!1);
49
- I(
48
+ }), w = P(!1);
49
+ R(
50
50
  () => n.value["x-scalar-secret-redirect-uri"],
51
51
  (s) => {
52
52
  w.value || s || typeof window > "u" || !("x-scalar-secret-redirect-uri" in n.value) || (w.value = !0, i({
@@ -65,13 +65,16 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
65
65
  U.value,
66
66
  t.server,
67
67
  t.proxyUrl,
68
- h(t.environment)
68
+ A(t.environment)
69
69
  );
70
- await y.clear(), e ? i({ "x-scalar-secret-token": e }) : (console.error(s), B(s?.message ?? "Failed to authorize", "error"));
71
- }, O = (s) => x({
70
+ await y.clear(), e?.accessToken ? i({
71
+ "x-scalar-secret-token": e.accessToken,
72
+ ...e.refreshToken ? { "x-scalar-secret-refresh-token": e.refreshToken } : {}
73
+ }) : (console.error(s), z(s?.message ?? "Failed to authorize", "error"));
74
+ }, h = (s) => x({
72
75
  "x-scalar-credentials-location": s === "body" ? "body" : "header"
73
76
  });
74
- return (s, e) => n.value["x-scalar-secret-token"] ? (m(), p(V, { key: 0 }, [
77
+ return (s, e) => n.value["x-scalar-secret-token"] ? (m(), k(p, { key: 0 }, [
75
78
  r(o(u), null, {
76
79
  default: l(() => [
77
80
  r(c, {
@@ -93,12 +96,15 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
93
96
  r(o(u), { class: "min-w-full" }, {
94
97
  default: l(() => [
95
98
  S("div", j, [
96
- r(o(k), {
99
+ r(o(V), {
97
100
  class: "mr-1 p-0 px-2 py-0.5",
98
101
  loader: o(y),
99
102
  size: "sm",
100
103
  variant: "outlined",
101
- onClick: e[1] || (e[1] = () => i({ "x-scalar-secret-token": "" }))
104
+ onClick: e[1] || (e[1] = () => i({
105
+ "x-scalar-secret-token": "",
106
+ "x-scalar-secret-refresh-token": ""
107
+ }))
102
108
  }, {
103
109
  default: l(() => [...e[13] || (e[13] = [
104
110
  d(" Clear ", -1)
@@ -109,10 +115,10 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
109
115
  ]),
110
116
  _: 1
111
117
  })
112
- ], 64)) : (m(), p(V, { key: 1 }, [
118
+ ], 64)) : (m(), k(p, { key: 1 }, [
113
119
  r(o(u), null, {
114
120
  default: l(() => [
115
- "authorizationUrl" in n.value ? (m(), f(c, {
121
+ "authorizationUrl" in n.value ? (m(), v(c, {
116
122
  key: 0,
117
123
  containerClass: "border-r-0",
118
124
  environment: t.environment,
@@ -124,8 +130,8 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
124
130
  d(" Auth URL ", -1)
125
131
  ])]),
126
132
  _: 1
127
- }, 8, ["environment", "modelValue"])) : v("", !0),
128
- "tokenUrl" in n.value ? (m(), f(c, {
133
+ }, 8, ["environment", "modelValue"])) : f("", !0),
134
+ "tokenUrl" in n.value ? (m(), v(c, {
129
135
  key: 1,
130
136
  environment: t.environment,
131
137
  modelValue: n.value.tokenUrl,
@@ -136,11 +142,11 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
136
142
  d(" Token URL ", -1)
137
143
  ])]),
138
144
  _: 1
139
- }, 8, ["environment", "modelValue"])) : v("", !0)
145
+ }, 8, ["environment", "modelValue"])) : f("", !0)
140
146
  ]),
141
147
  _: 1
142
148
  }),
143
- "x-scalar-secret-redirect-uri" in n.value ? (m(), f(o(u), { key: 0 }, {
149
+ "x-scalar-secret-redirect-uri" in n.value ? (m(), v(o(u), { key: 0 }, {
144
150
  default: l(() => [
145
151
  r(c, {
146
152
  environment: t.environment,
@@ -155,8 +161,8 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
155
161
  }, 8, ["environment", "modelValue"])
156
162
  ]),
157
163
  _: 1
158
- })) : v("", !0),
159
- "x-scalar-secret-username" in n.value && "x-scalar-secret-password" in n.value ? (m(), p(V, { key: 1 }, [
164
+ })) : f("", !0),
165
+ "x-scalar-secret-username" in n.value && "x-scalar-secret-password" in n.value ? (m(), k(p, { key: 1 }, [
160
166
  r(o(u), null, {
161
167
  default: l(() => [
162
168
  r(c, {
@@ -191,7 +197,7 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
191
197
  ]),
192
198
  _: 1
193
199
  })
194
- ], 64)) : v("", !0),
200
+ ], 64)) : f("", !0),
195
201
  r(o(u), null, {
196
202
  default: l(() => [
197
203
  r(c, {
@@ -208,7 +214,7 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
208
214
  ]),
209
215
  _: 1
210
216
  }),
211
- "x-scalar-secret-client-secret" in n.value ? (m(), f(o(u), { key: 2 }, {
217
+ "x-scalar-secret-client-secret" in n.value ? (m(), v(o(u), { key: 2 }, {
212
218
  default: l(() => [
213
219
  r(c, {
214
220
  environment: t.environment,
@@ -224,11 +230,11 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
224
230
  }, 8, ["environment", "modelValue"])
225
231
  ]),
226
232
  _: 1
227
- })) : v("", !0),
228
- "x-usePkce" in n.value ? (m(), f(o(u), { key: 3 }, {
233
+ })) : f("", !0),
234
+ "x-usePkce" in n.value ? (m(), v(o(u), { key: 3 }, {
229
235
  default: l(() => [
230
236
  r(c, {
231
- enum: o(F),
237
+ enum: o(L),
232
238
  environment: t.environment,
233
239
  modelValue: n.value["x-usePkce"],
234
240
  readOnly: "",
@@ -243,8 +249,8 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
243
249
  }, 8, ["enum", "environment", "modelValue"])
244
250
  ]),
245
251
  _: 1
246
- })) : v("", !0),
247
- t.type !== "implicit" ? (m(), f(o(u), { key: 4 }, {
252
+ })) : f("", !0),
253
+ t.type !== "implicit" ? (m(), v(o(u), { key: 4 }, {
248
254
  default: l(() => [
249
255
  r(c, {
250
256
  enum: ["header", "body"],
@@ -252,7 +258,7 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
252
258
  modelValue: n.value["x-scalar-credentials-location"] || "header",
253
259
  placeholder: "header",
254
260
  readOnly: "",
255
- "onUpdate:modelValue": e[10] || (e[10] = (a) => O(a))
261
+ "onUpdate:modelValue": e[10] || (e[10] = (a) => h(a))
256
262
  }, {
257
263
  default: l(() => [...e[22] || (e[22] = [
258
264
  d(" Credentials Location ", -1)
@@ -261,14 +267,14 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
261
267
  }, 8, ["environment", "modelValue"])
262
268
  ]),
263
269
  _: 1
264
- })) : v("", !0),
270
+ })) : f("", !0),
265
271
  r(o(u), null, {
266
272
  default: l(() => [
267
273
  r(E, {
268
274
  flow: n.value,
269
275
  flowType: t.type,
270
276
  selectedScopes: U.value,
271
- "onUpdate:selectedScopes": e[11] || (e[11] = (a) => z("update:selectedScopes", a))
277
+ "onUpdate:selectedScopes": e[11] || (e[11] = (a) => g("update:selectedScopes", a))
272
278
  }, null, 8, ["flow", "flowType", "selectedScopes"])
273
279
  ]),
274
280
  _: 1
@@ -276,20 +282,20 @@ const j = { class: "flex h-8 items-center justify-end gap-2 border-t" }, Q = { c
276
282
  r(o(u), { class: "min-w-full" }, {
277
283
  default: l(() => [
278
284
  S("div", Q, [
279
- t.scheme.type === "openIdConnect" ? (m(), f(o(k), {
285
+ t.scheme.type === "openIdConnect" ? (m(), v(o(V), {
280
286
  key: 0,
281
287
  class: "mr-1 p-0 px-2 py-0.5",
282
288
  loader: o(y),
283
289
  size: "sm",
284
290
  variant: "outlined",
285
- onClick: T
291
+ onClick: B
286
292
  }, {
287
293
  default: l(() => [...e[23] || (e[23] = [
288
294
  d(" Clear ", -1)
289
295
  ])]),
290
296
  _: 1
291
- }, 8, ["loader"])) : v("", !0),
292
- r(o(k), {
297
+ }, 8, ["loader"])) : f("", !0),
298
+ r(o(V), {
293
299
  class: "mr-0.75 p-0 px-2 py-0.5",
294
300
  loader: o(y),
295
301
  size: "sm",
@@ -1 +1 @@
1
- {"version":3,"file":"extract-security-scheme-secrets.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAA2C,MAAM,uCAAuC,CAAA;AAC/G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAA;AAOlF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAA;AAExG,OAAO,KAAK,EAUV,0BAA0B,EAC3B,MAAM,gBAAgB,CAAA;AAEvB,wGAAwG;AACxG,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,WAAW,CAAC,cAAc,CAAC,CAAA;AA0HjF,6DAA6D;AAC7D,eAAO,MAAM,4BAA4B,GAEvC,QAAQ,oBAAoB,GAAG,WAAW,CAAC,cAAc,CAAC,EAC1D,WAAW,SAAS,EACpB,MAAM,MAAM,EACZ,cAAc,MAAM,KACnB,0BAuDF,CAAA"}
1
+ {"version":3,"file":"extract-security-scheme-secrets.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAA2C,MAAM,uCAAuC,CAAA;AAC/G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAA;AAOlF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAA;AAExG,OAAO,KAAK,EAUV,0BAA0B,EAC3B,MAAM,gBAAgB,CAAA;AAEvB,wGAAwG;AACxG,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG,WAAW,CAAC,cAAc,CAAC,CAAA;AA0IjF,6DAA6D;AAC7D,eAAO,MAAM,4BAA4B,GAEvC,QAAQ,oBAAoB,GAAG,WAAW,CAAC,cAAc,CAAC,EAC1D,WAAW,SAAS,EACpB,MAAM,MAAM,EACZ,cAAc,MAAM,KACnB,0BAuDF,CAAA"}
@@ -1,32 +1,36 @@
1
- import { isObject as p } from "@scalar/helpers/object/is-object";
2
- import { objectEntries as x } from "@scalar/helpers/object/object-entries";
3
- const u = {
1
+ import { isObject as u } from "@scalar/helpers/object/is-object";
2
+ import { objectEntries as p } from "@scalar/helpers/object/object-entries";
3
+ const f = {
4
4
  "x-scalar-secret-client-id": "x-scalar-client-id",
5
5
  "x-scalar-secret-client-secret": "clientSecret",
6
6
  "x-scalar-secret-password": "password",
7
7
  "x-scalar-secret-redirect-uri": "x-scalar-redirect-uri",
8
8
  "x-scalar-secret-token": "token",
9
9
  "x-scalar-secret-username": "username"
10
- }, n = (t, c, i = {}) => Object.fromEntries(
10
+ }, n = (t, s, i = {}) => Object.fromEntries(
11
11
  t.map((a) => {
12
- const r = i[a] || c[a] || c[u[a]] || "";
12
+ const r = i[a] || s[a] || s[f[a]] || "";
13
13
  return [a, r];
14
14
  })
15
- ), d = (t, c) => {
15
+ ), o = (t = {}) => {
16
+ const s = t["x-scalar-secret-refresh-token"];
17
+ return typeof s == "string" ? { "x-scalar-secret-refresh-token": s } : {};
18
+ }, x = (t, s) => {
16
19
  const i = /* @__PURE__ */ new Set();
17
- return { flows: x(t ?? {}).reduce((r, [e, s]) => {
18
- if (!p(s))
20
+ return { flows: p(t ?? {}).reduce((r, [e, c]) => {
21
+ if (!u(c))
19
22
  return r;
20
- const o = s.selectedScopes;
21
- return Array.isArray(o) && o.forEach((l) => typeof l == "string" && i.add(l)), e === "implicit" && (r.implicit = {
22
- ...s,
23
+ const l = c.selectedScopes;
24
+ return Array.isArray(l) && l.forEach((d) => typeof d == "string" && i.add(d)), e === "implicit" && (r.implicit = {
25
+ ...c,
23
26
  ...n(
24
27
  ["x-scalar-secret-client-id", "x-scalar-secret-redirect-uri", "x-scalar-secret-token"],
25
- s,
26
- c?.implicit
27
- )
28
+ c,
29
+ s?.implicit
30
+ ),
31
+ ...o(s?.implicit)
28
32
  }), e === "password" && (r[e] = {
29
- ...s,
33
+ ...c,
30
34
  ...n(
31
35
  [
32
36
  "x-scalar-secret-client-id",
@@ -35,18 +39,20 @@ const u = {
35
39
  "x-scalar-secret-password",
36
40
  "x-scalar-secret-token"
37
41
  ],
38
- s,
39
- c?.password
40
- )
42
+ c,
43
+ s?.password
44
+ ),
45
+ ...o(s?.password)
41
46
  }), e === "clientCredentials" && (r[e] = {
42
- ...s,
47
+ ...c,
43
48
  ...n(
44
49
  ["x-scalar-secret-client-id", "x-scalar-secret-client-secret", "x-scalar-secret-token"],
45
- s,
46
- c?.clientCredentials
47
- )
50
+ c,
51
+ s?.clientCredentials
52
+ ),
53
+ ...o(s?.clientCredentials)
48
54
  }), e === "authorizationCode" && (r[e] = {
49
- ...s,
55
+ ...c,
50
56
  ...n(
51
57
  [
52
58
  "x-scalar-secret-client-id",
@@ -54,13 +60,14 @@ const u = {
54
60
  "x-scalar-secret-redirect-uri",
55
61
  "x-scalar-secret-token"
56
62
  ],
57
- s,
58
- c?.authorizationCode
59
- )
63
+ c,
64
+ s?.authorizationCode
65
+ ),
66
+ ...o(s?.authorizationCode)
60
67
  }), r;
61
68
  }, {}), selectedScopes: Array.from(i) };
62
- }, w = (t, c, i, a) => {
63
- const r = c.getAuthSecrets(a, i);
69
+ }, S = (t, s, i, a) => {
70
+ const r = s.getAuthSecrets(a, i);
64
71
  if (t.type === "apiKey") {
65
72
  const e = r?.type === "apiKey" ? r : void 0;
66
73
  return {
@@ -78,15 +85,15 @@ const u = {
78
85
  };
79
86
  }
80
87
  if (t.type === "oauth2") {
81
- const e = r?.type === "oauth2" ? r : void 0, s = d(t.flows, e);
88
+ const e = r?.type === "oauth2" ? r : void 0, c = x(t.flows, e);
82
89
  return {
83
90
  ...t,
84
- flows: s.flows,
85
- "x-default-scopes": s.selectedScopes
91
+ flows: c.flows,
92
+ "x-default-scopes": c.selectedScopes
86
93
  };
87
94
  }
88
95
  if (t.type === "openIdConnect") {
89
- const e = r?.type === "openIdConnect" ? r : void 0, s = d(
96
+ const e = r?.type === "openIdConnect" ? r : void 0, c = x(
90
97
  {
91
98
  implicit: e?.implicit,
92
99
  password: e?.password,
@@ -97,11 +104,11 @@ const u = {
97
104
  );
98
105
  return {
99
106
  ...t,
100
- ...x(s.flows).length ? { flows: s.flows } : {}
107
+ ...p(c.flows).length ? { flows: c.flows } : {}
101
108
  };
102
109
  }
103
110
  return t;
104
111
  };
105
112
  export {
106
- w as extractSecuritySchemeSecrets
113
+ S as extractSecuritySchemeSecrets
107
114
  };
@@ -1,10 +1,14 @@
1
1
  import type { ServerObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
2
2
  import type { ErrorResponse } from '../../../../libs/errors.js';
3
3
  import type { OAuthFlowsObjectSecret } from '../../../../v2/blocks/scalar-auth-selector-block/helpers/secret-types';
4
+ export type OAuth2Tokens = {
5
+ accessToken: string;
6
+ refreshToken?: string;
7
+ };
4
8
  /**
5
9
  * Authorize oauth2 flow
6
10
  *
7
- * @returns the accessToken
11
+ * @returns the resolved oauth2 tokens
8
12
  */
9
13
  export declare const authorizeOauth2: (flows: OAuthFlowsObjectSecret, type: keyof OAuthFlowsObjectSecret, selectedScopes: string[],
10
14
  /** We use the active server to set a base for relative redirect uris */
@@ -12,5 +16,5 @@ activeServer: ServerObject | null,
12
16
  /** If we want to use the proxy */
13
17
  proxyUrl: string,
14
18
  /** Flattened environment variables used to resolve server URL templates like `{protocol}` */
15
- environmentVariables?: Record<string, string>) => Promise<ErrorResponse<string>>;
19
+ environmentVariables?: Record<string, string>) => Promise<ErrorResponse<OAuth2Tokens>>;
16
20
  //# sourceMappingURL=oauth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/helpers/oauth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAGhG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6DAA6D,CAAA;AA+DzG;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,sBAAsB,EAC7B,MAAM,MAAM,sBAAsB,EAClC,gBAAgB,MAAM,EAAE;AACxB,wEAAwE;AACxE,cAAc,YAAY,GAAG,IAAI;AACjC,kCAAkC;AAClC,UAAU,MAAM;AAChB,6FAA6F;AAC7F,uBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,KAChD,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAqL/B,CAAA"}
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/helpers/oauth.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8DAA8D,CAAA;AAGhG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6DAA6D,CAAA;AAYzG,MAAM,MAAM,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAqDD;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,sBAAsB,EAC7B,MAAM,MAAM,sBAAsB,EAClC,gBAAgB,MAAM,EAAE;AACxB,wEAAwE;AACxE,cAAc,YAAY,GAAG,IAAI;AACjC,kCAAkC;AAClC,UAAU,MAAM;AAChB,6FAA6F;AAC7F,uBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,KAChD,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAwLrC,CAAA"}
@@ -1,25 +1,25 @@
1
- import { isRelativePath as z } from "@scalar/helpers/url/is-relative-path";
2
- import { makeUrlAbsolute as S } from "@scalar/helpers/url/make-url-absolute";
3
- import { shouldUseProxy as F } from "@scalar/helpers/url/redirect-to-proxy";
4
- import { encode as R, fromUint8Array as A } from "js-base64";
5
- import { getServerUrl as E } from "../../operation-block/helpers/get-server-url.js";
6
- const b = (t, e = {}) => {
7
- const i = E(t, e);
8
- return i ? z(i) ? typeof window > "u" ? {} : { basePath: i } : { baseUrl: i } : {};
1
+ import { isRelativePath as F } from "@scalar/helpers/url/is-relative-path";
2
+ import { makeUrlAbsolute as A } from "@scalar/helpers/url/make-url-absolute";
3
+ import { shouldUseProxy as R } from "@scalar/helpers/url/redirect-to-proxy";
4
+ import { encode as T, fromUint8Array as E } from "js-base64";
5
+ import { getServerUrl as b } from "../../operation-block/helpers/get-server-url.js";
6
+ const z = (t, e = {}) => {
7
+ const i = b(t, e);
8
+ return i ? F(i) ? typeof window > "u" ? {} : { basePath: i } : { baseUrl: i } : {};
9
9
  }, $ = () => {
10
10
  const t = new Uint8Array(32);
11
- return crypto.getRandomValues(t), A(t, !0);
11
+ return crypto.getRandomValues(t), E(t, !0);
12
12
  }, L = async (t, e) => {
13
13
  if (e === "plain")
14
14
  return t;
15
15
  if (typeof crypto?.subtle?.digest != "function")
16
16
  return console.warn("SHA-256 is only supported when using https, using a plain text code challenge instead."), t;
17
- const d = new TextEncoder().encode(t), m = await crypto.subtle.digest("SHA-256", d);
18
- return A(new Uint8Array(m), !0);
19
- }, q = async (t, e, i, d, m, g = {}) => {
20
- const h = t[e];
17
+ const u = new TextEncoder().encode(t), m = await crypto.subtle.digest("SHA-256", u);
18
+ return E(new Uint8Array(m), !0);
19
+ }, B = async (t, e, i, u, m, g = {}) => {
20
+ const f = t[e];
21
21
  try {
22
- if (!h)
22
+ if (!f)
23
23
  return [new Error("Flow not found"), null];
24
24
  const p = i.join(" ");
25
25
  if (e === "clientCredentials" || e === "password")
@@ -30,55 +30,55 @@ const b = (t, e = {}) => {
30
30
  {
31
31
  proxyUrl: m
32
32
  },
33
- d,
33
+ u,
34
34
  g
35
35
  );
36
- const r = (Math.random() + 1).toString(36).substring(2, 10), a = S(
36
+ const s = (Math.random() + 1).toString(36).substring(2, 10), n = A(
37
37
  t[e].authorizationUrl,
38
- b(d, g)
39
- ), n = new URL(a);
38
+ z(u, g)
39
+ ), a = new URL(n);
40
40
  let c = null;
41
41
  if (e === "implicit")
42
- n.searchParams.set("response_type", "token");
42
+ a.searchParams.set("response_type", "token");
43
43
  else if (e === "authorizationCode") {
44
- const s = t[e];
45
- if (n.searchParams.set("response_type", "code"), s["x-usePkce"] !== "no") {
46
- const o = $(), u = await L(o, s["x-usePkce"]);
44
+ const r = t[e];
45
+ if (a.searchParams.set("response_type", "code"), r["x-usePkce"] !== "no") {
46
+ const o = $(), d = await L(o, r["x-usePkce"]);
47
47
  c = {
48
48
  codeVerifier: o,
49
- codeChallenge: u,
50
- codeChallengeMethod: s["x-usePkce"] === "SHA-256" ? "S256" : "plain"
51
- }, n.searchParams.set("code_challenge", u), n.searchParams.set("code_challenge_method", c.codeChallengeMethod);
49
+ codeChallenge: d,
50
+ codeChallengeMethod: r["x-usePkce"] === "SHA-256" ? "S256" : "plain"
51
+ }, a.searchParams.set("code_challenge", d), a.searchParams.set("code_challenge_method", c.codeChallengeMethod);
52
52
  }
53
53
  }
54
54
  const l = t[e];
55
55
  if (l["x-scalar-secret-redirect-uri"].startsWith("/")) {
56
- const s = E(d, g) || window.location.origin + window.location.pathname, o = new URL(l["x-scalar-secret-redirect-uri"], s).toString();
57
- n.searchParams.set("redirect_uri", o);
56
+ const r = b(u, g) || window.location.origin + window.location.pathname, o = new URL(l["x-scalar-secret-redirect-uri"], r).toString();
57
+ a.searchParams.set("redirect_uri", o);
58
58
  } else
59
- n.searchParams.set("redirect_uri", l["x-scalar-secret-redirect-uri"]);
60
- h["x-scalar-security-query"] && Object.keys(h["x-scalar-security-query"]).forEach((s) => {
61
- const o = h["x-scalar-security-query"]?.[s];
62
- o && n.searchParams.set(s, o);
63
- }), n.searchParams.set("client_id", h["x-scalar-secret-client-id"]), n.searchParams.set("state", r), p && n.searchParams.set("scope", p);
64
- const w = window.open(n, "openAuth2Window", "left=100,top=100,width=800,height=600");
65
- return w ? new Promise((s) => {
59
+ a.searchParams.set("redirect_uri", l["x-scalar-secret-redirect-uri"]);
60
+ f["x-scalar-security-query"] && Object.keys(f["x-scalar-security-query"]).forEach((r) => {
61
+ const o = f["x-scalar-security-query"]?.[r];
62
+ o && a.searchParams.set(r, o);
63
+ }), a.searchParams.set("client_id", f["x-scalar-secret-client-id"]), a.searchParams.set("state", s), p && a.searchParams.set("scope", p);
64
+ const w = window.open(a, "openAuth2Window", "left=100,top=100,width=800,height=600");
65
+ return w ? new Promise((r) => {
66
66
  const o = setInterval(() => {
67
- let u = null, x = null, _ = null, P = null;
67
+ let d = null, _ = null, x = null, P = null, k = null;
68
68
  try {
69
- const f = new URL(w.location.href).searchParams, U = h["x-tokenName"] || "access_token";
70
- u = f.get(U), x = f.get("code"), _ = f.get("error"), P = f.get("error_description");
69
+ const h = new URL(w.location.href).searchParams, S = f["x-tokenName"] || "access_token";
70
+ d = h.get(S), _ = h.get("refresh_token"), x = h.get("code"), P = h.get("error"), k = h.get("error_description");
71
71
  const y = new URLSearchParams(w.location.href.split("#")[1]);
72
- u ||= y.get(U), x ||= y.get("code"), _ ||= y.get("error"), P ||= y.get("error_description");
72
+ d ||= y.get(S), _ ||= y.get("refresh_token"), x ||= y.get("code"), P ||= y.get("error"), k ||= y.get("error_description");
73
73
  } catch {
74
74
  }
75
- if (w.closed || u || x || _)
76
- if (clearInterval(o), w.close(), _)
77
- s([new Error(`OAuth error: ${_}${P ? ` (${P})` : ""}`), null]);
78
- else if (u) {
79
- const f = w.location.href.match(/state=([^&]*)/)?.[1];
80
- s(f === r ? [null, u] : [new Error("State mismatch"), null]);
81
- } else x && e === "authorizationCode" ? new URL(w.location.href).searchParams.get("state") === r ? C(
75
+ if (w.closed || d || x || P)
76
+ if (clearInterval(o), w.close(), P)
77
+ r([new Error(`OAuth error: ${P}${k ? ` (${k})` : ""}`), null]);
78
+ else if (d) {
79
+ const h = w.location.href.match(/state=([^&]*)/)?.[1];
80
+ r(h === s ? [null, { accessToken: d, ..._ ? { refreshToken: _ } : {} }] : [new Error("State mismatch"), null]);
81
+ } else x && e === "authorizationCode" ? new URL(w.location.href).searchParams.get("state") === s ? C(
82
82
  t,
83
83
  e,
84
84
  p,
@@ -87,50 +87,50 @@ const b = (t, e = {}) => {
87
87
  pkce: c,
88
88
  proxyUrl: m
89
89
  },
90
- d,
90
+ u,
91
91
  g
92
- ).then(s) : s([new Error("State mismatch"), null]) : (clearInterval(o), s([new Error("Window was closed without granting authorization"), null]));
92
+ ).then(r) : r([new Error("State mismatch"), null]) : (clearInterval(o), r([new Error("Window was closed without granting authorization"), null]));
93
93
  }, 200);
94
94
  }) : [new Error("Failed to open auth window"), null];
95
95
  } catch {
96
96
  return [new Error("Failed to authorize oauth2 flow"), null];
97
97
  }
98
98
  }, C = async (t, e, i, {
99
- code: d,
99
+ code: u,
100
100
  pkce: m,
101
101
  proxyUrl: g
102
- } = {}, h, p = {}) => {
103
- const r = t[e];
104
- if (!r)
102
+ } = {}, f, p = {}) => {
103
+ const s = t[e];
104
+ if (!s)
105
105
  return [new Error("OAuth2 flow was not defined"), null];
106
- const a = new URLSearchParams();
107
- i && (e === "clientCredentials" || e === "password") && a.set("scope", i);
108
- const n = r["x-scalar-credentials-location"] === "body";
109
- if (n && (a.set("client_id", r["x-scalar-secret-client-id"]), a.set("client_secret", r["x-scalar-secret-client-secret"])), "x-scalar-secret-redirect-uri" in r && r["x-scalar-secret-redirect-uri"] && a.set("redirect_uri", r["x-scalar-secret-redirect-uri"]), d)
110
- a.set("code", d), a.set("grant_type", "authorization_code"), m && a.set("code_verifier", m.codeVerifier);
106
+ const n = new URLSearchParams();
107
+ i && (e === "clientCredentials" || e === "password") && n.set("scope", i);
108
+ const a = s["x-scalar-credentials-location"] === "body";
109
+ if (a && (n.set("client_id", s["x-scalar-secret-client-id"]), n.set("client_secret", s["x-scalar-secret-client-secret"])), "x-scalar-secret-redirect-uri" in s && s["x-scalar-secret-redirect-uri"] && n.set("redirect_uri", s["x-scalar-secret-redirect-uri"]), u)
110
+ n.set("code", u), n.set("grant_type", "authorization_code"), m && n.set("code_verifier", m.codeVerifier);
111
111
  else if (e === "password") {
112
112
  const c = t[e];
113
- a.set("grant_type", "password"), a.set("username", c["x-scalar-secret-username"]), a.set("password", c["x-scalar-secret-password"]);
113
+ n.set("grant_type", "password"), n.set("username", c["x-scalar-secret-username"]), n.set("password", c["x-scalar-secret-password"]);
114
114
  } else
115
- a.set("grant_type", "client_credentials");
116
- r["x-scalar-security-body"] && Object.entries(r["x-scalar-security-body"]).forEach(([c, l]) => {
117
- l && a.set(c, l);
115
+ n.set("grant_type", "client_credentials");
116
+ s["x-scalar-security-body"] && Object.entries(s["x-scalar-security-body"]).forEach(([c, l]) => {
117
+ l && n.set(c, String(l));
118
118
  });
119
119
  try {
120
120
  const c = {
121
121
  "Content-Type": "application/x-www-form-urlencoded"
122
122
  };
123
- n || (c.Authorization = `Basic ${R(`${r["x-scalar-secret-client-id"]}:${r["x-scalar-secret-client-secret"]}`)}`);
124
- const l = S(r.tokenUrl, b(h, p)), k = F(g, l) ? `${g}?${new URLSearchParams([["scalar_url", l]]).toString()}` : l, s = await (await fetch(k, {
123
+ a || (c.Authorization = `Basic ${T(`${s["x-scalar-secret-client-id"]}:${s["x-scalar-secret-client-secret"]}`)}`);
124
+ const l = A(s.tokenUrl, z(f, p)), U = R(g, l) ? `${g}?${new URLSearchParams([["scalar_url", l]]).toString()}` : l, r = await (await fetch(U, {
125
125
  method: "POST",
126
126
  headers: c,
127
- body: a
128
- })).json(), o = r["x-tokenName"] || "access_token";
129
- return [null, s[o]];
127
+ body: n
128
+ })).json(), o = s["x-tokenName"] || "access_token", d = r[o], _ = r.refresh_token;
129
+ return [null, { accessToken: d, ...typeof _ == "string" ? { refreshToken: _ } : {} }];
130
130
  } catch {
131
131
  return [new Error("Failed to get an access token. Please check your credentials."), null];
132
132
  }
133
133
  };
134
134
  export {
135
- q as authorizeOauth2
135
+ B as authorizeOauth2
136
136
  };
@@ -1,7 +1,7 @@
1
- import type { XScalarSecretClientId, XScalarSecretClientSecret, XScalarSecretHTTP, XScalarSecretRedirectUri, XScalarSecretToken } from '@scalar/workspace-store/schemas/extensions/security';
1
+ import type { XScalarSecretClientId, XScalarSecretClientSecret, XScalarSecretHTTP, XScalarSecretRedirectUri, XScalarSecretRefreshToken, XScalarSecretToken } from '@scalar/workspace-store/schemas/extensions/security';
2
2
  import type { OAuthFlowAuthorizationCode, OAuthFlowClientCredentials, OAuthFlowImplicit, OAuthFlowPassword } from '@scalar/workspace-store/schemas/v3.1/strict/oauth-flow';
3
3
  import type { ApiKeyObject, HttpObject, OAuth2Object, OpenIdConnectObject } from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document';
4
- type OAuthFlowCommonSecret = XScalarSecretClientId & XScalarSecretToken;
4
+ type OAuthFlowCommonSecret = XScalarSecretClientId & XScalarSecretToken & XScalarSecretRefreshToken;
5
5
  export type OAuthFlowImplicitSecret = OAuthFlowImplicit & OAuthFlowCommonSecret & XScalarSecretRedirectUri;
6
6
  export type OAuthFlowPasswordSecret = OAuthFlowPassword & OAuthFlowCommonSecret & XScalarSecretHTTP & XScalarSecretClientSecret;
7
7
  export type OAuthFlowClientCredentialsSecret = OAuthFlowClientCredentials & OAuthFlowCommonSecret & XScalarSecretClientSecret;
@@ -1 +1 @@
1
- {"version":3,"file":"secret-types.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/helpers/secret-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,qDAAqD,CAAA;AAC5D,OAAO,KAAK,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,wDAAwD,CAAA;AAC/D,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,mBAAmB,EACpB,MAAM,8DAA8D,CAAA;AAErE,KAAK,qBAAqB,GAAG,qBAAqB,GAAG,kBAAkB,CAAA;AAEvE,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG,qBAAqB,GAAG,wBAAwB,CAAA;AAE1G,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GACrD,qBAAqB,GACrB,iBAAiB,GACjB,yBAAyB,CAAA;AAE3B,MAAM,MAAM,gCAAgC,GAAG,0BAA0B,GACvE,qBAAqB,GACrB,yBAAyB,CAAA;AAE3B,MAAM,MAAM,gCAAgC,GAAG,0BAA0B,GACvE,qBAAqB,GACrB,yBAAyB,GACzB,wBAAwB,CAAA;AAE1B,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;IAClC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;IAClC,iBAAiB,CAAC,EAAE,gCAAgC,CAAA;IACpD,iBAAiB,CAAC,EAAE,gCAAgC,CAAA;CACrD,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAClE,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;AAClF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG;IAAE,KAAK,EAAE,sBAAsB,CAAA;CAAE,CAAA;AAChG,MAAM,MAAM,yBAAyB,GAAG,mBAAmB,GAAG;IAAE,KAAK,CAAC,EAAE,sBAAsB,CAAA;CAAE,CAAA;AAEhG,MAAM,MAAM,0BAA0B,GAClC,kBAAkB,GAClB,gBAAgB,GAChB,kBAAkB,GAClB,yBAAyB,CAAA"}
1
+ {"version":3,"file":"secret-types.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/helpers/secret-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,qDAAqD,CAAA;AAC5D,OAAO,KAAK,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,wDAAwD,CAAA;AAC/D,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,mBAAmB,EACpB,MAAM,8DAA8D,CAAA;AAErE,KAAK,qBAAqB,GAAG,qBAAqB,GAAG,kBAAkB,GAAG,yBAAyB,CAAA;AAEnG,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG,qBAAqB,GAAG,wBAAwB,CAAA;AAE1G,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GACrD,qBAAqB,GACrB,iBAAiB,GACjB,yBAAyB,CAAA;AAE3B,MAAM,MAAM,gCAAgC,GAAG,0BAA0B,GACvE,qBAAqB,GACrB,yBAAyB,CAAA;AAE3B,MAAM,MAAM,gCAAgC,GAAG,0BAA0B,GACvE,qBAAqB,GACrB,yBAAyB,GACzB,wBAAwB,CAAA;AAE1B,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;IAClC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;IAClC,iBAAiB,CAAC,EAAE,gCAAgC,CAAA;IACpD,iBAAiB,CAAC,EAAE,gCAAgC,CAAA;CACrD,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAClE,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;AAClF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,GAAG;IAAE,KAAK,EAAE,sBAAsB,CAAA;CAAE,CAAA;AAChG,MAAM,MAAM,yBAAyB,GAAG,mBAAmB,GAAG;IAAE,KAAK,CAAC,EAAE,sBAAsB,CAAA;CAAE,CAAA;AAEhG,MAAM,MAAM,0BAA0B,GAClC,kBAAkB,GAClB,gBAAgB,GAChB,kBAAkB,GAClB,yBAAyB,CAAA"}