Unverified Commit 20aa8257 authored by Hong Minhee's avatar Hong Minhee
Browse files

Remove dependency on jose

parent 86f836ea
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@
    "redirections",
    "rels",
    "setext",
    "spki",
    "subproperty",
    "superproperty",
    "unfollow",
+5 −0
Original line number Diff line number Diff line
@@ -13,6 +13,11 @@ Version 0.5.0

To be released.

 -  Removed dependency on *jose*.

     -  Added `exportSpki()` function.
     -  Added `importSpki()` function.


Version 0.4.0
-------------
+3 −5
Original line number Diff line number Diff line
@@ -6,9 +6,9 @@ import { Temporal } from \\"@js-temporal/polyfill\\";
import jsonld from \\"jsonld\\";
import { type LanguageTag, parseLanguageTag }
    from \\"@phensley/language-tag\\";
import { exportSPKI, importSPKI } from \\"jose\\";
import { type DocumentLoader, fetchDocumentLoader }
    from \\"../runtime/docloader.ts\\";
import { exportSpki, importSpki } from \\"../runtime/key.ts\\";
import { LanguageString } from \\"../runtime/langstr.ts\\";
@@ -178,7 +178,7 @@ get publicKey(): (CryptoKey | null) {
    array = [];
    for (const v of this.#_2fE2QMDdg6KFGqa4NEC3TmjApSAD) {
      array.push(
    { \\"@value\\": await exportSPKI(v) }
    { \\"@value\\": await exportSpki(v) }
      );
    }
    if (array.length > 0) values[\\"https://w3id.org/security#publicKeyPem\\"] = array;
@@ -263,9 +263,7 @@ get publicKey(): (CryptoKey | null) {
    for (const v of values[\\"https://w3id.org/security#publicKeyPem\\"] ?? []) {
      if (v == null) continue;
    _2fE2QMDdg6KFGqa4NEC3TmjApSAD.push(await importSPKI<CryptoKey>(v[\\"@value\\"], \\"RS256\\", {
        extractable: true
      }))
    _2fE2QMDdg6KFGqa4NEC3TmjApSAD.push(await importSpki(v[\\"@value\\"]))
    }
    instance.#_2fE2QMDdg6KFGqa4NEC3TmjApSAD = _2fE2QMDdg6KFGqa4NEC3TmjApSAD;
    
+1 −1
Original line number Diff line number Diff line
@@ -73,9 +73,9 @@ export async function* generateClasses(
  yield 'import jsonld from "jsonld";\n';
  yield `import { type LanguageTag, parseLanguageTag }
    from "@phensley/language-tag";\n`;
  yield `import { exportSPKI, importSPKI } from "jose";\n`;
  yield `import { type DocumentLoader, fetchDocumentLoader }
    from "${runtimePath}/docloader.ts";\n`;
  yield `import { exportSpki, importSpki } from "${runtimePath}/key.ts";\n`;
  yield `import { LanguageString } from "${runtimePath}/langstr.ts";\n`;
  yield "\n\n";
  const sorted = sortTopologically(types);
+2 −5
Original line number Diff line number Diff line
@@ -199,17 +199,14 @@ const scalarTypes: Record<string, ScalarType> = {
      return `${v} instanceof CryptoKey`;
    },
    encoder(v) {
      return `{ "@value": await exportSPKI(${v}) }`;
      return `{ "@value": await exportSpki(${v}) }`;
    },
    dataCheck(v) {
      return `typeof ${v} === "object" && "@value" in ${v}
        && typeof ${v}["@value"] === "string"`;
    },
    decoder(v) {
      // TODO: support other than RSASSA-PKCS1-v1_5:
      return `await importSPKI<CryptoKey>(${v}["@value"], "RS256", {
        extractable: true
      })`;
      return `await importSpki(${v}["@value"])`;
    },
  },
  "fedify:units": {
Loading