@ -105,13 +105,11 @@
< span class = "col-span-1 w-full flex justify-center" > { { zoneName } } < / span >
< / div >
< div class = "flex items-center mb-4" >
< input
type = "checkbox"
class = "mr-2"
v - model = "includeLocation"
< div
class = "flex items-center mb-4"
@ click = "includeLocation = !includeLocation"
/ >
>
< input type = "checkbox" class = "mr-2" v -model = " includeLocation " / >
< label for = "includeLocation" > Include Location < / label >
< / div >
< div v-if ="includeLocation" class="mb-4 aspect-video" >
@ -149,22 +147,12 @@
v - if = "showGeneralAdvanced && includeLocation"
class = "items-center mb-4"
>
< div class = "flex" >
< input
type = "checkbox"
class = "mr-2"
v - model = "sendToTrustroots"
@ click = "sendToTrustroots = !sendToTrustroots"
/ >
< div class = "flex" @ click = "sendToTrustroots = !sendToTrustroots" >
< input type = "checkbox" class = "mr-2" v -model = " sendToTrustroots " / >
< label > Send to Trustroots < / label >
< / div >
< div class = "flex" >
< input
type = "checkbox"
class = "mr-2"
v - model = "sendToTripHopping"
@ click = "sendToTripHopping = !sendToTripHopping"
/ >
< div class = "flex" @ click = "sendToTripHopping = !sendToTripHopping" >
< input type = "checkbox" class = "mr-2" v -model = " sendToTripHopping " / >
< label > Send to TripHopping < / label >
< / div >
< / div >
@ -202,7 +190,10 @@
import "leaflet/dist/leaflet.css" ;
import { AxiosError , AxiosRequestHeaders } from "axios" ;
import { DateTime } from "luxon" ;
import { hexToBytes } from "@noble/hashes/utils" ;
import type { EventTemplate , VerifiedEvent } from "nostr-tools/lib/types/core" ;
import { accountFromSeedWords } from "nostr-tools/nip06" ;
import { finalizeEvent , serializeEvent } from "nostr-tools/pure" ;
import { Component , Vue } from "vue-facing-decorator" ;
import { LMap , LMarker , LTileLayer } from "@vue-leaflet/vue-leaflet" ;
import { Router } from "vue-router" ;
@ -456,18 +447,25 @@ export default class NewEditProjectView extends Vue {
const projectPath = encodeURIComponent ( resp . data . success . handleId ) ;
let signedPayload : VerifiedEvent ; / / s i g n s o m e t h i n g t o p r o v e o w n e r s h i p o f p u b k e y
if ( this . sendToTrustroots ) {
signedPayload = await this . signPayload ( ) ;
this . sendToNostrPartner (
"NOSTR-EVENT-TRUSTROOTS" ,
"Trustroots" ,
resp . data . success . claimId ,
signedPayload ,
) ;
}
if ( this . sendToTripHopping ) {
if ( ! signedPayload ) {
signedPayload = await this . signPayload ( ) ;
}
this . sendToNostrPartner (
"NOSTR-EVENT-TRIPHOPPING" ,
"TripHopping" ,
resp . data . success . claimId ,
signedPayload ,
) ;
}
@ -535,10 +533,38 @@ export default class NewEditProjectView extends Vue {
}
}
private async signPayload ( ) : Promise < VerifiedEvent > {
const account = await getAccount ( this . activeDid ) ;
/ / g e t t h e l a s t n u m b e r o f t h e d e r i v a t i o n P a t h
const finalDerNum = account ? . derivationPath ? . split ? . ( "/" ) ? . reverse ( ) [ 0 ] ;
/ / r e m o v e a n y t r a i l i n g '
const finalDerNumNoApostrophe = finalDerNum ? . replace ( /'/g , "" ) ;
const accountNum = Number ( finalDerNumNoApostrophe || 0 ) ;
const pubPri = accountFromSeedWords (
account ? . mnemonic as string ,
"" ,
accountNum ,
) ;
const privateBytes = hexToBytes ( pubPri ? . privateKey ) ;
/ / N o r e a l c o n t e n t i s n e c e s s a r y , w e j u s t w a n t s o m e t h i n g s i g n e d ,
/ / s o w e m i g h t a s w e l l u s e n o s t r l i b s f o r n o s t r f u n c t i o n s .
/ / B e s i d e s : s o m e d a y w e m a y c r e a t e r e a l c o n t e n t t h a t w e c a n r e l a y .
const event : EventTemplate = {
kind : 30402 ,
tags : [ [ ] ] ,
content : "" ,
created_at : 0 ,
} ;
/ / W h y d o e s I n t e l l i J n o t s e e m a t c h i n g t y p e s ?
const signedEvent = finalizeEvent ( event , privateBytes ) ;
return signedEvent ;
}
private async sendToNostrPartner (
linkCode : string ,
serviceName : string ,
jwtId : string ,
signedPayload : VerifiedEvent ,
) {
/ / f i r s t , g e t t h e p u b l i c k e y f o r n o s t r
const account = await getAccount ( this . activeDid ) ;
@ -557,11 +583,15 @@ export default class NewEditProjectView extends Vue {
const trustrootsUrl = DEFAULT_PARTNER_API_SERVER + "/api/partner/link" ;
const timeSafariUrl = window . location . origin + "/claim/" + jwtId ;
const content = this . fullClaim . name + " - see " + timeSafariUrl ;
/ / W h y d o e s I n t e l l i J n o t s e e m a t c h i n g t y p e s ?
const payload = serializeEvent ( signedPayload ) ;
const trustrootsParams = {
jwtId : jwtId ,
linkCode : linkCode ,
inputJson : JSON . stringify ( content ) ,
nostrPubKeyHex : nostrPubKey ,
pubKeyHex : nostrPubKey ,
pubKeyImage : payload ,
pubKeySigHex : signedPayload . sig ,
} ;
const fullTrustrootsUrl = trustrootsUrl ;
const headers = await getHeaders ( this . activeDid ) ;