forked from jsnbuchanan/crowd-funder-for-time-pwa
add link directly into contact page to add a new contact via "contactJwt" query parameter
This commit is contained in:
@@ -299,6 +299,7 @@ import {
|
||||
} from "@/db/index";
|
||||
import { Contact } from "@/db/tables/contacts";
|
||||
import { getContactPayloadFromJwtUrl } from "@/libs/crypto";
|
||||
import { decodeEndorserJwt } from "@/libs/crypto/vc";
|
||||
import {
|
||||
CONTACT_CSV_HEADER,
|
||||
CONTACT_URL_PREFIX,
|
||||
@@ -307,6 +308,7 @@ import {
|
||||
isDid,
|
||||
register,
|
||||
setVisibilityUtil,
|
||||
UserInfo,
|
||||
} from "@/libs/endorserServer";
|
||||
import * as libsUtil from "@/libs/util";
|
||||
import QuickNav from "@/components/QuickNav.vue";
|
||||
@@ -374,6 +376,24 @@ export default class ContactsView extends Vue {
|
||||
this.contacts = baseContacts.sort((a, b) =>
|
||||
(a.name || "").localeCompare(b.name || ""),
|
||||
);
|
||||
|
||||
const importedContactJwt = (this.$route as Router).query[
|
||||
"contactJwt"
|
||||
] as string;
|
||||
if (importedContactJwt) {
|
||||
// really should fully verify
|
||||
const { payload } = decodeEndorserJwt(importedContactJwt);
|
||||
const userInfo = payload["own"] as UserInfo;
|
||||
const newContact = {
|
||||
did: payload["iss"],
|
||||
name: userInfo.name,
|
||||
nextPubKeyHashB64: userInfo.nextPublicEncKeyHash,
|
||||
profileImageUrl: userInfo.profileImageUrl,
|
||||
publicKeyBase64: userInfo.publicEncKey,
|
||||
registered: userInfo.registered,
|
||||
} as Contact;
|
||||
this.addContact(newContact);
|
||||
}
|
||||
}
|
||||
|
||||
private danger(message: string, title: string = "Error", timeout = 5000) {
|
||||
@@ -891,7 +911,10 @@ export default class ContactsView extends Vue {
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
console.error("Got strange result from setting visibility:", result);
|
||||
console.error(
|
||||
"Got strange result from setting visibility. It can happen when setting visibility on oneself.",
|
||||
result,
|
||||
);
|
||||
const message =
|
||||
(result.error as string) || "Could not set visibility on the server.";
|
||||
this.$notify(
|
||||
|
||||
Reference in New Issue
Block a user