@fedify/fedify 0.8.0-dev.140 → 0.8.0-dev.142

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of @fedify/fedify might be problematic. Click here for more details.

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/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 { Temporal } from "@js-temporal/polyfill";
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("", {
@@ -1,4 +1,9 @@
1
- import { Temporal } from "@js-temporal/polyfill";
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) {
@@ -1,3 +1,4 @@
1
+ // deno-lint-ignore-file no-explicit-any
1
2
  /**
2
3
  * A message queue that processes messages in the same process.
3
4
  * Do not use this in production as it does not persist messages.
@@ -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
  }
@@ -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}`