@fedify/fedify 1.3.0-dev.575 → 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 +1 -1
- package/esm/federation/handler.js +154 -59
- package/esm/federation/inbox.js +5 -2
- package/esm/federation/middleware.js +105 -63
- 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/federation/handler.d.ts +1 -1
- package/types/federation/handler.d.ts.map +1 -1
- package/types/federation/inbox.d.ts +4 -0
- package/types/federation/inbox.d.ts.map +1 -1
- package/types/federation/middleware.d.ts.map +1 -1
- package/types/federation/queue.d.ts +1 -0
- package/types/federation/queue.d.ts.map +1 -1
- package/types/sig/key.d.ts +2 -2
- package/types/sig/key.d.ts.map +1 -1
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"]);
|