@fedify/testing 2.4.0-dev.2093 → 2.4.0-dev.2103
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/dist/mod.cjs +18 -5
- package/dist/mod.js +19 -6
- package/package.json +4 -4
package/dist/mod.cjs
CHANGED
|
@@ -39,7 +39,7 @@ const noopMeterProvider$1 = { getMeter: () => ({
|
|
|
39
39
|
removeBatchObservableCallback: () => void 0
|
|
40
40
|
}) };
|
|
41
41
|
function createContext(values) {
|
|
42
|
-
const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, meterProvider, tracerProvider, clone, getNodeInfoUri, getActorUri, getObjectUri, getPortableObjectUri, getPortableInboxUri, getCollectionUri, getOutboxUri, getMediaUploaderUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject, traverseCollection, lookupNodeInfo, lookupWebFinger, sendActivity, routeActivity, enqueueTask, enqueueTaskMany } = values;
|
|
42
|
+
const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, meterProvider, tracerProvider, clone, getNodeInfoUri, getActorUri, getPortableActorUri, getObjectUri, getPortableObjectUri, getPortableInboxUri, getCollectionUri, getOutboxUri, getMediaUploaderUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject, traverseCollection, lookupNodeInfo, lookupWebFinger, sendActivity, routeActivity, enqueueTask, enqueueTaskMany } = values;
|
|
43
43
|
function throwRouterError() {
|
|
44
44
|
throw new _fedify_fedify_federation.RouterError("Not implemented");
|
|
45
45
|
}
|
|
@@ -60,6 +60,7 @@ function createContext(values) {
|
|
|
60
60
|
})),
|
|
61
61
|
getNodeInfoUri: getNodeInfoUri ?? throwRouterError,
|
|
62
62
|
getActorUri: getActorUri ?? throwRouterError,
|
|
63
|
+
getPortableActorUri: getPortableActorUri ?? throwRouterError,
|
|
63
64
|
getObjectUri: getObjectUri ?? throwRouterError,
|
|
64
65
|
getPortableObjectUri: getPortableObjectUri ?? throwRouterError,
|
|
65
66
|
getPortableInboxUri: getPortableInboxUri ?? throwRouterError,
|
|
@@ -230,6 +231,16 @@ function expandUriTemplate(template, values) {
|
|
|
230
231
|
}
|
|
231
232
|
});
|
|
232
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Builds an FEP-ef61 portable ID from a DID authority and a path, validating
|
|
236
|
+
* the authority the same way as `@fedify/fedify` does.
|
|
237
|
+
*/
|
|
238
|
+
function buildPortableUri(authority, path) {
|
|
239
|
+
if (typeof authority !== "string" || !/^did:[a-z0-9]+:[^/?#]+$/i.test(authority)) throw new TypeError("The authority of a portable ID must be a DID without a path, query, or fragment.");
|
|
240
|
+
const did = (0, _fedify_vocab_runtime.getFe34Origin)(authority);
|
|
241
|
+
if (did.startsWith("did:key:") && !/^z[1-9A-HJ-NP-Za-km-z]+$/.test(did.slice(8))) throw new TypeError("The did:key authority of a portable ID must be encoded in base58-btc, i.e., start with z.");
|
|
242
|
+
return (0, _fedify_vocab_runtime.parseIri)(`ap+ef61://${did}${path}`);
|
|
243
|
+
}
|
|
233
244
|
function validateOutboxListenerPath(path, dispatcherPath) {
|
|
234
245
|
if (!path.startsWith("/")) throw new TypeError("Path must start with a slash.");
|
|
235
246
|
if (dispatcherPath != null && dispatcherPath !== path) throw new TypeError("Outbox listener path and outbox dispatcher path must match.");
|
|
@@ -837,15 +848,17 @@ var MockContext = class MockContext {
|
|
|
837
848
|
const path = globalThis.Object.entries(values).map(([key, value]) => `${key}/${value}`).join("/");
|
|
838
849
|
return new URL(`/objects/${cls.name.toLowerCase()}/${path}`, this.origin);
|
|
839
850
|
}
|
|
851
|
+
getPortableActorUri(identifier, authority) {
|
|
852
|
+
const { pathname } = this.getActorUri(identifier);
|
|
853
|
+
return buildPortableUri(authority, pathname);
|
|
854
|
+
}
|
|
840
855
|
getPortableObjectUri(cls, values, authority) {
|
|
841
|
-
if (!/^did:[a-z0-9]+:[^/?#]+$/i.test(authority)) throw new TypeError("The authority of a portable ID must be a DID without a path, query, or fragment.");
|
|
842
856
|
const { pathname } = this.getObjectUri(cls, values);
|
|
843
|
-
return (
|
|
857
|
+
return buildPortableUri(authority, pathname);
|
|
844
858
|
}
|
|
845
859
|
getPortableInboxUri(identifier, authority) {
|
|
846
|
-
if (!/^did:[a-z0-9]+:[^/?#]+$/i.test(authority)) throw new TypeError("The authority of a portable ID must be a DID without a path, query, or fragment.");
|
|
847
860
|
const { pathname } = this.getInboxUri(identifier);
|
|
848
|
-
return (
|
|
861
|
+
return buildPortableUri(authority, pathname);
|
|
849
862
|
}
|
|
850
863
|
getOutboxUri(identifier) {
|
|
851
864
|
if (this.federation instanceof MockFederation && this.federation.outboxPath) {
|
package/dist/mod.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "temporal-polyfill";
|
|
2
2
|
import { hasProofLike, hasSignatureLike } from "@fedify/fedify/sig";
|
|
3
3
|
import { Activity, CryptographicKey, Multikey, lookupObject, traverseCollection } from "@fedify/vocab";
|
|
4
|
-
import { parseIri } from "@fedify/vocab-runtime";
|
|
4
|
+
import { getFe34Origin, parseIri } from "@fedify/vocab-runtime";
|
|
5
5
|
import { RouterError } from "@fedify/fedify/federation";
|
|
6
6
|
import { delay } from "es-toolkit";
|
|
7
7
|
import { deepStrictEqual, ok, strictEqual } from "node:assert/strict";
|
|
@@ -38,7 +38,7 @@ const noopMeterProvider$1 = { getMeter: () => ({
|
|
|
38
38
|
removeBatchObservableCallback: () => void 0
|
|
39
39
|
}) };
|
|
40
40
|
function createContext(values) {
|
|
41
|
-
const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, meterProvider, tracerProvider, clone, getNodeInfoUri, getActorUri, getObjectUri, getPortableObjectUri, getPortableInboxUri, getCollectionUri, getOutboxUri, getMediaUploaderUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject: lookupObject$1, traverseCollection: traverseCollection$1, lookupNodeInfo, lookupWebFinger, sendActivity, routeActivity, enqueueTask, enqueueTaskMany } = values;
|
|
41
|
+
const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, meterProvider, tracerProvider, clone, getNodeInfoUri, getActorUri, getPortableActorUri, getObjectUri, getPortableObjectUri, getPortableInboxUri, getCollectionUri, getOutboxUri, getMediaUploaderUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject: lookupObject$1, traverseCollection: traverseCollection$1, lookupNodeInfo, lookupWebFinger, sendActivity, routeActivity, enqueueTask, enqueueTaskMany } = values;
|
|
42
42
|
function throwRouterError() {
|
|
43
43
|
throw new RouterError("Not implemented");
|
|
44
44
|
}
|
|
@@ -59,6 +59,7 @@ function createContext(values) {
|
|
|
59
59
|
})),
|
|
60
60
|
getNodeInfoUri: getNodeInfoUri ?? throwRouterError,
|
|
61
61
|
getActorUri: getActorUri ?? throwRouterError,
|
|
62
|
+
getPortableActorUri: getPortableActorUri ?? throwRouterError,
|
|
62
63
|
getObjectUri: getObjectUri ?? throwRouterError,
|
|
63
64
|
getPortableObjectUri: getPortableObjectUri ?? throwRouterError,
|
|
64
65
|
getPortableInboxUri: getPortableInboxUri ?? throwRouterError,
|
|
@@ -229,6 +230,16 @@ function expandUriTemplate(template, values) {
|
|
|
229
230
|
}
|
|
230
231
|
});
|
|
231
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Builds an FEP-ef61 portable ID from a DID authority and a path, validating
|
|
235
|
+
* the authority the same way as `@fedify/fedify` does.
|
|
236
|
+
*/
|
|
237
|
+
function buildPortableUri(authority, path) {
|
|
238
|
+
if (typeof authority !== "string" || !/^did:[a-z0-9]+:[^/?#]+$/i.test(authority)) throw new TypeError("The authority of a portable ID must be a DID without a path, query, or fragment.");
|
|
239
|
+
const did = getFe34Origin(authority);
|
|
240
|
+
if (did.startsWith("did:key:") && !/^z[1-9A-HJ-NP-Za-km-z]+$/.test(did.slice(8))) throw new TypeError("The did:key authority of a portable ID must be encoded in base58-btc, i.e., start with z.");
|
|
241
|
+
return parseIri(`ap+ef61://${did}${path}`);
|
|
242
|
+
}
|
|
232
243
|
function validateOutboxListenerPath(path, dispatcherPath) {
|
|
233
244
|
if (!path.startsWith("/")) throw new TypeError("Path must start with a slash.");
|
|
234
245
|
if (dispatcherPath != null && dispatcherPath !== path) throw new TypeError("Outbox listener path and outbox dispatcher path must match.");
|
|
@@ -836,15 +847,17 @@ var MockContext = class MockContext {
|
|
|
836
847
|
const path = globalThis.Object.entries(values).map(([key, value]) => `${key}/${value}`).join("/");
|
|
837
848
|
return new URL(`/objects/${cls.name.toLowerCase()}/${path}`, this.origin);
|
|
838
849
|
}
|
|
850
|
+
getPortableActorUri(identifier, authority) {
|
|
851
|
+
const { pathname } = this.getActorUri(identifier);
|
|
852
|
+
return buildPortableUri(authority, pathname);
|
|
853
|
+
}
|
|
839
854
|
getPortableObjectUri(cls, values, authority) {
|
|
840
|
-
if (!/^did:[a-z0-9]+:[^/?#]+$/i.test(authority)) throw new TypeError("The authority of a portable ID must be a DID without a path, query, or fragment.");
|
|
841
855
|
const { pathname } = this.getObjectUri(cls, values);
|
|
842
|
-
return
|
|
856
|
+
return buildPortableUri(authority, pathname);
|
|
843
857
|
}
|
|
844
858
|
getPortableInboxUri(identifier, authority) {
|
|
845
|
-
if (!/^did:[a-z0-9]+:[^/?#]+$/i.test(authority)) throw new TypeError("The authority of a portable ID must be a DID without a path, query, or fragment.");
|
|
846
859
|
const { pathname } = this.getInboxUri(identifier);
|
|
847
|
-
return
|
|
860
|
+
return buildPortableUri(authority, pathname);
|
|
848
861
|
}
|
|
849
862
|
getOutboxUri(identifier) {
|
|
850
863
|
if (this.federation instanceof MockFederation && this.federation.outboxPath) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/testing",
|
|
3
|
-
"version": "2.4.0-dev.
|
|
3
|
+
"version": "2.4.0-dev.2103+3be829c0",
|
|
4
4
|
"description": "Testing utilities for Fedify applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"package.json"
|
|
48
48
|
],
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@fedify/fedify": "^2.4.0-dev.
|
|
50
|
+
"@fedify/fedify": "^2.4.0-dev.2103+3be829c0"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"es-toolkit": "1.46.1",
|
|
54
54
|
"temporal-polyfill": "^1.0.1",
|
|
55
|
-
"@fedify/vocab": "2.4.0-dev.
|
|
56
|
-
"@fedify/vocab-runtime": "^2.4.0-dev.
|
|
55
|
+
"@fedify/vocab": "2.4.0-dev.2103+3be829c0",
|
|
56
|
+
"@fedify/vocab-runtime": "^2.4.0-dev.2103+3be829c0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@standard-schema/spec": "^1.1.0",
|