UNPKG

@erc7824/nitrolite

Version:

The Nitrolite SDK empowers developers to build high-performance, scalable web3 applications using state channels. It's designed to provide near-instant transactions and significantly improved user experiences by minimizing direct blockchain interactions.

40 lines (39 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.authParamsParsers = void 0; const zod_1 = require("zod"); const types_1 = require("../types"); const common_1 = require("./common"); const AuthChallengeParamsSchema = zod_1.z .array(zod_1.z .object({ challenge_message: zod_1.z.string() }) .transform((raw) => ({ challengeMessage: raw.challenge_message }))) .refine((arr) => arr.length === 1) .transform((arr) => arr[0]); const AuthVerifyParamsSchema = zod_1.z .array(zod_1.z .object({ address: common_1.addressSchema, session_key: common_1.addressSchema, success: zod_1.z.boolean(), jwt_token: zod_1.z.string().optional(), }) .transform((raw) => ({ address: raw.address, sessionKey: raw.session_key, success: raw.success, jwtToken: raw.jwt_token, }))) .refine((arr) => arr.length === 1) .transform((arr) => arr[0]); const AuthRequestParamsSchema = zod_1.z .array(zod_1.z .object({ challenge_message: zod_1.z.string() }) .transform((raw) => ({ challengeMessage: raw.challenge_message }))) .refine((arr) => arr.length === 1) .transform((arr) => arr[0]); exports.authParamsParsers = { [types_1.RPCMethod.AuthChallenge]: (params) => AuthChallengeParamsSchema.parse(params), [types_1.RPCMethod.AuthVerify]: (params) => AuthVerifyParamsSchema.parse(params), [types_1.RPCMethod.AuthRequest]: (params) => AuthRequestParamsSchema.parse(params), };