@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.
31 lines (30 loc) • 1.21 kB
JavaScript
;
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
.object({ challenge_message: zod_1.z.string() })
.transform((raw) => ({ challengeMessage: raw.challenge_message }));
const AuthVerifyParamsSchema = 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,
}));
const AuthRequestParamsSchema = zod_1.z
.object({ challenge_message: zod_1.z.string() })
.transform((raw) => ({ challengeMessage: raw.challenge_message }));
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),
};