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

Function createSignatureBase

http/unstable_message_signatures.ts:705–747  ·  view source on GitHub ↗
(
  options: CreateSignatureBaseOptions,
)

Source from the content-addressed store, hash-verified

703 * @returns The signature base string.
704 */
705export function createSignatureBase(
706 options: CreateSignatureBaseOptions,
707): string {
708 const { message, params, request: relatedRequest } = options;
709 const components = params.components.map(normalizeIdentifier);
710
711 const seen = new Set<string>();
712 const lines: string[] = [];
713 const parsedUrl: { value?: URL } = {};
714 const relatedParsedUrl: { value?: URL } = {};
715 for (const id of components) {
716 if (id.name === "@signature-params") {
717 throw new TypeError(
718 `"@signature-params" must not be listed in covered components`,
719 );
720 }
721 if (id.name !== id.name.toLowerCase()) {
722 throw new TypeError(
723 `Component name "${id.name}" must be lowercase`,
724 );
725 }
726 const serializedId = serializeComponentIdentifier(id);
727 if (seen.has(serializedId)) {
728 throw new TypeError(
729 `Duplicate component identifier ${serializedId} in covered components`,
730 );
731 }
732 seen.add(serializedId);
733 const value = resolveComponentValue(
734 id,
735 message,
736 parsedUrl,
737 relatedRequest,
738 relatedParsedUrl,
739 );
740 lines.push(`${serializedId}: ${value}`);
741 }
742
743 const sigParamsValue = buildSignatureParamsValue(components, params);
744 lines.push(`"@signature-params": ${sigParamsValue}`);
745
746 return lines.join("\n");
747}
748
749// =============================================================================
750// Input Validation

Callers 3

signMessageFunction · 0.85
verifyMessageFunction · 0.85

Calls 6

resolveComponentValueFunction · 0.85
hasMethod · 0.65
addMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected