change all copied contact URLs to contact-import, and handle multiples & singles separately

This commit is contained in:
2025-01-09 20:10:00 -07:00
parent 5f39beef55
commit 6514f52b92
5 changed files with 104 additions and 74 deletions

View File

@@ -11,7 +11,6 @@ import {
CONTACT_IMPORT_ONE_URL_PATH_TIME_SAFARI,
} from "@/libs/endorserServer";
import { DEFAULT_DID_PROVIDER_NAME } from "../veramo/setup";
import { decodeEndorserJwt } from "@/libs/crypto/vc";
export const DEFAULT_ROOT_DERIVATION_PATH = "m/84737769'/0'/0'/0'";
@@ -103,11 +102,9 @@ export const accessToken = async (did?: string) => {
};
/**
@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) } }
... or an array of such as { contacts: [ contact, ... ] }
@return payload of JWT pulled out of any recognized URL path (if any)
*/
export const getContactPayloadFromJwtUrl = (jwtUrlText: string) => {
export const getContactJwtFromJwtUrl = (jwtUrlText: string) => {
let jwtText = jwtUrlText;
const appImportConfirmUrlLoc = jwtText.indexOf(
CONTACT_IMPORT_CONFIRM_URL_PATH_TIME_SAFARI,
@@ -132,11 +129,7 @@ export const getContactPayloadFromJwtUrl = (jwtUrlText: string) => {
endorserUrlPathLoc + CONTACT_URL_PATH_ENDORSER_CH_OLD.length,
);
}
// JWT format: { header, payload, signature, data }
const jwt = decodeEndorserJwt(jwtText);
return jwt.payload;
return jwtText;
};
export const nextDerivationPath = (origDerivPath: string) => {