@orangecheck/sdk 1.3.0 → 1.4.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 +33 -12
- package/dist/attestation.js.map +1 -1
- package/dist/attestation.mjs +33 -12
- package/dist/attestation.mjs.map +1 -1
- package/dist/identity.js +2 -1
- package/dist/identity.js.map +1 -1
- package/dist/identity.mjs +2 -1
- package/dist/identity.mjs.map +1 -1
- package/dist/index.js +33 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -12
- package/dist/index.mjs.map +1 -1
- package/dist/nostr.js +33 -12
- package/dist/nostr.js.map +1 -1
- package/dist/nostr.mjs +33 -12
- package/dist/nostr.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -193,14 +193,19 @@ var DEFAULT_RELAYS = [
|
|
|
193
193
|
"wss://relay.damus.io",
|
|
194
194
|
"wss://relay.nostr.band",
|
|
195
195
|
"wss://nos.lol",
|
|
196
|
-
"wss://relay.snort.social"
|
|
196
|
+
"wss://relay.snort.social",
|
|
197
|
+
"wss://relay.ochk.io"
|
|
197
198
|
];
|
|
198
199
|
function createAttestationEvent(envelope, pubkey) {
|
|
199
200
|
const tags = [
|
|
200
201
|
["d", envelope.attestation_id],
|
|
201
|
-
// Parameterized replaceable event identifier
|
|
202
|
+
// Parameterized replaceable event identifier (indexed)
|
|
203
|
+
["t", envelope.address],
|
|
204
|
+
// Indexed btc-address tag — query with `#t`
|
|
205
|
+
["t", "oc-attest"],
|
|
206
|
+
// Family marker — `#t=["oc-attest"]` for cross-cut discovery
|
|
202
207
|
["address", envelope.address],
|
|
203
|
-
//
|
|
208
|
+
// Diagnostic / legacy — relay won't index this
|
|
204
209
|
["scheme", envelope.scheme],
|
|
205
210
|
// Signature scheme (bip322 or legacy)
|
|
206
211
|
["issued_at", envelope.issued_at]
|
|
@@ -232,6 +237,17 @@ async function publishToRelays(event, relays = DEFAULT_RELAYS) {
|
|
|
232
237
|
log.info({ eventId: event.id, relayCount: relays.length }, "Publishing event to relays");
|
|
233
238
|
const publishPromises = relays.map(async (relayUrl) => {
|
|
234
239
|
let ws = null;
|
|
240
|
+
let settled = false;
|
|
241
|
+
const recordSuccess = () => {
|
|
242
|
+
if (settled) return;
|
|
243
|
+
settled = true;
|
|
244
|
+
success.push(relayUrl);
|
|
245
|
+
};
|
|
246
|
+
const recordFailure = () => {
|
|
247
|
+
if (settled) return;
|
|
248
|
+
settled = true;
|
|
249
|
+
failed.push(relayUrl);
|
|
250
|
+
};
|
|
235
251
|
try {
|
|
236
252
|
ws = new WebSocket(relayUrl);
|
|
237
253
|
const wsRef = ws;
|
|
@@ -252,7 +268,7 @@ async function publishToRelays(event, relays = DEFAULT_RELAYS) {
|
|
|
252
268
|
const data = JSON.parse(msg.data);
|
|
253
269
|
if (data[0] === "OK" && data[1] === event.id) {
|
|
254
270
|
if (data[2] === true) {
|
|
255
|
-
|
|
271
|
+
recordSuccess();
|
|
256
272
|
cleanup();
|
|
257
273
|
resolve();
|
|
258
274
|
} else {
|
|
@@ -260,7 +276,7 @@ async function publishToRelays(event, relays = DEFAULT_RELAYS) {
|
|
|
260
276
|
{ relay: relayUrl, reason: data[3] },
|
|
261
277
|
"Relay rejected event"
|
|
262
278
|
);
|
|
263
|
-
|
|
279
|
+
recordFailure();
|
|
264
280
|
cleanup();
|
|
265
281
|
reject(new Error(data[3] || "Relay rejected event"));
|
|
266
282
|
}
|
|
@@ -270,14 +286,14 @@ async function publishToRelays(event, relays = DEFAULT_RELAYS) {
|
|
|
270
286
|
{ relay: relayUrl, error: err },
|
|
271
287
|
"Failed to parse relay response"
|
|
272
288
|
);
|
|
273
|
-
|
|
289
|
+
recordFailure();
|
|
274
290
|
cleanup();
|
|
275
291
|
reject(err);
|
|
276
292
|
}
|
|
277
293
|
};
|
|
278
294
|
wsRef.onerror = (err) => {
|
|
279
295
|
log.error({ relay: relayUrl, error: err }, "WebSocket error");
|
|
280
|
-
|
|
296
|
+
recordFailure();
|
|
281
297
|
cleanup();
|
|
282
298
|
reject(err);
|
|
283
299
|
};
|
|
@@ -287,9 +303,7 @@ async function publishToRelays(event, relays = DEFAULT_RELAYS) {
|
|
|
287
303
|
});
|
|
288
304
|
} catch (err) {
|
|
289
305
|
log.error({ relay: relayUrl, error: err }, "Failed to publish to relay");
|
|
290
|
-
|
|
291
|
-
failed.push(relayUrl);
|
|
292
|
-
}
|
|
306
|
+
recordFailure();
|
|
293
307
|
} finally {
|
|
294
308
|
if (ws && ws.readyState !== WebSocket.CLOSED) {
|
|
295
309
|
ws.close();
|
|
@@ -384,8 +398,15 @@ async function queryByAddress(address, relays = DEFAULT_RELAYS) {
|
|
|
384
398
|
subscriptionId,
|
|
385
399
|
{
|
|
386
400
|
kinds: [30078],
|
|
387
|
-
|
|
388
|
-
|
|
401
|
+
// `#t`, NOT `#address`: NIP-12 relays index
|
|
402
|
+
// single-letter tags only, so `#address`
|
|
403
|
+
// matched nothing on any relay and this
|
|
404
|
+
// function returned empty for every real
|
|
405
|
+
// attestation. attest.ochk.io's verifier has
|
|
406
|
+
// queried `#t` since the same fix landed
|
|
407
|
+
// there; this is the back-port.
|
|
408
|
+
"#t": [address],
|
|
409
|
+
limit: 50
|
|
389
410
|
}
|
|
390
411
|
])
|
|
391
412
|
);
|