change the contact-sharing data into a JWT for the contact-import page
This commit is contained in:
@@ -16,10 +16,11 @@
|
||||
Contact Import
|
||||
</h1>
|
||||
|
||||
<span class="flex justify-center">
|
||||
<span v-if="contactsImporting.length > 0" class="flex justify-center">
|
||||
<input type="checkbox" v-model="makeVisible" class="mr-2" />
|
||||
Make my activity visible to these contacts.
|
||||
</span>
|
||||
|
||||
<div v-if="sameCount > 0">
|
||||
<span v-if="sameCount == 1"
|
||||
>One contact is the same as an existing contact</span
|
||||
@@ -85,17 +86,19 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { JWTVerified } from "did-jwt";
|
||||
import * as R from "ramda";
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
import { Router } from "vue-router";
|
||||
|
||||
import QuickNav from "@/components/QuickNav.vue";
|
||||
import EntityIcon from "@/components/EntityIcon.vue";
|
||||
import OfferDialog from "@/components/OfferDialog.vue";
|
||||
import { AppString, NotificationIface } from "@/constants/app";
|
||||
import { db, retrieveSettingsForActiveAccount } from "@/db/index";
|
||||
import { Contact } from "@/db/tables/contacts";
|
||||
import * as libsUtil from "@/libs/util";
|
||||
import QuickNav from "@/components/QuickNav.vue";
|
||||
import EntityIcon from "@/components/EntityIcon.vue";
|
||||
import OfferDialog from "@/components/OfferDialog.vue";
|
||||
import { decodeAndVerifyJwt } from "@/libs/crypto/vc/index";
|
||||
import { setVisibilityUtil } from "@/libs/endorserServer";
|
||||
|
||||
@Component({
|
||||
@@ -127,9 +130,27 @@ export default class ContactImportView extends Vue {
|
||||
this.apiServer = settings.apiServer || "";
|
||||
|
||||
// Retrieve the imported contacts from the query parameter
|
||||
const importedContacts =
|
||||
((this.$route as Router).query["contacts"] as string) || "[]";
|
||||
this.contactsImporting = JSON.parse(importedContacts);
|
||||
const importedContacts = (this.$route as Router).query[
|
||||
"contacts"
|
||||
] as string;
|
||||
if (importedContacts) {
|
||||
await this.setContactsSelected(JSON.parse(importedContacts));
|
||||
}
|
||||
|
||||
// match everything after /contact-import/ in the window.location.pathname
|
||||
const jwt = window.location.pathname.match(
|
||||
/\/contact-import\/(ey.+)$/,
|
||||
)?.[1];
|
||||
if (jwt) {
|
||||
// decode the JWT
|
||||
// eslint-disable-next-line prettier/prettier
|
||||
const parsedJwt: Omit<JWTVerified, "didResolutionResult" | "signer" | "jwt"> = await decodeAndVerifyJwt(jwt);
|
||||
await this.setContactsSelected(parsedJwt.payload.contacts as Contact[]);
|
||||
}
|
||||
}
|
||||
|
||||
async setContactsSelected(contacts: Array<Contact>) {
|
||||
this.contactsImporting = contacts;
|
||||
this.contactsSelected = new Array(this.contactsImporting.length).fill(true);
|
||||
|
||||
await db.open();
|
||||
|
||||
Reference in New Issue
Block a user