@thurinlabs/identity-kit 1.0.0 → 1.0.1
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/README.md +1 -1
- package/dist/embed.global.js +27 -0
- package/dist/embed.global.js.map +1 -1
- package/dist/index.cjs +36 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1625,6 +1625,14 @@ var PROVIDERS = [
|
|
|
1625
1625
|
pattern: /^https:\/\/gist\.github\.com\/([^/]+)\/([a-f0-9]+)$/i,
|
|
1626
1626
|
parse: (m) => ({ user: m[1], gistId: m[2] })
|
|
1627
1627
|
},
|
|
1628
|
+
{
|
|
1629
|
+
// A repository's description — the form an organisation can use, since
|
|
1630
|
+
// gists belong to user accounts only. Same shape as the Codeberg proof.
|
|
1631
|
+
provider: "github",
|
|
1632
|
+
label: "GitHub",
|
|
1633
|
+
pattern: /^https:\/\/github\.com\/([A-Za-z0-9-]+)\/([A-Za-z0-9._-]+)$/i,
|
|
1634
|
+
parse: (m) => ({ user: m[1], repo: m[2] })
|
|
1635
|
+
},
|
|
1628
1636
|
{
|
|
1629
1637
|
provider: "dns",
|
|
1630
1638
|
label: "DNS",
|
|
@@ -1696,6 +1704,7 @@ function containsFingerprintUrl(text, fingerprint) {
|
|
|
1696
1704
|
return text.toUpperCase().includes(fingerprint.toUpperCase());
|
|
1697
1705
|
}
|
|
1698
1706
|
async function verifyGitHub(proof, fingerprint) {
|
|
1707
|
+
if (proof.repo) return verifyGitHubRepo(proof, fingerprint);
|
|
1699
1708
|
try {
|
|
1700
1709
|
const resp = await fetch(`https://api.github.com/gists/${proof.gistId}`);
|
|
1701
1710
|
if (!resp.ok) return { verified: false, reason: `GitHub API returned ${resp.status}` };
|
|
@@ -1713,6 +1722,24 @@ async function verifyGitHub(proof, fingerprint) {
|
|
|
1713
1722
|
return { verified: false, reason: `GitHub fetch failed: ${err.message}` };
|
|
1714
1723
|
}
|
|
1715
1724
|
}
|
|
1725
|
+
async function verifyGitHubRepo(proof, fingerprint) {
|
|
1726
|
+
try {
|
|
1727
|
+
const resp = await fetch(
|
|
1728
|
+
`https://api.github.com/repos/${encodeURIComponent(proof.user)}/${encodeURIComponent(proof.repo)}`
|
|
1729
|
+
);
|
|
1730
|
+
if (!resp.ok) return { verified: false, reason: `GitHub API returned ${resp.status}` };
|
|
1731
|
+
const data = await resp.json();
|
|
1732
|
+
if (data.owner?.login?.toLowerCase() !== proof.user.toLowerCase()) {
|
|
1733
|
+
return { verified: false, reason: "Repository owner does not match claimed account" };
|
|
1734
|
+
}
|
|
1735
|
+
if (data.description && containsFingerprint(data.description, fingerprint)) {
|
|
1736
|
+
return { verified: true };
|
|
1737
|
+
}
|
|
1738
|
+
return { verified: false, reason: "Fingerprint token not found in repository description" };
|
|
1739
|
+
} catch (err) {
|
|
1740
|
+
return { verified: false, reason: `GitHub fetch failed: ${err.message}` };
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1716
1743
|
async function verifyDNS(proof, fingerprint) {
|
|
1717
1744
|
try {
|
|
1718
1745
|
const resp = await fetch(
|