@orangecheck/sdk 1.9.0 → 1.10.0

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.mjs CHANGED
@@ -1595,11 +1595,14 @@ function isValidDomain(domain) {
1595
1595
  const domainPattern = /^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,}$/i;
1596
1596
  return domainPattern.test(cleanDomain);
1597
1597
  }
1598
- function isDnsIdentityVerified(attestationId, _domain, cachedContent) {
1599
- if (!cachedContent) {
1598
+ function isDnsIdentityVerified(attestationId, domain, cachedContent) {
1599
+ if (!cachedContent || !cachedContent.includes(attestationId)) {
1600
1600
  return false;
1601
1601
  }
1602
- return cachedContent.includes(attestationId);
1602
+ const named = /^Domain:\s*(\S+)\s*$/im.exec(cachedContent);
1603
+ if (!named) return true;
1604
+ const cleanDomain = domain.replace(/^https?:\/\//, "").replace(/\/$/, "").toLowerCase();
1605
+ return named[1].toLowerCase() === cleanDomain;
1603
1606
  }
1604
1607
 
1605
1608
  // src/identity/github.ts
@@ -1743,8 +1746,10 @@ This gist proves that I control both:
1743
1746
  Learn more about OrangeCheck: https://ochk.io
1744
1747
  `;
1745
1748
  }
1746
- function isGitHubIdentityVerified(attestationId, _username, cachedGists) {
1749
+ function isGitHubIdentityVerified(attestationId, username, cachedGists) {
1750
+ const login = username.replace(/^@/, "").toLowerCase();
1747
1751
  return cachedGists.some((gist) => {
1752
+ if (gist.owner?.login?.toLowerCase() !== login) return false;
1748
1753
  if (gist.description?.includes(attestationId)) {
1749
1754
  return true;
1750
1755
  }
@@ -1843,6 +1848,9 @@ async function queryNostrEvents(options) {
1843
1848
  return events;
1844
1849
  }
1845
1850
  async function verifyNostrEventSignature(event) {
1851
+ return nostrEventSignatureValid(event);
1852
+ }
1853
+ function nostrEventSignatureValid(event) {
1846
1854
  try {
1847
1855
  if (!event.id || !event.sig || !event.pubkey || typeof event.id !== "string" || typeof event.sig !== "string" || typeof event.pubkey !== "string" || event.sig.length !== 128 || !HEX_64_RE2.test(event.id) || !HEX_64_RE2.test(event.pubkey)) {
1848
1856
  return false;
@@ -1929,7 +1937,7 @@ The verification will search Nostr relays for your note and confirm you control
1929
1937
  function isNostrIdentityVerified(attestationId, npub, cachedEvents) {
1930
1938
  const pubkeyHex = npubToHex(npub);
1931
1939
  return cachedEvents.some(
1932
- (event) => event.pubkey === pubkeyHex && event.kind === 1 && event.content.includes(attestationId)
1940
+ (event) => event.pubkey === pubkeyHex && event.kind === 1 && event.content.includes(attestationId) && nostrEventSignatureValid(event)
1933
1941
  );
1934
1942
  }
1935
1943