dukcapil/internal/contract/dukcapil_contract.go
Aditya Siregar bc64eb20ea add dukcapil
2026-05-07 04:01:32 +07:00

67 lines
2.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"`
}