@fedify/fedify 0.8.0-dev.140 → 0.8.0-dev.144
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/CHANGES.md +4 -0
- package/README.md +12 -15
- package/esm/_dnt.shims.js +3 -0
- package/esm/federation/handler.js +2 -2
- package/esm/federation/kv.js +8 -3
- package/esm/federation/middleware.js +1 -2
- package/esm/federation/mq.js +1 -0
- package/esm/httpsig/mod.js +4 -5
- package/esm/runtime/docloader.js +4 -5
- package/esm/vocab/vocab.js +671 -95
- package/package.json +3 -3
- package/types/_dnt.shims.d.ts +4 -1
- package/types/_dnt.shims.d.ts.map +1 -1
- package/types/_dnt.test_shims.d.ts.map +1 -1
- package/types/federation/kv.d.ts +2 -2
- package/types/federation/kv.d.ts.map +1 -1
- package/types/federation/middleware.d.ts +1 -2
- package/types/federation/middleware.d.ts.map +1 -1
- package/types/federation/mq.d.ts +2 -2
- package/types/federation/mq.d.ts.map +1 -1
- package/types/httpsig/mod.d.ts +1 -2
- package/types/httpsig/mod.d.ts.map +1 -1
- package/types/runtime/docloader.d.ts +1 -2
- package/types/runtime/docloader.d.ts.map +1 -1
- package/types/vocab/vocab.d.ts +385 -386
- package/types/vocab/vocab.d.ts.map +1 -1
package/CHANGES.md
CHANGED
@@ -36,6 +36,10 @@ To be released.
|
|
36
36
|
parameter became `CollectionDispatcher<Recipient, TContextData, URL>`
|
37
37
|
(was `CollectionDispatcher<Actor | URL, TContextData>`).
|
38
38
|
|
39
|
+
- Removed the dependency on *@js-temporal/polyfill* on Deno, and Fedify now
|
40
|
+
requires `--unstable-temporal` flag. On other runtime, it still depends
|
41
|
+
on *@js-temporal/polyfill*.
|
42
|
+
|
39
43
|
[FEP-8fcf]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8fcf/fep-8fcf.md
|
40
44
|
|
41
45
|
|
package/README.md
CHANGED
@@ -105,15 +105,20 @@ via the following command:
|
|
105
105
|
deno add @fedify/fedify
|
106
106
|
~~~~
|
107
107
|
|
108
|
-
|
109
|
-
|
108
|
+
Since Fedify requires [`Temporal`] API, which is an unstable feature in Deno as
|
109
|
+
of April 2024, you need to add the `"temporal"` to the `"unstable"` field of
|
110
|
+
the *deno.json* file:
|
111
|
+
|
112
|
+
~~~~ json
|
113
|
+
{
|
114
|
+
"imports": {
|
115
|
+
"@fedify/fedify": "jsr:@fedify/fedify"
|
116
|
+
},
|
117
|
+
"unstable": ["temporal"]
|
118
|
+
}
|
110
119
|
~~~~
|
111
120
|
|
112
|
-
|
113
|
-
|
114
|
-
~~~~ typescript
|
115
|
-
import { Federation } from "jsr:@fedify/fedify";
|
116
|
-
~~~~
|
121
|
+
[`Temporal`]: https://tc39.es/proposal-temporal/docs/
|
117
122
|
|
118
123
|
### Node.js
|
119
124
|
|
@@ -125,10 +130,6 @@ the following command:
|
|
125
130
|
npm add @fedify/fedify
|
126
131
|
~~~~
|
127
132
|
|
128
|
-
~~~~ typescript
|
129
|
-
import { Federation } from "@fedify/fedify";
|
130
|
-
~~~~
|
131
|
-
|
132
133
|
### Bun
|
133
134
|
|
134
135
|
Fedify can also be used in Bun. You can install it via the following
|
@@ -137,7 +138,3 @@ command:
|
|
137
138
|
~~~~ sh
|
138
139
|
bun add @fedify/fedify
|
139
140
|
~~~~
|
140
|
-
|
141
|
-
~~~~ typescript
|
142
|
-
import { Federation } from "@fedify/fedify";
|
143
|
-
~~~~
|
package/esm/_dnt.shims.js
CHANGED
@@ -4,10 +4,13 @@ import { crypto } from "@deno/shim-crypto";
|
|
4
4
|
export { crypto } from "@deno/shim-crypto";
|
5
5
|
import { URLPattern as URLPattern } from "urlpattern-polyfill";
|
6
6
|
export { URLPattern as URLPattern } from "urlpattern-polyfill";
|
7
|
+
import { Temporal as Temporal } from "@js-temporal/polyfill";
|
8
|
+
export { Temporal as Temporal } from "@js-temporal/polyfill";
|
7
9
|
const dntGlobals = {
|
8
10
|
Deno,
|
9
11
|
crypto,
|
10
12
|
URLPattern,
|
13
|
+
Temporal,
|
11
14
|
};
|
12
15
|
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
13
16
|
function createMergeProxy(baseObj, extObj) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import * as dntShim from "../_dnt.shims.js";
|
2
2
|
import { getLogger } from "@logtape/logtape";
|
3
3
|
import { accepts } from "../deps/jsr.io/@std/http/0.220.1/negotiation.js";
|
4
4
|
import { doesActorOwnKey, verify } from "../httpsig/mod.js";
|
@@ -270,7 +270,7 @@ export async function handleInbox(request, { handle, context, kv, kvPrefix, acto
|
|
270
270
|
});
|
271
271
|
}
|
272
272
|
if (cacheKey != null) {
|
273
|
-
await kv.set(cacheKey, true, { ttl: Temporal.Duration.from({ days: 1 }) });
|
273
|
+
await kv.set(cacheKey, true, { ttl: dntShim.Temporal.Duration.from({ days: 1 }) });
|
274
274
|
}
|
275
275
|
logger.info("Activity {activityId} has been processed.", { activityId: activity.id?.href, activity: json });
|
276
276
|
return new Response("", {
|
package/esm/federation/kv.js
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
/**
|
2
|
+
* A key for a key-value store. An array of one or more strings.
|
3
|
+
*
|
4
|
+
* @since 0.5.0
|
5
|
+
*/
|
6
|
+
import * as dntShim from "../_dnt.shims.js";
|
2
7
|
/**
|
3
8
|
* A key-value store that stores values in memory.
|
4
9
|
* Do not use this in production as it does not persist values.
|
@@ -19,7 +24,7 @@ export class MemoryKvStore {
|
|
19
24
|
if (entry == null)
|
20
25
|
return Promise.resolve(undefined);
|
21
26
|
const [value, expiration] = entry;
|
22
|
-
if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
|
27
|
+
if (expiration != null && dntShim.Temporal.Now.instant().until(expiration).sign < 0) {
|
23
28
|
delete this.#values[encodedKey];
|
24
29
|
return Promise.resolve(undefined);
|
25
30
|
}
|
@@ -32,7 +37,7 @@ export class MemoryKvStore {
|
|
32
37
|
const encodedKey = this.#encodeKey(key);
|
33
38
|
const expiration = options?.ttl == null
|
34
39
|
? null
|
35
|
-
: Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
|
40
|
+
: dntShim.Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
|
36
41
|
this.#values[encodedKey] = [value, expiration];
|
37
42
|
return Promise.resolve();
|
38
43
|
}
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
3
2
|
import { getLogger } from "@logtape/logtape";
|
4
3
|
import { exportJwk, importJwk, validateCryptoKey } from "../httpsig/key.js";
|
5
4
|
import { getKeyOwner, verify } from "../httpsig/mod.js";
|
@@ -73,7 +72,7 @@ export class Federation {
|
|
73
72
|
60000,
|
74
73
|
15 * 60000,
|
75
74
|
60 * 60000,
|
76
|
-
].map((ms) => Temporal.Duration.from({ milliseconds: ms }));
|
75
|
+
].map((ms) => dntShim.Temporal.Duration.from({ milliseconds: ms }));
|
77
76
|
}
|
78
77
|
#startQueue() {
|
79
78
|
if (this.#queue != null && !this.#queueStarted) {
|
package/esm/federation/mq.js
CHANGED
package/esm/httpsig/mod.js
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
* @module
|
6
6
|
*/
|
7
7
|
import * as dntShim from "../_dnt.shims.js";
|
8
|
-
import { Temporal } from "@js-temporal/polyfill";
|
9
8
|
import { equals } from "../deps/jsr.io/@std/bytes/0.220.1/mod.js";
|
10
9
|
import { decodeBase64, encodeBase64 } from "../deps/jsr.io/@std/encoding/0.220.1/base64.js";
|
11
10
|
import { isActor } from "../vocab/actor.js";
|
@@ -104,13 +103,13 @@ export async function verify(request, documentLoader, currentTime) {
|
|
104
103
|
if (!matched)
|
105
104
|
return null;
|
106
105
|
}
|
107
|
-
const date = Temporal.Instant.from(new Date(dateHeader).toISOString());
|
108
|
-
const now = currentTime ?? Temporal.Now.instant();
|
109
|
-
if (Temporal.Instant.compare(date, now.add({ seconds: 30 })) > 0) {
|
106
|
+
const date = dntShim.Temporal.Instant.from(new Date(dateHeader).toISOString());
|
107
|
+
const now = currentTime ?? dntShim.Temporal.Now.instant();
|
108
|
+
if (dntShim.Temporal.Instant.compare(date, now.add({ seconds: 30 })) > 0) {
|
110
109
|
// Too far in the future
|
111
110
|
return null;
|
112
111
|
}
|
113
|
-
else if (Temporal.Instant.compare(date, now.subtract({ seconds: 30 })) < 0) {
|
112
|
+
else if (dntShim.Temporal.Instant.compare(date, now.subtract({ seconds: 30 })) < 0) {
|
114
113
|
// Too far in the past
|
115
114
|
return null;
|
116
115
|
}
|
package/esm/runtime/docloader.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
2
|
-
import { Temporal } from "@js-temporal/polyfill";
|
3
2
|
import { validateCryptoKey } from "../httpsig/key.js";
|
4
3
|
import { sign } from "../httpsig/mod.js";
|
5
4
|
/**
|
@@ -79,13 +78,13 @@ export function kvCache({ loader, kv, prefix, rules }) {
|
|
79
78
|
rules ??= [
|
80
79
|
[
|
81
80
|
"https://www.w3.org/ns/activitystreams",
|
82
|
-
Temporal.Duration.from({ days: 30 }),
|
81
|
+
dntShim.Temporal.Duration.from({ days: 30 }),
|
83
82
|
],
|
84
|
-
["https://w3id.org/security/v1", Temporal.Duration.from({ days: 30 })],
|
85
|
-
[new dntShim.URLPattern({}), Temporal.Duration.from({ minutes: 5 })],
|
83
|
+
["https://w3id.org/security/v1", dntShim.Temporal.Duration.from({ days: 30 })],
|
84
|
+
[new dntShim.URLPattern({}), dntShim.Temporal.Duration.from({ minutes: 5 })],
|
86
85
|
];
|
87
86
|
for (const [p, duration] of rules) {
|
88
|
-
if (Temporal.Duration.compare(duration, { days: 30 }) > 0) {
|
87
|
+
if (dntShim.Temporal.Duration.compare(duration, { days: 30 }) > 0) {
|
89
88
|
throw new TypeError("The maximum cache duration is 30 days: " +
|
90
89
|
(p instanceof dntShim.URLPattern
|
91
90
|
? `${p.protocol}://${p.username}:${p.password}@${p.hostname}:${p.port}/${p.pathname}?${p.search}#${p.hash}`
|