forked from jsnbuchanan/crowd-funder-for-time-pwa
add correct encodings for public keys, plus some instructions for entering a contact
This commit is contained in:
@@ -144,6 +144,9 @@ import { accountsDB, db } from "@/db";
|
||||
import { Contact } from "@/db/tables/contacts";
|
||||
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const Buffer = require("buffer/").Buffer;
|
||||
|
||||
export interface GiveVerifiableCredential {
|
||||
"@context": string;
|
||||
"@type": string;
|
||||
@@ -196,6 +199,11 @@ export default class ContactsView extends Vue {
|
||||
publicKeyBase64 = this.contactInput.substring(commaPos2 + 1).trim();
|
||||
}
|
||||
}
|
||||
// help with potential mistakes while this sharing requires copy-and-paste
|
||||
if (publicKeyBase64 && /^[0-9A-Fa-f]{66}$/i.test(publicKeyBase64)) {
|
||||
// it must be all hex (compressed public key), so convert
|
||||
publicKeyBase64 = Buffer.from(publicKeyBase64, "hex").toString("base64");
|
||||
}
|
||||
const newContact = { did, name, publicKeyBase64 };
|
||||
await db.contacts.add(newContact);
|
||||
this.contacts = this.contacts.concat([newContact]);
|
||||
|
||||
Reference in New Issue
Block a user