@scalar/api-client 3.19.0 → 3.19.2
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.
- package/CHANGELOG.md +22 -0
- package/dist/style.css +55 -25
- package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.js +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js +21 -5
- package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBodyRaw.vue.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBodyRaw.vue.js +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBodyRaw.vue.js.map +1 -1
- package/dist/v2/blocks/response-block/components/ResponseBodyRaw.vue.script.js +42 -16
- package/dist/v2/blocks/response-block/components/ResponseBodyRaw.vue.script.js.map +1 -1
- package/dist/v2/blocks/response-block/helpers/media-types.d.ts.map +1 -1
- package/dist/v2/blocks/response-block/helpers/media-types.js +5 -0
- package/dist/v2/blocks/response-block/helpers/media-types.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue.d.ts +16 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue.js +7 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue.js.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue.script.js +86 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue.script.js.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.script.js +19 -2
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-oauth2-metadata.d.ts +6 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-oauth2-metadata.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-oauth2-metadata.js +25 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-oauth2-metadata.js.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.d.ts +1 -2
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.js +2 -2
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/fetch-openid-connect-discovery.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js +13 -9
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth2-metadata-to-flows.d.ts +9 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth2-metadata-to-flows.d.ts.map +1 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth2-metadata-to-flows.js +36 -0
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/oauth2-metadata-to-flows.js.map +1 -0
- package/dist/v2/components/code-input/CodeInput.vue.d.ts +2 -2
- package/dist/v2/components/code-input/CodeInput.vue.d.ts.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.js.map +1 -1
- package/dist/v2/components/code-input/CodeInput.vue.script.js +40 -9
- package/dist/v2/components/code-input/CodeInput.vue.script.js.map +1 -1
- package/dist/v2/components/server/ServerDropdown.vue.d.ts.map +1 -1
- package/dist/v2/components/server/ServerDropdown.vue.js.map +1 -1
- package/dist/v2/components/server/ServerDropdown.vue.script.js +1 -1
- package/dist/v2/components/server/ServerDropdown.vue.script.js.map +1 -1
- package/dist/v2/constants.js +1 -1
- package/dist/v2/features/modal/helpers/resolve-route-parameters.d.ts +9 -3
- package/dist/v2/features/modal/helpers/resolve-route-parameters.d.ts.map +1 -1
- package/dist/v2/features/modal/helpers/resolve-route-parameters.js.map +1 -1
- package/dist/vue-styles.css +33 -23
- package/package.json +16 -16
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { prettifyJsoncString } from "../helpers/prettify-jsonc-string.js";
|
|
2
|
-
import { computed,
|
|
3
|
-
import {
|
|
2
|
+
import { computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, openBlock, ref, toRef, unref, useId } from "vue";
|
|
3
|
+
import { ScalarIconArrowElbowDownLeft } from "@scalar/icons";
|
|
4
|
+
import { ScalarIconButton } from "@scalar/components/icon-button";
|
|
5
|
+
import { EditorView, useCodeMirror } from "@scalar/use-codemirror";
|
|
4
6
|
import { ScalarCodeBlockCopy } from "@scalar/components/code-block";
|
|
5
7
|
//#region src/v2/blocks/response-block/components/ResponseBodyRaw.vue?vue&type=script&setup=true&lang.ts
|
|
6
8
|
var _hoisted_1 = {
|
|
@@ -11,6 +13,10 @@ var _hoisted_2 = {
|
|
|
11
13
|
class: "custom-scroll relative pr-1",
|
|
12
14
|
tabindex: "0"
|
|
13
15
|
};
|
|
16
|
+
var _hoisted_3 = {
|
|
17
|
+
key: 0,
|
|
18
|
+
class: "absolute top-2 right-2 flex items-center gap-1.5 opacity-0 transition-opacity duration-150 group-hover/code-block:opacity-100 group-has-focus-visible/code-block:opacity-100"
|
|
19
|
+
};
|
|
14
20
|
var ResponseBodyRaw_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
15
21
|
__name: "ResponseBodyRaw",
|
|
16
22
|
props: {
|
|
@@ -23,35 +29,55 @@ var ResponseBodyRaw_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
|
|
|
23
29
|
const codeMirrorRef = ref(null);
|
|
24
30
|
/** Base id for the code block */
|
|
25
31
|
const id = useId();
|
|
32
|
+
const isLineWrapping = ref(false);
|
|
33
|
+
const displayContent = computed(() => {
|
|
34
|
+
const { content, language, prettyPrintJson = false } = props;
|
|
35
|
+
if (typeof content !== "string") {
|
|
36
|
+
if (content == null) return "";
|
|
37
|
+
return String(content);
|
|
38
|
+
}
|
|
39
|
+
if (prettyPrintJson && language === "json") return prettifyJsoncString(content);
|
|
40
|
+
return content;
|
|
41
|
+
});
|
|
42
|
+
const extensions = computed(() => isLineWrapping.value ? [EditorView.lineWrapping] : []);
|
|
26
43
|
const { codeMirror } = useCodeMirror({
|
|
27
44
|
codeMirrorRef,
|
|
28
45
|
readOnly: true,
|
|
29
46
|
lineNumbers: true,
|
|
30
|
-
content: toRef(
|
|
31
|
-
const { content, language, prettyPrintJson = false } = props;
|
|
32
|
-
if (typeof content !== "string") {
|
|
33
|
-
if (content == null) return "";
|
|
34
|
-
return String(content);
|
|
35
|
-
}
|
|
36
|
-
if (prettyPrintJson && language === "json") return prettifyJsoncString(content);
|
|
37
|
-
return content;
|
|
38
|
-
})),
|
|
47
|
+
content: toRef(displayContent),
|
|
39
48
|
language: toRef(() => props.language),
|
|
40
|
-
forceFoldGutter: true
|
|
49
|
+
forceFoldGutter: true,
|
|
50
|
+
extensions
|
|
41
51
|
});
|
|
42
52
|
const getCurrentContent = () => {
|
|
43
53
|
return codeMirror.value?.state.doc.toString() || "";
|
|
44
54
|
};
|
|
55
|
+
const toggleLineWrapping = () => {
|
|
56
|
+
isLineWrapping.value = !isLineWrapping.value;
|
|
57
|
+
};
|
|
45
58
|
return (_ctx, _cache) => {
|
|
46
59
|
return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [createElementVNode("div", {
|
|
47
60
|
ref_key: "codeMirrorRef",
|
|
48
61
|
ref: codeMirrorRef
|
|
49
|
-
}, null, 512)]), getCurrentContent() ? (openBlock(),
|
|
50
|
-
|
|
62
|
+
}, null, 512)]), getCurrentContent() ? (openBlock(), createElementBlock("div", _hoisted_3, [createVNode(unref(ScalarIconButton), {
|
|
63
|
+
class: "bg-b-2 text-c-2 hover:text-c-1 absolute right-18",
|
|
64
|
+
icon: unref(ScalarIconArrowElbowDownLeft),
|
|
65
|
+
"aria-pressed": isLineWrapping.value,
|
|
66
|
+
"aria-label": isLineWrapping.value ? "Disable line wrap" : "Wrap lines",
|
|
67
|
+
label: isLineWrapping.value ? "Disable line wrap" : "Wrap lines",
|
|
68
|
+
size: "sm",
|
|
69
|
+
tooltip: "",
|
|
70
|
+
variant: "ghost",
|
|
71
|
+
onClick: toggleLineWrapping
|
|
72
|
+
}, null, 8, [
|
|
73
|
+
"icon",
|
|
74
|
+
"aria-pressed",
|
|
75
|
+
"aria-label",
|
|
76
|
+
"label"
|
|
77
|
+
]), createVNode(unref(ScalarCodeBlockCopy), {
|
|
51
78
|
"aria-controls": unref(id),
|
|
52
|
-
class: "absolute top-2 right-2",
|
|
53
79
|
content: getCurrentContent()
|
|
54
|
-
}, null, 8, ["aria-controls", "content"])) : createCommentVNode("", true)]);
|
|
80
|
+
}, null, 8, ["aria-controls", "content"])])) : createCommentVNode("", true)]);
|
|
55
81
|
};
|
|
56
82
|
}
|
|
57
83
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseBodyRaw.vue.script.js","names":[],"sources":["../../../../../src/v2/blocks/response-block/components/ResponseBodyRaw.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { ScalarCodeBlockCopy } from '@scalar/components/code-block'\nimport { useCodeMirror
|
|
1
|
+
{"version":3,"file":"ResponseBodyRaw.vue.script.js","names":[],"sources":["../../../../../src/v2/blocks/response-block/components/ResponseBodyRaw.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { ScalarCodeBlockCopy } from '@scalar/components/code-block'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { ScalarIconArrowElbowDownLeft } from '@scalar/icons'\nimport {\n EditorView,\n useCodeMirror,\n type CodeMirrorLanguage,\n} from '@scalar/use-codemirror'\nimport { computed, ref, toRef, useId } from 'vue'\n\nimport { prettifyJsoncString } from '@/v2/blocks/response-block/helpers/prettify-jsonc-string'\n\nconst props = defineProps<{\n content: unknown\n language: CodeMirrorLanguage | undefined\n /** When true, JSON/JSONC strings are pretty-printed for the Preview tab (wire bytes stay unchanged in Raw). */\n prettyPrintJson?: boolean\n}>()\n\nconst codeMirrorRef = ref<HTMLDivElement | null>(null)\n/** Base id for the code block */\nconst id = useId()\n\nconst isLineWrapping = ref(false)\n\nconst displayContent = computed((): string => {\n const { content, language, prettyPrintJson = false } = props\n if (typeof content !== 'string') {\n if (content == null) {\n return ''\n }\n return String(content)\n }\n if (prettyPrintJson && language === 'json') {\n return prettifyJsoncString(content)\n }\n return content\n})\n\nconst extensions = computed(() =>\n isLineWrapping.value ? [EditorView.lineWrapping] : [],\n)\n\nconst { codeMirror } = useCodeMirror({\n codeMirrorRef,\n readOnly: true,\n lineNumbers: true,\n content: toRef(displayContent),\n language: toRef(() => props.language),\n forceFoldGutter: true,\n extensions,\n})\n\n// Function to get current content\nconst getCurrentContent = () => {\n return codeMirror.value?.state.doc.toString() || ''\n}\n\nconst toggleLineWrapping = (): void => {\n isLineWrapping.value = !isLineWrapping.value\n}\n</script>\n<template>\n <div\n class=\"scalar-code-block group/code-block relative grid min-h-0 overflow-hidden p-px outline-none has-focus-visible:outline\"\n data-testid=\"response-body-raw\">\n <div\n class=\"custom-scroll relative pr-1\"\n tabindex=\"0\">\n <!-- CodeMirror container -->\n <div ref=\"codeMirrorRef\" />\n </div>\n <!-- Action buttons -->\n <div\n v-if=\"getCurrentContent()\"\n class=\"absolute top-2 right-2 flex items-center gap-1.5 opacity-0 transition-opacity duration-150 group-hover/code-block:opacity-100 group-has-focus-visible/code-block:opacity-100\">\n <ScalarIconButton\n class=\"bg-b-2 text-c-2 hover:text-c-1 absolute right-18\"\n :icon=\"ScalarIconArrowElbowDownLeft\"\n :aria-pressed=\"isLineWrapping\"\n :aria-label=\"isLineWrapping ? 'Disable line wrap' : 'Wrap lines'\"\n :label=\"isLineWrapping ? 'Disable line wrap' : 'Wrap lines'\"\n size=\"sm\"\n tooltip\n variant=\"ghost\"\n @click=\"toggleLineWrapping\" />\n <ScalarCodeBlockCopy\n :aria-controls=\"id\"\n :content=\"getCurrentContent()\" />\n </div>\n </div>\n</template>\n<style scoped>\n:deep(.cm-editor) {\n background-color: transparent;\n font-size: var(--scalar-small);\n outline: none;\n}\n\n:deep(.cm-gutters) {\n background-color: var(--scalar-background-1);\n border-radius: var(--scalar-radius) 0 0 var(--scalar-radius);\n}\n\n:deep(.cm-scroller) {\n overflow: auto;\n min-width: 100%;\n}\n\n:deep(.cm-lineWrapping .cm-line) {\n word-break: break-all;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAaA,MAAM,QAAQ;EAOd,MAAM,gBAAgB,IAA2B,IAAI;;EAErD,MAAM,KAAK,MAAM;EAEjB,MAAM,iBAAiB,IAAI,KAAK;EAEhC,MAAM,iBAAiB,eAAuB;GAC5C,MAAM,EAAE,SAAS,UAAU,kBAAkB,UAAU;GACvD,IAAI,OAAO,YAAY,UAAU;IAC/B,IAAI,WAAW,MACb,OAAO;IAET,OAAO,OAAO,OAAO;GACvB;GACA,IAAI,mBAAmB,aAAa,QAClC,OAAO,oBAAoB,OAAO;GAEpC,OAAO;EACT,CAAC;EAED,MAAM,aAAa,eACjB,eAAe,QAAQ,CAAC,WAAW,YAAY,IAAI,CAAC,CACtD;EAEA,MAAM,EAAE,eAAe,cAAc;GACnC;GACA,UAAU;GACV,aAAa;GACb,SAAS,MAAM,cAAc;GAC7B,UAAU,YAAY,MAAM,QAAQ;GACpC,iBAAiB;GACjB;EACF,CAAC;EAGD,MAAM,0BAA0B;GAC9B,OAAO,WAAW,OAAO,MAAM,IAAI,SAAS,KAAK;EACnD;EAEA,MAAM,2BAAiC;GACrC,eAAe,QAAQ,CAAC,eAAe;EACzC;;uBAGE,mBA2BM,OA3BN,YA2BM,CAxBJ,mBAKM,OALN,YAKM,CADJ,mBAA2B,OAAA;aAAlB;IAAJ,KAAI;oBAIH,kBAAiB,KAAA,UAAA,GADzB,mBAgBM,OAhBN,YAgBM,CAbJ,YASgC,MAAA,gBAAA,GAAA;IAR9B,OAAM;IACL,MAAM,MAAA,4BAAA;IACN,gBAAc,eAAA;IACd,cAAY,eAAA,QAAc,sBAAA;IAC1B,OAAO,eAAA,QAAc,sBAAA;IACtB,MAAK;IACL,SAAA;IACA,SAAQ;IACP,SAAO;;;;;;OACV,YAEmC,MAAA,mBAAA,GAAA;IADhC,iBAAe,MAAA,EAAA;IACf,SAAS,kBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-types.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/response-block/helpers/media-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAEhE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAA;AAErF,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AA6JD,iEAAiE;AACjE,eAAO,MAAM,cAAc,EAAE,MAAM,EAEX,CAAA;AAExB,sCAAsC;AACtC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"media-types.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/response-block/helpers/media-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAEhE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAA;AAErF,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAC7B,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AA6JD,iEAAiE;AACjE,eAAO,MAAM,cAAc,EAAE,MAAM,EAEX,CAAA;AAExB,sCAAsC;AACtC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CA0BxE;AAED,8DAA8D;AAC9D,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD"}
|
|
@@ -244,6 +244,11 @@ function getMediaTypeConfig(type) {
|
|
|
244
244
|
language: "json",
|
|
245
245
|
preview: "json"
|
|
246
246
|
};
|
|
247
|
+
if (type.endsWith("+xml")) return {
|
|
248
|
+
extension: ".xml",
|
|
249
|
+
raw: true,
|
|
250
|
+
language: "xml"
|
|
251
|
+
};
|
|
247
252
|
}
|
|
248
253
|
/** Check if a media type that can be displayed as raw text */
|
|
249
254
|
function isTextMediaType(type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-types.js","names":[],"sources":["../../../../../src/v2/blocks/response-block/helpers/media-types.ts"],"sourcesContent":["import type { CodeMirrorLanguage } from '@scalar/use-codemirror'\n\nexport type MediaPreview = 'object' | 'image' | 'video' | 'audio' | 'json' | 'ndjson'\n\ntype MediaConfig = {\n preview?: MediaPreview\n alpha?: boolean\n raw?: boolean\n language?: CodeMirrorLanguage\n extension: string\n}\n\n/** Media Type (MIME Type) Definitions */\nconst mediaTypes: { [type: string]: MediaConfig | undefined } = {\n 'application/epub+zip': { extension: '.epub' },\n 'application/gzip': { extension: '.gz' },\n 'application/java-archive': { extension: '.jar' },\n 'application/javascript': { extension: '.js', raw: true },\n 'application/json': {\n extension: '.json',\n raw: true,\n language: 'json',\n preview: 'json',\n },\n 'application/ld+json': {\n extension: '.jsonld',\n raw: true,\n language: 'json',\n preview: 'json',\n },\n 'application/problem+json': {\n extension: '.json',\n raw: true,\n language: 'json',\n preview: 'json',\n },\n 'application/vnd.api+json': {\n extension: '.json',\n raw: true,\n language: 'json',\n preview: 'json',\n },\n 'application/dns-json': {\n extension: '.json',\n raw: true,\n language: 'json',\n preview: 'json',\n },\n // Newline-delimited JSON is many JSON objects separated by newlines, not one\n // JSON document. The `ndjson` preview pretty-prints each line on its own, while\n // Raw keeps the exact wire format of one object per line.\n 'application/x-ndjson': {\n extension: '.ndjson',\n raw: true,\n language: 'json',\n preview: 'ndjson',\n },\n 'application/ndjson': {\n extension: '.ndjson',\n raw: true,\n language: 'json',\n preview: 'ndjson',\n },\n 'application/msword': { extension: '.doc' },\n 'application/octet-stream': { extension: '.bin' },\n 'application/ogg': { extension: '.ogx' },\n 'application/pdf': { extension: '.pdf', preview: 'object' },\n 'application/rtf': { extension: '.rtf', raw: true },\n 'application/vnd.amazon.ebook': { extension: '.azw' },\n 'application/vnd.apple.installer+xml': {\n extension: '.mpkg',\n raw: true,\n language: 'xml',\n },\n 'application/vnd.mozilla.xul+xml': {\n extension: '.xul',\n raw: true,\n language: 'xml',\n },\n 'application/vnd.ms-excel': { extension: '.xls' },\n 'application/vnd.ms-fontobject': { extension: '.eot' },\n 'application/vnd.ms-powerpoint': { extension: '.ppt' },\n 'application/vnd.oasis.opendocument.presentation': { extension: '.odp' },\n 'application/vnd.oasis.opendocument.spreadsheet': { extension: '.ods' },\n 'application/vnd.oasis.opendocument.text': { extension: '.odt' },\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation': {\n extension: '.pptx',\n },\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': {\n extension: '.xlsx',\n },\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': {\n extension: '.docx',\n },\n 'application/vnd.rar': { extension: '.rar' },\n 'application/vnd.visio': { extension: '.vsd' },\n 'application/x-7z-compressed': { extension: '.7z' },\n 'application/x-abiword': { extension: '.abw' },\n 'application/x-bzip': { extension: '.bz' },\n 'application/x-bzip2': { extension: '.bz2' },\n 'application/x-cdf': { extension: '.cda' },\n 'application/x-csh': { extension: '.csh' },\n 'application/x-freearc': { extension: '.arc' },\n 'application/x-httpd-php': { extension: '.php', raw: true },\n 'application/x-sh': { extension: '.sh', raw: true },\n 'application/x-tar': { extension: '.tar' },\n 'application/xhtml+xml': { extension: '.xhtml', raw: true, language: 'html' },\n 'application/xml': { extension: '.xml', raw: true, language: 'xml' },\n 'application/yaml': { extension: '.yaml', raw: true, language: 'yaml' },\n 'application/zip': { extension: '.zip' },\n 'audio/aac': { extension: '.aac' },\n 'audio/midi': { extension: '.midi' },\n 'audio/mpeg': { extension: '.mp3', preview: 'audio' },\n 'audio/ogg': { extension: '.oga' },\n 'audio/wav': { extension: '.wav' },\n 'audio/webm': { extension: '.weba' },\n 'font/otf': { extension: '.otf' },\n 'font/ttf': { extension: '.ttf' },\n 'font/woff': { extension: '.woff' },\n 'font/woff2': { extension: '.woff2' },\n 'image/apng': { extension: '.apng', preview: 'image', alpha: true },\n 'image/avif': { extension: '.avif', preview: 'image' },\n 'image/bmp': { extension: '.bmp', preview: 'image' },\n 'image/gif': { extension: '.gif', preview: 'image', alpha: true },\n 'image/jpeg': { extension: '.jpg', preview: 'image' },\n 'image/png': { extension: '.png', preview: 'image', alpha: true },\n 'image/svg+xml': {\n extension: '.svg',\n raw: true,\n language: 'xml',\n preview: 'image',\n alpha: true,\n },\n 'image/tiff': { extension: '.tiff' },\n 'image/vnd.microsoft.icon': { extension: '.ico', preview: 'image' },\n 'image/webp': { extension: '.webp', preview: 'image', alpha: true },\n 'text/calendar': { extension: '.ics', raw: true },\n 'text/css': { extension: '.css', raw: true, language: 'css' },\n 'text/csv': { extension: '.csv', raw: true },\n 'text/html': {\n extension: '.html',\n raw: true,\n language: 'html',\n preview: 'object',\n },\n 'text/javascript': { extension: '.js', raw: true },\n 'text/json': {\n extension: '.json',\n raw: true,\n language: 'json',\n preview: 'json',\n },\n 'text/plain': { extension: '.txt', raw: true },\n 'text/xml': { extension: '.xml', raw: true, language: 'xml' },\n 'text/yaml': { extension: '.yaml', raw: true, language: 'yaml' },\n 'video/3gpp': { extension: '.3gp' },\n 'audio/3gpp': { extension: '.3gp' },\n 'video/3gpp2': { extension: '.3g2' },\n 'audio/3gpp2': { extension: '.3g2' },\n 'video/mp2t': { extension: '.ts' },\n 'video/mp4': { extension: '.mp4', preview: 'video' },\n 'video/mpeg': { extension: '.mpeg' },\n 'video/ogg': { extension: '.ogv' },\n 'video/webm': { extension: '.webm', preview: 'video' },\n 'video/x-msvideo': { extension: '.avi' },\n}\n\n/** Media Types (MIME Types) that can be displayed as raw text */\nexport const textMediaTypes: string[] = Object.entries(mediaTypes)\n .filter(([, config]) => config?.raw)\n .map(([type]) => type)\n\n/** Get the config for a media type */\nexport function getMediaTypeConfig(type: string): MediaConfig | undefined {\n const config = mediaTypes[type]\n if (config) {\n return config\n }\n\n // Fallback for +json types\n if (type.endsWith('+json')) {\n return {\n extension: '.json',\n raw: true,\n language: 'json',\n preview: 'json',\n }\n }\n\n return undefined\n}\n\n/** Check if a media type that can be displayed as raw text */\nexport function isTextMediaType(type: string): boolean {\n return !!getMediaTypeConfig(type)?.raw\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"media-types.js","names":[],"sources":["../../../../../src/v2/blocks/response-block/helpers/media-types.ts"],"sourcesContent":["import type { CodeMirrorLanguage } from '@scalar/use-codemirror'\n\nexport type MediaPreview = 'object' | 'image' | 'video' | 'audio' | 'json' | 'ndjson'\n\ntype MediaConfig = {\n preview?: MediaPreview\n alpha?: boolean\n raw?: boolean\n language?: CodeMirrorLanguage\n extension: string\n}\n\n/** Media Type (MIME Type) Definitions */\nconst mediaTypes: { [type: string]: MediaConfig | undefined } = {\n 'application/epub+zip': { extension: '.epub' },\n 'application/gzip': { extension: '.gz' },\n 'application/java-archive': { extension: '.jar' },\n 'application/javascript': { extension: '.js', raw: true },\n 'application/json': {\n extension: '.json',\n raw: true,\n language: 'json',\n preview: 'json',\n },\n 'application/ld+json': {\n extension: '.jsonld',\n raw: true,\n language: 'json',\n preview: 'json',\n },\n 'application/problem+json': {\n extension: '.json',\n raw: true,\n language: 'json',\n preview: 'json',\n },\n 'application/vnd.api+json': {\n extension: '.json',\n raw: true,\n language: 'json',\n preview: 'json',\n },\n 'application/dns-json': {\n extension: '.json',\n raw: true,\n language: 'json',\n preview: 'json',\n },\n // Newline-delimited JSON is many JSON objects separated by newlines, not one\n // JSON document. The `ndjson` preview pretty-prints each line on its own, while\n // Raw keeps the exact wire format of one object per line.\n 'application/x-ndjson': {\n extension: '.ndjson',\n raw: true,\n language: 'json',\n preview: 'ndjson',\n },\n 'application/ndjson': {\n extension: '.ndjson',\n raw: true,\n language: 'json',\n preview: 'ndjson',\n },\n 'application/msword': { extension: '.doc' },\n 'application/octet-stream': { extension: '.bin' },\n 'application/ogg': { extension: '.ogx' },\n 'application/pdf': { extension: '.pdf', preview: 'object' },\n 'application/rtf': { extension: '.rtf', raw: true },\n 'application/vnd.amazon.ebook': { extension: '.azw' },\n 'application/vnd.apple.installer+xml': {\n extension: '.mpkg',\n raw: true,\n language: 'xml',\n },\n 'application/vnd.mozilla.xul+xml': {\n extension: '.xul',\n raw: true,\n language: 'xml',\n },\n 'application/vnd.ms-excel': { extension: '.xls' },\n 'application/vnd.ms-fontobject': { extension: '.eot' },\n 'application/vnd.ms-powerpoint': { extension: '.ppt' },\n 'application/vnd.oasis.opendocument.presentation': { extension: '.odp' },\n 'application/vnd.oasis.opendocument.spreadsheet': { extension: '.ods' },\n 'application/vnd.oasis.opendocument.text': { extension: '.odt' },\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation': {\n extension: '.pptx',\n },\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': {\n extension: '.xlsx',\n },\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': {\n extension: '.docx',\n },\n 'application/vnd.rar': { extension: '.rar' },\n 'application/vnd.visio': { extension: '.vsd' },\n 'application/x-7z-compressed': { extension: '.7z' },\n 'application/x-abiword': { extension: '.abw' },\n 'application/x-bzip': { extension: '.bz' },\n 'application/x-bzip2': { extension: '.bz2' },\n 'application/x-cdf': { extension: '.cda' },\n 'application/x-csh': { extension: '.csh' },\n 'application/x-freearc': { extension: '.arc' },\n 'application/x-httpd-php': { extension: '.php', raw: true },\n 'application/x-sh': { extension: '.sh', raw: true },\n 'application/x-tar': { extension: '.tar' },\n 'application/xhtml+xml': { extension: '.xhtml', raw: true, language: 'html' },\n 'application/xml': { extension: '.xml', raw: true, language: 'xml' },\n 'application/yaml': { extension: '.yaml', raw: true, language: 'yaml' },\n 'application/zip': { extension: '.zip' },\n 'audio/aac': { extension: '.aac' },\n 'audio/midi': { extension: '.midi' },\n 'audio/mpeg': { extension: '.mp3', preview: 'audio' },\n 'audio/ogg': { extension: '.oga' },\n 'audio/wav': { extension: '.wav' },\n 'audio/webm': { extension: '.weba' },\n 'font/otf': { extension: '.otf' },\n 'font/ttf': { extension: '.ttf' },\n 'font/woff': { extension: '.woff' },\n 'font/woff2': { extension: '.woff2' },\n 'image/apng': { extension: '.apng', preview: 'image', alpha: true },\n 'image/avif': { extension: '.avif', preview: 'image' },\n 'image/bmp': { extension: '.bmp', preview: 'image' },\n 'image/gif': { extension: '.gif', preview: 'image', alpha: true },\n 'image/jpeg': { extension: '.jpg', preview: 'image' },\n 'image/png': { extension: '.png', preview: 'image', alpha: true },\n 'image/svg+xml': {\n extension: '.svg',\n raw: true,\n language: 'xml',\n preview: 'image',\n alpha: true,\n },\n 'image/tiff': { extension: '.tiff' },\n 'image/vnd.microsoft.icon': { extension: '.ico', preview: 'image' },\n 'image/webp': { extension: '.webp', preview: 'image', alpha: true },\n 'text/calendar': { extension: '.ics', raw: true },\n 'text/css': { extension: '.css', raw: true, language: 'css' },\n 'text/csv': { extension: '.csv', raw: true },\n 'text/html': {\n extension: '.html',\n raw: true,\n language: 'html',\n preview: 'object',\n },\n 'text/javascript': { extension: '.js', raw: true },\n 'text/json': {\n extension: '.json',\n raw: true,\n language: 'json',\n preview: 'json',\n },\n 'text/plain': { extension: '.txt', raw: true },\n 'text/xml': { extension: '.xml', raw: true, language: 'xml' },\n 'text/yaml': { extension: '.yaml', raw: true, language: 'yaml' },\n 'video/3gpp': { extension: '.3gp' },\n 'audio/3gpp': { extension: '.3gp' },\n 'video/3gpp2': { extension: '.3g2' },\n 'audio/3gpp2': { extension: '.3g2' },\n 'video/mp2t': { extension: '.ts' },\n 'video/mp4': { extension: '.mp4', preview: 'video' },\n 'video/mpeg': { extension: '.mpeg' },\n 'video/ogg': { extension: '.ogv' },\n 'video/webm': { extension: '.webm', preview: 'video' },\n 'video/x-msvideo': { extension: '.avi' },\n}\n\n/** Media Types (MIME Types) that can be displayed as raw text */\nexport const textMediaTypes: string[] = Object.entries(mediaTypes)\n .filter(([, config]) => config?.raw)\n .map(([type]) => type)\n\n/** Get the config for a media type */\nexport function getMediaTypeConfig(type: string): MediaConfig | undefined {\n const config = mediaTypes[type]\n if (config) {\n return config\n }\n\n // Fallback for +json types\n if (type.endsWith('+json')) {\n return {\n extension: '.json',\n raw: true,\n language: 'json',\n preview: 'json',\n }\n }\n\n // Preserve specialized XML previews above, while treating other +xml types as text.\n if (type.endsWith('+xml')) {\n return {\n extension: '.xml',\n raw: true,\n language: 'xml',\n }\n }\n\n return undefined\n}\n\n/** Check if a media type that can be displayed as raw text */\nexport function isTextMediaType(type: string): boolean {\n return !!getMediaTypeConfig(type)?.raw\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
2
|
+
import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
|
|
3
|
+
import type { OAuth2Object } from '@scalar/workspace-store/schemas/v3.2/strict/security-scheme';
|
|
4
|
+
import type { CustomFetch } from '../../../../v2/blocks/operation-block/helpers/send-request.js';
|
|
5
|
+
type __VLS_Props = {
|
|
6
|
+
scheme: OAuth2Object;
|
|
7
|
+
name: string;
|
|
8
|
+
environment: XScalarEnvironment;
|
|
9
|
+
eventBus: WorkspaceEventBus;
|
|
10
|
+
proxyUrl: string;
|
|
11
|
+
customFetch?: CustomFetch;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
//# sourceMappingURL=OAuth2Metadata.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuth2Metadata.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue"],"names":[],"mappings":"AAgGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AACnH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6DAA6D,CAAA;AAE/F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAA;AAOnF,KAAK,WAAW,GAAG;IACf,MAAM,EAAE,YAAY,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,kBAAkB,CAAA;IAC/B,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,WAAW,CAAA;CAC1B,CAAC;AAiKJ,QAAA,MAAM,YAAY,kSAEhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import OAuth2Metadata_vue_vue_type_script_setup_true_lang_default from "./OAuth2Metadata.vue.script.js";
|
|
2
|
+
//#region src/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue
|
|
3
|
+
var OAuth2Metadata_default = OAuth2Metadata_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { OAuth2Metadata_default as default };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=OAuth2Metadata.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuth2Metadata.vue.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { useLoadingState } from '@scalar/components/loading'\nimport { useToasts } from '@scalar/use-toasts'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { OAuth2Object } from '@scalar/workspace-store/schemas/v3.2/strict/security-scheme'\n\nimport type { CustomFetch } from '@/v2/blocks/operation-block/helpers/send-request'\nimport { fetchOAuth2Metadata } from '@/v2/blocks/scalar-auth-selector-block/helpers/fetch-oauth2-metadata'\nimport { oauth2MetadataToFlows } from '@/v2/blocks/scalar-auth-selector-block/helpers/oauth2-metadata-to-flows'\nimport { DataTableRow } from '@/v2/components/data-table'\n\nimport RequestAuthDataTableInput from './RequestAuthDataTableInput.vue'\n\nconst { scheme, name, environment, eventBus, proxyUrl, customFetch } =\n defineProps<{\n scheme: OAuth2Object\n name: string\n environment: XScalarEnvironment\n eventBus: WorkspaceEventBus\n proxyUrl: string\n customFetch?: CustomFetch\n }>()\nconst loader = useLoadingState()\nconst { toast } = useToasts()\n\nconst updateMetadataUrl = (oauth2MetadataUrl: string): void =>\n eventBus.emit('auth:update:security-scheme', {\n name,\n payload: { type: 'oauth2', oauth2MetadataUrl },\n })\n\n/** Apply metadata only to the scheme and URL that initiated the request. */\nconst fetchConfiguration = async (): Promise<void> => {\n const url = scheme.oauth2MetadataUrl\n const schemeName = name\n if (!url || loader.isLoading) {\n return\n }\n loader.start()\n const [error, metadata] = await fetchOAuth2Metadata(\n url,\n proxyUrl,\n customFetch,\n )\n await loader.clear()\n // Store updates can replace the proxy without changing the selected authorization server.\n if (name !== schemeName || scheme.oauth2MetadataUrl !== url) {\n return\n }\n if (error) {\n toast(error.message, 'error')\n return\n }\n eventBus.emit('auth:update:security-scheme', {\n name,\n payload: {\n type: 'oauth2',\n flows: oauth2MetadataToFlows(metadata, scheme.flows),\n },\n })\n}\n</script>\n\n<template>\n <DataTableRow>\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"scheme.oauth2MetadataUrl ?? ''\"\n placeholder=\"https://example.com/.well-known/oauth-authorization-server\"\n @update:modelValue=\"updateMetadataUrl\">\n Metadata URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n <DataTableRow\n v-if=\"scheme.oauth2MetadataUrl\"\n class=\"min-w-full\">\n <div class=\"flex h-8 w-full items-center justify-end border-t\">\n <ScalarButton\n class=\"mr-0.75 p-0 px-2 py-0.5\"\n :loader\n size=\"sm\"\n variant=\"outlined\"\n @click=\"fetchConfiguration\">\n Fetch Configuration\n </ScalarButton>\n </div>\n </DataTableRow>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import DataTableRow_default from "../../../components/data-table/DataTableRow.vue.js";
|
|
2
|
+
import RequestAuthDataTableInput_default from "./RequestAuthDataTableInput.vue.js";
|
|
3
|
+
import { fetchOAuth2Metadata } from "../helpers/fetch-oauth2-metadata.js";
|
|
4
|
+
import { oauth2MetadataToFlows } from "../helpers/oauth2-metadata-to-flows.js";
|
|
5
|
+
import { Fragment, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, unref, withCtx } from "vue";
|
|
6
|
+
import { ScalarButton } from "@scalar/components/button";
|
|
7
|
+
import { useToasts } from "@scalar/use-toasts";
|
|
8
|
+
import { useLoadingState } from "@scalar/components/loading";
|
|
9
|
+
//#region src/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue?vue&type=script&setup=true&lang.ts
|
|
10
|
+
var _hoisted_1 = { class: "flex h-8 w-full items-center justify-end border-t" };
|
|
11
|
+
var OAuth2Metadata_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
12
|
+
__name: "OAuth2Metadata",
|
|
13
|
+
props: {
|
|
14
|
+
scheme: {},
|
|
15
|
+
name: {},
|
|
16
|
+
environment: {},
|
|
17
|
+
eventBus: {},
|
|
18
|
+
proxyUrl: {},
|
|
19
|
+
customFetch: {}
|
|
20
|
+
},
|
|
21
|
+
setup(__props) {
|
|
22
|
+
const loader = useLoadingState();
|
|
23
|
+
const { toast } = useToasts();
|
|
24
|
+
const updateMetadataUrl = (oauth2MetadataUrl) => __props.eventBus.emit("auth:update:security-scheme", {
|
|
25
|
+
name: __props.name,
|
|
26
|
+
payload: {
|
|
27
|
+
type: "oauth2",
|
|
28
|
+
oauth2MetadataUrl
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
/** Apply metadata only to the scheme and URL that initiated the request. */
|
|
32
|
+
const fetchConfiguration = async () => {
|
|
33
|
+
const url = __props.scheme.oauth2MetadataUrl;
|
|
34
|
+
const schemeName = __props.name;
|
|
35
|
+
if (!url || loader.isLoading) return;
|
|
36
|
+
loader.start();
|
|
37
|
+
const [error, metadata] = await fetchOAuth2Metadata(url, __props.proxyUrl, __props.customFetch);
|
|
38
|
+
await loader.clear();
|
|
39
|
+
if (__props.name !== schemeName || __props.scheme.oauth2MetadataUrl !== url) return;
|
|
40
|
+
if (error) {
|
|
41
|
+
toast(error.message, "error");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
__props.eventBus.emit("auth:update:security-scheme", {
|
|
45
|
+
name: __props.name,
|
|
46
|
+
payload: {
|
|
47
|
+
type: "oauth2",
|
|
48
|
+
flows: oauth2MetadataToFlows(metadata, __props.scheme.flows)
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
return (_ctx, _cache) => {
|
|
53
|
+
return openBlock(), createElementBlock(Fragment, null, [createVNode(unref(DataTableRow_default), null, {
|
|
54
|
+
default: withCtx(() => [createVNode(RequestAuthDataTableInput_default, {
|
|
55
|
+
environment: __props.environment,
|
|
56
|
+
modelValue: __props.scheme.oauth2MetadataUrl ?? "",
|
|
57
|
+
placeholder: "https://example.com/.well-known/oauth-authorization-server",
|
|
58
|
+
"onUpdate:modelValue": updateMetadataUrl
|
|
59
|
+
}, {
|
|
60
|
+
default: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode(" Metadata URL ", -1)])]),
|
|
61
|
+
_: 1
|
|
62
|
+
}, 8, ["environment", "modelValue"])]),
|
|
63
|
+
_: 1
|
|
64
|
+
}), __props.scheme.oauth2MetadataUrl ? (openBlock(), createBlock(unref(DataTableRow_default), {
|
|
65
|
+
key: 0,
|
|
66
|
+
class: "min-w-full"
|
|
67
|
+
}, {
|
|
68
|
+
default: withCtx(() => [createElementVNode("div", _hoisted_1, [createVNode(unref(ScalarButton), {
|
|
69
|
+
class: "mr-0.75 p-0 px-2 py-0.5",
|
|
70
|
+
loader: unref(loader),
|
|
71
|
+
size: "sm",
|
|
72
|
+
variant: "outlined",
|
|
73
|
+
onClick: fetchConfiguration
|
|
74
|
+
}, {
|
|
75
|
+
default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode(" Fetch Configuration ", -1)])]),
|
|
76
|
+
_: 1
|
|
77
|
+
}, 8, ["loader"])])]),
|
|
78
|
+
_: 1
|
|
79
|
+
})) : createCommentVNode("", true)], 64);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
//#endregion
|
|
84
|
+
export { OAuth2Metadata_vue_vue_type_script_setup_true_lang_default as default };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=OAuth2Metadata.vue.script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuth2Metadata.vue.script.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuth2Metadata.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { useLoadingState } from '@scalar/components/loading'\nimport { useToasts } from '@scalar/use-toasts'\nimport type { WorkspaceEventBus } from '@scalar/workspace-store/events'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport type { OAuth2Object } from '@scalar/workspace-store/schemas/v3.2/strict/security-scheme'\n\nimport type { CustomFetch } from '@/v2/blocks/operation-block/helpers/send-request'\nimport { fetchOAuth2Metadata } from '@/v2/blocks/scalar-auth-selector-block/helpers/fetch-oauth2-metadata'\nimport { oauth2MetadataToFlows } from '@/v2/blocks/scalar-auth-selector-block/helpers/oauth2-metadata-to-flows'\nimport { DataTableRow } from '@/v2/components/data-table'\n\nimport RequestAuthDataTableInput from './RequestAuthDataTableInput.vue'\n\nconst { scheme, name, environment, eventBus, proxyUrl, customFetch } =\n defineProps<{\n scheme: OAuth2Object\n name: string\n environment: XScalarEnvironment\n eventBus: WorkspaceEventBus\n proxyUrl: string\n customFetch?: CustomFetch\n }>()\nconst loader = useLoadingState()\nconst { toast } = useToasts()\n\nconst updateMetadataUrl = (oauth2MetadataUrl: string): void =>\n eventBus.emit('auth:update:security-scheme', {\n name,\n payload: { type: 'oauth2', oauth2MetadataUrl },\n })\n\n/** Apply metadata only to the scheme and URL that initiated the request. */\nconst fetchConfiguration = async (): Promise<void> => {\n const url = scheme.oauth2MetadataUrl\n const schemeName = name\n if (!url || loader.isLoading) {\n return\n }\n loader.start()\n const [error, metadata] = await fetchOAuth2Metadata(\n url,\n proxyUrl,\n customFetch,\n )\n await loader.clear()\n // Store updates can replace the proxy without changing the selected authorization server.\n if (name !== schemeName || scheme.oauth2MetadataUrl !== url) {\n return\n }\n if (error) {\n toast(error.message, 'error')\n return\n }\n eventBus.emit('auth:update:security-scheme', {\n name,\n payload: {\n type: 'oauth2',\n flows: oauth2MetadataToFlows(metadata, scheme.flows),\n },\n })\n}\n</script>\n\n<template>\n <DataTableRow>\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"scheme.oauth2MetadataUrl ?? ''\"\n placeholder=\"https://example.com/.well-known/oauth-authorization-server\"\n @update:modelValue=\"updateMetadataUrl\">\n Metadata URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n <DataTableRow\n v-if=\"scheme.oauth2MetadataUrl\"\n class=\"min-w-full\">\n <div class=\"flex h-8 w-full items-center justify-end border-t\">\n <ScalarButton\n class=\"mr-0.75 p-0 px-2 py-0.5\"\n :loader\n size=\"sm\"\n variant=\"outlined\"\n @click=\"fetchConfiguration\">\n Fetch Configuration\n </ScalarButton>\n </div>\n </DataTableRow>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAwBA,MAAM,SAAS,gBAAgB;EAC/B,MAAM,EAAE,UAAU,UAAU;EAE5B,MAAM,qBAAqB,sBACzB,QAAA,SAAS,KAAK,+BAA+B;GAC3C,MAAG,QAAA;GACH,SAAS;IAAE,MAAM;IAAU;GAAkB;EAC/C,CAAC;;EAGH,MAAM,qBAAqB,YAA2B;GACpD,MAAM,MAAM,QAAA,OAAO;GACnB,MAAM,aAAa,QAAA;GACnB,IAAI,CAAC,OAAO,OAAO,WACjB;GAEF,OAAO,MAAM;GACb,MAAM,CAAC,OAAO,YAAY,MAAM,oBAC9B,KACA,QAAA,UACA,QAAA,WACF;GACA,MAAM,OAAO,MAAM;GAEnB,IAAI,QAAA,SAAS,cAAc,QAAA,OAAO,sBAAsB,KACtD;GAEF,IAAI,OAAO;IACT,MAAM,MAAM,SAAS,OAAO;IAC5B;GACF;GACA,QAAA,SAAS,KAAK,+BAA+B;IAC3C,MAAG,QAAA;IACH,SAAS;KACP,MAAM;KACN,OAAO,sBAAsB,UAAU,QAAA,OAAO,KAAK;IACrD;GACF,CAAC;EACH;;2DAIE,YAQe,MAAA,oBAAA,GAAA,MAAA;2BADe,CAN5B,YAM4B,mCAAA;KALzB,aAAA,QAAA;KACA,YAAY,QAAA,OAAO,qBAAiB;KACrC,aAAY;KACX,uBAAmB;;4BAEtB,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAFyC,kBAEzC,EAAA,CAAA,EAAA,CAAA;;;;OAGM,QAAA,OAAO,qBAAA,UAAA,GADf,YAae,MAAA,oBAAA,GAAA;;IAXb,OAAM;;2BAUA,CATN,mBASM,OATN,YASM,CARJ,YAOe,MAAA,YAAA,GAAA;KANb,OAAM;KACL,QAAA,MAAA,MAAA;KACD,MAAK;KACL,SAAQ;KACP,SAAO;;4BAEV,CAAA,GAAA,OAAA,OAAA,OAAA,KAAA,CAAA,gBAF8B,yBAE9B,EAAA,CAAA,EAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestAuthTab.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RequestAuthTab.vue.d.ts","sourceRoot":"","sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue"],"names":[],"mappings":"AA0rBA,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,gCAAgC,CAAA;AAEvC,OAAO,EAEL,KAAK,qBAAqB,EAG3B,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAA;AAEnH,OAAO,KAAK,EAEV,yBAAyB,EACzB,YAAY,EACb,MAAM,8DAA8D,CAAA;AAgBrE,OAAe,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAA;AAazD,KAAK,WAAW,GAAG;IACjB,wCAAwC;IACxC,WAAW,EAAE,kBAAkB,CAAA;IAC/B,yFAAyF;IACzF,QAAQ,EAAE,OAAO,CAAA;IACjB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,+BAA+B;IAC/B,uBAAuB,EAAE,yBAAyB,CAAA;IAClD,oGAAoG;IACpG,eAAe,EAAE,qBAAqB,CAAA;IACtC,mCAAmC;IACnC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAA;IAC3B,2CAA2C;IAC3C,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,uDAAuD;IACvD,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,yFAAyF;IACzF,YAAY,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;CACtC,CAAC;AAwtCF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kFAGhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestAuthTab.vue.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { useLoadingState } from '@scalar/components/loading'\nimport { ScalarMarkdownSummary } from '@scalar/components/markdown'\nimport { ScalarModal, useModal } from '@scalar/components/modal'\nimport { ScalarIconGear } from '@scalar/icons'\nimport { useToasts } from '@scalar/use-toasts'\nimport type {\n SecretsApiKey,\n SecretsHttp,\n} from '@scalar/workspace-store/entities/auth'\nimport type {\n ApiReferenceEvents,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getEnvironmentVariables,\n type MergedSecuritySchemes,\n type OAuthFlowsObjectSecret,\n type SecuritySchemeObjectSecret,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { getDocumentTypeLabel } from '@scalar/workspace-store/schemas/type-guards'\nimport type {\n ApiKeyObject,\n SecurityRequirementObject,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { capitalize, computed, ref } from 'vue'\n\nimport { refreshOauth2Token } from '@/v2/blocks/scalar-auth-selector-block/helpers/oauth'\nimport { getVisibleOrderedFlowKeys } from '@/v2/blocks/scalar-auth-selector-block/helpers/oauth-flows'\nimport {\n runOAuth2Authorize,\n storeOAuth2Tokens,\n} from '@/v2/blocks/scalar-auth-selector-block/helpers/run-oauth2-authorize'\nimport { getOauth2AcquisitionTarget } from '@/v2/blocks/scalar-auth-selector-block/helpers/security-scheme'\nimport {\n DataTable,\n DataTableCell,\n DataTableRow,\n} from '@/v2/components/data-table'\n\nimport OAuth2, { type OAuth2Options } from './OAuth2.vue'\nimport OpenIDConnect from './OpenIDConnect.vue'\nimport RequestAuthDataTableInput from './RequestAuthDataTableInput.vue'\n\ntype SecurityItem = {\n scheme: SecuritySchemeObjectSecret | undefined\n name: string\n scopes: string[]\n /** Ordered, non-hidden oauth2/openIdConnect flow keys for this scheme (empty for other types). */\n visibleFlowKeys: (keyof OAuthFlowsObjectSecret)[]\n}\n\nconst {\n environment,\n isStatic,\n proxyUrl,\n selectedSecuritySchemas,\n securitySchemes,\n server,\n eventBus,\n options,\n documentType = 'openapi',\n} = defineProps<{\n /** Current environment configuration */\n environment: XScalarEnvironment\n /** Controls the display of certain borders which are used when we are non-collapsible */\n isStatic: boolean\n /** Proxy URL */\n proxyUrl: string\n /** Selected security schemes*/\n selectedSecuritySchemas: SecurityRequirementObject\n /** Merged security schemes from the document and the config together with the auth store secrets */\n securitySchemes: MergedSecuritySchemes\n /** Current server configuration */\n server: ServerObject | null\n /** Event bus for authentication updates */\n eventBus: WorkspaceEventBus\n /** Any config options required for the OAuth2 flow */\n options?: OAuth2Options\n /** Type of the document the schemes belong to, used to label the missing-type warning */\n documentType?: 'openapi' | 'asyncapi'\n}>()\n\n/**\n * Human-readable name of the document type.\n * Used in the missing-type warning so it points at the correct document\n * (e.g. \"AsyncAPI\") instead of always naming OpenAPI.\n */\nconst documentTypeLabel = computed<string>(() =>\n getDocumentTypeLabel(documentType),\n)\n\nconst emits = defineEmits<{\n (\n e: 'update:selectedScopes',\n payload: Omit<ApiReferenceEvents['auth:update:selected-scopes'], 'meta'>,\n ): void\n (e: 'upsert:scope', payload: ApiReferenceEvents['auth:upsert:scopes']): void\n (e: 'delete:scope', payload: ApiReferenceEvents['auth:delete:scopes']): void\n}>()\n\n/**\n * Resolves security schemes from the OpenAPI document and combines them with their selected scopes.\n * Each item includes the scheme definition, name, and associated scopes.\n */\nconst security = computed<SecurityItem[]>(() =>\n Object.entries(selectedSecuritySchemas).map(([name, scopes = []]) => {\n const scheme = getResolvedRef(securitySchemes[name])\n return {\n scheme,\n name,\n scopes,\n // Compute the visible, ordered flow keys once per scheme so the tabs, the label, and the\n // active-flow tracking all agree on the same set (and we do not filter + sort on every access).\n visibleFlowKeys:\n scheme?.type === 'oauth2' || scheme?.type === 'openIdConnect'\n ? getVisibleOrderedFlowKeys(scheme.flows)\n : [],\n }\n }),\n)\n\n/** Tracks which OAuth2 flow is currently active when multiple flows are available. */\nconst activeFlow = ref<string>('')\n\n/**\n * Keeps the selected flow in sync with the currently visible flow keys. Validating against the\n * visible set (not every declared flow) means a selection that becomes hidden — e.g. the document\n * is updated to mark the active flow with `x-scalar-ignore` — resets, so the default (first visible)\n * flow activates instead of leaving no tab selected.\n */\nconst selectedFlow = computed<string>(() => {\n const visibleFlowKeys = security.value.flatMap((item) => item.visibleFlowKeys)\n\n return visibleFlowKeys.some((key) => key === activeFlow.value)\n ? activeFlow.value\n : ''\n})\n\nconst setActiveFlow = (flow: string): void => {\n activeFlow.value = flow\n}\n\n/** Determines if multiple auth schemes are configured, which affects the UI layout. */\nconst hasMultipleSchemes = computed<boolean>(() => security.value.length > 1)\n\n/**\n * Generates a human-readable label for the security scheme.\n * Intentionally omits the description here — it is rendered separately as\n * rich text via ScalarMarkdownSummary so markdown formatting is preserved.\n */\nconst generateLabel = (\n name: string,\n scheme: SecuritySchemeObjectSecret,\n): string => {\n const capitalizedName = capitalize(name)\n\n switch (scheme.type) {\n case 'apiKey':\n return `${capitalizedName}: ${scheme.in}`\n\n case 'openIdConnect':\n case 'oauth2': {\n const firstFlow = getVisibleOrderedFlowKeys(scheme.flows)[0]\n const currentFlow = selectedFlow.value || firstFlow\n if (!currentFlow) {\n return capitalizedName\n }\n return `${capitalizedName}: ${currentFlow}`\n }\n\n case 'http':\n return `${capitalizedName}: ${scheme.scheme}`\n\n default:\n return capitalizedName\n }\n}\n\n/**\n * Whether an API key scheme exposes an editable parameter name.\n *\n * OpenAPI `apiKey` and AsyncAPI `httpApiKey` (normalized to `apiKey`) name a query/header/cookie\n * parameter, so the Name input is shown. AsyncAPI `apiKey` places the key in the broker `user` or\n * `password` slot and has no parameter name, so the Name input is hidden and only the value is asked for.\n */\nconst apiKeyHasName = (scheme: { in?: string }): boolean =>\n scheme.in !== 'user' && scheme.in !== 'password'\n\n/**\n * The scheme's type when it is one we do not render inputs for (a type outside both the OpenAPI\n * and AsyncAPI security scheme unions). Read through a helper so the fallback template branch,\n * where the scheme type is narrowed to `never` after the supported cases, can still surface the type.\n */\nconst getUnsupportedSchemeType = (\n scheme: SecurityItem['scheme'],\n): string | undefined => scheme?.type\n\n/**\n * Determines if an OAuth2 flow tab should be active.\n * The first flow is active by default if no flow is explicitly selected.\n */\nconst isFlowActive = (flowKey: string, index: number): boolean =>\n selectedFlow.value === flowKey || (index === 0 && !selectedFlow.value)\n\n/** Computes the container class for static display mode. */\nconst getStaticBorderClass = (): string | false => isStatic && 'border-t'\n\nconst handleHttpSecretsUpdate = (\n payload: Omit<Partial<SecretsHttp>, 'type'>,\n name: string,\n): void =>\n eventBus.emit('auth:update:security-scheme-secrets', {\n payload: { type: 'http', ...payload },\n name,\n })\n\nconst handleApiKeySecretsUpdate = (\n payload: Omit<Partial<SecretsApiKey>, 'type'>,\n name: string,\n): void =>\n eventBus.emit('auth:update:security-scheme-secrets', {\n payload: { type: 'apiKey', ...payload },\n name,\n })\n\nconst handleApiKeySecuritySchemeUpdate = (\n payload: Omit<Partial<ApiKeyObject>, 'type'>,\n name: string,\n): void =>\n eventBus.emit('auth:update:security-scheme', {\n payload: { type: 'apiKey', ...payload },\n name,\n })\n\n/** Handles scope selection updates for OAuth2 */\nconst handleScopesUpdate = (\n name: string,\n event: { scopes?: string[]; scope?: string; selected?: boolean },\n): void => {\n emits('update:selectedScopes', {\n id: Object.keys(selectedSecuritySchemas),\n name,\n ...event,\n })\n}\n\n/** Handles scope-definition upserts (add / rename / description change) */\nconst handleScopeUpsert = (\n name: string,\n event: Omit<ApiReferenceEvents['auth:upsert:scopes'], 'name'>,\n): void => {\n emits('upsert:scope', { ...event, name })\n}\n\n/** Handles scope-definition deletes */\nconst handleScopeDelete = (\n name: string,\n event: Omit<ApiReferenceEvents['auth:delete:scopes'], 'name'>,\n): void => {\n emits('delete:scope', { ...event, name })\n}\n\n/**\n * Computes dynamic classes for OAuth2 flow tabs based on active state.\n */\nconst getFlowTabClasses = (flowKey: string, index: number): string => {\n const baseClasses =\n 'floating-bg text-c-3 relative cursor-pointer border-b border-transparent py-1 text-base font-medium'\n const activeClasses = '!text-c-1 !rounded-none border-b !border-current'\n\n return isFlowActive(flowKey, index)\n ? `${baseClasses} ${activeClasses} ${isStatic ? 'opacity-100' : ''}`\n : baseClasses\n}\n\n/**\n * OAuth2 token-acquisition target (an oauth2 scheme with an interactive grant) sourced from\n * the merged schemes. When the active scheme is HTTP bearer, this powers the inline\n * \"Authorize via OAuth2\" shortcut: the flow's bearer token is written onto the bearer scheme,\n * so the panel never switches to oauth2.\n *\n * The shortcut is purely a convenience, so it is offered for any interactive oauth2 scheme —\n * including one that is also independently selectable in the dropdown (e.g. Scalar Galaxy's\n * `oAuth2`). Whether that oauth2 scheme is *hidden* from the dropdown is a separate decision made\n * in the selector; here we only surface the shortcut.\n */\nconst oauth2Target = computed(() => getOauth2AcquisitionTarget(securitySchemes))\n\n/** Resolved oauth2 scheme object, for embedding its config form behind the gear. */\nconst oauth2Scheme = computed(() =>\n oauth2Target.value\n ? getResolvedRef(securitySchemes[oauth2Target.value.name])\n : undefined,\n)\n\nconst acquisitionLoader = useLoadingState()\nconst { toast } = useToasts()\nconst configModal = useModal()\n/** Bearer scheme that opened the config modal, so its Authorize callback targets it. */\nconst configBearerName = ref<string | undefined>()\n\n/** Runs the OAuth2 flow and writes the resulting bearer token onto the bearer scheme. */\nconst handleAcquisitionAuthorize = async (\n bearerName: string,\n): Promise<void> => {\n const target = oauth2Target.value\n if (!target || acquisitionLoader.isLoading) {\n return\n }\n acquisitionLoader.start()\n const [error] = await runOAuth2Authorize({\n eventBus,\n bearerSchemeName: bearerName,\n oauth2Name: target.name,\n flows: target.flows,\n flowType: target.flowType,\n scopes: target.scopes,\n server,\n proxyUrl,\n environment,\n options,\n })\n await acquisitionLoader.clear()\n if (error) {\n toast(error?.message ?? 'Failed to authorize', 'error')\n }\n}\n\n/** Refreshes the OAuth2 token and rewrites it onto the bearer scheme. */\nconst handleAcquisitionRefresh = async (bearerName: string): Promise<void> => {\n const target = oauth2Target.value\n // Only the authorization-code flow carries a refresh token; implicit can't be refreshed.\n if (\n !target ||\n target.flowType !== 'authorizationCode' ||\n acquisitionLoader.isLoading\n ) {\n return\n }\n acquisitionLoader.start()\n const [error, tokens] = await refreshOauth2Token(\n target.flows,\n target.flowType,\n proxyUrl,\n server,\n getEnvironmentVariables(environment),\n options?.customFetch,\n )\n await acquisitionLoader.clear()\n if (tokens?.accessToken) {\n storeOAuth2Tokens(eventBus, {\n bearerSchemeName: bearerName,\n oauth2Name: target.name,\n flowType: target.flowType,\n tokens,\n })\n } else if (error) {\n toast(error?.message ?? 'Failed to refresh', 'error')\n }\n}\n\nconst openAcquisitionConfig = (bearerName: string): void => {\n configBearerName.value = bearerName\n configModal.show()\n}\n\n/** Closes the config modal and runs Authorize against the bearer scheme that opened it. */\nconst handleConfigAuthorize = (): void => {\n const bearerName = configBearerName.value\n configModal.hide()\n if (bearerName) {\n void handleAcquisitionAuthorize(bearerName)\n }\n}\n</script>\n<template>\n <template\n v-for=\"{ scheme, name, scopes, visibleFlowKeys } in security\"\n :key=\"name\">\n <!--\n Header row for AND'ed schemes: label (bold) and description (rich text) are\n combined.\n -->\n <DataTableRow v-if=\"hasMultipleSchemes && scheme\">\n <DataTableCell\n :aria-label=\"generateLabel(name, scheme)\"\n class=\"max-h-[auto]\">\n <div class=\"bg-b-1 min-w-0 flex-1 px-3 py-1.25\">\n <p class=\"text-c-1 leading-5.5 font-medium\">\n {{ generateLabel(name, scheme) }}\n </p>\n <ScalarMarkdownSummary\n v-if=\"scheme.description\"\n class=\"auth-description text-c-2 w-full\"\n :value=\"scheme.description\" />\n </div>\n </DataTableCell>\n </DataTableRow>\n\n <!-- Description: shown for single auth schemes with descriptions -->\n <DataTableRow v-if=\"scheme?.description && !hasMultipleSchemes\">\n <DataTableCell\n :aria-label=\"scheme.description\"\n class=\"max-h-[auto]\">\n <ScalarMarkdownSummary\n class=\"auth-description bg-b-1 text-c-2 min-w-0 flex-1 px-3 py-1.25\"\n :value=\"scheme.description\" />\n </DataTableCell>\n </DataTableRow>\n\n <!-- HTTP Authentication -->\n <template v-if=\"scheme?.type === 'http'\">\n <!-- Bearer Token -->\n <DataTableRow v-if=\"scheme.scheme === 'bearer'\">\n <RequestAuthDataTableInput\n :containerClass=\"getStaticBorderClass()\"\n :environment\n :modelValue=\"scheme['x-scalar-secret-token']\"\n placeholder=\"Token\"\n type=\"password\"\n @update:modelValue=\"\n (v) => handleHttpSecretsUpdate({ 'x-scalar-secret-token': v }, name)\n \">\n Bearer Token\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <!-- OAuth2 token-acquisition shortcut (shown when an interactive oauth2 flow exists) -->\n <DataTableRow v-if=\"scheme.scheme === 'bearer' && oauth2Target\">\n <div class=\"flex h-8 items-center gap-2 border-t px-3\">\n <span class=\"text-c-3 mr-auto text-xs\">Get a token</span>\n <ScalarButton\n class=\"p-0 px-2 py-0.5\"\n :loader=\"acquisitionLoader\"\n size=\"sm\"\n type=\"button\"\n variant=\"outlined\"\n @click=\"handleAcquisitionAuthorize(name)\">\n Authorize via {{ oauth2Target.name }}\n </ScalarButton>\n <ScalarButton\n v-if=\"\n scheme['x-scalar-secret-token'] &&\n oauth2Target.flowType === 'authorizationCode'\n \"\n class=\"p-0 px-2 py-0.5\"\n :disabled=\"acquisitionLoader.isLoading\"\n size=\"sm\"\n type=\"button\"\n variant=\"outlined\"\n @click=\"handleAcquisitionRefresh(name)\">\n Refresh\n </ScalarButton>\n <ScalarIconButton\n :icon=\"ScalarIconGear\"\n :label=\"`Configure ${oauth2Target.name}`\"\n size=\"xs\"\n @click=\"openAcquisitionConfig(name)\" />\n </div>\n </DataTableRow>\n\n <!-- HTTP Basic Authentication -->\n <template v-else-if=\"scheme?.scheme === 'basic'\">\n <DataTableRow>\n <RequestAuthDataTableInput\n class=\"text-c-2\"\n :environment\n :modelValue=\"scheme['x-scalar-secret-username']\"\n placeholder=\"janedoe\"\n required\n @update:modelValue=\"\n (v) =>\n handleHttpSecretsUpdate({ 'x-scalar-secret-username': v }, name)\n \">\n Username\n </RequestAuthDataTableInput>\n </DataTableRow>\n <DataTableRow>\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"scheme['x-scalar-secret-password']\"\n placeholder=\"********\"\n type=\"password\"\n @update:modelValue=\"\n (v) =>\n handleHttpSecretsUpdate({ 'x-scalar-secret-password': v }, name)\n \">\n Password\n </RequestAuthDataTableInput>\n </DataTableRow>\n </template>\n </template>\n\n <!-- API Key Authentication -->\n <template v-else-if=\"scheme?.type === 'apiKey'\">\n <DataTableRow v-if=\"apiKeyHasName(scheme)\">\n <RequestAuthDataTableInput\n :containerClass=\"getStaticBorderClass()\"\n :environment\n :modelValue=\"scheme.name ?? ''\"\n placeholder=\"api-key\"\n @update:modelValue=\"\n (v) => handleApiKeySecuritySchemeUpdate({ name: v }, name)\n \">\n Name\n </RequestAuthDataTableInput>\n </DataTableRow>\n <DataTableRow>\n <RequestAuthDataTableInput\n :containerClass=\"\n apiKeyHasName(scheme) ? undefined : getStaticBorderClass()\n \"\n :environment\n :modelValue=\"scheme['x-scalar-secret-token']\"\n placeholder=\"QUxMIFlPVVIgQkFTRSBBUkUgQkVMT05HIFRPIFVT\"\n type=\"password\"\n @update:modelValue=\"\n (v) =>\n handleApiKeySecretsUpdate({ 'x-scalar-secret-token': v }, name)\n \">\n Value\n </RequestAuthDataTableInput>\n </DataTableRow>\n </template>\n\n <!-- OAuth 2.0 / OpenID Connect Authentication -->\n <template\n v-else-if=\"scheme?.type === 'oauth2' || scheme?.type === 'openIdConnect'\">\n <!-- OpenID Connect -->\n <OpenIDConnect\n v-if=\"scheme?.type === 'openIdConnect' && !visibleFlowKeys.length\"\n :customFetch=\"options?.customFetch\"\n :environment\n :eventBus\n :getStaticBorderClass\n :name\n :proxyUrl\n :scheme />\n\n <!-- Flow selector tabs: shown when multiple visible flows are available -->\n <DataTableRow v-if=\"visibleFlowKeys.length > 1\">\n <div class=\"flex min-h-8 border-t text-base\">\n <div class=\"flex h-8 max-w-full gap-2.5 overflow-x-auto px-3\">\n <button\n v-for=\"(key, ind) in visibleFlowKeys\"\n :key=\"key\"\n :class=\"getFlowTabClasses(key, ind)\"\n type=\"button\"\n @click=\"setActiveFlow(key)\">\n <span class=\"relative z-10\">{{ key }}</span>\n </button>\n </div>\n </div>\n </DataTableRow>\n\n <!-- OAuth2 flow configuration -->\n <template\n v-for=\"(key, ind) in visibleFlowKeys\"\n :key=\"key\">\n <OAuth2\n v-if=\"scheme.flows && isFlowActive(key, ind)\"\n :environment\n :eventBus\n :flows=\"scheme.flows\"\n :name\n :options\n :proxyUrl\n :scheme\n :selectedScopes=\"scopes\"\n :server\n :type=\"key\"\n @delete:scope=\"(event) => handleScopeDelete(name, event)\"\n @update:selectedScopes=\"(event) => handleScopesUpdate(name, event)\"\n @upsert:scope=\"(event) => handleScopeUpsert(name, event)\" />\n </template>\n </template>\n\n <!-- Browser WebSocket connections cannot apply these broker credentials. -->\n <div\n v-else-if=\"\n scheme?.type === 'userPassword' ||\n scheme?.type === 'plain' ||\n scheme?.type === 'scramSha256' ||\n scheme?.type === 'scramSha512' ||\n scheme?.type === 'X509' ||\n scheme?.type === 'symmetricEncryption' ||\n scheme?.type === 'asymmetricEncryption' ||\n scheme?.type === 'gssapi'\n \"\n class=\"text-c-3 flex items-center justify-center border-t p-4 px-4 text-center text-xs text-balance\">\n Credentials for this AsyncAPI security scheme are not sent by the browser\n client.\n </div>\n\n <!-- Mutual TLS credentials are chosen during the browser-managed TLS handshake. -->\n <div\n v-else-if=\"scheme?.type === 'mutualTLS'\"\n class=\"text-c-3 flex items-center justify-center border-t p-4 px-4 text-center text-xs text-balance\">\n Mutual TLS authenticates with a client certificate presented during the\n TLS handshake, so there is nothing to enter here.\n </div>\n\n <!-- Scheme has a type we do not render inputs for -->\n <div\n v-else-if=\"getUnsupportedSchemeType(scheme)\"\n class=\"text-c-3 flex items-center justify-center border-t p-4 px-4 text-center text-xs text-balance\">\n The <code>{{ getUnsupportedSchemeType(scheme) }}</code> security scheme\n type is not supported yet.\n </div>\n\n <!-- Scheme is missing type -->\n <div\n v-else\n class=\"text-c-3 flex items-center justify-center border-t p-4 px-4 text-center text-xs text-balance\">\n The security scheme is missing a type, please double check your\n {{ documentTypeLabel }} document or Authentication Configuration\n </div>\n </template>\n\n <!-- OAuth2 configuration modal (opened from the bearer scheme's gear) -->\n <ScalarModal\n v-if=\"oauth2Target && oauth2Scheme\"\n :state=\"configModal\"\n size=\"sm\"\n :title=\"`Configure ${oauth2Target.name}`\">\n <DataTable\n :columns=\"['']\"\n presentational>\n <OAuth2\n hideActions\n :environment\n :eventBus\n :flows=\"oauth2Target.flows\"\n :name=\"oauth2Target.name\"\n :options\n :proxyUrl\n :scheme=\"oauth2Scheme\"\n :selectedScopes=\"oauth2Target.scopes\"\n :server\n :type=\"oauth2Target.flowType\"\n @delete:scope=\"(event) => handleScopeDelete(oauth2Target!.name, event)\"\n @update:selectedScopes=\"\n (event) => handleScopesUpdate(oauth2Target!.name, event)\n \"\n @upsert:scope=\"\n (event) => handleScopeUpsert(oauth2Target!.name, event)\n \" />\n </DataTable>\n <div class=\"flex h-8 items-center justify-end gap-2 border-t\">\n <ScalarButton\n class=\"p-0 px-2 py-0.5\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"configModal.hide()\">\n Cancel\n </ScalarButton>\n <ScalarButton\n class=\"p-0 px-2 py-0.5\"\n :loader=\"acquisitionLoader\"\n size=\"sm\"\n @click=\"handleConfigAuthorize\">\n Authorize\n </ScalarButton>\n </div>\n </ScalarModal>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"RequestAuthTab.vue.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { useLoadingState } from '@scalar/components/loading'\nimport { ScalarMarkdownSummary } from '@scalar/components/markdown'\nimport { ScalarModal, useModal } from '@scalar/components/modal'\nimport { ScalarIconGear } from '@scalar/icons'\nimport { useToasts } from '@scalar/use-toasts'\nimport type {\n SecretsApiKey,\n SecretsHttp,\n} from '@scalar/workspace-store/entities/auth'\nimport type {\n ApiReferenceEvents,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport { getResolvedRef } from '@scalar/workspace-store/helpers/get-resolved-ref'\nimport {\n getEnvironmentVariables,\n type MergedSecuritySchemes,\n type OAuthFlowsObjectSecret,\n type SecuritySchemeObjectSecret,\n} from '@scalar/workspace-store/request-example'\nimport type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments'\nimport { getDocumentTypeLabel } from '@scalar/workspace-store/schemas/type-guards'\nimport type {\n ApiKeyObject,\n SecurityRequirementObject,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { capitalize, computed, ref } from 'vue'\n\nimport { refreshOauth2Token } from '@/v2/blocks/scalar-auth-selector-block/helpers/oauth'\nimport { getVisibleOrderedFlowKeys } from '@/v2/blocks/scalar-auth-selector-block/helpers/oauth-flows'\nimport {\n runOAuth2Authorize,\n storeOAuth2Tokens,\n} from '@/v2/blocks/scalar-auth-selector-block/helpers/run-oauth2-authorize'\nimport { getOauth2AcquisitionTarget } from '@/v2/blocks/scalar-auth-selector-block/helpers/security-scheme'\nimport {\n DataTable,\n DataTableCell,\n DataTableRow,\n} from '@/v2/components/data-table'\n\nimport OAuth2, { type OAuth2Options } from './OAuth2.vue'\nimport OAuth2Metadata from './OAuth2Metadata.vue'\nimport OpenIDConnect from './OpenIDConnect.vue'\nimport RequestAuthDataTableInput from './RequestAuthDataTableInput.vue'\n\ntype SecurityItem = {\n scheme: SecuritySchemeObjectSecret | undefined\n name: string\n scopes: string[]\n /** Ordered, non-hidden oauth2/openIdConnect flow keys for this scheme (empty for other types). */\n visibleFlowKeys: (keyof OAuthFlowsObjectSecret)[]\n}\n\nconst {\n environment,\n isStatic,\n proxyUrl,\n selectedSecuritySchemas,\n securitySchemes,\n server,\n eventBus,\n options,\n documentType = 'openapi',\n} = defineProps<{\n /** Current environment configuration */\n environment: XScalarEnvironment\n /** Controls the display of certain borders which are used when we are non-collapsible */\n isStatic: boolean\n /** Proxy URL */\n proxyUrl: string\n /** Selected security schemes*/\n selectedSecuritySchemas: SecurityRequirementObject\n /** Merged security schemes from the document and the config together with the auth store secrets */\n securitySchemes: MergedSecuritySchemes\n /** Current server configuration */\n server: ServerObject | null\n /** Event bus for authentication updates */\n eventBus: WorkspaceEventBus\n /** Any config options required for the OAuth2 flow */\n options?: OAuth2Options\n /** Type of the document the schemes belong to, used to label the missing-type warning */\n documentType?: 'openapi' | 'asyncapi'\n}>()\n\n/**\n * Human-readable name of the document type.\n * Used in the missing-type warning so it points at the correct document\n * (e.g. \"AsyncAPI\") instead of always naming OpenAPI.\n */\nconst documentTypeLabel = computed<string>(() =>\n getDocumentTypeLabel(documentType),\n)\n\nconst emits = defineEmits<{\n (\n e: 'update:selectedScopes',\n payload: Omit<ApiReferenceEvents['auth:update:selected-scopes'], 'meta'>,\n ): void\n (e: 'upsert:scope', payload: ApiReferenceEvents['auth:upsert:scopes']): void\n (e: 'delete:scope', payload: ApiReferenceEvents['auth:delete:scopes']): void\n}>()\n\n/**\n * Resolves security schemes from the OpenAPI document and combines them with their selected scopes.\n * Each item includes the scheme definition, name, and associated scopes.\n */\nconst security = computed<SecurityItem[]>(() =>\n Object.entries(selectedSecuritySchemas).map(([name, scopes = []]) => {\n const scheme = getResolvedRef(securitySchemes[name])\n return {\n scheme,\n name,\n scopes,\n // Compute the visible, ordered flow keys once per scheme so the tabs, the label, and the\n // active-flow tracking all agree on the same set (and we do not filter + sort on every access).\n visibleFlowKeys:\n scheme?.type === 'oauth2' || scheme?.type === 'openIdConnect'\n ? getVisibleOrderedFlowKeys(scheme.flows)\n : [],\n }\n }),\n)\n\n/** Tracks which OAuth2 flow is currently active when multiple flows are available. */\nconst activeFlow = ref<string>('')\n\n/**\n * Keeps the selected flow in sync with the currently visible flow keys. Validating against the\n * visible set (not every declared flow) means a selection that becomes hidden — e.g. the document\n * is updated to mark the active flow with `x-scalar-ignore` — resets, so the default (first visible)\n * flow activates instead of leaving no tab selected.\n */\nconst selectedFlow = computed<string>(() => {\n const visibleFlowKeys = security.value.flatMap((item) => item.visibleFlowKeys)\n\n return visibleFlowKeys.some((key) => key === activeFlow.value)\n ? activeFlow.value\n : ''\n})\n\nconst setActiveFlow = (flow: string): void => {\n activeFlow.value = flow\n}\n\n/** Determines if multiple auth schemes are configured, which affects the UI layout. */\nconst hasMultipleSchemes = computed<boolean>(() => security.value.length > 1)\n\n/**\n * Generates a human-readable label for the security scheme.\n * Intentionally omits the description here — it is rendered separately as\n * rich text via ScalarMarkdownSummary so markdown formatting is preserved.\n */\nconst generateLabel = (\n name: string,\n scheme: SecuritySchemeObjectSecret,\n): string => {\n const capitalizedName = capitalize(name)\n\n switch (scheme.type) {\n case 'apiKey':\n return `${capitalizedName}: ${scheme.in}`\n\n case 'openIdConnect':\n case 'oauth2': {\n const firstFlow = getVisibleOrderedFlowKeys(scheme.flows)[0]\n const currentFlow = selectedFlow.value || firstFlow\n if (!currentFlow) {\n return capitalizedName\n }\n return `${capitalizedName}: ${currentFlow}`\n }\n\n case 'http':\n return `${capitalizedName}: ${scheme.scheme}`\n\n default:\n return capitalizedName\n }\n}\n\n/**\n * Whether an API key scheme exposes an editable parameter name.\n *\n * OpenAPI `apiKey` and AsyncAPI `httpApiKey` (normalized to `apiKey`) name a query/header/cookie\n * parameter, so the Name input is shown. AsyncAPI `apiKey` places the key in the broker `user` or\n * `password` slot and has no parameter name, so the Name input is hidden and only the value is asked for.\n */\nconst apiKeyHasName = (scheme: { in?: string }): boolean =>\n scheme.in !== 'user' && scheme.in !== 'password'\n\n/**\n * The scheme's type when it is one we do not render inputs for (a type outside both the OpenAPI\n * and AsyncAPI security scheme unions). Read through a helper so the fallback template branch,\n * where the scheme type is narrowed to `never` after the supported cases, can still surface the type.\n */\nconst getUnsupportedSchemeType = (\n scheme: SecurityItem['scheme'],\n): string | undefined => scheme?.type\n\n/**\n * Determines if an OAuth2 flow tab should be active.\n * The first flow is active by default if no flow is explicitly selected.\n */\nconst isFlowActive = (flowKey: string, index: number): boolean =>\n selectedFlow.value === flowKey || (index === 0 && !selectedFlow.value)\n\n/** Computes the container class for static display mode. */\nconst getStaticBorderClass = (): string | false => isStatic && 'border-t'\n\nconst handleHttpSecretsUpdate = (\n payload: Omit<Partial<SecretsHttp>, 'type'>,\n name: string,\n): void =>\n eventBus.emit('auth:update:security-scheme-secrets', {\n payload: { type: 'http', ...payload },\n name,\n })\n\nconst handleApiKeySecretsUpdate = (\n payload: Omit<Partial<SecretsApiKey>, 'type'>,\n name: string,\n): void =>\n eventBus.emit('auth:update:security-scheme-secrets', {\n payload: { type: 'apiKey', ...payload },\n name,\n })\n\nconst handleApiKeySecuritySchemeUpdate = (\n payload: Omit<Partial<ApiKeyObject>, 'type'>,\n name: string,\n): void =>\n eventBus.emit('auth:update:security-scheme', {\n payload: { type: 'apiKey', ...payload },\n name,\n })\n\n/** Handles scope selection updates for OAuth2 */\nconst handleScopesUpdate = (\n name: string,\n event: { scopes?: string[]; scope?: string; selected?: boolean },\n): void => {\n emits('update:selectedScopes', {\n id: Object.keys(selectedSecuritySchemas),\n name,\n ...event,\n })\n}\n\n/** Handles scope-definition upserts (add / rename / description change) */\nconst handleScopeUpsert = (\n name: string,\n event: Omit<ApiReferenceEvents['auth:upsert:scopes'], 'name'>,\n): void => {\n emits('upsert:scope', { ...event, name })\n}\n\n/** Handles scope-definition deletes */\nconst handleScopeDelete = (\n name: string,\n event: Omit<ApiReferenceEvents['auth:delete:scopes'], 'name'>,\n): void => {\n emits('delete:scope', { ...event, name })\n}\n\n/**\n * Computes dynamic classes for OAuth2 flow tabs based on active state.\n */\nconst getFlowTabClasses = (flowKey: string, index: number): string => {\n const baseClasses =\n 'floating-bg text-c-3 relative cursor-pointer border-b border-transparent py-1 text-base font-medium'\n const activeClasses = '!text-c-1 !rounded-none border-b !border-current'\n\n return isFlowActive(flowKey, index)\n ? `${baseClasses} ${activeClasses} ${isStatic ? 'opacity-100' : ''}`\n : baseClasses\n}\n\n/**\n * OAuth2 token-acquisition target (an oauth2 scheme with an interactive grant) sourced from\n * the merged schemes. When the active scheme is HTTP bearer, this powers the inline\n * \"Authorize via OAuth2\" shortcut: the flow's bearer token is written onto the bearer scheme,\n * so the panel never switches to oauth2.\n *\n * The shortcut is purely a convenience, so it is offered for any interactive oauth2 scheme —\n * including one that is also independently selectable in the dropdown (e.g. Scalar Galaxy's\n * `oAuth2`). Whether that oauth2 scheme is *hidden* from the dropdown is a separate decision made\n * in the selector; here we only surface the shortcut.\n */\nconst oauth2Target = computed(() => getOauth2AcquisitionTarget(securitySchemes))\n\n/** Resolved oauth2 scheme object, for embedding its config form behind the gear. */\nconst oauth2Scheme = computed(() =>\n oauth2Target.value\n ? getResolvedRef(securitySchemes[oauth2Target.value.name])\n : undefined,\n)\n\nconst acquisitionLoader = useLoadingState()\nconst { toast } = useToasts()\nconst configModal = useModal()\n/** Bearer scheme that opened the config modal, so its Authorize callback targets it. */\nconst configBearerName = ref<string | undefined>()\n\n/** Runs the OAuth2 flow and writes the resulting bearer token onto the bearer scheme. */\nconst handleAcquisitionAuthorize = async (\n bearerName: string,\n): Promise<void> => {\n const target = oauth2Target.value\n if (!target || acquisitionLoader.isLoading) {\n return\n }\n acquisitionLoader.start()\n const [error] = await runOAuth2Authorize({\n eventBus,\n bearerSchemeName: bearerName,\n oauth2Name: target.name,\n flows: target.flows,\n flowType: target.flowType,\n scopes: target.scopes,\n server,\n proxyUrl,\n environment,\n options,\n })\n await acquisitionLoader.clear()\n if (error) {\n toast(error?.message ?? 'Failed to authorize', 'error')\n }\n}\n\n/** Refreshes the OAuth2 token and rewrites it onto the bearer scheme. */\nconst handleAcquisitionRefresh = async (bearerName: string): Promise<void> => {\n const target = oauth2Target.value\n // Only the authorization-code flow carries a refresh token; implicit can't be refreshed.\n if (\n !target ||\n target.flowType !== 'authorizationCode' ||\n acquisitionLoader.isLoading\n ) {\n return\n }\n acquisitionLoader.start()\n const [error, tokens] = await refreshOauth2Token(\n target.flows,\n target.flowType,\n proxyUrl,\n server,\n getEnvironmentVariables(environment),\n options?.customFetch,\n )\n await acquisitionLoader.clear()\n if (tokens?.accessToken) {\n storeOAuth2Tokens(eventBus, {\n bearerSchemeName: bearerName,\n oauth2Name: target.name,\n flowType: target.flowType,\n tokens,\n })\n } else if (error) {\n toast(error?.message ?? 'Failed to refresh', 'error')\n }\n}\n\nconst openAcquisitionConfig = (bearerName: string): void => {\n configBearerName.value = bearerName\n configModal.show()\n}\n\n/** Closes the config modal and runs Authorize against the bearer scheme that opened it. */\nconst handleConfigAuthorize = (): void => {\n const bearerName = configBearerName.value\n configModal.hide()\n if (bearerName) {\n void handleAcquisitionAuthorize(bearerName)\n }\n}\n</script>\n<template>\n <template\n v-for=\"{ scheme, name, scopes, visibleFlowKeys } in security\"\n :key=\"name\">\n <!--\n Header row for AND'ed schemes: label (bold) and description (rich text) are\n combined.\n -->\n <DataTableRow v-if=\"hasMultipleSchemes && scheme\">\n <DataTableCell\n :aria-label=\"generateLabel(name, scheme)\"\n class=\"max-h-[auto]\">\n <div class=\"bg-b-1 min-w-0 flex-1 px-3 py-1.25\">\n <p class=\"text-c-1 leading-5.5 font-medium\">\n {{ generateLabel(name, scheme) }}\n </p>\n <ScalarMarkdownSummary\n v-if=\"scheme.description\"\n class=\"auth-description text-c-2 w-full\"\n :value=\"scheme.description\" />\n </div>\n </DataTableCell>\n </DataTableRow>\n\n <!-- Description: shown for single auth schemes with descriptions -->\n <DataTableRow v-if=\"scheme?.description && !hasMultipleSchemes\">\n <DataTableCell\n :aria-label=\"scheme.description\"\n class=\"max-h-[auto]\">\n <ScalarMarkdownSummary\n class=\"auth-description bg-b-1 text-c-2 min-w-0 flex-1 px-3 py-1.25\"\n :value=\"scheme.description\" />\n </DataTableCell>\n </DataTableRow>\n\n <!-- HTTP Authentication -->\n <template v-if=\"scheme?.type === 'http'\">\n <!-- Bearer Token -->\n <DataTableRow v-if=\"scheme.scheme === 'bearer'\">\n <RequestAuthDataTableInput\n :containerClass=\"getStaticBorderClass()\"\n :environment\n :modelValue=\"scheme['x-scalar-secret-token']\"\n placeholder=\"Token\"\n type=\"password\"\n @update:modelValue=\"\n (v) => handleHttpSecretsUpdate({ 'x-scalar-secret-token': v }, name)\n \">\n Bearer Token\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <!-- OAuth2 token-acquisition shortcut (shown when an interactive oauth2 flow exists) -->\n <DataTableRow v-if=\"scheme.scheme === 'bearer' && oauth2Target\">\n <div class=\"flex h-8 items-center gap-2 border-t px-3\">\n <span class=\"text-c-3 mr-auto text-xs\">Get a token</span>\n <ScalarButton\n class=\"p-0 px-2 py-0.5\"\n :loader=\"acquisitionLoader\"\n size=\"sm\"\n type=\"button\"\n variant=\"outlined\"\n @click=\"handleAcquisitionAuthorize(name)\">\n Authorize via {{ oauth2Target.name }}\n </ScalarButton>\n <ScalarButton\n v-if=\"\n scheme['x-scalar-secret-token'] &&\n oauth2Target.flowType === 'authorizationCode'\n \"\n class=\"p-0 px-2 py-0.5\"\n :disabled=\"acquisitionLoader.isLoading\"\n size=\"sm\"\n type=\"button\"\n variant=\"outlined\"\n @click=\"handleAcquisitionRefresh(name)\">\n Refresh\n </ScalarButton>\n <ScalarIconButton\n :icon=\"ScalarIconGear\"\n :label=\"`Configure ${oauth2Target.name}`\"\n size=\"xs\"\n @click=\"openAcquisitionConfig(name)\" />\n </div>\n </DataTableRow>\n\n <!-- HTTP Basic Authentication -->\n <template v-else-if=\"scheme?.scheme === 'basic'\">\n <DataTableRow>\n <RequestAuthDataTableInput\n class=\"text-c-2\"\n :environment\n :modelValue=\"scheme['x-scalar-secret-username']\"\n placeholder=\"janedoe\"\n required\n @update:modelValue=\"\n (v) =>\n handleHttpSecretsUpdate({ 'x-scalar-secret-username': v }, name)\n \">\n Username\n </RequestAuthDataTableInput>\n </DataTableRow>\n <DataTableRow>\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"scheme['x-scalar-secret-password']\"\n placeholder=\"********\"\n type=\"password\"\n @update:modelValue=\"\n (v) =>\n handleHttpSecretsUpdate({ 'x-scalar-secret-password': v }, name)\n \">\n Password\n </RequestAuthDataTableInput>\n </DataTableRow>\n </template>\n </template>\n\n <!-- API Key Authentication -->\n <template v-else-if=\"scheme?.type === 'apiKey'\">\n <DataTableRow v-if=\"apiKeyHasName(scheme)\">\n <RequestAuthDataTableInput\n :containerClass=\"getStaticBorderClass()\"\n :environment\n :modelValue=\"scheme.name ?? ''\"\n placeholder=\"api-key\"\n @update:modelValue=\"\n (v) => handleApiKeySecuritySchemeUpdate({ name: v }, name)\n \">\n Name\n </RequestAuthDataTableInput>\n </DataTableRow>\n <DataTableRow>\n <RequestAuthDataTableInput\n :containerClass=\"\n apiKeyHasName(scheme) ? undefined : getStaticBorderClass()\n \"\n :environment\n :modelValue=\"scheme['x-scalar-secret-token']\"\n placeholder=\"QUxMIFlPVVIgQkFTRSBBUkUgQkVMT05HIFRPIFVT\"\n type=\"password\"\n @update:modelValue=\"\n (v) =>\n handleApiKeySecretsUpdate({ 'x-scalar-secret-token': v }, name)\n \">\n Value\n </RequestAuthDataTableInput>\n </DataTableRow>\n </template>\n\n <!-- OAuth 2.0 / OpenID Connect Authentication -->\n <template\n v-else-if=\"scheme?.type === 'oauth2' || scheme?.type === 'openIdConnect'\">\n <OAuth2Metadata\n v-if=\"\n scheme.type === 'oauth2' && (!isStatic || scheme.oauth2MetadataUrl)\n \"\n :customFetch=\"options?.customFetch\"\n :environment\n :eventBus\n :name\n :proxyUrl\n :scheme />\n\n <!-- OpenID Connect -->\n <OpenIDConnect\n v-if=\"scheme?.type === 'openIdConnect' && !visibleFlowKeys.length\"\n :customFetch=\"options?.customFetch\"\n :environment\n :eventBus\n :getStaticBorderClass\n :name\n :proxyUrl\n :scheme />\n\n <!-- Flow selector tabs: shown when multiple visible flows are available -->\n <DataTableRow v-if=\"visibleFlowKeys.length > 1\">\n <div class=\"flex min-h-8 border-t text-base\">\n <div class=\"flex h-8 max-w-full gap-2.5 overflow-x-auto px-3\">\n <button\n v-for=\"(key, ind) in visibleFlowKeys\"\n :key=\"key\"\n :class=\"getFlowTabClasses(key, ind)\"\n type=\"button\"\n @click=\"setActiveFlow(key)\">\n <span class=\"relative z-10\">{{ key }}</span>\n </button>\n </div>\n </div>\n </DataTableRow>\n\n <!-- OAuth2 flow configuration -->\n <template\n v-for=\"(key, ind) in visibleFlowKeys\"\n :key=\"key\">\n <OAuth2\n v-if=\"scheme.flows && isFlowActive(key, ind)\"\n :environment\n :eventBus\n :flows=\"scheme.flows\"\n :name\n :options\n :proxyUrl\n :scheme\n :selectedScopes=\"scopes\"\n :server\n :type=\"key\"\n @delete:scope=\"(event) => handleScopeDelete(name, event)\"\n @update:selectedScopes=\"(event) => handleScopesUpdate(name, event)\"\n @upsert:scope=\"(event) => handleScopeUpsert(name, event)\" />\n </template>\n </template>\n\n <!-- Browser WebSocket connections cannot apply these broker credentials. -->\n <div\n v-else-if=\"\n scheme?.type === 'userPassword' ||\n scheme?.type === 'plain' ||\n scheme?.type === 'scramSha256' ||\n scheme?.type === 'scramSha512' ||\n scheme?.type === 'X509' ||\n scheme?.type === 'symmetricEncryption' ||\n scheme?.type === 'asymmetricEncryption' ||\n scheme?.type === 'gssapi'\n \"\n class=\"text-c-3 flex items-center justify-center border-t p-4 px-4 text-center text-xs text-balance\">\n Credentials for this AsyncAPI security scheme are not sent by the browser\n client.\n </div>\n\n <!-- Mutual TLS credentials are chosen during the browser-managed TLS handshake. -->\n <div\n v-else-if=\"scheme?.type === 'mutualTLS'\"\n class=\"text-c-3 flex items-center justify-center border-t p-4 px-4 text-center text-xs text-balance\">\n Mutual TLS authenticates with a client certificate presented during the\n TLS handshake, so there is nothing to enter here.\n </div>\n\n <!-- Scheme has a type we do not render inputs for -->\n <div\n v-else-if=\"getUnsupportedSchemeType(scheme)\"\n class=\"text-c-3 flex items-center justify-center border-t p-4 px-4 text-center text-xs text-balance\">\n The <code>{{ getUnsupportedSchemeType(scheme) }}</code> security scheme\n type is not supported yet.\n </div>\n\n <!-- Scheme is missing type -->\n <div\n v-else\n class=\"text-c-3 flex items-center justify-center border-t p-4 px-4 text-center text-xs text-balance\">\n The security scheme is missing a type, please double check your\n {{ documentTypeLabel }} document or Authentication Configuration\n </div>\n </template>\n\n <!-- OAuth2 configuration modal (opened from the bearer scheme's gear) -->\n <ScalarModal\n v-if=\"oauth2Target && oauth2Scheme\"\n :state=\"configModal\"\n size=\"sm\"\n :title=\"`Configure ${oauth2Target.name}`\">\n <DataTable\n :columns=\"['']\"\n presentational>\n <OAuth2\n hideActions\n :environment\n :eventBus\n :flows=\"oauth2Target.flows\"\n :name=\"oauth2Target.name\"\n :options\n :proxyUrl\n :scheme=\"oauth2Scheme\"\n :selectedScopes=\"oauth2Target.scopes\"\n :server\n :type=\"oauth2Target.flowType\"\n @delete:scope=\"(event) => handleScopeDelete(oauth2Target!.name, event)\"\n @update:selectedScopes=\"\n (event) => handleScopesUpdate(oauth2Target!.name, event)\n \"\n @upsert:scope=\"\n (event) => handleScopeUpsert(oauth2Target!.name, event)\n \" />\n </DataTable>\n <div class=\"flex h-8 items-center justify-end gap-2 border-t\">\n <ScalarButton\n class=\"p-0 px-2 py-0.5\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"configModal.hide()\">\n Cancel\n </ScalarButton>\n <ScalarButton\n class=\"p-0 px-2 py-0.5\"\n :loader=\"acquisitionLoader\"\n size=\"sm\"\n @click=\"handleConfigAuthorize\">\n Authorize\n </ScalarButton>\n </div>\n </ScalarModal>\n</template>\n"],"mappings":""}
|
|
@@ -7,6 +7,7 @@ import { getVisibleOrderedFlowKeys } from "../helpers/oauth-flows.js";
|
|
|
7
7
|
import { runOAuth2Authorize, storeOAuth2Tokens } from "../helpers/run-oauth2-authorize.js";
|
|
8
8
|
import RequestAuthDataTableInput_default from "./RequestAuthDataTableInput.vue.js";
|
|
9
9
|
import OAuth2_default from "./OAuth2.vue.js";
|
|
10
|
+
import OAuth2Metadata_default from "./OAuth2Metadata.vue.js";
|
|
10
11
|
import OpenIDConnect_default from "./OpenIDConnect.vue.js";
|
|
11
12
|
import { Fragment, capitalize, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, openBlock, ref, renderList, toDisplayString, unref, withCtx } from "vue";
|
|
12
13
|
import { ScalarButton } from "@scalar/components/button";
|
|
@@ -409,11 +410,27 @@ var RequestAuthTab_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
|
|
|
409
410
|
])]),
|
|
410
411
|
_: 2
|
|
411
412
|
}, 1024)], 64)) : scheme?.type === "oauth2" || scheme?.type === "openIdConnect" ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
|
|
412
|
-
scheme
|
|
413
|
+
scheme.type === "oauth2" && (!__props.isStatic || scheme.oauth2MetadataUrl) ? (openBlock(), createBlock(OAuth2Metadata_default, {
|
|
413
414
|
key: 0,
|
|
414
415
|
customFetch: __props.options?.customFetch,
|
|
415
416
|
environment: __props.environment,
|
|
416
417
|
eventBus: __props.eventBus,
|
|
418
|
+
name,
|
|
419
|
+
proxyUrl: __props.proxyUrl,
|
|
420
|
+
scheme
|
|
421
|
+
}, null, 8, [
|
|
422
|
+
"customFetch",
|
|
423
|
+
"environment",
|
|
424
|
+
"eventBus",
|
|
425
|
+
"name",
|
|
426
|
+
"proxyUrl",
|
|
427
|
+
"scheme"
|
|
428
|
+
])) : createCommentVNode("", true),
|
|
429
|
+
scheme?.type === "openIdConnect" && !visibleFlowKeys.length ? (openBlock(), createBlock(OpenIDConnect_default, {
|
|
430
|
+
key: 1,
|
|
431
|
+
customFetch: __props.options?.customFetch,
|
|
432
|
+
environment: __props.environment,
|
|
433
|
+
eventBus: __props.eventBus,
|
|
417
434
|
getStaticBorderClass,
|
|
418
435
|
name,
|
|
419
436
|
proxyUrl: __props.proxyUrl,
|
|
@@ -426,7 +443,7 @@ var RequestAuthTab_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
|
|
|
426
443
|
"proxyUrl",
|
|
427
444
|
"scheme"
|
|
428
445
|
])) : createCommentVNode("", true),
|
|
429
|
-
visibleFlowKeys.length > 1 ? (openBlock(), createBlock(unref(DataTableRow_default), { key:
|
|
446
|
+
visibleFlowKeys.length > 1 ? (openBlock(), createBlock(unref(DataTableRow_default), { key: 2 }, {
|
|
430
447
|
default: withCtx(() => [createElementVNode("div", _hoisted_4, [createElementVNode("div", _hoisted_5, [(openBlock(true), createElementBlock(Fragment, null, renderList(visibleFlowKeys, (key, ind) => {
|
|
431
448
|
return openBlock(), createElementBlock("button", {
|
|
432
449
|
key,
|