@scalar/api-client
Version:
the open source API testing client
83 lines (82 loc) • 2.97 kB
JavaScript
import { defineComponent as d, computed as i, createBlock as v, openBlock as y, withCtx as n, createElementVNode as a, normalizeClass as r, createVNode as s, unref as l, createTextVNode as u } from "vue";
import { ScalarToggle as h } from "@scalar/components";
import f from "../../settings/components/Section.vue.js";
import { getActiveProxyUrl as S } from "../../../helpers/get-active-proxy-url.js";
import p from "../../../blocks/scalar-auth-selector-block/components/AuthSelector.vue.js";
const x = { class: "flex h-8 items-center" }, V = /* @__PURE__ */ d({
__name: "Authentication",
props: {
documentSlug: {},
document: {},
eventBus: {},
layout: {},
path: {},
method: {},
exampleName: {},
environment: {},
securitySchemes: {},
workspaceStore: {},
activeWorkspace: {},
plugins: {},
customThemes: {},
collectionType: {}
},
setup(e) {
const o = i(
() => e.document?.["x-scalar-set-operation-security"] ?? !1
), m = i(
() => e.document?.servers?.find(
({ url: c }) => c === e.document?.["x-scalar-selected-server"]
) ?? null
);
return (c, t) => (y(), v(f, null, {
title: n(() => [...t[1] || (t[1] = [
u("Authentication", -1)
])]),
description: n(() => [...t[2] || (t[2] = [
u(" If enabled, all selected authentication will apply to all operations in this document. You can override this by disabling the toggle and authentication will then be applied at the operation level. ", -1)
])]),
actions: n(() => [
a("div", x, [
s(l(h), {
class: "w-4",
modelValue: o.value,
"onUpdate:modelValue": t[0] || (t[0] = () => e.eventBus.emit("document:toggle:security"))
}, null, 8, ["modelValue"])
])
]),
default: n(() => [
a("div", {
class: r(!o.value && "cursor-not-allowed")
}, [
s(l(p), {
class: r([
"scalar-collection-auth border-none!",
!o.value && "pointer-events-none opacity-50 mix-blend-luminosity"
]),
environment: e.environment,
eventBus: e.eventBus,
isStatic: "",
meta: { type: "document" },
proxyUrl: l(S)(
e.workspaceStore.workspace["x-scalar-active-proxy"],
e.layout
) ?? "",
securityRequirements: e.document?.security ?? [],
securitySchemes: e.securitySchemes,
selectedSecurity: e.workspaceStore.auth.getAuthSelectedSchemas({
type: "document",
documentName: e.documentSlug
}),
server: m.value,
title: "Authentication"
}, null, 8, ["class", "environment", "eventBus", "proxyUrl", "securityRequirements", "securitySchemes", "selectedSecurity", "server"])
], 2)
]),
_: 1
}));
}
});
export {
V as default
};