@fedify/fedify 1.3.0-dev.576 → 1.3.0-dev.577
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fedify/fedify might be problematic. Click here for more details.
- package/esm/deno.js +1 -1
 - package/esm/sig/http.js +1 -1
 - package/esm/sig/key.js +35 -1
 - package/esm/vocab/vocab.js +173 -173
 - package/package.json +1 -1
 - package/types/sig/key.d.ts +2 -2
 - package/types/sig/key.d.ts.map +1 -1
 
    
        package/esm/deno.js
    CHANGED
    
    
    
        package/esm/sig/http.js
    CHANGED
    
    | 
         @@ -236,7 +236,6 @@ async function verifyRequestInternal(request, span, { documentLoader, contextLoa 
     | 
|
| 
       236 
236 
     | 
    
         
             
                }
         
     | 
| 
       237 
237 
     | 
    
         
             
                const { keyId, headers, signature } = sigValues;
         
     | 
| 
       238 
238 
     | 
    
         
             
                span?.setAttribute("http_signatures.key_id", keyId);
         
     | 
| 
       239 
     | 
    
         
            -
                span?.setAttribute("http_signatures.signature", signature);
         
     | 
| 
       240 
239 
     | 
    
         
             
                if ("algorithm" in sigValues) {
         
     | 
| 
       241 
240 
     | 
    
         
             
                    span?.setAttribute("http_signatures.algorithm", sigValues.algorithm);
         
     | 
| 
       242 
241 
     | 
    
         
             
                }
         
     | 
| 
         @@ -266,6 +265,7 @@ async function verifyRequestInternal(request, span, { documentLoader, contextLoa 
     | 
|
| 
       266 
265 
     | 
    
         
             
                            ? request.headers.get("host") ?? new URL(request.url).host
         
     | 
| 
       267 
266 
     | 
    
         
             
                            : request.headers.get(name))).join("\n");
         
     | 
| 
       268 
267 
     | 
    
         
             
                const sig = decodeBase64(signature);
         
     | 
| 
      
 268 
     | 
    
         
            +
                span?.setAttribute("http_signatures.signature", encodeHex(sig));
         
     | 
| 
       269 
269 
     | 
    
         
             
                // TODO: support other than RSASSA-PKCS1-v1_5:
         
     | 
| 
       270 
270 
     | 
    
         
             
                const verified = await dntShim.crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message));
         
     | 
| 
       271 
271 
     | 
    
         
             
                if (!verified) {
         
     | 
    
        package/esm/sig/key.js
    CHANGED
    
    | 
         @@ -1,5 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            import * as dntShim from "../_dnt.shims.js";
         
     | 
| 
       2 
2 
     | 
    
         
             
            import { getLogger } from "@logtape/logtape";
         
     | 
| 
      
 3 
     | 
    
         
            +
            import { SpanKind, SpanStatusCode, trace, } from "@opentelemetry/api";
         
     | 
| 
      
 4 
     | 
    
         
            +
            import metadata from "../deno.js";
         
     | 
| 
       3 
5 
     | 
    
         
             
            import { getDocumentLoader, } from "../runtime/docloader.js";
         
     | 
| 
       4 
6 
     | 
    
         
             
            import { isActor } from "../vocab/actor.js";
         
     | 
| 
       5 
7 
     | 
    
         
             
            import { CryptographicKey, Object } from "../vocab/vocab.js";
         
     | 
| 
         @@ -104,7 +106,39 @@ export async function importJwk(jwk, type) { 
     | 
|
| 
       104 
106 
     | 
    
         
             
             * @returns The fetched key or `null` if the key is not found.
         
     | 
| 
       105 
107 
     | 
    
         
             
             * @since 1.3.0
         
     | 
| 
       106 
108 
     | 
    
         
             
             */
         
     | 
| 
       107 
     | 
    
         
            -
            export  
     | 
| 
      
 109 
     | 
    
         
            +
            export function fetchKey(keyId, 
         
     | 
| 
      
 110 
     | 
    
         
            +
            // deno-lint-ignore no-explicit-any
         
     | 
| 
      
 111 
     | 
    
         
            +
            cls, options = {}) {
         
     | 
| 
      
 112 
     | 
    
         
            +
                const tracerProvider = options.tracerProvider ?? trace.getTracerProvider();
         
     | 
| 
      
 113 
     | 
    
         
            +
                const tracer = tracerProvider.getTracer(metadata.name, metadata.version);
         
     | 
| 
      
 114 
     | 
    
         
            +
                keyId = typeof keyId === "string" ? new URL(keyId) : keyId;
         
     | 
| 
      
 115 
     | 
    
         
            +
                return tracer.startActiveSpan("activitypub.fetch_key", {
         
     | 
| 
      
 116 
     | 
    
         
            +
                    kind: SpanKind.CLIENT,
         
     | 
| 
      
 117 
     | 
    
         
            +
                    attributes: {
         
     | 
| 
      
 118 
     | 
    
         
            +
                        "http.method": "GET",
         
     | 
| 
      
 119 
     | 
    
         
            +
                        "url.full": keyId.href,
         
     | 
| 
      
 120 
     | 
    
         
            +
                        "url.scheme": keyId.protocol.replace(/:$/, ""),
         
     | 
| 
      
 121 
     | 
    
         
            +
                        "url.domain": keyId.hostname,
         
     | 
| 
      
 122 
     | 
    
         
            +
                        "url.path": keyId.pathname,
         
     | 
| 
      
 123 
     | 
    
         
            +
                        "url.query": keyId.search.replace(/^\?/, ""),
         
     | 
| 
      
 124 
     | 
    
         
            +
                        "url.fragment": keyId.hash.replace(/^#/, ""),
         
     | 
| 
      
 125 
     | 
    
         
            +
                    },
         
     | 
| 
      
 126 
     | 
    
         
            +
                }, async (span) => {
         
     | 
| 
      
 127 
     | 
    
         
            +
                    try {
         
     | 
| 
      
 128 
     | 
    
         
            +
                        const result = await fetchKeyInternal(keyId, cls, options);
         
     | 
| 
      
 129 
     | 
    
         
            +
                        span.setAttribute("activitypub.actor.key.cached", result.cached);
         
     | 
| 
      
 130 
     | 
    
         
            +
                        return result;
         
     | 
| 
      
 131 
     | 
    
         
            +
                    }
         
     | 
| 
      
 132 
     | 
    
         
            +
                    catch (e) {
         
     | 
| 
      
 133 
     | 
    
         
            +
                        span.setStatus({ code: SpanStatusCode.ERROR, message: String(e) });
         
     | 
| 
      
 134 
     | 
    
         
            +
                        throw e;
         
     | 
| 
      
 135 
     | 
    
         
            +
                    }
         
     | 
| 
      
 136 
     | 
    
         
            +
                    finally {
         
     | 
| 
      
 137 
     | 
    
         
            +
                        span.end();
         
     | 
| 
      
 138 
     | 
    
         
            +
                    }
         
     | 
| 
      
 139 
     | 
    
         
            +
                });
         
     | 
| 
      
 140 
     | 
    
         
            +
            }
         
     | 
| 
      
 141 
     | 
    
         
            +
            async function fetchKeyInternal(keyId, 
         
     | 
| 
       108 
142 
     | 
    
         
             
            // deno-lint-ignore no-explicit-any
         
     | 
| 
       109 
143 
     | 
    
         
             
            cls, { documentLoader, contextLoader, keyCache, tracerProvider } = {}) {
         
     | 
| 
       110 
144 
     | 
    
         
             
                const logger = getLogger(["fedify", "sig", "key"]);
         
     |