loading
Preparing LoginRadius developer resources
Mission: Help enterprises accelerate digital transformation with our fully-managed Customer IAM technology.
Skip to main content

lrObject Reference

lrObject is the first argument passed to every exports.execute function. It is a read-only data object: not an API with methods. It provides contextual information about the current user, their request, and the running workflow session.

exports.execute = async (lrObject, hook) => {
// lrObject is a plain object: read fields directly
};

Top-Level Fields

FieldTypeDescription
lrObject.RequestobjectMetadata about the incoming request.
lrObject.IdentityobjectFull user identity profile (Email RAAS response).
lrObject.SessionobjectWorkflow session state: access token, form data, shared state.
lrObject.IsAuthenticatedbooleantrue if the Auth node has successfully authenticated the user upstream.

lrObject.Request

FieldTypeDescription
IPstringClient IP address.
LanguagestringAccept-Language value from the request.
UserAgentstringBrowser or client user-agent string.

lrObject.Identity

Contains the full Email (RAAS) identity profile. Key fields:

FieldTypeDescription
Emailstring | Array<{Type, Value}>User's email. Pre-auth: plain string. Post-auth: array of {Type, Value} objects. Always check type before accessing.
PhoneIdstringUser's phone identifier (optional).
UserNamestringUsername.
UidstringUnique user identifier.
EmailVerifiedbooleanWhether the email has been verified.
PhoneIdVerifiedbooleanWhether the phone number has been verified.
NoOfLoginsnumberTotal login count for this user.
BirthDatestringUser's date of birth.
LastPasswordChangeDatestringISO timestamp of the last password change.
IdentitiesarrayLinked social/federated identities (IdentityResponseWithoutLogins objects).

Pre-auth vs post-auth email format

In pre-auth scripts, Identity.Email is a plain string. In post-auth scripts it is an array of {Type, Value} objects. Always handle both:

let email = "";
if (Array.isArray(lrObject.Identity?.Email)) {
const primary = lrObject.Identity.Email.find(e => e.Type === "Primary") || lrObject.Identity.Email[0];
email = primary?.Value || "";
} else if (typeof lrObject.Identity?.Email === "string") {
email = lrObject.Identity.Email;
}

lrObject.Session

FieldTypeDescription
AccessTokenstringUser's session access token. Set by the Auth node. null if Auth has not run.
WorkflowNamestringName of the currently executing workflow.
FormDatamap<string, string>Key-value pairs submitted by the user through Web Page nodes.
SharedStatemap<string, any>Workflow-scoped key-value store. Auto-populated from authorization_details in PAR/SCA flows. Write back using hook.sharedState.set().

SharedState: SCA / PAR flows

When a workflow is initiated via a PAR request with authorization_details, SharedState is automatically populated:

FieldDescription
authorization_details.typeTransaction type (e.g. lr_payment).
authorization_details.amountTransaction amount.
authorization_details.currencyCurrency code.
authorization_details.payeePayee name.
authorization_details.hashServer-computed integrity token: "{amount}_{currency}_{payee}_{nonce}".
linking_idDynamic linking ID correlating the browser session with the mobile MFA device.
const sharedState = lrObject?.Session?.SharedState || {};
const authDetails = sharedState.authorization_details || {};
const { amount, currency, payee, hash } = authDetails;
const linkingId = sharedState.linking_id || "";

Checking session and authentication

exports.execute = async (lrObject, hook) => {
if (!lrObject.IsAuthenticated) {
hook.setError(401, "Not authenticated", "Login required.");
return;
}

const token = lrObject.Session?.AccessToken;
const uid = lrObject.Identity?.Uid;
};

Related
  • Hook API: write custom fields, claims, metadata, and errors
  • Examples: full working script examples