Module: EndPointBlank::DeprecationHeaders
- Defined in:
- lib/end_point_blank/deprecation_headers.rb
Overview
Formats the deprecation facts returned by an authorize call into the standard response headers.
Deprecation RFC 9745 — an Item Structured Header Date: "@1688169599"
Sunset RFC 8594 — an HTTP-date: "Sat, 31 Dec 2018 23:59:59 GMT"
RFC 9745 permits a past value ("was deprecated at that date"), which is what EndPointBlank emits: deprecation takes effect when it is declared.
Pure and stateless on purpose. The SDK does not know what a lifecycle is — it relays two timestamps the portal already decided about, and this turns them into two strings. That keeps the vectors in docs/superpowers/specs/2026-08-01-header-vectors.md assertable without constructing a request.
Constant Summary collapse
- DEPRECATION =
"Deprecation"- SUNSET =
"Sunset"- DAYS =
Fixed English abbreviations. Ruby's %a/%b are locale-independent, but spelling them out removes the question entirely — a server running under a different locale must still emit an HTTP-date.
%w[Sun Mon Tue Wed Thu Fri Sat].freeze
- MONTHS =
%w[Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec].freeze
Class Method Summary collapse
-
.build(deprecation) ⇒ Hash
Header name => value; empty when there is nothing to say.
-
.deprecation_value(time) ⇒ Object
"@1688169599" — no quotes, no sub-second precision.
-
.sunset_value(time) ⇒ Object
"Sat, 31 Dec 2018 23:59:59 GMT" — day-of-month zero padded, always GMT.
Class Method Details
.build(deprecation) ⇒ Hash
Returns header name => value; empty when there is nothing to say.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/end_point_blank/deprecation_headers.rb', line 34 def build(deprecation) return {} unless deprecation.is_a?(Hash) headers = {} if (at = parse(deprecation["deprecated_at"] || deprecation[:deprecated_at])) headers[DEPRECATION] = deprecation_value(at) end if (at = parse(deprecation["sunset_at"] || deprecation[:sunset_at])) headers[SUNSET] = sunset_value(at) end headers end |
.deprecation_value(time) ⇒ Object
"@1688169599" — no quotes, no sub-second precision.
51 52 53 |
# File 'lib/end_point_blank/deprecation_headers.rb', line 51 def deprecation_value(time) "@#{time.to_i}" end |
.sunset_value(time) ⇒ Object
"Sat, 31 Dec 2018 23:59:59 GMT" — day-of-month zero padded, always GMT.
56 57 58 59 60 61 62 |
# File 'lib/end_point_blank/deprecation_headers.rb', line 56 def sunset_value(time) t = time.utc format( "%s, %02d %s %04d %02d:%02d:%02d GMT", DAYS[t.wday], t.day, MONTHS[t.month - 1], t.year, t.hour, t.min, t.sec ) end |