/opt/canhelp/node_modules/better-auth/dist/oauth2
NameSizeModeActions
index.d.mts3110644editdlrm
index.mjs3120644editdlrm
link-account.d.mts12260644editdlrm
link-account.mjs59950644editdlrm
link-account.mjs.map114300644editdlrm
state.d.mts7450644editdlrm
state.mjs18950644editdlrm
state.mjs.map33280644editdlrm
utils.d.mts3980644editdlrm
utils.mjs8300644editdlrm
utils.mjs.map15000644editdlrm
Edit: /opt/canhelp/node_modules/better-auth/dist/oauth2/state.mjs (1895B)
import { generateRandomString } from "../crypto/random.mjs"; import "../crypto/index.mjs"; import { setOAuthState } from "../api/state/oauth.mjs"; import { StateError, generateGenericState, parseGenericState } from "../state.mjs"; import { APIError, BASE_ERROR_CODES } from "@better-auth/core/error"; //#region src/oauth2/state.ts async function generateState(c, link, additionalData) { const callbackURL = c.body?.callbackURL || c.context.options.baseURL; if (!callbackURL) throw APIError.from("BAD_REQUEST", BASE_ERROR_CODES.CALLBACK_URL_REQUIRED); const codeVerifier = generateRandomString(128); const stateData = { ...additionalData ? additionalData : {}, callbackURL, codeVerifier, errorURL: c.body?.errorCallbackURL, newUserURL: c.body?.newUserCallbackURL, link, expiresAt: Date.now() + 600 * 1e3, requestSignUp: c.body?.requestSignUp }; await setOAuthState(stateData); try { return generateGenericState(c, stateData); } catch (error) { c.context.logger.error("Failed to create verification", error); throw new APIError("INTERNAL_SERVER_ERROR", { message: "Unable to create verification", cause: error }); } } async function parseState(c) { const state = c.query.state || c.body.state; const errorURL = c.context.options.onAPIError?.errorURL || `${c.context.baseURL}/error`; let parsedData; try { parsedData = await parseGenericState(c, state); } catch (error) { c.context.logger.error("Failed to parse state", error); if (error instanceof StateError && error.code === "state_security_mismatch") throw c.redirect(`${errorURL}?error=state_mismatch`); throw c.redirect(`${errorURL}?error=please_restart_the_process`); } if (!parsedData.errorURL) parsedData.errorURL = errorURL; if (parsedData) await setOAuthState(parsedData); return parsedData; } //#endregion export { generateState, parseState }; //# sourceMappingURL=state.mjs.map