das-Face
vericlient.dasface.client.DasfaceClient
¶
Bases: Client
Class to interact with the das-Face API.
das-Face differs from the other two clients in how it is spoken to: requests carry JSON
with base64 encoded images rather than multipart file parts, its fields are camelCase,
and it is served under /v2. None of that reaches the caller — images go in as a path or
as bytes, and attributes keep their Python names.
Source code in src/vericlient/dasface/client.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 | |
alive
¶
Check if the service is alive.
Returns bool: True if the service is alive, False otherwise
Source code in src/vericlient/dasface/client.py
get_models
¶
Get the biometrics models available in the service.
One entry per hash and mode, so the same hash appears several times.
Returns:
| Name | Type | Description |
|---|---|---|
ModelsOutput |
ModelsOutput
|
The available models |
Source code in src/vericlient/dasface/client.py
generate_credential
¶
Generate a credential from a photo.
A credential is the biometric representation of a face, and what gets stored and
compared later. The model is part of it, so hash and mode are required: take
them from get_models(). The service has no endpoint that picks a model for you.
Setting inemex uses the INE Mexico variant of the endpoint, which needs a specific
agreement with Veridas. That one does have a default-model form, so with inemex
set the model may be left out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
str | bytes
|
The photo, as a path or as bytes |
required |
hash
|
str | None
|
The hash of the model to use, from |
None
|
mode
|
str | None
|
The mode to use, from |
None
|
inemex
|
bool
|
Use the INE Mexico variant of the endpoint |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
GenerateCredentialOutput |
GenerateCredentialOutput
|
The credential and the model behind it |
Raises:
| Type | Description |
|---|---|
FaceTooSmallForIasError
|
If the face is too small to analyse |
UnknownHashAndModeError
|
If no model matches that hash and mode |
FormValidationError
|
If the photo cannot be read |
Source code in src/vericlient/dasface/client.py
get_model_metadata_from_credential
¶
Get the model a credential was generated with.
Useful to tell whether a credential stored some time ago still matches a model the service offers today.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential
|
str
|
The credential to inspect |
required |
Returns:
| Name | Type | Description |
|---|---|---|
GetModelMetadataFromCredentialOutput |
GetModelMetadataFromCredentialOutput
|
The model behind the credential |
Raises:
| Type | Description |
|---|---|
FormValidationError
|
If the credential is not a credential |
Source code in src/vericlient/dasface/client.py
verify_photo
¶
Compare two photos and report how confident the service is that they match.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
anchor_image
|
str | bytes
|
The reference photo, as a path or as bytes |
required |
target_image
|
str | bytes
|
The photo to evaluate, as a path or as bytes |
required |
mode
|
str | None
|
The model mode to use. The service picks its default when omitted |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
VerificationOutput |
VerificationOutput
|
The confidence, from 0 to 1 |
Raises:
| Type | Description |
|---|---|
FaceNotFoundError
|
If either photo holds no face |
MoreThanOneFaceError
|
If either photo holds more than one |
FaceAlignmentError
|
If a face's key points could not be located |
FormValidationError
|
If a photo cannot be read |
Source code in src/vericlient/dasface/client.py
verify_video
¶
Compare a photo against the face in a video.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
anchor_image
|
str | bytes
|
The reference photo, as a path or as bytes |
required |
target_video
|
str | bytes
|
The video to evaluate, as a path or as bytes |
required |
Returns:
| Name | Type | Description |
|---|---|---|
VerificationOutput |
VerificationOutput
|
The confidence, from 0 to 1 |
Raises:
| Type | Description |
|---|---|
FaceNotFoundError
|
If no face is found |
ZeroLengthVideoError
|
If the video is empty or corrupted |
NotEnoughVideoDataError
|
If the video holds too few usable frames |
Source code in src/vericlient/dasface/client.py
verify_credential
¶
Compare a photo against a stored credential.
This is the usual verification: the credential was generated once at enrolment, and every later check compares a fresh photo against it without needing the original.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
anchor_image
|
str | bytes
|
The photo, as a path or as bytes |
required |
target_credential
|
str
|
The credential to compare it with |
required |
Returns:
| Name | Type | Description |
|---|---|---|
VerificationOutput |
VerificationOutput
|
The confidence, from 0 to 1 |
Raises:
| Type | Description |
|---|---|
InvalidCredentialError
|
If the credential cannot be read |
ObsoleteCredentialModelError
|
If it came from a model the service has dropped |
FaceNotFoundError
|
If the photo holds no face |
Source code in src/vericlient/dasface/client.py
check_photo_authenticity
¶
Check whether a selfie is a genuine capture rather than a photo of a screen or print.
The face has to fill enough of the frame: a small one is rejected with FaceTooSmallForIasError rather than scored low.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
str | bytes
|
The selfie to analyse, as a path or as bytes |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PhotoAuthenticityOutput |
PhotoAuthenticityOutput
|
The confidence, from 0 to 1 |
Raises:
| Type | Description |
|---|---|
FaceTooSmallForIasError
|
If the face is too small to analyse |
FaceNotFoundError
|
If the photo holds no face |
MoreThanOneFaceError
|
If it holds more than one |
Source code in src/vericlient/dasface/client.py
check_video_authenticity
¶
Check whether a video is a genuine recording, and of the expected person.
Answers both questions at once, and they are independent: a genuine recording of somebody else scores high on authenticity and low on similarity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
anchor_image
|
str | bytes
|
The photo of the expected person, as a path or as bytes |
required |
target_video
|
str | bytes
|
The video to analyse, as a path or as bytes |
required |
Returns:
| Name | Type | Description |
|---|---|---|
VideoAuthenticityOutput |
VideoAuthenticityOutput
|
The authenticity and the similarity, each from 0 to 1 |
Raises:
| Type | Description |
|---|---|
FaceTooSmallForIasError
|
If a face is too small to analyse |
ZeroLengthVideoError
|
If the video is empty or corrupted |
VideoExtractionError
|
If the video cannot be decoded |
NotEnoughVideoDataError
|
If it holds too few usable frames |
Source code in src/vericlient/dasface/client.py
generate_sequential_challenge
¶
Generate a liveness challenge: a sequence of actions for the subject to perform.
The point of a challenge is that the recording cannot have been prepared in advance,
since the actions are only known once the challenge is issued. Show the actions to
the subject, record them, and send the recording back to
analyse_challenge_response together with this token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
int | None
|
How many actions to ask for, from 1 to 6. The service defaults to 2 |
None
|
expiration
|
int | None
|
How long the challenge stays valid, in seconds, from 300 to 1800. The service defaults to 1800 |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
SequentialChallengeOutput |
SequentialChallengeOutput
|
The token to pass on, and the actions to prompt for |
Raises:
| Type | Description |
|---|---|
FormValidationError
|
If the length or the expiration is out of range |
Source code in src/vericlient/dasface/client.py
analyse_challenge_response
¶
Analyse the recording of a challenge against the photo of the expected person.
One figure answers all of it: whether the recording is genuine, whether it performs the challenge that was issued, and whether it is the right person.
Unlike every other endpoint here, this one reports what went wrong inside a
successful response. A confidence of None means the analysis could not be
completed, and the errors of the result say why.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token
|
str
|
The token from |
required |
annotations
|
str | bytes
|
The SDK's WebVTT annotations, as a path or as bytes. A |
required |
anchor_image
|
str | bytes
|
The photo of the expected person, as a path or as bytes |
required |
target_video
|
str | bytes
|
The recording of the challenge, as a path or as bytes |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ChallengeAnalysisOutput |
ChallengeAnalysisOutput
|
The confidence, or |
Raises:
| Type | Description |
|---|---|
ExpiredOrInvalidChallengeError
|
If the challenge is no longer valid |
FormValidationError
|
If the token, the annotations or a media file cannot be read |
Source code in src/vericlient/dasface/client.py
vericlient.dasface.models
¶
Module to define the models for the das-Face API.
Note the naming: das-Face fields are camelCase on the wire, where das-Peak and VCSP use
snake_case. The models use Python names and alias them, so callers write
anchor_image and the service receives anchorImage.
BiometricsModel
¶
Bases: BaseModel
One biometrics model the service offers.
Attributes:
| Name | Type | Description |
|---|---|---|
hash |
str
|
The hash that identifies the model |
mode |
str
|
The mode it runs in, such as |
tag |
str
|
Its release tag |
methods |
list[str]
|
The biometric methods it implements |
length |
int
|
The length of the credentials it produces |
Source code in src/vericlient/dasface/models.py
ModelsOutput
¶
Bases: BaseModel
Output class for the models endpoint.
Attributes:
| Name | Type | Description |
|---|---|---|
models |
list[BiometricsModel]
|
Every model the service offers, one entry per hash and mode |
Source code in src/vericlient/dasface/models.py
ModelMetadata
¶
Bases: BaseModel
Metadata identifying the model a credential was generated with.
Attributes:
| Name | Type | Description |
|---|---|---|
hash |
str
|
The hash of the model |
mode |
str
|
The mode it ran in |
tag |
str | None
|
Its release tag, when the service reports one |
Source code in src/vericlient/dasface/models.py
GenerateCredentialInput
¶
Bases: BaseModel
Input class for generating a credential from a photo.
The model is part of the credential: two credentials only compare if they were
generated with the same one. The service does not pick a model on its own, so hash
and mode are required. Take them from get_models().
The only exception is the INE Mexico variant, which does have a default-model form:
with inemex set, leaving hash and mode out uses it.
Attributes:
| Name | Type | Description |
|---|---|---|
image |
Media
|
The photo, as a path or as bytes |
hash |
str | None
|
The hash of the model to use, from |
mode |
str | None
|
The mode to use, from |
inemex |
bool
|
Use the INE Mexico variant of the endpoint. It needs a specific agreement with Veridas |
Source code in src/vericlient/dasface/models.py
model_must_be_named_in_full
¶
Require hash and mode together, and require them at all outside INE Mexico.
A model key is the pair, so half of it is always an error. Only the INE Mexico endpoint has a default-model form, so everywhere else the pair is mandatory: there is no endpoint that lets the service choose.
A model validator rather than a field one, because pydantic does not run field validators over a field left at its default, which is exactly the case being caught.
Source code in src/vericlient/dasface/models.py
GenerateCredentialOutput
¶
Bases: BaseModel
Output class for generating a credential from a photo.
Attributes:
| Name | Type | Description |
|---|---|---|
credential |
str
|
The biometric representation of the face |
model |
ModelMetadata
|
The model it was generated with |
Source code in src/vericlient/dasface/models.py
GetModelMetadataFromCredentialInput
¶
Bases: BaseModel
Input class for reading which model produced a credential.
Attributes:
| Name | Type | Description |
|---|---|---|
credential |
str
|
The credential to inspect |
Source code in src/vericlient/dasface/models.py
GetModelMetadataFromCredentialOutput
¶
Bases: BaseModel
Output class for reading which model produced a credential.
Attributes:
| Name | Type | Description |
|---|---|---|
metadata |
ModelMetadata
|
The model the credential was generated with |
Source code in src/vericlient/dasface/models.py
VerifyPhotoInput
¶
Bases: BaseModel
Input class for comparing two photos.
Attributes:
| Name | Type | Description |
|---|---|---|
anchor_image |
Media
|
The reference photo, as a path or as bytes |
target_image |
Media
|
The photo to evaluate, as a path or as bytes |
mode |
str | None
|
The model mode to use, such as |
Source code in src/vericlient/dasface/models.py
VerifyVideoInput
¶
Bases: BaseModel
Input class for comparing a photo against a video.
Attributes:
| Name | Type | Description |
|---|---|---|
anchor_image |
Media
|
The reference photo, as a path or as bytes |
target_video |
Media
|
The video to evaluate, as a path or as bytes |
Source code in src/vericlient/dasface/models.py
VerifyCredentialInput
¶
Bases: BaseModel
Input class for comparing a photo against a stored credential.
Attributes:
| Name | Type | Description |
|---|---|---|
anchor_image |
Media
|
The photo, as a path or as bytes |
target_credential |
str
|
The credential to compare it with |
Source code in src/vericlient/dasface/models.py
VerificationOutput
¶
Bases: BaseModel
Output class for a verification.
Attributes:
| Name | Type | Description |
|---|---|---|
confidence |
float
|
How confident the service is that both faces belong to the same person, from 0 to 1 |
Source code in src/vericlient/dasface/models.py
PhotoAuthenticityInput
¶
Bases: BaseModel
Input class for checking whether a selfie is a genuine capture.
Attributes:
| Name | Type | Description |
|---|---|---|
image |
Media
|
The selfie to analyse, as a path or as bytes |
Source code in src/vericlient/dasface/models.py
PhotoAuthenticityOutput
¶
Bases: BaseModel
Output class for a photo authenticity check.
Attributes:
| Name | Type | Description |
|---|---|---|
confidence |
float
|
How confident the service is that the photo is a genuine capture rather than a photo of a screen or a print, from 0 to 1 |
Source code in src/vericlient/dasface/models.py
VideoAuthenticityInput
¶
Bases: BaseModel
Input class for checking a video's authenticity and who is in it.
Attributes:
| Name | Type | Description |
|---|---|---|
anchor_image |
Media
|
The photo of the person the video should show, as a path or as bytes |
target_video |
Media
|
The video to analyse, as a path or as bytes |
Source code in src/vericlient/dasface/models.py
VideoAuthenticityOutput
¶
Bases: BaseModel
Output class for a video authenticity check.
Both figures matter, and they answer different questions: a genuine recording of the wrong person scores high on one and low on the other.
Attributes:
| Name | Type | Description |
|---|---|---|
authenticity |
float
|
How confident the service is that the video is a genuine recording |
similarity |
float
|
How closely the face in the video matches the anchor photo |
Source code in src/vericlient/dasface/models.py
SequentialChallengeInput
¶
Bases: BaseModel
Input class for requesting a sequential liveness challenge.
Attributes:
| Name | Type | Description |
|---|---|---|
length |
int | None
|
How many actions the challenge asks for, from 1 to 6. The service defaults to 2, which it describes as standard security, and 6 as high security |
expiration |
int | None
|
How long the challenge stays valid, in seconds, from 300 to 1800. The service defaults to 1800 |
Source code in src/vericlient/dasface/models.py
ChallengeAction
¶
Bases: BaseModel
One action the subject is asked to perform.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name the annotations refer to this action by, such as |
action_class |
str
|
What kind of action it is, such as |
parameters |
dict
|
The details of the action, such as |
Source code in src/vericlient/dasface/models.py
SequentialChallengeOutput
¶
Bases: BaseModel
Output class for a sequential liveness challenge.
The service answers with a signed token rather than JSON. Pass token on unchanged: the
capture SDK needs it, and so does analyse_challenge_response. The rest of the fields
are read from inside it, because a caller has to know which actions to prompt for.
Attributes:
| Name | Type | Description |
|---|---|---|
token |
str
|
The JWS token, exactly as the service returned it |
id |
str
|
The identifier of this challenge |
timestamp |
datetime
|
When the challenge was issued |
expires |
datetime
|
When it stops being accepted |
actions |
list[ChallengeAction]
|
The actions to perform, in order |
Source code in src/vericlient/dasface/models.py
ChallengeAnalysisInput
¶
Bases: BaseModel
Input class for analysing the recording of a challenge.
Attributes:
| Name | Type | Description |
|---|---|---|
token |
str
|
The token from |
annotations |
Media
|
The SDK's WebVTT annotations of the recording, as a path or as bytes.
A |
anchor_image |
Media
|
The photo of the person the recording should show, as a path or as bytes |
target_video |
Media
|
The recording of the challenge, as a path or as bytes |
Source code in src/vericlient/dasface/models.py
ChallengeError
¶
Bases: BaseModel
One reason the analysis could not produce a confidence.
Attributes:
| Name | Type | Description |
|---|---|---|
code |
str
|
The error code, such as |
message |
str
|
What the service said about it |
Source code in src/vericlient/dasface/models.py
ChallengeAnalysisOutput
¶
Bases: BaseModel
Output class for the analysis of a challenge recording.
This endpoint reports its failures in a successful response rather than as an error
status, which no other das-Face endpoint does. A confidence of None means the
analysis could not be completed and errors says why — a face too small to analyse
comes back here, where every other endpoint raises.
Attributes:
| Name | Type | Description |
|---|---|---|
confidence |
float | None
|
How confident the service is that the recording is a genuine response to
the challenge by the person in the anchor photo, from 0 to 1, or |
errors |
list[ChallengeError]
|
What went wrong, empty when nothing did |
Source code in src/vericlient/dasface/models.py
vericlient.dasface.exceptions
¶
Module to define the exceptions for the das-Face API.
das-Face reports failures differently from the other services: its error bodies carry
{code, message, status}, where das-Peak uses {error, exception} and VCSP uses
{error, title, reason}.
The v3.35 specification enumerates these codes properly, which v3.26 did not. Three of the
codes below are not in it: UnknownHashAndModeError and PathNotFoundError, both found
against work/eu, and ExpiredOrInvalidChallengeError, which v3.26 documents for the
challenge endpoints that v3.35 dropped.
DasfaceError
¶
FaceNotFoundError
¶
Bases: DasfaceError
Exception raised when no face could be located in the image.
Source code in src/vericlient/dasface/exceptions.py
MoreThanOneFaceError
¶
Bases: DasfaceError
Exception raised when the image holds more than one face.
Source code in src/vericlient/dasface/exceptions.py
FaceAlignmentError
¶
Bases: DasfaceError
Exception raised when the face's key points could not be located.
Source code in src/vericlient/dasface/exceptions.py
ObsoleteCredentialModelError
¶
Bases: DasfaceError
Exception raised when a credential was generated with a model the service has dropped.
Worth catching on its own: it means the credential has to be regenerated from the original photo, not that the request was wrong.
Source code in src/vericlient/dasface/exceptions.py
IncompatibleCredentialsError
¶
Bases: DasfaceError
Exception raised when two credentials cannot be compared with each other.
Credentials are only comparable when they come from the same model and mode.
Source code in src/vericlient/dasface/exceptions.py
ZeroLengthVideoError
¶
Bases: DasfaceError
Exception raised when the video is empty or was corrupted in transit.
Source code in src/vericlient/dasface/exceptions.py
NotEnoughVideoDataError
¶
Bases: DasfaceError
Exception raised when the video holds too few usable frames to analyse.
Source code in src/vericlient/dasface/exceptions.py
VideoExtractionError
¶
Bases: DasfaceError
Exception raised when the video could not be decoded.
Source code in src/vericlient/dasface/exceptions.py
InvalidVideoMetadataError
¶
Bases: DasfaceError
Exception raised when the video's frame rate or frame count are not usable.
das-Face reports these as two separate codes, InvalidFPSVideoError and
InvalidNumFramesVideoError; both mean the same thing to a caller.
Source code in src/vericlient/dasface/exceptions.py
FaceTooSmallForIasError
¶
Bases: DasfaceError
Exception raised when the face is too small for the authenticity analysis.
Source code in src/vericlient/dasface/exceptions.py
FormValidationError
¶
Bases: DasfaceError
Exception raised when the request body is not what the endpoint expects.
das-Face uses one code for every malformed input: an image that is not decodable, a string that is not valid base64, a credential that is not a credential, and a missing required field all arrive as this.
The service splits the explanation in two. Its message names the form it was validating
— Incorrect parameters in GenerateSequentialChallengeForm — and its errors name the
field and what is wrong with it. Only the second half is any use, so both are reported
and errors is kept for a caller that wants to act on a specific field.
Attributes:
| Name | Type | Description |
|---|---|---|
errors |
The |
Source code in src/vericlient/dasface/exceptions.py
UnknownHashAndModeError
¶
Bases: DasfaceError
Exception raised when no biometrics model matches the given hash and mode.
Source code in src/vericlient/dasface/exceptions.py
PathNotFoundError
¶
Bases: DasfaceError
Exception raised when the endpoint is not available on the target deployment.
Some endpoints in the specification are not enabled everywhere. On the EU sandbox,
authenticity/photo/unequal-pair answers with this.
Source code in src/vericlient/dasface/exceptions.py
DasfaceApiError
¶
Bases: DasfaceError
Exception raised for a failure das-Face reports with a code this client does not map.
The specification documents only status codes, so the set of codes is discovered by provoking them. Rather than swallow an unrecognised one into a generic server error, it is surfaced with the code and message the service gave, which is what an integrator needs to report it.
Source code in src/vericlient/dasface/exceptions.py
ExpiredOrInvalidChallengeError
¶
Bases: DasfaceError
Exception raised when a challenge token is no longer accepted.
A challenge is valid for as long as its expiration said, 1800 seconds by default. Past
that the recording cannot be analysed and a fresh challenge has to be generated.