Unverified Commit 0c8eeb58 authored by Hong Minhee's avatar Hong Minhee
Browse files

Add assertionMethod prop to Actor types

FEP-521a compliance

Close https://github.com/dahlia/fedify/issues/55
parent 6bb368f0
Loading
Loading
Loading
Loading
+37 −2
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ To be released.
     -  The `importSpki()` function now accepts Ed25519 keys.
     -  The `exportJwk()` function now exports Ed25519 keys.

 -  Now multiple key pairs can be registered for an actor.  [[#55]]
 -  Now multiple key pairs can be registered for an actor.  [[FEP-521a], [#55]]

     -  Added `Context.getActorKeyPairs()` method.
     -  Deprecated `Context.getActorKey()` method.
@@ -31,11 +31,45 @@ To be released.
     -  Deprecated the third parameter of the `ActorDispatcher` callback type.
        Use `Context.getActorKeyPairs()` method instead.

 -  Added `Multikey` class to Activity Vocabulary API.  [[#55]]
 -  Added `Multikey` class to Activity Vocabulary API.  [[FEP-521a], [#55]]

     -  Added `importMultibaseKey()` function.
     -  Added `exportMultibaseKey()` function.

 -  Added `assertionMethod` property to the `Actor` types in the Activity
    Vocabulary API.  [[FEP-521a], [#55]]

     -  Added `Application.getAssertionMethod()` method.
     -  Added `Application.getAssertionMethods()` method.
     -  `new Application()` constructor now accepts `assertionMethod` option.
     -  `new Application()` constructor now accepts `assertionMethods` option.
     -  `Application.clone()` method now accepts `assertionMethod` option.
     -  `Application.clone()` method now accepts `assertionMethods` option.
     -  Added `Group.getAssertionMethod()` method.
     -  Added `Group.getAssertionMethods()` method.
     -  `new Group()` constructor now accepts `assertionMethod` option.
     -  `new Group()` constructor now accepts `assertionMethods` option.
     -  `Group.clone()` method now accepts `assertionMethod` option.
     -  `Group.clone()` method now accepts `assertionMethods` option.
     -  Added `Organization.getAssertionMethod()` method.
     -  Added `Organization.getAssertionMethods()` method.
     -  `new Organization()` constructor now accepts `assertionMethod` option.
     -  `new Organization()` constructor now accepts `assertionMethods` option.
     -  `Organization.clone()` method now accepts `assertionMethod` option.
     -  `Organization.clone()` method now accepts `assertionMethods` option.
     -  Added `Person.getAssertionMethod()` method.
     -  Added `Person.getAssertionMethods()` method.
     -  `new Person()` constructor now accepts `assertionMethod` option.
     -  `new Person()` constructor now accepts `assertionMethods` option.
     -  `Person.clone()` method now accepts `assertionMethod` option.
     -  `Person.clone()` method now accepts `assertionMethods` option.
     -  Added `Service.getAssertionMethod()` method.
     -  Added `Service.getAssertionMethods()` method.
     -  `new Service()` constructor now accepts `assertionMethod` option.
     -  `new Service()` constructor now accepts `assertionMethods` option.
     -  `Service.clone()` method now accepts `assertionMethod` option.
     -  `Service.clone()` method now accepts `assertionMethods` option.

 -  Deprecated `treatHttps` option in `FederationParameters` interface.
    Instead, use the [x-forwarded-fetch] library to recognize the
    `X-Forwarded-Host` and `X-Forwarded-Proto` headers.
@@ -48,6 +82,7 @@ To be released.
        `url`.

[#55]: https://github.com/dahlia/fedify/issues/55
[FEP-521a]: https://codeberg.org/fediverse/fep/src/branch/main/fep/521a/fep-521a.md
[x-forwarded-fetch]: https://github.com/dahlia/x-forwarded-fetch


+956 −26

File changed.

Preview size limit exceeded, changes collapsed.

+2 −0
Original line number Diff line number Diff line
@@ -34,9 +34,11 @@
    "@std/assert": "jsr:@std/assert@^0.224.0",
    "@std/async/delay": "jsr:@std/async@^0.224.0/delay",
    "@std/bytes": "jsr:@std/bytes@^0.224.0",
    "@std/bytes/concat": "jsr:@std/bytes@^0.224.0/concat",
    "@std/collections": "jsr:@std/collections@^0.224.0",
    "@std/encoding": "jsr:@std/encoding@^0.224.0",
    "@std/encoding/base64": "jsr:@std/encoding@^0.224.0/base64",
    "@std/encoding/base64url": "jsr:@std/encoding@^0.224.0/base64url",
    "@std/encoding/hex": "jsr:@std/encoding@^0.224.0/hex",
    "@std/fs": "jsr:@std/fs@^0.224.0",
    "@std/http/negotiation": "jsr:@std/http@^0.224.0/negotiation",
+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@
    "httpsig",
    "logtape",
    "Misskey",
    "multikey",
    "nodeinfo",
    "preact",
    "unfollow",
+8 −6
Original line number Diff line number Diff line
@@ -49,6 +49,10 @@ federation.setActorDispatcher("/users/{handle}", async (ctx, handle) => {
  const blog = await getBlog();
  if (blog == null) return null;
  else if (blog.handle !== handle) return null;
  // A `Context<TContextData>` object has several purposes, and one of
  // them is to provide a way to get the key pairs for the actor in various
  // formats:
  const keyPairs = await ctx.getActorKeyPairs(handle);
  return new Person({
    id: ctx.getActorUri(handle),
    name: blog.title,
@@ -70,12 +74,10 @@ federation.setActorDispatcher("/users/{handle}", async (ctx, handle) => {
    }),
    following: ctx.getFollowingUri(handle),
    followers: ctx.getFollowersUri(handle),
    // The `key` parameter is the public key of the actor, which is used
    // for the HTTP Signatures.  Note that the `key` object is not a
    // `CryptoKey` instance, but a `CryptographicKey` instance which is
    // used for ActivityPub:
    publicKeys: (await ctx.getActorKeyPairs(handle))
      .map((keyPair) => keyPair.cryptographicKey),
    // The `publicKey` and `assertionMethods` are used by peer servers
    // to verify the signature of the actor:
    publicKey: keyPairs[0].cryptographicKey,
    assertionMethods: keyPairs.map((keyPair) => keyPair.multikey),
  });
})
  .setKeyPairsDispatcher(async (_ctxData, handle) => {
Loading