@softr/sdk
Version:
The SDK for building Softr apps on TanStack Start. It lets an app interact with Softr: auth, datasources, workflows and integrations.
28 lines (26 loc) • 1.01 kB
JavaScript
import { panic } from "../../assertions.js";
import { sessionConfig } from "../config.js";
import { makePlatform } from "../platform.js";
import { authError } from "./utils.js";
//#region src/auth/methods/sso.ts
/**
* Whether a visitor with this email signs in with single sign-on, for a login
* page that asks for the email first and routes from there.
*
* Decided by the email's domain against the domains the builder set for single
* sign-on in Softr. It says nothing about whether an account exists, and an
* address that is not an email answers `false`.
*/
async function discoverSso(details) {
const result = await makePlatform(sessionConfig().applicationId).ssoDiscover(details);
if (!result.ok) {
if (result.status === 429) return authError("tooManyAttempts", result.message);
panic(`Expected to learn whether that email signs in with single sign-on, but got ${result.status}: ` + result.message);
}
return {
success: true,
data: result.data
};
}
//#endregion
export { discoverSso };