mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 12:52:26 +00:00
Refactor auth login providers
This commit is contained in:
1 parent
8f316f915b
commit
494b00b926
5 files changed
+240
-27
No files matched your search
@@ -5,6 +5,7 @@ import {
|
||||
BITVID_WEBSITE_URL as CONFIG_BITVID_WEBSITE_URL,
|
||||
MAX_WALLET_DEFAULT_ZAP as CONFIG_MAX_WALLET_DEFAULT_ZAP,
|
||||
} from "../config.js";
|
||||
import { getAuthProvider } from "../services/authProviders/index.js";
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
@@ -15,6 +16,32 @@ const DEFAULT_BITVID_WEBSITE_URL = "https://bitvid.network/";
|
||||
const NWC_URI_SCHEME = "nostr+walletconnect://";
|
||||
const DEFAULT_MAX_WALLET_DEFAULT_ZAP = 100000000;
|
||||
|
||||
function resolveAuthTypeLabel(authType) {
|
||||
if (typeof authType !== "string") {
|
||||
return "Saved profile";
|
||||
}
|
||||
|
||||
const trimmed = authType.trim();
|
||||
if (!trimmed) {
|
||||
return "Saved profile";
|
||||
}
|
||||
|
||||
const provider = getAuthProvider(trimmed);
|
||||
if (provider && typeof provider.label === "string" && provider.label) {
|
||||
return provider.label;
|
||||
}
|
||||
|
||||
if (trimmed === "nsec") {
|
||||
return "Direct key";
|
||||
}
|
||||
|
||||
if (trimmed === "nip07") {
|
||||
return "Saved profile";
|
||||
}
|
||||
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
const DEFAULT_INTERNAL_NWC_SETTINGS = Object.freeze({
|
||||
nwcUri: "",
|
||||
defaultZap: null,
|
||||
@@ -1306,8 +1333,7 @@ export class ProfileModalController {
|
||||
|
||||
const label = document.createElement("span");
|
||||
label.className = "profile-card__label";
|
||||
label.textContent =
|
||||
entry.authType === "nsec" ? "Direct key" : "Saved profile";
|
||||
label.textContent = resolveAuthTypeLabel(entry.authType);
|
||||
|
||||
const action = document.createElement("span");
|
||||
action.className = "profile-card__action";
|
||||
|
||||
Reference in new issue
Block a user