Skip to main content

@idpass/data-collect-core / IdAuthAdapter

Class: IdAuthAdapter

Defined in: components/authentication/IdAuthAdapter.ts:44

Authentication adapter that verifies beneficiaries using their national ID combined with date of birth, or via QR code data. Designed for self-service scenarios where beneficiaries authenticate using identity documents rather than credentials.

Flows:

  • authenticateWithId(nationalId, dateOfBirth, tenantId): Verify using ID document
  • authenticateWithQr(qrData): Verify using scanned QR code

Both flows return a JWT with scope "self-service" scoped to the matched entity.

Implements

Constructors

Constructor

new IdAuthAdapter(storage, config): IdAuthAdapter

Defined in: components/authentication/IdAuthAdapter.ts:47

Parameters

storage

SingleAuthStorage | null

config

AuthConfig

Returns

IdAuthAdapter

Methods

authenticateWithId()

authenticateWithId(nationalId, dateOfBirth, tenantId): Promise<{ username: string; token: string; }>

Defined in: components/authentication/IdAuthAdapter.ts:55

Authenticate with national ID + date of birth

Parameters

nationalId

string

dateOfBirth

string

tenantId

string

Returns

Promise<{ username: string; token: string; }>


authenticateWithQr()

authenticateWithQr(qrData): Promise<{ username: string; token: string; }>

Defined in: components/authentication/IdAuthAdapter.ts:80

Authenticate with QR code data

Parameters

qrData

string

Returns

Promise<{ username: string; token: string; }>


isAuthenticated()

isAuthenticated(): Promise<boolean>

Defined in: components/authentication/IdAuthAdapter.ts:101

Check if currently authenticated

Returns

Promise<boolean>

Implementation of

AuthAdapter.isAuthenticated


validateToken()

validateToken(token): Promise<boolean>

Defined in: components/authentication/IdAuthAdapter.ts:113

Validate stored token

Parameters

token

string

Returns

Promise<boolean>

Implementation of

AuthAdapter.validateToken


logout()

logout(): Promise<void>

Defined in: components/authentication/IdAuthAdapter.ts:127

Returns

Promise<void>

Implementation of

AuthAdapter.logout


initialize()

initialize(): Promise<void>

Defined in: components/authentication/IdAuthAdapter.ts:133

Returns

Promise<void>

Implementation of

AuthAdapter.initialize


login()

login(_credentials): Promise<{ username: string; token: string; }>

Defined in: components/authentication/IdAuthAdapter.ts:137

Parameters

_credentials

PasswordCredentials | TokenCredentials | null

Returns

Promise<{ username: string; token: string; }>

Implementation of

AuthAdapter.login


handleCallback()

handleCallback(): Promise<void>

Defined in: components/authentication/IdAuthAdapter.ts:145

Returns

Promise<void>

Implementation of

AuthAdapter.handleCallback