@kehto/paja 0.5.1 → 0.6.3
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/browser-host.js +149 -52
- package/dist/browser-host.js.map +1 -1
- package/dist/{chunk-5QKVKI4K.js → chunk-ADMLM2LH.js} +15 -7
- package/dist/{chunk-5QKVKI4K.js.map → chunk-ADMLM2LH.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -1
- package/package.json +12 -12
package/dist/browser-host.js
CHANGED
|
@@ -243,7 +243,7 @@ function cvmMap(action) {
|
|
|
243
243
|
return { senderCap: "cvm:call", recipientCap: null };
|
|
244
244
|
}
|
|
245
245
|
function outboxMap(action) {
|
|
246
|
-
if (action === "event" || action === "
|
|
246
|
+
if (action === "event" || action === "closed" || action.endsWith(".result") || action.endsWith(".error")) {
|
|
247
247
|
return { senderCap: null, recipientCap: "outbox:read" };
|
|
248
248
|
}
|
|
249
249
|
if (action === "publish") return { senderCap: "outbox:write", recipientCap: null };
|
|
@@ -612,7 +612,7 @@ function deserialize2(json) {
|
|
|
612
612
|
return defaultConfig();
|
|
613
613
|
}
|
|
614
614
|
|
|
615
|
-
// ../../node_modules/.pnpm/@napplet+core@0.
|
|
615
|
+
// ../../node_modules/.pnpm/@napplet+core@0.27.0/node_modules/@napplet/core/dist/index.js
|
|
616
616
|
function createDispatch() {
|
|
617
617
|
const handlers = /* @__PURE__ */ new Map();
|
|
618
618
|
function registerNap2(domain, handler) {
|
|
@@ -1079,6 +1079,41 @@ function createEventBuffer(sendToNapplet, sessionRegistry2, enforce, subscriptio
|
|
|
1079
1079
|
}
|
|
1080
1080
|
};
|
|
1081
1081
|
}
|
|
1082
|
+
function stringList(value) {
|
|
1083
|
+
if (!Array.isArray(value)) return void 0;
|
|
1084
|
+
const out = [...new Set(value.filter((item) => typeof item === "string" && item.length > 0))];
|
|
1085
|
+
return out.length > 0 ? out : void 0;
|
|
1086
|
+
}
|
|
1087
|
+
function sidecarFromUnknown(value) {
|
|
1088
|
+
if (!value || typeof value !== "object") return void 0;
|
|
1089
|
+
const input = value;
|
|
1090
|
+
const sidecar = {};
|
|
1091
|
+
if (Array.isArray(input.resources) && input.resources.length > 0) sidecar.resources = input.resources;
|
|
1092
|
+
const relayHints = stringList(input.relayHints);
|
|
1093
|
+
if (relayHints) sidecar.relayHints = relayHints;
|
|
1094
|
+
return sidecar.resources || sidecar.relayHints ? sidecar : void 0;
|
|
1095
|
+
}
|
|
1096
|
+
function createRelayEventResult(event, sidecar) {
|
|
1097
|
+
const normalized = sidecarFromUnknown(sidecar);
|
|
1098
|
+
return normalized ? { event, sidecar: normalized } : { event };
|
|
1099
|
+
}
|
|
1100
|
+
function createRelayEventResultWithHints(event, relayHints) {
|
|
1101
|
+
return createRelayEventResult(event, relayHints && relayHints.length > 0 ? { relayHints } : void 0);
|
|
1102
|
+
}
|
|
1103
|
+
function relayEventResultFromCarrier(carrier) {
|
|
1104
|
+
if (carrier.result && typeof carrier.result === "object") {
|
|
1105
|
+
const result2 = carrier.result;
|
|
1106
|
+
if (result2.event && typeof result2.event === "object") return createRelayEventResult(result2.event, result2.sidecar);
|
|
1107
|
+
}
|
|
1108
|
+
if (carrier.event && typeof carrier.event === "object") {
|
|
1109
|
+
const sidecar = sidecarFromUnknown(carrier.sidecar) ?? sidecarFromUnknown({ resources: carrier.resources });
|
|
1110
|
+
const relayHints = typeof carrier.relay === "string" && carrier.relay.length > 0 ? [carrier.relay] : void 0;
|
|
1111
|
+
const merged = sidecar ? { ...sidecar } : {};
|
|
1112
|
+
if (relayHints) merged.relayHints = relayHints;
|
|
1113
|
+
return createRelayEventResult(carrier.event, merged);
|
|
1114
|
+
}
|
|
1115
|
+
return null;
|
|
1116
|
+
}
|
|
1082
1117
|
function notifyServiceWindowDestroyed(windowId, services) {
|
|
1083
1118
|
for (const handler of Object.values(services)) {
|
|
1084
1119
|
try {
|
|
@@ -1119,6 +1154,15 @@ function relayServiceFrom(context) {
|
|
|
1119
1154
|
function isShellKindQuery(filters) {
|
|
1120
1155
|
return filters.length > 0 && filters.every((filter) => filter.kinds?.every((kind) => kind >= 29e3 && kind < 3e4));
|
|
1121
1156
|
}
|
|
1157
|
+
function sendRelayEvent(hooks, windowId, subId, result2) {
|
|
1158
|
+
hooks.sendToNapplet(windowId, { type: "relay.event", subId, result: result2 });
|
|
1159
|
+
}
|
|
1160
|
+
function normalizeRelayServiceResponse(resp) {
|
|
1161
|
+
const m = resp;
|
|
1162
|
+
if (m.type !== "relay.event") return resp;
|
|
1163
|
+
const result2 = relayEventResultFromCarrier(m);
|
|
1164
|
+
return result2 ? { type: "relay.event", subId: m.subId, result: result2 } : resp;
|
|
1165
|
+
}
|
|
1122
1166
|
function handleRelaySubscribe(context, windowId, msg, m) {
|
|
1123
1167
|
const { eventBuffer, hooks, serviceRegistry, subscriptions } = context;
|
|
1124
1168
|
const subId = m.subId ?? "";
|
|
@@ -1127,11 +1171,11 @@ function handleRelaySubscribe(context, windowId, msg, m) {
|
|
|
1127
1171
|
const subKey = `${windowId}:${subId}`;
|
|
1128
1172
|
subscriptions.set(subKey, { windowId, filters });
|
|
1129
1173
|
const seenIds = /* @__PURE__ */ new Set();
|
|
1130
|
-
function deliver(event) {
|
|
1174
|
+
function deliver(event, relayHints) {
|
|
1131
1175
|
if (seenIds.has(event.id)) return;
|
|
1132
1176
|
seenIds.add(event.id);
|
|
1133
1177
|
if (subscriptions.has(subKey)) {
|
|
1134
|
-
hooks
|
|
1178
|
+
sendRelayEvent(hooks, windowId, subId, createRelayEventResultWithHints(event, relayHints));
|
|
1135
1179
|
}
|
|
1136
1180
|
}
|
|
1137
1181
|
for (const bufferedEvent of eventBuffer.getBufferedEvents()) {
|
|
@@ -1143,12 +1187,12 @@ function handleRelaySubscribe(context, windowId, msg, m) {
|
|
|
1143
1187
|
if (!isShellKind && relayService) {
|
|
1144
1188
|
relayService.handleMessage(windowId, msg, (resp) => {
|
|
1145
1189
|
if (!subscriptions.has(subKey)) return;
|
|
1146
|
-
hooks.sendToNapplet(windowId, resp);
|
|
1190
|
+
hooks.sendToNapplet(windowId, normalizeRelayServiceResponse(resp));
|
|
1147
1191
|
});
|
|
1148
1192
|
if (cacheService) {
|
|
1149
1193
|
cacheService.handleMessage(windowId, msg, (resp) => {
|
|
1150
1194
|
if (!subscriptions.has(subKey)) return;
|
|
1151
|
-
hooks.sendToNapplet(windowId, resp);
|
|
1195
|
+
hooks.sendToNapplet(windowId, normalizeRelayServiceResponse(resp));
|
|
1152
1196
|
});
|
|
1153
1197
|
}
|
|
1154
1198
|
return;
|
|
@@ -1188,10 +1232,11 @@ function deliverFromRuntimeBackends(context, windowId, subId, subKey, filters, i
|
|
|
1188
1232
|
}
|
|
1189
1233
|
return;
|
|
1190
1234
|
}
|
|
1191
|
-
|
|
1235
|
+
const event = item;
|
|
1236
|
+
deliver(event, relayUrls);
|
|
1192
1237
|
if (cache2?.isAvailable() && !isShellKind) {
|
|
1193
1238
|
try {
|
|
1194
|
-
cache2.store(
|
|
1239
|
+
cache2.store(event);
|
|
1195
1240
|
} catch {
|
|
1196
1241
|
return;
|
|
1197
1242
|
}
|
|
@@ -1330,7 +1375,7 @@ function handleRelayQuery(context, windowId, m) {
|
|
|
1330
1375
|
for (const event of eventBuffer.getBufferedEvents()) {
|
|
1331
1376
|
if (matchesAnyFilter(event, filters) && !seenIds.has(event.id)) {
|
|
1332
1377
|
seenIds.add(event.id);
|
|
1333
|
-
events.push(event);
|
|
1378
|
+
events.push(createRelayEventResult(event));
|
|
1334
1379
|
}
|
|
1335
1380
|
}
|
|
1336
1381
|
let settled = false;
|
|
@@ -1363,9 +1408,10 @@ function handleRelayQuery(context, windowId, m) {
|
|
|
1363
1408
|
}, makeCollector2 = function() {
|
|
1364
1409
|
return function collector(resp) {
|
|
1365
1410
|
const r = resp;
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1411
|
+
const result2 = r.type === "relay.event" ? relayEventResultFromCarrier(r) : null;
|
|
1412
|
+
if (result2 && !seenIds.has(result2.event.id)) {
|
|
1413
|
+
seenIds.add(result2.event.id);
|
|
1414
|
+
events.push(result2);
|
|
1369
1415
|
} else if (r.type === "relay.eose") {
|
|
1370
1416
|
onBackendEose2();
|
|
1371
1417
|
}
|
|
@@ -1407,7 +1453,7 @@ function handleRelayQuery(context, windowId, m) {
|
|
|
1407
1453
|
for (const event of cachedEvents) {
|
|
1408
1454
|
if (!seenIds.has(event.id)) {
|
|
1409
1455
|
seenIds.add(event.id);
|
|
1410
|
-
events.push(event);
|
|
1456
|
+
events.push(createRelayEventResult(event));
|
|
1411
1457
|
}
|
|
1412
1458
|
}
|
|
1413
1459
|
}).catch(() => {
|
|
@@ -1434,7 +1480,7 @@ function handleRelayQuery(context, windowId, m) {
|
|
|
1434
1480
|
const event = item;
|
|
1435
1481
|
if (!seenIds.has(event.id)) {
|
|
1436
1482
|
seenIds.add(event.id);
|
|
1437
|
-
events.push(event);
|
|
1483
|
+
events.push(createRelayEventResultWithHints(event, relayUrls));
|
|
1438
1484
|
}
|
|
1439
1485
|
if (cache2?.isAvailable()) {
|
|
1440
1486
|
try {
|
|
@@ -7499,7 +7545,7 @@ function createRelayPoolService(options) {
|
|
|
7499
7545
|
}
|
|
7500
7546
|
return;
|
|
7501
7547
|
}
|
|
7502
|
-
send({ type: "relay.event", subId,
|
|
7548
|
+
send({ type: "relay.event", subId, result: createRelayEventResultWithHints(item, relayUrls2) });
|
|
7503
7549
|
}, relayUrls2);
|
|
7504
7550
|
tracked.set(subKey, { handle, eoseTimer });
|
|
7505
7551
|
return;
|
|
@@ -8857,6 +8903,59 @@ var OUTBOX_DESCRIPTOR = {
|
|
|
8857
8903
|
version: OUTBOX_SERVICE_VERSION,
|
|
8858
8904
|
description: "NAP-OUTBOX outbox-aware relay routing \u2014 getEvent/query/subscribe/publish/resolveRelays"
|
|
8859
8905
|
};
|
|
8906
|
+
function isRecord2(value) {
|
|
8907
|
+
return typeof value === "object" && value !== null;
|
|
8908
|
+
}
|
|
8909
|
+
function stringArray(value) {
|
|
8910
|
+
if (!Array.isArray(value)) return void 0;
|
|
8911
|
+
const strings = value.filter((item) => typeof item === "string");
|
|
8912
|
+
return strings.length > 0 ? strings : void 0;
|
|
8913
|
+
}
|
|
8914
|
+
function uint(value) {
|
|
8915
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : void 0;
|
|
8916
|
+
}
|
|
8917
|
+
function sanitizeEventOptions(raw) {
|
|
8918
|
+
if (!isRecord2(raw)) return void 0;
|
|
8919
|
+
const out = {};
|
|
8920
|
+
if (typeof raw.author === "string") out.author = raw.author;
|
|
8921
|
+
const relays = stringArray(raw.relays);
|
|
8922
|
+
if (relays) out.relays = relays;
|
|
8923
|
+
const timeoutMs = uint(raw.timeoutMs);
|
|
8924
|
+
if (timeoutMs !== void 0) out.timeoutMs = timeoutMs;
|
|
8925
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
8926
|
+
}
|
|
8927
|
+
function sanitizeQueryOptions(raw) {
|
|
8928
|
+
if (!isRecord2(raw)) return void 0;
|
|
8929
|
+
const out = {};
|
|
8930
|
+
const authors = stringArray(raw.authors);
|
|
8931
|
+
if (authors) out.authors = authors;
|
|
8932
|
+
const relays = stringArray(raw.relays);
|
|
8933
|
+
if (relays) out.relays = relays;
|
|
8934
|
+
const limit = uint(raw.limit);
|
|
8935
|
+
if (limit !== void 0) out.limit = limit;
|
|
8936
|
+
const timeoutMs = uint(raw.timeoutMs);
|
|
8937
|
+
if (timeoutMs !== void 0) out.timeoutMs = timeoutMs;
|
|
8938
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
8939
|
+
}
|
|
8940
|
+
var sanitizeSubscribeOptions = sanitizeQueryOptions;
|
|
8941
|
+
function sanitizePublishOptions(raw) {
|
|
8942
|
+
if (!isRecord2(raw)) return void 0;
|
|
8943
|
+
const out = {};
|
|
8944
|
+
const relays = stringArray(raw.relays);
|
|
8945
|
+
if (relays) out.relays = relays;
|
|
8946
|
+
const targetAuthors = stringArray(raw.targetAuthors);
|
|
8947
|
+
if (targetAuthors) out.targetAuthors = targetAuthors;
|
|
8948
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
8949
|
+
}
|
|
8950
|
+
function sanitizeTarget(raw) {
|
|
8951
|
+
if (!isRecord2(raw)) return void 0;
|
|
8952
|
+
const out = {};
|
|
8953
|
+
const authors = stringArray(raw.authors);
|
|
8954
|
+
if (authors) out.authors = authors;
|
|
8955
|
+
if (typeof raw.pubkey === "string") out.pubkey = raw.pubkey;
|
|
8956
|
+
if (raw.direction === "read" || raw.direction === "write") out.direction = raw.direction;
|
|
8957
|
+
return out;
|
|
8958
|
+
}
|
|
8860
8959
|
function normalizeFilters(raw) {
|
|
8861
8960
|
if (Array.isArray(raw)) {
|
|
8862
8961
|
const filters = raw.filter((f) => typeof f === "object" && f !== null);
|
|
@@ -8873,17 +8972,14 @@ function buildEventQuery(eventId, eventOptions) {
|
|
|
8873
8972
|
queryOptions.authors = [eventOptions.author];
|
|
8874
8973
|
}
|
|
8875
8974
|
if (Array.isArray(eventOptions?.relays)) queryOptions.relays = eventOptions.relays;
|
|
8876
|
-
if (eventOptions?.strategy !== void 0) queryOptions.strategy = eventOptions.strategy;
|
|
8877
8975
|
if (eventOptions?.timeoutMs !== void 0) queryOptions.timeoutMs = eventOptions.timeoutMs;
|
|
8878
8976
|
return { filter, queryOptions };
|
|
8879
8977
|
}
|
|
8880
8978
|
function eventResultFromQuery(eventId, result2) {
|
|
8881
|
-
const
|
|
8882
|
-
const eventResult = {
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
if (event) eventResult.event = event;
|
|
8886
|
-
if (!event) eventResult.error = result2.error ?? "not found";
|
|
8979
|
+
const relayResult = result2.events.find((candidate) => candidate.event.id === eventId);
|
|
8980
|
+
const eventResult = {};
|
|
8981
|
+
if (relayResult) eventResult.result = relayResult;
|
|
8982
|
+
if (!relayResult) eventResult.error = result2.error ?? "not found";
|
|
8887
8983
|
else if (result2.error !== void 0) eventResult.error = result2.error;
|
|
8888
8984
|
if (result2.incomplete !== void 0) eventResult.incomplete = result2.incomplete;
|
|
8889
8985
|
return eventResult;
|
|
@@ -8893,15 +8989,14 @@ function fallbackGetEvent(router, eventId, eventOptions) {
|
|
|
8893
8989
|
return router.query([filter], queryOptions).then((result2) => eventResultFromQuery(eventId, result2));
|
|
8894
8990
|
}
|
|
8895
8991
|
function sendEventResult(id, eventId, result2, send) {
|
|
8896
|
-
if (result2.
|
|
8897
|
-
send({ type: "outbox.getEvent.result", id,
|
|
8992
|
+
if (result2.result && result2.result.event.id !== eventId) {
|
|
8993
|
+
send({ type: "outbox.getEvent.result", id, error: "not found" });
|
|
8898
8994
|
return;
|
|
8899
8995
|
}
|
|
8900
8996
|
send({
|
|
8901
8997
|
type: "outbox.getEvent.result",
|
|
8902
8998
|
id,
|
|
8903
|
-
...result2.
|
|
8904
|
-
relays: result2.relays,
|
|
8999
|
+
...result2.result === void 0 ? {} : { result: result2.result },
|
|
8905
9000
|
...result2.incomplete === void 0 ? {} : { incomplete: result2.incomplete },
|
|
8906
9001
|
...result2.error === void 0 ? {} : { error: result2.error }
|
|
8907
9002
|
});
|
|
@@ -8910,12 +9005,12 @@ function handleGetEvent(router, msg, send) {
|
|
|
8910
9005
|
const m = msg;
|
|
8911
9006
|
const id = m.id ?? "";
|
|
8912
9007
|
if (typeof m.eventId !== "string" || m.eventId.length === 0) {
|
|
8913
|
-
send({ type: "outbox.getEvent.result", id,
|
|
9008
|
+
send({ type: "outbox.getEvent.result", id, error: "invalid filter" });
|
|
8914
9009
|
return;
|
|
8915
9010
|
}
|
|
8916
9011
|
const getEvent = router.getEvent ?? ((eventId, eventOptions) => fallbackGetEvent(router, eventId, eventOptions));
|
|
8917
|
-
void getEvent(m.eventId, m.options).then((result2) => sendEventResult(id, m.eventId, result2, send)).catch(
|
|
8918
|
-
(err2) => send({ type: "outbox.getEvent.result", id,
|
|
9012
|
+
void getEvent(m.eventId, sanitizeEventOptions(m.options)).then((result2) => sendEventResult(id, m.eventId, result2, send)).catch(
|
|
9013
|
+
(err2) => send({ type: "outbox.getEvent.result", id, error: toErrorMessage(err2) })
|
|
8919
9014
|
);
|
|
8920
9015
|
}
|
|
8921
9016
|
function createOutboxService(options) {
|
|
@@ -8929,20 +9024,19 @@ function createOutboxService(options) {
|
|
|
8929
9024
|
const id = m.id ?? "";
|
|
8930
9025
|
const filters = normalizeFilters(m.filters);
|
|
8931
9026
|
if (!filters) {
|
|
8932
|
-
send({ type: "outbox.query.result", id, events: [],
|
|
9027
|
+
send({ type: "outbox.query.result", id, events: [], error: "invalid filter" });
|
|
8933
9028
|
return;
|
|
8934
9029
|
}
|
|
8935
|
-
void router.query(filters, m.options).then(
|
|
9030
|
+
void router.query(filters, sanitizeQueryOptions(m.options)).then(
|
|
8936
9031
|
(result2) => send({
|
|
8937
9032
|
type: "outbox.query.result",
|
|
8938
9033
|
id,
|
|
8939
9034
|
events: result2.events,
|
|
8940
|
-
relays: result2.relays,
|
|
8941
9035
|
...result2.incomplete === void 0 ? {} : { incomplete: result2.incomplete },
|
|
8942
9036
|
...result2.error === void 0 ? {} : { error: result2.error }
|
|
8943
9037
|
})
|
|
8944
9038
|
).catch(
|
|
8945
|
-
(err2) => send({ type: "outbox.query.result", id, events: [],
|
|
9039
|
+
(err2) => send({ type: "outbox.query.result", id, events: [], error: toErrorMessage(err2) })
|
|
8946
9040
|
);
|
|
8947
9041
|
}
|
|
8948
9042
|
function handleSubscribe2(windowId, msg, send) {
|
|
@@ -8958,14 +9052,13 @@ function createOutboxService(options) {
|
|
|
8958
9052
|
return;
|
|
8959
9053
|
}
|
|
8960
9054
|
const sink = {
|
|
8961
|
-
event: (
|
|
8962
|
-
eose: () => send({ type: "outbox.eose", subId }),
|
|
9055
|
+
event: (result2) => send({ type: "outbox.event", subId, result: result2 }),
|
|
8963
9056
|
closed: (reason) => {
|
|
8964
9057
|
subscriptions.delete(subKey);
|
|
8965
9058
|
send({ type: "outbox.closed", subId, ...reason === void 0 ? {} : { reason } });
|
|
8966
9059
|
}
|
|
8967
9060
|
};
|
|
8968
|
-
subscriptions.set(subKey, router.subscribe(filters, m.options, sink));
|
|
9061
|
+
subscriptions.set(subKey, router.subscribe(filters, sanitizeSubscribeOptions(m.options), sink));
|
|
8969
9062
|
}
|
|
8970
9063
|
function handleClose(windowId, msg, send) {
|
|
8971
9064
|
const m = msg;
|
|
@@ -8983,7 +9076,7 @@ function createOutboxService(options) {
|
|
|
8983
9076
|
send({ type: "outbox.publish.result", id, ok: false, error: "invalid filter" });
|
|
8984
9077
|
return;
|
|
8985
9078
|
}
|
|
8986
|
-
void router.publish(m.event, m.options).then(
|
|
9079
|
+
void router.publish(m.event, sanitizePublishOptions(m.options)).then(
|
|
8987
9080
|
(result2) => send({
|
|
8988
9081
|
type: "outbox.publish.result",
|
|
8989
9082
|
id,
|
|
@@ -9000,11 +9093,12 @@ function createOutboxService(options) {
|
|
|
9000
9093
|
function handleResolveRelays(msg, send) {
|
|
9001
9094
|
const m = msg;
|
|
9002
9095
|
const id = m.id ?? "";
|
|
9003
|
-
|
|
9096
|
+
const target = sanitizeTarget(m.target);
|
|
9097
|
+
if (!target) {
|
|
9004
9098
|
send({ type: "outbox.resolveRelays.result", id, error: "invalid filter" });
|
|
9005
9099
|
return;
|
|
9006
9100
|
}
|
|
9007
|
-
void router.resolveRelays(
|
|
9101
|
+
void router.resolveRelays(target).then((plan) => send({ type: "outbox.resolveRelays.result", id, plan })).catch(
|
|
9008
9102
|
(err2) => send({ type: "outbox.resolveRelays.result", id, error: toErrorMessage(err2) })
|
|
9009
9103
|
);
|
|
9010
9104
|
}
|
|
@@ -10478,13 +10572,13 @@ function createOutboxRouter(pool, getSimulation, confirmRequest, signerProvider)
|
|
|
10478
10572
|
error: () => resolve(out)
|
|
10479
10573
|
});
|
|
10480
10574
|
});
|
|
10481
|
-
return { events
|
|
10575
|
+
return { events: events.map((event) => createRelayEventResultWithHints(event, relayUrls)) };
|
|
10482
10576
|
},
|
|
10483
10577
|
subscribe(filters, _options, sink) {
|
|
10484
10578
|
const relayUrls = getRelayUrls(getSimulation());
|
|
10485
10579
|
const sub = pool.subscription(relayUrls, filters).subscribe((item) => {
|
|
10486
|
-
if (item === "EOSE")
|
|
10487
|
-
|
|
10580
|
+
if (item === "EOSE") return;
|
|
10581
|
+
sink.event(createRelayEventResultWithHints(item, relayUrls[0] ? [relayUrls[0]] : relayUrls));
|
|
10488
10582
|
});
|
|
10489
10583
|
return { close: () => sub.unsubscribe() };
|
|
10490
10584
|
},
|
|
@@ -11092,9 +11186,9 @@ var __export = (target, all) => {
|
|
|
11092
11186
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11093
11187
|
};
|
|
11094
11188
|
var verifiedSymbol2 = /* @__PURE__ */ Symbol("verified");
|
|
11095
|
-
var
|
|
11189
|
+
var isRecord3 = (obj) => obj instanceof Object;
|
|
11096
11190
|
function validateEvent2(event) {
|
|
11097
|
-
if (!
|
|
11191
|
+
if (!isRecord3(event))
|
|
11098
11192
|
return false;
|
|
11099
11193
|
if (typeof event.kind !== "number")
|
|
11100
11194
|
return false;
|
|
@@ -14032,9 +14126,9 @@ function renderSignerStatus(state, signerPubkey) {
|
|
|
14032
14126
|
|
|
14033
14127
|
// ../../node_modules/.pnpm/nostr-tools@2.23.3_typescript@5.9.3/node_modules/nostr-tools/lib/esm/pool.js
|
|
14034
14128
|
var verifiedSymbol3 = /* @__PURE__ */ Symbol("verified");
|
|
14035
|
-
var
|
|
14129
|
+
var isRecord4 = (obj) => obj instanceof Object;
|
|
14036
14130
|
function validateEvent3(event) {
|
|
14037
|
-
if (!
|
|
14131
|
+
if (!isRecord4(event))
|
|
14038
14132
|
return false;
|
|
14039
14133
|
if (typeof event.kind !== "number")
|
|
14040
14134
|
return false;
|
|
@@ -15523,7 +15617,7 @@ async function resolveNapplet(options) {
|
|
|
15523
15617
|
}
|
|
15524
15618
|
|
|
15525
15619
|
// src/runtime-resolver.ts
|
|
15526
|
-
var
|
|
15620
|
+
var PAJA_NAPPLET_MANIFEST_KINDS = NAPPLET_KINDS;
|
|
15527
15621
|
function decodePajaPointer(value) {
|
|
15528
15622
|
const trimmed = value.trim();
|
|
15529
15623
|
const decoded = decode(trimmed);
|
|
@@ -15607,17 +15701,17 @@ async function resolvePointerEvent(pointer, pool, relays, maxWaitMs) {
|
|
|
15607
15701
|
if (!event) {
|
|
15608
15702
|
throw new Error(`No napplet manifest event found for ${pointer.type} pointer.`);
|
|
15609
15703
|
}
|
|
15610
|
-
if (event.kind
|
|
15611
|
-
throw new Error(`Pointer resolved kind ${event.kind}; expected ${
|
|
15704
|
+
if (!isNappletManifestKind(event.kind)) {
|
|
15705
|
+
throw new Error(`Pointer resolved kind ${event.kind}; expected ${formatNappletManifestKinds()}.`);
|
|
15612
15706
|
}
|
|
15613
15707
|
return event;
|
|
15614
15708
|
}
|
|
15615
15709
|
function addressableFilter(pointer) {
|
|
15616
|
-
if (pointer.kind !==
|
|
15617
|
-
throw new Error(`naddr kind ${pointer.kind} is not a napplet manifest kind.`);
|
|
15710
|
+
if (pointer.kind !== NAPPLET_KIND_NAMED) {
|
|
15711
|
+
throw new Error(`naddr kind ${pointer.kind} is not a named NIP-5D napplet manifest kind.`);
|
|
15618
15712
|
}
|
|
15619
15713
|
return {
|
|
15620
|
-
kinds: [
|
|
15714
|
+
kinds: [NAPPLET_KIND_NAMED],
|
|
15621
15715
|
authors: [pointer.pubkey],
|
|
15622
15716
|
"#d": [pointer.identifier],
|
|
15623
15717
|
limit: 1
|
|
@@ -15667,6 +15761,9 @@ function normalizeRelayUrl(value) {
|
|
|
15667
15761
|
function escapeAttribute(value) {
|
|
15668
15762
|
return value.replaceAll("&", "&").replaceAll('"', """).replaceAll("<", "<").replaceAll(">", ">");
|
|
15669
15763
|
}
|
|
15764
|
+
function formatNappletManifestKinds() {
|
|
15765
|
+
return PAJA_NAPPLET_MANIFEST_KINDS.join(" / ");
|
|
15766
|
+
}
|
|
15670
15767
|
|
|
15671
15768
|
// src/browser-host.ts
|
|
15672
15769
|
var bridgeRef = null;
|