@orangecheck/sdk 1.8.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
@@ -862,10 +862,6 @@ async function verifySignature({
862
862
  scheme
863
863
  }) {
864
864
  try {
865
- if (sig === "demo_signature") {
866
- log4.warn("Demo signature detected in verifySignature - should be handled by demo mode");
867
- return "sig_invalid";
868
- }
869
865
  const detectedScheme = scheme || detectSignatureScheme(addr, sig);
870
866
  log4.debug(
871
867
  { addr, msgLength: msg.length, sigLength: sig.length, scheme: detectedScheme },
@@ -1091,26 +1087,6 @@ async function verify2(input, opts = {}) {
1091
1087
  codes.push("bad_request");
1092
1088
  return { ok: false, codes, network, attestation_id };
1093
1089
  }
1094
- if (opts.demoMode) {
1095
- const sats_bonded = 1e6;
1096
- const days_unspent = 90;
1097
- const metrics = {
1098
- sats_bonded,
1099
- days_unspent,
1100
- score: computeScore(sats_bonded, days_unspent, { algorithm: "v0" })
1101
- // ≈ 55.26
1102
- };
1103
- codes.push("sig_ok_bip322");
1104
- codes.push("bond_confirmed");
1105
- return {
1106
- ok: true,
1107
- codes,
1108
- network,
1109
- attestation_id,
1110
- identities: parsed.core.identities,
1111
- metrics
1112
- };
1113
- }
1114
1090
  if ((network === "testnet" || network === "signet") && !opts.testMode) {
1115
1091
  codes.push("network_testmode");
1116
1092
  return { ok: false, codes, network, attestation_id };
@@ -1619,11 +1595,14 @@ function isValidDomain(domain) {
1619
1595
  const domainPattern = /^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,}$/i;
1620
1596
  return domainPattern.test(cleanDomain);
1621
1597
  }
1622
- function isDnsIdentityVerified(attestationId, _domain, cachedContent) {
1623
- if (!cachedContent) {
1598
+ function isDnsIdentityVerified(attestationId, domain, cachedContent) {
1599
+ if (!cachedContent || !cachedContent.includes(attestationId)) {
1624
1600
  return false;
1625
1601
  }
1626
- 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;
1627
1606
  }
1628
1607
 
1629
1608
  // src/identity/github.ts
@@ -1767,8 +1746,10 @@ This gist proves that I control both:
1767
1746
  Learn more about OrangeCheck: https://ochk.io
1768
1747
  `;
1769
1748
  }
1770
- function isGitHubIdentityVerified(attestationId, _username, cachedGists) {
1749
+ function isGitHubIdentityVerified(attestationId, username, cachedGists) {
1750
+ const login = username.replace(/^@/, "").toLowerCase();
1771
1751
  return cachedGists.some((gist) => {
1752
+ if (gist.owner?.login?.toLowerCase() !== login) return false;
1772
1753
  if (gist.description?.includes(attestationId)) {
1773
1754
  return true;
1774
1755
  }
@@ -1867,6 +1848,9 @@ async function queryNostrEvents(options) {
1867
1848
  return events;
1868
1849
  }
1869
1850
  async function verifyNostrEventSignature(event) {
1851
+ return nostrEventSignatureValid(event);
1852
+ }
1853
+ function nostrEventSignatureValid(event) {
1870
1854
  try {
1871
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)) {
1872
1856
  return false;
@@ -1953,7 +1937,7 @@ The verification will search Nostr relays for your note and confirm you control
1953
1937
  function isNostrIdentityVerified(attestationId, npub, cachedEvents) {
1954
1938
  const pubkeyHex = npubToHex(npub);
1955
1939
  return cachedEvents.some(
1956
- (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)
1957
1941
  );
1958
1942
  }
1959
1943