@orangecheck/sdk 1.7.0 → 1.8.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/attestation.js.map +1 -1
- package/dist/attestation.mjs.map +1 -1
- package/dist/identity.js.map +1 -1
- package/dist/identity.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +67 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -3
- package/dist/index.mjs.map +1 -1
- package/dist/nostr.d.mts +2 -1
- package/dist/nostr.d.ts +2 -1
- package/dist/nostr.js +65 -0
- package/dist/nostr.js.map +1 -1
- package/dist/nostr.mjs +65 -1
- package/dist/nostr.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -527,6 +527,70 @@ async function queryByIdentity(protocol, identifier, relays = DEFAULT_RELAYS) {
|
|
|
527
527
|
log.info({ eventCount: events.length }, "Query complete");
|
|
528
528
|
return events;
|
|
529
529
|
}
|
|
530
|
+
async function queryRecent(relays = DEFAULT_RELAYS, limit = 200) {
|
|
531
|
+
const events = [];
|
|
532
|
+
log.info({ relayCount: relays.length, limit }, "Querying relays for recent attestations");
|
|
533
|
+
const deadlineAt = Date.now() + FANOUT_DEADLINE_MS;
|
|
534
|
+
const queryPromises = relays.map(async (relayUrl) => {
|
|
535
|
+
try {
|
|
536
|
+
const ws = new WebSocket(relayUrl);
|
|
537
|
+
await new Promise((resolve, reject) => {
|
|
538
|
+
const timeout = setTimeout(() => {
|
|
539
|
+
ws.close();
|
|
540
|
+
reject(new Error("Query timeout"));
|
|
541
|
+
}, budgetFor(deadlineAt));
|
|
542
|
+
ws.onopen = () => {
|
|
543
|
+
const subscriptionId = `ochk_recent_${Date.now()}`;
|
|
544
|
+
ws.send(
|
|
545
|
+
JSON.stringify([
|
|
546
|
+
"REQ",
|
|
547
|
+
subscriptionId,
|
|
548
|
+
{ kinds: [ATTESTATION_EVENT_KIND], "#t": ["oc-attest"], limit }
|
|
549
|
+
])
|
|
550
|
+
);
|
|
551
|
+
};
|
|
552
|
+
ws.onmessage = (msg) => {
|
|
553
|
+
try {
|
|
554
|
+
const data = JSON.parse(msg.data);
|
|
555
|
+
if (data[0] === "EVENT") {
|
|
556
|
+
const ev = data[2];
|
|
557
|
+
const scheme = ev.tags?.find((t) => t[0] === "scheme")?.[1];
|
|
558
|
+
const dTag = ev.tags?.find((t) => t[0] === "d")?.[1];
|
|
559
|
+
if ((scheme === "bip322" || scheme === "legacy") && dTag) {
|
|
560
|
+
events.push(ev);
|
|
561
|
+
}
|
|
562
|
+
} else if (data[0] === "EOSE") {
|
|
563
|
+
clearTimeout(timeout);
|
|
564
|
+
ws.close();
|
|
565
|
+
resolve();
|
|
566
|
+
}
|
|
567
|
+
} catch (err) {
|
|
568
|
+
log.error({ relay: relayUrl, error: err }, "Failed to parse event");
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
ws.onerror = (err) => {
|
|
572
|
+
clearTimeout(timeout);
|
|
573
|
+
log.error({ relay: relayUrl, error: err }, "WebSocket error during query");
|
|
574
|
+
reject(err);
|
|
575
|
+
};
|
|
576
|
+
});
|
|
577
|
+
} catch (err) {
|
|
578
|
+
log.error({ relay: relayUrl, error: err }, "Failed to query relay");
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
await Promise.allSettled(queryPromises);
|
|
582
|
+
const seen = /* @__PURE__ */ new Set();
|
|
583
|
+
const envelopes = [];
|
|
584
|
+
for (const ev of events) {
|
|
585
|
+
const envelope = parseAttestationFromEvent(ev);
|
|
586
|
+
if (!envelope || seen.has(envelope.attestation_id)) continue;
|
|
587
|
+
if (!await verifyAttestationEnvelope(envelope)) continue;
|
|
588
|
+
seen.add(envelope.attestation_id);
|
|
589
|
+
envelopes.push(envelope);
|
|
590
|
+
}
|
|
591
|
+
log.info({ eventCount: events.length, unique: envelopes.length }, "Recent query complete");
|
|
592
|
+
return envelopes;
|
|
593
|
+
}
|
|
530
594
|
async function verifyAttestationEnvelope(envelope) {
|
|
531
595
|
try {
|
|
532
596
|
const encoder = new TextEncoder();
|
|
@@ -2133,12 +2197,12 @@ var STATUS_META = {
|
|
|
2133
2197
|
},
|
|
2134
2198
|
bond_zero: {
|
|
2135
2199
|
label: "No confirmed bitcoin found",
|
|
2136
|
-
detail: "This address has no confirmed UTXOs. Send some bitcoin to this address and wait for confirmation to establish a
|
|
2200
|
+
detail: "This address has no confirmed UTXOs. Send some bitcoin to this address and wait for confirmation to establish a stake.",
|
|
2137
2201
|
severity: "warn"
|
|
2138
2202
|
},
|
|
2139
2203
|
bond_pending: {
|
|
2140
2204
|
label: "Pending transactions detected",
|
|
2141
|
-
detail: "This address has unconfirmed transactions. Wait for confirmations before they count toward your
|
|
2205
|
+
detail: "This address has unconfirmed transactions. Wait for confirmations before they count toward your stake.",
|
|
2142
2206
|
severity: "info"
|
|
2143
2207
|
},
|
|
2144
2208
|
bond_insufficient: {
|
|
@@ -2183,6 +2247,6 @@ var STATUS_META = {
|
|
|
2183
2247
|
}
|
|
2184
2248
|
};
|
|
2185
2249
|
|
|
2186
|
-
export { DEFAULT_RELAYS, FANOUT_DEADLINE_MS, STATUS_META, buildCanonicalMessage, check, computeAllScores, computeScore, createAttestation, createAttestationEnvelope, createAttestationEvent, discoverAttestations, extractAttestationIdFromUrl, formatIdentities, formatIdentitiesForDisplay, generateAttestationId, generateGistTemplate, generateTweetText, generateWellKnownContent, getAttestationsForAddress, getAttestationsForIdentity, getDnsVerificationInstructions, getGistCreationUrl, getGitHubVerificationInstructions, getManualVerificationInstructions, getNip07Info, getNostrPublicKey, getNostrVerificationInstructions, getTweetUrl, getTwitterComposeUrl, getTwitterVerificationInstructions, getVerificationInstructions, getVerificationSummary, getVerificationUrl, getWellKnownUrl, isDnsIdentityVerified, isGitHubIdentityVerified, isNip07Available, isNostrIdentityVerified, isValidDomain, isValidTweetUrl, issueChallenge, nostrIdentifierForms, nostrPubkeyToHex, parseAttestationFromEvent, parseIdentities, publishAttestation, publishToRelays, queryByAddress, queryByAttestationId, queryByIdentity, requiresManualVerification, signNostrEvent, supportsAutomaticVerification, verify2 as verify, verifyAllIdentities, verifyAttestationById, verifyChallenge, verifyDnsIdentity, verifyGitHubIdentity, verifyIdentity, verifyNostrIdentity, verifyTwitterIdentity };
|
|
2250
|
+
export { DEFAULT_RELAYS, FANOUT_DEADLINE_MS, STATUS_META, buildCanonicalMessage, check, computeAllScores, computeScore, createAttestation, createAttestationEnvelope, createAttestationEvent, discoverAttestations, extractAttestationIdFromUrl, formatIdentities, formatIdentitiesForDisplay, generateAttestationId, generateGistTemplate, generateTweetText, generateWellKnownContent, getAttestationsForAddress, getAttestationsForIdentity, getDnsVerificationInstructions, getGistCreationUrl, getGitHubVerificationInstructions, getManualVerificationInstructions, getNip07Info, getNostrPublicKey, getNostrVerificationInstructions, getTweetUrl, getTwitterComposeUrl, getTwitterVerificationInstructions, getVerificationInstructions, getVerificationSummary, getVerificationUrl, getWellKnownUrl, isDnsIdentityVerified, isGitHubIdentityVerified, isNip07Available, isNostrIdentityVerified, isValidDomain, isValidTweetUrl, issueChallenge, nostrIdentifierForms, nostrPubkeyToHex, parseAttestationFromEvent, parseIdentities, publishAttestation, publishToRelays, queryByAddress, queryByAttestationId, queryByIdentity, queryRecent, requiresManualVerification, signNostrEvent, supportsAutomaticVerification, verify2 as verify, verifyAllIdentities, verifyAttestationById, verifyChallenge, verifyDnsIdentity, verifyGitHubIdentity, verifyIdentity, verifyNostrIdentity, verifyTwitterIdentity };
|
|
2187
2251
|
//# sourceMappingURL=index.mjs.map
|
|
2188
2252
|
//# sourceMappingURL=index.mjs.map
|