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: remove authName from HoppRESTAuth type definitions

Andrew Bastin1a4fc1f539bd
diff --git a/components/http/Authorization.vue b/components/http/Authorization.vue
index 2213764e4..1139b8a17 100644
--- a/components/http/Authorization.vue
+++ b/components/http/Authorization.vue
@@ -36,7 +36,6 @@
label="None"
@click.native="
authType = 'none'
- authName = 'None'
$refs.authTypeOptions.tippy().hide()
"
/>
@@ -44,7 +43,6 @@
label="Basic Auth"
@click.native="
authType = 'basic'
- authName = 'Basic Auth'
$refs.authTypeOptions.tippy().hide()
"
/>
@@ -52,7 +50,6 @@
label="Bearer Token"
@click.native="
authType = 'bearer'
- authName = 'Bearer Token'
$refs.authTypeOptions.tippy().hide()
"
/>
@@ -174,7 +171,7 @@
</template>
<script lang="ts">
-import { defineComponent, Ref, ref } from "@nuxtjs/composition-api"
+import { computed, defineComponent, Ref, ref } from "@nuxtjs/composition-api"
import {
HoppRESTAuthBasic,
HoppRESTAuthBearer,
@@ -187,12 +184,16 @@ export default defineComponent({
setup() {
const auth = useStream(
restAuth$,
- { authType: "none", authName: "None", authActive: true },
+ { authType: "none", authActive: true },
setRESTAuth
)
const authType = pluckRef(auth, "authType")
- const authName = pluckRef(auth, "authName")
+ const authName = computed(() => {
+ if (authType.value === "basic") return "Basic Auth"
+ else if (authType.value === "bearer") return "Bearer"
+ else return "None"
+ })
const authActive = pluckRef(auth, "authActive")
const basicUsername = pluckRef(auth as Ref<HoppRESTAuthBasic>, "username")
@@ -207,7 +208,6 @@ export default defineComponent({
const clearContent = () => {
auth.value = {
authType: "none",
- authName: "None",
authActive: true,
}
}
diff --git a/components/http/ImportCurl.vue b/components/http/ImportCurl.vue
index caf15e6bf..10874cda9 100644
--- a/components/http/ImportCurl.vue
+++ b/components/http/ImportCurl.vue
@@ -116,7 +116,6 @@ export default defineComponent({
testScript: "",
auth: {
authType: "none",
- authName: "None",
authActive: true,
},
body: {
diff --git a/helpers/types/HoppRESTAuth.ts b/helpers/types/HoppRESTAuth.ts
index de82e4ff8..e9048863a 100644
--- a/helpers/types/HoppRESTAuth.ts
+++ b/helpers/types/HoppRESTAuth.ts
@@ -1,13 +1,9 @@
export type HoppRESTAuthNone = {
authType: "none"
- authName: "None"
- authActive: true
}
export type HoppRESTAuthBasic = {
authType: "basic"
- authName: "Basic Auth"
- authActive: true
username: string
password: string
@@ -15,13 +11,13 @@ export type HoppRESTAuthBasic = {
export type HoppRESTAuthBearer = {
authType: "bearer"
- authName: "Bearer Token"
- authActive: true
token: string
}
export type HoppRESTAuth =
+ { authActive: boolean } & (
| HoppRESTAuthNone
| HoppRESTAuthBasic
| HoppRESTAuthBearer
+)
diff --git a/helpers/types/HoppRESTRequest.ts b/helpers/types/HoppRESTRequest.ts
index b789f0198..2c18ec1d5 100644
--- a/helpers/types/HoppRESTRequest.ts
+++ b/helpers/types/HoppRESTRequest.ts
@@ -124,14 +124,12 @@ export function parseOldAuth(x: any): HoppRESTAuth {
if (!x.auth || x.auth === "None")
return {
authType: "none",
- authName: "None",
authActive: true,
}
if (x.auth === "Basic Auth")
return {
authType: "basic",
- authName: "Basic Auth",
authActive: true,
username: x.httpUser,
password: x.httpPassword,
@@ -140,10 +138,9 @@ export function parseOldAuth(x: any): HoppRESTAuth {
if (x.auth === "Bearer Token")
return {
authType: "bearer",
- authName: "Bearer Token",
authActive: true,
token: x.bearerToken,
}
- return { authType: "none", authName: "None", authActive: true }
+ return { authType: "none", authActive: true }
}
diff --git a/newstore/RESTSession.ts b/newstore/RESTSession.ts
index 3377bbb05..ee668875a 100644
--- a/newstore/RESTSession.ts
+++ b/newstore/RESTSession.ts
@@ -23,7 +23,7 @@ type RESTSession = {
saveContext: HoppRequestSaveContext | null
}
-const defaultRESTRequest: HoppRESTRequest = {
+export const defaultRESTRequest: HoppRESTRequest = {
v: RESTReqSchemaVersion,
endpoint: "https://echo.hoppscotch.io",
name: "Untitled request",
@@ -32,7 +32,6 @@ const defaultRESTRequest: HoppRESTRequest = {
method: "GET",
auth: {
authType: "none",
- authName: "None",
authActive: true,
},
preRequestScript: "",