@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.js CHANGED
@@ -884,10 +884,6 @@ async function verifySignature({
884
884
  scheme
885
885
  }) {
886
886
  try {
887
- if (sig === "demo_signature") {
888
- log4.warn("Demo signature detected in verifySignature - should be handled by demo mode");
889
- return "sig_invalid";
890
- }
891
887
  const detectedScheme = scheme || detectSignatureScheme(addr, sig);
892
888
  log4.debug(
893
889
  { addr, msgLength: msg.length, sigLength: sig.length, scheme: detectedScheme },
@@ -1113,26 +1109,6 @@ async function verify2(input, opts = {}) {
1113
1109
  codes.push("bad_request");
1114
1110
  return { ok: false, codes, network, attestation_id };
1115
1111
  }
1116
- if (opts.demoMode) {
1117
- const sats_bonded = 1e6;
1118
- const days_unspent = 90;
1119
- const metrics = {
1120
- sats_bonded,
1121
- days_unspent,
1122
- score: computeScore(sats_bonded, days_unspent, { algorithm: "v0" })
1123
- // ≈ 55.26
1124
- };
1125
- codes.push("sig_ok_bip322");
1126
- codes.push("bond_confirmed");
1127
- return {
1128
- ok: true,
1129
- codes,
1130
- network,
1131
- attestation_id,
1132
- identities: parsed.core.identities,
1133
- metrics
1134
- };
1135
- }
1136
1112
  if ((network === "testnet" || network === "signet") && !opts.testMode) {
1137
1113
  codes.push("network_testmode");
1138
1114
  return { ok: false, codes, network, attestation_id };
@@ -1641,11 +1617,14 @@ function isValidDomain(domain) {
1641
1617
  const domainPattern = /^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,}$/i;
1642
1618
  return domainPattern.test(cleanDomain);
1643
1619
  }
1644
- function isDnsIdentityVerified(attestationId, _domain, cachedContent) {
1645
- if (!cachedContent) {
1620
+ function isDnsIdentityVerified(attestationId, domain, cachedContent) {
1621
+ if (!cachedContent || !cachedContent.includes(attestationId)) {
1646
1622
  return false;
1647
1623
  }
1648
- return cachedContent.includes(attestationId);
1624
+ const named = /^Domain:\s*(\S+)\s*$/im.exec(cachedContent);
1625
+ if (!named) return true;
1626
+ const cleanDomain = domain.replace(/^https?:\/\//, "").replace(/\/$/, "").toLowerCase();
1627
+ return named[1].toLowerCase() === cleanDomain;
1649
1628
  }
1650
1629
 
1651
1630
  // src/identity/github.ts
@@ -1789,8 +1768,10 @@ This gist proves that I control both:
1789
1768
  Learn more about OrangeCheck: https://ochk.io
1790
1769
  `;
1791
1770
  }
1792
- function isGitHubIdentityVerified(attestationId, _username, cachedGists) {
1771
+ function isGitHubIdentityVerified(attestationId, username, cachedGists) {
1772
+ const login = username.replace(/^@/, "").toLowerCase();
1793
1773
  return cachedGists.some((gist) => {
1774
+ if (gist.owner?.login?.toLowerCase() !== login) return false;
1794
1775
  if (gist.description?.includes(attestationId)) {
1795
1776
  return true;
1796
1777
  }
@@ -1889,6 +1870,9 @@ async function queryNostrEvents(options) {
1889
1870
  return events;
1890
1871
  }
1891
1872
  async function verifyNostrEventSignature(event) {
1873
+ return nostrEventSignatureValid(event);
1874
+ }
1875
+ function nostrEventSignatureValid(event) {
1892
1876
  try {
1893
1877
  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)) {
1894
1878
  return false;
@@ -1975,7 +1959,7 @@ The verification will search Nostr relays for your note and confirm you control
1975
1959
  function isNostrIdentityVerified(attestationId, npub, cachedEvents) {
1976
1960
  const pubkeyHex = npubToHex(npub);
1977
1961
  return cachedEvents.some(
1978
- (event) => event.pubkey === pubkeyHex && event.kind === 1 && event.content.includes(attestationId)
1962
+ (event) => event.pubkey === pubkeyHex && event.kind === 1 && event.content.includes(attestationId) && nostrEventSignatureValid(event)
1979
1963
  );
1980
1964
  }
1981
1965