Files
zyt/artifacts/esign-embedded-admin.md
2026-11-20 10:30:04 +08:00

3.1 KiB
Raw Permalink Blame History

Admin in-system eSign verification

Implemented in:

  • admin/src/components/EsignPrescriptionPanel.vue
  • admin/src/api/tcm.ts
  • admin/src/utils/prescription-esign.ts
  • admin/tests/prescription-esign.test.cjs

Behavior

The explicit “核身并签署” action opens an Element Plus dialog in the current application. The user is told that successful server-confirmed identity verification will sign the current prescription automatically. The iframe accepts only the existing exact HTTPS eSign host allowlist, has allow-forms allow-scripts allow-same-origin sandbox permissions and no-referrer; it has no popup or outer-window navigation permission. No new tab, external link, manual “return and complete” action, frame-content access or frame-message trust remains.

After a successful start, a single-flight GET /tcm.prescription/esignIdentityStatus runs every five seconds after each reply, bounded to ten minutes. Only a validated full status DTO with identity_status: SUCCESS, can_complete: true, status: authenticating and can_sign: true can submit completion. The component consumes the explicit intent before the POST, clears timers and never automatically repeats a failed, timed-out or uncertain completion request. The transport also disables retries.

Close, unmount, deactivation, prescription replacement, independently replaced source state, hidden document, timeout, invalid response, provider failure and terminal state revoke intent and abort readiness reads. Generation checks discard late responses. Parent echoes of this component’s accepted DTO are ignored. Refresh is read-only, revokes automatic signing intent and requires a new explicit action to resume.

The verified original PDF and SHA-256 download checks are preserved.

Validation

  • node --test tests/prescription-esign.test.cjs in admin: 46 passed, 0 failed, including the previous 17 tests.
  • Coverage includes the complete lifecycle, read-only query transport, five-second single-flight cadence, ten-minute bound, stale SUCCESS rejection, hidden/closed/unmounted states, exactly one pending completion, unknown/failed states, official URL validation, no external navigation, Vue SFC compilation, original PDF bytes and hash validation.
  • npm run type-check: repository has 62 existing TypeScript diagnostics, exactly matching admin/tests/esign-typecheck.log; no diagnostics reference the modified API, utility or component. Current output: admin/tests/esign-embedded-typecheck.log.
  • LF normalized; scoped git diff --check passed.

Integration boundary

No vendor requests or server mutations were performed by this work. New provider requests are configured by the backend owner for SMS-only in-system verification. Existing stored URLs do not identify their previous verification channel. They remain sandboxed; an inline explanation and “核身页面不可用” action stop the flow if an old provider page requires unsupported external navigation. Browsers do not reliably report cross-origin CSP/X-Frame-Options or in-frame provider errors to the parent; no successful embedded provider journey is claimed from local mocked tests. There is deliberately no new-window fallback.