# eSign identity binding backend verification Date: 2026-11-18. Scope: server changes and offline tests only; no real provider call, account, credentials or production database accessed. ## Behavior - `esignIdentityStatus` remains read-only. A successful individual flow with literal `indivInfo: null` and no SDK account returns `identity_details_required: true` and `can_complete: false`. - `esignComplete` accepts an optional POST `identity_number`. For that precise null/unbound case, it checks mainland format, birth date, sequence and (18-digit) checksum, then passes the frozen server doctor name, transient number and validated flow ID to existing SDK `addPerson` via `createPerson`. - The supplemental number is input for SDK verification, not identity proof. Signing and account insertion require SDK binding success; willingness must still be valid. - Missing or invalid local input leaves authentication usable and requests correction. An SDK rejection cannot bind or sign. - Existing SDK-bound flows with null details can continue only when the current doctor account exactly matches the account ID captured when authentication began. Replacement, deletion and concurrent first-time binding remain blocked. - Missing, empty, masked, malformed or explicitly mismatched returned identities cannot be replaced with caller input. Wrong flow/app/object type also fails closed. - Snapshot, creator, environment, operation-token, final account recheck, no-resign and archival behavior are retained. Readiness and detail-required flags are mutually exclusive. ## Privacy - No full identity number is written to prescription evidence, doctor account, PDF, DTO or server-generated error messages. - The completion controller rejects non-string input and never echoes it. SDK adapter exceptions contain only an operation label and a validated numeric provider code, omitting raw provider messages and bodies. - The existing generic operation audit listener (currently disabled in `adminapi/event.php`) now allowlists only prescription ID for completion and strips URL query parameters, including if it is re-enabled later. - Middleware review found no request-body logging in the active common/admin middleware. SDK transport has no body/credential logging and no automatic retry. - This report covers application PHP code. SDK/JVM and reverse-proxy log settings are deployment concerns handled separately by the parent task. ## Verification All checks passed using synthetic fixtures, fake provider transport and isolated temporary SQLite, without loading `.env`: - `php tests/PrescriptionEsignFlowTest.php`: **129 checks**. Null/read-only readiness, missing/invalid input, SDK rejection, verified binding input, bound-null success, binding changes, malformed/mismatched provider identity, wrong app/object, expired willingness, stale flow and privacy, plus existing signing/recovery invariants. - `php tests/EsignClientTest.php`: **175 checks**. Includes raw provider rejection containing a synthetic number: exception redacted; exactly one binding attempt. - `php tests/EsignIdentityPrivacyTest.php`: **7 checks**. Actual controller forwards only POST input/current actor, compatibility without input, array/GET rejection, response privacy and actual audit-listener persistence redaction via an in-memory model double. - PHP syntax checks passed for all six changed/new PHP files. ## Contract and project context SDK contract reviewed from `.spool/esign-docs/sdk3-addperson-contract.txt`, cached by the parent from [official SDK addPerson documentation](https://open.esign.cn/doc/opendoc/paas_sdk_3/feq5f4b4x450i0ya): `name` and `idNo` must match authenticated identity, `identityAuthId` links the completed flow, and the provider limits its use to 30 minutes. No new endpoint or database schema is required. `.trellis/workflow.md` is absent in this checkout, so no Trellis task/spec files could be read. No commit or deployment was performed by this worker. The tests validate implementation behavior, not a real provider signature.