feat: added inherit auth-header for personal gql
This commit is contained in:
@@ -82,7 +82,7 @@ export function translateToNewGQLCollection(
|
||||
const folders = (x.folders ?? []).map(translateToNewGQLCollection)
|
||||
const requests = (x.requests ?? []).map(translateToGQLRequest)
|
||||
|
||||
const auth = x.auth ?? "None"
|
||||
const auth = x.auth ?? { authType: "inherit", authActive: true }
|
||||
const headers = x.headers ?? []
|
||||
|
||||
const obj = makeCollection<HoppGQLRequest>({
|
||||
|
||||
@@ -11,6 +11,7 @@ export {
|
||||
HoppGQLAuthBearer,
|
||||
HoppGQLAuthNone,
|
||||
HoppGQLAuthOAuth2,
|
||||
HoppGQLAuthInherit,
|
||||
} from "./v/2"
|
||||
|
||||
export const GQL_REQ_SCHEMA_VERSION = 2
|
||||
|
||||
@@ -3,7 +3,7 @@ import { defineVersion } from "verzod"
|
||||
import { GQLHeader, V1_SCHEMA } from "./1"
|
||||
|
||||
export const HoppGQLAuthNone = z.object({
|
||||
authType: z.literal("none")
|
||||
authType: z.literal("none"),
|
||||
})
|
||||
|
||||
export type HoppGQLAuthNone = z.infer<typeof HoppGQLAuthNone>
|
||||
@@ -12,7 +12,7 @@ export const HoppGQLAuthBasic = z.object({
|
||||
authType: z.literal("basic"),
|
||||
|
||||
username: z.string().catch(""),
|
||||
password: z.string().catch("")
|
||||
password: z.string().catch(""),
|
||||
})
|
||||
|
||||
export type HoppGQLAuthBasic = z.infer<typeof HoppGQLAuthBasic>
|
||||
@@ -20,7 +20,7 @@ export type HoppGQLAuthBasic = z.infer<typeof HoppGQLAuthBasic>
|
||||
export const HoppGQLAuthBearer = z.object({
|
||||
authType: z.literal("bearer"),
|
||||
|
||||
token: z.string().catch("")
|
||||
token: z.string().catch(""),
|
||||
})
|
||||
|
||||
export type HoppGQLAuthBearer = z.infer<typeof HoppGQLAuthBearer>
|
||||
@@ -33,7 +33,7 @@ export const HoppGQLAuthOAuth2 = z.object({
|
||||
authURL: z.string().catch(""),
|
||||
accessTokenURL: z.string().catch(""),
|
||||
clientID: z.string().catch(""),
|
||||
scope: z.string().catch("")
|
||||
scope: z.string().catch(""),
|
||||
})
|
||||
|
||||
export type HoppGQLAuthOAuth2 = z.infer<typeof HoppGQLAuthOAuth2>
|
||||
@@ -43,22 +43,31 @@ export const HoppGQLAuthAPIKey = z.object({
|
||||
|
||||
key: z.string().catch(""),
|
||||
value: z.string().catch(""),
|
||||
addTo: z.string().catch("Headers")
|
||||
addTo: z.string().catch("Headers"),
|
||||
})
|
||||
|
||||
export type HoppGQLAuthAPIKey = z.infer<typeof HoppGQLAuthAPIKey>
|
||||
|
||||
export const HoppGQLAuth = z.discriminatedUnion("authType", [
|
||||
HoppGQLAuthNone,
|
||||
HoppGQLAuthBasic,
|
||||
HoppGQLAuthBearer,
|
||||
HoppGQLAuthOAuth2,
|
||||
HoppGQLAuthAPIKey
|
||||
]).and(
|
||||
z.object({
|
||||
authActive: z.boolean()
|
||||
})
|
||||
)
|
||||
export const HoppGQLAuthInherit = z.object({
|
||||
authType: z.literal("inherit"),
|
||||
})
|
||||
|
||||
export type HoppGQLAuthInherit = z.infer<typeof HoppGQLAuthInherit>
|
||||
|
||||
export const HoppGQLAuth = z
|
||||
.discriminatedUnion("authType", [
|
||||
HoppGQLAuthNone,
|
||||
HoppGQLAuthBasic,
|
||||
HoppGQLAuthBearer,
|
||||
HoppGQLAuthOAuth2,
|
||||
HoppGQLAuthAPIKey,
|
||||
HoppGQLAuthInherit,
|
||||
])
|
||||
.and(
|
||||
z.object({
|
||||
authActive: z.boolean(),
|
||||
})
|
||||
)
|
||||
|
||||
export type HoppGQLAuth = z.infer<typeof HoppGQLAuth>
|
||||
|
||||
@@ -72,7 +81,7 @@ const V2_SCHEMA = z.object({
|
||||
query: z.string(),
|
||||
variables: z.string(),
|
||||
|
||||
auth: HoppGQLAuth
|
||||
auth: HoppGQLAuth,
|
||||
})
|
||||
|
||||
export default defineVersion({
|
||||
@@ -85,7 +94,7 @@ export default defineVersion({
|
||||
auth: {
|
||||
authActive: true,
|
||||
authType: "none",
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user