Embedded sign-in form
The Novren ID sign-in form inside your page, in an iframe, without leaving your site. The password is still typed on the Novren ID origin: your page's code never sees it.
You need: a client with a callback URL on the same origin as the page that shows the form (the result is delivered only there).
Show the form
import { embedLogin, LoginRejected } from '@novren/id-client/app'
async function showLoginForm(container: HTMLElement) {
const login = await embedLogin({
accountUrl: 'https://account.novren.net',
idServerUrl: 'https://id.novren.net',
clientId: 'cl-0123456789abcdef0123',
// Must be on THIS page's origin and registered on the client.
redirectUri: 'https://myapp.example/callback',
container,
accent: '#724cf9', // optional: your brand colour for the buttons
locale: 'en', // optional: 'it', 'en', or a list such as 'it-IT en'
})
try {
const result = await login.result
login.destroy()
startSession(result)
} catch (error) {
login.destroy()
if (error instanceof LoginRejected) return showMessage('Sign-in failed, please try again.')
throw error
}
}Options
| Option | Required | Meaning |
|---|---|---|
accountUrl | yes | https://account.novren.net. |
idServerUrl | yes | https://id.novren.net, for the code exchange. |
clientId | yes | Your client id. |
redirectUri | yes | A callback URL of that client, on the origin of this page. Otherwise embedLogin throws before showing anything. |
container | yes | The element that will contain the form. Its current content is replaced. |
accent | no | Your brand colour in hex (#724cf9), used for the form's buttons. Anything that isn't 6 hex digits is ignored. |
locale | no | The language of the form. See Language of the form. |
title | no | The iframe's accessible title. Default: "Sign in with Novren ID" (or the Italian equivalent). |
onOpen | no | Called when the form asks to open an account-page link (forgot password, create account). Default: a new tab. |
What happens
embedLoginprepares the request in your page (PKCE,state, ephemeral key) and creates the iframe onaccount.novren.net/incorporato/accedi.- The form grows and shrinks with its content: it sends its height, and the iframe follows it (between 80 and 1600 pixels).
- The user signs in: password, two-factor authentication, passkey, new device approval. The top of the form says which app they are signing in to ("Sign in to Your app"), with the name Novren ID has for your client: your page can't rewrite it. This takes the place of the consent page, so signing in through the form authorizes your app.
- The form sends your page the return address (code + sealed key) with
postMessage. Your page accepts messages only from that iframe and that origin, and only a return address starting with yourredirectUri. login.resultcompletes the sign-in exactly likecompleteLoginand resolves to aLoginResult.
Who can embed it
The account page decides at every request: for your client, only the origin of its callback URL can frame the form, confirmed by the Novren ID server. A page on another origin gets a blank frame. That's why the redirectUri must be on the origin of the page.
Passkeys in the frame
The SDK sets allow="publickey-credentials-get …; publickey-credentials-create …" on the iframe for the Novren ID origin, so passkeys work inside the frame in browsers that allow it. If your page sends a Permissions-Policy header, it must not block publickey-credentials-get for https://account.novren.net.
Close it
Call login.destroy() when the form is no longer needed (the user closed your dialog, navigated away): it removes the iframe and stops listening for messages. login.result then never resolves.
Edge cases
login.resultrejects when the code exchange fails (expired, refused, network). The iframe stays: calldestroy()and show it again with a newembedLoginif the user retries.- No session left behind: inside a frame the browser treats Novren ID as a third party and won't keep its cookie. The form therefore uses a session held in memory and closes it when the sign-in ends. Each sign-in in the frame asks for the credentials again; nothing is added to the user's list of signed-in devices.
- Desktop apps: use the system browser with the loopback callback instead (Desktop apps). A desktop window's origin isn't an https callback URL, so it can't frame the form.