/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of token being revoked. */ export const TokenTypeHint = { AccessToken: "access_token", RefreshToken: "refresh_token", } as const; /** * The type of token being revoked. */ export type TokenTypeHint = ClosedEnum; export type RevokeTokenRequest = { /** * The access or refresh token to revoke. */ token: string; /** * The type of token being revoked. */ tokenTypeHint?: TokenTypeHint | undefined; /** * Client ID can be provided here in the body, or as the Username in HTTP Basic Auth. */ clientId?: string | undefined; /** * Client secret can be provided here in the body, or as the Password in HTTP Basic Auth. */ clientSecret?: string | undefined; }; /** @internal */ export const TokenTypeHint$inboundSchema: z.ZodNativeEnum< typeof TokenTypeHint > = z.nativeEnum(TokenTypeHint); /** @internal */ export const TokenTypeHint$outboundSchema: z.ZodNativeEnum< typeof TokenTypeHint > = TokenTypeHint$inboundSchema; /** @internal */ export const RevokeTokenRequest$inboundSchema: z.ZodType< RevokeTokenRequest, z.ZodTypeDef, unknown > = z.object({ token: z.string(), token_type_hint: TokenTypeHint$inboundSchema.optional(), client_id: z.string().optional(), client_secret: z.string().optional(), }).transform((v) => { return remap$(v, { "token_type_hint": "tokenTypeHint", "client_id": "clientId", "client_secret": "clientSecret", }); }); /** @internal */ export type RevokeTokenRequest$Outbound = { token: string; token_type_hint?: string | undefined; client_id?: string | undefined; client_secret?: string | undefined; }; /** @internal */ export const RevokeTokenRequest$outboundSchema: z.ZodType< RevokeTokenRequest$Outbound, z.ZodTypeDef, RevokeTokenRequest > = z.object({ token: z.string(), tokenTypeHint: TokenTypeHint$outboundSchema.optional(), clientId: z.string().optional(), clientSecret: z.string().optional(), }).transform((v) => { return remap$(v, { tokenTypeHint: "token_type_hint", clientId: "client_id", clientSecret: "client_secret", }); }); export function revokeTokenRequestToJSON( revokeTokenRequest: RevokeTokenRequest, ): string { return JSON.stringify( RevokeTokenRequest$outboundSchema.parse(revokeTokenRequest), ); } export function revokeTokenRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RevokeTokenRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RevokeTokenRequest' from JSON`, ); }