@ -528,8 +533,40 @@ export async function getHeaders(did?: string) {
token=awaitaccessToken(did);
token=awaitaccessToken(did);
}
}
headers["Authorization"]="Bearer "+token;
headers["Authorization"]="Bearer "+token;
}catch(error){
// This rarely happens: we've seen it when they have account info but the
// encryption secret got lost. But in most cases we want users to at
// least see their feed -- and anything else that returns results for
// anonymous users.
// We'll continue with an anonymous request... still want to show feed and other things, but ideally let them know.
logConsoleAndDb(
"Something failed in getHeaders call (will proceed anonymously"+
($notify?" and notify user":"")+
"): "+
// IntelliJ type system complains about getCircularReplacer() with: Argument of type '(obj: any, key: string, value: any) => any' is not assignable to parameter of type '(this: any, key: string, value: any) => any'.
//JSON.stringify(error, getCircularReplacer()), // JSON.stringify(error) on a Dexie error throws another error about: Converting circular structure to JSON
error,
true,
);
if($notify){
// remember: only want to do this if they supplied a DID, expecting personal results
constnotifyMessage=
failureMessage||
"Showing anonymous data. See the Help page for help with personal data.";
$notify(
{
group:"alert",
type:"danger",
title:"Personal Data Error",
text: notifyMessage,
},
3000,
);
}
}
}else{
}else{
// it's often OK to request without auth; we assume necessary checks are done earlier
// it's usually OK to request without auth; we assume we're only here when allowed
}
}
returnheaders;
returnheaders;
}
}
@ -611,6 +648,7 @@ export async function getNewOffersToUser(
// // Beware: we've seen this return "undefined" when there is actually a message, eg: DatabaseClosedError: Error DEXIE ENCRYPT ADDON: Encryption key has changed