Confirm email via webook function

Hello.
I’m trying to implement email confirmation logic. I would like to confirmEmail in webook function. I can’t find an example of how to achieve it.
In documentation I can find that in order to confirm email, I have to execute app.emailPasswordAuth.confirmUser(token, tokenId). But how can I get app instance inside my webhook function ? This is what I have.

// This function is the webhook's request handler.
exports = async function(payload, response) {
    const {token, tokenId} = payload.query;
    console.log("token, tokenId: ", token, tokenId);
    await app.emailPasswordAuth.confirmUser(token, tokenId);
}

At the moment app is undefined. Can I get an app from context? It’s strange that such a standard use case is not documented in any way.

I’ve tried the naive way, include the realm node.js npm package into external dependencies and get instance of app from.

  const Realm = require("realm");
  const app = new Realm.App({ id: "my_project_app-id" });

but even this approach does not work because the realm nodejs package alone weights 104MB (compressed ), where the limit is 10MB :worried:

Really, what is your goto approach to email confirmation? Do I have to deploy a separate server for email confirmation? I must be missing something here.

1 Like

Can I login using tokenId and token ?