From 07c4e58e872274a539d3eb8bab399562a1c9cebc Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Tue, 7 Jan 2025 20:56:39 -0700 Subject: [PATCH] add sanity checks for importing bulk contacts, eg. when there is a truncated link --- src/libs/crypto/index.ts | 5 +- src/libs/crypto/vc/index.ts | 2 +- src/views/ContactImportView.vue | 253 +++++++++++++++++++--------- src/views/ContactQRScanShowView.vue | 2 +- src/views/ContactsView.vue | 70 +++++--- src/views/InviteOneAcceptView.vue | 33 ++-- 6 files changed, 235 insertions(+), 130 deletions(-) diff --git a/src/libs/crypto/index.ts b/src/libs/crypto/index.ts index 0e16bec..a9846da 100644 --- a/src/libs/crypto/index.ts +++ b/src/libs/crypto/index.ts @@ -103,10 +103,9 @@ export const accessToken = async (did?: string) => { }; /** - @return payload of JWT pulled out of the URL and decoded: + @return payload of JWT pulled out of any recognized URL path (if any) and decoded: { iat: number, iss: string (DID), own: { name, publicEncKey (base64-encoded key) } } - - Result may be a single contact or it may be { contacts: [ contact, ... ] } + ... or an array of such as { contacts: [ contact, ... ] } */ export const getContactPayloadFromJwtUrl = (jwtUrlText: string) => { let jwtText = jwtUrlText; diff --git a/src/libs/crypto/vc/index.ts b/src/libs/crypto/vc/index.ts index 252ca06..a77cd00 100644 --- a/src/libs/crypto/vc/index.ts +++ b/src/libs/crypto/vc/index.ts @@ -124,7 +124,7 @@ function bytesToHex(b: Uint8Array): string { } // We should be calling 'verify' in more places, showing warnings if it fails. -// @returns JWTDecoded with { header: JWTHeader, payload: string, signature: string, data: string } (but doesn't verify the signature) +// @returns JWTDecoded with { header: JWTHeader, payload: any, signature: string, data: string } (but doesn't verify the signature) export function decodeEndorserJwt(jwt: string) { return didJwt.decodeJWT(jwt); } diff --git a/src/views/ContactImportView.vue b/src/views/ContactImportView.vue index b69bf39..6fd71ce 100644 --- a/src/views/ContactImportView.vue +++ b/src/views/ContactImportView.vue @@ -16,96 +16,135 @@ Contact Import - - - Make my activity visible to these contacts. - - -
- One contact is the same as an existing contact - {{ sameCount }} contacts are the same as existing contacts +
+
+
+ + + Make my activity visible to these contacts. + - -
    -
  • -
    + One contact is the same as an existing contact -

    - - {{ contact.name || AppString.NO_CONTACT_NAME }} - - - Existing - New -

    -
    - {{ contact.did }} -
    -
    -
    -
    -
    Field
    -
    Old Value
    -
    New Value
    -
    -
    {{ sameCount }} contacts are the same as existing contacts +
    + + +
      +
    • +
      +

      + + {{ contact.name || AppString.NO_CONTACT_NAME }} + - + Existing -
      {{ contactField }}
      -
      {{ value.old }}
      -
      {{ value.new }}
      + New +

      +
      + {{ contact.did }} +
      +
      +
      +
      +
      +
      Old Value
      +
      New Value
      +
      +
      +
      + {{ capitalizeAndInsertSpacesBeforeCaps(contactField) }} +
      +
      {{ value.old }}
      +
      {{ value.new }}
      +
      +
    • + +
    +

    + All those contacts are already in your list with the same information. +

    +
    + There are no contacts in that import. If some were sent, try again to + get the full text and paste it. (Note that iOS cuts off data in text + messages.) Ask the person to send the data a different way, eg. email. +
    +