Unverified Commit 01ec855b authored by Hong Minhee's avatar Hong Minhee
Browse files

Multikey support in CLI tools

parent 52d750a0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
    "httpsig",
    "logtape",
    "msvc",
    "multikey",
    "nodeinfo",
    "poppanator",
    "shiki",
+6 −0
Original line number Diff line number Diff line
@@ -19,9 +19,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.220.1",
    "@std/http/negotiation": "jsr:@std/http@^0.224.0/negotiation",
@@ -32,10 +34,14 @@
    "@std/text": "jsr:@std/text@^0.224.0",
    "@std/url": "jsr:@std/url@^0.224.0",
    "@std/yaml": "jsr:@std/yaml@^0.224.0",
    "asn1js": "npm:asn1js@^3.0.5",
    "fast-check": "npm:fast-check@^3.18.0",
    "json-canon": "npm:json-canon@^1.0.1",
    "jsonld": "npm:jsonld@^8.3.2",
    "mock_fetch": "https://deno.land/x/mock_fetch@0.3.0/mod.ts",
    "multibase": "npm:multibase@^4.0.6",
    "multicodec": "npm:multicodec@^3.2.1",
    "pkijs": "npm:pkijs@^3.1.0",
    "uri-template-router": "npm:uri-template-router@^0.0.16",
    "url-template": "npm:url-template@^3.1.1",
    "@fedify/fedify/sig": ".././sig/mod.ts",
+15 −7
Original line number Diff line number Diff line
@@ -116,10 +116,10 @@ const federation = new Federation<number>({
});

const time = Temporal.Now.instant();
let actorKeyPair: CryptoKeyPair | undefined = undefined;
let actorKeyPairs: CryptoKeyPair[] | undefined = undefined;

federation
  .setActorDispatcher("/{handle}", (ctx, handle, key) => {
  .setActorDispatcher("/{handle}", async (ctx, handle) => {
    if (handle !== "i") return null;
    return new Application({
      id: ctx.getActorUri(handle),
@@ -139,14 +139,22 @@ federation
        url: new URL("https://fedify.dev/logo.png"),
        mediaType: "image/png",
      }),
      publicKey: key,
      publicKeys: (await ctx.getActorKeyPairs(handle))
        .map((pair) => pair.cryptographicKey),
      assertionMethods: (await ctx.getActorKeyPairs(handle))
        .map((pair) => pair.multikey),
      url: ctx.getActorUri(handle),
    });
  })
  .setKeyPairDispatcher(async (_ctxData, handle) => {
    if (handle !== "i") return null;
    if (actorKeyPair == null) actorKeyPair = await generateCryptoKeyPair();
    return actorKeyPair;
  .setKeyPairsDispatcher(async (_ctxData, handle) => {
    if (handle !== "i") return [];
    if (actorKeyPairs == null) {
      actorKeyPairs = [
        await generateCryptoKeyPair("RSASSA-PKCS1-v1_5"),
        await generateCryptoKeyPair("Ed25519"),
      ];
    }
    return actorKeyPairs;
  });

const activities: ActivityEntry[] = [];