mirror of
https://github.com/hanzoai/idv.git
synced 2026-10-30 18:33:39 +00:00
85 lines
2.6 KiB
Go
85 lines
2.6 KiB
Go
// Package lexisnexis implements the IDV provider for LexisNexis FlexID.
|
|
package provider
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"time"
|
|
|
|
)
|
|
|
|
const (
|
|
LexisNexisProdURL = "https://wsonline.seisint.com/WsIdentity/FlexID"
|
|
LexisNexisSandboxURL = "https://wsonline-uat.seisint.com/WsIdentity/FlexID"
|
|
)
|
|
|
|
type LexisNexisConfig struct {
|
|
BaseURL string
|
|
Username string
|
|
Password string
|
|
}
|
|
|
|
type LexisNexis struct {
|
|
cfg LexisNexisConfig
|
|
client *http.Client
|
|
}
|
|
|
|
func NewLexisNexis(cfg LexisNexisConfig) *LexisNexis {
|
|
if cfg.BaseURL == "" {
|
|
cfg.BaseURL = LexisNexisSandboxURL
|
|
}
|
|
return &LexisNexis{cfg: cfg, client: &http.Client{Timeout: 30 * time.Second}}
|
|
}
|
|
|
|
func (p *LexisNexis) Name() string { return "lexisnexis" }
|
|
|
|
func (p *LexisNexis) InitiateVerification(ctx context.Context, user VerificationRequest) (*VerificationResponse, error) {
|
|
body := map[string]any{
|
|
"Options": map[string]any{"Watchlists.Threshold": 0.84},
|
|
"User": map[string]string{"GLBPurpose": "7", "DLPurpose": "3"},
|
|
"SearchBy": map[string]any{
|
|
"Name": map[string]string{"First": user.GivenName, "Last": user.FamilyName},
|
|
"Address": map[string]string{"StreetAddress1": func() string { if len(user.Street) > 0 { return user.Street[0] }; return "" }(), "City": user.City, "State": user.State, "Zip5": user.PostalCode},
|
|
"SSN": user.TaxID,
|
|
"DOB": map[string]string{"Year": user.DateOfBirth, "Month": "01", "Day": "01"},
|
|
},
|
|
}
|
|
payload, _ := json.Marshal(body)
|
|
req, err := http.NewRequestWithContext(ctx, "POST", p.cfg.BaseURL+"?ver_=3.12", bytes.NewReader(payload))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req.SetBasicAuth(p.cfg.Username, p.cfg.Password)
|
|
req.Header.Set("Content-Type", "application/json")
|
|
|
|
resp, err := p.client.Do(req)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("lexisnexis: request failed: %w", err)
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
respBody, _ := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
|
|
if resp.StatusCode >= 400 {
|
|
return nil, fmt.Errorf("lexisnexis: %d %s", resp.StatusCode, string(respBody))
|
|
}
|
|
|
|
return &VerificationResponse{
|
|
VerificationID: fmt.Sprintf("ln-%d", time.Now().UnixNano()),
|
|
Provider: "lexisnexis",
|
|
Status: StatusApproved, // LexisNexis returns sync result
|
|
|
|
}, nil
|
|
}
|
|
|
|
func (p *LexisNexis) CheckStatus(ctx context.Context, sessionID string) (*VerificationStatusResult, error) {
|
|
return &VerificationStatusResult{Status: StatusApproved}, nil
|
|
}
|
|
|
|
func (p *LexisNexis) ParseWebhook(headers map[string]string, body []byte) (*VerificationStatusResult, error) {
|
|
return nil, fmt.Errorf("lexisnexis: no webhook support (synchronous API)")
|
|
}
|