Browse Source

add next-public-key-hash to manual input

starred-projects
Trent Larson 9 months ago
parent
commit
aeb1d6a6a5
  1. 2
      project.task.yaml
  2. 2
      src/db/tables/contacts.ts
  3. 32
      src/views/ContactsView.vue

2
project.task.yaml

@ -8,13 +8,11 @@ tasks:
- look for "if is a new user" -- blank name
- copy button for seed
- explanation for contact icons
- .5 If notifications are not enabled, add message to front page with link/button to enable
- record donations vs gives
- make server endpoint for full English description of limits
- make identicons for contacts into more-memorable faces (and maybe change project identicons, too)
- .5 add next key hash to text input field
- 01 server - show all claim details when issued by the issuer
- bug - got error adding on Firefox user #0 as contact for themselves

2
src/db/tables/contacts.ts

@ -1,7 +1,7 @@
export interface Contact {
did: string;
name?: string;
nextPublicKeyHashBase64?: string; // base64-encoded SHA256 hash of next public key
nextPubKeyHashB64?: string; // base64-encoded SHA256 hash of next public key
publicKeyBase64?: string;
seesMe?: boolean;
registered?: boolean;

32
src/views/ContactsView.vue

@ -28,7 +28,7 @@
</router-link>
<input
type="text"
placeholder="DID, Name, Public Key (base 16 or 64)"
placeholder="DID, Name, Public Key, Next Public Key Hash"
class="block w-full rounded-l border border-r-0 border-slate-400 px-3 py-2"
v-model="contactInput"
/>
@ -109,9 +109,9 @@
<div class="text-sm truncate" v-if="contact.publicKeyBase64">
Public Key (base 64): {{ contact.publicKeyBase64 }}
</div>
<div class="text-sm truncate" v-if="contact.nextPublicKeyHashBase64">
<div class="text-sm truncate" v-if="contact.nextPubKeyHashB64">
Next Public Key Hash (base 64):
{{ contact.nextPublicKeyHashBase64 }}
{{ contact.nextPubKeyHashB64 }}
</div>
<div id="ContactActions" class="flex gap-1.5 mt-2">
@ -497,7 +497,7 @@ export default class ContactsView extends Vue {
}
let did = this.contactInput;
let name, publicKeyBase64;
let name, publicKeyInput, nextPublicKeyHashInput;
const commaPos1 = this.contactInput.indexOf(",");
if (commaPos1 > -1) {
did = this.contactInput.substring(0, commaPos1).trim();
@ -505,15 +505,31 @@ export default class ContactsView extends Vue {
const commaPos2 = this.contactInput.indexOf(",", commaPos1 + 1);
if (commaPos2 > -1) {
name = this.contactInput.substring(commaPos1 + 1, commaPos2).trim();
publicKeyBase64 = this.contactInput.substring(commaPos2 + 1).trim();
publicKeyInput = this.contactInput.substring(commaPos2 + 1).trim();
const commaPos3 = this.contactInput.indexOf(",", commaPos2 + 1);
if (commaPos3 > -1) {
publicKeyInput = this.contactInput.substring(commaPos2 + 1, commaPos3).trim(); // eslint-disable-line prettier/prettier
nextPublicKeyHashInput = this.contactInput.substring(commaPos3 + 1).trim(); // eslint-disable-line prettier/prettier
}
}
}
// help with potential mistakes while this sharing requires copy-and-paste
let publicKeyBase64 = publicKeyInput;
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 };
let nextPubKeyHashB64 = nextPublicKeyHashInput;
if (nextPubKeyHashB64 && /^[0-9A-Fa-f]{66}$/i.test(nextPubKeyHashB64)) {
// it must be all hex (compressed public key), so convert
nextPubKeyHashB64 = Buffer.from(nextPubKeyHashB64, "hex").toString("base64"); // eslint-disable-line prettier/prettier
}
const newContact = {
did,
name,
publicKeyBase64,
nextPubKeyHashB64: nextPubKeyHashB64,
};
await this.addContact(newContact);
}
@ -534,7 +550,7 @@ export default class ContactsView extends Vue {
return this.addContact({
did: payload.iss,
name: payload.own.name,
nextPublicKeyHashBase64: payload.own.nextPublicEncKeyHash,
nextPubKeyHashB64: payload.own.nextPublicEncKeyHash,
publicKeyBase64: payload.own.publicEncKey,
} as Contact);
}
@ -592,7 +608,7 @@ export default class ContactsView extends Vue {
title: "Contact Added",
text: addedMessage,
},
5000,
-1, // keeping it up so that the "visibility" message is seen
);
})
.catch((err) => {

Loading…
Cancel
Save