MCPcopy Create free account
hub / github.com/denoland/std / assertUniqueLabel

Function assertUniqueLabel

http/unstable_message_signatures.ts:872–891  ·  view source on GitHub ↗
(headers: Headers, label: string)

Source from the content-addressed store, hash-verified

870// that silently corrupt prior signatures on parse (last value wins per
871// RFC 8941).
872function 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

Callers 1

signMessageFunction · 0.85

Calls 3

parseDictionaryFunction · 0.90
getMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected