Difficulties when trying to login via non webview flow with custom database login scripts

So i’m trying to login using login and password:
.login(usernameOrEmail: login,
password: password,
realm: realm,
audience: “https://(domain)/userinfo”,
scope: “openid profile offline_access”)
.start {
And i have a database connection custom script which:
a) makes a connection to my server passing credentials (works fine)
b) parses the response, wraps it into user profile (works fine)
c) calls callback function

The problem is that during c) i’m getting an error:
(node:23) UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘redirect_uri’ of undefined

So it’s clear that i’m missing some argument somewhere (context or user profile or original query’s arguments).
Could someone help me with such flow (native iOS login, not a webview solution + custom login script)?

Thanks in advance!

Well, found the problem.
One of the rules caused that exception because it hasn’t checked context.request.query for existence.