( components: ComponentIdentifier[], params: SignatureParams, )
| 599 | } |
| 600 | |
| 601 | function buildSignatureParamsValue( |
| 602 | components: ComponentIdentifier[], |
| 603 | params: SignatureParams, |
| 604 | ): string { |
| 605 | // Build the inner list items (component identifiers as String items with params) |
| 606 | const items: Item[] = components.map((id) => { |
| 607 | const sfParams = new Map<string, BareItem>(); |
| 608 | const p = id.parameters ?? {}; |
| 609 | if (p.sf) sfParams.set("sf", { type: "boolean", value: true }); |
| 610 | if (p.key !== undefined) { |
| 611 | sfParams.set("key", { type: "string", value: p.key }); |
| 612 | } |
| 613 | if (p.bs) sfParams.set("bs", { type: "boolean", value: true }); |
| 614 | if (p.req) sfParams.set("req", { type: "boolean", value: true }); |
| 615 | // `;tr` is rejected upstream; add handling here when trailer support lands. |
| 616 | if (p.name !== undefined) { |
| 617 | sfParams.set("name", { type: "string", value: p.name }); |
| 618 | } |
| 619 | return sfItem(sfString(id.name), sfParams); |
| 620 | }); |
| 621 | |
| 622 | // Build the inner list parameters (signature metadata) |
| 623 | const listParams = new Map<string, BareItem>(); |
| 624 | if (params.created !== undefined) { |
| 625 | listParams.set("created", sfInteger(params.created)); |
| 626 | } |
| 627 | if (params.expires !== undefined) { |
| 628 | listParams.set("expires", sfInteger(params.expires)); |
| 629 | } |
| 630 | if (params.nonce !== undefined) { |
| 631 | listParams.set("nonce", sfString(params.nonce)); |
| 632 | } |
| 633 | if (params.algorithm !== undefined) { |
| 634 | listParams.set("alg", sfString(params.algorithm)); |
| 635 | } |
| 636 | if (params.keyId !== undefined) { |
| 637 | listParams.set("keyid", sfString(params.keyId)); |
| 638 | } |
| 639 | if (params.tag !== undefined) { |
| 640 | listParams.set("tag", sfString(params.tag)); |
| 641 | } |
| 642 | |
| 643 | const il = sfInnerList(items, listParams); |
| 644 | // Serialize just the inner list (not as a dictionary member) |
| 645 | return serializeInnerListValue(il); |
| 646 | } |
| 647 | |
| 648 | function serializeInnerListValue(il: InnerList): string { |
| 649 | const items = il.items.map((i) => serializeItem(i)).join(" "); |
no test coverage detected