UNPKG

cdp-wallet-onramp-kit

Version:

Complete toolkit for Coinbase Developer Platform (CDP) Embedded Wallets and Onramp integration with reusable components, utilities, and documentation

203 lines (202 loc) 5.58 kB
import { z } from 'zod'; import { NextResponse } from 'next/server'; /** * Validation schema for wallet addresses */ export declare const walletAddressSchema: z.ZodString; /** * Validation schema for address with blockchains */ export declare const addressConfigSchema: z.ZodObject<{ address: z.ZodString; blockchains: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { address?: string; blockchains?: string[]; }, { address?: string; blockchains?: string[]; }>; /** * Validation schema for session token creation (guest checkout) */ export declare const guestSessionTokenSchema: z.ZodObject<{ guestCheckout: z.ZodLiteral<true>; assets: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>; }, "strip", z.ZodTypeAny, { guestCheckout?: true; assets?: string[]; }, { guestCheckout?: true; assets?: string[]; }>; /** * Validation schema for session token creation (with wallet) */ export declare const walletSessionTokenSchema: z.ZodObject<{ userAddress: z.ZodString; assets: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>; }, "strip", z.ZodTypeAny, { assets?: string[]; userAddress?: string; }, { assets?: string[]; userAddress?: string; }>; /** * Combined session token validation schema */ export declare const sessionTokenSchema: z.ZodUnion<[z.ZodObject<{ guestCheckout: z.ZodLiteral<true>; assets: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>; }, "strip", z.ZodTypeAny, { guestCheckout?: true; assets?: string[]; }, { guestCheckout?: true; assets?: string[]; }>, z.ZodObject<{ userAddress: z.ZodString; assets: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>; }, "strip", z.ZodTypeAny, { assets?: string[]; userAddress?: string; }, { assets?: string[]; userAddress?: string; }>]>; /** * Validation schema for onramp URL generation */ export declare const onrampUrlSchema: z.ZodObject<{ addresses: z.ZodArray<z.ZodObject<{ address: z.ZodString; blockchains: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { address?: string; blockchains?: string[]; }, { address?: string; blockchains?: string[]; }>, "many">; assets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; defaultAsset: z.ZodOptional<z.ZodString>; defaultNetwork: z.ZodOptional<z.ZodString>; presetFiatAmount: z.ZodOptional<z.ZodNumber>; presetCryptoAmount: z.ZodOptional<z.ZodNumber>; redirectUrl: z.ZodOptional<z.ZodString>; partnerUserId: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { defaultAsset?: string; defaultNetwork?: string; presetFiatAmount?: number; presetCryptoAmount?: number; redirectUrl?: string; partnerUserId?: string; assets?: string[]; addresses?: { address?: string; blockchains?: string[]; }[]; }, { defaultAsset?: string; defaultNetwork?: string; presetFiatAmount?: number; presetCryptoAmount?: number; redirectUrl?: string; partnerUserId?: string; assets?: string[]; addresses?: { address?: string; blockchains?: string[]; }[]; }>; /** * Validation schema for amount input */ export declare const amountSchema: z.ZodNumber; /** * Validation schema for email input */ export declare const emailSchema: z.ZodString; /** * Validation schema for OTP input */ export declare const otpSchema: z.ZodString; /** * Common asset symbols validation */ export declare const assetSchema: z.ZodEnum<["ETH", "USDC", "BTC", "USDT", "DAI", "WETH", "MATIC", "LINK", "UNI"]>; /** * Network validation */ export declare const networkSchema: z.ZodEnum<["base", "ethereum", "arbitrum", "optimism", "polygon"]>; /** * Error response schema */ export declare const errorResponseSchema: z.ZodObject<{ error: z.ZodString; details: z.ZodOptional<z.ZodAny>; code: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { code?: string; error?: string; details?: any; }, { code?: string; error?: string; details?: any; }>; /** * Success response schema for session token */ export declare const sessionTokenResponseSchema: z.ZodObject<{ sessionToken: z.ZodString; expiresIn: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; channelId: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { expiresIn?: number; sessionToken?: string; channelId?: string; }, { expiresIn?: number; sessionToken?: string; channelId?: string; }>; /** * Success response schema for onramp URL */ export declare const onrampUrlResponseSchema: z.ZodObject<{ url: z.ZodString; expiresIn: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; sessionToken: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { url?: string; expiresIn?: number; sessionToken?: string; }, { url?: string; expiresIn?: number; sessionToken?: string; }>; /** * Utility function to validate and parse request data */ export declare function validateRequest<T>(schema: z.ZodSchema<T>, data: unknown): T; /** * Utility function to create error response */ export declare function createErrorResponse(error: string, statusCode?: number, suggestions?: string[]): NextResponse<{ timestamp: string; help: string; suggestions: string[]; statusCode: number; error: string; }>; /** * Utility function to validate environment variables */ export declare function validateEnvironment(): { isValid: boolean; missing: string[]; };