@thurinlabs/identity-kit 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1339,6 +1339,7 @@ function keyIdToBytes(keyId) {
1339
1339
  }
1340
1340
 
1341
1341
  // src/core/pgp.ts
1342
+ var PGP_CONFIG = { rejectCurves: /* @__PURE__ */ new Set() };
1342
1343
  function algorithmName(keyOrSubkey) {
1343
1344
  try {
1344
1345
  const info = keyOrSubkey.getAlgorithmInfo();
@@ -1379,7 +1380,9 @@ async function parsePgpKey(armoredKey) {
1379
1380
  await cert.verify(
1380
1381
  key.keyPacket,
1381
1382
  cert.signatureType,
1382
- { userID: user.userID, key: key.keyPacket }
1383
+ { userID: user.userID, key: key.keyPacket },
1384
+ void 0,
1385
+ PGP_CONFIG
1383
1386
  );
1384
1387
  } catch {
1385
1388
  continue;
@@ -1430,7 +1433,7 @@ async function verifyAttestation({
1430
1433
  return { verified: false, reason: "Key fingerprint mismatch" };
1431
1434
  }
1432
1435
  const message = await readCleartextMessage({ cleartextMessage: pgpSignature });
1433
- const { signatures } = await verify({ message, verificationKeys: publicKey });
1436
+ const { signatures } = await verify({ message, verificationKeys: publicKey, config: PGP_CONFIG });
1434
1437
  await signatures[0].verified;
1435
1438
  const signedText = message.getText();
1436
1439
  if (!signedText.toLowerCase().includes(ethAddress.toLowerCase())) {
@@ -1625,6 +1628,14 @@ var PROVIDERS = [
1625
1628
  pattern: /^https:\/\/gist\.github\.com\/([^/]+)\/([a-f0-9]+)$/i,
1626
1629
  parse: (m) => ({ user: m[1], gistId: m[2] })
1627
1630
  },
1631
+ {
1632
+ // A repository's description — the form an organisation can use, since
1633
+ // gists belong to user accounts only. Same shape as the Codeberg proof.
1634
+ provider: "github",
1635
+ label: "GitHub",
1636
+ pattern: /^https:\/\/github\.com\/([A-Za-z0-9-]+)\/([A-Za-z0-9._-]+)$/i,
1637
+ parse: (m) => ({ user: m[1], repo: m[2] })
1638
+ },
1628
1639
  {
1629
1640
  provider: "dns",
1630
1641
  label: "DNS",
@@ -1696,6 +1707,7 @@ function containsFingerprintUrl(text, fingerprint) {
1696
1707
  return text.toUpperCase().includes(fingerprint.toUpperCase());
1697
1708
  }
1698
1709
  async function verifyGitHub(proof, fingerprint) {
1710
+ if (proof.repo) return verifyGitHubRepo(proof, fingerprint);
1699
1711
  try {
1700
1712
  const resp = await fetch(`https://api.github.com/gists/${proof.gistId}`);
1701
1713
  if (!resp.ok) return { verified: false, reason: `GitHub API returned ${resp.status}` };
@@ -1713,6 +1725,24 @@ async function verifyGitHub(proof, fingerprint) {
1713
1725
  return { verified: false, reason: `GitHub fetch failed: ${err.message}` };
1714
1726
  }
1715
1727
  }
1728
+ async function verifyGitHubRepo(proof, fingerprint) {
1729
+ try {
1730
+ const resp = await fetch(
1731
+ `https://api.github.com/repos/${encodeURIComponent(proof.user)}/${encodeURIComponent(proof.repo)}`
1732
+ );
1733
+ if (!resp.ok) return { verified: false, reason: `GitHub API returned ${resp.status}` };
1734
+ const data = await resp.json();
1735
+ if (data.owner?.login?.toLowerCase() !== proof.user.toLowerCase()) {
1736
+ return { verified: false, reason: "Repository owner does not match claimed account" };
1737
+ }
1738
+ if (data.description && containsFingerprint(data.description, fingerprint)) {
1739
+ return { verified: true };
1740
+ }
1741
+ return { verified: false, reason: "Fingerprint token not found in repository description" };
1742
+ } catch (err) {
1743
+ return { verified: false, reason: `GitHub fetch failed: ${err.message}` };
1744
+ }
1745
+ }
1716
1746
  async function verifyDNS(proof, fingerprint) {
1717
1747
  try {
1718
1748
  const resp = await fetch(