Skip to Content

OpsisID

Sign in with an EU eID, and verify a signed-in user's identity, through OpsisID.

OpsisID verifies people for EU platforms: with their country's eID, or with an ID document and a selfie a reviewer checks. It is an OpenID Connect provider for its workspaces, and this package connects it to Entro Auth in two ways:

  • Sign in with an eID (opsisidSignIn): the person proves who they are with their eID and is signed in. Your app learns a subject that is the same at every sign-in and unrelated to what any other OpsisID workspace sees, and no name, birth date or ID number unless OpsisID granted your workspace a disclosure.
  • Verify a signed-in user (opsisid): for an account that exists, such as before a payout or a first listing. The user may use any method the purpose allows, including an ID document; when a reviewer still has to decide, the result says so and the decision arrives by webhook.

Both use the authorization code flow with PKCE, and every request is pushed to OpsisID (PAR) with your API key, so the browser never carries what is asked.

Installation

Install the package

npm install @entro314labs/entro-auth-opsisid

Register your redirect URIs in OpsisID

In the OpsisID dashboard, open Settings → Sign in with OpsisID and add:

  • https://your-app.com/api/auth/callback/opsisid for sign-in;
  • https://your-app.com/api/auth/opsisid/callback for verification.

The client ID is shown there; the client secret is your API key. For verification results decided later, set the workspace's webhook URL to https://your-app.com/api/auth/opsisid/webhook.

Add the plugins to your auth config

Use either or both.

auth.ts
import { entroAuth } from "@entro314labs/entro-auth";
import { genericOAuth } from "@entro314labs/entro-auth/plugins/generic-oauth";
import { opsisid, opsisidSignIn } from "@entro314labs/entro-auth-opsisid"; 

const credentials = {
    issuer: "https://opsisid.com",
    clientId: process.env.OPSISID_CLIENT_ID!,
    clientSecret: process.env.OPSISID_API_KEY!,
};

export const auth = entroAuth({
    plugins: [
        genericOAuth({ config: [opsisidSignIn(credentials)] }), 
        opsisid({ ...credentials, webhookSecret: process.env.OPSISID_WEBHOOK_SECRET }), 
    ],
});

Migrate the database

opsisid() adds the opsisidVerification table.

npx @entro314labs/entro-auth-cli@latest migrate

Add the client plugin

auth-client.ts
import { createAuthClient } from "@entro314labs/entro-auth/client";
import { opsisidClient } from "@entro314labs/entro-auth-opsisid/client"; 

export const authClient = createAuthClient({
    plugins: [opsisidClient()], 
});

Sign in with an eID

await authClient.signIn.social({
    provider: "opsisid",
    callbackURL: "/home",
    additionalParams: { country: "PL" }, // the country whose eIDs are offered
});

Pass country to opsisidSignIn instead to fix it for every sign-in. A sign-in is refused when the eID result needs a reviewer, when the person cancels, and when the eID gives no national identifier to derive the subject from.

OpsisID gives no email address, so the user is created with an unverified placeholder address (createPlaceholderEmail, namespace opsisid). Ask for a real one after sign-in if your app needs it.

Only an approved OpsisID sign-in signs anyone in. The ID token's signed opsisid.purpose must be authentication: a request whose parameters were changed in the browser to verify some known user is refused.

Verify a signed-in user

await authClient.opsisid.verify({
    purpose: "rental_lister",
    country: "GR",
    level: 1,
    subject: { given_name: "Eleni", family_name: "Papadopoulou" },
    callbackURL: "/account/verification",
});

The user is sent to OpsisID and comes back to callbackURL; on failure to errorCallbackURL (or callbackURL) with an error query parameter. The user's ID is sent as OpsisID's external_ref by the server, so a user cannot verify as someone else, and repeated verifications of the same user build on each other in OpsisID.

purpose, level and subject are those of OpsisID's session API: see its integration guide for what each purpose checks.

Results

const { data } = await authClient.opsisid.verifications();
// [{ sessionId, purpose, country, status: "review", outcome: null, level: null, ... }]

A row is written when the user returns, or, if they closed the page before returning, when the decision's webhook arrives (the plugin then reads the session from OpsisID with your API key). status is decided with an outcome when OpsisID decided at once, and review when a reviewer still has to look; the webhook then sets the decision. Graded purposes also store the level reached, its levelName and validUntil.

The webhook endpoint checks the Opsisid-Signature header against webhookSecret and refuses deliveries more than five minutes old. Without webhookSecret it refuses every delivery.

Schema

Table: opsisidVerification

Table
Field
Type
Attributes
Description
id
string
PK
Unique identifier
userId
string
FK
The user verified
sessionId
string
UQ
OpsisID's session ID
purpose
string
-
Why the user was verified
country
string
-
The user's country, ISO 3166-1 alpha-2
status
string
-
open, review, decided or closed
outcome ?
string
-
approved or rejected, once decided
level ?
number
-
The level reached, for graded purposes
levelName ?
string
-
That level's name
validUntil ?
Date
-
When the level lapses
createdAt
Date
-
When the user returned from OpsisID
updatedAt
Date
-
When the row last changed

Options

opsisidSignIn

OptionDescription
issuerOpsisID's issuer URL, such as https://opsisid.com.
clientIdYour OpsisID workspace ID.
clientSecretYour OpsisID API key.
countryThe country whose eIDs are offered. Leave it out to pass additionalParams.country per sign-in.
redirectURIDefaults to {baseURL}/callback/opsisid.
disableSignUp, disableImplicitSignUpAs for any Generic OAuth provider.

opsisid

OptionDescription
issuer, clientId, clientSecretAs above.
webhookSecretThe workspace's webhook signing secret (whsec_…).
redirectURIDefaults to {baseURL}/opsisid/callback.
schemaCustom table and field names.

On this page