forked from trent_larson/crowd-funder-for-time-pwa
change all copied contact URLs to contact-import, and handle multiples & singles separately
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -294,7 +294,12 @@ export interface ErrorResult extends ResultWithType {
|
||||
|
||||
export type CreateAndSubmitClaimResult = SuccessResult | ErrorResult;
|
||||
|
||||
/**
|
||||
* This is similar to Contact but it grew up in different logic paths.
|
||||
* We may want to change this to be a Contact.
|
||||
*/
|
||||
export interface UserInfo {
|
||||
did: string;
|
||||
name: string;
|
||||
publicEncKey: string;
|
||||
registered: boolean;
|
||||
@@ -609,7 +614,17 @@ const planCache: LRUCache<string, PlanSummaryRecord> = new LRUCache({
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function errorStringForLog(error: any) {
|
||||
let fullError = "" + error + " - JSON: " + JSON.stringify(error);
|
||||
let stringifiedError = "" + error;
|
||||
try {
|
||||
stringifiedError = JSON.stringify(error);
|
||||
} catch (e) {
|
||||
// can happen with Dexie, eg:
|
||||
// TypeError: Converting circular structure to JSON
|
||||
// --> starting at object with constructor 'DexieError2'
|
||||
// | property '_promise' -> object with constructor 'DexiePromise'
|
||||
// --- property '_value' closes the circle
|
||||
}
|
||||
let fullError = "" + error + " - JSON: " + stringifiedError;
|
||||
const errorResponseText = JSON.stringify(error.response);
|
||||
// for some reason, error.response is not included in stringify result (eg. for 400 errors on invite redemptions)
|
||||
if (!R.empty(errorResponseText) && !fullError.includes(errorResponseText)) {
|
||||
@@ -1112,6 +1127,7 @@ export async function generateEndorserJwtUrlForAccount(
|
||||
iat: Date.now(),
|
||||
iss: account.did,
|
||||
own: {
|
||||
did: account.did,
|
||||
name: name ?? "",
|
||||
publicEncKey,
|
||||
registered: !!isRegistered,
|
||||
@@ -1137,7 +1153,7 @@ export async function generateEndorserJwtUrlForAccount(
|
||||
|
||||
const vcJwt = await createEndorserJwtForDid(account.did, contactInfo);
|
||||
|
||||
const viewPrefix = APP_SERVER + CONTACT_IMPORT_ONE_URL_PATH_TIME_SAFARI;
|
||||
const viewPrefix = APP_SERVER + CONTACT_IMPORT_CONFIRM_URL_PATH_TIME_SAFARI;
|
||||
return viewPrefix + vcJwt;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user