Unverified Commit 66147100 authored by Hong Minhee's avatar Hong Minhee
Browse files
parent 55cc34d1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -70,6 +70,9 @@ To be released.
     -  `Service.clone()` method now accepts `assertionMethod` option.
     -  `Service.clone()` method now accepts `assertionMethods` option.

 -  Added `DataIntegrityProof` class to Activity Vocabulary API.
    [[FEP-8b32], [#54]]

 -  Deprecated `treatHttps` option in `FederationParameters` interface.
    Instead, use the [x-forwarded-fetch] library to recognize the
    `X-Forwarded-Host` and `X-Forwarded-Proto` headers.
@@ -81,8 +84,10 @@ To be released.
        `following`, `followers`, `outbox`, `manuallyApprovesFollowers`, and
        `url`.

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


+533 −1

File changed.

Preview size limit exceeded, changes collapsed.

+2 −0
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ export async function* generateClasses(
  yield 'import jsonld from "jsonld";\n';
  yield `import { type LanguageTag, parseLanguageTag }
    from "@phensley/language-tag";\n`;
  yield `import { decode as decodeMultibase, encode as encodeMultibase }
    from "multibase";`;
  yield `import { type DocumentLoader, fetchDocumentLoader }
    from "${runtimePath}/docloader.ts";\n`;
  yield `import {
+61 −0
Original line number Diff line number Diff line
@@ -177,6 +177,41 @@ const scalarTypes: Record<string, ScalarType> = {
      return `Temporal.Duration.from(${v}["@value"])`;
    },
  },
  "https://w3id.org/security#cryptosuiteString": {
    name: '"eddsa-jcs-2022"',
    typeGuard(v) {
      return `${v} == "eddsa-jcs-2022"`;
    },
    encoder(v) {
      return `{ "@value": ${v} }`;
    },
    dataCheck(v) {
      return `typeof ${v} === "object" && "@value" in ${v}
        && !("@language" in ${v}) && ${v}["@value"] === "eddsa-jcs-2022"`;
    },
    decoder(v) {
      return `${v}["@value"]`;
    },
  },
  "https://w3id.org/security#multibase": {
    name: "Uint8Array",
    typeGuard(v) {
      return `${v} instanceof Uint8Array`;
    },
    encoder(v) {
      return `{
        "@type": "https://w3id.org/security#multibase",
        "@value": new TextDecoder().decode(encodeMultibase("base58btc", ${v})),
      }`;
    },
    dataCheck(v) {
      return `typeof ${v} === "object" && "@value" in ${v}
        && typeof ${v}["@value"] === "string"`;
    },
    decoder(v) {
      return `decodeMultibase(${v}["@value"])`;
    },
  },
  "fedify:langTag": {
    name: "LanguageTag",
    typeGuard(v) {
@@ -228,6 +263,32 @@ const scalarTypes: Record<string, ScalarType> = {
      return `await importMultibaseKey(${v}["@value"])`;
    },
  },
  "fedify:proofPurpose": {
    name: `("assertionMethod" | "authentication" | "capabilityInvocation" |
      "capabilityDelegation" | "keyAgreement")`,
    typeGuard(v) {
      return `${v} === "assertionMethod" || ${v} === "authentication" ||
        ${v} === "capabilityInvocation" || ${v} === "capabilityDelegation" ||
        ${v} === "keyAgreement"`;
    },
    encoder(v) {
      return `{
        "@id": "https://w3id.org/security#" + ${v},
      }`;
    },
    dataCheck(v) {
      return `typeof ${v} === "object" && "@id" in ${v}
        && typeof ${v}["@id"] === "string"
        && ${v}["@id"].startsWith("https://w3id.org/security#")
        && [
          "assertionMethod", "authentication", "capabilityInvocation",
          "capabilityDelegation", "keyAgreement",
        ].includes(${v}["@id"].substring(26))`;
    },
    decoder(v) {
      return `${v}["@id"].substring(26)`;
    },
  },
  "fedify:units": {
    name: '"cm" | "feet" | "inches" | "km" | "m" | "miles"',
    typeGuard(v) {
+74 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading