feat: remove authName from HoppRESTAuth type definitions
This commit is contained in:
@@ -36,7 +36,6 @@
|
|||||||
label="None"
|
label="None"
|
||||||
@click.native="
|
@click.native="
|
||||||
authType = 'none'
|
authType = 'none'
|
||||||
authName = 'None'
|
|
||||||
$refs.authTypeOptions.tippy().hide()
|
$refs.authTypeOptions.tippy().hide()
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
@@ -44,7 +43,6 @@
|
|||||||
label="Basic Auth"
|
label="Basic Auth"
|
||||||
@click.native="
|
@click.native="
|
||||||
authType = 'basic'
|
authType = 'basic'
|
||||||
authName = 'Basic Auth'
|
|
||||||
$refs.authTypeOptions.tippy().hide()
|
$refs.authTypeOptions.tippy().hide()
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
@@ -52,7 +50,6 @@
|
|||||||
label="Bearer Token"
|
label="Bearer Token"
|
||||||
@click.native="
|
@click.native="
|
||||||
authType = 'bearer'
|
authType = 'bearer'
|
||||||
authName = 'Bearer Token'
|
|
||||||
$refs.authTypeOptions.tippy().hide()
|
$refs.authTypeOptions.tippy().hide()
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
@@ -174,7 +171,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, Ref, ref } from "@nuxtjs/composition-api"
|
import { computed, defineComponent, Ref, ref } from "@nuxtjs/composition-api"
|
||||||
import {
|
import {
|
||||||
HoppRESTAuthBasic,
|
HoppRESTAuthBasic,
|
||||||
HoppRESTAuthBearer,
|
HoppRESTAuthBearer,
|
||||||
@@ -187,12 +184,16 @@ export default defineComponent({
|
|||||||
setup() {
|
setup() {
|
||||||
const auth = useStream(
|
const auth = useStream(
|
||||||
restAuth$,
|
restAuth$,
|
||||||
{ authType: "none", authName: "None", authActive: true },
|
{ authType: "none", authActive: true },
|
||||||
setRESTAuth
|
setRESTAuth
|
||||||
)
|
)
|
||||||
|
|
||||||
const authType = pluckRef(auth, "authType")
|
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 authActive = pluckRef(auth, "authActive")
|
||||||
|
|
||||||
const basicUsername = pluckRef(auth as Ref<HoppRESTAuthBasic>, "username")
|
const basicUsername = pluckRef(auth as Ref<HoppRESTAuthBasic>, "username")
|
||||||
@@ -207,7 +208,6 @@ export default defineComponent({
|
|||||||
const clearContent = () => {
|
const clearContent = () => {
|
||||||
auth.value = {
|
auth.value = {
|
||||||
authType: "none",
|
authType: "none",
|
||||||
authName: "None",
|
|
||||||
authActive: true,
|
authActive: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ export default defineComponent({
|
|||||||
testScript: "",
|
testScript: "",
|
||||||
auth: {
|
auth: {
|
||||||
authType: "none",
|
authType: "none",
|
||||||
authName: "None",
|
|
||||||
authActive: true,
|
authActive: true,
|
||||||
},
|
},
|
||||||
body: {
|
body: {
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
export type HoppRESTAuthNone = {
|
export type HoppRESTAuthNone = {
|
||||||
authType: "none"
|
authType: "none"
|
||||||
authName: "None"
|
|
||||||
authActive: true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type HoppRESTAuthBasic = {
|
export type HoppRESTAuthBasic = {
|
||||||
authType: "basic"
|
authType: "basic"
|
||||||
authName: "Basic Auth"
|
|
||||||
authActive: true
|
|
||||||
|
|
||||||
username: string
|
username: string
|
||||||
password: string
|
password: string
|
||||||
@@ -15,13 +11,13 @@ export type HoppRESTAuthBasic = {
|
|||||||
|
|
||||||
export type HoppRESTAuthBearer = {
|
export type HoppRESTAuthBearer = {
|
||||||
authType: "bearer"
|
authType: "bearer"
|
||||||
authName: "Bearer Token"
|
|
||||||
authActive: true
|
|
||||||
|
|
||||||
token: string
|
token: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type HoppRESTAuth =
|
export type HoppRESTAuth =
|
||||||
|
{ authActive: boolean } & (
|
||||||
| HoppRESTAuthNone
|
| HoppRESTAuthNone
|
||||||
| HoppRESTAuthBasic
|
| HoppRESTAuthBasic
|
||||||
| HoppRESTAuthBearer
|
| HoppRESTAuthBearer
|
||||||
|
)
|
||||||
|
|||||||
@@ -124,14 +124,12 @@ export function parseOldAuth(x: any): HoppRESTAuth {
|
|||||||
if (!x.auth || x.auth === "None")
|
if (!x.auth || x.auth === "None")
|
||||||
return {
|
return {
|
||||||
authType: "none",
|
authType: "none",
|
||||||
authName: "None",
|
|
||||||
authActive: true,
|
authActive: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x.auth === "Basic Auth")
|
if (x.auth === "Basic Auth")
|
||||||
return {
|
return {
|
||||||
authType: "basic",
|
authType: "basic",
|
||||||
authName: "Basic Auth",
|
|
||||||
authActive: true,
|
authActive: true,
|
||||||
username: x.httpUser,
|
username: x.httpUser,
|
||||||
password: x.httpPassword,
|
password: x.httpPassword,
|
||||||
@@ -140,10 +138,9 @@ export function parseOldAuth(x: any): HoppRESTAuth {
|
|||||||
if (x.auth === "Bearer Token")
|
if (x.auth === "Bearer Token")
|
||||||
return {
|
return {
|
||||||
authType: "bearer",
|
authType: "bearer",
|
||||||
authName: "Bearer Token",
|
|
||||||
authActive: true,
|
authActive: true,
|
||||||
token: x.bearerToken,
|
token: x.bearerToken,
|
||||||
}
|
}
|
||||||
|
|
||||||
return { authType: "none", authName: "None", authActive: true }
|
return { authType: "none", authActive: true }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ type RESTSession = {
|
|||||||
saveContext: HoppRequestSaveContext | null
|
saveContext: HoppRequestSaveContext | null
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultRESTRequest: HoppRESTRequest = {
|
export const defaultRESTRequest: HoppRESTRequest = {
|
||||||
v: RESTReqSchemaVersion,
|
v: RESTReqSchemaVersion,
|
||||||
endpoint: "https://echo.hoppscotch.io",
|
endpoint: "https://echo.hoppscotch.io",
|
||||||
name: "Untitled request",
|
name: "Untitled request",
|
||||||
@@ -32,7 +32,6 @@ const defaultRESTRequest: HoppRESTRequest = {
|
|||||||
method: "GET",
|
method: "GET",
|
||||||
auth: {
|
auth: {
|
||||||
authType: "none",
|
authType: "none",
|
||||||
authName: "None",
|
|
||||||
authActive: true,
|
authActive: true,
|
||||||
},
|
},
|
||||||
preRequestScript: "",
|
preRequestScript: "",
|
||||||
|
|||||||
Reference in New Issue
Block a user