(headers: Headers, label: string)
| 870 | // that silently corrupt prior signatures on parse (last value wins per |
| 871 | // RFC 8941). |
| 872 | function assertUniqueLabel(headers: Headers, label: string): void { |
| 873 | for (const name of ["Signature-Input", "Signature"] as const) { |
| 874 | const value = headers.get(name); |
| 875 | if (value === null) continue; |
| 876 | let dict: Dictionary; |
| 877 | try { |
| 878 | dict = parseDictionary(value); |
| 879 | } catch (cause) { |
| 880 | throw new TypeError( |
| 881 | `Cannot parse existing "${name}" header on message to check label uniqueness`, |
| 882 | { cause }, |
| 883 | ); |
| 884 | } |
| 885 | if (dict.has(label)) { |
| 886 | throw new TypeError( |
| 887 | `Signature label "${label}" is already present in the "${name}" header on the message; choose a unique label (RFC 9421 section 4)`, |
| 888 | ); |
| 889 | } |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | // ============================================================================= |
| 894 | // verifyMessage |
no test coverage detected