Merge branch 'master' into kosmos
# Conflicts: # release/assets/main-B-1wPM4A.js # release/assets/modules-4-12-CvJU34cM.js # release/assets/modules-4-12-DPYeIi5w.js # release/assets/modules-4-12-DWN9ffW9.js # release/index.html
This commit is contained in:
30 files changed
+1369
-14
No files matched your search
@@ -8,6 +8,7 @@ import { modifier } from 'ember-modifier';
|
||||
import { task } from 'ember-concurrency';
|
||||
import { EventFactory } from 'applesauce-core';
|
||||
import { encodePointer } from 'applesauce-core/helpers/pointers';
|
||||
import { withMarcoClientTag } from '../utils/client-tag';
|
||||
import or from 'ember-truth-helpers/helpers/or';
|
||||
import config from 'marco/config/environment';
|
||||
import DropdownMenu from './dropdown-menu';
|
||||
@@ -303,9 +304,11 @@ export default class PhotoGallery extends Component {
|
||||
tags.push(['i', this.currentPhoto.placeIdentifier]);
|
||||
}
|
||||
|
||||
const event = await EventFactory.fromKind(5)
|
||||
.content('Deleted photo')
|
||||
.modifyPublicTags(() => tags)
|
||||
const event = await withMarcoClientTag(
|
||||
EventFactory.fromKind(5)
|
||||
.content('Deleted photo')
|
||||
.modifyPublicTags(() => tags)
|
||||
)
|
||||
.as(this.nostrAuth.signer)
|
||||
.sign();
|
||||
const responses = await this.nostrRelay.publish(
|
||||
|
||||
@@ -148,6 +148,14 @@ export default class PlaceDetails extends Component {
|
||||
);
|
||||
}
|
||||
|
||||
// The event id the inline carousel should focus: a deep-linked photo from the
|
||||
// route's `photo` query param (see the `/e/:event_id` route), or a photo just
|
||||
// uploaded on this page.
|
||||
get focusPhotoEventId() {
|
||||
const photo = this.router.currentRoute?.queryParams?.photo;
|
||||
return photo || this.newlyUploadedPhotoId || null;
|
||||
}
|
||||
|
||||
get hasMultipleUntrusted() {
|
||||
return this.nostrData.untrustedContentCount > 1;
|
||||
}
|
||||
@@ -549,7 +557,7 @@ export default class PlaceDetails extends Component {
|
||||
@photos={{this.photos}}
|
||||
@name={{this.name}}
|
||||
@resetKey={{this.place.osmId}}
|
||||
@scrollToEventId={{this.newlyUploadedPhotoId}}
|
||||
@scrollToEventId={{this.focusPhotoEventId}}
|
||||
@onPhotoClick={{this.openGallery}}
|
||||
/>
|
||||
<h3>{{this.name}}</h3>
|
||||
|
||||
@@ -9,6 +9,7 @@ import PlacePhotoUploadItem from './place-photo-upload-item';
|
||||
import Icon from '#components/icon';
|
||||
import { getSuggestedPhotoTags } from '../utils/photo-tag-suggestions';
|
||||
import { buildPlacePhotoTags } from '../utils/photo-tags';
|
||||
import { withMarcoClientTag } from '../utils/client-tag';
|
||||
import capitalize from '../helpers/capitalize';
|
||||
import includes from '../helpers/includes';
|
||||
import { fn } from '@ember/helper';
|
||||
@@ -167,9 +168,11 @@ export default class PlacePhotoUpload extends Component {
|
||||
});
|
||||
|
||||
// NIP-XX draft Place Photo event
|
||||
const event = await EventFactory.fromKind(360)
|
||||
.content('')
|
||||
.modifyPublicTags(() => tags)
|
||||
const event = await withMarcoClientTag(
|
||||
EventFactory.fromKind(360)
|
||||
.content('')
|
||||
.modifyPublicTags(() => tags)
|
||||
)
|
||||
.as(this.nostrAuth.signer)
|
||||
.sign();
|
||||
const responses = await this.nostrRelay.publish(
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import Controller from '@ember/controller';
|
||||
|
||||
// `photo` carries the event id of a deep-linked place photo (e.g. from
|
||||
// `/e/:event_id`) so the place details carousel can focus it. Declared here so
|
||||
// Ember tracks it as a query parameter; `refreshModel: false` on the route
|
||||
// keeps the place model from reloading when only the photo changes.
|
||||
export default class PlaceController extends Controller {
|
||||
queryParams = ['photo'];
|
||||
|
||||
photo = null;
|
||||
}
|
||||
@@ -9,6 +9,7 @@ export default class Router extends EmberRouter {
|
||||
Router.map(function () {
|
||||
this.route('place', { path: '/place/:place_id' });
|
||||
this.route('place.new', { path: '/place/new' });
|
||||
this.route('event', { path: '/e/:event_id' });
|
||||
this.route('search');
|
||||
this.route('menu');
|
||||
this.route('lists', function () {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import Route from '@ember/routing/route';
|
||||
import { service } from '@ember/service';
|
||||
|
||||
import {
|
||||
parseNostrEventReference,
|
||||
placeIdentifierFromEvent,
|
||||
} from '../utils/nostr';
|
||||
|
||||
// Opens a shared NIP-19 event reference at its place. This backs the NIP-89
|
||||
// app handler's `web` URL template (https://marco.earth/e/<bech32>): given a
|
||||
// place photo (kind 360) or, later, a place review (kind 30360), it reads the
|
||||
// event's `i` tag and redirects into the place route.
|
||||
export default class EventRoute extends Route {
|
||||
@service nostrData;
|
||||
@service router;
|
||||
@service toast;
|
||||
|
||||
async model(params) {
|
||||
const pointer = parseNostrEventReference(params.event_id);
|
||||
if (!pointer) {
|
||||
return { error: 'This link is not a valid Nostr event reference.' };
|
||||
}
|
||||
|
||||
const event = await this.nostrData.loadEventByPointer(pointer);
|
||||
if (!event) {
|
||||
return { error: 'Could not find this event on any relay.' };
|
||||
}
|
||||
|
||||
const placeId = placeIdentifierFromEvent(event);
|
||||
if (!placeId) {
|
||||
return { error: 'This event is not linked to a place.' };
|
||||
}
|
||||
|
||||
return { placeId, eventId: event.id };
|
||||
}
|
||||
|
||||
redirect(model) {
|
||||
if (model.placeId) {
|
||||
return this.router.replaceWith('place', model.placeId, {
|
||||
queryParams: { photo: model.eventId },
|
||||
});
|
||||
}
|
||||
|
||||
this.toast.show(model.error || 'Could not open this event.');
|
||||
return this.router.replaceWith('index');
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,10 @@ export default class PlaceRoute extends Route {
|
||||
@service osm;
|
||||
@service mapUi;
|
||||
|
||||
// `photo` is the deep-link target consumed by place-details. Keep the model
|
||||
// from reloading when only the focused photo changes.
|
||||
queryParams = { photo: { refreshModel: false } };
|
||||
|
||||
async model(params) {
|
||||
const id = params.place_id;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
takeUntil,
|
||||
defer,
|
||||
of,
|
||||
firstValueFrom,
|
||||
} from 'rxjs';
|
||||
import { EventStore } from 'applesauce-core/event-store';
|
||||
import { ProfileModel } from 'applesauce-core/models/profile';
|
||||
@@ -129,6 +130,10 @@ export default class NostrDataService extends Service {
|
||||
_contactsSub = null;
|
||||
_blossomSub = null;
|
||||
_photosSub = null;
|
||||
// Live network subscription for the selected place's photos (`#i`). Unlike
|
||||
// the one-shot loaders, it stays open while the place is selected so photos
|
||||
// from every relay arrive even if some respond after others have EOSE'd.
|
||||
_photosNetworkSub = null;
|
||||
_contributionsSub = null;
|
||||
_deletionsSub = null;
|
||||
_insertSub = null;
|
||||
@@ -474,6 +479,38 @@ export default class NostrDataService extends Service {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a LIVE subscription to `filters` across `relays`, recording relay
|
||||
* provenance and adding events to the store as they arrive.
|
||||
*
|
||||
* Unlike `_requestContentWithProvenance`, this does NOT complete on the first
|
||||
* relay's EOSE. `completeOnAllEose()` only accounts for relays that have
|
||||
* reported so far, so a one-shot request can finish right after the fastest
|
||||
* relay and drop the rest (e.g. a place whose photos live on a relay that
|
||||
* answers later than the submission relay). Keeping the subscription open
|
||||
* lets every relay's events stream in, and keeps new events arriving live.
|
||||
* The caller is responsible for unsubscribing.
|
||||
*/
|
||||
_subscribeContentWithProvenance(relays, filters, errorLabel) {
|
||||
return this.nostrRelay.pool
|
||||
.req(relays, filters)
|
||||
.pipe(
|
||||
// Only EVENT messages carry content; ignore OPEN/EOSE/CLOSED/ERROR.
|
||||
// We deliberately do NOT dedupe so we see every relay's copy and can
|
||||
// accumulate full provenance across relays.
|
||||
filter((message) => message.type === 'EVENT')
|
||||
)
|
||||
.subscribe({
|
||||
next: (message) => {
|
||||
this._recordProvenance(message.event.id, message.from);
|
||||
this.store.add(message.event);
|
||||
},
|
||||
error: (err) => {
|
||||
console.error(errorLabel, err);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async loadPlacesInBounds(bbox) {
|
||||
const requiredPrefixes = getGeohashPrefixesInBbox(bbox);
|
||||
|
||||
@@ -543,6 +580,11 @@ export default class NostrDataService extends Service {
|
||||
this._photosSub = null;
|
||||
}
|
||||
|
||||
if (this._photosNetworkSub) {
|
||||
this._photosNetworkSub.unsubscribe();
|
||||
this._photosNetworkSub = null;
|
||||
}
|
||||
|
||||
this._cleanupZapReceiptSubs();
|
||||
this._clearZapRefreshTimer();
|
||||
|
||||
@@ -594,11 +636,13 @@ export default class NostrDataService extends Service {
|
||||
);
|
||||
}
|
||||
|
||||
// Fire network request specifically for this place (captures provenance).
|
||||
this._requestContentWithProvenance(
|
||||
// Open a live subscription for this place (captures provenance). It stays
|
||||
// open until the place changes, so photos from slower relays — and new
|
||||
// photos — still arrive after the first render.
|
||||
this._photosNetworkSub = this._subscribeContentWithProvenance(
|
||||
this.activeReadRelays,
|
||||
[{ kinds: [360, 5], '#i': [entityId] }],
|
||||
'[nostr-data] Error fetching place photos for place:'
|
||||
'[nostr-data] Error in place photos subscription:'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1092,6 +1136,38 @@ export default class NostrDataService extends Service {
|
||||
return this.profiles[pubkey];
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves a NIP-19 event reference (an `EventPointer` or `AddressPointer`)
|
||||
* to a concrete event, using the store's loader: cache first, then relay
|
||||
* hints attached to the pointer, then the active read relays and the public
|
||||
* directory relays. Returns `null` if nothing is found within `timeoutMs`.
|
||||
*
|
||||
* Used by the `/e/:event_id` route to find the place a shared event belongs
|
||||
* to.
|
||||
*
|
||||
* @param {object|null} pointer EventPointer or AddressPointer
|
||||
* @param {number} [timeoutMs=15000]
|
||||
* @returns {Promise<object|null>}
|
||||
*/
|
||||
async loadEventByPointer(pointer, timeoutMs = 15_000) {
|
||||
if (!pointer) return null;
|
||||
|
||||
try {
|
||||
return await firstValueFrom(
|
||||
this.store
|
||||
.event(pointer)
|
||||
.pipe(filter(Boolean), timeout({ first: timeoutMs }))
|
||||
);
|
||||
} catch (e) {
|
||||
console.debug(
|
||||
'[nostr-data] Failed to load event for pointer',
|
||||
pointer,
|
||||
e
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
_clearProfileSubs() {
|
||||
for (const sub of this._profileModelSubs.values()) {
|
||||
sub.unsubscribe();
|
||||
@@ -1431,6 +1507,10 @@ export default class NostrDataService extends Service {
|
||||
this._photosSub.unsubscribe();
|
||||
this._photosSub = null;
|
||||
}
|
||||
if (this._photosNetworkSub) {
|
||||
this._photosNetworkSub.unsubscribe();
|
||||
this._photosNetworkSub = null;
|
||||
}
|
||||
if (this._contributionsSub) {
|
||||
this._contributionsSub.unsubscribe();
|
||||
this._contributionsSub = null;
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from 'applesauce-common/helpers';
|
||||
import { getInboxes } from 'applesauce-core/helpers/mailboxes';
|
||||
import { firstValueFrom, timeout, catchError, of } from 'rxjs';
|
||||
import { MARCO_CLIENT_NAME, MARCO_HANDLER_POINTER } from '../utils/client-tag';
|
||||
|
||||
const DEFAULT_ZAP_RELAYS = [
|
||||
'wss://relay.damus.io',
|
||||
@@ -150,6 +151,7 @@ export default class NostrZapService extends Service {
|
||||
|
||||
return await ZapRequestFactory.event(event, amountMsats, relays)
|
||||
.message(message || '')
|
||||
.clientTag(MARCO_CLIENT_NAME, MARCO_HANDLER_POINTER)
|
||||
.as(signer)
|
||||
.sign();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// NIP-89 `client` tag for events published by Marco. It points at Marco's own
|
||||
// app handler (kind 31990) so other clients can attribute the event to the app.
|
||||
|
||||
export const MARCO_CLIENT_NAME = 'Marco';
|
||||
|
||||
export const MARCO_HANDLER_POINTER = {
|
||||
pubkey: '1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb',
|
||||
identifier: 'marco.earth',
|
||||
relays: ['wss://nostr.kosmos.org'],
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the NIP-89 client tag to an EventFactory (or subclass) and returns it,
|
||||
* so it can be chained: `withMarcoClientTag(factory).as(signer).sign()`.
|
||||
*
|
||||
* @param {object} factory An applesauce EventFactory
|
||||
* @returns {object} The same factory with the client tag operation queued
|
||||
*/
|
||||
export function withMarcoClientTag(factory) {
|
||||
return factory.clientTag(MARCO_CLIENT_NAME, MARCO_HANDLER_POINTER);
|
||||
}
|
||||
@@ -1,3 +1,8 @@
|
||||
import {
|
||||
decodeAddressPointer,
|
||||
decodeEventPointer,
|
||||
} from 'applesauce-core/helpers/pointers';
|
||||
|
||||
import { extractMediaHashes } from './photo-tags';
|
||||
|
||||
export function normalizeRelayUrl(url) {
|
||||
@@ -155,3 +160,98 @@ export function parsePlacePhotos(events) {
|
||||
|
||||
return allPhotos;
|
||||
}
|
||||
|
||||
// --- NIP-19 / NIP-21 event references (the `/e/:event_id` handler) ---------
|
||||
|
||||
const HEX_EVENT_ID = /^[0-9a-f]{64}$/i;
|
||||
const ADDRESS_COORDINATE = /^(\d+):([0-9a-f]{64}):(.*)$/i;
|
||||
const PLACE_IDENTIFIER = /^osm:(node|way|relation):\d+$/;
|
||||
|
||||
// Addressable ranges: NIP-01 replaceable (10xxx/10002) and parameterized
|
||||
// replaceable (30000-39999). Only the latter can be referenced by `naddr`.
|
||||
function isAddressableKind(kind) {
|
||||
return Number.isInteger(kind) && kind >= 30000 && kind < 40000;
|
||||
}
|
||||
|
||||
function stripNostrScheme(value) {
|
||||
return value.toLowerCase().startsWith('nostr:')
|
||||
? value.slice('nostr:'.length)
|
||||
: value;
|
||||
}
|
||||
|
||||
// Reduces a full permalink (e.g. https://njump.me/nevent1…) to its last path
|
||||
// segment; leaves bare references untouched.
|
||||
function toReference(value) {
|
||||
if (!/^https?:\/\//i.test(value)) return value;
|
||||
try {
|
||||
const segments = new URL(value).pathname.split('/').filter(Boolean);
|
||||
return segments.length
|
||||
? decodeURIComponent(segments[segments.length - 1])
|
||||
: '';
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a user-supplied event reference into an Applesauce pointer that
|
||||
* `EventStore.event()` / the event loader can resolve.
|
||||
*
|
||||
* Accepts a raw 64-hex event id, `note1`/`nevent1`/`naddr1` NIP-19 codes
|
||||
* (relay hints included), an optional `nostr:` scheme prefix (NIP-21), a raw
|
||||
* `kind:pubkey:d` coordinate, or a full permalink to any of those (resolved
|
||||
* via its last path segment).
|
||||
*
|
||||
* @param {string} input
|
||||
* @returns {{id: string, relays?: string[], author?: string, kind?: number}
|
||||
* | {kind: number, pubkey: string, identifier: string, relays?: string[]}
|
||||
* | null} An EventPointer or AddressPointer, or `null` if unrecognized
|
||||
*/
|
||||
export function parseNostrEventReference(input) {
|
||||
if (typeof input !== 'string') return null;
|
||||
|
||||
const candidate = toReference(stripNostrScheme(input.trim()));
|
||||
if (!candidate) return null;
|
||||
|
||||
const reference = stripNostrScheme(candidate);
|
||||
|
||||
if (HEX_EVENT_ID.test(reference)) {
|
||||
return { id: reference.toLowerCase() };
|
||||
}
|
||||
|
||||
const eventPointer = decodeEventPointer(reference);
|
||||
if (eventPointer) return eventPointer;
|
||||
|
||||
const addressPointer = decodeAddressPointer(reference);
|
||||
if (addressPointer && isAddressableKind(addressPointer.kind)) {
|
||||
return addressPointer;
|
||||
}
|
||||
|
||||
const coordinate = ADDRESS_COORDINATE.exec(reference);
|
||||
if (coordinate) {
|
||||
const kind = Number(coordinate[1]);
|
||||
if (isAddressableKind(kind)) {
|
||||
return {
|
||||
kind,
|
||||
pubkey: coordinate[2].toLowerCase(),
|
||||
identifier: coordinate[3],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the place identifier (e.g. `osm:node:123`) from a place photo or
|
||||
* review event's `i` tag, or `null` when the event is not linked to an OSM
|
||||
* element.
|
||||
*
|
||||
* @param {object} event A Nostr event
|
||||
* @returns {string | null}
|
||||
*/
|
||||
export function placeIdentifierFromEvent(event) {
|
||||
if (!event || !Array.isArray(event.tags)) return null;
|
||||
const value = event.tags.find((tag) => tag[0] === 'i')?.[1];
|
||||
return value && PLACE_IDENTIFIER.test(value) ? value : null;
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
# Marco as a NIP-89 App Handler
|
||||
|
||||
[NIP-89](https://github.com/nostr-protocol/nips/blob/master/89.md) lets clients
|
||||
discover applications that can handle an otherwise unknown event kind. Marco
|
||||
declares itself as the handler for the place media kinds it defines:
|
||||
|
||||
- `kind 360` — Place Photos and Videos (see
|
||||
[`nip-place-photos.md`](./nip-place-photos.md))
|
||||
- `kind 30360` — Place Reviews (to be added when
|
||||
[`nip-place-reviews.md`](./nip-place-reviews.md) ships)
|
||||
|
||||
Two events are involved:
|
||||
|
||||
| Event | Kind | Published by | Purpose |
|
||||
| -------------- | ------- | --------------------- | --------------------------------------------------- |
|
||||
| App handler | `31990` | the author's **npub** | Describes Marco and where to open each handled kind |
|
||||
| Recommendation | `31989` | a **user** key | Recommends Marco's handler to that user's followers |
|
||||
|
||||
Both are addressable: re-publishing with the same author and `d` tag replaces
|
||||
the previous event.
|
||||
|
||||
## Identity
|
||||
|
||||
Marco's app handler is signed by the author's own npub — the same identity that
|
||||
authors the NIP specs — so it appears on NostrHub under a real Nostr account
|
||||
rather than a separate app key:
|
||||
|
||||
```
|
||||
pubkey: 1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb
|
||||
npub: npub1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89svgdees
|
||||
naddr: naddr1qq9k6ctjvdhjuetpwf6xsq3qraustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89sxpqqqp70va9myaa
|
||||
```
|
||||
|
||||
The key itself is never stored in this repository. The publishing scripts sign
|
||||
through `nak` with an explicit signer from `NOSTR_SECRET_KEY` (an `nsec`/hex
|
||||
key, or a NIP-46 `bunker://` URL for a desktop signer), and `MARCO_APP_PUBKEY`
|
||||
in `scripts/nostr-common.sh` guards against signing from any other key. See
|
||||
[`publishing.md`](./publishing.md) for the shared setup.
|
||||
|
||||
## App handler event (`kind 31990`)
|
||||
|
||||
```json
|
||||
{
|
||||
"kind": 31990,
|
||||
"pubkey": "1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb",
|
||||
"content": "{\"name\":\"Marco\",\"about\":\"Unhosted maps app, enhancing OpenStreetMap with decentralized user data and content\",\"picture\":\"https://marco.earth/icons/icon-192.png\",\"website\":\"https://marco.earth\",\"nip05\":\"marco@kosmos.org\"}",
|
||||
"tags": [
|
||||
["d", "marco.earth"],
|
||||
["k", "360"],
|
||||
["web", "https://marco.earth/e/<bech32>", "nevent"],
|
||||
["i", "https://github.com/nostr-protocol/nips/blob/master/01.md"],
|
||||
["i", "https://github.com/nostr-protocol/nips/blob/master/07.md"],
|
||||
["i", "https://github.com/nostr-protocol/nips/blob/master/09.md"],
|
||||
["i", "https://github.com/nostr-protocol/nips/blob/master/19.md"],
|
||||
["i", "https://github.com/nostr-protocol/nips/blob/master/21.md"],
|
||||
["i", "https://github.com/nostr-protocol/nips/blob/master/46.md"],
|
||||
["i", "https://github.com/nostr-protocol/nips/blob/master/57.md"],
|
||||
["i", "https://github.com/nostr-protocol/nips/blob/master/65.md"],
|
||||
["i", "https://github.com/nostr-protocol/nips/blob/master/73.md"],
|
||||
["i", "https://github.com/nostr-protocol/nips/blob/master/89.md"],
|
||||
["i", "https://github.com/nostr-protocol/nips/blob/master/92.md"],
|
||||
["i", "https://github.com/nostr-protocol/nips/blob/master/B7.md"],
|
||||
[
|
||||
"a",
|
||||
"30817:1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb:place-photos-and-videos",
|
||||
"wss://nostr.kosmos.org",
|
||||
"nip"
|
||||
],
|
||||
["t", "maps"],
|
||||
[
|
||||
"a",
|
||||
"30617:1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb:marco",
|
||||
"wss://relay.ngit.dev"
|
||||
]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- **`content`** is optional kind-0-style metadata. Because the app key is not an
|
||||
account users follow, Marco carries its name/description/icon/website here
|
||||
instead of (or in addition to) a `kind 0`.
|
||||
- **`d`** is `marco.earth`, so the addressable coordinate is
|
||||
`31990:1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb:marco.earth`.
|
||||
- **`k`** lists every event kind Marco handles. Add `["k", "30360"]` when place
|
||||
reviews ship.
|
||||
- **`web`** is a URL template. Clients replace `<bech32>` with the NIP-19
|
||||
encoding of the entity to open, then load the URL. Marco resolves this at
|
||||
`/e/:event_id`, reads the event's `i` tag and opens its place. When the event
|
||||
is a place photo, it focuses that photo in the place's carousel (the place URL
|
||||
gains a `?photo=<event-id>` query param). It accepts a raw 64-hex event id,
|
||||
`note1`/`nevent1`/`naddr1` codes (relay hints included), an optional `nostr:`
|
||||
prefix, and full permalinks (resolved via the last path segment).
|
||||
- The second `web` value (`nevent`) makes the tag kind-specific. When reviews
|
||||
ship, add an `naddr` template (reviews are addressable) pointing at the same
|
||||
route, since an `naddr` resolves to the reviewed place too.
|
||||
- **`i`** tags advertise the official NIPs Marco implements, and one **`a`** tag
|
||||
references Marco's own kind-30817 NIP (Place Photos and Videos). See
|
||||
[Implemented NIPs](#implemented-nips).
|
||||
- **`content.nip05`** is the app's NIP-05 identifier.
|
||||
- **`t`** tags are categories; NostrHub renders them as hashtags.
|
||||
- The kind-30617 **`a`** tag links Marco's ngit repository (with a relay hint),
|
||||
which NostrHub shows as the app's source.
|
||||
|
||||
## Implemented NIPs
|
||||
|
||||
The handler lists what Marco implements so directories such as NostrHub's app
|
||||
list can show it. NostrHub reads two shapes:
|
||||
|
||||
- official NIPs as `i` tags whose value is the NIP's file URL in
|
||||
[nostr-protocol/nips](https://github.com/nostr-protocol/nips), e.g.
|
||||
`["i", "https://github.com/nostr-protocol/nips/blob/master/89.md"]`;
|
||||
- custom NIPs (kind 30817) as an `a` tag marked `nip`, e.g.
|
||||
`["a", "30817:<pubkey>:place-photos-and-videos", "wss://nostr.kosmos.org", "nip"]`.
|
||||
|
||||
The set (edit `MARCO_NIPS` and `MARCO_NIP_PHOTOS_D` in
|
||||
`scripts/nostr-common.sh`):
|
||||
|
||||
| NIP | What Marco uses it for |
|
||||
| --- | ----------------------------------------- |
|
||||
| 01 | Base protocol |
|
||||
| 07 | `window.nostr` extension signer |
|
||||
| 09 | Photo deletion (kind 5) |
|
||||
| 19 | bech32 entities (`npub`/`nevent`/`naddr`) |
|
||||
| 21 | `nostr:` URIs |
|
||||
| 46 | Nostr Connect remote signer |
|
||||
| 57 | Zaps (kinds 9734/9735) |
|
||||
| 65 | Reading relay lists (kind 10002) |
|
||||
| 73 | External content IDs (`osm:`) |
|
||||
| 89 | App handlers (this NIP) |
|
||||
| 92 | `imeta` media metadata |
|
||||
| B7 | Blossom blob upload/delete (kind 24242) |
|
||||
|
||||
The [NipId & NIP References](https://nostrhub.io/naddr1qvzqqqrcvypzphm8lxn7gyf9w3wtu7k0hhxsx6ghsrry8hmm44c0t5ss3uk5lssqqqrxu6ts95mnxjpcazr)
|
||||
extension of NIP-73 defines a more general `["i", "<nipid>", …]` + `["k", "nip"]`
|
||||
form (`github.com:nostr-protocol/nips:89`, or `30817:<pubkey>:<d>`), but
|
||||
NostrHub's app directory does not parse it, so the shapes above are used
|
||||
instead.
|
||||
|
||||
## Recommendation event (`kind 31989`)
|
||||
|
||||
Published from a _user's_ account (`scripts/publish-app-recommendation.sh`):
|
||||
|
||||
```json
|
||||
{
|
||||
"kind": 31989,
|
||||
"pubkey": "<user-pubkey>",
|
||||
"content": "",
|
||||
"tags": [
|
||||
["d", "360"],
|
||||
[
|
||||
"a",
|
||||
"31990:1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb:marco.earth",
|
||||
"wss://nostr.kosmos.org",
|
||||
"web"
|
||||
],
|
||||
[
|
||||
"a",
|
||||
"31990:1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb:marco.earth",
|
||||
"wss://relay.primal.net",
|
||||
"web"
|
||||
]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
- **`d`** is the supported event kind this recommendation applies to (`360`
|
||||
now; publish another with `d = 30360` later).
|
||||
- Each **`a`** tag is the app-handler coordinate plus a relay hint and the
|
||||
platform (`web`). Two tags give clients two places to find the handler.
|
||||
|
||||
## Relays
|
||||
|
||||
Publishing targets live in `scripts/nostr-relays.txt` (one URL per line; `#`
|
||||
comments allowed). `scripts/nostr-common.sh` loads them into `NOSTR_RELAYS`;
|
||||
edit that file to change where events are sent. An explicitly set
|
||||
`NOSTR_RELAYS` environment variable overrides it.
|
||||
|
||||
## Publishing
|
||||
|
||||
```sh
|
||||
# app handler, signed by the author's own npub
|
||||
NOSTR_SECRET_KEY='bunker://...' ./scripts/publish-app-handler.sh
|
||||
|
||||
# recommendation, signed by your own key
|
||||
NOSTR_SECRET_KEY='<your key or bunker>' ./scripts/publish-app-recommendation.sh
|
||||
|
||||
# retire an old handler (only its author key can delete it)
|
||||
NOSTR_SECRET_KEY='<old app key>' ./scripts/unpublish-app-handler.sh --dry-run
|
||||
NOSTR_SECRET_KEY='<old app key>' ./scripts/unpublish-app-handler.sh
|
||||
|
||||
# add --dry-run to any script to sign and print without publishing
|
||||
```
|
||||
|
||||
`MARCO_APP_PUBKEY` in `scripts/nostr-common.sh` holds the handler's author npub;
|
||||
the scripts refuse to sign from any other key. `unpublish-app-handler.sh`
|
||||
targets `MARCO_OLD_APP_PUBKEY` by default (pass a pubkey to override).
|
||||
@@ -0,0 +1,77 @@
|
||||
# Publishing Marco's NIPs on Nostr
|
||||
|
||||
Marco distributes the place NIPs both as files in `doc/nostr/` and as Nostr
|
||||
events, so they are discoverable and updatable without a git host.
|
||||
|
||||
## Custom NIPs (`kind 30817`)
|
||||
|
||||
Marco publishes each spec as a **`kind 30817` "Custom NIP"** event, the
|
||||
_NIPs on Nostr_ convention:
|
||||
|
||||
- `content` — the full Markdown of the spec
|
||||
- `["d", "<slug>"]` — unique identifier
|
||||
- `["title", "<title>"]`
|
||||
- `["k", "<kind>", "<kind name>"]` — the event kind(s) the spec defines
|
||||
- `["status", "review"]` — NostrHub metadata (not part of the kind-30817 spec)
|
||||
|
||||
Kind 30817 is addressable, so the spec is identified by `(pubkey, d)`. Editing
|
||||
the file and re-running the publish script **replaces** the previous event;
|
||||
this only works from the original author's key, which the script enforces.
|
||||
|
||||
### Published specs
|
||||
|
||||
| Spec | `d` | `k` | Status |
|
||||
| ----------------- | ------------------------- | ------- | ----------------- |
|
||||
| Photos and Videos | `place-photos-and-videos` | `360` | published |
|
||||
| Place Reviews | `place-reviews` | `30360` | not yet published |
|
||||
|
||||
The published photos spec is authored by
|
||||
|
||||
```
|
||||
npub: npub1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89svgdees
|
||||
hex: 1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb
|
||||
naddr: naddr1qvzqqqrcvypzq8meqkx80g3yuklzymy0qfx2ekk56aqc2ht4ak03z3em4r4cdcwtqqthqmrpvdjj6urgda6x7uedv9hxgttkd9jx2mmnl2q70n
|
||||
```
|
||||
|
||||
and is readable at
|
||||
https://nostrhub.io/naddr1qvzqqqrcvypzq8meqkx80g3yuklzymy0qfx2ekk56aqc2ht4ak03z3em4r4cdcwtqqthqmrpvdjj6urgda6x7uedv9hxgttkd9jx2mmnl2q70n.
|
||||
|
||||
## Relays
|
||||
|
||||
All publishing scripts read their relay list from `scripts/nostr-relays.txt`
|
||||
(one URL per line; `#` comments allowed), loaded into `NOSTR_RELAYS` by
|
||||
`scripts/nostr-common.sh`. Edit that file to change where events are sent; an
|
||||
explicitly set `NOSTR_RELAYS` environment variable overrides it.
|
||||
|
||||
## Scripts
|
||||
|
||||
| Script | Publishes |
|
||||
| --------------------------------------- | --------------------------------------------------- |
|
||||
| `scripts/publish-nip.sh photos` | `nip-place-photos.md` as kind 30817 |
|
||||
| `scripts/publish-nip.sh reviews` | `nip-place-reviews.md` as kind 30817 (when ready) |
|
||||
| `scripts/publish-app-handler.sh` | Marco's NIP-89 app handler (kind 31990) |
|
||||
| `scripts/publish-app-recommendation.sh` | A NIP-89 recommendation (kind 31989) pointing at it |
|
||||
|
||||
Each script signs via `nak` with an explicit `NOSTR_SECRET_KEY` and refuses to
|
||||
run without one, so nak's machine default key is never used by accident. The
|
||||
NIP scripts additionally verify the signer is the spec's author, so an update
|
||||
cannot accidentally fork the spec instead of replacing it.
|
||||
|
||||
## Signing
|
||||
|
||||
`NOSTR_SECRET_KEY` accepts an `nsec`, hex or `ncryptsec` key, or a NIP-46
|
||||
`bunker://` URL to sign with a desktop signer over Nostr Connect. For example:
|
||||
|
||||
```sh
|
||||
NOSTR_SECRET_KEY='bunker://<remote-pubkey>?relay=wss://relay.example' \
|
||||
./scripts/publish-nip.sh photos
|
||||
```
|
||||
|
||||
Use `--dry-run` to sign and print the event without publishing:
|
||||
|
||||
```sh
|
||||
NOSTR_SECRET_KEY='...' ./scripts/publish-nip.sh photos --dry-run
|
||||
```
|
||||
|
||||
See [`nip-89-app-handler.md`](./nip-89-app-handler.md) for the app handler and
|
||||
recommendation events.
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "marco",
|
||||
"version": "1.36.4",
|
||||
"version": "1.37.0",
|
||||
"private": true,
|
||||
"description": "Unhosted maps app",
|
||||
"repository": {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),a=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:"Module"}),r},l=(e,i,o,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var l,c=r(i),u=0,h=c.length;u<h;u++)l=c[u],s.call(e,l)||l===o||t(e,l,{get:(e=>i[e]).bind(null,l),enumerable:!(a=n(i,l))||a.enumerable});return e},c=(n,r,o)=>(o=null!=n?e(i(n)):{},l(!r&&n&&n.__esModule&&s.call(n,"default")?o:t(o,"default",{value:n,enumerable:!0}),n)),u=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)(function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver(e=>{for(const n of e)if("childList"===n.type)for(const e of n.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&t(e)}).observe(document,{childList:!0,subtree:!0})}function t(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),"use-credentials"===e.crossOrigin?t.credentials="include":"anonymous"===e.crossOrigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}();var h,d=Object.prototype,p=Symbol("undefined"),f=function(e){return e[e.ADD=0]="ADD",e[e.ONCE=1]="ONCE",e[e.REMOVE=2]="REMOVE",e}(f||{}),g=1,m=class{_descriptors;_mixins;_isInit;_lazyChains;_values;_revisions;source;proto;_parent;_listeners;_listenersVersion=1;_inheritedEnd=-1;_flattenedVersion=0;constructor(e){this._parent=void 0,this._descriptors=void 0,this._mixins=void 0,this._lazyChains=void 0,this._values=void 0,this._revisions=void 0,this._isInit=!1,this.source=e,this.proto=void 0===e.constructor?void 0:e.constructor.prototype,this._listeners=void 0}get parent(){let e=this._parent;if(void 0===e){let t=y(this.source);this._parent=e=null===t||t===d?null:_(t)}return e}setInitializing(){this._isInit=!0}unsetInitializing(){this._isInit=!1}isInitializing(){return this._isInit}isPrototypeMeta(e){return this.proto===this.source&&this.source===e}_getOrCreateOwnMap(e){return this[e]||(this[e]=Object.create(null))}_getOrCreateOwnSet(e){return this[e]||(this[e]=new Set)}_findInheritedMap(e,t){let n=this;for(;null!==n;){let r=n[e];if(void 0!==r){let e=r.get(t);if(void 0!==e)return e}n=n.parent}}_hasInInheritedSet(e,t){let n=this;for(;null!==n;){let r=n[e];if(void 0!==r&&r.has(t))return!0;n=n.parent}return!1}valueFor(e){let t=this._values;return void 0!==t?t[e]:void 0}setValueFor(e,t){this._getOrCreateOwnMap("_values")[e]=t}revisionFor(e){let t=this._revisions;return void 0!==t?t[e]:void 0}setRevisionFor(e,t){this._getOrCreateOwnMap("_revisions")[e]=t}writableLazyChainsFor(e){let t=this._getOrCreateOwnMap("_lazyChains"),n=t[e];return void 0===n&&(n=t[e]=[]),n}readableLazyChainsFor(e){let t=this._lazyChains;if(void 0!==t)return t[e]}addMixin(e){this._getOrCreateOwnSet("_mixins").add(e)}hasMixin(e){return this._hasInInheritedSet("_mixins",e)}forEachMixins(e){let t,n=this;for(;null!==n;){let r=n._mixins;void 0!==r&&(t=void 0===t?new Set:t,r.forEach(n=>{t.has(n)||(t.add(n),e(n))})),n=n.parent}}writeDescriptors(e,t){(this._descriptors||(this._descriptors=new Map)).set(e,t)}peekDescriptors(e){let t=this._findInheritedMap("_descriptors",e);return t===p?void 0:t}removeDescriptors(e){this.writeDescriptors(e,p)}forEachDescriptors(e){let t,n=this;for(;null!==n;){let r=n._descriptors;void 0!==r&&(t=void 0===t?new Set:t,r.forEach((n,r)=>{t.has(r)||(t.add(r),n!==p&&e(r,n))})),n=n.parent}}addToListeners(e,t,n,r,i){this.pushListener(e,t,n,r?f.ONCE:f.ADD,i)}removeFromListeners(e,t,n){this.pushListener(e,t,n,f.REMOVE)}pushListener(e,t,n,r,i=!1){let s=this.writableListeners(),o=x(s,e,t,n);if(-1!==o&&o<this._inheritedEnd&&(s.splice(o,1),this._inheritedEnd--,o=-1),-1===o)s.push({event:e,target:t,method:n,kind:r,sync:i});else{let e=s[o];r===f.REMOVE&&e.kind!==f.REMOVE?s.splice(o,1):(e.kind=r,e.sync=i)}}writableListeners(){return this._flattenedVersion!==g||this.source!==this.proto&&-1!==this._inheritedEnd||g++,-1===this._inheritedEnd&&(this._inheritedEnd=0,this._listeners=[]),this._listeners}flattenedListeners(){if(this._flattenedVersion<g){let e=this.parent;if(null!==e){let t=e.flattenedListeners();if(void 0!==t)if(void 0===this._listeners)this._listeners=t;else{let e=this._listeners;this._inheritedEnd>0&&(e.splice(0,this._inheritedEnd),this._inheritedEnd=0);for(Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
var t=Object.create,e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,o=(t,e)=>()=>(e||(t((e={exports:{}}).exports,e),t=null),e.exports),a=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:"Module"}),r},l=(t,i,o,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var l,c=r(i),u=0,h=c.length;u<h;u++)l=c[u],s.call(t,l)||l===o||e(t,l,{get:(t=>i[t]).bind(null,l),enumerable:!(a=n(i,l))||a.enumerable});return t},c=(n,r,o)=>(o=null!=n?t(i(n)):{},l(!r&&n&&n.__esModule&&s.call(n,"default")?o:e(o,"default",{value:n,enumerable:!0}),n)),u=(t=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(t,{get:(t,e)=>("undefined"!=typeof require?require:t)[e]}):t)(function(t){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Calling `require` for "'+t+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});!function(){const t=document.createElement("link").relList;if(!(t&&t.supports&&t.supports("modulepreload"))){for(const t of document.querySelectorAll('link[rel="modulepreload"]'))e(t);new MutationObserver(t=>{for(const n of t)if("childList"===n.type)for(const t of n.addedNodes)"LINK"===t.tagName&&"modulepreload"===t.rel&&e(t)}).observe(document,{childList:!0,subtree:!0})}function e(t){if(t.ep)return;t.ep=!0;const e=function(t){const e={};return t.integrity&&(e.integrity=t.integrity),t.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),"use-credentials"===t.crossOrigin?e.credentials="include":"anonymous"===t.crossOrigin?e.credentials="omit":e.credentials="same-origin",e}(t);fetch(t.href,e)}}();var h,d=Object.prototype,p=Symbol("undefined"),f=function(t){return t[t.ADD=0]="ADD",t[t.ONCE=1]="ONCE",t[t.REMOVE=2]="REMOVE",t}(f||{}),g=1,m=class{_descriptors;_mixins;_isInit;_lazyChains;_values;_revisions;source;proto;_parent;_listeners;_listenersVersion=1;_inheritedEnd=-1;_flattenedVersion=0;constructor(t){this._parent=void 0,this._descriptors=void 0,this._mixins=void 0,this._lazyChains=void 0,this._values=void 0,this._revisions=void 0,this._isInit=!1,this.source=t,this.proto=void 0===t.constructor?void 0:t.constructor.prototype,this._listeners=void 0}get parent(){let t=this._parent;if(void 0===t){let e=y(this.source);this._parent=t=null===e||e===d?null:_(e)}return t}setInitializing(){this._isInit=!0}unsetInitializing(){this._isInit=!1}isInitializing(){return this._isInit}isPrototypeMeta(t){return this.proto===this.source&&this.source===t}_getOrCreateOwnMap(t){return this[t]||(this[t]=Object.create(null))}_getOrCreateOwnSet(t){return this[t]||(this[t]=new Set)}_findInheritedMap(t,e){let n=this;for(;null!==n;){let r=n[t];if(void 0!==r){let t=r.get(e);if(void 0!==t)return t}n=n.parent}}_hasInInheritedSet(t,e){let n=this;for(;null!==n;){let r=n[t];if(void 0!==r&&r.has(e))return!0;n=n.parent}return!1}valueFor(t){let e=this._values;return void 0!==e?e[t]:void 0}setValueFor(t,e){this._getOrCreateOwnMap("_values")[t]=e}revisionFor(t){let e=this._revisions;return void 0!==e?e[t]:void 0}setRevisionFor(t,e){this._getOrCreateOwnMap("_revisions")[t]=e}writableLazyChainsFor(t){let e=this._getOrCreateOwnMap("_lazyChains"),n=e[t];return void 0===n&&(n=e[t]=[]),n}readableLazyChainsFor(t){let e=this._lazyChains;if(void 0!==e)return e[t]}addMixin(t){this._getOrCreateOwnSet("_mixins").add(t)}hasMixin(t){return this._hasInInheritedSet("_mixins",t)}forEachMixins(t){let e,n=this;for(;null!==n;){let r=n._mixins;void 0!==r&&(e=void 0===e?new Set:e,r.forEach(n=>{e.has(n)||(e.add(n),t(n))})),n=n.parent}}writeDescriptors(t,e){(this._descriptors||(this._descriptors=new Map)).set(t,e)}peekDescriptors(t){let e=this._findInheritedMap("_descriptors",t);return e===p?void 0:e}removeDescriptors(t){this.writeDescriptors(t,p)}forEachDescriptors(t){let e,n=this;for(;null!==n;){let r=n._descriptors;void 0!==r&&(e=void 0===e?new Set:e,r.forEach((n,r)=>{e.has(r)||(e.add(r),n!==p&&t(r,n))})),n=n.parent}}addToListeners(t,e,n,r,i){this.pushListener(t,e,n,r?f.ONCE:f.ADD,i)}removeFromListeners(t,e,n){this.pushListener(t,e,n,f.REMOVE)}pushListener(t,e,n,r,i=!1){let s=this.writableListeners(),o=x(s,t,e,n);if(-1!==o&&o<this._inheritedEnd&&(s.splice(o,1),this._inheritedEnd--,o=-1),-1===o)s.push({event:t,target:e,method:n,kind:r,sync:i});else{let t=s[o];r===f.REMOVE&&t.kind!==f.REMOVE?s.splice(o,1):(t.kind=r,t.sync=i)}}writableListeners(){return this._flattenedVersion!==g||this.source!==this.proto&&-1!==this._inheritedEnd||g++,-1===this._inheritedEnd&&(this._inheritedEnd=0,this._listeners=[]),this._listeners}flattenedListeners(){if(this._flattenedVersion<g){let t=this.parent;if(null!==t){let e=t.flattenedListeners();if(void 0!==e)if(void 0===this._listeners)this._listeners=e;else{let t=this._listeners;this._inheritedEnd>0&&(t.splice(0,this._inheritedEnd),this._inheritedEnd=0);for(Line truncated
|
||||
@@ -1 +1 @@
|
||||
import{$ as e,$n as t,$t as a,A as n,An as s,Ar as r,At as i,B as o,Bn as l,Br as g,Bt as d,C as h,Cn as c,Cr as u,Ct as p,D as _,Dn as m,Dr as y,Dt as C,E as b,En as f,Er as A,Et as M,F as I,Fn as D,Fr as T,Ft as v,G as O,Gn as E,Gr as S,Gt as R,H as j,Hn as x,Hr as w,Ht as P,I as N,In as V,Ir as F,It as G,J as L,Jn as k,Jr as U,Jt as Y,K as B,Kn as H,Kr as $,Kt as z,L as W,Ln as q,Lr as Z,Lt as J,M as K,Mn as X,Mr as Q,Mt as ee,N as te,Nn as ae,Nr as ne,Nt as se,O as re,On as ie,Or as oe,Ot as le,P as ge,Pn as de,Pr as he,Pt as ce,Q as ue,Qn as pe,Qt as _e,R as me,Rn as ye,Rr as Ce,Rt as be,S as fe,Sn as Ae,Sr as Me,St as Ie,T as De,Tn as Te,Tr as ve,Tt as Oe,U as Ee,Un as Se,Ur as Re,Ut as je,V as xe,Vn as we,Vr as Pe,Vt as Ne,W as Ve,Wn as Fe,Wr as Ge,Wt as Le,X as ke,Xn as Ue,Xr as Ye,Xt as Be,Y as He,Yn as $e,Yr as ze,Yt as We,Z as qe,Zn as Ze,Zr as Je,Zt as Ke,_ as Xe,_n as Qe,_r as et,_t as tt,a as at,an as nt,ar as st,at as rt,b as it,bn as ot,br as lt,bt as gt,c as dt,cn as ht,cr as ct,ct as ut,d as pt,dn as _t,dr as mt,dt as yt,en as Ct,er as bt,et as ft,f as At,fn as Mt,fr as It,ft as Dt,g as Tt,gn as vt,gr as Ot,gt as Et,h as St,hn as Rt,hr as jt,ht as xt,i as wt,in as Pt,ir as Nt,it as Vt,j as Ft,jn as Gt,jr as Lt,jt as kt,k as Ut,kn as Yt,kr as Bt,kt as Ht,l as $t,ln as zt,lr as Wt,lt as qt,m as Zt,mn as Jt,mr as Kt,mt as Xt,n as Qt,nn as ea,nr as ta,nt as aa,o as na,on as sa,or as ra,ot as ia,p as oa,pn as la,pr as ga,pt as da,q as ha,qn as ca,qr as ua,qt as pa,r as _a,rn as ma,rr as ya,rt as Ca,s as ba,sn as fa,sr as Aa,st as Ma,t as Ia,tn as Da,tr as Ta,tt as va,u as Oa,un as Ea,ur as Sa,ut as Ra,v as ja,vn as xa,vr as wa,vt as Pa,w as Na,wn as Va,wr as Fa,wt as Ga,x as La,xn as ka,xr as Ua,xt as Ya,y as Ba,yn as Ha,yr as $a,yt as za,z as Wa,zn as qa,zr as Za,zt as Ja}from"./main-B-1wPM4A.js";var Ka=Je({default:()=>Jt}),Xa=Je({default:()=>tn}),Qa={willChange:"_arrangedContentArrayWillChange",didChange:"_arrangedContentArrayDidChange"};function en(e,t){return"[]"===t?(e._revalidate(),e._arrTag):"length"===t?(e._revalidate(),e._lengthTag):F(e,t)}var tn=class extends V{_objectsDirtyIndex=0;_objects=null;_lengthDirty=!0;_length=0;_arrangedContent=null;_arrangedContentIsUpdating=!1;_arrangedContentTag=null;_arrangedContentRevision=null;_lengthTag=null;_arrTag=null;init(e){super.init(e),y(this,en)}[Ot](){this._revalidate()}willDestroy(){this._removeArrangedContentArrayObserver()}objectAtContent(e){let t=It(this,"arrangedContent");return Fa(t,e)}replace(e,t,a){this.replaceContent(e,t,a)}replaceContent(e,t,a){let n=It(this,"content");Wt(n,e,t,a)}objectAt(e){if(this._revalidate(),null===this._objects&&(this._objects=[]),-1!==this._objectsDirtyIndex&&e>=this._objectsDirtyIndex){let e=It(this,"arrangedContent");if(e){let t=this._objects.length=It(e,"length");for(let e=this._objectsDirtyIndex;e<t;e++)this._objects[e]=this.objectAtContent(e)}else this._objects.length=0;this._objectsDirtyIndex=-1}return this._objects[e]}get length(){if(this._revalidate(),this._lengthDirty){let e=It(this,"arrangedContent");this._length=e?It(e,"length"):0,this._lengthDirty=!1}return Ce(this._lengthTag),this._length}set length(e){let t,a=this.length-e;if(0===a)return;a<0&&(t=new Array(-a),a=0);let n=It(this,"content");n&&(Wt(n,e,a,t),this._invalidate())}_updateArrangedContentArray(e){let t=null===this._objects?0:this._objects.length,a=e?It(e,"length"):0;this._removeArrangedContentArrayObserver(),Aa(this,0,t,a),this._invalidate(),ra(this,0,t,a,!1),this._addArrangedContentArrayObserver(e)}_addArrangedContentArrayObserver(e){e&&!e.isDestroyed&&(st(e,this,Qa),this._arrangedContent=e)}_removeArrangedContentArrayObserver(){this._arrangedContent&&ct(this._arrangedContent,this,Qa)}_arrangedContentArrayWillChange(){}_arrangedContentArrayDidChange(e,t,a,n){Aa(this,t,a,n);let s=t;s<0&&(s+=It(this._arrangedContent,"length")+a-n),(-1===this._objectsDirtyIndex||this._objectsDirtyIndex>s)&&(this._objectsDirtyIndex=s),this._lengthDirty=!0,ra(this,t,a,n,!1)}_invalidate(){this._objectsDirtyIndex=0,this._lengthDirty=!0}_revalidate(){if(!0!==this._arrangedContentIsUpdating&&(null===this._arrangedContentTag||!Za(this._arrangedContentTag,this._arrangedContentRevision))){let e=this.get("arrangedContent");null===this._arrangedContentTag?this._addArrangedContentArrayObserver(e):(this._arrangedContentIsUpdating=!0,this._updateArrangedContentArray(e),this._arrangedContentIsUpdating=!1);let t=this._arrangedContentTag=F(this,"arrangedContent");this._arrangedContentRevision=g(this._arrangedContentTag),T(e)?(this._lengthTag=Z([t,ve(e,"length")]),this._arrTag=Z([t,ve(e,"[]")])):this._lengthTag=this._arrTag=t}}};tn.reopen(Jt,{arrangedContent:Sa("content")});var an=Je({Meta:()=>S,UNDEFINED:()=>$,counters:()=>ua,meta:()=>U,peekMeta:()=>ze,setMeta:()=>Ye}),nn=Je({ActionHandler:()=>l,Comparable:()=>vt,ContainerProxyMixin:()=>_t,MutableEnumerable:()=>Qe,RSVP:()=>k,RegistryProxyMixin:()=>Ea,TargetActionSupport:()=>ja,_ProxyMixin:()=>O,_contentFor:()=>B,onerrorLine truncated
|
||||
import{$ as e,$n as t,$t as a,A as n,An as s,Ar as r,At as i,B as o,Bn as l,Br as g,Bt as d,C as h,Cn as c,Cr as u,Ct as p,D as _,Dn as m,Dr as y,Dt as C,E as b,En as f,Er as A,Et as M,F as I,Fn as D,Fr as T,Ft as v,G as O,Gn as E,Gr as S,Gt as R,H as j,Hn as x,Hr as w,Ht as P,I as N,In as V,Ir as F,It as G,J as L,Jn as k,Jr as U,Jt as Y,K as B,Kn as H,Kr as $,Kt as z,L as W,Ln as q,Lr as Z,Lt as J,M as K,Mn as X,Mr as Q,Mt as ee,N as te,Nn as ae,Nr as ne,Nt as se,O as re,On as ie,Or as oe,Ot as le,P as ge,Pn as de,Pr as he,Pt as ce,Q as ue,Qn as pe,Qt as _e,R as me,Rn as ye,Rr as Ce,Rt as be,S as fe,Sn as Ae,Sr as Me,St as Ie,T as De,Tn as Te,Tr as ve,Tt as Oe,U as Ee,Un as Se,Ur as Re,Ut as je,V as xe,Vn as we,Vr as Pe,Vt as Ne,W as Ve,Wn as Fe,Wr as Ge,Wt as Le,X as ke,Xn as Ue,Xr as Ye,Xt as Be,Y as He,Yn as $e,Yr as ze,Yt as We,Z as qe,Zn as Ze,Zr as Je,Zt as Ke,_ as Xe,_n as Qe,_r as et,_t as tt,a as at,an as nt,ar as st,at as rt,b as it,bn as ot,br as lt,bt as gt,c as dt,cn as ht,cr as ct,ct as ut,d as pt,dn as _t,dr as mt,dt as yt,en as Ct,er as bt,et as ft,f as At,fn as Mt,fr as It,ft as Dt,g as Tt,gn as vt,gr as Ot,gt as Et,h as St,hn as Rt,hr as jt,ht as xt,i as wt,in as Pt,ir as Nt,it as Vt,j as Ft,jn as Gt,jr as Lt,jt as kt,k as Ut,kn as Yt,kr as Bt,kt as Ht,l as $t,ln as zt,lr as Wt,lt as qt,m as Zt,mn as Jt,mr as Kt,mt as Xt,n as Qt,nn as ea,nr as ta,nt as aa,o as na,on as sa,or as ra,ot as ia,p as oa,pn as la,pr as ga,pt as da,q as ha,qn as ca,qr as ua,qt as pa,r as _a,rn as ma,rr as ya,rt as Ca,s as ba,sn as fa,sr as Aa,st as Ma,t as Ia,tn as Da,tr as Ta,tt as va,u as Oa,un as Ea,ur as Sa,ut as Ra,v as ja,vn as xa,vr as wa,vt as Pa,w as Na,wn as Va,wr as Fa,wt as Ga,x as La,xn as ka,xr as Ua,xt as Ya,y as Ba,yn as Ha,yr as $a,yt as za,z as Wa,zn as qa,zr as Za,zt as Ja}from"./main-BD5lfqyM.js";var Ka=Je({default:()=>Jt}),Xa=Je({default:()=>tn}),Qa={willChange:"_arrangedContentArrayWillChange",didChange:"_arrangedContentArrayDidChange"};function en(e,t){return"[]"===t?(e._revalidate(),e._arrTag):"length"===t?(e._revalidate(),e._lengthTag):F(e,t)}var tn=class extends V{_objectsDirtyIndex=0;_objects=null;_lengthDirty=!0;_length=0;_arrangedContent=null;_arrangedContentIsUpdating=!1;_arrangedContentTag=null;_arrangedContentRevision=null;_lengthTag=null;_arrTag=null;init(e){super.init(e),y(this,en)}[Ot](){this._revalidate()}willDestroy(){this._removeArrangedContentArrayObserver()}objectAtContent(e){let t=It(this,"arrangedContent");return Fa(t,e)}replace(e,t,a){this.replaceContent(e,t,a)}replaceContent(e,t,a){let n=It(this,"content");Wt(n,e,t,a)}objectAt(e){if(this._revalidate(),null===this._objects&&(this._objects=[]),-1!==this._objectsDirtyIndex&&e>=this._objectsDirtyIndex){let e=It(this,"arrangedContent");if(e){let t=this._objects.length=It(e,"length");for(let e=this._objectsDirtyIndex;e<t;e++)this._objects[e]=this.objectAtContent(e)}else this._objects.length=0;this._objectsDirtyIndex=-1}return this._objects[e]}get length(){if(this._revalidate(),this._lengthDirty){let e=It(this,"arrangedContent");this._length=e?It(e,"length"):0,this._lengthDirty=!1}return Ce(this._lengthTag),this._length}set length(e){let t,a=this.length-e;if(0===a)return;a<0&&(t=new Array(-a),a=0);let n=It(this,"content");n&&(Wt(n,e,a,t),this._invalidate())}_updateArrangedContentArray(e){let t=null===this._objects?0:this._objects.length,a=e?It(e,"length"):0;this._removeArrangedContentArrayObserver(),Aa(this,0,t,a),this._invalidate(),ra(this,0,t,a,!1),this._addArrangedContentArrayObserver(e)}_addArrangedContentArrayObserver(e){e&&!e.isDestroyed&&(st(e,this,Qa),this._arrangedContent=e)}_removeArrangedContentArrayObserver(){this._arrangedContent&&ct(this._arrangedContent,this,Qa)}_arrangedContentArrayWillChange(){}_arrangedContentArrayDidChange(e,t,a,n){Aa(this,t,a,n);let s=t;s<0&&(s+=It(this._arrangedContent,"length")+a-n),(-1===this._objectsDirtyIndex||this._objectsDirtyIndex>s)&&(this._objectsDirtyIndex=s),this._lengthDirty=!0,ra(this,t,a,n,!1)}_invalidate(){this._objectsDirtyIndex=0,this._lengthDirty=!0}_revalidate(){if(!0!==this._arrangedContentIsUpdating&&(null===this._arrangedContentTag||!Za(this._arrangedContentTag,this._arrangedContentRevision))){let e=this.get("arrangedContent");null===this._arrangedContentTag?this._addArrangedContentArrayObserver(e):(this._arrangedContentIsUpdating=!0,this._updateArrangedContentArray(e),this._arrangedContentIsUpdating=!1);let t=this._arrangedContentTag=F(this,"arrangedContent");this._arrangedContentRevision=g(this._arrangedContentTag),T(e)?(this._lengthTag=Z([t,ve(e,"length")]),this._arrTag=Z([t,ve(e,"[]")])):this._lengthTag=this._arrTag=t}}};tn.reopen(Jt,{arrangedContent:Sa("content")});var an=Je({Meta:()=>S,UNDEFINED:()=>$,counters:()=>ua,meta:()=>U,peekMeta:()=>ze,setMeta:()=>Ye}),nn=Je({ActionHandler:()=>l,Comparable:()=>vt,ContainerProxyMixin:()=>_t,MutableEnumerable:()=>Qe,RSVP:()=>k,RegistryProxyMixin:()=>Ea,TargetActionSupport:()=>ja,_ProxyMixin:()=>O,_contentFor:()=>B,onerrorLine truncated
|
||||
+1
-1
@@ -42,7 +42,7 @@
|
||||
<meta name="msapplication-TileColor" content="#F6E9A6">
|
||||
<meta name="msapplication-TileImage" content="/icons/icon-144.png">
|
||||
|
||||
<script type="module" crossorigin src="/assets/main-B-1wPM4A.js"></script>
|
||||
<script type="module" crossorigin src="/assets/main-BD5lfqyM.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/main-D1ODG1Dj.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Executable
+93
@@ -0,0 +1,93 @@
|
||||
# Shared configuration for Marco's Nostr publishing scripts.
|
||||
#
|
||||
# Sourced (not executed) by:
|
||||
# scripts/publish-app-handler.sh
|
||||
# scripts/publish-app-recommendation.sh
|
||||
# scripts/publish-nip.sh
|
||||
#
|
||||
# Nothing here is secret. Signing is done through nak with an explicit signer
|
||||
# from the environment (nsec, hex, ncryptsec or a NIP-46 bunker:// URL).
|
||||
|
||||
# Prints an error and exits.
|
||||
die() {
|
||||
echo "error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Relays every script publishes to. Edit scripts/nostr-relays.txt (one URL per
|
||||
# line) instead of this file. An explicitly set NOSTR_RELAYS overrides it.
|
||||
if [ -z "${NOSTR_RELAYS:-}" ]; then
|
||||
RELAYS_FILE="${NOSTR_RELAYS_FILE:-$(dirname "$0")/nostr-relays.txt}"
|
||||
[ -f "$RELAYS_FILE" ] || die "relay list not found: $RELAYS_FILE (create it or set NOSTR_RELAYS)"
|
||||
NOSTR_RELAYS=$(
|
||||
tr -d '\r' <"$RELAYS_FILE" |
|
||||
sed -e 's/#.*//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d' |
|
||||
tr '\n' ' '
|
||||
)
|
||||
NOSTR_RELAYS=${NOSTR_RELAYS% }
|
||||
[ -n "$NOSTR_RELAYS" ] || die "no relays found in $RELAYS_FILE"
|
||||
fi
|
||||
|
||||
# Hex pubkey that signs and therefore owns Marco's NIP-89 app handler
|
||||
# (kind 31990). This is the author's own npub (the same identity that authors
|
||||
# the NIP specs), so the handler appears under a real Nostr identity rather
|
||||
# than a separate app key. The scripts refuse to publish from any other key.
|
||||
MARCO_APP_PUBKEY="1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb"
|
||||
|
||||
# The previous dedicated "Marco app" key. Its handler (same `d`) is a separate
|
||||
# addressable coordinate that must be deleted explicitly with
|
||||
# scripts/unpublish-app-handler.sh. Safe to remove once it is gone.
|
||||
MARCO_OLD_APP_PUBKEY="72424a5bdb8b3e6bcb2731643d43b26f3e3750ae61e5d601719aabd12ee94316"
|
||||
|
||||
# "d" identifier of Marco's NIP-89 app handler (kind 31990).
|
||||
MARCO_APP_D="marco.earth"
|
||||
|
||||
# App metadata advertised in the handler:
|
||||
# - NIP-05 identifier (goes into `content.nip05`)
|
||||
# - category tags, one `["t", <tag>]` each (NostrHub shows these as
|
||||
# hashtags/categories)
|
||||
# - git repo reference: a kind-30617 `a` tag plus a relay hint
|
||||
MARCO_APP_NIP05="marco@kosmos.org"
|
||||
MARCO_APP_TAGS="maps"
|
||||
MARCO_APP_REPO="30617:1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb:marco"
|
||||
MARCO_APP_REPO_RELAY="wss://relay.ngit.dev"
|
||||
|
||||
# Author of the published NIP specs (kind 30817, "NIPs on Nostr"). A published
|
||||
# spec can only be updated by this key; publishing from another key would fork
|
||||
# the spec instead of replacing it, so the scripts guard against it.
|
||||
NIP_SPEC_PUBKEY="1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb"
|
||||
|
||||
# Official NIPs Marco implements, advertised in the app handler (kind 31990) as
|
||||
# NIP references so directories like NostrHub can list them. Space separated
|
||||
# two-character identifiers (B7 is Blossom). See doc/nostr/nip-89-app-handler.md.
|
||||
MARCO_NIPS="01 07 09 19 21 46 57 65 73 89 92 B7"
|
||||
|
||||
# "d" identifier of Marco's own published NIP (kind 30817): Place Photos and
|
||||
# Videos. The app handler references it via its `a` address.
|
||||
MARCO_NIP_PHOTOS_D="place-photos-and-videos"
|
||||
|
||||
# Relay hint for the custom NIP reference.
|
||||
MARCO_NIP_RELAY="wss://nostr.kosmos.org"
|
||||
|
||||
# Requires an explicit signer so we never silently fall back to nak's machine
|
||||
# default key. Exports NAK_SEC for the nak calls.
|
||||
require_signer() {
|
||||
command -v nak >/dev/null 2>&1 || die "nak is not installed (https://github.com/fiatjaf/nak)"
|
||||
[ -n "${NOSTR_SECRET_KEY:-}" ] || die "set NOSTR_SECRET_KEY (nsec, hex, ncryptsec or bunker://...) first"
|
||||
NAK_SEC="$NOSTR_SECRET_KEY"
|
||||
export NAK_SEC
|
||||
}
|
||||
|
||||
# Reads a signed event (nak prints compact, single-line JSON) on stdin and
|
||||
# prints its pubkey.
|
||||
event_pubkey() {
|
||||
sed -n 's/.*"pubkey":"\([0-9a-f]\{64\}\)".*/\1/p'
|
||||
}
|
||||
|
||||
# Refuses to continue when the signer is not the expected identity.
|
||||
# $1 expected pubkey ("" skips the check), $2 actual pubkey.
|
||||
assert_pubkey() {
|
||||
if [ -n "$1" ] && [ "$2" != "$1" ]; then
|
||||
die "signer is $2, expected $1 — wrong key for this event"
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
# Relays every Nostr publish script sends to.
|
||||
#
|
||||
# One WebSocket URL per line. Blank lines and everything after a "#" are
|
||||
# ignored. Edit this file to change where Marco publishes its NIP-89 app
|
||||
# handler, recommendations and kind-30817 specs.
|
||||
#
|
||||
# Read by scripts/nostr-common.sh into NOSTR_RELAYS. Set the NOSTR_RELAYS
|
||||
# environment variable to override this file entirely.
|
||||
|
||||
# Marco's home relay
|
||||
wss://nostr.kosmos.org
|
||||
|
||||
# Relays used by the Ditto/NostrHub clients
|
||||
wss://relay.ditto.pub
|
||||
wss://relay.dreamith.to
|
||||
|
||||
# General public relays
|
||||
wss://nos.lol
|
||||
wss://relay.primal.net
|
||||
wss://relay.nostr.band
|
||||
wss://relay.snort.social
|
||||
wss://relay.damus.io
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Publish (or re-publish) Marco's NIP-89 app handler (kind 31990).
|
||||
#
|
||||
# Kind 31990 is addressable, so re-running this replaces the previous event
|
||||
# (same author + "d" tag). See doc/nostr/nip-89-app-handler.md.
|
||||
#
|
||||
# Usage:
|
||||
# NOSTR_SECRET_KEY='bunker://...' ./scripts/publish-app-handler.sh [--dry-run]
|
||||
#
|
||||
set -eu
|
||||
|
||||
. "$(dirname "$0")/nostr-common.sh"
|
||||
|
||||
DRY_RUN=0
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--dry-run) DRY_RUN=1 ;;
|
||||
*) die "unknown argument: $arg" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
require_signer
|
||||
|
||||
APP_ORIGIN="https://marco.earth"
|
||||
APP_CONTENT="{\"name\":\"Marco\",\"about\":\"Unhosted maps app, enhancing OpenStreetMap with decentralized user data and content\",\"picture\":\"$APP_ORIGIN/icons/icon-192.png\",\"website\":\"$APP_ORIGIN\",\"nip05\":\"$MARCO_APP_NIP05\"}"
|
||||
NIP_URL_PREFIX="https://github.com/nostr-protocol/nips/blob/master"
|
||||
|
||||
# "k" tags list every kind this app handles; add k=30360 when place reviews
|
||||
# ship. Clients replace <bech32> with a NIP-19 nevent before opening the URL;
|
||||
# the /e/<nevent> route is implemented in Marco (see the doc).
|
||||
#
|
||||
# "i" tags advertise the official NIPs Marco implements and an "a" tag points
|
||||
# at Marco's own kind-30817 NIP. These are the shapes NostrHub's app directory
|
||||
# reads (see doc/nostr/nip-89-app-handler.md).
|
||||
set -- nak event --sec "$NAK_SEC" -k 31990 \
|
||||
-d "$MARCO_APP_D" \
|
||||
-t k=360 \
|
||||
-t "web=$APP_ORIGIN/e/<bech32>;nevent" \
|
||||
-c "$APP_CONTENT"
|
||||
|
||||
for nip in $MARCO_NIPS; do
|
||||
set -- "$@" -t "i=$NIP_URL_PREFIX/$nip.md"
|
||||
done
|
||||
|
||||
set -- "$@" -t "a=30817:$NIP_SPEC_PUBKEY:$MARCO_NIP_PHOTOS_D;$MARCO_NIP_RELAY;nip"
|
||||
|
||||
# Category tags (NostrHub shows these as hashtags/categories).
|
||||
for tag in $MARCO_APP_TAGS; do
|
||||
set -- "$@" -t "t=$tag"
|
||||
done
|
||||
|
||||
# Git repo (ngit) reference: kind-30617 address plus relay hint.
|
||||
set -- "$@" -t "a=$MARCO_APP_REPO;$MARCO_APP_REPO_RELAY"
|
||||
|
||||
event=$("$@")
|
||||
|
||||
pubkey=$(printf '%s\n' "$event" | event_pubkey)
|
||||
[ -n "$pubkey" ] || die "could not read pubkey from the signed event"
|
||||
assert_pubkey "$MARCO_APP_PUBKEY" "$pubkey"
|
||||
|
||||
if [ "$DRY_RUN" = 1 ]; then
|
||||
printf '%s\n' "$event"
|
||||
echo "dry run: signed by $pubkey, not published" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf '%s\n' "$event" | nak event $NOSTR_RELAYS
|
||||
|
||||
echo "published app handler (kind 31990) as $pubkey"
|
||||
if [ -z "$MARCO_APP_PUBKEY" ]; then
|
||||
echo "record MARCO_APP_PUBKEY=$pubkey in scripts/nostr-common.sh" >&2
|
||||
fi
|
||||
naddr=$(nak encode naddr -k 31990 -a "$pubkey" -d "$MARCO_APP_D" 2>/dev/null || true)
|
||||
if [ -n "$naddr" ]; then
|
||||
echo "naddr: $naddr"
|
||||
fi
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Publish (or re-publish) a NIP-89 recommendation (kind 31989) pointing at
|
||||
# Marco's app handler. Signed by a *user* key (your own), not the app key.
|
||||
#
|
||||
# Kind 31989 is addressable per (author, "d" = supported kind), so re-running
|
||||
# replaces your previous recommendation for that kind.
|
||||
#
|
||||
# Usage:
|
||||
# NOSTR_SECRET_KEY='...' ./scripts/publish-app-recommendation.sh [kind] [--dry-run]
|
||||
#
|
||||
# kind defaults to 360 (place photos); pass 30360 once place reviews ship.
|
||||
#
|
||||
set -eu
|
||||
|
||||
. "$(dirname "$0")/nostr-common.sh"
|
||||
|
||||
DRY_RUN=0
|
||||
RECOMMEND_KIND=360
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--dry-run) DRY_RUN=1 ;;
|
||||
*[!0-9]*) die "unknown argument: $arg" ;;
|
||||
*) RECOMMEND_KIND="$arg" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$MARCO_APP_PUBKEY" ] || die "set MARCO_APP_PUBKEY in scripts/nostr-common.sh (run publish-app-handler.sh first)"
|
||||
require_signer
|
||||
|
||||
# One "a" tag per relay hint, so clients can find the handler either way.
|
||||
event=$(
|
||||
nak event --sec "$NAK_SEC" -k 31989 \
|
||||
-d "$RECOMMEND_KIND" \
|
||||
-t "a=31990:$MARCO_APP_PUBKEY:$MARCO_APP_D;wss://nostr.kosmos.org;web" \
|
||||
-t "a=31990:$MARCO_APP_PUBKEY:$MARCO_APP_D;wss://relay.primal.net;web"
|
||||
)
|
||||
|
||||
pubkey=$(printf '%s\n' "$event" | event_pubkey)
|
||||
[ -n "$pubkey" ] || die "could not read pubkey from the signed event"
|
||||
|
||||
if [ "$DRY_RUN" = 1 ]; then
|
||||
printf '%s\n' "$event"
|
||||
echo "dry run: signed by $pubkey, not published" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf '%s\n' "$event" | nak event $NOSTR_RELAYS
|
||||
|
||||
echo "published recommendation (kind 31989, kind $RECOMMEND_KIND) as $pubkey"
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Publish (or re-publish) one of Marco's NIPs as a kind 30817 "Custom NIP"
|
||||
# ("NIPs on Nostr"). Kind 30817 is addressable, so re-running replaces the
|
||||
# previous version (same author + "d" tag); the spec is updated, not forked.
|
||||
#
|
||||
# See doc/nostr/publishing.md.
|
||||
#
|
||||
# Usage:
|
||||
# NOSTR_SECRET_KEY='...' ./scripts/publish-nip.sh [photos|reviews] [--dry-run]
|
||||
#
|
||||
set -eu
|
||||
|
||||
. "$(dirname "$0")/nostr-common.sh"
|
||||
|
||||
DRY_RUN=0
|
||||
WHICH=photos
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--dry-run) DRY_RUN=1 ;;
|
||||
photos | reviews) WHICH="$arg" ;;
|
||||
*) die "unknown argument: $arg" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
case "$WHICH" in
|
||||
photos)
|
||||
NIP_PATH="doc/nostr/nip-place-photos.md"
|
||||
NIP_D="place-photos-and-videos"
|
||||
NIP_TITLE="Place Photos and Videos"
|
||||
NIP_KIND="360"
|
||||
;;
|
||||
reviews)
|
||||
NIP_PATH="doc/nostr/nip-place-reviews.md"
|
||||
NIP_D="place-reviews"
|
||||
NIP_TITLE="Place Reviews"
|
||||
NIP_KIND="30360"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Allow running from anywhere: resolve paths against the repo root.
|
||||
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
NIP_FILE="$root/$NIP_PATH"
|
||||
[ -f "$NIP_FILE" ] || die "spec not found: $NIP_FILE"
|
||||
|
||||
require_signer
|
||||
|
||||
# "status" is NostrHub metadata; the spec-defined tags are d/title/k (see
|
||||
# doc/nostr/publishing.md). The "client" tag is deliberately not set.
|
||||
event=$(
|
||||
nak event --sec "$NAK_SEC" -k 30817 \
|
||||
-d "$NIP_D" \
|
||||
-t "title=$NIP_TITLE" \
|
||||
-t "alt=Nostr Implementation Possibility: $NIP_TITLE" \
|
||||
-t "k=$NIP_KIND;$NIP_TITLE" \
|
||||
-t "status=review" \
|
||||
-c "@$NIP_FILE"
|
||||
)
|
||||
|
||||
pubkey=$(printf '%s\n' "$event" | event_pubkey)
|
||||
[ -n "$pubkey" ] || die "could not read pubkey from the signed event"
|
||||
assert_pubkey "$NIP_SPEC_PUBKEY" "$pubkey"
|
||||
|
||||
if [ "$DRY_RUN" = 1 ]; then
|
||||
printf '%s\n' "$event"
|
||||
echo "dry run: signed by $pubkey, not published" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf '%s\n' "$event" | nak event $NOSTR_RELAYS
|
||||
|
||||
echo "published NIP '$NIP_TITLE' (kind 30817) as $pubkey"
|
||||
naddr=$(nak encode naddr -k 30817 -a "$pubkey" -d "$NIP_D" 2>/dev/null || true)
|
||||
if [ -n "$naddr" ]; then
|
||||
echo "naddr: $naddr"
|
||||
fi
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Delete (unpublish) a NIP-89 app handler (kind 31990) by publishing a NIP-09
|
||||
# kind-5 deletion for its addressable coordinate. Only the handler's own author
|
||||
# key can delete it, so NOSTR_SECRET_KEY must be the key that signed it.
|
||||
#
|
||||
# Used to retire Marco's old handler after moving it to the author's own npub.
|
||||
#
|
||||
# Usage:
|
||||
# NOSTR_SECRET_KEY='<old app key>' ./scripts/unpublish-app-handler.sh [<pubkey>] [--dry-run]
|
||||
#
|
||||
# <pubkey> defaults to MARCO_OLD_APP_PUBKEY in scripts/nostr-common.sh.
|
||||
#
|
||||
set -eu
|
||||
|
||||
. "$(dirname "$0")/nostr-common.sh"
|
||||
|
||||
DRY_RUN=0
|
||||
TARGET_PUBKEY="$MARCO_OLD_APP_PUBKEY"
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--dry-run) DRY_RUN=1 ;;
|
||||
*[!0-9a-fA-F]* | '') die "invalid pubkey: $arg" ;;
|
||||
*) TARGET_PUBKEY="$arg" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -n "$TARGET_PUBKEY" ] || die "no pubkey to unpublish (set MARCO_OLD_APP_PUBKEY or pass one)"
|
||||
TARGET_PUBKEY=$(printf '%s' "$TARGET_PUBKEY" | tr 'A-F' 'a-f')
|
||||
|
||||
# Addressable handler coordinate, e.g. 31990:<pubkey>:marco.earth
|
||||
address="31990:$TARGET_PUBKEY:$MARCO_APP_D"
|
||||
|
||||
require_signer
|
||||
|
||||
# NIP-09: a parameterized replaceable event is deleted with an `a` tag pointing
|
||||
# at its coordinate (the `k` tag names the kind being deleted).
|
||||
event=$(
|
||||
nak event --sec "$NAK_SEC" -k 5 \
|
||||
-t "a=$address" \
|
||||
-t k=31990 \
|
||||
-c ''
|
||||
)
|
||||
|
||||
pubkey=$(printf '%s\n' "$event" | event_pubkey)
|
||||
[ -n "$pubkey" ] || die "could not read pubkey from the signed event"
|
||||
assert_pubkey "$TARGET_PUBKEY" "$pubkey"
|
||||
|
||||
if [ "$DRY_RUN" = 1 ]; then
|
||||
printf '%s\n' "$event"
|
||||
echo "dry run: deletion signed by $pubkey, not published" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf '%s\n' "$event" | nak event $NOSTR_RELAYS
|
||||
|
||||
echo "published deletion for $address as $pubkey"
|
||||
@@ -109,4 +109,49 @@ module('Integration | Component | photo-carousel', function (hooks) {
|
||||
|
||||
assert.ok(true, 'clicking next button does not throw');
|
||||
});
|
||||
|
||||
test('it marks the deep-linked photo as active', async function (assert) {
|
||||
this.photos = [
|
||||
{
|
||||
eventId: 'event-1',
|
||||
url: 'photo1.jpg',
|
||||
thumbUrl: 'thumb1.jpg',
|
||||
isLandscape: true,
|
||||
},
|
||||
{
|
||||
eventId: 'event-2',
|
||||
url: 'photo2.jpg',
|
||||
thumbUrl: 'thumb2.jpg',
|
||||
isLandscape: true,
|
||||
},
|
||||
{
|
||||
eventId: 'event-3',
|
||||
url: 'photo3.jpg',
|
||||
thumbUrl: 'thumb3.jpg',
|
||||
isLandscape: true,
|
||||
},
|
||||
];
|
||||
this.focusEventId = 'event-2';
|
||||
|
||||
await render(
|
||||
<template>
|
||||
<div class="test-container">
|
||||
<PhotoCarousel
|
||||
@photos={{this.photos}}
|
||||
@scrollToEventId={{this.focusEventId}}
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
);
|
||||
|
||||
assert
|
||||
.dom('[data-event-id="event-2"]')
|
||||
.hasClass('active', 'the deep-linked photo is marked active');
|
||||
assert
|
||||
.dom('[data-event-id="event-1"]')
|
||||
.doesNotHaveClass('active', 'other photos stay inactive');
|
||||
assert
|
||||
.dom('[data-event-id="event-3"]')
|
||||
.doesNotHaveClass('active', 'other photos stay inactive');
|
||||
});
|
||||
});
|
||||
@@ -806,4 +806,43 @@ module('Integration | Component | place-details', function (hooks) {
|
||||
assert.dom('.place-lists-manager').exists();
|
||||
assert.dom('.place-lists-manager .edit-item').doesNotExist();
|
||||
});
|
||||
|
||||
test('it focuses a deep-linked photo from the photo query param', async function (assert) {
|
||||
class NostrDataStub extends Service {
|
||||
placePhotos = [
|
||||
{
|
||||
id: 'event-2',
|
||||
pubkey: 'a'.repeat(64),
|
||||
kind: 360,
|
||||
created_at: 1,
|
||||
tags: [
|
||||
['i', 'osm:node:1'],
|
||||
['imeta', 'url https://example.com/a.jpg', 'dim 800x600'],
|
||||
],
|
||||
},
|
||||
];
|
||||
untrustedContentCount = 0;
|
||||
showUntrustedContent = false;
|
||||
toggleShowUntrustedContent() {}
|
||||
}
|
||||
|
||||
class MockRouter extends Service {
|
||||
currentRoute = { queryParams: { photo: 'event-2' } };
|
||||
transitionTo() {}
|
||||
urlFor() {
|
||||
return '/place/osm:node:1';
|
||||
}
|
||||
}
|
||||
|
||||
this.owner.register('service:nostr-data', NostrDataStub);
|
||||
this.owner.register('service:router', MockRouter);
|
||||
|
||||
const place = { title: 'Test Place', osmId: '1', osmType: 'node' };
|
||||
|
||||
await render(<template><PlaceDetails @place={{place}} /></template>);
|
||||
|
||||
assert
|
||||
.dom('.carousel-slide[data-event-id="event-2"]')
|
||||
.hasClass('active', 'the deep-linked photo is focused');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,108 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'marco/tests/helpers';
|
||||
import Service from '@ember/service';
|
||||
|
||||
const EVENT_ID =
|
||||
'1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb';
|
||||
|
||||
module('Unit | Route | event', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
// Registers stubs for `nostr-data` (returns `event`), `toast` (records the
|
||||
// last message) and `router` (records the last replaceWith target).
|
||||
function setupStubs(owner, { event = null, onToast } = {}) {
|
||||
let loadCalled = false;
|
||||
let redirect = null;
|
||||
|
||||
class NostrDataStub extends Service {
|
||||
async loadEventByPointer() {
|
||||
loadCalled = true;
|
||||
return event;
|
||||
}
|
||||
}
|
||||
|
||||
class ToastStub extends Service {
|
||||
show(message) {
|
||||
onToast?.(message);
|
||||
}
|
||||
}
|
||||
|
||||
class RouterStub extends Service {
|
||||
replaceWith(name, arg, options) {
|
||||
redirect = { name, arg, options };
|
||||
}
|
||||
}
|
||||
|
||||
owner.register('service:nostr-data', NostrDataStub);
|
||||
owner.register('service:toast', ToastStub);
|
||||
owner.register('service:router', RouterStub);
|
||||
|
||||
return {
|
||||
wasLoaded: () => loadCalled,
|
||||
getRedirect: () => redirect,
|
||||
};
|
||||
}
|
||||
|
||||
test('it exists', function (assert) {
|
||||
assert.ok(this.owner.lookup('route:event'));
|
||||
});
|
||||
|
||||
test('redirects to the place of a photo event', async function (assert) {
|
||||
const stubs = setupStubs(this.owner, {
|
||||
event: { id: EVENT_ID, kind: 360, tags: [['i', 'osm:node:123']] },
|
||||
});
|
||||
|
||||
const route = this.owner.lookup('route:event');
|
||||
const model = await route.model({ event_id: EVENT_ID });
|
||||
assert.strictEqual(model.placeId, 'osm:node:123');
|
||||
|
||||
route.redirect(model);
|
||||
assert.deepEqual(stubs.getRedirect(), {
|
||||
name: 'place',
|
||||
arg: 'osm:node:123',
|
||||
options: { queryParams: { photo: EVENT_ID } },
|
||||
});
|
||||
});
|
||||
|
||||
test('toasts and returns to the map when the event has no place', async function (assert) {
|
||||
let toastMessage;
|
||||
const stubs = setupStubs(this.owner, {
|
||||
event: { kind: 1, tags: [] },
|
||||
onToast: (message) => (toastMessage = message),
|
||||
});
|
||||
|
||||
const route = this.owner.lookup('route:event');
|
||||
const model = await route.model({ event_id: EVENT_ID });
|
||||
assert.ok(model.error, 'model carries an error');
|
||||
|
||||
route.redirect(model);
|
||||
assert.strictEqual(stubs.getRedirect().name, 'index');
|
||||
assert.ok(toastMessage, 'a toast was shown');
|
||||
});
|
||||
|
||||
test('toasts and returns to the map when the event is not found', async function (assert) {
|
||||
let toastMessage;
|
||||
const stubs = setupStubs(this.owner, {
|
||||
event: null,
|
||||
onToast: (message) => (toastMessage = message),
|
||||
});
|
||||
|
||||
const route = this.owner.lookup('route:event');
|
||||
const model = await route.model({ event_id: EVENT_ID });
|
||||
assert.ok(model.error, 'model carries an error');
|
||||
|
||||
route.redirect(model);
|
||||
assert.strictEqual(stubs.getRedirect().name, 'index');
|
||||
assert.ok(toastMessage, 'a toast was shown');
|
||||
});
|
||||
|
||||
test('rejects invalid references without loading an event', async function (assert) {
|
||||
const stubs = setupStubs(this.owner, { event: null });
|
||||
|
||||
const route = this.owner.lookup('route:event');
|
||||
const model = await route.model({ event_id: 'not-a-pointer' });
|
||||
|
||||
assert.ok(model.error, 'model carries an error');
|
||||
assert.notOk(stubs.wasLoaded(), 'loadEventByPointer was not called');
|
||||
});
|
||||
});
|
||||
@@ -1134,6 +1134,80 @@ module('Unit | Service | nostr-data | place photos', function (hooks) {
|
||||
);
|
||||
assert.strictEqual(service.untrustedContentCount, 0);
|
||||
});
|
||||
|
||||
test('keeps streaming place photos after a relay EOSEs', async function (assert) {
|
||||
const service = this.owner.lookup('service:nostr-data');
|
||||
const pk = makePubkey(90);
|
||||
const slowId = makeEventId(904);
|
||||
|
||||
await service.loadPhotosForPlace({ osmId: '902', osmType: 'node' });
|
||||
|
||||
// The submission relay answers first (EOSE). A one-shot request with
|
||||
// `completeOnAllEose()` would complete here and drop the slower relay.
|
||||
this.reqMessages.next({
|
||||
type: 'EOSE',
|
||||
from: 'wss://submit.nostr.kosmos.org',
|
||||
});
|
||||
|
||||
// The trusted relay answers afterwards with the actual place photo.
|
||||
this.reqMessages.next({
|
||||
type: 'EVENT',
|
||||
from: 'wss://nostr.kosmos.org',
|
||||
event: makePhotoEvent(pk, 'osm:node:902', { id: slowId }),
|
||||
});
|
||||
|
||||
await wait(50);
|
||||
|
||||
assert.deepEqual(
|
||||
service.placePhotos.map((e) => e.id),
|
||||
[slowId],
|
||||
'photo from the slower relay is shown'
|
||||
);
|
||||
});
|
||||
|
||||
test('keeps the live place photo subscription for the same place', async function (assert) {
|
||||
const service = this.owner.lookup('service:nostr-data');
|
||||
|
||||
await service.loadPhotosForPlace({ osmId: '903', osmType: 'node' });
|
||||
const first = service._photosNetworkSub;
|
||||
|
||||
await service.loadPhotosForPlace({ osmId: '903', osmType: 'node' });
|
||||
|
||||
assert.strictEqual(
|
||||
service._photosNetworkSub,
|
||||
first,
|
||||
'same live subscription retained'
|
||||
);
|
||||
assert.notOk(first.closed, 'it is still open');
|
||||
});
|
||||
|
||||
test('closes the live place photo subscription when switching places', async function (assert) {
|
||||
const service = this.owner.lookup('service:nostr-data');
|
||||
|
||||
await service.loadPhotosForPlace({ osmId: '903', osmType: 'node' });
|
||||
const first = service._photosNetworkSub;
|
||||
|
||||
await service.loadPhotosForPlace({ osmId: '904', osmType: 'node' });
|
||||
|
||||
assert.ok(first.closed, 'previous live subscription closed');
|
||||
assert.notStrictEqual(
|
||||
service._photosNetworkSub,
|
||||
first,
|
||||
'a new live subscription was opened'
|
||||
);
|
||||
});
|
||||
|
||||
test('closes the live place photo subscription for a null place', async function (assert) {
|
||||
const service = this.owner.lookup('service:nostr-data');
|
||||
|
||||
await service.loadPhotosForPlace({ osmId: '905', osmType: 'node' });
|
||||
const sub = service._photosNetworkSub;
|
||||
|
||||
await service.loadPhotosForPlace(null);
|
||||
|
||||
assert.ok(sub.closed, 'live subscription closed');
|
||||
assert.strictEqual(service._photosNetworkSub, null);
|
||||
});
|
||||
});
|
||||
|
||||
module('Unit | Service | nostr-data | my contributions', function (hooks) {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { EventFactory } from 'applesauce-core';
|
||||
import {
|
||||
MARCO_CLIENT_NAME,
|
||||
MARCO_HANDLER_POINTER,
|
||||
withMarcoClientTag,
|
||||
} from 'marco/utils/client-tag';
|
||||
|
||||
module('Unit | Utility | client-tag', function () {
|
||||
test('exposes the Marco name and handler pointer', function (assert) {
|
||||
assert.strictEqual(MARCO_CLIENT_NAME, 'Marco');
|
||||
assert.deepEqual(MARCO_HANDLER_POINTER, {
|
||||
pubkey:
|
||||
'1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb',
|
||||
identifier: 'marco.earth',
|
||||
relays: ['wss://nostr.kosmos.org'],
|
||||
});
|
||||
});
|
||||
|
||||
test('adds the NIP-89 client tag to an event', async function (assert) {
|
||||
const template = await withMarcoClientTag(EventFactory.fromKind(360));
|
||||
|
||||
assert.deepEqual(
|
||||
template.tags.find((tag) => tag[0] === 'client'),
|
||||
[
|
||||
'client',
|
||||
'Marco',
|
||||
'31990:1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb:marco.earth',
|
||||
'wss://nostr.kosmos.org/',
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
test('does not add the client tag to direct-message kinds', async function (assert) {
|
||||
const template = await withMarcoClientTag(EventFactory.fromKind(4));
|
||||
|
||||
assert.notOk(
|
||||
template.tags.find((tag) => tag[0] === 'client'),
|
||||
'no client tag on a kind 4 event'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,9 @@ import {
|
||||
excludeRequiredRelays,
|
||||
mergeRequiredRelays,
|
||||
normalizeRelayUrl,
|
||||
parseNostrEventReference,
|
||||
parsePlacePhotos,
|
||||
placeIdentifierFromEvent,
|
||||
relayUrlMatches,
|
||||
uniqNormalizedRelays,
|
||||
} from 'marco/utils/nostr';
|
||||
@@ -427,4 +429,121 @@ module('Unit | Utility | nostr', function () {
|
||||
'null trust list'
|
||||
);
|
||||
});
|
||||
|
||||
module('parseNostrEventReference', function () {
|
||||
const EVENT_ID =
|
||||
'1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb';
|
||||
const NOTE =
|
||||
'note1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89sazwyqc';
|
||||
const NEVENT =
|
||||
'nevent1qvzqqqqpdqpzq8meqkx80g3yuklzymy0qfx2ekk56aqc2ht4ak03z3em4r4cdcwtqyfhwumn8ghj7un9d3shjtn90psk6urvv5qzq8meqkx80g3yuklzymy0qfx2ekk56aqc2ht4ak03z3em4r4cdcwtzltwfa';
|
||||
const NEVENT_NOHINTS =
|
||||
'nevent1qqsp77g933m6yf89hc3xerczfjkd44xhgxz46a0dnug5wwagawrwrjcfq0qqc';
|
||||
const NADDR =
|
||||
'naddr1qvzqqqrknqpzq8meqkx80g3yuklzymy0qfx2ekk56aqc2ht4ak03z3em4r4cdcwtqyfhwumn8ghj7un9d3shjtn90psk6urvv5qqcmmnd5axummyv5arzv3najzpek';
|
||||
|
||||
test('parses a raw hex event id (case-insensitive)', function (assert) {
|
||||
assert.deepEqual(parseNostrEventReference(EVENT_ID), { id: EVENT_ID });
|
||||
assert.deepEqual(parseNostrEventReference(EVENT_ID.toUpperCase()), {
|
||||
id: EVENT_ID,
|
||||
});
|
||||
});
|
||||
|
||||
test('parses a note1 event id', function (assert) {
|
||||
assert.deepEqual(parseNostrEventReference(NOTE), { id: EVENT_ID });
|
||||
});
|
||||
|
||||
test('parses a nevent with relay hints, author and kind', function (assert) {
|
||||
const pointer = parseNostrEventReference(NEVENT);
|
||||
assert.strictEqual(pointer.id, EVENT_ID);
|
||||
assert.deepEqual(pointer.relays, ['wss://relay.example']);
|
||||
assert.strictEqual(pointer.author, EVENT_ID);
|
||||
assert.strictEqual(pointer.kind, 360);
|
||||
});
|
||||
|
||||
test('parses a nevent without hints', function (assert) {
|
||||
const pointer = parseNostrEventReference(NEVENT_NOHINTS);
|
||||
assert.strictEqual(pointer.id, EVENT_ID);
|
||||
assert.notOk(pointer.relays?.length);
|
||||
});
|
||||
|
||||
test('parses an naddr into an address pointer', function (assert) {
|
||||
const pointer = parseNostrEventReference(NADDR);
|
||||
assert.strictEqual(pointer.kind, 30360);
|
||||
assert.strictEqual(pointer.pubkey, EVENT_ID);
|
||||
assert.strictEqual(pointer.identifier, 'osm:node:123');
|
||||
assert.deepEqual(pointer.relays, ['wss://relay.example']);
|
||||
});
|
||||
|
||||
test('accepts a nostr: scheme prefix', function (assert) {
|
||||
assert.deepEqual(parseNostrEventReference(`nostr:${NOTE}`), {
|
||||
id: EVENT_ID,
|
||||
});
|
||||
});
|
||||
|
||||
test('extracts the reference from a permalink URL', function (assert) {
|
||||
assert.deepEqual(
|
||||
parseNostrEventReference(`https://njump.me/${NEVENT}`),
|
||||
parseNostrEventReference(NEVENT)
|
||||
);
|
||||
assert.deepEqual(
|
||||
parseNostrEventReference(`https://primal.net/e/${EVENT_ID}`),
|
||||
{ id: EVENT_ID }
|
||||
);
|
||||
});
|
||||
|
||||
test('parses a raw address coordinate', function (assert) {
|
||||
assert.deepEqual(
|
||||
parseNostrEventReference(`30360:${EVENT_ID}:osm:node:123`),
|
||||
{ kind: 30360, pubkey: EVENT_ID, identifier: 'osm:node:123' }
|
||||
);
|
||||
});
|
||||
|
||||
test('rejects unsupported input', function (assert) {
|
||||
assert.strictEqual(parseNostrEventReference(''), null);
|
||||
assert.strictEqual(parseNostrEventReference('not-a-pointer'), null);
|
||||
assert.strictEqual(
|
||||
parseNostrEventReference('naddr1qqqqqqqq'),
|
||||
null,
|
||||
'malformed naddr'
|
||||
);
|
||||
assert.strictEqual(parseNostrEventReference(null), null);
|
||||
assert.strictEqual(
|
||||
parseNostrEventReference('30360:nothex:osm:node:123'),
|
||||
null
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
module('placeIdentifierFromEvent', function () {
|
||||
test('returns the i tag place identifier', function (assert) {
|
||||
assert.strictEqual(
|
||||
placeIdentifierFromEvent({ tags: [['i', 'osm:node:123']] }),
|
||||
'osm:node:123'
|
||||
);
|
||||
assert.strictEqual(
|
||||
placeIdentifierFromEvent({
|
||||
tags: [
|
||||
['g', 'xn0'],
|
||||
['i', 'osm:way:9'],
|
||||
],
|
||||
}),
|
||||
'osm:way:9'
|
||||
);
|
||||
});
|
||||
|
||||
test('returns null without a valid OSM i tag', function (assert) {
|
||||
assert.strictEqual(placeIdentifierFromEvent({ tags: [] }), null);
|
||||
assert.strictEqual(
|
||||
placeIdentifierFromEvent({ tags: [['i', 'geo:1,2']] }),
|
||||
null
|
||||
);
|
||||
assert.strictEqual(
|
||||
placeIdentifierFromEvent({ tags: [['i', 'osm:foo:1']] }),
|
||||
null
|
||||
);
|
||||
assert.strictEqual(placeIdentifierFromEvent(null), null);
|
||||
assert.strictEqual(placeIdentifierFromEvent({}), null);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user