67 lines
2.8 KiB
Go
67 lines
2.8 KiB
Go
package contract
|
||
|
||
// FaceMatchRequest is the inbound payload from clients of this service to
|
||
// trigger a Dukcapil 1:N face recognition lookup.
|
||
//
|
||
// Image must already be a base64 (no data:image prefix) representation of a
|
||
// jpg/png file. Threshold is forwarded to Dukcapil (1..20). IP is optional;
|
||
// when empty the configured default IP will be used.
|
||
type FaceMatchRequest struct {
|
||
TransactionID string `json:"transaction_id" validate:"required,max=20"`
|
||
TransactionSource string `json:"transaction_source" validate:"required,max=50"`
|
||
Threshold string `json:"threshold" validate:"required"`
|
||
Image string `json:"image" validate:"required"`
|
||
IP string `json:"ip,omitempty"`
|
||
}
|
||
|
||
// DukcapilFaceRequest is the exact JSON body sent to the Dukcapil
|
||
// face-recognition endpoint (CALL_FN). user_id and password are RSA encrypted
|
||
// with the provided public key and base64 encoded.
|
||
type DukcapilFaceRequest struct {
|
||
TransactionID string `json:"transactionId"`
|
||
TransactionSource string `json:"transactionSource"`
|
||
Threshold string `json:"threshold"`
|
||
Image string `json:"image"`
|
||
UserID string `json:"user_id"`
|
||
Password string `json:"password"`
|
||
IP string `json:"ip"`
|
||
}
|
||
|
||
// DukcapilFaceResponse is the standard Dukcapil response envelope (success +
|
||
// most error variants share this shape). Some error variants use a different
|
||
// shape – clients should also inspect ErrorCode.
|
||
type DukcapilFaceResponse struct {
|
||
TID string `json:"tid"`
|
||
EncounterID interface{} `json:"encounter_id"`
|
||
Error string `json:"error"`
|
||
ErrorCode string `json:"errorCode"`
|
||
FingerData interface{} `json:"finger_data"`
|
||
IrisData interface{} `json:"iris_data"`
|
||
FaceData interface{} `json:"face_data"`
|
||
RequestType string `json:"request_type"`
|
||
MaxResults int `json:"maxResults"`
|
||
FaceThreshold string `json:"faceThreshold"`
|
||
FingerThreshold int `json:"fingerThreshold"`
|
||
IrisThreshold int `json:"irisThreshold"`
|
||
Response string `json:"response"`
|
||
}
|
||
|
||
// FaceMatchResponse is what we return to our API consumers.
|
||
type FaceMatchResponse struct {
|
||
TID string `json:"tid"`
|
||
ErrorCode string `json:"error_code"`
|
||
Error string `json:"error"`
|
||
RequestType string `json:"request_type"`
|
||
Threshold string `json:"threshold"`
|
||
MaxResults int `json:"max_results"`
|
||
Matches []FaceMatchResult `json:"matches"`
|
||
Raw *DukcapilFaceResponse `json:"raw,omitempty"`
|
||
}
|
||
|
||
// FaceMatchResult represents a single (NIK -> score) entry from the Dukcapil
|
||
// `response.face.FACE_T5` map.
|
||
type FaceMatchResult struct {
|
||
NIK string `json:"nik"`
|
||
Score float64 `json:"score"`
|
||
}
|