|
@ -188,19 +188,21 @@ |
|
|
import "leaflet/dist/leaflet.css"; |
|
|
import "leaflet/dist/leaflet.css"; |
|
|
import { AxiosError, AxiosRequestHeaders } from "axios"; |
|
|
import { AxiosError, AxiosRequestHeaders } from "axios"; |
|
|
import { DateTime } from "luxon"; |
|
|
import { DateTime } from "luxon"; |
|
|
|
|
|
import { accountFromSeedWords } from "nostr-tools/nip06"; |
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
import { Component, Vue } from "vue-facing-decorator"; |
|
|
import { LMap, LMarker, LTileLayer } from "@vue-leaflet/vue-leaflet"; |
|
|
import { LMap, LMarker, LTileLayer } from "@vue-leaflet/vue-leaflet"; |
|
|
import { Router } from "vue-router"; |
|
|
import { Router } from "vue-router"; |
|
|
|
|
|
|
|
|
import ImageMethodDialog from "@/components/ImageMethodDialog.vue"; |
|
|
import ImageMethodDialog from "@/components/ImageMethodDialog.vue"; |
|
|
import QuickNav from "@/components/QuickNav.vue"; |
|
|
import QuickNav from "@/components/QuickNav.vue"; |
|
|
import { DEFAULT_IMAGE_API_SERVER, NotificationIface } from "@/constants/app"; |
|
|
import { DEFAULT_IMAGE_API_SERVER, DEFAULT_PARTNER_API_SERVER, NotificationIface } from "@/constants/app"; |
|
|
import { accountsDB, retrieveSettingsForActiveAccount } from "@/db/index"; |
|
|
import { accountsDB, retrieveSettingsForActiveAccount } from "@/db/index"; |
|
|
import { |
|
|
import { |
|
|
createEndorserJwtVcFromClaim, |
|
|
createEndorserJwtVcFromClaim, |
|
|
getHeaders, |
|
|
getHeaders, |
|
|
PlanVerifiableCredential, |
|
|
PlanVerifiableCredential, |
|
|
} from "@/libs/endorserServer"; |
|
|
} from "@/libs/endorserServer"; |
|
|
|
|
|
import { getAccount } from "@/libs/util"; |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
components: { ImageMethodDialog, LMap, LMarker, LTileLayer, QuickNav }, |
|
|
components: { ImageMethodDialog, LMap, LMarker, LTileLayer, QuickNav }, |
|
@ -431,36 +433,68 @@ export default class NewEditProjectView extends Vue { |
|
|
try { |
|
|
try { |
|
|
const resp = await this.axios.post(url, payload, { headers }); |
|
|
const resp = await this.axios.post(url, payload, { headers }); |
|
|
if (resp.data?.success?.handleId) { |
|
|
if (resp.data?.success?.handleId) { |
|
|
console.log("Saved project with data", resp.data.success); |
|
|
|
|
|
this.errorMessage = ""; |
|
|
this.errorMessage = ""; |
|
|
|
|
|
|
|
|
const projectPath = encodeURIComponent(resp.data.success.handleId); |
|
|
const projectPath = encodeURIComponent(resp.data.success.handleId); |
|
|
|
|
|
|
|
|
if (this.sendToTrustroots) { |
|
|
if (this.sendToTrustroots) { |
|
|
const trustrootsUrl = "http://localhost:3000/api/partner/link"; |
|
|
// first, get the public key for nostr |
|
|
|
|
|
const account = await getAccount(this.activeDid); |
|
|
|
|
|
// get the last number of the derivationPath |
|
|
|
|
|
const finalDerNum = account?.derivationPath?.split?.("/")?.reverse()[0]; |
|
|
|
|
|
// remove any trailing ' |
|
|
|
|
|
const finalDerNumNoApostrophe = finalDerNum?.replace(/'/g, ""); |
|
|
|
|
|
const accountNum = Number(finalDerNumNoApostrophe || 0); |
|
|
|
|
|
const pubPri = accountFromSeedWords(account?.mnemonic as string, "", accountNum); |
|
|
|
|
|
const nostrPubKey = pubPri?.publicKey; |
|
|
|
|
|
|
|
|
|
|
|
const trustrootsUrl = DEFAULT_PARTNER_API_SERVER + "/api/partner/link"; |
|
|
|
|
|
const timeSafariUrl = window.location.origin + "/claim/" + resp.data.success.claimId; |
|
|
|
|
|
const content = this.fullClaim.name + " - see " + timeSafariUrl; |
|
|
const trustrootsParams = new URLSearchParams({ |
|
|
const trustrootsParams = new URLSearchParams({ |
|
|
jwtId: resp.data.success.claimId, |
|
|
jwtId: resp.data.success.claimId, |
|
|
linkCode: "NOSTR-EVENT-TRUSTROOTS", |
|
|
linkCode: "NOSTR-EVENT-TRUSTROOTS", |
|
|
inputJson: JSON.stringify("localhost " + resp.data.success.claimId), |
|
|
inputJson: JSON.stringify(content), |
|
|
|
|
|
nostrPubKeyHex: nostrPubKey, |
|
|
}); |
|
|
}); |
|
|
const fullTrustrootsUrl = |
|
|
const fullTrustrootsUrl = trustrootsUrl + "?" + trustrootsParams.toString(); |
|
|
trustrootsUrl + "?" + trustrootsParams.toString(); |
|
|
|
|
|
const headers = await getHeaders(issuerDid); |
|
|
const headers = await getHeaders(issuerDid); |
|
|
try { |
|
|
try { |
|
|
const linkResp = await this.axios.post( |
|
|
const linkResp = await this.axios.post(fullTrustrootsUrl, {}, { headers }); |
|
|
fullTrustrootsUrl, |
|
|
if (linkResp.status === 201) { |
|
|
{}, |
|
|
this.$notify( |
|
|
{ headers }, |
|
|
{ |
|
|
); |
|
|
group: "alert", |
|
|
console.log("Sent to Trustroots with data!!!!", linkResp.data); |
|
|
type: "success", |
|
|
|
|
|
title: "Sent to Trustroots", |
|
|
|
|
|
text: "The project info was sent to Trustroots.", |
|
|
|
|
|
}, |
|
|
|
|
|
5000, |
|
|
|
|
|
); |
|
|
|
|
|
} else { |
|
|
|
|
|
// axios never gets here because it throws an error, but just in case |
|
|
|
|
|
this.$notify( |
|
|
|
|
|
{ |
|
|
|
|
|
group: "alert", |
|
|
|
|
|
type: "danger", |
|
|
|
|
|
title: "Failed Sending to Trustroots", |
|
|
|
|
|
text: JSON.stringify(linkResp.data), |
|
|
|
|
|
}, |
|
|
|
|
|
5000, |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.error("Error sending to Trustroots", error); |
|
|
console.error("Error sending to Trustroots", error); |
|
|
|
|
|
let errorMessage = "There was an error sending to Trustroots."; |
|
|
|
|
|
if (error.response?.data?.error?.message) { |
|
|
|
|
|
errorMessage = error.response.data.error.message; |
|
|
|
|
|
} |
|
|
this.$notify( |
|
|
this.$notify( |
|
|
{ |
|
|
{ |
|
|
group: "alert", |
|
|
group: "alert", |
|
|
type: "danger", |
|
|
type: "danger", |
|
|
title: "Error Sending to Trustroots", |
|
|
title: "Error Sending to Trustroots", |
|
|
text: "There was an error sending to Trustroots.", |
|
|
text: errorMessage, |
|
|
}, |
|
|
}, |
|
|
5000, |
|
|
5000, |
|
|
); |
|
|
); |
|
|