Rani Fischer
02/23/2026, 4:37 PMNick Rodriguez
02/23/2026, 7:22 PMRani Fischer
02/23/2026, 10:20 PMawait descopeClient.management.tenant.loadtenantId(tenandId) but it fails , but I got two issues:
(1) The test in the builder doesn't run, it says the script syntax error (on the line attached here)
I have to initialize the descopeClient? if yes -> how? or is there any other alternative to achieve it? I've tried to import DescopeClient from '@descope/node-sdk'; but it says I can't.
Thank youNick Rodriguez
02/24/2026, 1:09 AM// Get hostname, e.g. "<http://env1.platform.com|env1.platform.com>"
const hostname = context.device.location.hostname || "";
// Extract subdomain ("env1")
const loginSubdomain = hostname.split(".")[0];
// Get user-associated tenant IDs
const tenantIds = context.unauthUser?.tenantIds || [];
// Default result
let domainMatch = false;
let matchedTenantId = null;
// Iterate through user tenants
for (const tenantId of tenantIds) {
// Call the Generic HTTP connector
const tenantResp = await context.connectors.loadTenant({
tenantId: tenantId
});
if (!tenantResp || !tenantResp.customAttributes) {
continue;
}
const tenantDomain = tenantResp.customAttributes.TenantDomain;
if (
tenantDomain &&
tenantDomain.toLowerCase() === loginSubdomain.toLowerCase()
) {
domainMatch = true;
matchedTenantId = tenantId;
break;
}
}
// Expose results to the flow
return {
domainMatch,
matchedTenantId
};