From 703b71de2ceda0783916d27edd1ff6af928ae3a4 Mon Sep 17 00:00:00 2001 From: Anwarul Islam Date: Fri, 30 Aug 2024 14:30:13 +0600 Subject: [PATCH] feat: add support for AWS Signature auth type (#4142) Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com> Co-authored-by: nivedin --- packages/hoppscotch-common/locales/en.json | 11 +- packages/hoppscotch-common/package.json | 1 + .../hoppscotch-common/src/components.d.ts | 438 +++++++++--------- .../src/components/graphql/Authorization.vue | 164 ++++--- .../src/components/graphql/Headers.vue | 58 ++- .../src/components/graphql/RequestOptions.vue | 104 ++--- .../src/components/http/Authorization.vue | 134 +++--- .../src/components/http/Headers.vue | 28 +- .../components/http/authorization/ASAP.vue | 192 ++++++++ .../components/http/authorization/AWSSign.vue | 140 ++++++ .../http/authorization/AkamaiEG.vue | 96 ++++ .../components/http/authorization/HAWK.vue | 152 ++++++ .../components/http/authorization/NTLM.vue | 77 +++ .../OAuth2.vue} | 57 +-- .../src/helpers/RequestRunner.ts | 6 +- .../src/helpers/auth/index.ts | 56 +++ .../src/helpers/graphql/connection.ts | 28 ++ .../src/helpers/graphql/index.ts | 12 - .../src/helpers/utils/EffectiveURL.ts | 147 ++++-- .../src/newstore/collections.ts | 4 +- .../hoppscotch-data/src/collection/v/3.ts | 21 +- packages/hoppscotch-data/src/graphql/index.ts | 5 +- packages/hoppscotch-data/src/graphql/v/6.ts | 44 +- packages/hoppscotch-data/src/rest/index.ts | 21 +- packages/hoppscotch-data/src/rest/v/7.ts | 69 +-- pnpm-lock.yaml | 100 ++-- 26 files changed, 1499 insertions(+), 666 deletions(-) create mode 100644 packages/hoppscotch-common/src/components/http/authorization/ASAP.vue create mode 100644 packages/hoppscotch-common/src/components/http/authorization/AWSSign.vue create mode 100644 packages/hoppscotch-common/src/components/http/authorization/AkamaiEG.vue create mode 100644 packages/hoppscotch-common/src/components/http/authorization/HAWK.vue create mode 100644 packages/hoppscotch-common/src/components/http/authorization/NTLM.vue rename packages/hoppscotch-common/src/components/http/{OAuth2Authorization.vue => authorization/OAuth2.vue} (95%) create mode 100644 packages/hoppscotch-common/src/helpers/auth/index.ts diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.json index 30d2db11b..15a8d96a7 100644 --- a/packages/hoppscotch-common/locales/en.json +++ b/packages/hoppscotch-common/locales/en.json @@ -174,7 +174,16 @@ "save_to_inherit": "Please save this request in any collection to inherit the authorization", "token": "Token", "type": "Authorization Type", - "username": "Username" + "username": "Username", + "aws_signature": { + "access_key": "Access Key", + "secret_key": "Secret Key", + "service_name": "Service Name", + "aws_region": "AWS Region", + "service_token": "Service Token", + "advance_config": "Advanced Configuration", + "advance_config_description": "Hoppscotch automatically assigns default values to certain fields if no explicit value is provided" + } }, "collection": { "created": "Collection created", diff --git a/packages/hoppscotch-common/package.json b/packages/hoppscotch-common/package.json index bc2f5288b..b909e201d 100644 --- a/packages/hoppscotch-common/package.json +++ b/packages/hoppscotch-common/package.json @@ -49,6 +49,7 @@ "@vueuse/core": "10.7.0", "acorn-walk": "8.3.0", "axios": "1.7.5", + "aws4fetch": "1.0.19", "buffer": "6.0.3", "cookie-es": "1.0.0", "dioc": "3.0.2", diff --git a/packages/hoppscotch-common/src/components.d.ts b/packages/hoppscotch-common/src/components.d.ts index 92ec415bb..06dfe2ae5 100644 --- a/packages/hoppscotch-common/src/components.d.ts +++ b/packages/hoppscotch-common/src/components.d.ts @@ -5,230 +5,238 @@ // Read more: https://github.com/vuejs/core/pull/3399 export {} -declare module "vue" { +declare module 'vue' { export interface GlobalComponents { - AccessTokens: (typeof import("./components/accessTokens/index.vue"))["default"] - AccessTokensGenerateModal: (typeof import("./components/accessTokens/GenerateModal.vue"))["default"] - AccessTokensList: (typeof import("./components/accessTokens/List.vue"))["default"] - AccessTokensOverview: (typeof import("./components/accessTokens/Overview.vue"))["default"] - AppActionHandler: (typeof import("./components/app/ActionHandler.vue"))["default"] - AppBanner: (typeof import("./components/app/Banner.vue"))["default"] - AppContextMenu: (typeof import("./components/app/ContextMenu.vue"))["default"] - AppDeveloperOptions: (typeof import("./components/app/DeveloperOptions.vue"))["default"] + AccessTokens: typeof import('./components/accessTokens/index.vue')['default'] + AccessTokensGenerateModal: typeof import('./components/accessTokens/GenerateModal.vue')['default'] + AccessTokensList: typeof import('./components/accessTokens/List.vue')['default'] + AccessTokensOverview: typeof import('./components/accessTokens/Overview.vue')['default'] + AppActionHandler: typeof import('./components/app/ActionHandler.vue')['default'] + AppBanner: typeof import('./components/app/Banner.vue')['default'] + AppContextMenu: typeof import('./components/app/ContextMenu.vue')['default'] + AppDeveloperOptions: typeof import('./components/app/DeveloperOptions.vue')['default'] AppDrawer: (typeof import("./components/app/Drawer.vue"))["default"] - AppFooter: (typeof import("./components/app/Footer.vue"))["default"] - AppGitHubStarButton: (typeof import("./components/app/GitHubStarButton.vue"))["default"] - AppHeader: (typeof import("./components/app/Header.vue"))["default"] - AppInspection: (typeof import("./components/app/Inspection.vue"))["default"] - AppInterceptor: (typeof import("./components/app/Interceptor.vue"))["default"] - AppLogo: (typeof import("./components/app/Logo.vue"))["default"] - AppOptions: (typeof import("./components/app/Options.vue"))["default"] - AppPaneLayout: (typeof import("./components/app/PaneLayout.vue"))["default"] + AppFooter: typeof import('./components/app/Footer.vue')['default'] + AppGitHubStarButton: typeof import('./components/app/GitHubStarButton.vue')['default'] + AppHeader: typeof import('./components/app/Header.vue')['default'] + AppInspection: typeof import('./components/app/Inspection.vue')['default'] + AppInterceptor: typeof import('./components/app/Interceptor.vue')['default'] + AppLogo: typeof import('./components/app/Logo.vue')['default'] + AppOptions: typeof import('./components/app/Options.vue')['default'] + AppPaneLayout: typeof import('./components/app/PaneLayout.vue')['default'] AppPWAPrompt: (typeof import("./components/app/PWAPrompt.vue"))["default"] - AppShare: (typeof import("./components/app/Share.vue"))["default"] - AppShortcuts: (typeof import("./components/app/Shortcuts.vue"))["default"] - AppShortcutsEntry: (typeof import("./components/app/ShortcutsEntry.vue"))["default"] - AppShortcutsPrompt: (typeof import("./components/app/ShortcutsPrompt.vue"))["default"] - AppSidenav: (typeof import("./components/app/Sidenav.vue"))["default"] - AppSpotlight: (typeof import("./components/app/spotlight/index.vue"))["default"] - AppSpotlightEntry: (typeof import("./components/app/spotlight/Entry.vue"))["default"] - AppSpotlightEntryGQLHistory: (typeof import("./components/app/spotlight/entry/GQLHistory.vue"))["default"] - AppSpotlightEntryGQLRequest: (typeof import("./components/app/spotlight/entry/GQLRequest.vue"))["default"] - AppSpotlightEntryIconSelected: (typeof import("./components/app/spotlight/entry/IconSelected.vue"))["default"] - AppSpotlightEntryRESTHistory: (typeof import("./components/app/spotlight/entry/RESTHistory.vue"))["default"] - AppSpotlightEntryRESTRequest: (typeof import("./components/app/spotlight/entry/RESTRequest.vue"))["default"] - AppSpotlightEntryRESTTeamRequestEntry: (typeof import("./components/app/spotlight/entry/RESTTeamRequestEntry.vue"))["default"] - AppSpotlightSearch: (typeof import("./components/app/SpotlightSearch.vue"))["default"] - AppSupport: (typeof import("./components/app/Support.vue"))["default"] - AppWhatsNewDialog: (typeof import("./components/app/WhatsNewDialog.vue"))["default"] - Collections: (typeof import("./components/collections/index.vue"))["default"] - CollectionsAdd: (typeof import("./components/collections/Add.vue"))["default"] - CollectionsAddFolder: (typeof import("./components/collections/AddFolder.vue"))["default"] - CollectionsAddRequest: (typeof import("./components/collections/AddRequest.vue"))["default"] - CollectionsCollection: (typeof import("./components/collections/Collection.vue"))["default"] - CollectionsEdit: (typeof import("./components/collections/Edit.vue"))["default"] - CollectionsEditFolder: (typeof import("./components/collections/EditFolder.vue"))["default"] - CollectionsEditRequest: (typeof import("./components/collections/EditRequest.vue"))["default"] - CollectionsGraphql: (typeof import("./components/collections/graphql/index.vue"))["default"] - CollectionsGraphqlAdd: (typeof import("./components/collections/graphql/Add.vue"))["default"] - CollectionsGraphqlAddFolder: (typeof import("./components/collections/graphql/AddFolder.vue"))["default"] - CollectionsGraphqlAddRequest: (typeof import("./components/collections/graphql/AddRequest.vue"))["default"] - CollectionsGraphqlCollection: (typeof import("./components/collections/graphql/Collection.vue"))["default"] - CollectionsGraphqlEdit: (typeof import("./components/collections/graphql/Edit.vue"))["default"] - CollectionsGraphqlEditFolder: (typeof import("./components/collections/graphql/EditFolder.vue"))["default"] - CollectionsGraphqlEditRequest: (typeof import("./components/collections/graphql/EditRequest.vue"))["default"] - CollectionsGraphqlFolder: (typeof import("./components/collections/graphql/Folder.vue"))["default"] - CollectionsGraphqlImportExport: (typeof import("./components/collections/graphql/ImportExport.vue"))["default"] - CollectionsGraphqlRequest: (typeof import("./components/collections/graphql/Request.vue"))["default"] - CollectionsImportExport: (typeof import("./components/collections/ImportExport.vue"))["default"] - CollectionsMyCollections: (typeof import("./components/collections/MyCollections.vue"))["default"] - CollectionsProperties: (typeof import("./components/collections/Properties.vue"))["default"] - CollectionsRequest: (typeof import("./components/collections/Request.vue"))["default"] - CollectionsRunner: (typeof import("./components/collections/Runner.vue"))["default"] - CollectionsSaveRequest: (typeof import("./components/collections/SaveRequest.vue"))["default"] - CollectionsTeamCollections: (typeof import("./components/collections/TeamCollections.vue"))["default"] - CookiesAllModal: (typeof import("./components/cookies/AllModal.vue"))["default"] - CookiesEditCookie: (typeof import("./components/cookies/EditCookie.vue"))["default"] - Embeds: (typeof import("./components/embeds/index.vue"))["default"] - EmbedsHeader: (typeof import("./components/embeds/Header.vue"))["default"] - EmbedsRequest: (typeof import("./components/embeds/Request.vue"))["default"] - Environments: (typeof import("./components/environments/index.vue"))["default"] - EnvironmentsAdd: (typeof import("./components/environments/Add.vue"))["default"] - EnvironmentsImportExport: (typeof import("./components/environments/ImportExport.vue"))["default"] - EnvironmentsMy: (typeof import("./components/environments/my/index.vue"))["default"] - EnvironmentsMyDetails: (typeof import("./components/environments/my/Details.vue"))["default"] - EnvironmentsMyEnvironment: (typeof import("./components/environments/my/Environment.vue"))["default"] - EnvironmentsProperties: (typeof import("./components/environments/Properties.vue"))["default"] - EnvironmentsSelector: (typeof import("./components/environments/Selector.vue"))["default"] - EnvironmentsTeams: (typeof import("./components/environments/teams/index.vue"))["default"] - EnvironmentsTeamsDetails: (typeof import("./components/environments/teams/Details.vue"))["default"] - EnvironmentsTeamsEnvironment: (typeof import("./components/environments/teams/Environment.vue"))["default"] - FirebaseLogin: (typeof import("./components/firebase/Login.vue"))["default"] - FirebaseLogout: (typeof import("./components/firebase/Logout.vue"))["default"] - GraphqlAuthorization: (typeof import("./components/graphql/Authorization.vue"))["default"] - GraphqlField: (typeof import("./components/graphql/Field.vue"))["default"] - GraphqlHeaders: (typeof import("./components/graphql/Headers.vue"))["default"] - GraphqlQuery: (typeof import("./components/graphql/Query.vue"))["default"] - GraphqlRequest: (typeof import("./components/graphql/Request.vue"))["default"] - GraphqlRequestOptions: (typeof import("./components/graphql/RequestOptions.vue"))["default"] - GraphqlRequestTab: (typeof import("./components/graphql/RequestTab.vue"))["default"] - GraphqlResponse: (typeof import("./components/graphql/Response.vue"))["default"] - GraphqlSidebar: (typeof import("./components/graphql/Sidebar.vue"))["default"] - GraphqlSubscriptionLog: (typeof import("./components/graphql/SubscriptionLog.vue"))["default"] - GraphqlTabHead: (typeof import("./components/graphql/TabHead.vue"))["default"] - GraphqlType: (typeof import("./components/graphql/Type.vue"))["default"] - GraphqlTypeLink: (typeof import("./components/graphql/TypeLink.vue"))["default"] - GraphqlVariable: (typeof import("./components/graphql/Variable.vue"))["default"] - History: (typeof import("./components/history/index.vue"))["default"] - HistoryGraphqlCard: (typeof import("./components/history/graphql/Card.vue"))["default"] - HistoryRestCard: (typeof import("./components/history/rest/Card.vue"))["default"] - HoppButtonPrimary: (typeof import("@hoppscotch/ui"))["HoppButtonPrimary"] - HoppButtonSecondary: (typeof import("@hoppscotch/ui"))["HoppButtonSecondary"] - HoppSmartAnchor: (typeof import("@hoppscotch/ui"))["HoppSmartAnchor"] - HoppSmartCheckbox: (typeof import("@hoppscotch/ui"))["HoppSmartCheckbox"] - HoppSmartConfirmModal: (typeof import("@hoppscotch/ui"))["HoppSmartConfirmModal"] - HoppSmartExpand: (typeof import("@hoppscotch/ui"))["HoppSmartExpand"] - HoppSmartFileChip: (typeof import("@hoppscotch/ui"))["HoppSmartFileChip"] - HoppSmartInput: (typeof import("@hoppscotch/ui"))["HoppSmartInput"] - HoppSmartIntersection: (typeof import("@hoppscotch/ui"))["HoppSmartIntersection"] - HoppSmartItem: (typeof import("@hoppscotch/ui"))["HoppSmartItem"] - HoppSmartLink: (typeof import("@hoppscotch/ui"))["HoppSmartLink"] - HoppSmartModal: (typeof import("@hoppscotch/ui"))["HoppSmartModal"] - HoppSmartPicture: (typeof import("@hoppscotch/ui"))["HoppSmartPicture"] - HoppSmartPlaceholder: (typeof import("@hoppscotch/ui"))["HoppSmartPlaceholder"] - HoppSmartProgressRing: (typeof import("@hoppscotch/ui"))["HoppSmartProgressRing"] - HoppSmartRadio: (typeof import("@hoppscotch/ui"))["HoppSmartRadio"] - HoppSmartRadioGroup: (typeof import("@hoppscotch/ui"))["HoppSmartRadioGroup"] - HoppSmartSelectWrapper: (typeof import("@hoppscotch/ui"))["HoppSmartSelectWrapper"] - HoppSmartSlideOver: (typeof import("@hoppscotch/ui"))["HoppSmartSlideOver"] - HoppSmartSpinner: (typeof import("@hoppscotch/ui"))["HoppSmartSpinner"] - HoppSmartTab: (typeof import("@hoppscotch/ui"))["HoppSmartTab"] - HoppSmartTabs: (typeof import("@hoppscotch/ui"))["HoppSmartTabs"] - HoppSmartToggle: (typeof import("@hoppscotch/ui"))["HoppSmartToggle"] - HoppSmartTree: (typeof import("@hoppscotch/ui"))["HoppSmartTree"] - HoppSmartWindow: (typeof import("@hoppscotch/ui"))["HoppSmartWindow"] - HoppSmartWindows: (typeof import("@hoppscotch/ui"))["HoppSmartWindows"] - HttpAuthorization: (typeof import("./components/http/Authorization.vue"))["default"] - HttpAuthorizationApiKey: (typeof import("./components/http/authorization/ApiKey.vue"))["default"] - HttpAuthorizationBasic: (typeof import("./components/http/authorization/Basic.vue"))["default"] - HttpBody: (typeof import("./components/http/Body.vue"))["default"] - HttpBodyParameters: (typeof import("./components/http/BodyParameters.vue"))["default"] - HttpCodegen: (typeof import("./components/http/Codegen.vue"))["default"] - HttpCodegenModal: (typeof import("./components/http/CodegenModal.vue"))["default"] - HttpHeaders: (typeof import("./components/http/Headers.vue"))["default"] - HttpImportCurl: (typeof import("./components/http/ImportCurl.vue"))["default"] - HttpKeyValue: (typeof import("./components/http/KeyValue.vue"))["default"] + AppShare: typeof import('./components/app/Share.vue')['default'] + AppShortcuts: typeof import('./components/app/Shortcuts.vue')['default'] + AppShortcutsEntry: typeof import('./components/app/ShortcutsEntry.vue')['default'] + AppShortcutsPrompt: typeof import('./components/app/ShortcutsPrompt.vue')['default'] + AppSidenav: typeof import('./components/app/Sidenav.vue')['default'] + AppSpotlight: typeof import('./components/app/spotlight/index.vue')['default'] + AppSpotlightEntry: typeof import('./components/app/spotlight/Entry.vue')['default'] + AppSpotlightEntryGQLHistory: typeof import('./components/app/spotlight/entry/GQLHistory.vue')['default'] + AppSpotlightEntryGQLRequest: typeof import('./components/app/spotlight/entry/GQLRequest.vue')['default'] + AppSpotlightEntryIconSelected: typeof import('./components/app/spotlight/entry/IconSelected.vue')['default'] + AppSpotlightEntryRESTHistory: typeof import('./components/app/spotlight/entry/RESTHistory.vue')['default'] + AppSpotlightEntryRESTRequest: typeof import('./components/app/spotlight/entry/RESTRequest.vue')['default'] + AppSpotlightEntryRESTTeamRequestEntry: typeof import('./components/app/spotlight/entry/RESTTeamRequestEntry.vue')['default'] + AppSpotlightSearch: typeof import('./components/app/SpotlightSearch.vue')['default'] + AppSupport: typeof import('./components/app/Support.vue')['default'] + AppWhatsNewDialog: typeof import('./components/app/WhatsNewDialog.vue')['default'] + Collections: typeof import('./components/collections/index.vue')['default'] + CollectionsAdd: typeof import('./components/collections/Add.vue')['default'] + CollectionsAddFolder: typeof import('./components/collections/AddFolder.vue')['default'] + CollectionsAddRequest: typeof import('./components/collections/AddRequest.vue')['default'] + CollectionsCollection: typeof import('./components/collections/Collection.vue')['default'] + CollectionsEdit: typeof import('./components/collections/Edit.vue')['default'] + CollectionsEditFolder: typeof import('./components/collections/EditFolder.vue')['default'] + CollectionsEditRequest: typeof import('./components/collections/EditRequest.vue')['default'] + CollectionsGraphql: typeof import('./components/collections/graphql/index.vue')['default'] + CollectionsGraphqlAdd: typeof import('./components/collections/graphql/Add.vue')['default'] + CollectionsGraphqlAddFolder: typeof import('./components/collections/graphql/AddFolder.vue')['default'] + CollectionsGraphqlAddRequest: typeof import('./components/collections/graphql/AddRequest.vue')['default'] + CollectionsGraphqlCollection: typeof import('./components/collections/graphql/Collection.vue')['default'] + CollectionsGraphqlEdit: typeof import('./components/collections/graphql/Edit.vue')['default'] + CollectionsGraphqlEditFolder: typeof import('./components/collections/graphql/EditFolder.vue')['default'] + CollectionsGraphqlEditRequest: typeof import('./components/collections/graphql/EditRequest.vue')['default'] + CollectionsGraphqlFolder: typeof import('./components/collections/graphql/Folder.vue')['default'] + CollectionsGraphqlImportExport: typeof import('./components/collections/graphql/ImportExport.vue')['default'] + CollectionsGraphqlRequest: typeof import('./components/collections/graphql/Request.vue')['default'] + CollectionsImportExport: typeof import('./components/collections/ImportExport.vue')['default'] + CollectionsMyCollections: typeof import('./components/collections/MyCollections.vue')['default'] + CollectionsProperties: typeof import('./components/collections/Properties.vue')['default'] + CollectionsRequest: typeof import('./components/collections/Request.vue')['default'] + CollectionsRunner: typeof import('./components/collections/Runner.vue')['default'] + CollectionsSaveRequest: typeof import('./components/collections/SaveRequest.vue')['default'] + CollectionsTeamCollections: typeof import('./components/collections/TeamCollections.vue')['default'] + CookiesAllModal: typeof import('./components/cookies/AllModal.vue')['default'] + CookiesEditCookie: typeof import('./components/cookies/EditCookie.vue')['default'] + Embeds: typeof import('./components/embeds/index.vue')['default'] + EmbedsHeader: typeof import('./components/embeds/Header.vue')['default'] + EmbedsRequest: typeof import('./components/embeds/Request.vue')['default'] + Environments: typeof import('./components/environments/index.vue')['default'] + EnvironmentsAdd: typeof import('./components/environments/Add.vue')['default'] + EnvironmentsImportExport: typeof import('./components/environments/ImportExport.vue')['default'] + EnvironmentsMy: typeof import('./components/environments/my/index.vue')['default'] + EnvironmentsMyDetails: typeof import('./components/environments/my/Details.vue')['default'] + EnvironmentsMyEnvironment: typeof import('./components/environments/my/Environment.vue')['default'] + EnvironmentsProperties: typeof import('./components/environments/Properties.vue')['default'] + EnvironmentsSelector: typeof import('./components/environments/Selector.vue')['default'] + EnvironmentsTeams: typeof import('./components/environments/teams/index.vue')['default'] + EnvironmentsTeamsDetails: typeof import('./components/environments/teams/Details.vue')['default'] + EnvironmentsTeamsEnvironment: typeof import('./components/environments/teams/Environment.vue')['default'] + FirebaseLogin: typeof import('./components/firebase/Login.vue')['default'] + FirebaseLogout: typeof import('./components/firebase/Logout.vue')['default'] + GraphqlAuthorization: typeof import('./components/graphql/Authorization.vue')['default'] + GraphqlField: typeof import('./components/graphql/Field.vue')['default'] + GraphqlHeaders: typeof import('./components/graphql/Headers.vue')['default'] + GraphqlQuery: typeof import('./components/graphql/Query.vue')['default'] + GraphqlRequest: typeof import('./components/graphql/Request.vue')['default'] + GraphqlRequestOptions: typeof import('./components/graphql/RequestOptions.vue')['default'] + GraphqlRequestTab: typeof import('./components/graphql/RequestTab.vue')['default'] + GraphqlResponse: typeof import('./components/graphql/Response.vue')['default'] + GraphqlSidebar: typeof import('./components/graphql/Sidebar.vue')['default'] + GraphqlSubscriptionLog: typeof import('./components/graphql/SubscriptionLog.vue')['default'] + GraphqlTabHead: typeof import('./components/graphql/TabHead.vue')['default'] + GraphqlType: typeof import('./components/graphql/Type.vue')['default'] + GraphqlTypeLink: typeof import('./components/graphql/TypeLink.vue')['default'] + GraphqlVariable: typeof import('./components/graphql/Variable.vue')['default'] + History: typeof import('./components/history/index.vue')['default'] + HistoryGraphqlCard: typeof import('./components/history/graphql/Card.vue')['default'] + HistoryRestCard: typeof import('./components/history/rest/Card.vue')['default'] + HoppButtonPrimary: typeof import('@hoppscotch/ui')['HoppButtonPrimary'] + HoppButtonSecondary: typeof import('@hoppscotch/ui')['HoppButtonSecondary'] + HoppSmartAnchor: typeof import('@hoppscotch/ui')['HoppSmartAnchor'] + HoppSmartCheckbox: typeof import('@hoppscotch/ui')['HoppSmartCheckbox'] + HoppSmartConfirmModal: typeof import('@hoppscotch/ui')['HoppSmartConfirmModal'] + HoppSmartExpand: typeof import('@hoppscotch/ui')['HoppSmartExpand'] + HoppSmartFileChip: typeof import('@hoppscotch/ui')['HoppSmartFileChip'] + HoppSmartInput: typeof import('@hoppscotch/ui')['HoppSmartInput'] + HoppSmartIntersection: typeof import('@hoppscotch/ui')['HoppSmartIntersection'] + HoppSmartItem: typeof import('@hoppscotch/ui')['HoppSmartItem'] + HoppSmartLink: typeof import('@hoppscotch/ui')['HoppSmartLink'] + HoppSmartModal: typeof import('@hoppscotch/ui')['HoppSmartModal'] + HoppSmartPicture: typeof import('@hoppscotch/ui')['HoppSmartPicture'] + HoppSmartPlaceholder: typeof import('@hoppscotch/ui')['HoppSmartPlaceholder'] + HoppSmartProgressRing: typeof import('@hoppscotch/ui')['HoppSmartProgressRing'] + HoppSmartRadio: typeof import('@hoppscotch/ui')['HoppSmartRadio'] + HoppSmartRadioGroup: typeof import('@hoppscotch/ui')['HoppSmartRadioGroup'] + HoppSmartSelectWrapper: typeof import('@hoppscotch/ui')['HoppSmartSelectWrapper'] + HoppSmartSlideOver: typeof import('@hoppscotch/ui')['HoppSmartSlideOver'] + HoppSmartSpinner: typeof import('@hoppscotch/ui')['HoppSmartSpinner'] + HoppSmartTab: typeof import('@hoppscotch/ui')['HoppSmartTab'] + HoppSmartTabs: typeof import('@hoppscotch/ui')['HoppSmartTabs'] + HoppSmartToggle: typeof import('@hoppscotch/ui')['HoppSmartToggle'] + HoppSmartTree: typeof import('@hoppscotch/ui')['HoppSmartTree'] + HoppSmartWindow: typeof import('@hoppscotch/ui')['HoppSmartWindow'] + HoppSmartWindows: typeof import('@hoppscotch/ui')['HoppSmartWindows'] + HttpAuthorization: typeof import('./components/http/Authorization.vue')['default'] + HttpAuthorizationAkamaiEG: typeof import('./components/http/authorization/AkamaiEG.vue')['default'] + HttpAuthorizationApiKey: typeof import('./components/http/authorization/ApiKey.vue')['default'] + HttpAuthorizationASAP: typeof import('./components/http/authorization/ASAP.vue')['default'] + HttpAuthorizationAWSSign: typeof import('./components/http/authorization/AWSSign.vue')['default'] + HttpAuthorizationBasic: typeof import('./components/http/authorization/Basic.vue')['default'] + HttpAuthorizationHAWK: typeof import('./components/http/authorization/HAWK.vue')['default'] + HttpAuthorizationNTLM: typeof import('./components/http/authorization/NTLM.vue')['default'] + HttpAuthorizationOAuth2: typeof import('./components/http/authorization/OAuth2.vue')['default'] + HttpAuthorizationOAuth2Authorization: (typeof import("./components/http/authorization/OAuth2Authorization.vue"))["default"] + HttpBody: typeof import('./components/http/Body.vue')['default'] + HttpBodyParameters: typeof import('./components/http/BodyParameters.vue')['default'] + HttpCodegen: typeof import('./components/http/Codegen.vue')['default'] + HttpCodegenModal: typeof import('./components/http/CodegenModal.vue')['default'] + HttpHeaders: typeof import('./components/http/Headers.vue')['default'] + HttpImportCurl: typeof import('./components/http/ImportCurl.vue')['default'] + HttpKeyValue: typeof import('./components/http/KeyValue.vue')['default'] HttpOAuth2Authorization: (typeof import("./components/http/OAuth2Authorization.vue"))["default"] - HttpParameters: (typeof import("./components/http/Parameters.vue"))["default"] - HttpPreRequestScript: (typeof import("./components/http/PreRequestScript.vue"))["default"] - HttpRawBody: (typeof import("./components/http/RawBody.vue"))["default"] - HttpReqChangeConfirmModal: (typeof import("./components/http/ReqChangeConfirmModal.vue"))["default"] - HttpRequest: (typeof import("./components/http/Request.vue"))["default"] - HttpRequestOptions: (typeof import("./components/http/RequestOptions.vue"))["default"] - HttpRequestTab: (typeof import("./components/http/RequestTab.vue"))["default"] - HttpRequestVariables: (typeof import("./components/http/RequestVariables.vue"))["default"] - HttpResponse: (typeof import("./components/http/Response.vue"))["default"] - HttpResponseMeta: (typeof import("./components/http/ResponseMeta.vue"))["default"] - HttpSidebar: (typeof import("./components/http/Sidebar.vue"))["default"] - HttpTabHead: (typeof import("./components/http/TabHead.vue"))["default"] - HttpTestResult: (typeof import("./components/http/TestResult.vue"))["default"] - HttpTestResultEntry: (typeof import("./components/http/TestResultEntry.vue"))["default"] - HttpTestResultEnv: (typeof import("./components/http/TestResultEnv.vue"))["default"] - HttpTestResultReport: (typeof import("./components/http/TestResultReport.vue"))["default"] - HttpTests: (typeof import("./components/http/Tests.vue"))["default"] - HttpURLEncodedParams: (typeof import("./components/http/URLEncodedParams.vue"))["default"] - IconLucideActivity: (typeof import("~icons/lucide/activity"))["default"] - IconLucideAlertTriangle: (typeof import("~icons/lucide/alert-triangle"))["default"] - IconLucideArrowLeft: (typeof import("~icons/lucide/arrow-left"))["default"] - IconLucideArrowUpRight: (typeof import("~icons/lucide/arrow-up-right"))["default"] + HttpParameters: typeof import('./components/http/Parameters.vue')['default'] + HttpPreRequestScript: typeof import('./components/http/PreRequestScript.vue')['default'] + HttpRawBody: typeof import('./components/http/RawBody.vue')['default'] + HttpReqChangeConfirmModal: typeof import('./components/http/ReqChangeConfirmModal.vue')['default'] + HttpRequest: typeof import('./components/http/Request.vue')['default'] + HttpRequestOptions: typeof import('./components/http/RequestOptions.vue')['default'] + HttpRequestTab: typeof import('./components/http/RequestTab.vue')['default'] + HttpRequestVariables: typeof import('./components/http/RequestVariables.vue')['default'] + HttpResponse: typeof import('./components/http/Response.vue')['default'] + HttpResponseInterface: typeof import('./components/http/ResponseInterface.vue')['default'] + HttpResponseMeta: typeof import('./components/http/ResponseMeta.vue')['default'] + HttpSidebar: typeof import('./components/http/Sidebar.vue')['default'] + HttpTabHead: typeof import('./components/http/TabHead.vue')['default'] + HttpTestResult: typeof import('./components/http/TestResult.vue')['default'] + HttpTestResultEntry: typeof import('./components/http/TestResultEntry.vue')['default'] + HttpTestResultEnv: typeof import('./components/http/TestResultEnv.vue')['default'] + HttpTestResultReport: typeof import('./components/http/TestResultReport.vue')['default'] + HttpTests: typeof import('./components/http/Tests.vue')['default'] + HttpURLEncodedParams: typeof import('./components/http/URLEncodedParams.vue')['default'] + IconLucideActivity: typeof import('~icons/lucide/activity')['default'] + IconLucideAlertTriangle: typeof import('~icons/lucide/alert-triangle')['default'] + IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default'] + IconLucideArrowUpRight: typeof import('~icons/lucide/arrow-up-right')['default'] IconLucideBrush: (typeof import("~icons/lucide/brush"))["default"] - IconLucideCheckCircle: (typeof import("~icons/lucide/check-circle"))["default"] - IconLucideChevronRight: (typeof import("~icons/lucide/chevron-right"))["default"] - IconLucideGlobe: (typeof import("~icons/lucide/globe"))["default"] - IconLucideHelpCircle: (typeof import("~icons/lucide/help-circle"))["default"] - IconLucideInbox: (typeof import("~icons/lucide/inbox"))["default"] - IconLucideInfo: (typeof import("~icons/lucide/info"))["default"] - IconLucideLayers: (typeof import("~icons/lucide/layers"))["default"] - IconLucideListEnd: (typeof import("~icons/lucide/list-end"))["default"] - IconLucideMinus: (typeof import("~icons/lucide/minus"))["default"] + IconLucideCheckCircle: typeof import('~icons/lucide/check-circle')['default'] + IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default'] + IconLucideGlobe: typeof import('~icons/lucide/globe')['default'] + IconLucideHelpCircle: typeof import('~icons/lucide/help-circle')['default'] + IconLucideInbox: typeof import('~icons/lucide/inbox')['default'] + IconLucideInfo: typeof import('~icons/lucide/info')['default'] + IconLucideLayers: typeof import('~icons/lucide/layers')['default'] + IconLucideListEnd: typeof import('~icons/lucide/list-end')['default'] + IconLucideMinus: typeof import('~icons/lucide/minus')['default'] IconLucideRss: (typeof import("~icons/lucide/rss"))["default"] - IconLucideSearch: (typeof import("~icons/lucide/search"))["default"] - IconLucideUsers: (typeof import("~icons/lucide/users"))["default"] - IconLucideX: (typeof import("~icons/lucide/x"))["default"] - ImportExportBase: (typeof import("./components/importExport/Base.vue"))["default"] - ImportExportImportExportList: (typeof import("./components/importExport/ImportExportList.vue"))["default"] - ImportExportImportExportSourcesList: (typeof import("./components/importExport/ImportExportSourcesList.vue"))["default"] - ImportExportImportExportStepsFileImport: (typeof import("./components/importExport/ImportExportSteps/FileImport.vue"))["default"] - ImportExportImportExportStepsMyCollectionImport: (typeof import("./components/importExport/ImportExportSteps/MyCollectionImport.vue"))["default"] - ImportExportImportExportStepsUrlImport: (typeof import("./components/importExport/ImportExportSteps/UrlImport.vue"))["default"] - InterceptorsErrorPlaceholder: (typeof import("./components/interceptors/ErrorPlaceholder.vue"))["default"] - InterceptorsExtensionSubtitle: (typeof import("./components/interceptors/ExtensionSubtitle.vue"))["default"] - LensesHeadersRenderer: (typeof import("./components/lenses/HeadersRenderer.vue"))["default"] - LensesHeadersRendererEntry: (typeof import("./components/lenses/HeadersRendererEntry.vue"))["default"] - LensesRenderersAudioLensRenderer: (typeof import("./components/lenses/renderers/AudioLensRenderer.vue"))["default"] - LensesRenderersHTMLLensRenderer: (typeof import("./components/lenses/renderers/HTMLLensRenderer.vue"))["default"] - LensesRenderersImageLensRenderer: (typeof import("./components/lenses/renderers/ImageLensRenderer.vue"))["default"] - LensesRenderersJSONLensRenderer: (typeof import("./components/lenses/renderers/JSONLensRenderer.vue"))["default"] - LensesRenderersPDFLensRenderer: (typeof import("./components/lenses/renderers/PDFLensRenderer.vue"))["default"] - LensesRenderersRawLensRenderer: (typeof import("./components/lenses/renderers/RawLensRenderer.vue"))["default"] - LensesRenderersVideoLensRenderer: (typeof import("./components/lenses/renderers/VideoLensRenderer.vue"))["default"] - LensesRenderersXMLLensRenderer: (typeof import("./components/lenses/renderers/XMLLensRenderer.vue"))["default"] - LensesResponseBodyRenderer: (typeof import("./components/lenses/ResponseBodyRenderer.vue"))["default"] + IconLucideSearch: typeof import('~icons/lucide/search')['default'] + IconLucideUsers: typeof import('~icons/lucide/users')['default'] + IconLucideX: typeof import('~icons/lucide/x')['default'] + ImportExportBase: typeof import('./components/importExport/Base.vue')['default'] + ImportExportImportExportList: typeof import('./components/importExport/ImportExportList.vue')['default'] + ImportExportImportExportSourcesList: typeof import('./components/importExport/ImportExportSourcesList.vue')['default'] + ImportExportImportExportStepsFileImport: typeof import('./components/importExport/ImportExportSteps/FileImport.vue')['default'] + ImportExportImportExportStepsMyCollectionImport: typeof import('./components/importExport/ImportExportSteps/MyCollectionImport.vue')['default'] + ImportExportImportExportStepsUrlImport: typeof import('./components/importExport/ImportExportSteps/UrlImport.vue')['default'] + InterceptorsErrorPlaceholder: typeof import('./components/interceptors/ErrorPlaceholder.vue')['default'] + InterceptorsExtensionSubtitle: typeof import('./components/interceptors/ExtensionSubtitle.vue')['default'] + LensesHeadersRenderer: typeof import('./components/lenses/HeadersRenderer.vue')['default'] + LensesHeadersRendererEntry: typeof import('./components/lenses/HeadersRendererEntry.vue')['default'] + LensesRenderersAudioLensRenderer: typeof import('./components/lenses/renderers/AudioLensRenderer.vue')['default'] + LensesRenderersHTMLLensRenderer: typeof import('./components/lenses/renderers/HTMLLensRenderer.vue')['default'] + LensesRenderersImageLensRenderer: typeof import('./components/lenses/renderers/ImageLensRenderer.vue')['default'] + LensesRenderersJSONLensRenderer: typeof import('./components/lenses/renderers/JSONLensRenderer.vue')['default'] + LensesRenderersPDFLensRenderer: typeof import('./components/lenses/renderers/PDFLensRenderer.vue')['default'] + LensesRenderersRawLensRenderer: typeof import('./components/lenses/renderers/RawLensRenderer.vue')['default'] + LensesRenderersVideoLensRenderer: typeof import('./components/lenses/renderers/VideoLensRenderer.vue')['default'] + LensesRenderersXMLLensRenderer: typeof import('./components/lenses/renderers/XMLLensRenderer.vue')['default'] + LensesResponseBodyRenderer: typeof import('./components/lenses/ResponseBodyRenderer.vue')['default'] ModalsNativeCACertificates: (typeof import("./../../hoppscotch-selfhost-desktop/src/components/modals/NativeCACertificates.vue"))["default"] ModalsNativeClientCertificates: (typeof import("./../../hoppscotch-selfhost-desktop/src/components/modals/NativeClientCertificates.vue"))["default"] ModalsNativeClientCertsAdd: (typeof import("./../../hoppscotch-selfhost-desktop/src/components/modals/NativeClientCertsAdd.vue"))["default"] - ProfileUserDelete: (typeof import("./components/profile/UserDelete.vue"))["default"] - RealtimeCommunication: (typeof import("./components/realtime/Communication.vue"))["default"] - RealtimeConnectionConfig: (typeof import("./components/realtime/ConnectionConfig.vue"))["default"] - RealtimeLog: (typeof import("./components/realtime/Log.vue"))["default"] - RealtimeLogEntry: (typeof import("./components/realtime/LogEntry.vue"))["default"] - RealtimeSubscription: (typeof import("./components/realtime/Subscription.vue"))["default"] - SettingsExtension: (typeof import("./components/settings/Extension.vue"))["default"] + ProfileUserDelete: typeof import('./components/profile/UserDelete.vue')['default'] + RealtimeCommunication: typeof import('./components/realtime/Communication.vue')['default'] + RealtimeConnectionConfig: typeof import('./components/realtime/ConnectionConfig.vue')['default'] + RealtimeLog: typeof import('./components/realtime/Log.vue')['default'] + RealtimeLogEntry: typeof import('./components/realtime/LogEntry.vue')['default'] + RealtimeSubscription: typeof import('./components/realtime/Subscription.vue')['default'] + SettingsExtension: typeof import('./components/settings/Extension.vue')['default'] SettingsNativeInterceptor: (typeof import("./../../hoppscotch-selfhost-desktop/src/components/settings/NativeInterceptor.vue"))["default"] - SettingsProxy: (typeof import("./components/settings/Proxy.vue"))["default"] - Share: (typeof import("./components/share/index.vue"))["default"] - ShareCreateModal: (typeof import("./components/share/CreateModal.vue"))["default"] - ShareCustomizeModal: (typeof import("./components/share/CustomizeModal.vue"))["default"] - ShareModal: (typeof import("./components/share/Modal.vue"))["default"] - ShareRequest: (typeof import("./components/share/Request.vue"))["default"] - ShareTemplatesButton: (typeof import("./components/share/templates/Button.vue"))["default"] - ShareTemplatesEmbeds: (typeof import("./components/share/templates/Embeds.vue"))["default"] - ShareTemplatesLink: (typeof import("./components/share/templates/Link.vue"))["default"] - SmartAccentModePicker: (typeof import("./components/smart/AccentModePicker.vue"))["default"] - SmartChangeLanguage: (typeof import("./components/smart/ChangeLanguage.vue"))["default"] - SmartColorModePicker: (typeof import("./components/smart/ColorModePicker.vue"))["default"] - SmartEnvInput: (typeof import("./components/smart/EnvInput.vue"))["default"] - TabPrimary: (typeof import("./components/tab/Primary.vue"))["default"] - TabSecondary: (typeof import("./components/tab/Secondary.vue"))["default"] - Teams: (typeof import("./components/teams/index.vue"))["default"] - TeamsAdd: (typeof import("./components/teams/Add.vue"))["default"] - TeamsEdit: (typeof import("./components/teams/Edit.vue"))["default"] - TeamsInvite: (typeof import("./components/teams/Invite.vue"))["default"] - TeamsMemberStack: (typeof import("./components/teams/MemberStack.vue"))["default"] - TeamsModal: (typeof import("./components/teams/Modal.vue"))["default"] - TeamsTeam: (typeof import("./components/teams/Team.vue"))["default"] - Tippy: (typeof import("vue-tippy"))["Tippy"] - WorkspaceCurrent: (typeof import("./components/workspace/Current.vue"))["default"] - WorkspaceSelector: (typeof import("./components/workspace/Selector.vue"))["default"] + SettingsProxy: typeof import('./components/settings/Proxy.vue')['default'] + Share: typeof import('./components/share/index.vue')['default'] + ShareCreateModal: typeof import('./components/share/CreateModal.vue')['default'] + ShareCustomizeModal: typeof import('./components/share/CustomizeModal.vue')['default'] + ShareModal: typeof import('./components/share/Modal.vue')['default'] + ShareRequest: typeof import('./components/share/Request.vue')['default'] + ShareTemplatesButton: typeof import('./components/share/templates/Button.vue')['default'] + ShareTemplatesEmbeds: typeof import('./components/share/templates/Embeds.vue')['default'] + ShareTemplatesLink: typeof import('./components/share/templates/Link.vue')['default'] + SmartAccentModePicker: typeof import('./components/smart/AccentModePicker.vue')['default'] + SmartChangeLanguage: typeof import('./components/smart/ChangeLanguage.vue')['default'] + SmartColorModePicker: typeof import('./components/smart/ColorModePicker.vue')['default'] + SmartEnvInput: typeof import('./components/smart/EnvInput.vue')['default'] + TabPrimary: typeof import('./components/tab/Primary.vue')['default'] + TabSecondary: typeof import('./components/tab/Secondary.vue')['default'] + Teams: typeof import('./components/teams/index.vue')['default'] + TeamsAdd: typeof import('./components/teams/Add.vue')['default'] + TeamsEdit: typeof import('./components/teams/Edit.vue')['default'] + TeamsInvite: typeof import('./components/teams/Invite.vue')['default'] + TeamsMemberStack: typeof import('./components/teams/MemberStack.vue')['default'] + TeamsModal: typeof import('./components/teams/Modal.vue')['default'] + TeamsTeam: typeof import('./components/teams/Team.vue')['default'] + Tippy: typeof import('vue-tippy')['Tippy'] + WorkspaceCurrent: typeof import('./components/workspace/Current.vue')['default'] + WorkspaceSelector: typeof import('./components/workspace/Selector.vue')['default'] } } diff --git a/packages/hoppscotch-common/src/components/graphql/Authorization.vue b/packages/hoppscotch-common/src/components/graphql/Authorization.vue index d35fd83e3..c61319c55 100644 --- a/packages/hoppscotch-common/src/components/graphql/Authorization.vue +++ b/packages/hoppscotch-common/src/components/graphql/Authorization.vue @@ -32,68 +32,14 @@ @keyup.escape="hide()" > - - - - -
- Inherited - {{ getAuthName(inheritedProperties.auth.inheritedAuth.authType) }} - from Parent Collection {{ inheritedProperties?.auth.parentName }} + {{ + t("authorization.inherited_from", { + auth: getAuthName( + inheritedProperties.auth.inheritedAuth.authType + ), + collection: inheritedProperties?.auth.parentName, + }) + }} - Please save this request in any collection to inherit the - authorization + {{ t("authorization.save_to_inherit") }}
@@ -194,11 +144,14 @@ placeholder="Token" />
- +
+
+ +
void +} + const t = useI18n() const colorMode = useColorMode() @@ -263,26 +222,6 @@ onMounted(() => { const auth = useVModel(props, "modelValue", emit) -const AUTH_KEY_NAME = { - basic: "Basic Auth", - bearer: "Bearer", - "oauth-2": "OAuth 2.0", - "api-key": "API key", - none: "None", - inherit: "Inherit", -} as const - -const authType = pluckRef(auth, "authType") - -const authName = computed(() => - AUTH_KEY_NAME[authType.value] ? AUTH_KEY_NAME[authType.value] : "None" -) - -const getAuthName = (type: HoppGQLAuth["authType"] | undefined) => { - if (!type) return "None" - return AUTH_KEY_NAME[type] ? AUTH_KEY_NAME[type] : "None" -} - const selectOAuth2AuthType = () => { const defaultGrantTypeInfo: HoppGQLAuthOAuth2["grantTypeInfo"] = { ...getDefaultAuthCodeOauthFlowParams(), @@ -307,6 +246,59 @@ const selectOAuth2AuthType = () => { } } +const authTypes: AuthType[] = [ + { + key: "inherit", + label: "Inherit", + }, + { + key: "none", + label: "None", + }, + { + key: "basic", + label: "Basic Auth", + }, + { + key: "bearer", + label: "Bearer", + }, + { + key: "oauth-2", + label: "OAuth 2.0", + handler: selectOAuth2AuthType, + }, + { + key: "api-key", + label: "API Key", + }, + { + key: "aws-signature", + label: "AWS Signature", + }, +] + +const AUTH_KEY_NAME: Record = { + basic: "Basic Auth", + bearer: "Bearer", + "oauth-2": "OAuth 2.0", + "api-key": "API key", + none: "None", + inherit: "Inherit", + "aws-signature": "AWS Signature", +} + +const authType = pluckRef(auth, "authType") + +const authName = computed(() => + AUTH_KEY_NAME[authType.value] ? AUTH_KEY_NAME[authType.value] : "None" +) + +const getAuthName = (type: HoppGQLAuth["authType"] | undefined) => { + if (!type) return "None" + return AUTH_KEY_NAME[type] ? AUTH_KEY_NAME[type] : "None" +} + const authActive = pluckRef(auth, "authActive") const clearContent = () => { diff --git a/packages/hoppscotch-common/src/components/graphql/Headers.vue b/packages/hoppscotch-common/src/components/graphql/Headers.vue index 1a6904fcf..c2cb058b7 100644 --- a/packages/hoppscotch-common/src/components/graphql/Headers.vue +++ b/packages/hoppscotch-common/src/components/graphql/Headers.vue @@ -231,26 +231,25 @@ import { useColorMode } from "@composables/theming" import { useToast } from "@composables/toast" import { GQLHeader, - HoppGQLAuth, HoppGQLRequest, parseRawKeyValueEntriesE, rawKeyValueEntriesToString, RawKeyValueEntry, } from "@hoppscotch/data" -import { useVModel } from "@vueuse/core" +import { computedAsync, useVModel } from "@vueuse/core" +import { AwsV4Signer } from "aws4fetch" import * as A from "fp-ts/Array" import * as E from "fp-ts/Either" import * as O from "fp-ts/Option" import * as RA from "fp-ts/ReadonlyArray" import { flow, pipe } from "fp-ts/function" import { clone, cloneDeep, isEqual } from "lodash-es" -import { computed, reactive, ref, toRef, watch } from "vue" +import { reactive, ref, toRef, watch } from "vue" import draggable from "vuedraggable-es" import { useNestedSetting } from "~/composables/settings" import { throwError } from "~/helpers/functional/error" import { objRemoveKey } from "~/helpers/functional/object" -import { HoppGQLHeader } from "~/helpers/graphql" import { commonHeaders } from "~/helpers/headers" import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties" import { toggleNestedSetting } from "~/newstore/settings" @@ -524,7 +523,7 @@ const clearContent = () => { bulkHeaders.value = "" } -const getComputedAuthHeaders = ( +const getComputedAuthHeaders = async ( req?: HoppGQLRequest, auth?: HoppGQLRequest["auth"] ) => { @@ -537,7 +536,7 @@ const getComputedAuthHeaders = ( if (!request.auth || !request.auth.authActive) return [] - const headers: HoppGQLHeader[] = [] + const headers: GQLHeader[] = [] // TODO: Support a better b64 implementation than btoa ? if (request.auth.authType === "basic") { @@ -548,6 +547,7 @@ const getComputedAuthHeaders = ( active: true, key: "Authorization", value: `Basic ${btoa(`${username}:${password}`)}`, + description: "", }) } else if ( request.auth.authType === "bearer" || @@ -563,6 +563,7 @@ const getComputedAuthHeaders = ( active: true, key: "Authorization", value: `Bearer ${token}`, + description: "", }) } else if (request.auth.authType === "api-key") { const { key, addTo } = request.auth @@ -572,6 +573,35 @@ const getComputedAuthHeaders = ( active: true, key, value: request.auth.value ?? "", + description: "", + }) + } + } else if (request.auth.authType === "aws-signature") { + const { addTo } = request.auth + if (addTo === "HEADERS") { + const currentDate = new Date() + const amzDate = currentDate.toISOString().replace(/[:-]|\.\d{3}/g, "") + + const { url } = req as HoppGQLRequest + + const signer = new AwsV4Signer({ + datetime: amzDate, + accessKeyId: request.auth.accessKey, + secretAccessKey: request.auth.secretKey, + region: request.auth.region ?? "us-east-1", + service: request.auth.serviceName, + url, + }) + + const sign = await signer.sign() + + sign.headers.forEach((x, k) => { + headers.push({ + active: true, + key: k, + value: x, + description: "", + }) }) } } @@ -579,23 +609,23 @@ const getComputedAuthHeaders = ( return headers } -const getComputedHeaders = (req: HoppGQLRequest) => { +const getComputedHeaders = async (req: HoppGQLRequest) => { return [ - ...getComputedAuthHeaders(req).map((header) => ({ + ...(await getComputedAuthHeaders(req)).map((header) => ({ source: "auth" as const, header, })), ] } -const computedHeaders = computed(() => - getComputedHeaders(request.value).map((header, index) => ({ +const computedHeaders = computedAsync(async () => + (await getComputedHeaders(request.value)).map((header, index) => ({ id: `header-${index}`, ...header, })) ) -const inheritedProperties = computed(() => { +const inheritedProperties = computedAsync(async () => { if (!props.inheritedProperties?.auth || !props.inheritedProperties.headers) return [] @@ -642,10 +672,10 @@ const inheritedProperties = computed(() => { } }[] - const computedAuthHeader = getComputedAuthHeaders( + const [computedAuthHeader] = await getComputedAuthHeaders( request.value, - props.inheritedProperties.auth.inheritedAuth as HoppGQLAuth - )[0] + props.inheritedProperties.auth.inheritedAuth + ) if ( computedAuthHeader && diff --git a/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue b/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue index 17f68aa50..f54aa333a 100644 --- a/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue +++ b/packages/hoppscotch-common/src/components/graphql/RequestOptions.vue @@ -1,58 +1,56 @@ diff --git a/packages/hoppscotch-common/src/components/http/authorization/AWSSign.vue b/packages/hoppscotch-common/src/components/http/authorization/AWSSign.vue new file mode 100644 index 000000000..6b3a5d3e9 --- /dev/null +++ b/packages/hoppscotch-common/src/components/http/authorization/AWSSign.vue @@ -0,0 +1,140 @@ + + + diff --git a/packages/hoppscotch-common/src/components/http/authorization/AkamaiEG.vue b/packages/hoppscotch-common/src/components/http/authorization/AkamaiEG.vue new file mode 100644 index 000000000..99a43f096 --- /dev/null +++ b/packages/hoppscotch-common/src/components/http/authorization/AkamaiEG.vue @@ -0,0 +1,96 @@ + + + diff --git a/packages/hoppscotch-common/src/components/http/authorization/HAWK.vue b/packages/hoppscotch-common/src/components/http/authorization/HAWK.vue new file mode 100644 index 000000000..db1eebb38 --- /dev/null +++ b/packages/hoppscotch-common/src/components/http/authorization/HAWK.vue @@ -0,0 +1,152 @@ + + + diff --git a/packages/hoppscotch-common/src/components/http/authorization/NTLM.vue b/packages/hoppscotch-common/src/components/http/authorization/NTLM.vue new file mode 100644 index 000000000..28de9f804 --- /dev/null +++ b/packages/hoppscotch-common/src/components/http/authorization/NTLM.vue @@ -0,0 +1,77 @@ + + + diff --git a/packages/hoppscotch-common/src/components/http/OAuth2Authorization.vue b/packages/hoppscotch-common/src/components/http/authorization/OAuth2.vue similarity index 95% rename from packages/hoppscotch-common/src/components/http/OAuth2Authorization.vue rename to packages/hoppscotch-common/src/components/http/authorization/OAuth2.vue index afe17575a..48a76d6bf 100644 --- a/packages/hoppscotch-common/src/components/http/OAuth2Authorization.vue +++ b/packages/hoppscotch-common/src/components/http/authorization/OAuth2.vue @@ -182,11 +182,7 @@