@scalar/api-client 3.18.0 → 3.19.1
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 +51 -0
- package/dist/components/HttpMethod/HttpMethod.vue.d.ts +2 -2
- package/dist/components/SectionFilter.vue.d.ts +2 -1
- package/dist/components/SectionFilter.vue.d.ts.map +1 -1
- package/dist/components/SectionFilter.vue.js +1 -1
- package/dist/components/SectionFilter.vue.js.map +1 -1
- package/dist/components/SectionFilter.vue.script.js.map +1 -1
- package/dist/hooks/use-file-dialog.d.ts.map +1 -1
- package/dist/hooks/use-file-dialog.js +1 -0
- package/dist/hooks/use-file-dialog.js.map +1 -1
- package/dist/style.css +136 -90
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts +2 -2
- package/dist/v2/blocks/operation-block/OperationBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.js.map +1 -1
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js +15 -10
- package/dist/v2/blocks/operation-block/OperationBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-block/components/Header.vue.d.ts +1 -1
- package/dist/v2/blocks/operation-block/components/Header.vue.js +1 -1
- package/dist/v2/blocks/operation-block/components/Header.vue.js.map +1 -1
- package/dist/v2/blocks/operation-block/components/Header.vue.script.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts +3 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.d.ts.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/send-request.js +9 -5
- package/dist/v2/blocks/operation-block/helpers/send-request.js.map +1 -1
- package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.d.ts +1 -1
- package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js +1 -1
- package/dist/v2/blocks/operation-block/helpers/validate-path-parameters.js.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts +3 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js +58 -3
- package/dist/v2/blocks/request-block/RequestBlock.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBody.vue.d.ts +11 -3
- 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 +59 -23
- package/dist/v2/blocks/request-block/components/RequestBody.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.d.ts +5 -3
- package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.script.js +6 -3
- package/dist/v2/blocks/request-block/components/RequestBodyForm.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBodyStructured.vue.d.ts +1 -1
- package/dist/v2/blocks/request-block/components/RequestBodyStructured.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBodyStructured.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestBodyStructured.vue.script.js +1 -0
- package/dist/v2/blocks/request-block/components/RequestBodyStructured.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js +4 -3
- package/dist/v2/blocks/request-block/components/RequestCodeSnippet.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts +2 -0
- package/dist/v2/blocks/request-block/components/RequestTable.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.js +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTable.vue.script.js +7 -3
- package/dist/v2/blocks/request-block/components/RequestTable.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts +7 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js +17 -5
- package/dist/v2/blocks/request-block/components/RequestTableRow.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.d.ts +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.js.map +1 -1
- package/dist/v2/blocks/request-block/components/RequestTableTooltip.vue.script.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/create-parameter-rows.d.ts +1 -1
- package/dist/v2/blocks/request-block/helpers/create-parameter-rows.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/create-parameter-rows.js +17 -8
- package/dist/v2/blocks/request-block/helpers/create-parameter-rows.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/fold-structured-body-rows.d.ts +1 -1
- package/dist/v2/blocks/request-block/helpers/fold-structured-body-rows.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.d.ts +3 -1
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js +34 -17
- package/dist/v2/blocks/request-block/helpers/get-form-body-rows.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-parameter-content.d.ts +1 -1
- package/dist/v2/blocks/request-block/helpers/get-parameter-content.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-parameter-schema.d.ts +1 -1
- package/dist/v2/blocks/request-block/helpers/get-parameter-schema.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/get-structured-body-rows.d.ts +1 -1
- package/dist/v2/blocks/request-block/helpers/get-structured-body-rows.js +1 -1
- package/dist/v2/blocks/request-block/helpers/get-structured-body-rows.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/group-by.d.ts +3 -4
- package/dist/v2/blocks/request-block/helpers/group-by.d.ts.map +1 -1
- package/dist/v2/blocks/request-block/helpers/group-by.js +12 -10
- package/dist/v2/blocks/request-block/helpers/group-by.js.map +1 -1
- package/dist/v2/blocks/request-block/helpers/validate-parameter.d.ts +1 -1
- package/dist/v2/blocks/request-block/helpers/validate-parameter.js.map +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.js +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.js.map +1 -1
- package/dist/v2/blocks/response-block/ResponseBlock.vue.script.js +6 -1
- package/dist/v2/blocks/response-block/ResponseBlock.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-address-bar-block/components/AddressBar.vue.d.ts +2 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.script.js +2 -2
- package/dist/v2/blocks/scalar-address-bar-block/components/AddressBar.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-address-bar-block/helpers/refocus-blur-target.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/AuthSelector.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts +5 -5
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.js +10 -7
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue.script.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/OAuthScopesInput.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OpenIDConnect.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OpenIDConnect.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/OpenIDConnect.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthDataTable.vue.script.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/components/RequestAuthTab.vue.d.ts +5 -5
- 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 +39 -156
- 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/auth-options.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/auth-options.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/extract-security-scheme-secrets.d.ts.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 +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/blocks/scalar-auth-selector-block/helpers/openid-discovery-to-flows.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/run-oauth2-authorize.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/run-oauth2-authorize.js.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/security-scheme.d.ts +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/security-scheme.d.ts.map +1 -1
- package/dist/v2/blocks/scalar-auth-selector-block/helpers/security-scheme.js.map +1 -1
- 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 +41 -10
- package/dist/v2/components/code-input/CodeInput.vue.script.js.map +1 -1
- package/dist/v2/components/code-input/CodeInputLite.vue.d.ts.map +1 -1
- package/dist/v2/components/code-input/CodeInputLite.vue.js +1 -1
- package/dist/v2/components/code-input/CodeInputLite.vue.js.map +1 -1
- package/dist/v2/components/code-input/CodeInputLite.vue.script.js +7 -6
- package/dist/v2/components/code-input/CodeInputLite.vue.script.js.map +1 -1
- package/dist/v2/components/code-input/helpers/build-pill-context.d.ts.map +1 -1
- package/dist/v2/components/code-input/helpers/build-pill-context.js.map +1 -1
- package/dist/v2/components/data-table/DataTableCheckbox.vue.d.ts +1 -1
- package/dist/v2/components/data-table/DataTableCheckbox.vue.d.ts.map +1 -1
- package/dist/v2/components/layout/CollapsibleSection.vue.js.map +1 -1
- package/dist/v2/components/layout/CollapsibleSection.vue.script.js.map +1 -1
- package/dist/v2/components/server/ServerDropdown.vue.d.ts +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/components/server/ServerDropdownItem.vue.d.ts +1 -1
- package/dist/v2/components/server/ServerDropdownItem.vue.js +1 -1
- package/dist/v2/components/server/ServerDropdownItem.vue.js.map +1 -1
- package/dist/v2/components/server/ServerDropdownItem.vue.script.js.map +1 -1
- package/dist/v2/constants.js +1 -1
- package/dist/v2/features/command-palette/components/CommandActionInput.vue.js.map +1 -1
- package/dist/v2/features/command-palette/components/CommandActionInput.vue.script.js +1 -1
- package/dist/v2/features/command-palette/components/CommandActionInput.vue.script.js.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentColors.vue.js.map +1 -1
- package/dist/v2/features/environments/components/EnvironmentColors.vue.script.js +1 -1
- package/dist/v2/features/environments/components/EnvironmentColors.vue.script.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.d.ts +1 -1
- package/dist/v2/features/modal/Modal.vue.js.map +1 -1
- package/dist/v2/features/modal/Modal.vue.script.js.map +1 -1
- package/dist/v2/features/modal/helpers/create-api-client-modal.js.map +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 +1 -1
- package/dist/v2/features/modal/helpers/resolve-route-parameters.js.map +1 -1
- package/dist/v2/features/modal/hooks/use-modal-sidebar.js +1 -1
- package/dist/v2/features/modal/modal-events.d.ts.map +1 -1
- package/dist/v2/features/modal/modal-events.js +10 -1
- package/dist/v2/features/modal/modal-events.js.map +1 -1
- package/dist/v2/features/operation/Operation.vue.d.ts +1 -1
- package/dist/v2/features/operation/Operation.vue.js.map +1 -1
- package/dist/v2/features/operation/Operation.vue.script.js.map +1 -1
- package/dist/v2/features/search/components/DocumentSearchModal.vue.d.ts +1 -1
- package/dist/v2/features/search/components/DocumentSearchModal.vue.js +1 -1
- package/dist/v2/features/search/components/DocumentSearchModal.vue.js.map +1 -1
- package/dist/v2/features/search/components/DocumentSearchModal.vue.script.js.map +1 -1
- package/dist/v2/features/search/helpers/create-search-index.d.ts +1 -1
- package/dist/v2/features/search/helpers/create-search-index.js.map +1 -1
- package/dist/v2/features/search/hooks/use-document-search.d.ts +1 -1
- package/dist/v2/features/search/hooks/use-document-search.js.map +1 -1
- package/dist/v2/features/search/hooks/use-search-index.d.ts +1 -1
- package/dist/v2/features/search/hooks/use-search-index.js.map +1 -1
- package/dist/vue-styles.css +97 -87
- package/package.json +16 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuth2.vue.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue"],"sourcesContent":["<script lang=\"ts\">\n/** Any config options required for the OAuth2 flow */\nexport type OAuth2Options = Pick<\n ApiClientConfiguration,\n 'oauth2RedirectUri'\n> & {\n /** Optional fetch override (IPC-backed on desktop) used for token exchange, refresh, and OIDC discovery */\n customFetch?: typeof fetch\n /** Optional redirect capture (loopback-backed on desktop) for interactive OAuth2 flows */\n captureOAuth2Callback?: CaptureOAuth2Callback\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { useLoadingState } from '@scalar/components/loading'\nimport type { ApiClientConfiguration } from '@scalar/types/api-reference'\nimport { pkceOptions } from '@scalar/types/entities'\nimport { useToasts } from '@scalar/use-toasts'\nimport type { SecretsOAuthFlows } from '@scalar/workspace-store/entities/auth'\nimport type {\n ApiReferenceEvents,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport {\n getEnvironmentVariables,\n type OAuthFlowAuthorizationCodeSecret,\n type OAuthFlowClientCredentialsSecret,\n type OAuthFlowPasswordSecret,\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 type { XScalarCredentialsLocation } from '@scalar/workspace-store/schemas/extensions/security/x-scalar-credentials-location'\nimport { type XusePkce } from '@scalar/workspace-store/schemas/extensions/security/x-use-pkce'\nimport type {\n OAuthFlow,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed, ref, watch } from 'vue'\n\nimport OAuthScopesInput from '@/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue'\nimport {\n authorizeOauth2,\n refreshOauth2Token,\n type CaptureOAuth2Callback,\n} from '@/v2/blocks/scalar-auth-selector-block/helpers/oauth'\nimport { resolveDefaultOAuth2RedirectUri } from '@/v2/blocks/scalar-auth-selector-block/helpers/resolve-default-oauth2-redirect-url'\nimport { DataTableRow } from '@/v2/components/data-table'\n\nimport RequestAuthDataTableInput from './RequestAuthDataTableInput.vue'\n\nconst {\n environment,\n flows,\n type,\n scheme,\n selectedScopes: selectedScopesProp,\n server,\n proxyUrl,\n eventBus,\n name,\n options = {},\n} = defineProps<{\n /** Current environment configuration */\n environment: XScalarEnvironment\n /** OAuth flows */\n flows: OAuthFlowsObjectSecret\n /** Type of the OAuth flow */\n type: keyof OAuthFlowsObjectSecret\n /** Selected scopes */\n selectedScopes: string[]\n /** Security scheme */\n scheme: SecuritySchemeObjectSecret\n /** Current server configuration */\n server: ServerObject | null\n /** Proxy URL */\n proxyUrl: string\n /** Name of the security scheme */\n name: string\n /** Event bus for authentication updates */\n eventBus: WorkspaceEventBus\n /** Any config options required for the OAuth2 flow */\n options?: OAuth2Options\n /**\n * Hides the Authorize / Refresh / Clear actions. Used when the form is embedded as a\n * configuration-only view (e.g. behind a gear icon), so the host component owns the\n * authorize action and the tokens are routed to the scheme it chooses.\n */\n hideActions?: boolean\n}>()\n\nconst emits = defineEmits<{\n (\n e: 'update:selectedScopes',\n payload: { scopes?: string[]; scope?: string; selected?: boolean },\n ): void\n (\n e: 'upsert:scope',\n payload: Omit<ApiReferenceEvents['auth:upsert:scopes'], 'name'>,\n ): void\n (\n e: 'delete:scope',\n payload: Omit<ApiReferenceEvents['auth:delete:scopes'], 'name'>,\n ): void\n}>()\n\nconst loader = useLoadingState()\nconst { toast } = useToasts()\n\n/** The current OAuth flow based on the selected type */\nconst flow = computed(() => flows[type]!)\ntype NonImplicitFlow =\n | OAuthFlowPasswordSecret\n | OAuthFlowClientCredentialsSecret\n | OAuthFlowAuthorizationCodeSecret\n\n/** We filter selected scopes to only include scopes that are defined on this flow (own keys only). */\nconst selectedScopes = computed(() => {\n const definedScopes = flow.value.scopes\n if (!definedScopes) {\n return []\n }\n return selectedScopesProp.filter((scope) =>\n Object.hasOwn(definedScopes, scope),\n )\n})\n\n/**\n * Show the client secret whenever the flow supports one. PKCE and a client\n * secret are independent, so confidential clients can use both together\n * (see RFC 9700 Section 2.1.1).\n */\nconst showClientSecret = computed(\n () => 'x-scalar-secret-client-secret' in flow.value,\n)\n\nconst clientSecretValue = computed((): string => {\n const f = flow.value as { 'x-scalar-secret-client-secret'?: string }\n return f['x-scalar-secret-client-secret'] ?? ''\n})\n\n/** Updates the security scheme base */\nconst handleOauth2Update = (\n payload: Partial<OAuthFlow & XScalarCredentialsLocation>,\n): void => {\n // OpenIdConnect uses the secrets update for all\n if (scheme.type === 'openIdConnect') {\n return handleOauth2SecretsUpdate(payload)\n }\n\n // Only OAuth2 schemes carry flows on the document; this component is never\n // rendered for the other scheme types.\n if (scheme.type !== 'oauth2') {\n return\n }\n\n eventBus.emit('auth:update:security-scheme', {\n payload: {\n type: scheme.type,\n flows: {\n [type]: payload,\n },\n },\n name,\n })\n}\n\n/** Updates the flow secrets */\nconst handleOauth2SecretsUpdate = (\n payload: Omit<Partial<SecretsOAuthFlows[keyof SecretsOAuthFlows]>, 'type'>,\n): void =>\n eventBus.emit('auth:update:security-scheme-secrets', {\n payload: {\n type: scheme.type,\n [type]: payload,\n },\n name,\n })\n\n/** Clears the flow secrets */\nconst clearOauth2Secrets = (): void => {\n if (loader.isLoading) {\n return\n }\n eventBus.emit('auth:clear:security-scheme-secrets', {\n name,\n })\n}\n\n/** Clears stored access and refresh tokens (authorized state) */\nconst handleClearAccessTokens = (): void => {\n if (loader.isLoading) {\n return\n }\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-token': '',\n 'x-scalar-secret-refresh-token': '',\n })\n}\n\n/** Track redirect URI prefill per flow instance to support document switching */\nconst prefilledFlowIdentity = ref<string | null>(null)\nconst hasHandledRedirectPrefill = ref(false)\n\nconst resolveFlowIdentity = (\n currentFlow: OAuthFlowsObjectSecret[keyof OAuthFlowsObjectSecret] | undefined,\n): string =>\n JSON.stringify({\n type,\n authorizationUrl:\n currentFlow && 'authorizationUrl' in currentFlow\n ? currentFlow.authorizationUrl\n : '',\n tokenUrl:\n currentFlow && 'tokenUrl' in currentFlow ? currentFlow.tokenUrl : '',\n refreshUrl: currentFlow?.refreshUrl ?? '',\n scopes: Object.keys(currentFlow?.scopes ?? {}),\n })\n\n/** Default the redirect-uri to the current origin if we have access to window */\nwatch(\n () => flow.value,\n (currentFlow) => {\n if (!currentFlow || !('x-scalar-secret-redirect-uri' in currentFlow)) {\n return\n }\n\n const flowIdentity = resolveFlowIdentity(currentFlow)\n if (prefilledFlowIdentity.value !== flowIdentity) {\n prefilledFlowIdentity.value = flowIdentity\n hasHandledRedirectPrefill.value = false\n }\n\n if (hasHandledRedirectPrefill.value) {\n return\n }\n\n const newRedirectUri = (currentFlow as OAuthFlowAuthorizationCodeSecret)[\n 'x-scalar-secret-redirect-uri'\n ]\n const defaultRedirectUri = resolveDefaultOAuth2RedirectUri(options)\n\n hasHandledRedirectPrefill.value = true\n\n // The desktop loopback path computes the redirect URI at authorize time (an\n // ephemeral 127.0.0.1 port), so persisting a default into the document would\n // only bake in a stale, unused value. Leave it empty and show a hint instead.\n if (\n newRedirectUri ||\n !defaultRedirectUri ||\n options.captureOAuth2Callback\n ) {\n return\n }\n\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-redirect-uri': defaultRedirectUri,\n })\n },\n { immediate: true },\n)\n\n/**\n * Authorizes the user using the specified OAuth flow.\n * Opens the appropriate OAuth dialog and/or performs the token exchange.\n */\nconst handleAuthorize = async (): Promise<void> => {\n if (loader.isLoading) {\n return\n }\n\n loader.start()\n\n const [error, tokens] = await authorizeOauth2(\n flows,\n type,\n selectedScopes.value,\n server,\n proxyUrl,\n getEnvironmentVariables(environment),\n options.customFetch,\n options.captureOAuth2Callback,\n )\n\n await loader.clear()\n\n if (tokens?.accessToken) {\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-token': tokens.accessToken,\n ...(tokens.refreshToken\n ? { 'x-scalar-secret-refresh-token': tokens.refreshToken }\n : {}),\n })\n } else {\n console.error(error)\n toast(error?.message ?? 'Failed to authorize', 'error')\n }\n}\n\n/** Whether the current flow supports refreshing the access token */\nconst supportsRefreshToken = computed(() => type !== 'implicit')\n\n/**\n * Refresh URL placeholder, shows tokenUrl as hint if refreshUrl is not specified.\n * This helps users understand that tokenUrl will be used as fallback.\n */\nconst refreshUrlPlaceholder = computed(() => {\n if ('tokenUrl' in flow.value && flow.value.tokenUrl) {\n return flow.value.tokenUrl\n }\n return 'https://galaxy.scalar.com/oauth/refresh'\n})\n\n/**\n * Uses the stored refresh token to obtain a new access token\n * via grant_type=refresh_token.\n */\nconst handleRefresh = async (): Promise<void> => {\n if (loader.isLoading || type === 'implicit') {\n return\n }\n\n loader.start()\n\n const [error, tokens] = await refreshOauth2Token(\n flows,\n type,\n proxyUrl,\n server,\n getEnvironmentVariables(environment),\n options.customFetch,\n )\n\n await loader.clear()\n\n if (tokens?.accessToken) {\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-token': tokens.accessToken,\n ...(tokens.refreshToken\n ? { 'x-scalar-secret-refresh-token': tokens.refreshToken }\n : {}),\n })\n } else {\n console.error(error)\n toast(error?.message ?? 'Failed to refresh token', 'error')\n }\n}\n\n/** Updates the secret location */\nconst handleSecretLocationUpdate = (value: string): void => {\n const credentialsLocation = value === 'body' ? 'body' : 'header'\n\n if (scheme.type !== 'openIdConnect') {\n handleOauth2Update({\n 'x-scalar-credentials-location': credentialsLocation,\n })\n }\n\n handleOauth2SecretsUpdate({\n 'x-scalar-credentials-location': credentialsLocation,\n })\n}\n</script>\n\n<template>\n <!-- Access Token Display: Shows when user is already authorized -->\n <template v-if=\"Boolean(flow['x-scalar-secret-token'])\">\n <DataTableRow>\n <RequestAuthDataTableInput\n class=\"border-r-transparent\"\n :environment\n :modelValue=\"flow['x-scalar-secret-token']\"\n placeholder=\"QUxMIFlPVVIgQkFTRSBBUkUgQkVMT05HIFRPIFVT\"\n type=\"password\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-token': v })\n \">\n Access Token\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"supportsRefreshToken\">\n <RequestAuthDataTableInput\n class=\"border-r-transparent\"\n :environment\n :modelValue=\"flow.refreshUrl ?? ''\"\n :placeholder=\"refreshUrlPlaceholder\"\n @update:modelValue=\"(v) => handleOauth2Update({ refreshUrl: v })\">\n Refresh URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow\n v-if=\"!hideActions\"\n class=\"min-w-full\">\n <div class=\"flex h-8 items-center justify-end gap-2 border-t\">\n <ScalarButton\n v-if=\"supportsRefreshToken\"\n class=\"p-0 px-2 py-0.5\"\n :loader\n size=\"sm\"\n variant=\"outlined\"\n @click=\"handleRefresh\">\n Refresh\n </ScalarButton>\n <ScalarButton\n class=\"mr-1 p-0 px-2 py-0.5\"\n :disabled=\"loader.isLoading\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"handleClearAccessTokens\">\n Clear\n </ScalarButton>\n </div>\n </DataTableRow>\n </template>\n\n <!-- Authorization Form: Shows when user needs to authorize -->\n <template v-else>\n <DataTableRow>\n <RequestAuthDataTableInput\n v-if=\"'authorizationUrl' in flow\"\n containerClass=\"border-r-0\"\n :environment\n :modelValue=\"flow['x-scalar-secret-auth-url'] ?? ''\"\n placeholder=\"https://galaxy.scalar.com/authorize\"\n @update:modelValue=\"\n (v) => {\n handleOauth2SecretsUpdate({ 'x-scalar-secret-auth-url': v })\n handleOauth2Update({ authorizationUrl: v })\n }\n \">\n Auth URL\n </RequestAuthDataTableInput>\n\n <RequestAuthDataTableInput\n v-if=\"'tokenUrl' in flow\"\n :environment\n :modelValue=\"flow['x-scalar-secret-token-url'] ?? ''\"\n placeholder=\"https://galaxy.scalar.com/token\"\n @update:modelValue=\"\n (v) => {\n handleOauth2SecretsUpdate({ 'x-scalar-secret-token-url': v })\n handleOauth2Update({ tokenUrl: v })\n }\n \">\n Token URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"'x-scalar-secret-redirect-uri' in flow\">\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"flow['x-scalar-secret-redirect-uri']\"\n :placeholder=\"\n options.captureOAuth2Callback\n ? `${resolveDefaultOAuth2RedirectUri(options) || 'http://127.0.0.1'} (handled automatically)`\n : 'Optional redirect URL'\n \"\n @update:modelValue=\"\n (v) => {\n hasHandledRedirectPrefill = true\n handleOauth2SecretsUpdate({ 'x-scalar-secret-redirect-uri': v })\n }\n \">\n Redirect URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <template\n v-if=\"\n 'x-scalar-secret-username' in flow && 'x-scalar-secret-password' in flow\n \">\n <DataTableRow>\n <RequestAuthDataTableInput\n class=\"text-c-2\"\n :environment\n :modelValue=\"flow['x-scalar-secret-username']\"\n placeholder=\"janedoe\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-username': v })\n \">\n Username\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow>\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"flow['x-scalar-secret-password']\"\n placeholder=\"********\"\n type=\"password\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-password': v })\n \">\n Password\n </RequestAuthDataTableInput>\n </DataTableRow>\n </template>\n\n <DataTableRow>\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"flow['x-scalar-secret-client-id']\"\n placeholder=\"12345\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-client-id': v })\n \">\n Client ID\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"showClientSecret\">\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"clientSecretValue\"\n placeholder=\"XYZ123\"\n type=\"password\"\n @update:modelValue=\"\n (v) =>\n handleOauth2SecretsUpdate({ 'x-scalar-secret-client-secret': v })\n \">\n Client Secret\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"'x-usePkce' in flow\">\n <RequestAuthDataTableInput\n :enum=\"pkceOptions\"\n :environment\n :modelValue=\"flow['x-usePkce']\"\n readOnly\n @update:modelValue=\"\n (v) =>\n handleOauth2Update({\n 'x-usePkce': v as XusePkce['x-usePkce'],\n })\n \">\n Use PKCE\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <!-- Credentials Location -->\n <DataTableRow v-if=\"type !== 'implicit'\">\n <RequestAuthDataTableInput\n :enum=\"['header', 'body']\"\n :environment\n :modelValue=\"\n (flow as NonImplicitFlow)['x-scalar-credentials-location'] || 'header'\n \"\n placeholder=\"header\"\n readOnly\n @update:modelValue=\"(v) => handleSecretLocationUpdate(v)\">\n Credentials Location\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <!-- Scopes -->\n <DataTableRow>\n <OAuthScopesInput\n :flow\n :flowType=\"type\"\n :selectedScopes\n @update:selectedScopes=\"(v) => emits('update:selectedScopes', v)\"\n @upsert:scope=\"(v) => emits('upsert:scope', v)\"\n @delete:scope=\"(v) => emits('delete:scope', v)\" />\n </DataTableRow>\n\n <DataTableRow\n v-if=\"!hideActions\"\n class=\"min-w-full\">\n <div class=\"flex h-8 w-full items-center justify-end border-t\">\n <!-- Allow clearing the oauth section and going back to discovery -->\n <ScalarButton\n v-if=\"scheme.type === 'openIdConnect'\"\n class=\"mr-1 p-0 px-2 py-0.5\"\n :disabled=\"loader.isLoading\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"clearOauth2Secrets\">\n Clear\n </ScalarButton>\n\n <ScalarButton\n class=\"mr-0.75 p-0 px-2 py-0.5\"\n :loader\n size=\"sm\"\n variant=\"outlined\"\n @click=\"handleAuthorize\">\n Authorize\n </ScalarButton>\n </div>\n </DataTableRow>\n </template>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"OAuth2.vue.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue"],"sourcesContent":["<script lang=\"ts\">\n/** Any config options required for the OAuth2 flow */\nexport type OAuth2Options = Pick<\n ApiClientConfiguration,\n 'oauth2RedirectUri'\n> & {\n /** Optional fetch override (IPC-backed on desktop) used for token exchange, refresh, and OIDC discovery */\n customFetch?: typeof fetch\n /** Optional redirect capture (loopback-backed on desktop) for interactive OAuth2 flows */\n captureOAuth2Callback?: CaptureOAuth2Callback\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { useLoadingState } from '@scalar/components/loading'\nimport type { ApiClientConfiguration } from '@scalar/types/api-reference'\nimport { pkceOptions } from '@scalar/types/entities'\nimport { useToasts } from '@scalar/use-toasts'\nimport type { SecretsOAuthFlows } from '@scalar/workspace-store/entities/auth'\nimport type {\n ApiReferenceEvents,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport {\n getEnvironmentVariables,\n type OAuthFlowAuthorizationCodeSecret,\n type OAuthFlowClientCredentialsSecret,\n type OAuthFlowPasswordSecret,\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 type { XScalarCredentialsLocation } from '@scalar/workspace-store/schemas/extensions/security/x-scalar-credentials-location'\nimport { type XusePkce } from '@scalar/workspace-store/schemas/extensions/security/x-use-pkce'\nimport type {\n OAuthFlow,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed, ref, watch } from 'vue'\n\nimport OAuthScopesInput from '@/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue'\nimport {\n authorizeOauth2,\n refreshOauth2Token,\n type CaptureOAuth2Callback,\n} from '@/v2/blocks/scalar-auth-selector-block/helpers/oauth'\nimport { resolveDefaultOAuth2RedirectUri } from '@/v2/blocks/scalar-auth-selector-block/helpers/resolve-default-oauth2-redirect-url'\nimport { DataTableRow } from '@/v2/components/data-table'\n\nimport RequestAuthDataTableInput from './RequestAuthDataTableInput.vue'\n\nconst {\n environment,\n flows,\n type,\n scheme,\n selectedScopes: selectedScopesProp,\n server,\n proxyUrl,\n eventBus,\n name,\n options = {},\n} = defineProps<{\n /** Current environment configuration */\n environment: XScalarEnvironment\n /** OAuth flows */\n flows: OAuthFlowsObjectSecret\n /** Type of the OAuth flow */\n type: keyof OAuthFlowsObjectSecret\n /** Selected scopes */\n selectedScopes: string[]\n /** Security scheme */\n scheme: SecuritySchemeObjectSecret\n /** Current server configuration */\n server: ServerObject | null\n /** Proxy URL */\n proxyUrl: string\n /** Name of the security scheme */\n name: string\n /** Event bus for authentication updates */\n eventBus: WorkspaceEventBus\n /** Any config options required for the OAuth2 flow */\n options?: OAuth2Options\n /**\n * Hides the Authorize / Refresh / Clear actions. Used when the form is embedded as a\n * configuration-only view (e.g. behind a gear icon), so the host component owns the\n * authorize action and the tokens are routed to the scheme it chooses.\n */\n hideActions?: boolean\n}>()\n\nconst emits = defineEmits<{\n (\n e: 'update:selectedScopes',\n payload: { scopes?: string[]; scope?: string; selected?: boolean },\n ): void\n (\n e: 'upsert:scope',\n payload: Omit<ApiReferenceEvents['auth:upsert:scopes'], 'name'>,\n ): void\n (\n e: 'delete:scope',\n payload: Omit<ApiReferenceEvents['auth:delete:scopes'], 'name'>,\n ): void\n}>()\n\nconst loader = useLoadingState()\nconst { toast } = useToasts()\n\n/** The current OAuth flow based on the selected type */\nconst flow = computed(() => flows[type]!)\ntype NonImplicitFlow =\n | OAuthFlowPasswordSecret\n | OAuthFlowClientCredentialsSecret\n | OAuthFlowAuthorizationCodeSecret\n\n/** We filter selected scopes to only include scopes that are defined on this flow (own keys only). */\nconst selectedScopes = computed(() => {\n const definedScopes = flow.value.scopes\n if (!definedScopes) {\n return []\n }\n return selectedScopesProp.filter((scope) =>\n Object.hasOwn(definedScopes, scope),\n )\n})\n\n/**\n * Show the client secret whenever the flow supports one. PKCE and a client\n * secret are independent, so confidential clients can use both together\n * (see RFC 9700 Section 2.1.1).\n */\nconst showClientSecret = computed(\n () => 'x-scalar-secret-client-secret' in flow.value,\n)\n\nconst clientSecretValue = computed((): string => {\n const f = flow.value as { 'x-scalar-secret-client-secret'?: string }\n return f['x-scalar-secret-client-secret'] ?? ''\n})\n\n/** Updates the security scheme base */\nconst handleOauth2Update = (\n payload: Partial<OAuthFlow & XScalarCredentialsLocation>,\n): void => {\n // OpenIdConnect uses the secrets update for all\n if (scheme.type === 'openIdConnect') {\n return handleOauth2SecretsUpdate(payload)\n }\n\n // Only OAuth2 schemes carry flows on the document; this component is never\n // rendered for the other scheme types.\n if (scheme.type !== 'oauth2') {\n return\n }\n\n eventBus.emit('auth:update:security-scheme', {\n payload: {\n type: scheme.type,\n flows: {\n [type]: payload,\n },\n },\n name,\n })\n}\n\n/** Updates the flow secrets */\nconst handleOauth2SecretsUpdate = (\n payload: Omit<Partial<SecretsOAuthFlows[keyof SecretsOAuthFlows]>, 'type'>,\n): void => {\n // This component only renders for oauth2/openIdConnect. Other scheme types (e.g. mutualTLS)\n // carry no flow secrets, so there is nothing to persist and no matching secrets payload type.\n if (scheme.type !== 'oauth2' && scheme.type !== 'openIdConnect') {\n return\n }\n\n eventBus.emit('auth:update:security-scheme-secrets', {\n payload: {\n type: scheme.type,\n [type]: payload,\n },\n name,\n })\n}\n\n/** Clears the flow secrets */\nconst clearOauth2Secrets = (): void => {\n if (loader.isLoading) {\n return\n }\n eventBus.emit('auth:clear:security-scheme-secrets', {\n name,\n })\n}\n\n/** Clears stored access and refresh tokens (authorized state) */\nconst handleClearAccessTokens = (): void => {\n if (loader.isLoading) {\n return\n }\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-token': '',\n 'x-scalar-secret-refresh-token': '',\n })\n}\n\n/** Track redirect URI prefill per flow instance to support document switching */\nconst prefilledFlowIdentity = ref<string | null>(null)\nconst hasHandledRedirectPrefill = ref(false)\n\nconst resolveFlowIdentity = (\n currentFlow: OAuthFlowsObjectSecret[keyof OAuthFlowsObjectSecret] | undefined,\n): string =>\n JSON.stringify({\n type,\n authorizationUrl:\n currentFlow && 'authorizationUrl' in currentFlow\n ? currentFlow.authorizationUrl\n : '',\n tokenUrl:\n currentFlow && 'tokenUrl' in currentFlow ? currentFlow.tokenUrl : '',\n refreshUrl: currentFlow?.refreshUrl ?? '',\n scopes: Object.keys(currentFlow?.scopes ?? {}),\n })\n\n/** Default the redirect-uri to the current origin if we have access to window */\nwatch(\n () => flow.value,\n (currentFlow) => {\n if (!currentFlow || !('x-scalar-secret-redirect-uri' in currentFlow)) {\n return\n }\n\n const flowIdentity = resolveFlowIdentity(currentFlow)\n if (prefilledFlowIdentity.value !== flowIdentity) {\n prefilledFlowIdentity.value = flowIdentity\n hasHandledRedirectPrefill.value = false\n }\n\n if (hasHandledRedirectPrefill.value) {\n return\n }\n\n const newRedirectUri = (currentFlow as OAuthFlowAuthorizationCodeSecret)[\n 'x-scalar-secret-redirect-uri'\n ]\n const defaultRedirectUri = resolveDefaultOAuth2RedirectUri(options)\n\n hasHandledRedirectPrefill.value = true\n\n // The desktop loopback path computes the redirect URI at authorize time (an\n // ephemeral 127.0.0.1 port), so persisting a default into the document would\n // only bake in a stale, unused value. Leave it empty and show a hint instead.\n if (\n newRedirectUri ||\n !defaultRedirectUri ||\n options.captureOAuth2Callback\n ) {\n return\n }\n\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-redirect-uri': defaultRedirectUri,\n })\n },\n { immediate: true },\n)\n\n/**\n * Authorizes the user using the specified OAuth flow.\n * Opens the appropriate OAuth dialog and/or performs the token exchange.\n */\nconst handleAuthorize = async (): Promise<void> => {\n if (loader.isLoading) {\n return\n }\n\n loader.start()\n\n const [error, tokens] = await authorizeOauth2(\n flows,\n type,\n selectedScopes.value,\n server,\n proxyUrl,\n getEnvironmentVariables(environment),\n options.customFetch,\n options.captureOAuth2Callback,\n )\n\n await loader.clear()\n\n if (tokens?.accessToken) {\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-token': tokens.accessToken,\n ...(tokens.refreshToken\n ? { 'x-scalar-secret-refresh-token': tokens.refreshToken }\n : {}),\n })\n } else {\n console.error(error)\n toast(error?.message ?? 'Failed to authorize', 'error')\n }\n}\n\n/** Whether the current flow supports refreshing the access token */\nconst supportsRefreshToken = computed(() => type !== 'implicit')\n\n/**\n * Refresh URL placeholder, shows tokenUrl as hint if refreshUrl is not specified.\n * This helps users understand that tokenUrl will be used as fallback.\n */\nconst refreshUrlPlaceholder = computed(() => {\n if ('tokenUrl' in flow.value && flow.value.tokenUrl) {\n return flow.value.tokenUrl\n }\n return 'https://galaxy.scalar.com/oauth/refresh'\n})\n\n/**\n * Uses the stored refresh token to obtain a new access token\n * via grant_type=refresh_token.\n */\nconst handleRefresh = async (): Promise<void> => {\n if (loader.isLoading || type === 'implicit') {\n return\n }\n\n loader.start()\n\n const [error, tokens] = await refreshOauth2Token(\n flows,\n type,\n proxyUrl,\n server,\n getEnvironmentVariables(environment),\n options.customFetch,\n )\n\n await loader.clear()\n\n if (tokens?.accessToken) {\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-token': tokens.accessToken,\n ...(tokens.refreshToken\n ? { 'x-scalar-secret-refresh-token': tokens.refreshToken }\n : {}),\n })\n } else {\n console.error(error)\n toast(error?.message ?? 'Failed to refresh token', 'error')\n }\n}\n\n/** Updates the secret location */\nconst handleSecretLocationUpdate = (value: string): void => {\n const credentialsLocation = value === 'body' ? 'body' : 'header'\n\n if (scheme.type !== 'openIdConnect') {\n handleOauth2Update({\n 'x-scalar-credentials-location': credentialsLocation,\n })\n }\n\n handleOauth2SecretsUpdate({\n 'x-scalar-credentials-location': credentialsLocation,\n })\n}\n</script>\n\n<template>\n <!-- Access Token Display: Shows when user is already authorized -->\n <template v-if=\"Boolean(flow['x-scalar-secret-token'])\">\n <DataTableRow>\n <RequestAuthDataTableInput\n class=\"border-r-transparent\"\n :environment\n :modelValue=\"flow['x-scalar-secret-token']\"\n placeholder=\"QUxMIFlPVVIgQkFTRSBBUkUgQkVMT05HIFRPIFVT\"\n type=\"password\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-token': v })\n \">\n Access Token\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"supportsRefreshToken\">\n <RequestAuthDataTableInput\n class=\"border-r-transparent\"\n :environment\n :modelValue=\"flow.refreshUrl ?? ''\"\n :placeholder=\"refreshUrlPlaceholder\"\n @update:modelValue=\"(v) => handleOauth2Update({ refreshUrl: v })\">\n Refresh URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow\n v-if=\"!hideActions\"\n class=\"min-w-full\">\n <div class=\"flex h-8 items-center justify-end gap-2 border-t\">\n <ScalarButton\n v-if=\"supportsRefreshToken\"\n class=\"p-0 px-2 py-0.5\"\n :loader\n size=\"sm\"\n variant=\"outlined\"\n @click=\"handleRefresh\">\n Refresh\n </ScalarButton>\n <ScalarButton\n class=\"mr-1 p-0 px-2 py-0.5\"\n :disabled=\"loader.isLoading\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"handleClearAccessTokens\">\n Clear\n </ScalarButton>\n </div>\n </DataTableRow>\n </template>\n\n <!-- Authorization Form: Shows when user needs to authorize -->\n <template v-else>\n <DataTableRow>\n <RequestAuthDataTableInput\n v-if=\"'authorizationUrl' in flow\"\n containerClass=\"border-r-0\"\n :environment\n :modelValue=\"flow['x-scalar-secret-auth-url'] ?? ''\"\n placeholder=\"https://galaxy.scalar.com/authorize\"\n @update:modelValue=\"\n (v) => {\n handleOauth2SecretsUpdate({ 'x-scalar-secret-auth-url': v })\n handleOauth2Update({ authorizationUrl: v })\n }\n \">\n Auth URL\n </RequestAuthDataTableInput>\n\n <RequestAuthDataTableInput\n v-if=\"'tokenUrl' in flow\"\n :environment\n :modelValue=\"flow['x-scalar-secret-token-url'] ?? ''\"\n placeholder=\"https://galaxy.scalar.com/token\"\n @update:modelValue=\"\n (v) => {\n handleOauth2SecretsUpdate({ 'x-scalar-secret-token-url': v })\n handleOauth2Update({ tokenUrl: v })\n }\n \">\n Token URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"'x-scalar-secret-redirect-uri' in flow\">\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"flow['x-scalar-secret-redirect-uri']\"\n :placeholder=\"\n options.captureOAuth2Callback\n ? `${resolveDefaultOAuth2RedirectUri(options) || 'http://127.0.0.1'} (handled automatically)`\n : 'Optional redirect URL'\n \"\n @update:modelValue=\"\n (v) => {\n hasHandledRedirectPrefill = true\n handleOauth2SecretsUpdate({ 'x-scalar-secret-redirect-uri': v })\n }\n \">\n Redirect URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <template\n v-if=\"\n 'x-scalar-secret-username' in flow && 'x-scalar-secret-password' in flow\n \">\n <DataTableRow>\n <RequestAuthDataTableInput\n class=\"text-c-2\"\n :environment\n :modelValue=\"flow['x-scalar-secret-username']\"\n placeholder=\"janedoe\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-username': v })\n \">\n Username\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow>\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"flow['x-scalar-secret-password']\"\n placeholder=\"********\"\n type=\"password\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-password': v })\n \">\n Password\n </RequestAuthDataTableInput>\n </DataTableRow>\n </template>\n\n <DataTableRow>\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"flow['x-scalar-secret-client-id']\"\n placeholder=\"12345\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-client-id': v })\n \">\n Client ID\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"showClientSecret\">\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"clientSecretValue\"\n placeholder=\"XYZ123\"\n type=\"password\"\n @update:modelValue=\"\n (v) =>\n handleOauth2SecretsUpdate({ 'x-scalar-secret-client-secret': v })\n \">\n Client Secret\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"'x-usePkce' in flow\">\n <RequestAuthDataTableInput\n :enum=\"pkceOptions\"\n :environment\n :modelValue=\"flow['x-usePkce']\"\n readOnly\n @update:modelValue=\"\n (v) =>\n handleOauth2Update({\n 'x-usePkce': v as XusePkce['x-usePkce'],\n })\n \">\n Use PKCE\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <!-- Credentials Location -->\n <DataTableRow v-if=\"type !== 'implicit'\">\n <RequestAuthDataTableInput\n :enum=\"['header', 'body']\"\n :environment\n :modelValue=\"\n (flow as NonImplicitFlow)['x-scalar-credentials-location'] || 'header'\n \"\n placeholder=\"header\"\n readOnly\n @update:modelValue=\"(v) => handleSecretLocationUpdate(v)\">\n Credentials Location\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <!-- Scopes -->\n <DataTableRow>\n <OAuthScopesInput\n :flow\n :flowType=\"type\"\n :selectedScopes\n @update:selectedScopes=\"(v) => emits('update:selectedScopes', v)\"\n @upsert:scope=\"(v) => emits('upsert:scope', v)\"\n @delete:scope=\"(v) => emits('delete:scope', v)\" />\n </DataTableRow>\n\n <DataTableRow\n v-if=\"!hideActions\"\n class=\"min-w-full\">\n <div class=\"flex h-8 w-full items-center justify-end border-t\">\n <!-- Allow clearing the oauth section and going back to discovery -->\n <ScalarButton\n v-if=\"scheme.type === 'openIdConnect'\"\n class=\"mr-1 p-0 px-2 py-0.5\"\n :disabled=\"loader.isLoading\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"clearOauth2Secrets\">\n Clear\n </ScalarButton>\n\n <ScalarButton\n class=\"mr-0.75 p-0 px-2 py-0.5\"\n :loader\n size=\"sm\"\n variant=\"outlined\"\n @click=\"handleAuthorize\">\n Authorize\n </ScalarButton>\n </div>\n </DataTableRow>\n </template>\n</template>\n"],"mappings":""}
|
|
@@ -65,13 +65,16 @@ var OAuth2_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineCom
|
|
|
65
65
|
});
|
|
66
66
|
};
|
|
67
67
|
/** Updates the flow secrets */
|
|
68
|
-
const handleOauth2SecretsUpdate = (payload) =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
const handleOauth2SecretsUpdate = (payload) => {
|
|
69
|
+
if (__props.scheme.type !== "oauth2" && __props.scheme.type !== "openIdConnect") return;
|
|
70
|
+
__props.eventBus.emit("auth:update:security-scheme-secrets", {
|
|
71
|
+
payload: {
|
|
72
|
+
type: __props.scheme.type,
|
|
73
|
+
[__props.type]: payload
|
|
74
|
+
},
|
|
75
|
+
name: __props.name
|
|
76
|
+
});
|
|
77
|
+
};
|
|
75
78
|
/** Clears the flow secrets */
|
|
76
79
|
const clearOauth2Secrets = () => {
|
|
77
80
|
if (loader.isLoading) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuth2.vue.script.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue"],"sourcesContent":["<script lang=\"ts\">\n/** Any config options required for the OAuth2 flow */\nexport type OAuth2Options = Pick<\n ApiClientConfiguration,\n 'oauth2RedirectUri'\n> & {\n /** Optional fetch override (IPC-backed on desktop) used for token exchange, refresh, and OIDC discovery */\n customFetch?: typeof fetch\n /** Optional redirect capture (loopback-backed on desktop) for interactive OAuth2 flows */\n captureOAuth2Callback?: CaptureOAuth2Callback\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { useLoadingState } from '@scalar/components/loading'\nimport type { ApiClientConfiguration } from '@scalar/types/api-reference'\nimport { pkceOptions } from '@scalar/types/entities'\nimport { useToasts } from '@scalar/use-toasts'\nimport type { SecretsOAuthFlows } from '@scalar/workspace-store/entities/auth'\nimport type {\n ApiReferenceEvents,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport {\n getEnvironmentVariables,\n type OAuthFlowAuthorizationCodeSecret,\n type OAuthFlowClientCredentialsSecret,\n type OAuthFlowPasswordSecret,\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 type { XScalarCredentialsLocation } from '@scalar/workspace-store/schemas/extensions/security/x-scalar-credentials-location'\nimport { type XusePkce } from '@scalar/workspace-store/schemas/extensions/security/x-use-pkce'\nimport type {\n OAuthFlow,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed, ref, watch } from 'vue'\n\nimport OAuthScopesInput from '@/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue'\nimport {\n authorizeOauth2,\n refreshOauth2Token,\n type CaptureOAuth2Callback,\n} from '@/v2/blocks/scalar-auth-selector-block/helpers/oauth'\nimport { resolveDefaultOAuth2RedirectUri } from '@/v2/blocks/scalar-auth-selector-block/helpers/resolve-default-oauth2-redirect-url'\nimport { DataTableRow } from '@/v2/components/data-table'\n\nimport RequestAuthDataTableInput from './RequestAuthDataTableInput.vue'\n\nconst {\n environment,\n flows,\n type,\n scheme,\n selectedScopes: selectedScopesProp,\n server,\n proxyUrl,\n eventBus,\n name,\n options = {},\n} = defineProps<{\n /** Current environment configuration */\n environment: XScalarEnvironment\n /** OAuth flows */\n flows: OAuthFlowsObjectSecret\n /** Type of the OAuth flow */\n type: keyof OAuthFlowsObjectSecret\n /** Selected scopes */\n selectedScopes: string[]\n /** Security scheme */\n scheme: SecuritySchemeObjectSecret\n /** Current server configuration */\n server: ServerObject | null\n /** Proxy URL */\n proxyUrl: string\n /** Name of the security scheme */\n name: string\n /** Event bus for authentication updates */\n eventBus: WorkspaceEventBus\n /** Any config options required for the OAuth2 flow */\n options?: OAuth2Options\n /**\n * Hides the Authorize / Refresh / Clear actions. Used when the form is embedded as a\n * configuration-only view (e.g. behind a gear icon), so the host component owns the\n * authorize action and the tokens are routed to the scheme it chooses.\n */\n hideActions?: boolean\n}>()\n\nconst emits = defineEmits<{\n (\n e: 'update:selectedScopes',\n payload: { scopes?: string[]; scope?: string; selected?: boolean },\n ): void\n (\n e: 'upsert:scope',\n payload: Omit<ApiReferenceEvents['auth:upsert:scopes'], 'name'>,\n ): void\n (\n e: 'delete:scope',\n payload: Omit<ApiReferenceEvents['auth:delete:scopes'], 'name'>,\n ): void\n}>()\n\nconst loader = useLoadingState()\nconst { toast } = useToasts()\n\n/** The current OAuth flow based on the selected type */\nconst flow = computed(() => flows[type]!)\ntype NonImplicitFlow =\n | OAuthFlowPasswordSecret\n | OAuthFlowClientCredentialsSecret\n | OAuthFlowAuthorizationCodeSecret\n\n/** We filter selected scopes to only include scopes that are defined on this flow (own keys only). */\nconst selectedScopes = computed(() => {\n const definedScopes = flow.value.scopes\n if (!definedScopes) {\n return []\n }\n return selectedScopesProp.filter((scope) =>\n Object.hasOwn(definedScopes, scope),\n )\n})\n\n/**\n * Show the client secret whenever the flow supports one. PKCE and a client\n * secret are independent, so confidential clients can use both together\n * (see RFC 9700 Section 2.1.1).\n */\nconst showClientSecret = computed(\n () => 'x-scalar-secret-client-secret' in flow.value,\n)\n\nconst clientSecretValue = computed((): string => {\n const f = flow.value as { 'x-scalar-secret-client-secret'?: string }\n return f['x-scalar-secret-client-secret'] ?? ''\n})\n\n/** Updates the security scheme base */\nconst handleOauth2Update = (\n payload: Partial<OAuthFlow & XScalarCredentialsLocation>,\n): void => {\n // OpenIdConnect uses the secrets update for all\n if (scheme.type === 'openIdConnect') {\n return handleOauth2SecretsUpdate(payload)\n }\n\n // Only OAuth2 schemes carry flows on the document; this component is never\n // rendered for the other scheme types.\n if (scheme.type !== 'oauth2') {\n return\n }\n\n eventBus.emit('auth:update:security-scheme', {\n payload: {\n type: scheme.type,\n flows: {\n [type]: payload,\n },\n },\n name,\n })\n}\n\n/** Updates the flow secrets */\nconst handleOauth2SecretsUpdate = (\n payload: Omit<Partial<SecretsOAuthFlows[keyof SecretsOAuthFlows]>, 'type'>,\n): void =>\n eventBus.emit('auth:update:security-scheme-secrets', {\n payload: {\n type: scheme.type,\n [type]: payload,\n },\n name,\n })\n\n/** Clears the flow secrets */\nconst clearOauth2Secrets = (): void => {\n if (loader.isLoading) {\n return\n }\n eventBus.emit('auth:clear:security-scheme-secrets', {\n name,\n })\n}\n\n/** Clears stored access and refresh tokens (authorized state) */\nconst handleClearAccessTokens = (): void => {\n if (loader.isLoading) {\n return\n }\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-token': '',\n 'x-scalar-secret-refresh-token': '',\n })\n}\n\n/** Track redirect URI prefill per flow instance to support document switching */\nconst prefilledFlowIdentity = ref<string | null>(null)\nconst hasHandledRedirectPrefill = ref(false)\n\nconst resolveFlowIdentity = (\n currentFlow: OAuthFlowsObjectSecret[keyof OAuthFlowsObjectSecret] | undefined,\n): string =>\n JSON.stringify({\n type,\n authorizationUrl:\n currentFlow && 'authorizationUrl' in currentFlow\n ? currentFlow.authorizationUrl\n : '',\n tokenUrl:\n currentFlow && 'tokenUrl' in currentFlow ? currentFlow.tokenUrl : '',\n refreshUrl: currentFlow?.refreshUrl ?? '',\n scopes: Object.keys(currentFlow?.scopes ?? {}),\n })\n\n/** Default the redirect-uri to the current origin if we have access to window */\nwatch(\n () => flow.value,\n (currentFlow) => {\n if (!currentFlow || !('x-scalar-secret-redirect-uri' in currentFlow)) {\n return\n }\n\n const flowIdentity = resolveFlowIdentity(currentFlow)\n if (prefilledFlowIdentity.value !== flowIdentity) {\n prefilledFlowIdentity.value = flowIdentity\n hasHandledRedirectPrefill.value = false\n }\n\n if (hasHandledRedirectPrefill.value) {\n return\n }\n\n const newRedirectUri = (currentFlow as OAuthFlowAuthorizationCodeSecret)[\n 'x-scalar-secret-redirect-uri'\n ]\n const defaultRedirectUri = resolveDefaultOAuth2RedirectUri(options)\n\n hasHandledRedirectPrefill.value = true\n\n // The desktop loopback path computes the redirect URI at authorize time (an\n // ephemeral 127.0.0.1 port), so persisting a default into the document would\n // only bake in a stale, unused value. Leave it empty and show a hint instead.\n if (\n newRedirectUri ||\n !defaultRedirectUri ||\n options.captureOAuth2Callback\n ) {\n return\n }\n\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-redirect-uri': defaultRedirectUri,\n })\n },\n { immediate: true },\n)\n\n/**\n * Authorizes the user using the specified OAuth flow.\n * Opens the appropriate OAuth dialog and/or performs the token exchange.\n */\nconst handleAuthorize = async (): Promise<void> => {\n if (loader.isLoading) {\n return\n }\n\n loader.start()\n\n const [error, tokens] = await authorizeOauth2(\n flows,\n type,\n selectedScopes.value,\n server,\n proxyUrl,\n getEnvironmentVariables(environment),\n options.customFetch,\n options.captureOAuth2Callback,\n )\n\n await loader.clear()\n\n if (tokens?.accessToken) {\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-token': tokens.accessToken,\n ...(tokens.refreshToken\n ? { 'x-scalar-secret-refresh-token': tokens.refreshToken }\n : {}),\n })\n } else {\n console.error(error)\n toast(error?.message ?? 'Failed to authorize', 'error')\n }\n}\n\n/** Whether the current flow supports refreshing the access token */\nconst supportsRefreshToken = computed(() => type !== 'implicit')\n\n/**\n * Refresh URL placeholder, shows tokenUrl as hint if refreshUrl is not specified.\n * This helps users understand that tokenUrl will be used as fallback.\n */\nconst refreshUrlPlaceholder = computed(() => {\n if ('tokenUrl' in flow.value && flow.value.tokenUrl) {\n return flow.value.tokenUrl\n }\n return 'https://galaxy.scalar.com/oauth/refresh'\n})\n\n/**\n * Uses the stored refresh token to obtain a new access token\n * via grant_type=refresh_token.\n */\nconst handleRefresh = async (): Promise<void> => {\n if (loader.isLoading || type === 'implicit') {\n return\n }\n\n loader.start()\n\n const [error, tokens] = await refreshOauth2Token(\n flows,\n type,\n proxyUrl,\n server,\n getEnvironmentVariables(environment),\n options.customFetch,\n )\n\n await loader.clear()\n\n if (tokens?.accessToken) {\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-token': tokens.accessToken,\n ...(tokens.refreshToken\n ? { 'x-scalar-secret-refresh-token': tokens.refreshToken }\n : {}),\n })\n } else {\n console.error(error)\n toast(error?.message ?? 'Failed to refresh token', 'error')\n }\n}\n\n/** Updates the secret location */\nconst handleSecretLocationUpdate = (value: string): void => {\n const credentialsLocation = value === 'body' ? 'body' : 'header'\n\n if (scheme.type !== 'openIdConnect') {\n handleOauth2Update({\n 'x-scalar-credentials-location': credentialsLocation,\n })\n }\n\n handleOauth2SecretsUpdate({\n 'x-scalar-credentials-location': credentialsLocation,\n })\n}\n</script>\n\n<template>\n <!-- Access Token Display: Shows when user is already authorized -->\n <template v-if=\"Boolean(flow['x-scalar-secret-token'])\">\n <DataTableRow>\n <RequestAuthDataTableInput\n class=\"border-r-transparent\"\n :environment\n :modelValue=\"flow['x-scalar-secret-token']\"\n placeholder=\"QUxMIFlPVVIgQkFTRSBBUkUgQkVMT05HIFRPIFVT\"\n type=\"password\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-token': v })\n \">\n Access Token\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"supportsRefreshToken\">\n <RequestAuthDataTableInput\n class=\"border-r-transparent\"\n :environment\n :modelValue=\"flow.refreshUrl ?? ''\"\n :placeholder=\"refreshUrlPlaceholder\"\n @update:modelValue=\"(v) => handleOauth2Update({ refreshUrl: v })\">\n Refresh URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow\n v-if=\"!hideActions\"\n class=\"min-w-full\">\n <div class=\"flex h-8 items-center justify-end gap-2 border-t\">\n <ScalarButton\n v-if=\"supportsRefreshToken\"\n class=\"p-0 px-2 py-0.5\"\n :loader\n size=\"sm\"\n variant=\"outlined\"\n @click=\"handleRefresh\">\n Refresh\n </ScalarButton>\n <ScalarButton\n class=\"mr-1 p-0 px-2 py-0.5\"\n :disabled=\"loader.isLoading\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"handleClearAccessTokens\">\n Clear\n </ScalarButton>\n </div>\n </DataTableRow>\n </template>\n\n <!-- Authorization Form: Shows when user needs to authorize -->\n <template v-else>\n <DataTableRow>\n <RequestAuthDataTableInput\n v-if=\"'authorizationUrl' in flow\"\n containerClass=\"border-r-0\"\n :environment\n :modelValue=\"flow['x-scalar-secret-auth-url'] ?? ''\"\n placeholder=\"https://galaxy.scalar.com/authorize\"\n @update:modelValue=\"\n (v) => {\n handleOauth2SecretsUpdate({ 'x-scalar-secret-auth-url': v })\n handleOauth2Update({ authorizationUrl: v })\n }\n \">\n Auth URL\n </RequestAuthDataTableInput>\n\n <RequestAuthDataTableInput\n v-if=\"'tokenUrl' in flow\"\n :environment\n :modelValue=\"flow['x-scalar-secret-token-url'] ?? ''\"\n placeholder=\"https://galaxy.scalar.com/token\"\n @update:modelValue=\"\n (v) => {\n handleOauth2SecretsUpdate({ 'x-scalar-secret-token-url': v })\n handleOauth2Update({ tokenUrl: v })\n }\n \">\n Token URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"'x-scalar-secret-redirect-uri' in flow\">\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"flow['x-scalar-secret-redirect-uri']\"\n :placeholder=\"\n options.captureOAuth2Callback\n ? `${resolveDefaultOAuth2RedirectUri(options) || 'http://127.0.0.1'} (handled automatically)`\n : 'Optional redirect URL'\n \"\n @update:modelValue=\"\n (v) => {\n hasHandledRedirectPrefill = true\n handleOauth2SecretsUpdate({ 'x-scalar-secret-redirect-uri': v })\n }\n \">\n Redirect URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <template\n v-if=\"\n 'x-scalar-secret-username' in flow && 'x-scalar-secret-password' in flow\n \">\n <DataTableRow>\n <RequestAuthDataTableInput\n class=\"text-c-2\"\n :environment\n :modelValue=\"flow['x-scalar-secret-username']\"\n placeholder=\"janedoe\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-username': v })\n \">\n Username\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow>\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"flow['x-scalar-secret-password']\"\n placeholder=\"********\"\n type=\"password\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-password': v })\n \">\n Password\n </RequestAuthDataTableInput>\n </DataTableRow>\n </template>\n\n <DataTableRow>\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"flow['x-scalar-secret-client-id']\"\n placeholder=\"12345\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-client-id': v })\n \">\n Client ID\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"showClientSecret\">\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"clientSecretValue\"\n placeholder=\"XYZ123\"\n type=\"password\"\n @update:modelValue=\"\n (v) =>\n handleOauth2SecretsUpdate({ 'x-scalar-secret-client-secret': v })\n \">\n Client Secret\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"'x-usePkce' in flow\">\n <RequestAuthDataTableInput\n :enum=\"pkceOptions\"\n :environment\n :modelValue=\"flow['x-usePkce']\"\n readOnly\n @update:modelValue=\"\n (v) =>\n handleOauth2Update({\n 'x-usePkce': v as XusePkce['x-usePkce'],\n })\n \">\n Use PKCE\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <!-- Credentials Location -->\n <DataTableRow v-if=\"type !== 'implicit'\">\n <RequestAuthDataTableInput\n :enum=\"['header', 'body']\"\n :environment\n :modelValue=\"\n (flow as NonImplicitFlow)['x-scalar-credentials-location'] || 'header'\n \"\n placeholder=\"header\"\n readOnly\n @update:modelValue=\"(v) => handleSecretLocationUpdate(v)\">\n Credentials Location\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <!-- Scopes -->\n <DataTableRow>\n <OAuthScopesInput\n :flow\n :flowType=\"type\"\n :selectedScopes\n @update:selectedScopes=\"(v) => emits('update:selectedScopes', v)\"\n @upsert:scope=\"(v) => emits('upsert:scope', v)\"\n @delete:scope=\"(v) => emits('delete:scope', v)\" />\n </DataTableRow>\n\n <DataTableRow\n v-if=\"!hideActions\"\n class=\"min-w-full\">\n <div class=\"flex h-8 w-full items-center justify-end border-t\">\n <!-- Allow clearing the oauth section and going back to discovery -->\n <ScalarButton\n v-if=\"scheme.type === 'openIdConnect'\"\n class=\"mr-1 p-0 px-2 py-0.5\"\n :disabled=\"loader.isLoading\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"clearOauth2Secrets\">\n Clear\n </ScalarButton>\n\n <ScalarButton\n class=\"mr-0.75 p-0 px-2 py-0.5\"\n :loader\n size=\"sm\"\n variant=\"outlined\"\n @click=\"handleAuthorize\">\n Authorize\n </ScalarButton>\n </div>\n </DataTableRow>\n </template>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4FA,MAAM,QAAQ;EAed,MAAM,SAAS,gBAAgB;EAC/B,MAAM,EAAE,UAAU,UAAU;;EAG5B,MAAM,OAAO,eAAe,QAAA,MAAM,QAAA,KAAM;EAOxC,MAAM,iBAAiB,eAAe;GACpC,MAAM,gBAAgB,KAAK,MAAM;GACjC,IAAI,CAAC,eACH,OAAO,CAAC;GAEV,OAAO,QAAA,eAAmB,QAAQ,UAChC,OAAO,OAAO,eAAe,KAAK,CACpC;EACF,CAAC;;;;;;EAOD,MAAM,mBAAmB,eACjB,mCAAmC,KAAK,KAChD;EAEA,MAAM,oBAAoB,eAAuB;GAE/C,OADU,KAAK,MACN,oCAAoC;EAC/C,CAAC;;EAGD,MAAM,sBACJ,YACS;GAET,IAAI,QAAA,OAAO,SAAS,iBAClB,OAAO,0BAA0B,OAAO;GAK1C,IAAI,QAAA,OAAO,SAAS,UAClB;GAGF,QAAA,SAAS,KAAK,+BAA+B;IAC3C,SAAS;KACP,MAAM,QAAA,OAAO;KACb,OAAO,GACJ,QAAA,OAAO,QACV;IACF;IACA,MAAG,QAAA;GACL,CAAC;EACH;;EAGA,MAAM,6BACJ,YAEA,QAAA,SAAS,KAAK,uCAAuC;GACnD,SAAS;IACP,MAAM,QAAA,OAAO;KACZ,QAAA,OAAO;GACV;GACA,MAAG,QAAA;EACL,CAAC;;EAGH,MAAM,2BAAiC;GACrC,IAAI,OAAO,WACT;GAEF,QAAA,SAAS,KAAK,sCAAsC,EAClD,MAAG,QAAA,KACL,CAAC;EACH;;EAGA,MAAM,gCAAsC;GAC1C,IAAI,OAAO,WACT;GAEF,0B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M;MACL,QAAA,MAAA,MAAA;MACD,MAAK;MACL,SAAQ;MACP,SAAO;;6BAEV,CAAA,GAAA,OAAA,QAAA,OAAA,MAAA,CAAA,gBAF2B,eAE3B,EAAA,CAAA,EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"OAuth2.vue.script.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuth2.vue"],"sourcesContent":["<script lang=\"ts\">\n/** Any config options required for the OAuth2 flow */\nexport type OAuth2Options = Pick<\n ApiClientConfiguration,\n 'oauth2RedirectUri'\n> & {\n /** Optional fetch override (IPC-backed on desktop) used for token exchange, refresh, and OIDC discovery */\n customFetch?: typeof fetch\n /** Optional redirect capture (loopback-backed on desktop) for interactive OAuth2 flows */\n captureOAuth2Callback?: CaptureOAuth2Callback\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { ScalarButton } from '@scalar/components/button'\nimport { useLoadingState } from '@scalar/components/loading'\nimport type { ApiClientConfiguration } from '@scalar/types/api-reference'\nimport { pkceOptions } from '@scalar/types/entities'\nimport { useToasts } from '@scalar/use-toasts'\nimport type { SecretsOAuthFlows } from '@scalar/workspace-store/entities/auth'\nimport type {\n ApiReferenceEvents,\n WorkspaceEventBus,\n} from '@scalar/workspace-store/events'\nimport {\n getEnvironmentVariables,\n type OAuthFlowAuthorizationCodeSecret,\n type OAuthFlowClientCredentialsSecret,\n type OAuthFlowPasswordSecret,\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 type { XScalarCredentialsLocation } from '@scalar/workspace-store/schemas/extensions/security/x-scalar-credentials-location'\nimport { type XusePkce } from '@scalar/workspace-store/schemas/extensions/security/x-use-pkce'\nimport type {\n OAuthFlow,\n ServerObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed, ref, watch } from 'vue'\n\nimport OAuthScopesInput from '@/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue'\nimport {\n authorizeOauth2,\n refreshOauth2Token,\n type CaptureOAuth2Callback,\n} from '@/v2/blocks/scalar-auth-selector-block/helpers/oauth'\nimport { resolveDefaultOAuth2RedirectUri } from '@/v2/blocks/scalar-auth-selector-block/helpers/resolve-default-oauth2-redirect-url'\nimport { DataTableRow } from '@/v2/components/data-table'\n\nimport RequestAuthDataTableInput from './RequestAuthDataTableInput.vue'\n\nconst {\n environment,\n flows,\n type,\n scheme,\n selectedScopes: selectedScopesProp,\n server,\n proxyUrl,\n eventBus,\n name,\n options = {},\n} = defineProps<{\n /** Current environment configuration */\n environment: XScalarEnvironment\n /** OAuth flows */\n flows: OAuthFlowsObjectSecret\n /** Type of the OAuth flow */\n type: keyof OAuthFlowsObjectSecret\n /** Selected scopes */\n selectedScopes: string[]\n /** Security scheme */\n scheme: SecuritySchemeObjectSecret\n /** Current server configuration */\n server: ServerObject | null\n /** Proxy URL */\n proxyUrl: string\n /** Name of the security scheme */\n name: string\n /** Event bus for authentication updates */\n eventBus: WorkspaceEventBus\n /** Any config options required for the OAuth2 flow */\n options?: OAuth2Options\n /**\n * Hides the Authorize / Refresh / Clear actions. Used when the form is embedded as a\n * configuration-only view (e.g. behind a gear icon), so the host component owns the\n * authorize action and the tokens are routed to the scheme it chooses.\n */\n hideActions?: boolean\n}>()\n\nconst emits = defineEmits<{\n (\n e: 'update:selectedScopes',\n payload: { scopes?: string[]; scope?: string; selected?: boolean },\n ): void\n (\n e: 'upsert:scope',\n payload: Omit<ApiReferenceEvents['auth:upsert:scopes'], 'name'>,\n ): void\n (\n e: 'delete:scope',\n payload: Omit<ApiReferenceEvents['auth:delete:scopes'], 'name'>,\n ): void\n}>()\n\nconst loader = useLoadingState()\nconst { toast } = useToasts()\n\n/** The current OAuth flow based on the selected type */\nconst flow = computed(() => flows[type]!)\ntype NonImplicitFlow =\n | OAuthFlowPasswordSecret\n | OAuthFlowClientCredentialsSecret\n | OAuthFlowAuthorizationCodeSecret\n\n/** We filter selected scopes to only include scopes that are defined on this flow (own keys only). */\nconst selectedScopes = computed(() => {\n const definedScopes = flow.value.scopes\n if (!definedScopes) {\n return []\n }\n return selectedScopesProp.filter((scope) =>\n Object.hasOwn(definedScopes, scope),\n )\n})\n\n/**\n * Show the client secret whenever the flow supports one. PKCE and a client\n * secret are independent, so confidential clients can use both together\n * (see RFC 9700 Section 2.1.1).\n */\nconst showClientSecret = computed(\n () => 'x-scalar-secret-client-secret' in flow.value,\n)\n\nconst clientSecretValue = computed((): string => {\n const f = flow.value as { 'x-scalar-secret-client-secret'?: string }\n return f['x-scalar-secret-client-secret'] ?? ''\n})\n\n/** Updates the security scheme base */\nconst handleOauth2Update = (\n payload: Partial<OAuthFlow & XScalarCredentialsLocation>,\n): void => {\n // OpenIdConnect uses the secrets update for all\n if (scheme.type === 'openIdConnect') {\n return handleOauth2SecretsUpdate(payload)\n }\n\n // Only OAuth2 schemes carry flows on the document; this component is never\n // rendered for the other scheme types.\n if (scheme.type !== 'oauth2') {\n return\n }\n\n eventBus.emit('auth:update:security-scheme', {\n payload: {\n type: scheme.type,\n flows: {\n [type]: payload,\n },\n },\n name,\n })\n}\n\n/** Updates the flow secrets */\nconst handleOauth2SecretsUpdate = (\n payload: Omit<Partial<SecretsOAuthFlows[keyof SecretsOAuthFlows]>, 'type'>,\n): void => {\n // This component only renders for oauth2/openIdConnect. Other scheme types (e.g. mutualTLS)\n // carry no flow secrets, so there is nothing to persist and no matching secrets payload type.\n if (scheme.type !== 'oauth2' && scheme.type !== 'openIdConnect') {\n return\n }\n\n eventBus.emit('auth:update:security-scheme-secrets', {\n payload: {\n type: scheme.type,\n [type]: payload,\n },\n name,\n })\n}\n\n/** Clears the flow secrets */\nconst clearOauth2Secrets = (): void => {\n if (loader.isLoading) {\n return\n }\n eventBus.emit('auth:clear:security-scheme-secrets', {\n name,\n })\n}\n\n/** Clears stored access and refresh tokens (authorized state) */\nconst handleClearAccessTokens = (): void => {\n if (loader.isLoading) {\n return\n }\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-token': '',\n 'x-scalar-secret-refresh-token': '',\n })\n}\n\n/** Track redirect URI prefill per flow instance to support document switching */\nconst prefilledFlowIdentity = ref<string | null>(null)\nconst hasHandledRedirectPrefill = ref(false)\n\nconst resolveFlowIdentity = (\n currentFlow: OAuthFlowsObjectSecret[keyof OAuthFlowsObjectSecret] | undefined,\n): string =>\n JSON.stringify({\n type,\n authorizationUrl:\n currentFlow && 'authorizationUrl' in currentFlow\n ? currentFlow.authorizationUrl\n : '',\n tokenUrl:\n currentFlow && 'tokenUrl' in currentFlow ? currentFlow.tokenUrl : '',\n refreshUrl: currentFlow?.refreshUrl ?? '',\n scopes: Object.keys(currentFlow?.scopes ?? {}),\n })\n\n/** Default the redirect-uri to the current origin if we have access to window */\nwatch(\n () => flow.value,\n (currentFlow) => {\n if (!currentFlow || !('x-scalar-secret-redirect-uri' in currentFlow)) {\n return\n }\n\n const flowIdentity = resolveFlowIdentity(currentFlow)\n if (prefilledFlowIdentity.value !== flowIdentity) {\n prefilledFlowIdentity.value = flowIdentity\n hasHandledRedirectPrefill.value = false\n }\n\n if (hasHandledRedirectPrefill.value) {\n return\n }\n\n const newRedirectUri = (currentFlow as OAuthFlowAuthorizationCodeSecret)[\n 'x-scalar-secret-redirect-uri'\n ]\n const defaultRedirectUri = resolveDefaultOAuth2RedirectUri(options)\n\n hasHandledRedirectPrefill.value = true\n\n // The desktop loopback path computes the redirect URI at authorize time (an\n // ephemeral 127.0.0.1 port), so persisting a default into the document would\n // only bake in a stale, unused value. Leave it empty and show a hint instead.\n if (\n newRedirectUri ||\n !defaultRedirectUri ||\n options.captureOAuth2Callback\n ) {\n return\n }\n\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-redirect-uri': defaultRedirectUri,\n })\n },\n { immediate: true },\n)\n\n/**\n * Authorizes the user using the specified OAuth flow.\n * Opens the appropriate OAuth dialog and/or performs the token exchange.\n */\nconst handleAuthorize = async (): Promise<void> => {\n if (loader.isLoading) {\n return\n }\n\n loader.start()\n\n const [error, tokens] = await authorizeOauth2(\n flows,\n type,\n selectedScopes.value,\n server,\n proxyUrl,\n getEnvironmentVariables(environment),\n options.customFetch,\n options.captureOAuth2Callback,\n )\n\n await loader.clear()\n\n if (tokens?.accessToken) {\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-token': tokens.accessToken,\n ...(tokens.refreshToken\n ? { 'x-scalar-secret-refresh-token': tokens.refreshToken }\n : {}),\n })\n } else {\n console.error(error)\n toast(error?.message ?? 'Failed to authorize', 'error')\n }\n}\n\n/** Whether the current flow supports refreshing the access token */\nconst supportsRefreshToken = computed(() => type !== 'implicit')\n\n/**\n * Refresh URL placeholder, shows tokenUrl as hint if refreshUrl is not specified.\n * This helps users understand that tokenUrl will be used as fallback.\n */\nconst refreshUrlPlaceholder = computed(() => {\n if ('tokenUrl' in flow.value && flow.value.tokenUrl) {\n return flow.value.tokenUrl\n }\n return 'https://galaxy.scalar.com/oauth/refresh'\n})\n\n/**\n * Uses the stored refresh token to obtain a new access token\n * via grant_type=refresh_token.\n */\nconst handleRefresh = async (): Promise<void> => {\n if (loader.isLoading || type === 'implicit') {\n return\n }\n\n loader.start()\n\n const [error, tokens] = await refreshOauth2Token(\n flows,\n type,\n proxyUrl,\n server,\n getEnvironmentVariables(environment),\n options.customFetch,\n )\n\n await loader.clear()\n\n if (tokens?.accessToken) {\n handleOauth2SecretsUpdate({\n 'x-scalar-secret-token': tokens.accessToken,\n ...(tokens.refreshToken\n ? { 'x-scalar-secret-refresh-token': tokens.refreshToken }\n : {}),\n })\n } else {\n console.error(error)\n toast(error?.message ?? 'Failed to refresh token', 'error')\n }\n}\n\n/** Updates the secret location */\nconst handleSecretLocationUpdate = (value: string): void => {\n const credentialsLocation = value === 'body' ? 'body' : 'header'\n\n if (scheme.type !== 'openIdConnect') {\n handleOauth2Update({\n 'x-scalar-credentials-location': credentialsLocation,\n })\n }\n\n handleOauth2SecretsUpdate({\n 'x-scalar-credentials-location': credentialsLocation,\n })\n}\n</script>\n\n<template>\n <!-- Access Token Display: Shows when user is already authorized -->\n <template v-if=\"Boolean(flow['x-scalar-secret-token'])\">\n <DataTableRow>\n <RequestAuthDataTableInput\n class=\"border-r-transparent\"\n :environment\n :modelValue=\"flow['x-scalar-secret-token']\"\n placeholder=\"QUxMIFlPVVIgQkFTRSBBUkUgQkVMT05HIFRPIFVT\"\n type=\"password\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-token': v })\n \">\n Access Token\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"supportsRefreshToken\">\n <RequestAuthDataTableInput\n class=\"border-r-transparent\"\n :environment\n :modelValue=\"flow.refreshUrl ?? ''\"\n :placeholder=\"refreshUrlPlaceholder\"\n @update:modelValue=\"(v) => handleOauth2Update({ refreshUrl: v })\">\n Refresh URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow\n v-if=\"!hideActions\"\n class=\"min-w-full\">\n <div class=\"flex h-8 items-center justify-end gap-2 border-t\">\n <ScalarButton\n v-if=\"supportsRefreshToken\"\n class=\"p-0 px-2 py-0.5\"\n :loader\n size=\"sm\"\n variant=\"outlined\"\n @click=\"handleRefresh\">\n Refresh\n </ScalarButton>\n <ScalarButton\n class=\"mr-1 p-0 px-2 py-0.5\"\n :disabled=\"loader.isLoading\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"handleClearAccessTokens\">\n Clear\n </ScalarButton>\n </div>\n </DataTableRow>\n </template>\n\n <!-- Authorization Form: Shows when user needs to authorize -->\n <template v-else>\n <DataTableRow>\n <RequestAuthDataTableInput\n v-if=\"'authorizationUrl' in flow\"\n containerClass=\"border-r-0\"\n :environment\n :modelValue=\"flow['x-scalar-secret-auth-url'] ?? ''\"\n placeholder=\"https://galaxy.scalar.com/authorize\"\n @update:modelValue=\"\n (v) => {\n handleOauth2SecretsUpdate({ 'x-scalar-secret-auth-url': v })\n handleOauth2Update({ authorizationUrl: v })\n }\n \">\n Auth URL\n </RequestAuthDataTableInput>\n\n <RequestAuthDataTableInput\n v-if=\"'tokenUrl' in flow\"\n :environment\n :modelValue=\"flow['x-scalar-secret-token-url'] ?? ''\"\n placeholder=\"https://galaxy.scalar.com/token\"\n @update:modelValue=\"\n (v) => {\n handleOauth2SecretsUpdate({ 'x-scalar-secret-token-url': v })\n handleOauth2Update({ tokenUrl: v })\n }\n \">\n Token URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"'x-scalar-secret-redirect-uri' in flow\">\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"flow['x-scalar-secret-redirect-uri']\"\n :placeholder=\"\n options.captureOAuth2Callback\n ? `${resolveDefaultOAuth2RedirectUri(options) || 'http://127.0.0.1'} (handled automatically)`\n : 'Optional redirect URL'\n \"\n @update:modelValue=\"\n (v) => {\n hasHandledRedirectPrefill = true\n handleOauth2SecretsUpdate({ 'x-scalar-secret-redirect-uri': v })\n }\n \">\n Redirect URL\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <template\n v-if=\"\n 'x-scalar-secret-username' in flow && 'x-scalar-secret-password' in flow\n \">\n <DataTableRow>\n <RequestAuthDataTableInput\n class=\"text-c-2\"\n :environment\n :modelValue=\"flow['x-scalar-secret-username']\"\n placeholder=\"janedoe\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-username': v })\n \">\n Username\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow>\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"flow['x-scalar-secret-password']\"\n placeholder=\"********\"\n type=\"password\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-password': v })\n \">\n Password\n </RequestAuthDataTableInput>\n </DataTableRow>\n </template>\n\n <DataTableRow>\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"flow['x-scalar-secret-client-id']\"\n placeholder=\"12345\"\n @update:modelValue=\"\n (v) => handleOauth2SecretsUpdate({ 'x-scalar-secret-client-id': v })\n \">\n Client ID\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"showClientSecret\">\n <RequestAuthDataTableInput\n :environment\n :modelValue=\"clientSecretValue\"\n placeholder=\"XYZ123\"\n type=\"password\"\n @update:modelValue=\"\n (v) =>\n handleOauth2SecretsUpdate({ 'x-scalar-secret-client-secret': v })\n \">\n Client Secret\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <DataTableRow v-if=\"'x-usePkce' in flow\">\n <RequestAuthDataTableInput\n :enum=\"pkceOptions\"\n :environment\n :modelValue=\"flow['x-usePkce']\"\n readOnly\n @update:modelValue=\"\n (v) =>\n handleOauth2Update({\n 'x-usePkce': v as XusePkce['x-usePkce'],\n })\n \">\n Use PKCE\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <!-- Credentials Location -->\n <DataTableRow v-if=\"type !== 'implicit'\">\n <RequestAuthDataTableInput\n :enum=\"['header', 'body']\"\n :environment\n :modelValue=\"\n (flow as NonImplicitFlow)['x-scalar-credentials-location'] || 'header'\n \"\n placeholder=\"header\"\n readOnly\n @update:modelValue=\"(v) => handleSecretLocationUpdate(v)\">\n Credentials Location\n </RequestAuthDataTableInput>\n </DataTableRow>\n\n <!-- Scopes -->\n <DataTableRow>\n <OAuthScopesInput\n :flow\n :flowType=\"type\"\n :selectedScopes\n @update:selectedScopes=\"(v) => emits('update:selectedScopes', v)\"\n @upsert:scope=\"(v) => emits('upsert:scope', v)\"\n @delete:scope=\"(v) => emits('delete:scope', v)\" />\n </DataTableRow>\n\n <DataTableRow\n v-if=\"!hideActions\"\n class=\"min-w-full\">\n <div class=\"flex h-8 w-full items-center justify-end border-t\">\n <!-- Allow clearing the oauth section and going back to discovery -->\n <ScalarButton\n v-if=\"scheme.type === 'openIdConnect'\"\n class=\"mr-1 p-0 px-2 py-0.5\"\n :disabled=\"loader.isLoading\"\n size=\"sm\"\n variant=\"outlined\"\n @click=\"clearOauth2Secrets\">\n Clear\n </ScalarButton>\n\n <ScalarButton\n class=\"mr-0.75 p-0 px-2 py-0.5\"\n :loader\n size=\"sm\"\n variant=\"outlined\"\n @click=\"handleAuthorize\">\n Authorize\n </ScalarButton>\n </div>\n </DataTableRow>\n </template>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4FA,MAAM,QAAQ;EAed,MAAM,SAAS,gBAAgB;EAC/B,MAAM,EAAE,UAAU,UAAU;;EAG5B,MAAM,OAAO,eAAe,QAAA,MAAM,QAAA,KAAM;EAOxC,MAAM,iBAAiB,eAAe;GACpC,MAAM,gBAAgB,KAAK,MAAM;GACjC,IAAI,CAAC,eACH,OAAO,CAAC;GAEV,OAAO,QAAA,eAAmB,QAAQ,UAChC,OAAO,OAAO,eAAe,KAAK,CACpC;EACF,CAAC;;;;;;EAOD,MAAM,mBAAmB,eACjB,mCAAmC,KAAK,KAChD;EAEA,MAAM,oBAAoB,eAAuB;GAE/C,OADU,KAAK,MACN,oCAAoC;EAC/C,CAAC;;EAGD,MAAM,sBACJ,YACS;GAET,IAAI,QAAA,OAAO,SAAS,iBAClB,OAAO,0BAA0B,OAAO;GAK1C,IAAI,QAAA,OAAO,SAAS,UAClB;GAGF,QAAA,SAAS,KAAK,+BAA+B;IAC3C,SAAS;KACP,MAAM,QAAA,OAAO;KACb,OAAO,GACJ,QAAA,OAAO,QACV;IACF;IACA,MAAG,QAAA;GACL,CAAC;EACH;;EAGA,MAAM,6BACJ,YACS;GAGT,IAAI,QAAA,OAAO,SAAS,YAAY,QAAA,OAAO,SAAS,iBAC9C;GAGF,QAAA,SAAS,KAAK,uCAAuC;IACnD,SAAS;KACP,MAAM,QAAA,OAAO;MACZ,QAAA,OAAO;IACV;IACA,MAAG,QAAA;GACL,CAAC;EACH;;EAGA,MAAM,2BAAiC;GACrC,IAAI,OAAO,WACT;GAEF,QAAA,SAAS,KAAK,sC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,MAAA,CAAA,gBAF8B,WAE9B,EAAA,CAAA,EAAA,CAAA;;0DAEA,YAOe,MAAA,YAAA,GAAA;MANb,OAAM;MACL,QAAA,MAAA,MAAA;MACD,MAAK;MACL,SAAQ;MACP,SAAO;;6BAEV,CAAA,GAAA,OAAA,QAAA,OAAA,MAAA,CAAA,gBAF2B,eAE3B,EAAA,CAAA,EAAA,CAAA"}
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
import type { OAuthFlow, OAuthFlowsObject } from '@scalar/workspace-store/schemas/v3.
|
|
1
|
+
import type { OAuthFlow, OAuthFlowsObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
flowType: keyof OAuthFlowsObject;
|
|
4
4
|
flow: OAuthFlow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuthScopesInput.vue.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { useModal } from '@scalar/components/modal'\nimport { ScalarSearchInput } from '@scalar/components/search-input'\nimport { ScalarIconPencilSimple, ScalarIconTrash } from '@scalar/icons'\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport type {\n OAuthFlow,\n OAuthFlowsObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed, nextTick, ref, watch } from 'vue'\n\nimport {\n DataTableCell,\n DataTableCheckbox,\n DataTableRow,\n} from '@/v2/components/data-table'\n\nimport OAuthScopesAddModal from './OAuthScopesAddModal.vue'\n\nconst { selectedScopes, flow, flowType } = defineProps<{\n flowType: keyof OAuthFlowsObject\n flow: OAuthFlow\n selectedScopes: string[]\n}>()\n\nconst emits = defineEmits<{\n (\n e: 'update:selectedScopes',\n payload: { scopes?: string[]; scope?: string; selected?: boolean },\n ): void\n (\n e: 'upsert:scope',\n payload: Omit<ApiReferenceEvents['auth:upsert:scopes'], 'name'>,\n ): void\n (\n e: 'delete:scope',\n payload: Omit<ApiReferenceEvents['auth:delete:scopes'], 'name'>,\n ): void\n}>()\n\nconst searchQuery = ref('')\n\n/**\n * The scope currently being edited, used to switch the shared modal into edit mode.\n * Null means the modal is in \"add\" mode.\n */\nconst editingScope = ref<{ name: string; description: string } | null>(null)\n\n/** List of all available scopes */\nconst scopes = computed(() =>\n Object.entries(flow?.scopes ?? {}).map(([key, val]) => ({\n id: key,\n label: key,\n description: val,\n })),\n)\n\nconst scopeCount = computed(() => Object.keys(flow?.scopes ?? {}).length)\n\n/** Search is only useful once the list is long enough to scan */\nconst showScopeSearch = computed(() => scopeCount.value >= 10)\n\nconst filteredScopes = computed(() => {\n const query = showScopeSearch.value ? searchQuery.value : ''\n if (!query) {\n return scopes.value\n }\n\n const regex = new RegExp(\n query\n .split('')\n .map((c) => c.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('.*'),\n 'i',\n )\n\n return scopes.value.filter(({ label, description }) =>\n regex.test(`${label} ${description}`),\n )\n})\n\nconst hasScopes = computed(() => Object.keys(flow?.scopes ?? {}).length > 0)\n\nconst allScopesSelected = computed(\n () => selectedScopes.length === Object.keys(flow?.scopes ?? {}).length,\n)\n\nconst setScope = (scopeKey: string, checked: boolean) => {\n // Emit a single-scope toggle rather than a freshly computed list. The store applies it\n // against the currently selected scopes, so two quick clicks cannot overwrite each other\n // with a list computed from a prop that has not updated yet.\n emits('update:selectedScopes', { scope: scopeKey, selected: checked })\n}\n\n/** Select all scopes */\nconst selectAllScopes = () =>\n emits('update:selectedScopes', { scopes: Object.keys(flow?.scopes ?? {}) })\n\n/** Deselect all scopes */\nconst deselectAllScopes = () => emits('update:selectedScopes', { scopes: [] })\n\nconst scopeFormModal = useModal()\n\n/**\n * Forces the Disclosure to remount with `defaultOpen` set so the panel auto-expands\n * the moment a brand-new scope is added. Bumping this counter is paired with toggling\n * `expandOnNextMount` so the remount opens the panel, then reverts to the default\n * closed-on-mount behavior for any future unrelated remounts (e.g. collapse on empty).\n *\n * The Disclosure `:key` is only this counter — not a separate `hasScopes` segment — so\n * adding the first scope does not remount twice (empty prefix → with-scopes prefix),\n * which would reopen with `defaultOpen=false` and collapse the panel right when rows appear.\n */\nconst remountKey = ref(0)\nconst expandOnNextMount = ref(false)\n\nwatch(hasScopes, (has, had) => {\n if (had && !has) {\n expandOnNextMount.value = false\n remountKey.value += 1\n }\n})\n\n/** Open the modal in \"add new scope\" mode */\nconst openAddScopeModal = () => {\n editingScope.value = null\n scopeFormModal.show()\n}\n\n/** Open the modal in \"edit scope\" mode prefilled with the chosen row */\nconst openEditScopeModal = (scope: { id: string; description: string }) => {\n editingScope.value = {\n name: scope.id,\n description: scope.description ?? '',\n }\n scopeFormModal.show()\n}\n\n/**\n * Submit handler shared by Add Scope and Edit Scope. For renames, the `upsertScope` mutator on\n * the workspace store rewrites the selection state in place, so the component does not need to\n * emit a follow-up `update:selectedScopes`.\n *\n * When adding a brand-new scope (no `oldName`), the payload sets `enable: true` so the\n * `upsertScope` mutator also adds the new scope to any selection requirement that references\n * this scheme. The Disclosure is then remounted with `defaultOpen=true` so the user\n * immediately sees (and sees selected) the scope they just added.\n */\nconst handleScopeFormSubmit = async (payload: {\n name: string\n description: string\n oldName?: string\n}) => {\n const isAdd = !payload.oldName\n\n emits('upsert:scope', {\n scope: payload.name,\n description: payload.description,\n flowType,\n ...(payload.oldName ? { oldScope: payload.oldName } : {}),\n ...(isAdd ? { enable: true } : {}),\n })\n\n if (!isAdd) {\n return\n }\n\n expandOnNextMount.value = true\n remountKey.value += 1\n // Reset after the remount so subsequent unrelated remounts (e.g. when the last\n // scope is deleted) still default to a closed panel.\n await nextTick()\n expandOnNextMount.value = false\n}\n\n/**\n * Remove the scope from the flow. Selection cleanup (dropping the deleted key from any\n * currently-selected scopes) is handled by the `deleteScope` mutator on the workspace store,\n * so the component does not need to emit a follow-up `update:selectedScopes` here.\n */\nconst handleDeleteScope = (scopeKey: string) => {\n emits('delete:scope', { scope: scopeKey, flowType })\n}\n</script>\n\n<template>\n <DataTableCell class=\"h-auto !max-h-[initial] min-h-8 items-center\">\n <div class=\"flex h-fit w-full\">\n <div class=\"text-c-1 h-full items-center\"></div>\n <Disclosure\n :key=\"remountKey\"\n as=\"div\"\n class=\"bl flex w-full flex-col\"\n :defaultOpen=\"expandOnNextMount\">\n <!--\n Keep Add Scope (and other actions) outside the summary DisclosureButton.\n When there are no scopes the summary control is disabled; a native disabled\n button blocks pointer events for all descendants, which would make Add Scope unusable.\n -->\n <div\n class=\"group/scopes-accordion flex h-auto min-h-8 items-center gap-1.5 pr-2.25 pl-3 text-left\">\n <DisclosureButton\n :class=\"[\n 'min-w-0 flex-1 text-left',\n hasScopes ? 'hover:text-c-1 cursor-pointer' : 'cursor-default',\n (selectedScopes.length || 0) > 0 ? 'text-c-1' : 'text-c-3',\n ]\"\n :disabled=\"!hasScopes\">\n <template v-if=\"hasScopes\">\n Scopes Selected\n {{ selectedScopes.length || 0 }} /\n {{ Object.keys(flow?.scopes ?? {}).length || 0 }}\n </template>\n <template v-else> No Scopes Defined </template>\n </DisclosureButton>\n\n <div class=\"flex shrink-0 items-center gap-1.75\">\n <!-- Add new scope -->\n <ScalarButton\n class=\"pr-0.75 pl-1 transition-none\"\n size=\"sm\"\n variant=\"ghost\"\n @click.stop=\"openAddScopeModal\">\n Add Scope\n </ScalarButton>\n\n <!-- Deselect All -->\n <ScalarButton\n v-if=\"hasScopes && allScopesSelected\"\n class=\"pr-0.75 pl-1 transition-none\"\n size=\"sm\"\n variant=\"ghost\"\n @click.stop=\"deselectAllScopes\">\n Deselect All\n </ScalarButton>\n\n <!-- Select All -->\n <ScalarButton\n v-if=\"hasScopes && !allScopesSelected\"\n class=\"pr-0.75 pl-1 transition-none\"\n size=\"sm\"\n variant=\"ghost\"\n @click.stop=\"selectAllScopes\">\n Select All\n </ScalarButton>\n\n <DisclosureButton\n v-if=\"hasScopes\"\n v-slot=\"{ open }\"\n class=\"text-c-3 hover:text-c-2 -m-0.5 flex shrink-0 items-center justify-center rounded p-0.5 focus-visible:outline-offset-2\">\n <ScalarIcon\n class=\"group-hover/scopes-accordion:text-c-2\"\n :icon=\"open ? 'ChevronDown' : 'ChevronRight'\"\n size=\"md\" />\n </DisclosureButton>\n </div>\n </div>\n <!-- Scopes List -->\n <DisclosurePanel as=\"template\">\n <div>\n <ScalarSearchInput\n v-if=\"showScopeSearch\"\n v-model=\"searchQuery\"\n class=\"flex items-center text-xs\" />\n <table\n class=\"grid max-h-40 auto-rows-auto overflow-x-hidden overflow-y-auto\"\n :style=\"{ gridTemplateColumns: '1fr auto' }\">\n <DataTableRow\n v-for=\"{ id, label, description } in filteredScopes\"\n :key=\"id\"\n class=\"text-c-2 group/scope-row\"\n @click=\"setScope(id, !selectedScopes.includes(id))\">\n <DataTableCell\n class=\"box-border flex !max-h-[initial] w-full min-w-0 cursor-pointer items-stretch overflow-hidden px-0 py-0\">\n <!-- Text scrolls horizontally; action rail stays fixed -->\n <div\n class=\"no-scrollbar text-c-2 group-hover/scope-row:text-c-1 flex min-h-8 min-w-0 flex-1 items-center gap-1 overflow-x-auto px-3 py-1.5 pr-20 text-xs text-nowrap\">\n <span class=\"font-code shrink-0 text-xs\">{{ label }}</span>\n <template v-if=\"String(description ?? '').trim()\">\n <span class=\"shrink-0\">–</span>\n <span class=\"whitespace-nowrap\">{{ description }}</span>\n </template>\n </div>\n <div\n class=\"oauth-scope-row-action-rail absolute top-0 right-0 z-[1] flex h-full min-w-[4.5rem] items-center justify-end gap-0.5 py-1 pr-2 pl-4 opacity-0 transition-opacity group-focus-within/scope-row:opacity-100 group-hover/scope-row:opacity-100\"\n @click.stop>\n <ScalarIconButton\n :icon=\"ScalarIconPencilSimple\"\n :label=\"`Edit ${label}`\"\n size=\"sm\"\n @click.stop=\"\n openEditScopeModal({\n id,\n description: description ?? '',\n })\n \" />\n <ScalarIconButton\n :icon=\"ScalarIconTrash\"\n :label=\"`Delete ${label}`\"\n size=\"sm\"\n @click.stop=\"handleDeleteScope(id)\" />\n </div>\n </DataTableCell>\n <!--\n Stop the click here so it does not also bubble to the row's `@click`\n toggle. The checkbox already drives the change via `@update:modelValue`;\n letting the row fire too would toggle the scope a second time.\n -->\n <DataTableCheckbox\n :ariaLabel=\"`Select ${label} scope`\"\n :modelValue=\"selectedScopes.includes(id)\"\n @click.stop\n @update:modelValue=\"setScope(id, $event)\" />\n </DataTableRow>\n </table>\n </div>\n </DisclosurePanel>\n </Disclosure>\n </div>\n\n <!-- Shared add/edit scope modal -->\n <OAuthScopesAddModal\n :scope=\"editingScope\"\n :scopes=\"Object.keys(flow.scopes ?? {})\"\n :state=\"scopeFormModal\"\n @submit=\"handleScopeFormSubmit\" />\n </DataTableCell>\n</template>\n\n<style>\n/* Matches AddressBar.vue `.address-bar-bg-states` / `.fade-right` (header URL input). */\n.oauth-scope-row-action-rail {\n --oauth-scope-row-rail-bg: color-mix(\n in srgb,\n var(--scalar-background-1),\n var(--scalar-background-2)\n );\n background: linear-gradient(\n 90deg,\n color-mix(in srgb, var(--oauth-scope-row-rail-bg), transparent 100%) 0%,\n color-mix(in srgb, var(--oauth-scope-row-rail-bg), transparent 20%) 30%,\n var(--oauth-scope-row-rail-bg) 100%\n );\n}\n\n.no-scrollbar::-webkit-scrollbar {\n display: none;\n}\n\n.no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n}\n</style>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"OAuthScopesInput.vue.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { useModal } from '@scalar/components/modal'\nimport { ScalarSearchInput } from '@scalar/components/search-input'\nimport { ScalarIconPencilSimple, ScalarIconTrash } from '@scalar/icons'\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport type {\n OAuthFlow,\n OAuthFlowsObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed, nextTick, ref, watch } from 'vue'\n\nimport {\n DataTableCell,\n DataTableCheckbox,\n DataTableRow,\n} from '@/v2/components/data-table'\n\nimport OAuthScopesAddModal from './OAuthScopesAddModal.vue'\n\nconst { selectedScopes, flow, flowType } = defineProps<{\n flowType: keyof OAuthFlowsObject\n flow: OAuthFlow\n selectedScopes: string[]\n}>()\n\nconst emits = defineEmits<{\n (\n e: 'update:selectedScopes',\n payload: { scopes?: string[]; scope?: string; selected?: boolean },\n ): void\n (\n e: 'upsert:scope',\n payload: Omit<ApiReferenceEvents['auth:upsert:scopes'], 'name'>,\n ): void\n (\n e: 'delete:scope',\n payload: Omit<ApiReferenceEvents['auth:delete:scopes'], 'name'>,\n ): void\n}>()\n\nconst searchQuery = ref('')\n\n/**\n * The scope currently being edited, used to switch the shared modal into edit mode.\n * Null means the modal is in \"add\" mode.\n */\nconst editingScope = ref<{ name: string; description: string } | null>(null)\n\n/** List of all available scopes */\nconst scopes = computed(() =>\n Object.entries(flow?.scopes ?? {}).map(([key, val]) => ({\n id: key,\n label: key,\n description: val,\n })),\n)\n\nconst scopeCount = computed(() => Object.keys(flow?.scopes ?? {}).length)\n\n/** Search is only useful once the list is long enough to scan */\nconst showScopeSearch = computed(() => scopeCount.value >= 10)\n\nconst filteredScopes = computed(() => {\n const query = showScopeSearch.value ? searchQuery.value : ''\n if (!query) {\n return scopes.value\n }\n\n const regex = new RegExp(\n query\n .split('')\n .map((c) => c.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('.*'),\n 'i',\n )\n\n return scopes.value.filter(({ label, description }) =>\n regex.test(`${label} ${description}`),\n )\n})\n\nconst hasScopes = computed(() => Object.keys(flow?.scopes ?? {}).length > 0)\n\nconst allScopesSelected = computed(\n () => selectedScopes.length === Object.keys(flow?.scopes ?? {}).length,\n)\n\nconst setScope = (scopeKey: string, checked: boolean) => {\n // Emit a single-scope toggle rather than a freshly computed list. The store applies it\n // against the currently selected scopes, so two quick clicks cannot overwrite each other\n // with a list computed from a prop that has not updated yet.\n emits('update:selectedScopes', { scope: scopeKey, selected: checked })\n}\n\n/** Select all scopes */\nconst selectAllScopes = () =>\n emits('update:selectedScopes', { scopes: Object.keys(flow?.scopes ?? {}) })\n\n/** Deselect all scopes */\nconst deselectAllScopes = () => emits('update:selectedScopes', { scopes: [] })\n\nconst scopeFormModal = useModal()\n\n/**\n * Forces the Disclosure to remount with `defaultOpen` set so the panel auto-expands\n * the moment a brand-new scope is added. Bumping this counter is paired with toggling\n * `expandOnNextMount` so the remount opens the panel, then reverts to the default\n * closed-on-mount behavior for any future unrelated remounts (e.g. collapse on empty).\n *\n * The Disclosure `:key` is only this counter — not a separate `hasScopes` segment — so\n * adding the first scope does not remount twice (empty prefix → with-scopes prefix),\n * which would reopen with `defaultOpen=false` and collapse the panel right when rows appear.\n */\nconst remountKey = ref(0)\nconst expandOnNextMount = ref(false)\n\nwatch(hasScopes, (has, had) => {\n if (had && !has) {\n expandOnNextMount.value = false\n remountKey.value += 1\n }\n})\n\n/** Open the modal in \"add new scope\" mode */\nconst openAddScopeModal = () => {\n editingScope.value = null\n scopeFormModal.show()\n}\n\n/** Open the modal in \"edit scope\" mode prefilled with the chosen row */\nconst openEditScopeModal = (scope: { id: string; description: string }) => {\n editingScope.value = {\n name: scope.id,\n description: scope.description ?? '',\n }\n scopeFormModal.show()\n}\n\n/**\n * Submit handler shared by Add Scope and Edit Scope. For renames, the `upsertScope` mutator on\n * the workspace store rewrites the selection state in place, so the component does not need to\n * emit a follow-up `update:selectedScopes`.\n *\n * When adding a brand-new scope (no `oldName`), the payload sets `enable: true` so the\n * `upsertScope` mutator also adds the new scope to any selection requirement that references\n * this scheme. The Disclosure is then remounted with `defaultOpen=true` so the user\n * immediately sees (and sees selected) the scope they just added.\n */\nconst handleScopeFormSubmit = async (payload: {\n name: string\n description: string\n oldName?: string\n}) => {\n const isAdd = !payload.oldName\n\n emits('upsert:scope', {\n scope: payload.name,\n description: payload.description,\n flowType,\n ...(payload.oldName ? { oldScope: payload.oldName } : {}),\n ...(isAdd ? { enable: true } : {}),\n })\n\n if (!isAdd) {\n return\n }\n\n expandOnNextMount.value = true\n remountKey.value += 1\n // Reset after the remount so subsequent unrelated remounts (e.g. when the last\n // scope is deleted) still default to a closed panel.\n await nextTick()\n expandOnNextMount.value = false\n}\n\n/**\n * Remove the scope from the flow. Selection cleanup (dropping the deleted key from any\n * currently-selected scopes) is handled by the `deleteScope` mutator on the workspace store,\n * so the component does not need to emit a follow-up `update:selectedScopes` here.\n */\nconst handleDeleteScope = (scopeKey: string) => {\n emits('delete:scope', { scope: scopeKey, flowType })\n}\n</script>\n\n<template>\n <DataTableCell class=\"h-auto !max-h-[initial] min-h-8 items-center\">\n <div class=\"flex h-fit w-full\">\n <div class=\"text-c-1 h-full items-center\"></div>\n <Disclosure\n :key=\"remountKey\"\n as=\"div\"\n class=\"bl flex w-full flex-col\"\n :defaultOpen=\"expandOnNextMount\">\n <!--\n Keep Add Scope (and other actions) outside the summary DisclosureButton.\n When there are no scopes the summary control is disabled; a native disabled\n button blocks pointer events for all descendants, which would make Add Scope unusable.\n -->\n <div\n class=\"group/scopes-accordion flex h-auto min-h-8 items-center gap-1.5 pr-2.25 pl-3 text-left\">\n <DisclosureButton\n :class=\"[\n 'min-w-0 flex-1 text-left',\n hasScopes ? 'hover:text-c-1 cursor-pointer' : 'cursor-default',\n (selectedScopes.length || 0) > 0 ? 'text-c-1' : 'text-c-3',\n ]\"\n :disabled=\"!hasScopes\">\n <template v-if=\"hasScopes\">\n Scopes Selected\n {{ selectedScopes.length || 0 }} /\n {{ Object.keys(flow?.scopes ?? {}).length || 0 }}\n </template>\n <template v-else> No Scopes Defined </template>\n </DisclosureButton>\n\n <div class=\"flex shrink-0 items-center gap-1.75\">\n <!-- Add new scope -->\n <ScalarButton\n class=\"pr-0.75 pl-1 transition-none\"\n size=\"sm\"\n variant=\"ghost\"\n @click.stop=\"openAddScopeModal\">\n Add Scope\n </ScalarButton>\n\n <!-- Deselect All -->\n <ScalarButton\n v-if=\"hasScopes && allScopesSelected\"\n class=\"pr-0.75 pl-1 transition-none\"\n size=\"sm\"\n variant=\"ghost\"\n @click.stop=\"deselectAllScopes\">\n Deselect All\n </ScalarButton>\n\n <!-- Select All -->\n <ScalarButton\n v-if=\"hasScopes && !allScopesSelected\"\n class=\"pr-0.75 pl-1 transition-none\"\n size=\"sm\"\n variant=\"ghost\"\n @click.stop=\"selectAllScopes\">\n Select All\n </ScalarButton>\n\n <DisclosureButton\n v-if=\"hasScopes\"\n v-slot=\"{ open }\"\n class=\"text-c-3 hover:text-c-2 -m-0.5 flex shrink-0 items-center justify-center rounded p-0.5 focus-visible:outline-offset-2\">\n <ScalarIcon\n class=\"group-hover/scopes-accordion:text-c-2\"\n :icon=\"open ? 'ChevronDown' : 'ChevronRight'\"\n size=\"md\" />\n </DisclosureButton>\n </div>\n </div>\n <!-- Scopes List -->\n <DisclosurePanel as=\"template\">\n <div>\n <ScalarSearchInput\n v-if=\"showScopeSearch\"\n v-model=\"searchQuery\"\n class=\"flex items-center text-xs\" />\n <table\n class=\"grid max-h-40 auto-rows-auto overflow-x-hidden overflow-y-auto\"\n :style=\"{ gridTemplateColumns: '1fr auto' }\">\n <DataTableRow\n v-for=\"{ id, label, description } in filteredScopes\"\n :key=\"id\"\n class=\"text-c-2 group/scope-row\"\n @click=\"setScope(id, !selectedScopes.includes(id))\">\n <DataTableCell\n class=\"box-border flex !max-h-[initial] w-full min-w-0 cursor-pointer items-stretch overflow-hidden px-0 py-0\">\n <!-- Text scrolls horizontally; action rail stays fixed -->\n <div\n class=\"no-scrollbar text-c-2 group-hover/scope-row:text-c-1 flex min-h-8 min-w-0 flex-1 items-center gap-1 overflow-x-auto px-3 py-1.5 pr-20 text-xs text-nowrap\">\n <span class=\"font-code shrink-0 text-xs\">{{ label }}</span>\n <template v-if=\"String(description ?? '').trim()\">\n <span class=\"shrink-0\">–</span>\n <span class=\"whitespace-nowrap\">{{ description }}</span>\n </template>\n </div>\n <div\n class=\"oauth-scope-row-action-rail absolute top-0 right-0 z-[1] flex h-full min-w-[4.5rem] items-center justify-end gap-0.5 py-1 pr-2 pl-4 opacity-0 transition-opacity group-focus-within/scope-row:opacity-100 group-hover/scope-row:opacity-100\"\n @click.stop>\n <ScalarIconButton\n :icon=\"ScalarIconPencilSimple\"\n :label=\"`Edit ${label}`\"\n size=\"sm\"\n @click.stop=\"\n openEditScopeModal({\n id,\n description: description ?? '',\n })\n \" />\n <ScalarIconButton\n :icon=\"ScalarIconTrash\"\n :label=\"`Delete ${label}`\"\n size=\"sm\"\n @click.stop=\"handleDeleteScope(id)\" />\n </div>\n </DataTableCell>\n <!--\n Stop the click here so it does not also bubble to the row's `@click`\n toggle. The checkbox already drives the change via `@update:modelValue`;\n letting the row fire too would toggle the scope a second time.\n -->\n <DataTableCheckbox\n :ariaLabel=\"`Select ${label} scope`\"\n :modelValue=\"selectedScopes.includes(id)\"\n @click.stop\n @update:modelValue=\"setScope(id, $event)\" />\n </DataTableRow>\n </table>\n </div>\n </DisclosurePanel>\n </Disclosure>\n </div>\n\n <!-- Shared add/edit scope modal -->\n <OAuthScopesAddModal\n :scope=\"editingScope\"\n :scopes=\"Object.keys(flow.scopes ?? {})\"\n :state=\"scopeFormModal\"\n @submit=\"handleScopeFormSubmit\" />\n </DataTableCell>\n</template>\n\n<style>\n/* Matches AddressBar.vue `.address-bar-bg-states` / `.fade-right` (header URL input). */\n.oauth-scope-row-action-rail {\n --oauth-scope-row-rail-bg: color-mix(\n in srgb,\n var(--scalar-background-1),\n var(--scalar-background-2)\n );\n background: linear-gradient(\n 90deg,\n color-mix(in srgb, var(--oauth-scope-row-rail-bg), transparent 100%) 0%,\n color-mix(in srgb, var(--oauth-scope-row-rail-bg), transparent 20%) 30%,\n var(--oauth-scope-row-rail-bg) 100%\n );\n}\n\n.no-scrollbar::-webkit-scrollbar {\n display: none;\n}\n\n.no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n}\n</style>\n"],"mappings":""}
|
package/dist/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue.script.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuthScopesInput.vue.script.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { useModal } from '@scalar/components/modal'\nimport { ScalarSearchInput } from '@scalar/components/search-input'\nimport { ScalarIconPencilSimple, ScalarIconTrash } from '@scalar/icons'\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport type {\n OAuthFlow,\n OAuthFlowsObject,\n} from '@scalar/workspace-store/schemas/v3.1/strict/openapi-document'\nimport { computed, nextTick, ref, watch } from 'vue'\n\nimport {\n DataTableCell,\n DataTableCheckbox,\n DataTableRow,\n} from '@/v2/components/data-table'\n\nimport OAuthScopesAddModal from './OAuthScopesAddModal.vue'\n\nconst { selectedScopes, flow, flowType } = defineProps<{\n flowType: keyof OAuthFlowsObject\n flow: OAuthFlow\n selectedScopes: string[]\n}>()\n\nconst emits = defineEmits<{\n (\n e: 'update:selectedScopes',\n payload: { scopes?: string[]; scope?: string; selected?: boolean },\n ): void\n (\n e: 'upsert:scope',\n payload: Omit<ApiReferenceEvents['auth:upsert:scopes'], 'name'>,\n ): void\n (\n e: 'delete:scope',\n payload: Omit<ApiReferenceEvents['auth:delete:scopes'], 'name'>,\n ): void\n}>()\n\nconst searchQuery = ref('')\n\n/**\n * The scope currently being edited, used to switch the shared modal into edit mode.\n * Null means the modal is in \"add\" mode.\n */\nconst editingScope = ref<{ name: string; description: string } | null>(null)\n\n/** List of all available scopes */\nconst scopes = computed(() =>\n Object.entries(flow?.scopes ?? {}).map(([key, val]) => ({\n id: key,\n label: key,\n description: val,\n })),\n)\n\nconst scopeCount = computed(() => Object.keys(flow?.scopes ?? {}).length)\n\n/** Search is only useful once the list is long enough to scan */\nconst showScopeSearch = computed(() => scopeCount.value >= 10)\n\nconst filteredScopes = computed(() => {\n const query = showScopeSearch.value ? searchQuery.value : ''\n if (!query) {\n return scopes.value\n }\n\n const regex = new RegExp(\n query\n .split('')\n .map((c) => c.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('.*'),\n 'i',\n )\n\n return scopes.value.filter(({ label, description }) =>\n regex.test(`${label} ${description}`),\n )\n})\n\nconst hasScopes = computed(() => Object.keys(flow?.scopes ?? {}).length > 0)\n\nconst allScopesSelected = computed(\n () => selectedScopes.length === Object.keys(flow?.scopes ?? {}).length,\n)\n\nconst setScope = (scopeKey: string, checked: boolean) => {\n // Emit a single-scope toggle rather than a freshly computed list. The store applies it\n // against the currently selected scopes, so two quick clicks cannot overwrite each other\n // with a list computed from a prop that has not updated yet.\n emits('update:selectedScopes', { scope: scopeKey, selected: checked })\n}\n\n/** Select all scopes */\nconst selectAllScopes = () =>\n emits('update:selectedScopes', { scopes: Object.keys(flow?.scopes ?? {}) })\n\n/** Deselect all scopes */\nconst deselectAllScopes = () => emits('update:selectedScopes', { scopes: [] })\n\nconst scopeFormModal = useModal()\n\n/**\n * Forces the Disclosure to remount with `defaultOpen` set so the panel auto-expands\n * the moment a brand-new scope is added. Bumping this counter is paired with toggling\n * `expandOnNextMount` so the remount opens the panel, then reverts to the default\n * closed-on-mount behavior for any future unrelated remounts (e.g. collapse on empty).\n *\n * The Disclosure `:key` is only this counter — not a separate `hasScopes` segment — so\n * adding the first scope does not remount twice (empty prefix → with-scopes prefix),\n * which would reopen with `defaultOpen=false` and collapse the panel right when rows appear.\n */\nconst remountKey = ref(0)\nconst expandOnNextMount = ref(false)\n\nwatch(hasScopes, (has, had) => {\n if (had && !has) {\n expandOnNextMount.value = false\n remountKey.value += 1\n }\n})\n\n/** Open the modal in \"add new scope\" mode */\nconst openAddScopeModal = () => {\n editingScope.value = null\n scopeFormModal.show()\n}\n\n/** Open the modal in \"edit scope\" mode prefilled with the chosen row */\nconst openEditScopeModal = (scope: { id: string; description: string }) => {\n editingScope.value = {\n name: scope.id,\n description: scope.description ?? '',\n }\n scopeFormModal.show()\n}\n\n/**\n * Submit handler shared by Add Scope and Edit Scope. For renames, the `upsertScope` mutator on\n * the workspace store rewrites the selection state in place, so the component does not need to\n * emit a follow-up `update:selectedScopes`.\n *\n * When adding a brand-new scope (no `oldName`), the payload sets `enable: true` so the\n * `upsertScope` mutator also adds the new scope to any selection requirement that references\n * this scheme. The Disclosure is then remounted with `defaultOpen=true` so the user\n * immediately sees (and sees selected) the scope they just added.\n */\nconst handleScopeFormSubmit = async (payload: {\n name: string\n description: string\n oldName?: string\n}) => {\n const isAdd = !payload.oldName\n\n emits('upsert:scope', {\n scope: payload.name,\n description: payload.description,\n flowType,\n ...(payload.oldName ? { oldScope: payload.oldName } : {}),\n ...(isAdd ? { enable: true } : {}),\n })\n\n if (!isAdd) {\n return\n }\n\n expandOnNextMount.value = true\n remountKey.value += 1\n // Reset after the remount so subsequent unrelated remounts (e.g. when the last\n // scope is deleted) still default to a closed panel.\n await nextTick()\n expandOnNextMount.value = false\n}\n\n/**\n * Remove the scope from the flow. Selection cleanup (dropping the deleted key from any\n * currently-selected scopes) is handled by the `deleteScope` mutator on the workspace store,\n * so the component does not need to emit a follow-up `update:selectedScopes` here.\n */\nconst handleDeleteScope = (scopeKey: string) => {\n emits('delete:scope', { scope: scopeKey, flowType })\n}\n</script>\n\n<template>\n <DataTableCell class=\"h-auto !max-h-[initial] min-h-8 items-center\">\n <div class=\"flex h-fit w-full\">\n <div class=\"text-c-1 h-full items-center\"></div>\n <Disclosure\n :key=\"remountKey\"\n as=\"div\"\n class=\"bl flex w-full flex-col\"\n :defaultOpen=\"expandOnNextMount\">\n <!--\n Keep Add Scope (and other actions) outside the summary DisclosureButton.\n When there are no scopes the summary control is disabled; a native disabled\n button blocks pointer events for all descendants, which would make Add Scope unusable.\n -->\n <div\n class=\"group/scopes-accordion flex h-auto min-h-8 items-center gap-1.5 pr-2.25 pl-3 text-left\">\n <DisclosureButton\n :class=\"[\n 'min-w-0 flex-1 text-left',\n hasScopes ? 'hover:text-c-1 cursor-pointer' : 'cursor-default',\n (selectedScopes.length || 0) > 0 ? 'text-c-1' : 'text-c-3',\n ]\"\n :disabled=\"!hasScopes\">\n <template v-if=\"hasScopes\">\n Scopes Selected\n {{ selectedScopes.length || 0 }} /\n {{ Object.keys(flow?.scopes ?? {}).length || 0 }}\n </template>\n <template v-else> No Scopes Defined </template>\n </DisclosureButton>\n\n <div class=\"flex shrink-0 items-center gap-1.75\">\n <!-- Add new scope -->\n <ScalarButton\n class=\"pr-0.75 pl-1 transition-none\"\n size=\"sm\"\n variant=\"ghost\"\n @click.stop=\"openAddScopeModal\">\n Add Scope\n </ScalarButton>\n\n <!-- Deselect All -->\n <ScalarButton\n v-if=\"hasScopes && allScopesSelected\"\n class=\"pr-0.75 pl-1 transition-none\"\n size=\"sm\"\n variant=\"ghost\"\n @click.stop=\"deselectAllScopes\">\n Deselect All\n </ScalarButton>\n\n <!-- Select All -->\n <ScalarButton\n v-if=\"hasScopes && !allScopesSelected\"\n class=\"pr-0.75 pl-1 transition-none\"\n size=\"sm\"\n variant=\"ghost\"\n @click.stop=\"selectAllScopes\">\n Select All\n </ScalarButton>\n\n <DisclosureButton\n v-if=\"hasScopes\"\n v-slot=\"{ open }\"\n class=\"text-c-3 hover:text-c-2 -m-0.5 flex shrink-0 items-center justify-center rounded p-0.5 focus-visible:outline-offset-2\">\n <ScalarIcon\n class=\"group-hover/scopes-accordion:text-c-2\"\n :icon=\"open ? 'ChevronDown' : 'ChevronRight'\"\n size=\"md\" />\n </DisclosureButton>\n </div>\n </div>\n <!-- Scopes List -->\n <DisclosurePanel as=\"template\">\n <div>\n <ScalarSearchInput\n v-if=\"showScopeSearch\"\n v-model=\"searchQuery\"\n class=\"flex items-center text-xs\" />\n <table\n class=\"grid max-h-40 auto-rows-auto overflow-x-hidden overflow-y-auto\"\n :style=\"{ gridTemplateColumns: '1fr auto' }\">\n <DataTableRow\n v-for=\"{ id, label, description } in filteredScopes\"\n :key=\"id\"\n class=\"text-c-2 group/scope-row\"\n @click=\"setScope(id, !selectedScopes.includes(id))\">\n <DataTableCell\n class=\"box-border flex !max-h-[initial] w-full min-w-0 cursor-pointer items-stretch overflow-hidden px-0 py-0\">\n <!-- Text scrolls horizontally; action rail stays fixed -->\n <div\n class=\"no-scrollbar text-c-2 group-hover/scope-row:text-c-1 flex min-h-8 min-w-0 flex-1 items-center gap-1 overflow-x-auto px-3 py-1.5 pr-20 text-xs text-nowrap\">\n <span class=\"font-code shrink-0 text-xs\">{{ label }}</span>\n <template v-if=\"String(description ?? '').trim()\">\n <span class=\"shrink-0\">–</span>\n <span class=\"whitespace-nowrap\">{{ description }}</span>\n </template>\n </div>\n <div\n class=\"oauth-scope-row-action-rail absolute top-0 right-0 z-[1] flex h-full min-w-[4.5rem] items-center justify-end gap-0.5 py-1 pr-2 pl-4 opacity-0 transition-opacity group-focus-within/scope-row:opacity-100 group-hover/scope-row:opacity-100\"\n @click.stop>\n <ScalarIconButton\n :icon=\"ScalarIconPencilSimple\"\n :label=\"`Edit ${label}`\"\n size=\"sm\"\n @click.stop=\"\n openEditScopeModal({\n id,\n description: description ?? '',\n })\n \" />\n <ScalarIconButton\n :icon=\"ScalarIconTrash\"\n :label=\"`Delete ${label}`\"\n size=\"sm\"\n @click.stop=\"handleDeleteScope(id)\" />\n </div>\n </DataTableCell>\n <!--\n Stop the click here so it does not also bubble to the row's `@click`\n toggle. The checkbox already drives the change via `@update:modelValue`;\n letting the row fire too would toggle the scope a second time.\n -->\n <DataTableCheckbox\n :ariaLabel=\"`Select ${label} scope`\"\n :modelValue=\"selectedScopes.includes(id)\"\n @click.stop\n @update:modelValue=\"setScope(id, $event)\" />\n </DataTableRow>\n </table>\n </div>\n </DisclosurePanel>\n </Disclosure>\n </div>\n\n <!-- Shared add/edit scope modal -->\n <OAuthScopesAddModal\n :scope=\"editingScope\"\n :scopes=\"Object.keys(flow.scopes ?? {})\"\n :state=\"scopeFormModal\"\n @submit=\"handleScopeFormSubmit\" />\n </DataTableCell>\n</template>\n\n<style>\n/* Matches AddressBar.vue `.address-bar-bg-states` / `.fade-right` (header URL input). */\n.oauth-scope-row-action-rail {\n --oauth-scope-row-rail-bg: color-mix(\n in srgb,\n var(--scalar-background-1),\n var(--scalar-background-2)\n );\n background: linear-gradient(\n 90deg,\n color-mix(in srgb, var(--oauth-scope-row-rail-bg), transparent 100%) 0%,\n color-mix(in srgb, var(--oauth-scope-row-rail-bg), transparent 20%) 30%,\n var(--oauth-scope-row-rail-bg) 100%\n );\n}\n\n.no-scrollbar::-webkit-scrollbar {\n display: none;\n}\n\n.no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BA,MAAM,QAAQ;EAed,MAAM,cAAc,IAAI,EAAE;;;;;EAM1B,MAAM,eAAe,IAAkD,IAAI;;EAG3E,MAAM,SAAS,eACb,OAAO,QAAQ,QAAA,MAAM,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,UAAU;GACtD,IAAI;GACJ,OAAO;GACP,aAAa;EACf,EAAE,CACJ;EAEA,MAAM,aAAa,eAAe,OAAO,KAAK,QAAA,MAAM,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM;;EAGxE,MAAM,kBAAkB,eAAe,WAAW,SAAS,EAAE;EAE7D,MAAM,iBAAiB,eAAe;GACpC,MAAM,QAAQ,gBAAgB,QAAQ,YAAY,QAAQ;GAC1D,IAAI,CAAC,OACH,OAAO,OAAO;GAGhB,MAAM,QAAQ,IAAI,OAChB,MACG,MAAM,EAAE,CAAA,CACR,KAAK,MAAM,EAAE,QAAQ,uBAAuB,MAAM,CAAC,CAAA,CACnD,KAAK,IAAI,GACZ,GACF;GAEA,OAAO,OAAO,MAAM,QAAQ,EAAE,OAAO,kBACnC,MAAM,KAAK,GA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J,mBAA2D,QAA3D,YAA2D,gBAAf,KAAK,GAAA,CAAA,GACjC,OAAO,eAAW,EAAA,CAAA,CAAQ,KAAI,KAAA,UAAA,GAA9C,mBAGW,UAAA,EAAA,KAAA,EAAA,GAAA,CAAA,OAAA,OAAA,OAAA,KAFT,mBAAqC,QAAA,EAA/B,OAAM,WAAU,GAAC,KAAO,EAAA,IAC9B,mBAAwD,QAAxD,YAAwD,gBAArB,WAAW,GAAA,CAAA,CAAA,GAAA,EAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA,GAGlD,mBAkBM,OAAA;UAjBJ,OAAM;UACL,SAAK,OAAA,OAAA,OAAA,KAAA,oBAAN,CAAA,GAAW,CAAA,MAAA,CAAA;aACX,YASM,MAAA,gBAAA,GAAA;UARH,MAAM,MAAA,sBAAA;UACN,OAAK,QAAU;UAChB,MAAK;UACJ,SAAK,eAAA,WAAgC,mBAAkB;WAA6B;wBAA2C,eAAW;;;;;;aAM7I,YAIwC,MAAA,gBAAA,GAAA;UAHrC,MAAM,MAAA,eAAA;UACN,OAAK,UAAY;UAClB,MAAK;UACJ,SAAK,eAAA,WAAO,kBAAkB,EAAE,GAAA,CAAA,MAAA,CAAA;;;;;;;kBAQvC,YAI8C,MAAA,yBAAA,GAAA;SAH3C,WAAS,UAAY,MAAK;SAC1B,YAAY,QAAA,eAAe,SAAS,EAAE;SACtC,SAAK,OAAA,OAAA,OAAA,KAAA,oBAAN,CAAA,GAAW,CAAA,MAAA,CAAA;SACV,wBAAiB,WAAE,SAAS,IAAI,MAAM;;;;;;;;;;;;+BASrD,YAIoC,6BAAA;KAHjC,OAAO,aAAA;KACP,QAAQ,OAAO,KAAK,QAAA,KAAK,UAAM,CAAA,CAAA;KAC/B,OAAO,MAAA,cAAA;KACP,UAAQ"}
|
|
1
|
+
{"version":3,"file":"OAuthScopesInput.vue.script.js","names":[],"sources":["../../../../../src/v2/blocks/scalar-auth-selector-block/components/OAuthScopesInput.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'\nimport { ScalarButton } from '@scalar/components/button'\nimport { ScalarIcon } from '@scalar/components/icon'\nimport { ScalarIconButton } from '@scalar/components/icon-button'\nimport { useModal } from '@scalar/components/modal'\nimport { ScalarSearchInput } from '@scalar/components/search-input'\nimport { ScalarIconPencilSimple, ScalarIconTrash } from '@scalar/icons'\nimport type { ApiReferenceEvents } from '@scalar/workspace-store/events'\nimport type {\n OAuthFlow,\n OAuthFlowsObject,\n} from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document'\nimport { computed, nextTick, ref, watch } from 'vue'\n\nimport {\n DataTableCell,\n DataTableCheckbox,\n DataTableRow,\n} from '@/v2/components/data-table'\n\nimport OAuthScopesAddModal from './OAuthScopesAddModal.vue'\n\nconst { selectedScopes, flow, flowType } = defineProps<{\n flowType: keyof OAuthFlowsObject\n flow: OAuthFlow\n selectedScopes: string[]\n}>()\n\nconst emits = defineEmits<{\n (\n e: 'update:selectedScopes',\n payload: { scopes?: string[]; scope?: string; selected?: boolean },\n ): void\n (\n e: 'upsert:scope',\n payload: Omit<ApiReferenceEvents['auth:upsert:scopes'], 'name'>,\n ): void\n (\n e: 'delete:scope',\n payload: Omit<ApiReferenceEvents['auth:delete:scopes'], 'name'>,\n ): void\n}>()\n\nconst searchQuery = ref('')\n\n/**\n * The scope currently being edited, used to switch the shared modal into edit mode.\n * Null means the modal is in \"add\" mode.\n */\nconst editingScope = ref<{ name: string; description: string } | null>(null)\n\n/** List of all available scopes */\nconst scopes = computed(() =>\n Object.entries(flow?.scopes ?? {}).map(([key, val]) => ({\n id: key,\n label: key,\n description: val,\n })),\n)\n\nconst scopeCount = computed(() => Object.keys(flow?.scopes ?? {}).length)\n\n/** Search is only useful once the list is long enough to scan */\nconst showScopeSearch = computed(() => scopeCount.value >= 10)\n\nconst filteredScopes = computed(() => {\n const query = showScopeSearch.value ? searchQuery.value : ''\n if (!query) {\n return scopes.value\n }\n\n const regex = new RegExp(\n query\n .split('')\n .map((c) => c.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('.*'),\n 'i',\n )\n\n return scopes.value.filter(({ label, description }) =>\n regex.test(`${label} ${description}`),\n )\n})\n\nconst hasScopes = computed(() => Object.keys(flow?.scopes ?? {}).length > 0)\n\nconst allScopesSelected = computed(\n () => selectedScopes.length === Object.keys(flow?.scopes ?? {}).length,\n)\n\nconst setScope = (scopeKey: string, checked: boolean) => {\n // Emit a single-scope toggle rather than a freshly computed list. The store applies it\n // against the currently selected scopes, so two quick clicks cannot overwrite each other\n // with a list computed from a prop that has not updated yet.\n emits('update:selectedScopes', { scope: scopeKey, selected: checked })\n}\n\n/** Select all scopes */\nconst selectAllScopes = () =>\n emits('update:selectedScopes', { scopes: Object.keys(flow?.scopes ?? {}) })\n\n/** Deselect all scopes */\nconst deselectAllScopes = () => emits('update:selectedScopes', { scopes: [] })\n\nconst scopeFormModal = useModal()\n\n/**\n * Forces the Disclosure to remount with `defaultOpen` set so the panel auto-expands\n * the moment a brand-new scope is added. Bumping this counter is paired with toggling\n * `expandOnNextMount` so the remount opens the panel, then reverts to the default\n * closed-on-mount behavior for any future unrelated remounts (e.g. collapse on empty).\n *\n * The Disclosure `:key` is only this counter — not a separate `hasScopes` segment — so\n * adding the first scope does not remount twice (empty prefix → with-scopes prefix),\n * which would reopen with `defaultOpen=false` and collapse the panel right when rows appear.\n */\nconst remountKey = ref(0)\nconst expandOnNextMount = ref(false)\n\nwatch(hasScopes, (has, had) => {\n if (had && !has) {\n expandOnNextMount.value = false\n remountKey.value += 1\n }\n})\n\n/** Open the modal in \"add new scope\" mode */\nconst openAddScopeModal = () => {\n editingScope.value = null\n scopeFormModal.show()\n}\n\n/** Open the modal in \"edit scope\" mode prefilled with the chosen row */\nconst openEditScopeModal = (scope: { id: string; description: string }) => {\n editingScope.value = {\n name: scope.id,\n description: scope.description ?? '',\n }\n scopeFormModal.show()\n}\n\n/**\n * Submit handler shared by Add Scope and Edit Scope. For renames, the `upsertScope` mutator on\n * the workspace store rewrites the selection state in place, so the component does not need to\n * emit a follow-up `update:selectedScopes`.\n *\n * When adding a brand-new scope (no `oldName`), the payload sets `enable: true` so the\n * `upsertScope` mutator also adds the new scope to any selection requirement that references\n * this scheme. The Disclosure is then remounted with `defaultOpen=true` so the user\n * immediately sees (and sees selected) the scope they just added.\n */\nconst handleScopeFormSubmit = async (payload: {\n name: string\n description: string\n oldName?: string\n}) => {\n const isAdd = !payload.oldName\n\n emits('upsert:scope', {\n scope: payload.name,\n description: payload.description,\n flowType,\n ...(payload.oldName ? { oldScope: payload.oldName } : {}),\n ...(isAdd ? { enable: true } : {}),\n })\n\n if (!isAdd) {\n return\n }\n\n expandOnNextMount.value = true\n remountKey.value += 1\n // Reset after the remount so subsequent unrelated remounts (e.g. when the last\n // scope is deleted) still default to a closed panel.\n await nextTick()\n expandOnNextMount.value = false\n}\n\n/**\n * Remove the scope from the flow. Selection cleanup (dropping the deleted key from any\n * currently-selected scopes) is handled by the `deleteScope` mutator on the workspace store,\n * so the component does not need to emit a follow-up `update:selectedScopes` here.\n */\nconst handleDeleteScope = (scopeKey: string) => {\n emits('delete:scope', { scope: scopeKey, flowType })\n}\n</script>\n\n<template>\n <DataTableCell class=\"h-auto !max-h-[initial] min-h-8 items-center\">\n <div class=\"flex h-fit w-full\">\n <div class=\"text-c-1 h-full items-center\"></div>\n <Disclosure\n :key=\"remountKey\"\n as=\"div\"\n class=\"bl flex w-full flex-col\"\n :defaultOpen=\"expandOnNextMount\">\n <!--\n Keep Add Scope (and other actions) outside the summary DisclosureButton.\n When there are no scopes the summary control is disabled; a native disabled\n button blocks pointer events for all descendants, which would make Add Scope unusable.\n -->\n <div\n class=\"group/scopes-accordion flex h-auto min-h-8 items-center gap-1.5 pr-2.25 pl-3 text-left\">\n <DisclosureButton\n :class=\"[\n 'min-w-0 flex-1 text-left',\n hasScopes ? 'hover:text-c-1 cursor-pointer' : 'cursor-default',\n (selectedScopes.length || 0) > 0 ? 'text-c-1' : 'text-c-3',\n ]\"\n :disabled=\"!hasScopes\">\n <template v-if=\"hasScopes\">\n Scopes Selected\n {{ selectedScopes.length || 0 }} /\n {{ Object.keys(flow?.scopes ?? {}).length || 0 }}\n </template>\n <template v-else> No Scopes Defined </template>\n </DisclosureButton>\n\n <div class=\"flex shrink-0 items-center gap-1.75\">\n <!-- Add new scope -->\n <ScalarButton\n class=\"pr-0.75 pl-1 transition-none\"\n size=\"sm\"\n variant=\"ghost\"\n @click.stop=\"openAddScopeModal\">\n Add Scope\n </ScalarButton>\n\n <!-- Deselect All -->\n <ScalarButton\n v-if=\"hasScopes && allScopesSelected\"\n class=\"pr-0.75 pl-1 transition-none\"\n size=\"sm\"\n variant=\"ghost\"\n @click.stop=\"deselectAllScopes\">\n Deselect All\n </ScalarButton>\n\n <!-- Select All -->\n <ScalarButton\n v-if=\"hasScopes && !allScopesSelected\"\n class=\"pr-0.75 pl-1 transition-none\"\n size=\"sm\"\n variant=\"ghost\"\n @click.stop=\"selectAllScopes\">\n Select All\n </ScalarButton>\n\n <DisclosureButton\n v-if=\"hasScopes\"\n v-slot=\"{ open }\"\n class=\"text-c-3 hover:text-c-2 -m-0.5 flex shrink-0 items-center justify-center rounded p-0.5 focus-visible:outline-offset-2\">\n <ScalarIcon\n class=\"group-hover/scopes-accordion:text-c-2\"\n :icon=\"open ? 'ChevronDown' : 'ChevronRight'\"\n size=\"md\" />\n </DisclosureButton>\n </div>\n </div>\n <!-- Scopes List -->\n <DisclosurePanel as=\"template\">\n <div>\n <ScalarSearchInput\n v-if=\"showScopeSearch\"\n v-model=\"searchQuery\"\n class=\"flex items-center text-xs\" />\n <table\n class=\"grid max-h-40 auto-rows-auto overflow-x-hidden overflow-y-auto\"\n :style=\"{ gridTemplateColumns: '1fr auto' }\">\n <DataTableRow\n v-for=\"{ id, label, description } in filteredScopes\"\n :key=\"id\"\n class=\"text-c-2 group/scope-row\"\n @click=\"setScope(id, !selectedScopes.includes(id))\">\n <DataTableCell\n class=\"box-border flex !max-h-[initial] w-full min-w-0 cursor-pointer items-stretch overflow-hidden px-0 py-0\">\n <!-- Text scrolls horizontally; action rail stays fixed -->\n <div\n class=\"no-scrollbar text-c-2 group-hover/scope-row:text-c-1 flex min-h-8 min-w-0 flex-1 items-center gap-1 overflow-x-auto px-3 py-1.5 pr-20 text-xs text-nowrap\">\n <span class=\"font-code shrink-0 text-xs\">{{ label }}</span>\n <template v-if=\"String(description ?? '').trim()\">\n <span class=\"shrink-0\">–</span>\n <span class=\"whitespace-nowrap\">{{ description }}</span>\n </template>\n </div>\n <div\n class=\"oauth-scope-row-action-rail absolute top-0 right-0 z-[1] flex h-full min-w-[4.5rem] items-center justify-end gap-0.5 py-1 pr-2 pl-4 opacity-0 transition-opacity group-focus-within/scope-row:opacity-100 group-hover/scope-row:opacity-100\"\n @click.stop>\n <ScalarIconButton\n :icon=\"ScalarIconPencilSimple\"\n :label=\"`Edit ${label}`\"\n size=\"sm\"\n @click.stop=\"\n openEditScopeModal({\n id,\n description: description ?? '',\n })\n \" />\n <ScalarIconButton\n :icon=\"ScalarIconTrash\"\n :label=\"`Delete ${label}`\"\n size=\"sm\"\n @click.stop=\"handleDeleteScope(id)\" />\n </div>\n </DataTableCell>\n <!--\n Stop the click here so it does not also bubble to the row's `@click`\n toggle. The checkbox already drives the change via `@update:modelValue`;\n letting the row fire too would toggle the scope a second time.\n -->\n <DataTableCheckbox\n :ariaLabel=\"`Select ${label} scope`\"\n :modelValue=\"selectedScopes.includes(id)\"\n @click.stop\n @update:modelValue=\"setScope(id, $event)\" />\n </DataTableRow>\n </table>\n </div>\n </DisclosurePanel>\n </Disclosure>\n </div>\n\n <!-- Shared add/edit scope modal -->\n <OAuthScopesAddModal\n :scope=\"editingScope\"\n :scopes=\"Object.keys(flow.scopes ?? {})\"\n :state=\"scopeFormModal\"\n @submit=\"handleScopeFormSubmit\" />\n </DataTableCell>\n</template>\n\n<style>\n/* Matches AddressBar.vue `.address-bar-bg-states` / `.fade-right` (header URL input). */\n.oauth-scope-row-action-rail {\n --oauth-scope-row-rail-bg: color-mix(\n in srgb,\n var(--scalar-background-1),\n var(--scalar-background-2)\n );\n background: linear-gradient(\n 90deg,\n color-mix(in srgb, var(--oauth-scope-row-rail-bg), transparent 100%) 0%,\n color-mix(in srgb, var(--oauth-scope-row-rail-bg), transparent 20%) 30%,\n var(--oauth-scope-row-rail-bg) 100%\n );\n}\n\n.no-scrollbar::-webkit-scrollbar {\n display: none;\n}\n\n.no-scrollbar {\n -ms-overflow-style: none;\n scrollbar-width: none;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BA,MAAM,QAAQ;EAed,MAAM,cAAc,IAAI,EAAE;;;;;EAM1B,MAAM,eAAe,IAAkD,IAAI;;EAG3E,MAAM,SAAS,eACb,OAAO,QAAQ,QAAA,MAAM,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,UAAU;GACtD,IAAI;GACJ,OAAO;GACP,aAAa;EACf,EAAE,CACJ;EAEA,MAAM,aAAa,eAAe,OAAO,KAAK,QAAA,MAAM,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM;;EAGxE,MAAM,kBAAkB,eAAe,WAAW,SAAS,EAAE;EAE7D,MAAM,iBAAiB,eAAe;GACpC,MAAM,QAAQ,gBAAgB,QAAQ,YAAY,QAAQ;GAC1D,IAAI,CAAC,OACH,OAAO,OAAO;GAGhB,MAAM,QAAQ,IAAI,OAChB,MACG,MAAM,EAAE,CAAA,CACR,KAAK,MAAM,EAAE,QAAQ,uBAAuB,MAAM,CAAC,CAAA,CACnD,KAAK,IAAI,GACZ,GACF;GAEA,OAAO,OAAO,MAAM,QAAQ,EAAE,OAAO,kBACnC,MAAM,KAAK,GAAG,MAAM,GAAG,aAAa,CACtC;EACF,CAAC;EAED,MAAM,YAAY,eAAe,OAAO,KAAK,QAAA,MAAM,UAAU,CAAC,CAAC,CAAC,CAAC,SAA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W,UAAA,EAAA,KAAA,EAAA,GAAA,CAAA,OAAA,OAAA,OAAA,KAFT,mBAAqC,QAAA,EAA/B,OAAM,WAAU,GAAC,KAAO,EAAA,IAC9B,mBAAwD,QAAxD,YAAwD,gBAArB,WAAW,GAAA,CAAA,CAAA,GAAA,EAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA,GAGlD,mBAkBM,OAAA;UAjBJ,OAAM;UACL,SAAK,OAAA,OAAA,OAAA,KAAA,oBAAN,CAAA,GAAW,CAAA,MAAA,CAAA;aACX,YASM,MAAA,gBAAA,GAAA;UARH,MAAM,MAAA,sBAAA;UACN,OAAK,QAAU;UAChB,MAAK;UACJ,SAAK,eAAA,WAAgC,mBAAkB;WAA6B;wBAA2C,eAAW;;;;;;aAM7I,YAIwC,MAAA,gBAAA,GAAA;UAHrC,MAAM,MAAA,eAAA;UACN,OAAK,UAAY;UAClB,MAAK;UACJ,SAAK,eAAA,WAAO,kBAAkB,EAAE,GAAA,CAAA,MAAA,CAAA;;;;;;;kBAQvC,YAI8C,MAAA,yBAAA,GAAA;SAH3C,WAAS,UAAY,MAAK;SAC1B,YAAY,QAAA,eAAe,SAAS,EAAE;SACtC,SAAK,OAAA,OAAA,OAAA,KAAA,oBAAN,CAAA,GAAW,CAAA,MAAA,CAAA;SACV,wBAAiB,WAAE,SAAS,IAAI,MAAM;;;;;;;;;;;;+BASrD,YAIoC,6BAAA;KAHjC,OAAO,aAAA;KACP,QAAQ,OAAO,KAAK,QAAA,KAAK,UAAM,CAAA,CAAA;KAC/B,OAAO,MAAA,cAAA;KACP,UAAQ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WorkspaceEventBus } from '@scalar/workspace-store/events';
|
|
2
2
|
import type { XScalarEnvironment } from '@scalar/workspace-store/schemas/extensions/document/x-scalar-environments';
|
|
3
|
-
import { type OpenIdConnectObject } from '@scalar/workspace-store/schemas/v3.
|
|
3
|
+
import { type OpenIdConnectObject } from '@scalar/workspace-store/schemas/v3.2/strict/openapi-document';
|
|
4
4
|
import type { CustomFetch } from '../../../../v2/blocks/operation-block/helpers/send-request.js';
|
|
5
5
|
type __VLS_Props = {
|
|
6
6
|
/** Current environment configuration */
|