diff --git a/src/components/ImageMethodDialog.vue b/src/components/ImageMethodDialog.vue index 3cd857c..2e8aa20 100644 --- a/src/components/ImageMethodDialog.vue +++ b/src/components/ImageMethodDialog.vue @@ -18,7 +18,7 @@
-
+
; name?: string; diff --git a/src/libs/crypto/index.ts b/src/libs/crypto/index.ts index 2ac8aef..0e16bec 100644 --- a/src/libs/crypto/index.ts +++ b/src/libs/crypto/index.ts @@ -5,8 +5,10 @@ import { wordlist } from "ethereum-cryptography/bip39/wordlists/english"; import { HDNode } from "@ethersproject/hdnode"; import { + CONTACT_IMPORT_CONFIRM_URL_PATH_TIME_SAFARI, createEndorserJwtForDid, - ENDORSER_JWT_URL_LOCATION, + CONTACT_URL_PATH_ENDORSER_CH_OLD, + CONTACT_IMPORT_ONE_URL_PATH_TIME_SAFARI, } from "@/libs/endorserServer"; import { DEFAULT_DID_PROVIDER_NAME } from "../veramo/setup"; import { decodeEndorserJwt } from "@/libs/crypto/vc"; @@ -101,17 +103,34 @@ export const accessToken = async (did?: string) => { }; /** - @return results of uportJwtPayload: + @return payload of JWT pulled out of the URL and decoded: { iat: number, iss: string (DID), own: { name, publicEncKey (base64-encoded key) } } - Note that similar code is also contained in time-safari + Result may be a single contact or it may be { contacts: [ contact, ... ] } */ export const getContactPayloadFromJwtUrl = (jwtUrlText: string) => { let jwtText = jwtUrlText; - const endorserContextLoc = jwtText.indexOf(ENDORSER_JWT_URL_LOCATION); - if (endorserContextLoc > -1) { + const appImportConfirmUrlLoc = jwtText.indexOf( + CONTACT_IMPORT_CONFIRM_URL_PATH_TIME_SAFARI, + ); + if (appImportConfirmUrlLoc > -1) { jwtText = jwtText.substring( - endorserContextLoc + ENDORSER_JWT_URL_LOCATION.length, + appImportConfirmUrlLoc + + CONTACT_IMPORT_CONFIRM_URL_PATH_TIME_SAFARI.length, + ); + } + const appImportOneUrlLoc = jwtText.indexOf( + CONTACT_IMPORT_ONE_URL_PATH_TIME_SAFARI, + ); + if (appImportOneUrlLoc > -1) { + jwtText = jwtText.substring( + appImportOneUrlLoc + CONTACT_IMPORT_ONE_URL_PATH_TIME_SAFARI.length, + ); + } + const endorserUrlPathLoc = jwtText.indexOf(CONTACT_URL_PATH_ENDORSER_CH_OLD); + if (endorserUrlPathLoc > -1) { + jwtText = jwtText.substring( + endorserUrlPathLoc + CONTACT_URL_PATH_ENDORSER_CH_OLD.length, ); } diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 20d1fbf..42e1f3f 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -4,7 +4,11 @@ import { sha256 } from "ethereum-cryptography/sha256"; import { LRUCache } from "lru-cache"; import * as R from "ramda"; -import { DEFAULT_IMAGE_API_SERVER, NotificationIface } from "@/constants/app"; +import { + APP_SERVER, + DEFAULT_IMAGE_API_SERVER, + NotificationIface, +} from "@/constants/app"; import { Contact } from "@/db/tables/contacts"; import { accessToken, deriveAddress, nextDerivationPath } from "@/libs/crypto"; import { logConsoleAndDb, NonsensitiveDexie } from "@/db/index"; @@ -22,10 +26,14 @@ export const SCHEMA_ORG_CONTEXT = "https://schema.org"; export const SERVICE_ID = "endorser.ch"; // the header line for contacts exported via Endorser Mobile export const CONTACT_CSV_HEADER = "name,did,pubKeyBase64,seesMe,registered"; -// the prefix for the contact URL -export const CONTACT_URL_PREFIX = "https://endorser.ch"; -// the suffix for the contact URL -export const ENDORSER_JWT_URL_LOCATION = "/contact?jwt="; +// the suffix for the contact URL in this app where they are confirmed before import +export const CONTACT_IMPORT_CONFIRM_URL_PATH_TIME_SAFARI = "/contact-import/"; +// the suffix for the contact URL in this app where a single one gets imported automatically +export const CONTACT_IMPORT_ONE_URL_PATH_TIME_SAFARI = "/contacts?contactJwt="; +// the suffix for the old contact URL -- deprecated Jan 2025, though "endorser.ch/contact?jwt=" shows data on endorser.ch server +export const CONTACT_URL_PATH_ENDORSER_CH_OLD = "/contact?jwt="; +// unused now that we match on the URL path; just note that it was used for a while to create URLs that showed at endorser.ch +//export const CONTACT_URL_PREFIX_ENDORSER_CH_OLD = "https://endorser.ch"; // the prefix for handle IDs, the permanent ID for claims on Endorser export const ENDORSER_CH_HANDLE_PREFIX = "https://endorser.ch/entity/"; @@ -692,7 +700,6 @@ export async function getNewOffersToUser( url += "&beforeId=" + beforeOfferJwtId; } const headers = await getHeaders(activeDid); - console.log("Using headers: ", headers); const response = await axios.get(url, { headers }); return response.data; } @@ -1090,7 +1097,7 @@ export async function createAndSubmitClaim( } } -export async function generateEndorserJwtForAccount( +export async function generateEndorserJwtUrlForAccount( account: Account, isRegistered?: boolean, name?: string, @@ -1130,7 +1137,7 @@ export async function generateEndorserJwtForAccount( const vcJwt = await createEndorserJwtForDid(account.did, contactInfo); - const viewPrefix = CONTACT_URL_PREFIX + ENDORSER_JWT_URL_LOCATION; + const viewPrefix = APP_SERVER + CONTACT_IMPORT_ONE_URL_PATH_TIME_SAFARI; return viewPrefix + vcJwt; } diff --git a/src/views/ClaimCertificateView.vue b/src/views/ClaimCertificateView.vue index 2b22dd1..f7b6b6a 100644 --- a/src/views/ClaimCertificateView.vue +++ b/src/views/ClaimCertificateView.vue @@ -181,7 +181,6 @@ export default class ClaimCertificateView extends Vue { } // Draw claim issuer - console.log("claimData.issuer", claimData.issuer); if ( claimData.issuer == null || serverUtil.isHiddenDid(claimData.issuer) || diff --git a/src/views/ContactEditView.vue b/src/views/ContactEditView.vue index fd81be1..47264de 100644 --- a/src/views/ContactEditView.vue +++ b/src/views/ContactEditView.vue @@ -17,7 +17,7 @@
-
+