UNPKG

based-auth

Version:

A Next.js/Node.js authentication and wallet API kit for Ethereum and Solana, with utilities for serialization and contract interaction, designed for serverless and API route usage.

255 lines (254 loc) 6.23 kB
import { ChainSymbols as e } from "./chains.js"; import { N as r } from "./index-ChpwqF0V.mjs"; import l, { Schema as c, models as f, model as p } from "mongoose"; const B = process.env.NEXT_PUBLIC_APP_ENV === "mainnet", F = 10; process.env.NEXT_PUBLIC_CDN; process.env.NEXT_PUBLIC_IPFS_GETWAY; process.env.PATH_IPFS; process.env.NEXT_PUBLIC_DOMAIN; process.env.NEXT_PUBLIC_SOCKET_URL; Number(process.env.WAIT_FOR_RPC || 2e3); const w = "So11111111111111111111111111111111111111112", n = { [e.eth]: "0xcb98eafa8aCF87545c6773748d256eBFf7B0a128", [e.solDevnet]: "A9CwtR7VWSYKNxAD19smWMWNshJooGLMWS81jd5h8KWL", [e.sol]: "", [e.bsc]: "", [e.tbsc]: "", [e.sui]: "", [e.suiDevnet]: "", [e.ton]: "", [e.tonDevnet]: "", [e.base]: "", [e.uni]: "" }; e.tbsc + "", e.solDevnet + "", e.eth + "", e.sol + "", e.base + "", e.uni + "", e.bsc + "", e.ton + "", e.tonDevnet + "", e.sui + "", e.suiDevnet + ""; r.eth + "", r.sol + ""; const d = { [e.sol]: { appStorage: "", admin: n[e.sol], raydiumV5: "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C", raydiumFee: "DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8" }, [e.solDevnet]: { appStorage: "735eZhxFGoS37r7d8qjnfEvVS18uyZdCa7GBEnHePe9H", admin: n[e.solDevnet], raydiumV5: "CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW", raydiumFee: "G11FKBRaAkHAKuLCgLM6K6NUc9rTjPAznRCjZifrTQe2" } }; e.tbsc + "", e.solDevnet + "", e.sol + "", e.eth + "", e.uni + "", e.base + "", e.bsc + "", e.sui + "", e.suiDevnet + "", e.ton + "", e.tonDevnet + ""; const A = { [e.tbsc]: [ { url: "wss://bsc-testnet.blockpi.network/v1/ws/cd61e00aed93674ae0d608f823e2c2d05a52752d", block: 5e3 } ], [e.bsc]: [ { url: "wss://hidden-proportionate-aura.bsc.quiknode.pro/fc68f3fa6402d7c442f8e91f12c21de2c953d38e/", block: 5e5 }, { url: "wss://bsc.blockpi.network/v1/ws/44ee6379a352148c518c452e9ab05ff9db820294", block: 5e5 } ], [e.eth]: [ { url: "wss://little-broken-darkness.quiknode.pro/f85e866a4c8f0f3efa7c7bf0ec13e7fbca89a53c/", block: 5e5 }, { url: "wss://yolo-weathered-seed.quiknode.pro/4cb47a5c576555d953130952142ce72d72ab3feb/", block: 5e5 }, { url: "wss://ethereum.blockpi.network/v1/ws/7d5ca4a66a7ee2c83665faeff88e28b900b8e13b", block: 5e5 } ], [e.base]: [ { url: "wss://newest-autumn-friday.base-mainnet.quiknode.pro/04f163456de87269c6223cfe09df05b682c1cbe8/", block: 5e5 }, { url: "wss://fabled-special-wish.base-mainnet.quiknode.pro/6a79b883b4d8ea93ecd86acaf4b1d3a3eeaf5480/", block: 5e5 }, { url: "wss://base.blockpi.network/v1/ws/e7c7b85c7b5b718e6916e5e9017a51795f333e24", block: 5e5 } ], [e.uni]: [ { url: "wss://unichain-sepolia.blockpi.network/v1/ws/7a76de3edb42d4fe3af8e70eb09fc040b858c91d", block: 5e5 } ], [e.sui]: [ { url: "wss://sui.blockpi.network/v1/ws/4f4fdc33254600c03ca59e0f4b4ed615dbf58938", block: 5e5 } ], [e.solDevnet]: [ { url: "https://solana-devnet.core.chainstack.com/0083ce65be7bc1b5beac2efba5be3c7b", block: 1e3 } ], [e.sol]: [ { url: "https://late-indulgent-surf.solana-mainnet.quiknode.pro/06bfbf9317a2dac06f06abf1087a9ea64cd0da56/", block: 1e3 }, { url: "https://shy-omniscient-breeze.solana-mainnet.quiknode.pro/faf344b6f231bee3540b30de516ae70826cbe150", block: 1e3 } ], [e.suiDevnet]: [], [e.ton]: [], [e.tonDevnet]: [] }; e.tbsc + "", e.eth + "", e.bsc + "", e.uni + "", e.base + "", e.solDevnet + "", e.sol + ""; e.tbsc + "", e.eth + "", e.bsc + "", e.base + "", e.uni + "", e.sol + "", d[e.sol].raydiumV5, e.solDevnet + "", d[e.solDevnet].raydiumV5; const s = { connection: null, promise: null }, C = async (t = { uri: process.env.MONGO_URI || "", options: {} }) => { try { if (!t.uri) throw new Error("MONGO_URI environment variable is not set"); if (s.connection) return; if (!s.promise) { const a = {}; s.promise = l.connect(t.uri, a); } try { s.connection = await s.promise; } catch (a) { throw s.promise = null, a; } } catch (a) { throw console.error("MongoDB connection error:", a), a; } }, b = new c( { name: { type: String, default: "", required: !0, index: !0 }, bio: { type: String, default: "" }, image: { type: String, default: "" }, banner: { type: String, default: "" }, metaInfo: { website: { type: String, default: "" }, twitter: { type: String, default: "" }, telegram: { type: String, default: "" }, discord: { type: String, default: "" } }, lastNetwork: { type: String, default: "" }, lastSignedIn: { type: Date, default: Date.now }, lastAddress: { type: String, default: "" }, followers: [ { type: c.Types.ObjectId, ref: "UserProfile" } ], users: [ { network: { type: String, enum: Object.values(r), required: !0 }, address: { type: String, required: !0 }, social: { type: String, default: "" }, provider: { type: String, default: "" } } ] }, { timestamps: !0, toObject: { getters: !0, versionKey: !1, transform: (t, a) => (a.id = a._id.toString(), a.users = a.users.map(({ _id: o, ...u }) => ({ ...u, id: o.toString() })), delete a._id, delete a.__v, a) } } ); b.index( { "users.network": 1, "users.address": 1 }, { unique: !0 } ); var i; const D = ((i = f) == null ? void 0 : i.UserProfile) || p("UserProfile", b); async function x(t, a) { return await C(), await D.findOne({ "users.address": t, "users.network": a }); } export { F as S, D as U, C as c, x as g, B as i, A as r }; //# sourceMappingURL=get-user-profile-BApNPXZg.mjs.map