• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hypercerts-org / ePDS / 25217949680

01 May 2026 02:23PM UTC coverage: 51.166% (+0.8%) from 50.397%
25217949680

Pull #128

github

web-flow
Merge 16d5de665 into 20ad5e612
Pull Request #128: fix: graceful OAuth error when PAR has expired (no more raw JSON leak)

863 of 1706 branches covered (50.59%)

Branch coverage included in aggregate %.

53 of 76 new or added lines in 6 files covered. (69.74%)

2 existing lines in 1 file now uncovered.

1441 of 2797 relevant lines covered (51.52%)

5.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/shared/src/render-error.ts
1
import { escapeHtml } from './html.js'
2

3
/**
4
 * CSS shared across every styled error page in the project. Both
5
 * auth-service and pds-core consume it as-is. Layout is a centred
6
 * white card on a light-grey body, designed to look reasonable
7
 * regardless of which host serves it.
8
 *
9
 * Auth-service composes additional rules on top (the "Powered by
10
 * Certified" footer) — see `auth-service/src/lib/render-error.ts`.
11
 */
NEW
12
export const ERROR_CSS = `
×
13
  * { box-sizing: border-box; margin: 0; padding: 0; }
14
  body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f5f5; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
15
  .page-wrap { display: flex; flex-direction: column; align-items: stretch; max-width: 420px; width: 100%; }
16
  .container { background: white; border-radius: 12px; padding: 40px; width: 100%; box-shadow: 0 2px 8px rgba(0,0,0,0.08); text-align: center; }
17
  h1 { font-size: 24px; margin-bottom: 16px; color: #111; }
18
  .error { color: #dc3545; background: #fdf0f0; padding: 12px; border-radius: 8px; font-size: 15px; line-height: 1.5; }
19
`
20

21
export interface RenderErrorOptions {
22
  /** Page <title> and the in-page <h1>. Defaults to "Error". */
23
  title?: string
24
  /** Extra CSS to append after ERROR_CSS, e.g. auth-service's
25
   *  powered-by footer rules. */
26
  extraCss?: string
27
  /** Additional HTML inserted INSIDE `.page-wrap` after the
28
   *  `.container`, e.g. auth-service's powered-by footer link.
29
   *  Caller is responsible for ensuring this string is safe HTML —
30
   *  it is not escaped. */
31
  bodyExtra?: string
32
}
33

34
/**
35
 * Render a styled HTML error page. Used by every endpoint that needs
36
 * to surface a recoverable problem to the user without leaking JSON
37
 * or sending the user to a stack trace. Status codes are the
38
 * caller's responsibility — this only produces the body.
39
 */
40
export function renderError(
41
  message: string,
42
  options: RenderErrorOptions = {},
×
43
): string {
NEW
44
  const { title = 'Error', extraCss = '', bodyExtra = '' } = options
×
NEW
45
  return `<!DOCTYPE html>
×
46
<html lang="en">
47
<head>
48
  <meta charset="utf-8">
49
  <meta name="viewport" content="width=device-width, initial-scale=1">
50
  <link rel="icon" href="/static/favicon.svg" media="(prefers-color-scheme: light)" type="image/svg+xml">
51
  <link rel="icon" href="/static/favicon-dark.svg" media="(prefers-color-scheme: dark)" type="image/svg+xml">
52
  <title>${escapeHtml(title)}</title>
53
  <style>${ERROR_CSS}${extraCss}</style>
54
</head>
55
<body>
56
  <div class="page-wrap">
57
    <div class="container">
58
      <h1>${escapeHtml(title)}</h1>
59
      <p class="error">${escapeHtml(message)}</p>
60
    </div>
61
    ${bodyExtra}
62
  </div>
63
</body>
64
</html>`
65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc