@fedify/fedify 1.6.1-dev.849 → 1.6.1-dev.856
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/_virtual/rolldown_runtime.js +26 -1
- package/dist/codegen/schema.js +5 -4
- package/dist/deno.js +15 -2
- package/dist/federation/context.d.ts +27 -0
- package/dist/federation/handler.test.js +24 -5
- package/dist/federation/middleware.js +34 -1
- package/dist/federation/middleware.test.js +90 -53
- package/dist/federation/send.test.js +8 -10
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/constants.js +1 -7
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/dirname.js +1 -1
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/_common/from_file_url.js +1 -1
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/dirname.js +1 -32
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/join.js +1 -32
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/mod.js +0 -2
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/dirname.js +2 -2
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/from_file_url.js +1 -1
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/posix/join.js +1 -1
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/from_file_url.js +1 -1
- package/dist/node_modules/.pnpm/@jsr_std__url@1.0.0-rc.3/node_modules/@jsr/std__url/dirname.js +2 -2
- package/dist/node_modules/.pnpm/@jsr_std__url@1.0.0-rc.3/node_modules/@jsr/std__url/join.js +2 -2
- package/dist/node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/dist/index.js +68 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/CallHistory.js +94 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/FetchMock.js +143 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/IsSubsetOf.js +103 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Matchers.js +195 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/RequestUtils.js +83 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Route.js +137 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/Router.js +181 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/StatusTextMap.js +73 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/TypeDescriptor.js +97 -0
- package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/index.js +11 -0
- package/dist/node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js +87 -0
- package/dist/node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.js +37 -0
- package/dist/runtime/authdocloader.test.js +5 -5
- package/dist/runtime/docloader.js +1 -1
- package/dist/runtime/docloader.test.js +8 -0
- package/dist/sig/key.js +7 -2
- package/dist/testing/context.js +14 -2
- package/dist/testing/docloader.js +34 -15
- package/dist/testing/fixtures/example.com/{hong-gildong → hong-gildong.json} +1 -1
- package/dist/testing/fixtures/example.com/{object → object.json} +1 -1
- package/dist/testing/fixtures/example.com/person.js +29 -0
- package/dist/testing/fixtures/example.com/person2.js +48 -0
- package/dist/testing/fixtures/example.com/{test → test.json} +1 -1
- package/dist/testing/fixtures/w3id.org/security/data-integrity/{v1 → v1.json} +1 -1
- package/dist/testing/fixtures/w3id.org/security/{v1 → v1.json} +9 -9
- package/dist/testing/mod.d.ts +11 -0
- package/dist/testing/mod.js +44 -38
- package/dist/vocab/lookup.test.js +30 -35
- package/dist/vocab/vocab.js +176 -176
- package/dist/vocab/vocab.test.js +2 -2
- package/package.json +8 -3
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/_util.js +0 -19
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/dirname.js +0 -75
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/join.js +0 -54
- package/dist/node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/windows/normalize.js +0 -87
- /package/dist/testing/fixtures/activitypub.academy/users/{brauca_darradiul → brauca_darradiul.json} +0 -0
- /package/dist/testing/fixtures/example.com/{announce → announce.json} +0 -0
- /package/dist/testing/fixtures/example.com/{collection → collection.json} +0 -0
- /package/dist/testing/fixtures/example.com/{create → create.json} +0 -0
- /package/dist/testing/fixtures/example.com/{cross-origin-actor → cross-origin-actor.json} +0 -0
- /package/dist/testing/fixtures/example.com/{invite → invite.json} +0 -0
- /package/dist/testing/fixtures/example.com/{key → key.json} +0 -0
- /package/dist/testing/fixtures/example.com/{key2 → key2.json} +0 -0
- /package/dist/testing/fixtures/example.com/{orderedcollectionpage → orderedcollectionpage.json} +0 -0
- /package/dist/testing/fixtures/example.com/paged/{a → a.json} +0 -0
- /package/dist/testing/fixtures/example.com/paged/{b → b.json} +0 -0
- /package/dist/testing/fixtures/example.com/{paged-collection → paged-collection.json} +0 -0
- /package/dist/testing/fixtures/example.com/{person → person.json} +0 -0
- /package/dist/testing/fixtures/example.com/{person2 → person2.json} +0 -0
- /package/dist/testing/fixtures/example.com/users/{handle → handle.json} +0 -0
- /package/dist/testing/fixtures/example.com/{wrong-type → wrong-type.json} +0 -0
- /package/dist/testing/fixtures/remote.domain/users/{bob → bob.json} +0 -0
- /package/dist/testing/fixtures/server.example/users/{alice → alice.json} +0 -0
- /package/dist/testing/fixtures/w3id.org/identity/{v1 → v1.json} +0 -0
- /package/dist/testing/fixtures/w3id.org/security/multikey/{v1 → v1.json} +0 -0
- /package/dist/testing/fixtures/wizard.casa/users/{hongminhee → hongminhee.json} +0 -0
- /package/dist/testing/fixtures/www.w3.org/ns/{activitystreams → activitystreams.json} +0 -0
- /package/dist/testing/fixtures/www.w3.org/ns/did/{v1 → v1.json} +0 -0
package/dist/node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/TypeDescriptor.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
|
|
5
|
+
//#region node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/TypeDescriptor.js
|
|
6
|
+
const valueTypes = new Set([
|
|
7
|
+
"boolean",
|
|
8
|
+
"number",
|
|
9
|
+
"null",
|
|
10
|
+
"string",
|
|
11
|
+
"undefined"
|
|
12
|
+
]);
|
|
13
|
+
const referenceTypes = new Set([
|
|
14
|
+
"array",
|
|
15
|
+
"function",
|
|
16
|
+
"object",
|
|
17
|
+
"symbol"
|
|
18
|
+
]);
|
|
19
|
+
const detectableTypes = new Set([
|
|
20
|
+
"boolean",
|
|
21
|
+
"function",
|
|
22
|
+
"number",
|
|
23
|
+
"string",
|
|
24
|
+
"symbol"
|
|
25
|
+
]);
|
|
26
|
+
const typeConstructors = new Set([
|
|
27
|
+
Boolean,
|
|
28
|
+
Number,
|
|
29
|
+
String
|
|
30
|
+
]);
|
|
31
|
+
var TypeDescriptor = class TypeDescriptor {
|
|
32
|
+
constructor(value) {
|
|
33
|
+
this.name = TypeDescriptor.of(value);
|
|
34
|
+
this.isValueType = TypeDescriptor.isValueType(value);
|
|
35
|
+
this.isReferenceType = TypeDescriptor.isReferenceType(value);
|
|
36
|
+
this.isArray = TypeDescriptor.isArray(value);
|
|
37
|
+
this.isBoolean = TypeDescriptor.isBoolean(value);
|
|
38
|
+
this.isFunction = TypeDescriptor.isFunction(value);
|
|
39
|
+
this.isNull = TypeDescriptor.isNull(value);
|
|
40
|
+
this.isNumber = TypeDescriptor.isNumber(value);
|
|
41
|
+
this.isObject = TypeDescriptor.isObject(value);
|
|
42
|
+
this.isString = TypeDescriptor.isString(value);
|
|
43
|
+
this.isSymbol = TypeDescriptor.isSymbol(value);
|
|
44
|
+
this.isUndefined = TypeDescriptor.isUndefined(value);
|
|
45
|
+
}
|
|
46
|
+
static of(value) {
|
|
47
|
+
if (value === null) return "null";
|
|
48
|
+
if (value === void 0) return "undefined";
|
|
49
|
+
const detectedType = typeof value;
|
|
50
|
+
if (detectableTypes.has(detectedType)) return detectedType;
|
|
51
|
+
if (detectedType === "object") {
|
|
52
|
+
if (Array.isArray(value)) return "array";
|
|
53
|
+
if (typeConstructors.has(value.constructor)) return value.constructor.name.toLowerCase();
|
|
54
|
+
return detectedType;
|
|
55
|
+
}
|
|
56
|
+
throw new Error("Failed due to an unknown type.");
|
|
57
|
+
}
|
|
58
|
+
static from(value) {
|
|
59
|
+
return new TypeDescriptor(value);
|
|
60
|
+
}
|
|
61
|
+
static isValueType(value) {
|
|
62
|
+
return valueTypes.has(TypeDescriptor.of(value));
|
|
63
|
+
}
|
|
64
|
+
static isReferenceType(value) {
|
|
65
|
+
return referenceTypes.has(TypeDescriptor.of(value));
|
|
66
|
+
}
|
|
67
|
+
static isArray(value) {
|
|
68
|
+
return TypeDescriptor.of(value) === "array";
|
|
69
|
+
}
|
|
70
|
+
static isBoolean(value) {
|
|
71
|
+
return TypeDescriptor.of(value) === "boolean";
|
|
72
|
+
}
|
|
73
|
+
static isFunction(value) {
|
|
74
|
+
return TypeDescriptor.of(value) === "function";
|
|
75
|
+
}
|
|
76
|
+
static isNull(value) {
|
|
77
|
+
return TypeDescriptor.of(value) === "null";
|
|
78
|
+
}
|
|
79
|
+
static isNumber(value) {
|
|
80
|
+
return TypeDescriptor.of(value) === "number";
|
|
81
|
+
}
|
|
82
|
+
static isObject(value) {
|
|
83
|
+
return TypeDescriptor.of(value) === "object";
|
|
84
|
+
}
|
|
85
|
+
static isString(value) {
|
|
86
|
+
return TypeDescriptor.of(value) === "string";
|
|
87
|
+
}
|
|
88
|
+
static isSymbol(value) {
|
|
89
|
+
return TypeDescriptor.of(value) === "symbol";
|
|
90
|
+
}
|
|
91
|
+
static isUndefined(value) {
|
|
92
|
+
return TypeDescriptor.of(value) === "undefined";
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
export { TypeDescriptor };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
|
|
5
|
+
import { FetchMock, FetchMock_default, defaultFetchMockConfig } from "./FetchMock.js";
|
|
6
|
+
|
|
7
|
+
//#region node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/index.js
|
|
8
|
+
var esm_default = FetchMock_default;
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { esm_default };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
|
|
5
|
+
import { __commonJS } from "../../../../../_virtual/rolldown_runtime.js";
|
|
6
|
+
|
|
7
|
+
//#region node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js
|
|
8
|
+
var require_glob_to_regexp = __commonJS({ "node_modules/.pnpm/glob-to-regexp@0.4.1/node_modules/glob-to-regexp/index.js"(exports, module) {
|
|
9
|
+
module.exports = function(glob, opts) {
|
|
10
|
+
if (typeof glob !== "string") throw new TypeError("Expected a string");
|
|
11
|
+
var str = String(glob);
|
|
12
|
+
var reStr = "";
|
|
13
|
+
var extended = opts ? !!opts.extended : false;
|
|
14
|
+
var globstar = opts ? !!opts.globstar : false;
|
|
15
|
+
var inGroup = false;
|
|
16
|
+
var flags = opts && typeof opts.flags === "string" ? opts.flags : "";
|
|
17
|
+
var c;
|
|
18
|
+
for (var i = 0, len = str.length; i < len; i++) {
|
|
19
|
+
c = str[i];
|
|
20
|
+
switch (c) {
|
|
21
|
+
case "/":
|
|
22
|
+
case "$":
|
|
23
|
+
case "^":
|
|
24
|
+
case "+":
|
|
25
|
+
case ".":
|
|
26
|
+
case "(":
|
|
27
|
+
case ")":
|
|
28
|
+
case "=":
|
|
29
|
+
case "!":
|
|
30
|
+
case "|":
|
|
31
|
+
reStr += "\\" + c;
|
|
32
|
+
break;
|
|
33
|
+
case "?": if (extended) {
|
|
34
|
+
reStr += ".";
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case "[":
|
|
38
|
+
case "]": if (extended) {
|
|
39
|
+
reStr += c;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case "{": if (extended) {
|
|
43
|
+
inGroup = true;
|
|
44
|
+
reStr += "(";
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case "}": if (extended) {
|
|
48
|
+
inGroup = false;
|
|
49
|
+
reStr += ")";
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
case ",":
|
|
53
|
+
if (inGroup) {
|
|
54
|
+
reStr += "|";
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
reStr += "\\" + c;
|
|
58
|
+
break;
|
|
59
|
+
case "*":
|
|
60
|
+
var prevChar = str[i - 1];
|
|
61
|
+
var starCount = 1;
|
|
62
|
+
while (str[i + 1] === "*") {
|
|
63
|
+
starCount++;
|
|
64
|
+
i++;
|
|
65
|
+
}
|
|
66
|
+
var nextChar = str[i + 1];
|
|
67
|
+
if (!globstar) reStr += ".*";
|
|
68
|
+
else {
|
|
69
|
+
var isGlobstar = starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0);
|
|
70
|
+
if (isGlobstar) {
|
|
71
|
+
reStr += "((?:[^/]*(?:/|$))*)";
|
|
72
|
+
i++;
|
|
73
|
+
} else reStr += "([^/]*)";
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
default: reStr += c;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!flags || !~flags.indexOf("g")) reStr = "^" + reStr + "$";
|
|
80
|
+
return new RegExp(reStr, flags);
|
|
81
|
+
};
|
|
82
|
+
} });
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
export default require_glob_to_regexp();
|
|
86
|
+
|
|
87
|
+
export { require_glob_to_regexp };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
|
|
5
|
+
//#region node_modules/.pnpm/regexparam@3.0.0/node_modules/regexparam/dist/index.mjs
|
|
6
|
+
/**
|
|
7
|
+
* @param {string|RegExp} input The route pattern
|
|
8
|
+
* @param {boolean} [loose] Allow open-ended matching. Ignored with `RegExp` input.
|
|
9
|
+
*/
|
|
10
|
+
function parse(input, loose) {
|
|
11
|
+
if (input instanceof RegExp) return {
|
|
12
|
+
keys: false,
|
|
13
|
+
pattern: input
|
|
14
|
+
};
|
|
15
|
+
var c, o, tmp, ext, keys = [], pattern = "", arr = input.split("/");
|
|
16
|
+
arr[0] || arr.shift();
|
|
17
|
+
while (tmp = arr.shift()) {
|
|
18
|
+
c = tmp[0];
|
|
19
|
+
if (c === "*") {
|
|
20
|
+
keys.push(c);
|
|
21
|
+
pattern += tmp[1] === "?" ? "(?:/(.*))?" : "/(.*)";
|
|
22
|
+
} else if (c === ":") {
|
|
23
|
+
o = tmp.indexOf("?", 1);
|
|
24
|
+
ext = tmp.indexOf(".", 1);
|
|
25
|
+
keys.push(tmp.substring(1, !!~o ? o : !!~ext ? ext : tmp.length));
|
|
26
|
+
pattern += !!~o && !~ext ? "(?:/([^/]+?))?" : "/([^/]+?)";
|
|
27
|
+
if (!!~ext) pattern += (!!~o ? "?" : "") + "\\" + tmp.substring(ext);
|
|
28
|
+
} else pattern += "/" + tmp;
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
keys,
|
|
32
|
+
pattern: new RegExp("^" + pattern + (loose ? "(?=$|/)" : "/?$"), "i")
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { parse as parse$1 };
|
|
@@ -10,13 +10,13 @@ import { test } from "../testing/mod.js";
|
|
|
10
10
|
import { assertRejects } from "../node_modules/.pnpm/@jsr_std__assert@0.226.0/node_modules/@jsr/std__assert/assert_rejects.js";
|
|
11
11
|
import { mockDocumentLoader } from "../testing/docloader.js";
|
|
12
12
|
import { rsaPrivateKey2 } from "../testing/keys.js";
|
|
13
|
-
import {
|
|
13
|
+
import { esm_default } from "../node_modules/.pnpm/fetch-mock@12.5.2/node_modules/fetch-mock/dist/esm/index.js";
|
|
14
14
|
|
|
15
15
|
//#region runtime/authdocloader.test.ts
|
|
16
16
|
test("getAuthenticatedDocumentLoader()", async (t) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const v = await verifyRequest(
|
|
17
|
+
esm_default.spyGlobal();
|
|
18
|
+
esm_default.get("begin:https://example.com/object", async (cl) => {
|
|
19
|
+
const v = await verifyRequest(cl.request, {
|
|
20
20
|
documentLoader: mockDocumentLoader,
|
|
21
21
|
contextLoader: mockDocumentLoader,
|
|
22
22
|
currentTime: Temporal.Now.instant()
|
|
@@ -34,7 +34,7 @@ test("getAuthenticatedDocumentLoader()", async (t) => {
|
|
|
34
34
|
document: true
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
|
-
|
|
37
|
+
esm_default.hardReset();
|
|
38
38
|
await t.step("deny non-HTTP/HTTPS", async () => {
|
|
39
39
|
const loader = await getAuthenticatedDocumentLoader({
|
|
40
40
|
keyId: new URL("https://example.com/key2"),
|
|
@@ -279,7 +279,7 @@ function kvCache({ loader, kv, prefix, rules }) {
|
|
|
279
279
|
*/
|
|
280
280
|
function getUserAgent({ software, url } = {}) {
|
|
281
281
|
const fedify = `Fedify/${deno_default.version}`;
|
|
282
|
-
const runtime = globalThis.Deno?.version?.deno != null ? `Deno/${Deno.version.deno}` : globalThis.process?.versions?.bun != null ? `Bun/${process.versions.bun}` : globalThis.process?.versions?.node != null ? `Node.js/${process.versions.node}` : null;
|
|
282
|
+
const runtime = globalThis.Deno?.version?.deno != null ? `Deno/${Deno.version.deno}` : globalThis.process?.versions?.bun != null ? `Bun/${process.versions.bun}` : "navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers" ? navigator.userAgent : globalThis.process?.versions?.node != null ? `Node.js/${process.versions.node}` : null;
|
|
283
283
|
const userAgent = software == null ? [fedify] : [software, fedify];
|
|
284
284
|
if (runtime != null) userAgent.push(runtime);
|
|
285
285
|
if (url != null) userAgent.push(`+${url.toString()}`);
|
|
@@ -414,6 +414,14 @@ test("getUserAgent()", () => {
|
|
|
414
414
|
software: "MyApp/1.0.0",
|
|
415
415
|
url: new URL("https://example.com/")
|
|
416
416
|
}), `MyApp/1.0.0 (Fedify/${deno_default.version}; Bun/${Bun.version}; +https://example.com/)`);
|
|
417
|
+
} else if (navigator.userAgent === "Cloudflare-Workers") {
|
|
418
|
+
assertEquals(getUserAgent(), `Fedify/${deno_default.version} (Cloudflare-Workers)`);
|
|
419
|
+
assertEquals(getUserAgent({ software: "MyApp/1.0.0" }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Cloudflare-Workers)`);
|
|
420
|
+
assertEquals(getUserAgent({ url: "https://example.com/" }), `Fedify/${deno_default.version} (Cloudflare-Workers; +https://example.com/)`);
|
|
421
|
+
assertEquals(getUserAgent({
|
|
422
|
+
software: "MyApp/1.0.0",
|
|
423
|
+
url: new URL("https://example.com/")
|
|
424
|
+
}), `MyApp/1.0.0 (Fedify/${deno_default.version}; Cloudflare-Workers; +https://example.com/)`);
|
|
417
425
|
} else {
|
|
418
426
|
assertEquals(getUserAgent(), `Fedify/${deno_default.version} (Node.js/${process.versions.node})`);
|
|
419
427
|
assertEquals(getUserAgent({ software: "MyApp/1.0.0" }), `MyApp/1.0.0 (Fedify/${deno_default.version}; Node.js/${process.versions.node})`);
|
package/dist/sig/key.js
CHANGED
|
@@ -79,8 +79,13 @@ async function importJwk(jwk, type) {
|
|
|
79
79
|
name: "RSASSA-PKCS1-v1_5",
|
|
80
80
|
hash: "SHA-256"
|
|
81
81
|
}, true, type === "public" ? ["verify"] : ["sign"]);
|
|
82
|
-
else if (jwk.kty === "OKP" && jwk.crv === "Ed25519")
|
|
83
|
-
|
|
82
|
+
else if (jwk.kty === "OKP" && jwk.crv === "Ed25519") {
|
|
83
|
+
if (navigator?.userAgent === "Cloudflare-Workers") {
|
|
84
|
+
jwk = { ...jwk };
|
|
85
|
+
delete jwk.alg;
|
|
86
|
+
}
|
|
87
|
+
key = await crypto.subtle.importKey("jwk", jwk, "Ed25519", true, type === "public" ? ["verify"] : ["sign"]);
|
|
88
|
+
} else throw new TypeError("Unsupported JWK format.");
|
|
84
89
|
validateCryptoKey(key, type);
|
|
85
90
|
return key;
|
|
86
91
|
}
|
package/dist/testing/context.js
CHANGED
|
@@ -9,11 +9,11 @@ import { mockDocumentLoader } from "./docloader.js";
|
|
|
9
9
|
import { trace } from "@opentelemetry/api";
|
|
10
10
|
|
|
11
11
|
//#region testing/context.ts
|
|
12
|
-
function createContext(
|
|
12
|
+
function createContext(values) {
|
|
13
|
+
const { federation, url = new URL("http://example.com/"), canonicalOrigin, data, documentLoader, contextLoader, tracerProvider, clone, getNodeInfoUri, getActorUri, getObjectUri, getOutboxUri, getInboxUri, getFollowingUri, getFollowersUri, getLikedUri, getFeaturedUri, getFeaturedTagsUri, parseUri, getActorKeyPairs, getDocumentLoader, lookupObject: lookupObject$1, traverseCollection: traverseCollection$1, lookupNodeInfo, lookupWebFinger: lookupWebFinger$1, sendActivity, routeActivity } = values;
|
|
13
14
|
function throwRouteError() {
|
|
14
15
|
throw new RouterError("Not implemented");
|
|
15
16
|
}
|
|
16
|
-
url ??= new URL("http://example.com/");
|
|
17
17
|
return {
|
|
18
18
|
federation,
|
|
19
19
|
data,
|
|
@@ -24,6 +24,10 @@ function createContext({ federation, url, canonicalOrigin, data, documentLoader,
|
|
|
24
24
|
documentLoader: documentLoader ?? mockDocumentLoader,
|
|
25
25
|
contextLoader: contextLoader ?? mockDocumentLoader,
|
|
26
26
|
tracerProvider: tracerProvider ?? trace.getTracerProvider(),
|
|
27
|
+
clone: clone ?? ((data$1) => createContext({
|
|
28
|
+
...values,
|
|
29
|
+
data: data$1
|
|
30
|
+
})),
|
|
27
31
|
getNodeInfoUri: getNodeInfoUri ?? throwRouteError,
|
|
28
32
|
getActorUri: getActorUri ?? throwRouteError,
|
|
29
33
|
getObjectUri: getObjectUri ?? throwRouteError,
|
|
@@ -70,6 +74,10 @@ function createContext({ federation, url, canonicalOrigin, data, documentLoader,
|
|
|
70
74
|
function createRequestContext(args) {
|
|
71
75
|
return {
|
|
72
76
|
...createContext(args),
|
|
77
|
+
clone: args.clone ?? ((data) => createRequestContext({
|
|
78
|
+
...args,
|
|
79
|
+
data
|
|
80
|
+
})),
|
|
73
81
|
request: args.request ?? new Request(args.url),
|
|
74
82
|
url: args.url,
|
|
75
83
|
getActor: args.getActor ?? (() => Promise.resolve(null)),
|
|
@@ -84,6 +92,10 @@ function createRequestContext(args) {
|
|
|
84
92
|
function createInboxContext(args) {
|
|
85
93
|
return {
|
|
86
94
|
...createContext(args),
|
|
95
|
+
clone: args.clone ?? ((data) => createInboxContext({
|
|
96
|
+
...args,
|
|
97
|
+
data
|
|
98
|
+
})),
|
|
87
99
|
recipient: args.recipient ?? null,
|
|
88
100
|
forwardActivity: args.forwardActivity ?? ((_params) => {
|
|
89
101
|
throw new Error("Not implemented");
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
|
-
import { dirname } from "../node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/dirname.js";
|
|
6
|
-
import { fromFileUrl } from "../node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/from_file_url.js";
|
|
7
|
-
import { join } from "../node_modules/.pnpm/@jsr_std__path@1.0.9/node_modules/@jsr/std__path/join.js";
|
|
8
5
|
import { getLogger } from "@logtape/logtape";
|
|
9
|
-
import { readFileSync } from "node:fs";
|
|
10
6
|
|
|
11
7
|
//#region testing/docloader.ts
|
|
12
8
|
const logger = getLogger([
|
|
@@ -22,26 +18,49 @@ const logger = getLogger([
|
|
|
22
18
|
* the file `testing/fixtures/http/example.com/foo/bar` (no suffix) and return
|
|
23
19
|
* its content as the response.
|
|
24
20
|
*/
|
|
25
|
-
function mockDocumentLoader(resource) {
|
|
21
|
+
async function mockDocumentLoader(resource) {
|
|
26
22
|
const url = new URL(resource);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
if ("navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers") {
|
|
24
|
+
const testUrl = new URL(url);
|
|
25
|
+
testUrl.hostname += ".test";
|
|
26
|
+
const resp = await fetch(testUrl);
|
|
27
|
+
if (resp.ok) {
|
|
28
|
+
const document$1 = await resp.json();
|
|
29
|
+
logger.debug("Successfully fetched fixture {resource}: {status} {statusText}\n{body}", {
|
|
30
|
+
resource,
|
|
31
|
+
status: resp.status,
|
|
32
|
+
statusText: resp.statusText,
|
|
33
|
+
body: document$1
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
contextUrl: null,
|
|
37
|
+
document: document$1,
|
|
38
|
+
documentUrl: resource
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const error = await resp.text();
|
|
42
|
+
logger.error("Failed to fetch fixture {resource}: {error}", {
|
|
43
|
+
resource,
|
|
44
|
+
error
|
|
45
|
+
});
|
|
46
|
+
throw new Error(error);
|
|
47
|
+
}
|
|
48
|
+
const path = `./fixtures/${url.host}${url.pathname}.json`;
|
|
49
|
+
let document;
|
|
31
50
|
try {
|
|
32
|
-
|
|
51
|
+
document = (await import(path, { with: { type: "json" } })).default;
|
|
33
52
|
} catch (error) {
|
|
34
|
-
logger.error("Failed to read fixture file {
|
|
35
|
-
|
|
53
|
+
logger.error("Failed to read fixture file {path}: {error}", {
|
|
54
|
+
path,
|
|
36
55
|
error
|
|
37
56
|
});
|
|
38
57
|
throw error;
|
|
39
58
|
}
|
|
40
|
-
return
|
|
59
|
+
return {
|
|
41
60
|
contextUrl: null,
|
|
42
|
-
document
|
|
61
|
+
document,
|
|
43
62
|
documentUrl: resource
|
|
44
|
-
}
|
|
63
|
+
};
|
|
45
64
|
}
|
|
46
65
|
|
|
47
66
|
//#endregion
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
|
|
5
|
+
//#region testing/fixtures/example.com/person.json
|
|
6
|
+
var __context = ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"];
|
|
7
|
+
var id = "https://example.com/person";
|
|
8
|
+
var type = "Person";
|
|
9
|
+
var name = "John Doe";
|
|
10
|
+
var publicKey = [{
|
|
11
|
+
"id": "https://example.com/key",
|
|
12
|
+
"owner": "https://example.com/person",
|
|
13
|
+
"type": "CryptographicKey",
|
|
14
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyIB9rotX8G6r6/6toT+x\n24BUiQ/HaPH1Em9dOt4c94s+OPFoEdH7DY7Iym9A8LlH4JaGF8KD38bLHWe1S4x0\njV3gHJKhK7veJfGZCKUENcQecBZ+YWUs5HWvUIX1vVB//0luHrg6BQKGOrSOE+WI\nAxyr0qsWCFfZzQrvSnUD2yvg1arJX2xhms14uxoRd5Kg9efKSCmmQaNEapicARUm\nFWrIEpGFa/nUUnqimssAGw1eZFqf3wA4TjhsuARBhGaJtv/3KEa016eMZxy3kDlO\njZnXZTaTgWkXdodwUvy8563fes3Al6BlcS2iJ9qbtha8rSm0FHqoUKH73JsLPKQI\nwQIDAQAB\n-----END PUBLIC KEY-----"
|
|
15
|
+
}, {
|
|
16
|
+
"id": "https://example.com/key2",
|
|
17
|
+
"type": "CryptographicKey",
|
|
18
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoRmBtnxbdFutoRd1GLGw\nwGTrsqlRRWUe11hHQaoRLGf5LwQ0tIc6I9q+dynliw+2kxYsLn9SH2je6HcTYOol\ngW7F/cOWXZQN04b+OiYcU1ConAhLjmn4k1uKawJ614y0ScPNd8PQ+CljsnlPxbq9\nofaCMe2BV3B6y09aCuGFJ0nxn1/ubjmIBIWWFTAznoz1J9BhJDGyt3IO3ABy3f9z\nDVlR32L/n5VIkXnxkjUKdzMAOzYb62kuKOp1iznRTPrV71SNtivJMwSh/LVgBrmZ\njtIn/oim+KyX/fdLU3tQ7VClyqmJzyAjccOH6Qj6nFTPh+vX07gqN8IlLT2uye4w\nawIDAQAB\n-----END PUBLIC KEY-----"
|
|
19
|
+
}];
|
|
20
|
+
var person_default = {
|
|
21
|
+
"@context": __context,
|
|
22
|
+
id,
|
|
23
|
+
type,
|
|
24
|
+
name,
|
|
25
|
+
publicKey
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { person_default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
|
|
5
|
+
//#region testing/fixtures/example.com/person2.json
|
|
6
|
+
var __context = [
|
|
7
|
+
"https://www.w3.org/ns/activitystreams",
|
|
8
|
+
"https://w3id.org/security/v1",
|
|
9
|
+
"https://w3id.org/security/multikey/v1",
|
|
10
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
11
|
+
"https://www.w3.org/ns/did/v1"
|
|
12
|
+
];
|
|
13
|
+
var id = "https://example.com/person2";
|
|
14
|
+
var type = "Person";
|
|
15
|
+
var name = "Jane Doe";
|
|
16
|
+
var publicKey = [{
|
|
17
|
+
"id": "https://example.com/person2#key3",
|
|
18
|
+
"type": "CryptographicKey",
|
|
19
|
+
"owner": "https://example.com/person2",
|
|
20
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA4GUqWgdiYlN3Su5Gr4l6\ni+xRS8gDDVKZ718vpGk6eIpvqs33q430nRbHIzbHRXRaAhc/1++rUBcK0V4/kjZl\nCSzVtRgGU6HMkmjcD+uE56a8XbTczfltbEDj7afoEuB2F3UhQEWrSz+QJ29DPXaL\nMIa1Yv61NR2vxGqNbdtoMjDORMBYtg77CYbcFkiJHw65PDa7+f/yjLxuCRPye5L7\nhncN0UZuuFoRJmHNRLSg5omBad9WTvQXmSyXEhEdk9fHwlI022AqAzlWbT79hldc\nDSKGGLLbQIs1c3JZIG8G5i6Uh5Vy0Z7tSNBcxbhqoI9i9je4f/x/OPIVc19f04BE\n1LgWuHsftZzRgW9Sdqz53W83XxVdxlyHeywXOnstSWT11f8dkLyQUcHKTH+E6urb\nH+aiPLiRpYK8W7D9KTQA9kZ5JXaEuveBd5vJX7wakhbzAn8pWJU7GYIHNY38Ycok\nmivkU5pY8S2cKFMwY0b7ade3MComlir5P3ZYSjF+n6gRVsT96P+9mNfCu9gXt/f8\nXCyjKlH89kGwuJ7HhR8CuVdm0l+jYozVt6GsDy0hHYyn79NCCAEzP7ZbhBMR0T5V\nrkl+TIGXoJH9WFiz4VxO+NnglF6dNQjDS5IzYLoFRXIK1f3cmQiEB4FZmL70l9HL\nrgwR+Xys83xia79OqFDRezMCAwEAAQ==\n-----END PUBLIC KEY-----\n"
|
|
21
|
+
}, {
|
|
22
|
+
"id": "https://example.com/person2#key4",
|
|
23
|
+
"type": "CryptographicKey",
|
|
24
|
+
"owner": "https://example.com/person2",
|
|
25
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEALR8epAGDe+cVq5p2Tx49CCfphpk1rNhkNoY9i+XEUfg=\n-----END PUBLIC KEY-----\n"
|
|
26
|
+
}];
|
|
27
|
+
var assertionMethod = [{
|
|
28
|
+
"id": "https://example.com/peson2#key3",
|
|
29
|
+
"type": "Multikey",
|
|
30
|
+
"controller": "https://example.com/person2",
|
|
31
|
+
"publicKeyMultibase": "zgghBUVkqmWS8e1j4aN2yowLAEkJC6wowB9wWmLRACYCok7UzstWcTBp3waKiDUM7wqL9bbBD9W9FvNaXEK2KPCZ9ffhvd5dxChJL9bdPQSrMwa28FEYMGDtcF1uocrYNmZm2dBBMaWrCu8U3s4PpVVhn4hsWDL8GLuE466pkJs9Hy8xmECoaaVgAZLiYDw2gwrjHDiX2i7aDHKfE7aSZWUWmC8nAGNZ7DX5pXoyXK3pxuaCWxNxXwPmaFwgKDyy9uhtBJ8znp9NZXkXHBTQe5uAi8GFwHY5asvqCmYPrAGWxcT6pdbZaJHdWkM7nw6apBHfakKs42oMqdBoJ2WkkresoT1qHrX2GW7gNP9PLtveF4vfEd6cwgHKQCdYgayG3muGfZiPvML75cyfkNrjkctvuQUfMxY9umbd2TG3V3mPnLrvQnqHpuRMZYtCn3nX1qfZaqFhTwT4NFPqVNLqvgR6k9vcuGXn6Ndaumhd5xtTK64jk3e2gPBit9iq6MrFUSoxNsbTty4kqcHAodtkK8CMSxUxbFP1kK3nyy8ZfeMgDCts1KboBcT2m5FMpQpYxKtNBfvhTuyeDDC34uhbY8itmTAnDwSr5mKrniwwDUGPZFejda51TYs1N9D9Ejzaw5Mvr8qN6wahHmsDBWTbWwV6YKVMD1MjAhJBUopWJWB5x6mEBAX25MssKfAEhJyDtqYWjq63uQHUJCsPJp"
|
|
32
|
+
}, {
|
|
33
|
+
"id": "https://example.com/person2#key4",
|
|
34
|
+
"type": "Multikey",
|
|
35
|
+
"controller": "https://example.com/person2",
|
|
36
|
+
"publicKeyMultibase": "z6MkhVPuyvgG1RkMv67azDqDCDERPXVrUg1i3qchXY5EACE3"
|
|
37
|
+
}];
|
|
38
|
+
var person2_default = {
|
|
39
|
+
"@context": __context,
|
|
40
|
+
id,
|
|
41
|
+
type,
|
|
42
|
+
name,
|
|
43
|
+
publicKey,
|
|
44
|
+
assertionMethod
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { person2_default };
|
|
@@ -20,28 +20,28 @@
|
|
|
20
20
|
"cipherAlgorithm": "sec:cipherAlgorithm",
|
|
21
21
|
"cipherData": "sec:cipherData",
|
|
22
22
|
"cipherKey": "sec:cipherKey",
|
|
23
|
-
"created": {"@id": "dc:created", "@type": "xsd:dateTime"},
|
|
24
|
-
"creator": {"@id": "dc:creator", "@type": "@id"},
|
|
23
|
+
"created": { "@id": "dc:created", "@type": "xsd:dateTime" },
|
|
24
|
+
"creator": { "@id": "dc:creator", "@type": "@id" },
|
|
25
25
|
"digestAlgorithm": "sec:digestAlgorithm",
|
|
26
26
|
"digestValue": "sec:digestValue",
|
|
27
27
|
"domain": "sec:domain",
|
|
28
28
|
"encryptionKey": "sec:encryptionKey",
|
|
29
|
-
"expiration": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
|
|
30
|
-
"expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
|
|
29
|
+
"expiration": { "@id": "sec:expiration", "@type": "xsd:dateTime" },
|
|
30
|
+
"expires": { "@id": "sec:expiration", "@type": "xsd:dateTime" },
|
|
31
31
|
"initializationVector": "sec:initializationVector",
|
|
32
32
|
"iterationCount": "sec:iterationCount",
|
|
33
33
|
"nonce": "sec:nonce",
|
|
34
34
|
"normalizationAlgorithm": "sec:normalizationAlgorithm",
|
|
35
|
-
"owner": {"@id": "sec:owner", "@type": "@id"},
|
|
35
|
+
"owner": { "@id": "sec:owner", "@type": "@id" },
|
|
36
36
|
"password": "sec:password",
|
|
37
|
-
"privateKey": {"@id": "sec:privateKey", "@type": "@id"},
|
|
37
|
+
"privateKey": { "@id": "sec:privateKey", "@type": "@id" },
|
|
38
38
|
"privateKeyPem": "sec:privateKeyPem",
|
|
39
|
-
"publicKey": {"@id": "sec:publicKey", "@type": "@id"},
|
|
39
|
+
"publicKey": { "@id": "sec:publicKey", "@type": "@id" },
|
|
40
40
|
"publicKeyBase58": "sec:publicKeyBase58",
|
|
41
41
|
"publicKeyPem": "sec:publicKeyPem",
|
|
42
42
|
"publicKeyWif": "sec:publicKeyWif",
|
|
43
|
-
"publicKeyService": {"@id": "sec:publicKeyService", "@type": "@id"},
|
|
44
|
-
"revoked": {"@id": "sec:revoked", "@type": "xsd:dateTime"},
|
|
43
|
+
"publicKeyService": { "@id": "sec:publicKeyService", "@type": "@id" },
|
|
44
|
+
"revoked": { "@id": "sec:revoked", "@type": "xsd:dateTime" },
|
|
45
45
|
"salt": "sec:salt",
|
|
46
46
|
"signature": "sec:signature",
|
|
47
47
|
"signatureAlgorithm": "sec:signingAlgorithm",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
+
|
|
4
|
+
//#region testing/mod.d.ts
|
|
5
|
+
declare const testDefinitions: Deno.TestDefinition[];
|
|
6
|
+
declare function test(options: Deno.TestDefinition): void;
|
|
7
|
+
declare function test(name: string, fn: (t: Deno.TestContext) => void | Promise<void>): void;
|
|
8
|
+
declare function test(name: string, options: Omit<Deno.TestDefinition, "fn" | "name">, fn: (t: Deno.TestContext) => void | Promise<void>): void;
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { test, testDefinitions };
|