@fedify/fedify 0.12.0-dev.273 → 0.12.0-dev.278

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGES.md CHANGED
@@ -38,8 +38,31 @@ To be released.
38
38
  interface.
39
39
  - Added `Federation.startQueue()` method.
40
40
 
41
+ - Made the router able to be insensitive to trailing slashes in the URL paths.
42
+ [[#81]]
43
+
44
+ - Added `trailingSlashInsensitive` option to `CreateFederationOptions`
45
+ interface.
46
+ - Added `RouterOptions` interface.
47
+ - Added an optional parameter to `new Router()` constructor.
48
+
41
49
  - Added `ChatMessage` class to Activity Vocabulary API. [[#85]]
42
50
 
51
+ - Added `Move` class to Activity Vocabulary API. [[#65], [#92] by Lee Dogeon]
52
+
53
+ - Added `Read` class to Activity Vocabulary API. [[#65], [#92] by Lee Dogeon]
54
+
55
+ - Added `Travel` class to Activity Vocabulary API.
56
+ [[#65], [#92] by Lee Dogeon]
57
+
58
+ - Added `View` class to Activity Vocabulary API. [[#65], [#92] by Lee Dogeon]
59
+
60
+ - Added `TentativeAccept` class to Activity Vocabulary API.
61
+ [[#65], [#92] by Lee Dogeon]
62
+
63
+ - Added `TentativeReject` class to Activity Vocabulary API.
64
+ [[#65], [#92] by Lee Dogeon]
65
+
43
66
  - Improved multitenancy (virtual hosting) support. [[#66]]
44
67
 
45
68
  - Added `Context.hostname` property.
@@ -71,7 +94,9 @@ To be released.
71
94
  [#53]: https://github.com/dahlia/fedify/issues/53
72
95
  [#66]: https://github.com/dahlia/fedify/issues/66
73
96
  [#70]: https://github.com/dahlia/fedify/issues/70
97
+ [#81]: https://github.com/dahlia/fedify/issues/81
74
98
  [#85]: https://github.com/dahlia/fedify/issues/85
99
+ [#92]: https://github.com/dahlia/fedify/pull/92
75
100
 
76
101
 
77
102
  Version 0.11.1
package/FEDERATION.md CHANGED
@@ -61,9 +61,15 @@ lists the activity types that Fedify provides:
61
61
  - [`Leave`](https://jsr.io/@fedify/fedify/doc/vocab/~/Leave)
62
62
  - [`Like`](https://jsr.io/@fedify/fedify/doc/vocab/~/Like)
63
63
  - [`Listen`](https://jsr.io/@fedify/fedify/doc/vocab/~/Listen)
64
+ - [`Move`](https://jsr.io/@fedify/fedify/doc/vocab/~/Move)
64
65
  - [`Offer`](https://jsr.io/@fedify/fedify/doc/vocab/~/Offer)
65
66
  - [`Question`](https://jsr.io/@fedify/fedify/doc/vocab/~/Question)
67
+ - [`Read`](https://jsr.io/@fedify/fedify/doc/vocab/~/Read)
66
68
  - [`Reject`](https://jsr.io/@fedify/fedify/doc/vocab/~/Reject)
67
69
  - [`Remove`](https://jsr.io/@fedify/fedify/doc/vocab/~/Remove)
70
+ - [`TentativeAccept`](https://jsr.io/@fedify/fedify/doc/vocab/~/TentativeAccept)
71
+ - [`TentativeReject`](https://jsr.io/@fedify/fedify/doc/vocab/~/TentativeReject)
72
+ - [`Travel`](https://jsr.io/@fedify/fedify/doc/vocab/~/Travel)
68
73
  - [`Undo`](https://jsr.io/@fedify/fedify/doc/vocab/~/Undo)
69
74
  - [`Update`](https://jsr.io/@fedify/fedify/doc/vocab/~/Update)
75
+ - [`View`](https://jsr.io/@fedify/fedify/doc/vocab/~/View)
@@ -89,7 +89,9 @@ export class Federation {
89
89
  this.#queue = options.queue;
90
90
  this.#queueStarted = false;
91
91
  this.#manuallyStartQueue = options.manuallyStartQueue ?? false;
92
- this.#router = new Router();
92
+ this.#router = new Router({
93
+ trailingSlashInsensitive: options.trailingSlashInsensitive,
94
+ });
93
95
  this.#router.add("/.well-known/webfinger", "webfinger");
94
96
  this.#router.add("/.well-known/nodeinfo", "nodeInfoJrd");
95
97
  this.#objectCallbacks = {};
@@ -8,12 +8,15 @@ import { parseTemplate } from "url-template";
8
8
  export class Router {
9
9
  #router;
10
10
  #templates;
11
+ #trailingSlashInsensitive;
11
12
  /**
12
13
  * Create a new {@link Router}.
14
+ * @param options Options for the router.
13
15
  */
14
- constructor() {
16
+ constructor(options = {}) {
15
17
  this.#router = new InnerRouter();
16
18
  this.#templates = {};
19
+ this.#trailingSlashInsensitive = options.trailingSlashInsensitive ?? false;
17
20
  }
18
21
  /**
19
22
  * Checks if a path name exists in the router.
@@ -44,9 +47,15 @@ export class Router {
44
47
  * `null`.
45
48
  */
46
49
  route(url) {
47
- const match = this.#router.resolveURI(url);
48
- if (match == null)
49
- return null;
50
+ let match = this.#router.resolveURI(url);
51
+ if (match == null) {
52
+ if (!this.#trailingSlashInsensitive)
53
+ return null;
54
+ url = url.endsWith("/") ? url.replace(/\/+$/, "") : `${url}/`;
55
+ match = this.#router.resolveURI(url);
56
+ if (match == null)
57
+ return null;
58
+ }
50
59
  return {
51
60
  name: match.matchValue,
52
61
  values: match.params,
@@ -0,0 +1,13 @@
1
+ $schema: ../codegen/schema.yaml
2
+ name: Move
3
+ uri: "https://www.w3.org/ns/activitystreams#Move"
4
+ extends: "https://www.w3.org/ns/activitystreams#Activity"
5
+ entity: true
6
+ description: |
7
+ Indicates that the `actor` has moved `object` from `origin` to `target`.
8
+ If the `origin` or `target` are not specified,
9
+ either can be determined by context.
10
+ defaultContext:
11
+ - "https://www.w3.org/ns/activitystreams"
12
+ - "https://w3id.org/security/data-integrity/v1"
13
+ properties: []
@@ -0,0 +1,11 @@
1
+ $schema: ../codegen/schema.yaml
2
+ name: Read
3
+ uri: "https://www.w3.org/ns/activitystreams#Read"
4
+ extends: "https://www.w3.org/ns/activitystreams#Activity"
5
+ entity: true
6
+ description: |
7
+ Indicates that the `actor` has read the `object`.
8
+ defaultContext:
9
+ - "https://www.w3.org/ns/activitystreams"
10
+ - "https://w3id.org/security/data-integrity/v1"
11
+ properties: []
@@ -0,0 +1,12 @@
1
+ $schema: ../codegen/schema.yaml
2
+ name: TentativeAccept
3
+ uri: "https://www.w3.org/ns/activitystreams#TentativeAccept"
4
+ extends: "https://www.w3.org/ns/activitystreams#Accept"
5
+ entity: true
6
+ description: |
7
+ A specialization of {@link Accept} indicating that
8
+ the acceptance is tentative.
9
+ defaultContext:
10
+ - "https://www.w3.org/ns/activitystreams"
11
+ - "https://w3id.org/security/data-integrity/v1"
12
+ properties: []
@@ -0,0 +1,12 @@
1
+ $schema: ../codegen/schema.yaml
2
+ name: TentativeReject
3
+ uri: "https://www.w3.org/ns/activitystreams#TentativeReject"
4
+ extends: "https://www.w3.org/ns/activitystreams#Reject"
5
+ entity: true
6
+ description: |
7
+ A specialization of {@link Reject} in which
8
+ the rejection is considered tentative.
9
+ defaultContext:
10
+ - "https://www.w3.org/ns/activitystreams"
11
+ - "https://w3id.org/security/data-integrity/v1"
12
+ properties: []
@@ -0,0 +1,14 @@
1
+ $schema: ../codegen/schema.yaml
2
+ name: Travel
3
+ uri: "https://www.w3.org/ns/activitystreams#Travel"
4
+ extends: "https://www.w3.org/ns/activitystreams#IntransitiveActivity"
5
+ entity: true
6
+ description: |
7
+ Indicates that the `actor` is traveling to `target` from `origin`.
8
+ `Travel` is an `IntransitiveObject` whose `actor` specifies the direct object.
9
+ If the `target` or `origin` are not specified,
10
+ either can be determined by context.
11
+ defaultContext:
12
+ - "https://www.w3.org/ns/activitystreams"
13
+ - "https://w3id.org/security/data-integrity/v1"
14
+ properties: []
@@ -0,0 +1,11 @@
1
+ $schema: ../codegen/schema.yaml
2
+ name: View
3
+ uri: "https://www.w3.org/ns/activitystreams#View"
4
+ extends: "https://www.w3.org/ns/activitystreams#Activity"
5
+ entity: true
6
+ description: |
7
+ Indicates that the `actor` has viewed the object.
8
+ defaultContext:
9
+ - "https://www.w3.org/ns/activitystreams"
10
+ - "https://w3id.org/security/data-integrity/v1"
11
+ properties: []