/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { DeletedBuild, DeletedBuild$inboundSchema, DeletedBuild$Outbound, DeletedBuild$outboundSchema, } from "./deletedbuild.js"; /** * Enable google auth for your application. */ export type Google = { /** * A Google generated token representing the developer's credentials for [Google's API Console](https://console.cloud.google.com/apis/dashboard?pli=1&project=discourse-login-388921). Learn how to get a `clientId` [here](https://developers.google.com/identity/gsi/web/guides/get-google-api-clientid). */ clientId: string; }; /** * Configure [player authentication](https://hathora.dev/docs/backend-integrations/lobbies-and-matchmaking/auth-service) for your application. Use Hathora's built-in auth providers or use your own [custom authentication](https://hathora.dev/docs/lobbies-and-matchmaking/auth-service#custom-auth-provider). */ export type AuthConfiguration = { /** * Enable google auth for your application. */ google?: Google | undefined; /** * Construct a type with a set of properties K of type T */ nickname?: DeletedBuild | undefined; /** * Construct a type with a set of properties K of type T */ anonymous?: DeletedBuild | undefined; }; /** @internal */ export const Google$inboundSchema: z.ZodType = z .object({ clientId: z.string(), }); /** @internal */ export type Google$Outbound = { clientId: string; }; /** @internal */ export const Google$outboundSchema: z.ZodType< Google$Outbound, z.ZodTypeDef, Google > = z.object({ clientId: z.string(), }); export function googleToJSON(google: Google): string { return JSON.stringify(Google$outboundSchema.parse(google)); } export function googleFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Google$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Google' from JSON`, ); } /** @internal */ export const AuthConfiguration$inboundSchema: z.ZodType< AuthConfiguration, z.ZodTypeDef, unknown > = z.object({ google: z.lazy(() => Google$inboundSchema).optional(), nickname: DeletedBuild$inboundSchema.optional(), anonymous: DeletedBuild$inboundSchema.optional(), }); /** @internal */ export type AuthConfiguration$Outbound = { google?: Google$Outbound | undefined; nickname?: DeletedBuild$Outbound | undefined; anonymous?: DeletedBuild$Outbound | undefined; }; /** @internal */ export const AuthConfiguration$outboundSchema: z.ZodType< AuthConfiguration$Outbound, z.ZodTypeDef, AuthConfiguration > = z.object({ google: z.lazy(() => Google$outboundSchema).optional(), nickname: DeletedBuild$outboundSchema.optional(), anonymous: DeletedBuild$outboundSchema.optional(), }); export function authConfigurationToJSON( authConfiguration: AuthConfiguration, ): string { return JSON.stringify( AuthConfiguration$outboundSchema.parse(authConfiguration), ); } export function authConfigurationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AuthConfiguration$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AuthConfiguration' from JSON`, ); }