Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

feat: introduce personal access tokens for authorization (#4094)

James George021ecf17ce5a
diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.json
index 2ab5f041c..99fe9cd9a 100644
--- a/packages/hoppscotch-common/locales/en.json
+++ b/packages/hoppscotch-common/locales/en.json
@@ -208,7 +208,8 @@
"remove_telemetry": "Are you sure you want to opt-out of Telemetry?",
"request_change": "Are you sure you want to discard current request, unsaved changes will be lost.",
"save_unsaved_tab": "Do you want to save changes made in this tab?",
- "sync": "Would you like to restore your workspace from cloud? This will discard your local progress."
+ "sync": "Would you like to restore your workspace from cloud? This will discard your local progress.",
+ "delete_access_token": "Are you sure you want to delete the access token {tokenLabel}?"
},
"context_menu": {
"add_parameters": "Add to parameters",
@@ -270,7 +271,8 @@
"subscription": "Subscriptions are empty",
"team_name": "Workspace name empty",
"teams": "You don't belong to any workspaces",
- "tests": "There are no tests for this request"
+ "tests": "There are no tests for this request",
+ "access_tokens": "Access tokens are empty"
},
"environment": {
"add_to_global": "Add to Global",
@@ -342,7 +344,10 @@
"script_fail": "Could not execute pre-request script",
"something_went_wrong": "Something went wrong",
"test_script_fail": "Could not execute post-request script",
- "reading_files": "Error while reading one or more files."
+ "reading_files": "Error while reading one or more files.",
+ "fetching_access_tokens_list": "Something went wrong while fetching the list of tokens",
+ "generate_access_token": "Something went wrong while generating the access token",
+ "delete_access_token": "Something went wrong while deleting the access token"
},
"export": {
"as_json": "Export as JSON",
@@ -1033,5 +1038,27 @@
"login_to_continue": "Login to continue",
"login_to_continue_description": "You need to be logged in to access this Hoppscotch Enterprise Instance.",
"error_fetching_site_protection_status": "Something Went Wrong While Fetching Site Protection Status"
+ },
+ "access_tokens": {
+ "tab_title": "Tokens",
+ "section_title": "Personal Access Tokens",
+ "section_description": "Personal access tokens currently helps you connect the CLI to your Hoppscotch account",
+ "last_used_on": "Last used on",
+ "expires_on": "Expires on",
+ "no_expiration": "No expiration",
+ "expired": "Expired",
+ "copy_token_warning": "Make sure to copy your personal access token now. You won't be able to see it again!",
+ "token_purpose": "What's this token for?",
+ "expiration_label": "Expiration",
+ "scope_label": "Scope",
+ "workspace_read_only_access": "Read-only access to workspace data.",
+ "personal_workspace_access_limitation": "Personal Access Tokens can't access your personal workspace.",
+ "generate_token": "Generate Token",
+ "invalid_label": "Please provide a label for the token",
+ "no_expiration_verbose": "This token will never expire!",
+ "token_expires_on": "This token will expire on",
+ "generate_new_token": "Generate new token",
+ "generate_modal_title": "New Personal Access Token",
+ "deletion_success": "The access token {label} has been deleted"
}
}
diff --git a/packages/hoppscotch-common/src/components.d.ts b/packages/hoppscotch-common/src/components.d.ts
index 4ecf1d3b6..76b467152 100644
--- a/packages/hoppscotch-common/src/components.d.ts
+++ b/packages/hoppscotch-common/src/components.d.ts
@@ -1,216 +1,223 @@
// generated by unplugin-vue-components
// We suggest you to commit this file into source control
// Read more: https://github.com/vuejs/core/pull/3399
-import '@vue/runtime-core'
+import "@vue/runtime-core"
export {}
-declare module '@vue/runtime-core' {
+declare module "@vue/runtime-core" {
export interface GlobalComponents {
- 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']
- 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']
- 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']
- 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']
- 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']
- 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']
- 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']
- HttpCodegenModal: typeof import('./components/http/CodegenModal.vue')['default']
- HttpHeaders: typeof import('./components/http/Headers.vue')['default']
- HttpImportCurl: typeof import('./components/http/ImportCurl.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']
- 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']
- 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']
- 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']
- 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']
+ AccessTokens: (typeof import("./components/accessTokens/index.vue"))["default"]
+ AccessTokensGenerate: (typeof import("./components/accessTokens/Generate.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"]
+ 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"]
+ 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"]
+ 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"]
+ 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"]
+ 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"]
+ 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"]
+ HttpCodegenModal: (typeof import("./components/http/CodegenModal.vue"))["default"]
+ HttpHeaders: (typeof import("./components/http/Headers.vue"))["default"]
+ HttpImportCurl: (typeof import("./components/http/ImportCurl.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"]
+ 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"]
+ IconLucideRss: (typeof import("~icons/lucide/rss"))["default"]
+ IconLucideSearch: (typeof import("~icons/lucide/search"))["default"]
+ IconLucideUsers: (typeof import("~icons/lucide/users"))["default"]
+ IconLucideVerified: (typeof import("~icons/lucide/verified"))["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"]
+ 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"]
+ 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/accessTokens/GenerateModal.vue b/packages/hoppscotch-common/src/components/accessTokens/GenerateModal.vue
new file mode 100644
index 000000000..b368d7566
--- /dev/null
+++ b/packages/hoppscotch-common/src/components/accessTokens/GenerateModal.vue
@@ -0,0 +1,221 @@
+<template>
+ <HoppSmartModal
+ dialog
+ :title="t('access_tokens.generate_modal_title')"
+ @close="hideModal"
+ >
+ <template #body>
+ <template v-if="accessToken">
+ <p class="p-4 mb-4 border rounded-md text-amber-500 border-amber-600">
+ {{ t("access_tokens.copy_token_warning") }}
+ </p>
+
+ <div
+ class="flex items-center justify-between p-4 mt-4 rounded-md bg-primaryLight"
+ >
+ <div class="text-secondaryDark">{{ accessToken }}</div>
+ <HoppButtonSecondary
+ outline
+ filled
+ :icon="copyIcon"
+ @click="copyAccessToken"
+ />
+ </div>
+ </template>
+
+ <div v-else class="space-y-4">
+ <div class="space-y-2">
+ <div class="font-semibold text-secondaryDark">
+ {{ t("action.label") }}
+ </div>
+ <HoppSmartInput
+ v-model="accessTokenLabel"
+ :placeholder="t('access_tokens.token_purpose')"
+ />
+ </div>
+
+ <div class="space-y-2">
+ <label for="expiration" class="font-semibold text-secondaryDark">{{
+ t("access_tokens.expiration_label")
+ }}</label>
+
+ <div class="grid items-center grid-cols-2 gap-x-2">
+ <tippy
+ interactive
+ trigger="click"
+ theme="popover"
+ :on-shown="() => tippyActions?.focus()"
+ >
+ <HoppSmartSelectWrapper>
+ <input
+ id="expiration"
+ :value="expiration"
+ readonly
+ class="flex flex-1 px-4 py-2 bg-transparent border rounded cursor-pointer border-divider"
+ />
+ </HoppSmartSelectWrapper>
+
+ <template #content="{ hide }">
+ <div
+ ref="tippyActions"
+ tabindex="0"
+ role="menu"
+ class="flex flex-col focus:outline-none"
+ @keyup.escape="hide"
+ >
+ <HoppSmartItem
+ v-for="expirationOption in Object.keys(expirationOptions)"
+ :key="expirationOption"
+ :label="expirationOption"
+ :icon="
+ expirationOption === expiration
+ ? IconCircleDot
+ : IconCircle
+ "
+ :active="expirationOption === expiration"
+ :aria-selected="expirationOption === expiration"
+ @click="
+ () => {
+ expiration = expirationOption
+ hide()
+ }
+ "
+ />
+ </div>
+ </template>
+ </tippy>
+
+ <span class="text-secondaryLight">{{ expirationDateText }}</span>
+ </div>
+ </div>
+
+ <div class="space-y-2">
+ <div class="font-semibold text-secondaryDark">
+ {{ t("access_tokens.scope_label") }}
+ </div>
+
+ <p class="text-secondaryLight">
+ {{ t("access_tokens.workspace_read_only_access") }}<br />
+ {{ t("access_tokens.personal_workspace_access_limitation") }}
+ </p>
+ </div>
+ </div>
+ </template>
+ <template #footer>
+ <HoppButtonSecondary
+ v-if="accessToken"
+ :label="t('action.close')"
+ outline
+ filled
+ @click="hideModal"
+ />
+
+ <div v-else class="flex items-center gap-x-2">
+ <HoppButtonPrimary
+ :loading="tokenGenerateActionLoading"
+ filled
+ outline
+ :label="t('access_tokens.generate_token')"
+ @click="generateAccessToken"
+ />
+
+ <HoppButtonSecondary
+ :label="t('action.cancel')"
+ outline
+ filled
+ @click="hideModal"
+ />
+ </div>
+ </template>
+ </HoppSmartModal>
+</template>
+
+<script setup lang="ts">
+import { useI18n } from "@composables/i18n"
+import { useToast } from "@composables/toast"
+import { refAutoReset } from "@vueuse/core"
+import { VNodeRef, computed, ref } from "vue"
+
+import { copyToClipboard } from "~/helpers/utils/clipboard"
+import { shortDateTime } from "~/helpers/utils/date"
+
+import IconCheck from "~icons/lucide/check"
+import IconCircle from "~icons/lucide/circle"
+import IconCircleDot from "~icons/lucide/circle-dot"
+import IconCopy from "~icons/lucide/copy"
+
+const t = useI18n()
+const toast = useToast()
+
+const props = defineProps<{
+ tokenGenerateActionLoading: boolean
+ accessToken: string | null
+}>()
+
+const emit = defineEmits<{
+ (e: "hide-modal"): void
+ (
+ e: "generate-access-token",
+ { label, expiryInDays }: { label: string; expiryInDays: number | null }
+ ): void
+}>()
+
+// Template refs
+const tippyActions = ref<VNodeRef | null>(null)
+
+const copyIcon = refAutoReset<typeof IconCopy | typeof IconCheck>(
+ IconCopy,
+ 1000
+)
+
+const accessTokenLabel = ref<string>("")
+const expiration = ref<string>("30 days")
+
+const expirationOptions: Record<string, number | null> = {
+ "7 days": 7,
+ "30 days": 30,
+ "60 days": 60,
+ "90 days": 90,
+ "No expiration": null,
+}
+
+const expirationDateText = computed(() => {
+ const chosenExpiryInDays = expirationOptions[expiration.value]
+
+ if (chosenExpiryInDays === null) {
+ return t("access_tokens.no_expiration_verbose")
+ }
+
+ const currentDate = new Date()
+ currentDate.setDate(currentDate.getDate() + chosenExpiryInDays)
+
+ const expirationDate = shortDateTime(currentDate, false)
+ return `${t("access_tokens.token_expires_on")} ${expirationDate}`
+})
+
+const copyAccessToken = () => {
+ if (!props.accessToken) {
+ toast.error("error.something_went_wrong")
+ return
+ }
+
+ copyToClipboard(props.accessToken)
+ copyIcon.value = IconCheck
+
+ toast.success(`${t("state.copied_to_clipboard")}`)
+}
+
+const generateAccessToken = async () => {
+ if (!accessTokenLabel.value) {
+ toast.error(t("access_tokens.invalid_label"))
+ return
+ }
+
+ emit("generate-access-token", {
+ label: accessTokenLabel.value,
+ expiryInDays: expirationOptions[expiration.value],
+ })
+}
+
+const hideModal = () => emit("hide-modal")
+</script>
diff --git a/packages/hoppscotch-common/src/components/accessTokens/List.vue b/packages/hoppscotch-common/src/components/accessTokens/List.vue
new file mode 100644
index 000000000..220738cdc
--- /dev/null
+++ b/packages/hoppscotch-common/src/components/accessTokens/List.vue
@@ -0,0 +1,128 @@
+<template>
+ <div v-if="isInitialPageLoad" class="flex flex-col items-center py-3">
+ <HoppSmartSpinner />
+ </div>
+
+ <div
+ v-else-if="initialPageLoadHasError"
+ class="flex flex-col items-center py-4"
+ >
+ <icon-lucide-help-circle class="mb-4 svg-icons" />
+ {{ t("error.something_went_wrong") }}
+ </div>
+
+ <HoppSmartPlaceholder
+ v-else-if="accessTokens.length === 0"
+ :src="`/images/states/${colorMode}/pack.svg`"
+ :alt="`${t('empty.access_tokens')}`"
+ :text="t('empty.access_tokens')"
+ @drop.stop
+ />
+
+ <div
+ v-else
+ class="grid gap-4 p-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"
+ >
+ <div
+ v-for="{ id, label, lastUsedOn, expiresOn } in accessTokens"
+ :key="id"
+ class="flex flex-col items-center gap-4 p-4 border rounded border-divider"
+ >
+ <div class="w-full text-sm font-semibold truncate text-secondaryDark">
+ {{ label }}
+ </div>
+
+ <div class="flex items-center justify-between w-full gap-x-4">
+ <div class="space-y-1 text-secondaryLight">
+ <div class="space-x-1">
+ <span class="font-semibold"
+ >{{ t("access_tokens.last_used_on") }}:</span
+ >
+ <span>
+ {{ shortDateTime(lastUsedOn, false) }}
+ </span>
+ </div>
+
+ <div class="space-x-1">
+ <span class="font-semibold"
+ >{{ t("access_tokens.expires_on") }}:</span
+ >
+ <span>
+ {{ getTokenExpiryText(expiresOn) }}
+ </span>
+ </div>
+ </div>
+
+ <HoppButtonSecondary
+ :label="t('action.delete')"
+ filled
+ outline
+ @click="
+ emit('delete-access-token', {
+ tokenId: id,
+ tokenLabel: label,
+ })
+ "
+ />
+ </div>
+ </div>
+ </div>
+
+ <HoppSmartIntersection
+ v-if="hasMoreTokens"
+ @intersecting="emit('fetch-more-tokens')"
+ >
+ <div v-if="loading" class="flex flex-col items-center py-3">
+ <HoppSmartSpinner />
+ </div>
+
+ <div v-else-if="hasError" class="flex flex-col items-center py-4">
+ <icon-lucide-help-circle class="mb-4 svg-icons" />
+ {{ t("error.something_went_wrong") }}
+ </div>
+ </HoppSmartIntersection>
+</template>
+
+<script setup lang="ts">
+import { useI18n } from "@composables/i18n"
+import { useColorMode } from "@vueuse/core"
+import { computed } from "vue"
+
+import { shortDateTime } from "~/helpers/utils/date"
+import { AccessToken } from "./index.vue"
+
+const colorMode = useColorMode()
+const t = useI18n()
+
+const props = defineProps<{
+ accessTokens: AccessToken[]
+ hasMoreTokens: boolean
+ loading: boolean
+ hasError: boolean
+}>()
+
+const emit = defineEmits<{
+ (e: "fetch-more-tokens"): void
+ (
+ e: "delete-access-token",
+ { tokenId, tokenLabel }: { tokenId: string; tokenLabel: string }
+ ): void
+}>()
+
+const isInitialPageLoad = computed(() => props.loading && !props.hasMoreTokens)
+const initialPageLoadHasError = computed(
+ () => props.hasError && !props.hasMoreTokens
+)
+
+const getTokenExpiryText = (tokenExpiresOn: string | null) => {
+ if (!tokenExpiresOn) {
+ return t("access_tokens.no_expiration")
+ }
+
+ const isTokenExpired = new Date(tokenExpiresOn).toISOString() > tokenExpiresOn
+
+ return isTokenExpired
+ ? t("access_tokens.expired")
+ : shortDateTime(tokenExpiresOn, false)
+}
+</script>
diff --git a/packages/hoppscotch-common/src/components/accessTokens/Overview.vue b/packages/hoppscotch-common/src/components/accessTokens/Overview.vue
new file mode 100644
index 000000000..0b60e5dff
--- /dev/null
+++ b/packages/hoppscotch-common/src/components/accessTokens/Overview.vue
@@ -0,0 +1,30 @@
+<template>
+ <div class="p-4 space-y-4">
+ <div class="space-y-1">
+ <h4 class="font-semibold text-secondaryDark">
+ {{ t("access_tokens.section_title") }}
+ </h4>
+
+ <p class="text-secondaryLight">
+ {{ t("access_tokens.section_description") }}
+ </p>
+ </div>
+
+ <HoppButtonSecondary
+ filled
+ outline
+ :label="t('access_tokens.generate_new_token')"
+ @click="emit('show-access-tokens-generate-modal')"
+ />
+ </div>
+</template>
+
+<script setup lang="ts">
+import { useI18n } from "~/composables/i18n"
+
+const t = useI18n()
+
+const emit = defineEmits<{
+ (e: "show-access-tokens-generate-modal"): void
+}>()
+</script>
diff --git a/packages/hoppscotch-common/src/components/accessTokens/index.vue b/packages/hoppscotch-common/src/components/accessTokens/index.vue
new file mode 100644
index 000000000..ef33b5268
--- /dev/null
+++ b/packages/hoppscotch-common/src/components/accessTokens/index.vue
@@ -0,0 +1,208 @@
+<template>
+ <AccessTokensOverview
+ @show-access-tokens-generate-modal="showAccessTokensGenerateModal = true"
+ />
+
+ <AccessTokensList
+ :access-tokens="accessTokens"
+ :has-error="tokensListFetchErrored"
+ :has-more-tokens="hasMoreTokens"
+ :loading="tokensListLoading"
+ @delete-access-token="displayDeleteAccessTokenConfirmationModal"
+ @fetch-more-tokens="fetchAccessTokens"
+ />
+
+ <AccessTokensGenerateModal
+ v-if="showAccessTokensGenerateModal"
+ :access-token="accessToken"
+ :token-generate-action-loading="tokenGenerateActionLoading"
+ @generate-access-token="generateAccessToken"
+ @hide-modal="hideAccessTokenGenerateModal"
+ />
+
+ <HoppSmartConfirmModal
+ :show="confirmDeleteAccessToken"
+ :loading-state="tokenDeleteActionLoading"
+ :title="
+ t('confirm.delete_access_token', { tokenLabel: tokenToDelete?.label })
+ "
+ @hide-modal="confirmDeleteAccessToken = false"
+ @resolve="deleteAccessToken"
+ />
+</template>
+
+<script setup lang="ts">
+import axios from "axios"
+import { Ref, onMounted, ref } from "vue"
+import { platform } from "~/platform"
+
+import { useI18n } from "@composables/i18n"
+import { useToast } from "@composables/toast"
+
+export type AccessToken = {
+ id: string
+ label: string
+ createdOn: string
+ lastUsedOn: string
+ expiresOn: string | null
+}
+
+const t = useI18n()
+const toast = useToast()
+
+const confirmDeleteAccessToken = ref(false)
+const hasMoreTokens = ref(false)
+const showAccessTokensGenerateModal = ref(false)
+const tokenDeleteActionLoading = ref(false)
+const tokenGenerateActionLoading = ref(false)
+const tokensListFetchErrored = ref(false)
+const tokensListLoading = ref(false)
+
+const accessToken: Ref<string | null> = ref(null)
+const tokenToDelete = ref<{ id: string; label: string } | null>(null)
+
+const accessTokens: Ref<AccessToken[]> = ref([])
+
+const limit = 12
+let offset = 0
+
+const endpointPrefix = `${import.meta.env.VITE_BACKEND_API_URL}/access-tokens`
+
+const getAxiosPlatformConfig = async () => {
+ await platform.auth.waitProbableLoginToConfirm()
+ return platform.auth.axiosPlatformConfig?.() ?? {}
+}
+
+onMounted(async () => {
+ await fetchAccessTokens()
+})
+
+const fetchAccessTokens = async () => {
+ tokensListLoading.value = true
+
+ const axiosConfig = await getAxiosPlatformConfig()
+ const endpoint = `${endpointPrefix}/list?offset=${offset}&limit=${limit}`
+
+ try {
+ const { data } = await axios.get(endpoint, axiosConfig)
+
+ accessTokens.value.push(...data)
+
+ if (data.length > 0) {
+ offset += data.length
+ }
+
+ hasMoreTokens.value = data.length === limit
+
+ if (tokensListFetchErrored.value) {
+ tokensListFetchErrored.value = false
+ }
+ } catch (err) {
+ toast.error(t("error.fetching_access_tokens_list"))
+ tokensListFetchErrored.value = true
+ } finally {
+ tokensListLoading.value = false
+ }
+}
+
+const generateAccessToken = async ({
+ label,
+ expiryInDays,
+}: {
+ label: string
+ expiryInDays: number | null
+}) => {
+ tokenGenerateActionLoading.value = true
+
+ const axiosConfig = await getAxiosPlatformConfig()
+ const endpoint = `${endpointPrefix}/create`
+
+ const body = {
+ label,
+ expiryInDays,
+ }
+
+ try {
+ const { data }: { data: { token: string; info: AccessToken } } =
+ await axios.post(endpoint, body, axiosConfig)
+
+ accessTokens.value.unshift(data.info)
+ accessToken.value = data.token
+
+ // Incrementing the offset value by 1 to account for the newly generated token
+ offset += 1
+
+ // Toggle the error state in case it was set
+ if (tokensListFetchErrored.value) {
+ tokensListFetchErrored.value = false
+ }
+ } catch (err) {
+ toast.error(t("error.generate_access_token"))
+ showAccessTokensGenerateModal.value = false
+ } finally {
+ tokenGenerateActionLoading.value = false
+ }
+}
+
+const deleteAccessToken = async () => {
+ if (tokenToDelete.value === null) {
+ toast.error(t("error.something_went_wrong"))
+ return
+ }
+
+ const { id: tokenIdToDelete, label: tokenLabelToDelete } = tokenToDelete.value
+
+ tokenDeleteActionLoading.value = true
+
+ const axiosConfig = await getAxiosPlatformConfig()
+ const endpoint = `${endpointPrefix}/revoke?id=${tokenIdToDelete}`
+
+ try {
+ await axios.delete(endpoint, axiosConfig)
+
+ accessTokens.value = accessTokens.value.filter(
+ (token) => token.id !== tokenIdToDelete
+ )
+
+ // Decreasing the offset value by 1 to account for the deleted token
+ offset = offset > 0 ? offset - 1 : offset
+
+ toast.success(
+ t("access_tokens.deletion_success", { label: tokenLabelToDelete })
+ )
+
+ // Toggle the error state in case it was set
+ if (tokensListFetchErrored.value) {
+ tokensListFetchErrored.value = false
+ }
+ } catch (err) {
+ toast.error(t("error.delete_access_token"))
+ } finally {
+ tokenDeleteActionLoading.value = false
+ confirmDeleteAccessToken.value = false
+
+ tokenToDelete.value = null
+ }
+}
+
+const hideAccessTokenGenerateModal = () => {
+ // Reset the reactive state variable holding access token value and hide the modal
+ accessToken.value = null
+ showAccessTokensGenerateModal.value = false
+}
+
+const displayDeleteAccessTokenConfirmationModal = ({
+ tokenId,
+ tokenLabel,
+}: {
+ tokenId: string
+ tokenLabel: string
+}) => {
+ confirmDeleteAccessToken.value = true
+
+ tokenToDelete.value = {
+ id: tokenId,
+ label: tokenLabel,
+ }
+}
+</script>
diff --git a/packages/hoppscotch-common/src/helpers/utils/date.ts b/packages/hoppscotch-common/src/helpers/utils/date.ts
index ea064959f..ee7b8d3c8 100644
--- a/packages/hoppscotch-common/src/helpers/utils/date.ts
+++ b/packages/hoppscotch-common/src/helpers/utils/date.ts
@@ -1,10 +1,17 @@
-export function shortDateTime(date: string | number | Date) {
+export function shortDateTime(
+ date: string | number | Date,
+ includeTime: boolean = true
+) {
return new Date(date).toLocaleString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
- hour: "numeric",
- minute: "numeric",
- second: "numeric",
+ ...(includeTime
+ ? {
+ hour: "numeric",
+ minute: "numeric",
+ second: "numeric",
+ }
+ : {}),
})
}
diff --git a/packages/hoppscotch-common/src/pages/profile.vue b/packages/hoppscotch-common/src/pages/profile.vue
index 31aadb526..1ea50cb83 100644
--- a/packages/hoppscotch-common/src/pages/profile.vue
+++ b/packages/hoppscotch-common/src/pages/profile.vue
@@ -76,7 +76,7 @@
styles="sticky overflow-x-auto flex-shrink-0 bg-primary top-0 z-10"
render-inactive-tabs
>
- <HoppSmartTab :id="'sync'" :label="t('settings.account')">
+ <HoppSmartTab id="sync" :label="t('settings.account')">
<div class="grid grid-cols-1">
<section class="p-4">
<h4 class="font-semibold text-secondaryDark">
@@ -177,14 +177,17 @@
</template>
</template>
- <ProfileShortcodes />
-
<ProfileUserDelete />
</div>
</HoppSmartTab>
- <HoppSmartTab :id="'teams'" :label="t('team.title')">
+
+ <HoppSmartTab id="teams" :label="t('team.title')">
<Teams :modal="false" class="p-4" />
</HoppSmartTab>
+
+ <HoppSmartTab id="tokens" :label="t('access_tokens.tab_title')">
+ <AccessTokens />
+ </HoppSmartTab>
</HoppSmartTabs>
</div>
</div>
@@ -193,24 +196,23 @@
</template>
<script setup lang="ts">
-import { ref, watchEffect, computed } from "vue"
+import * as E from "fp-ts/Either"
+import { computed, ref, watchEffect } from "vue"
import { platform } from "~/platform"
-import { invokeAction } from "~/helpers/actions"
-import { useReadonlyStream } from "@composables/stream"
+import { usePageHead } from "@composables/head"
import { useI18n } from "@composables/i18n"
-import { useToast } from "@composables/toast"
import { useSetting } from "@composables/settings"
+import { useReadonlyStream } from "@composables/stream"
import { useColorMode } from "@composables/theming"
-import { usePageHead } from "@composables/head"
+import { useToast } from "@composables/toast"
+import { invokeAction } from "~/helpers/actions"
import { toggleSetting } from "~/newstore/settings"
-import IconVerified from "~icons/lucide/verified"
import IconSettings from "~icons/lucide/settings"
-
-import * as E from "fp-ts/Either"
+import IconVerified from "~icons/lucide/verified"
type ProfileTabs = "sync" | "teams"
diff --git a/packages/hoppscotch-common/src/platform/auth.ts b/packages/hoppscotch-common/src/platform/auth.ts
index f5f753242..883f8e473 100644
--- a/packages/hoppscotch-common/src/platform/auth.ts
+++ b/packages/hoppscotch-common/src/platform/auth.ts
@@ -148,6 +148,7 @@ export type AuthPlatformDef = {
* called by the platform to provide additional/different config options when
* sending requests with axios
* eg: SH needs to include cookies in the request, while Central doesn't and throws a cors error if it does
+ * Ensure to invoke `platform.auth.waitProbableLoginToConfirm()` before accessing
*
* @returns AxiosRequestConfig
*/