@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.
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "@fedify/fedify",
3
- "version": "1.3.0-dev.576+5eedba62",
3
+ "version": "1.3.0-dev.577+bda6d57e",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./mod.ts",
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 async function fetchKey(keyId,
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"]);