Handle custom auth providers in saved profiles

This commit is contained in:
thePR0M3TH3AN committed 2025-10-21 13:56:38 -04:00
1 parent 1137a8ca78
commit ea45488ee4
5 files changed
+256 -23

No files matched your search

+30 -2
View File
@@ -1961,11 +1961,39 @@ class Application {
setLoadingState(true);
try {
const { pubkey } = await this.authService.requestLogin({
const loginResult = await this.authService.requestLogin({
allowAccountSelection: true,
autoApply: false,
});
const { pubkey, authType: loginAuthType, providerId } =
typeof loginResult === "object" && loginResult
? loginResult
: { pubkey: loginResult };
const detailAuthType =
typeof loginResult?.detail?.authType === "string"
? loginResult.detail.authType
: null;
const detailProviderId =
typeof loginResult?.detail?.providerId === "string"
? loginResult.detail.providerId
: null;
const resolvedAuthType = (() => {
const candidates = [detailAuthType, loginAuthType, detailProviderId, providerId];
for (const candidate of candidates) {
if (typeof candidate !== "string") {
continue;
}
const trimmed = candidate.trim();
if (trimmed) {
return trimmed;
}
}
return "nip07";
})();
const normalizedPubkey = this.normalizeHexPubkey(pubkey);
if (!normalizedPubkey) {
throw new Error(
@@ -1999,7 +2027,7 @@ class Application {
npub,
name,
picture,
authType: "nip07",
authType: resolvedAuthType,
});
persistSavedProfiles({ persistActive: false });