@cedros/login-react 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +1183 -0
- package/dist/EmailRegisterForm-D_uCEdX9.cjs +1 -0
- package/dist/EmailRegisterForm-D_uCEdX9.cjs.map +1 -0
- package/dist/EmailRegisterForm-m3rX3A6X.js +2923 -0
- package/dist/EmailRegisterForm-m3rX3A6X.js.map +1 -0
- package/dist/ErrorMessage-Bm1j5mBT.js +2042 -0
- package/dist/ErrorMessage-Bm1j5mBT.js.map +1 -0
- package/dist/ErrorMessage-CntMyn93.cjs +1 -0
- package/dist/ErrorMessage-CntMyn93.cjs.map +1 -0
- package/dist/GoogleLoginButton-CJNJ-THo.cjs +1 -0
- package/dist/GoogleLoginButton-CJNJ-THo.cjs.map +1 -0
- package/dist/GoogleLoginButton-CvDoOc-0.js +227 -0
- package/dist/GoogleLoginButton-CvDoOc-0.js.map +1 -0
- package/dist/SolanaLoginButton-BlSgPW50.cjs +1 -0
- package/dist/SolanaLoginButton-BlSgPW50.cjs.map +1 -0
- package/dist/SolanaLoginButton-h32xN2PQ.js +261 -0
- package/dist/SolanaLoginButton-h32xN2PQ.js.map +1 -0
- package/dist/assets/argon2Worker-Bi5TuQvD.js +1 -0
- package/dist/assets/argon2Worker-Bi5TuQvD.js.map +1 -0
- package/dist/components/LoginButton.d.ts +23 -0
- package/dist/components/LoginForm.d.ts +9 -0
- package/dist/components/LoginModal.d.ts +9 -0
- package/dist/components/admin/AdminUserDetail.d.ts +21 -0
- package/dist/components/admin/AdminUserList.d.ts +25 -0
- package/dist/components/admin/CedrosAdminDashboard.d.ts +48 -0
- package/dist/components/admin/SystemSettings.d.ts +19 -0
- package/dist/components/apple/AppleLoginButton.d.ts +29 -0
- package/dist/components/deposit/CreditBalance.d.ts +19 -0
- package/dist/components/deposit/DepositFlow.d.ts +118 -0
- package/dist/components/deposit/FeeConfigDisplay.d.ts +15 -0
- package/dist/components/deposit/History.d.ts +21 -0
- package/dist/components/deposit/TieredAmountSlider.d.ts +19 -0
- package/dist/components/deposit/TokenSelector.d.ts +23 -0
- package/dist/components/deposit/admin/AdminDepositList.d.ts +21 -0
- package/dist/components/deposit/admin/AdminDepositStats.d.ts +15 -0
- package/dist/components/deposit/admin/AdminPrivacyPeriodDeposits.d.ts +19 -0
- package/dist/components/deposit/admin/AdminWithdrawalHistory.d.ts +19 -0
- package/dist/components/deposit/admin/AdminWithdrawalQueue.d.ts +23 -0
- package/dist/components/deposit/admin/PrivacySystemStatus.d.ts +15 -0
- package/dist/components/deposit/admin/index.d.ts +17 -0
- package/dist/components/deposit/index.d.ts +12 -0
- package/dist/components/deposit/tierUtils.d.ts +8 -0
- package/dist/components/deposit/tokens.d.ts +19 -0
- package/dist/components/email/EmailLoginForm.d.ts +11 -0
- package/dist/components/email/EmailRegisterForm.d.ts +14 -0
- package/dist/components/email/ForgotPasswordForm.d.ts +17 -0
- package/dist/components/email/PasswordInput.d.ts +14 -0
- package/dist/components/email/ResetPasswordForm.d.ts +22 -0
- package/dist/components/google/GoogleLoginButton.d.ts +12 -0
- package/dist/components/invites/InviteForm.d.ts +38 -0
- package/dist/components/invites/InviteList.d.ts +40 -0
- package/dist/components/members/MemberList.d.ts +47 -0
- package/dist/components/org/CreateOrgForm.d.ts +7 -0
- package/dist/components/org/OrgAvatar.d.ts +7 -0
- package/dist/components/org/OrgListView.d.ts +9 -0
- package/dist/components/org/OrgSelector.d.ts +51 -0
- package/dist/components/org/OrgSwitcher.d.ts +47 -0
- package/dist/components/org/icons.d.ts +8 -0
- package/dist/components/sessions/SessionList.d.ts +33 -0
- package/dist/components/shared/ErrorBoundary.d.ts +38 -0
- package/dist/components/shared/ErrorMessage.d.ts +14 -0
- package/dist/components/shared/LoadingSpinner.d.ts +16 -0
- package/dist/components/solana/SolanaLoginButton.d.ts +49 -0
- package/dist/components/templates/FullPageLayout.d.ts +40 -0
- package/dist/components/templates/SplitPageLayout.d.ts +44 -0
- package/dist/components/templates/index.d.ts +4 -0
- package/dist/components/totp/OtpInput.d.ts +32 -0
- package/dist/components/totp/QrCode.d.ts +21 -0
- package/dist/components/totp/TotpSettings.d.ts +38 -0
- package/dist/components/totp/TotpSetup.d.ts +23 -0
- package/dist/components/totp/TotpVerify.d.ts +25 -0
- package/dist/components/totp/index.d.ts +10 -0
- package/dist/components/wallet/CapabilityWarning.d.ts +11 -0
- package/dist/components/wallet/PasskeyPrompt.d.ts +34 -0
- package/dist/components/wallet/RecoveryPhraseDisplay.d.ts +18 -0
- package/dist/components/wallet/RecoveryPhraseInput.d.ts +21 -0
- package/dist/components/wallet/WalletAddressRow.d.ts +10 -0
- package/dist/components/wallet/WalletEnrollment.d.ts +15 -0
- package/dist/components/wallet/WalletManager.d.ts +9 -0
- package/dist/components/wallet/WalletRecovery.d.ts +19 -0
- package/dist/components/wallet/WalletStatus.d.ts +28 -0
- package/dist/components/wallet/WalletUnlock.d.ts +23 -0
- package/dist/components/wallet/index.d.ts +23 -0
- package/dist/components/webauthn/PasskeyLoginButton.d.ts +8 -0
- package/dist/context/CedrosLoginContext.d.ts +24 -0
- package/dist/context/CedrosLoginProvider.d.ts +17 -0
- package/dist/context/EmbeddedWalletExposure.d.ts +19 -0
- package/dist/context/useCedrosLogin.d.ts +12 -0
- package/dist/crypto/aesGcm.d.ts +89 -0
- package/dist/crypto/argon2.d.ts +65 -0
- package/dist/crypto/argon2Worker.d.ts +1 -0
- package/dist/crypto/argon2WorkerClient.d.ts +28 -0
- package/dist/crypto/bip39.d.ts +106 -0
- package/dist/crypto/capabilities.d.ts +35 -0
- package/dist/crypto/entropy.d.ts +56 -0
- package/dist/crypto/hkdf.d.ts +38 -0
- package/dist/crypto/index.d.ts +30 -0
- package/dist/crypto/secureWipe.d.ts +90 -0
- package/dist/crypto/shamir.d.ts +52 -0
- package/dist/crypto/solanaKeypair.d.ts +63 -0
- package/dist/crypto/types.d.ts +134 -0
- package/dist/crypto/webauthnPrf.d.ts +118 -0
- package/dist/email-only.cjs +1 -0
- package/dist/email-only.cjs.map +1 -0
- package/dist/email-only.d.ts +16 -0
- package/dist/email-only.js +15 -0
- package/dist/email-only.js.map +1 -0
- package/dist/google-only.cjs +1 -0
- package/dist/google-only.cjs.map +1 -0
- package/dist/google-only.d.ts +13 -0
- package/dist/google-only.js +11 -0
- package/dist/google-only.js.map +1 -0
- package/dist/hooks/useAdminDeposits.d.ts +10 -0
- package/dist/hooks/useAdminUsers.d.ts +28 -0
- package/dist/hooks/useAppleAuth.d.ts +52 -0
- package/dist/hooks/useAuth.d.ts +34 -0
- package/dist/hooks/useAuthSession.d.ts +19 -0
- package/dist/hooks/useAuthorize.d.ts +62 -0
- package/dist/hooks/useCredits.d.ts +11 -0
- package/dist/hooks/useDeposit.d.ts +16 -0
- package/dist/hooks/useEmailAuth.d.ts +60 -0
- package/dist/hooks/useGoogleAuth.d.ts +67 -0
- package/dist/hooks/useInstantLink.d.ts +42 -0
- package/dist/hooks/useInvites.d.ts +57 -0
- package/dist/hooks/useMembers.d.ts +52 -0
- package/dist/hooks/useOrgs.d.ts +49 -0
- package/dist/hooks/usePasswordReset.d.ts +32 -0
- package/dist/hooks/usePendingRecovery.d.ts +34 -0
- package/dist/hooks/useRateLimiter.d.ts +58 -0
- package/dist/hooks/useSessions.d.ts +45 -0
- package/dist/hooks/useSolanaAuth.d.ts +30 -0
- package/dist/hooks/useSystemSettings.d.ts +47 -0
- package/dist/hooks/useThemeManager.d.ts +11 -0
- package/dist/hooks/useTotp.d.ts +52 -0
- package/dist/hooks/useTotpVerify.d.ts +38 -0
- package/dist/hooks/useTransactionSigning.d.ts +45 -0
- package/dist/hooks/useWallet.d.ts +10 -0
- package/dist/hooks/useWalletDiscovery.d.ts +24 -0
- package/dist/hooks/useWalletEnrollment.d.ts +9 -0
- package/dist/hooks/useWalletMaterial.d.ts +10 -0
- package/dist/hooks/useWalletRecovery.d.ts +9 -0
- package/dist/hooks/useWalletSigning.d.ts +31 -0
- package/dist/hooks/useWebAuthn.d.ts +25 -0
- package/dist/i18n/I18nProvider.d.ts +16 -0
- package/dist/i18n/context.d.ts +6 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/translations.d.ts +66 -0
- package/dist/i18n/useI18n.d.ts +9 -0
- package/dist/index.cjs +2061 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +126 -0
- package/dist/index.js +14910 -0
- package/dist/index.js.map +1 -0
- package/dist/login-react.css +1 -0
- package/dist/solana-only.cjs +1 -0
- package/dist/solana-only.cjs.map +1 -0
- package/dist/solana-only.d.ts +13 -0
- package/dist/solana-only.js +11 -0
- package/dist/solana-only.js.map +1 -0
- package/dist/style.cjs +1 -0
- package/dist/style.cjs.map +1 -0
- package/dist/style.js +1 -0
- package/dist/style.js.map +1 -0
- package/dist/types/adminUser.d.ts +112 -0
- package/dist/types/auth.d.ts +122 -0
- package/dist/types/config.d.ts +266 -0
- package/dist/types/deposit.d.ts +488 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/invite.d.ts +71 -0
- package/dist/types/member.d.ts +45 -0
- package/dist/types/org.d.ts +101 -0
- package/dist/types/session.d.ts +28 -0
- package/dist/types/systemSettings.d.ts +81 -0
- package/dist/types/totp.d.ts +52 -0
- package/dist/types/wallet.d.ts +309 -0
- package/dist/utils/adminUserApi.d.ts +51 -0
- package/dist/utils/apiClient.d.ts +78 -0
- package/dist/utils/cryptoShim.d.ts +17 -0
- package/dist/utils/csrf.d.ts +1 -0
- package/dist/utils/deviceDetection.d.ts +17 -0
- package/dist/utils/embeddedWallet.d.ts +75 -0
- package/dist/utils/inviteApi.d.ts +31 -0
- package/dist/utils/memberApi.d.ts +23 -0
- package/dist/utils/orgApi.d.ts +36 -0
- package/dist/utils/sanitization.d.ts +66 -0
- package/dist/utils/sessionApi.d.ts +16 -0
- package/dist/utils/silentWalletEnroll.d.ts +41 -0
- package/dist/utils/systemSettingsApi.d.ts +18 -0
- package/dist/utils/tabSync.d.ts +46 -0
- package/dist/utils/tokenManager.d.ts +107 -0
- package/dist/utils/unlockCredential.d.ts +5 -0
- package/dist/utils/validation.d.ts +48 -0
- package/dist/utils/walletDetection.d.ts +23 -0
- package/dist/utils/webauthnJson.d.ts +21 -0
- package/dist/validation-BeXIfuHB.cjs +1 -0
- package/dist/validation-BeXIfuHB.cjs.map +1 -0
- package/dist/validation-BebL7hMF.js +56 -0
- package/dist/validation-BebL7hMF.js.map +1 -0
- package/package.json +109 -0
|
@@ -0,0 +1,2042 @@
|
|
|
1
|
+
import { jsxs as R, jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as me, useEffect as K, useState as U, useRef as P, useCallback as k, useMemo as O, useContext as we, memo as Qe } from "react";
|
|
3
|
+
const ae = me(null);
|
|
4
|
+
function be({ theme: e, themeOverrides: t }) {
|
|
5
|
+
K(() => {
|
|
6
|
+
if (typeof document > "u" || typeof window > "u")
|
|
7
|
+
return;
|
|
8
|
+
const A = document.documentElement;
|
|
9
|
+
let r = !1;
|
|
10
|
+
e === "dark" ? (A.classList.add("cedros-dark"), r = !0) : e === "light" ? A.classList.remove("cedros-dark") : window.matchMedia("(prefers-color-scheme: dark)").matches ? (A.classList.add("cedros-dark"), r = !0) : A.classList.remove("cedros-dark");
|
|
11
|
+
const n = /* @__PURE__ */ new Map();
|
|
12
|
+
return t && Object.entries(t).forEach(([i, o]) => {
|
|
13
|
+
if (o) {
|
|
14
|
+
const I = A.style.getPropertyValue(i);
|
|
15
|
+
n.set(i, I), A.style.setProperty(i, o);
|
|
16
|
+
}
|
|
17
|
+
}), () => {
|
|
18
|
+
r && A.classList.remove("cedros-dark"), n.forEach((i, o) => {
|
|
19
|
+
i ? A.style.setProperty(o, i) : A.style.removeProperty(o);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}, [e, t]);
|
|
23
|
+
}
|
|
24
|
+
const Ge = "cedros_tokens", Ke = 6e4;
|
|
25
|
+
class He {
|
|
26
|
+
storage;
|
|
27
|
+
requestedStorage;
|
|
28
|
+
storageKey;
|
|
29
|
+
tokens = null;
|
|
30
|
+
expiresAt = 0;
|
|
31
|
+
refreshTimer = null;
|
|
32
|
+
onRefreshNeeded = null;
|
|
33
|
+
onSessionExpired = null;
|
|
34
|
+
onRefreshError = null;
|
|
35
|
+
// P-02: Track destruction to prevent timer callbacks from executing after cleanup
|
|
36
|
+
isDestroyed = !1;
|
|
37
|
+
allowWebStorage;
|
|
38
|
+
constructor(t = "cookie", A = Ge, r = {}) {
|
|
39
|
+
this.requestedStorage = t, this.storage = t, this.storageKey = A, this.allowWebStorage = r.allowWebStorage ?? !1, this.warnIfLocalStorage(), !this.allowWebStorage && (this.requestedStorage === "localStorage" || this.requestedStorage === "sessionStorage") && (this.storage = "memory"), this.loadFromStorage();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* S-18/UI-XSS: Warn about localStorage XSS vulnerability in all environments.
|
|
43
|
+
* Security warnings should not be suppressed in production - operators need
|
|
44
|
+
* to be aware of the security implications of their storage choices.
|
|
45
|
+
*/
|
|
46
|
+
warnIfLocalStorage() {
|
|
47
|
+
if ((this.requestedStorage === "localStorage" || this.requestedStorage === "sessionStorage") && typeof console < "u") {
|
|
48
|
+
const t = this.allowWebStorage ? "" : " (web storage disabled by default; set allowWebStorage=true to enable)";
|
|
49
|
+
console.warn(
|
|
50
|
+
"[cedros-login] SECURITY: Using web storage for token storage. Tokens are vulnerable to XSS attacks." + t + " PRODUCTION RECOMMENDATIONS: (1) Use httpOnly cookie storage instead, (2) If web storage required: implement strict Content-Security-Policy, sanitize all input/output, audit third-party scripts. See https://owasp.org/www-community/attacks/xss/"
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Set the callback for when tokens need to be refreshed
|
|
56
|
+
*/
|
|
57
|
+
setRefreshCallback(t) {
|
|
58
|
+
this.onRefreshNeeded = t, this.scheduleRefresh();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Set the callback for when session expires
|
|
62
|
+
*/
|
|
63
|
+
setSessionExpiredCallback(t) {
|
|
64
|
+
this.onSessionExpired = t;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Set the callback for when token refresh fails
|
|
68
|
+
* This allows the UI to show an error message to the user
|
|
69
|
+
*/
|
|
70
|
+
setRefreshErrorCallback(t) {
|
|
71
|
+
this.onRefreshError = t;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Store tokens and schedule auto-refresh
|
|
75
|
+
*/
|
|
76
|
+
setTokens(t) {
|
|
77
|
+
this.tokens = t, this.expiresAt = Date.now() + t.expiresIn * 1e3, this.saveToStorage(), this.scheduleRefresh();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the current access token
|
|
81
|
+
* UI-4 FIX: Store token in local variable before expiry check to eliminate TOCTOU race.
|
|
82
|
+
* UI-TOK-01 FIX: Check isDestroyed to prevent access after manager is cleaned up.
|
|
83
|
+
*/
|
|
84
|
+
getAccessToken() {
|
|
85
|
+
if (this.isDestroyed) return null;
|
|
86
|
+
const t = this.tokens?.accessToken;
|
|
87
|
+
return t ? Date.now() >= this.expiresAt ? (this.clear(), this.onSessionExpired?.(), null) : t : null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get the current refresh token
|
|
91
|
+
*/
|
|
92
|
+
getRefreshToken() {
|
|
93
|
+
return this.tokens?.refreshToken ?? null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Clear stored tokens
|
|
97
|
+
*/
|
|
98
|
+
clear() {
|
|
99
|
+
this.tokens = null, this.expiresAt = 0, this.cancelRefresh(), this.clearStorage();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Check if tokens are stored
|
|
103
|
+
*/
|
|
104
|
+
hasTokens() {
|
|
105
|
+
return this.tokens !== null && Date.now() < this.expiresAt;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Destroy the token manager and clean up resources.
|
|
109
|
+
* Call this when unmounting components or cleaning up to prevent memory leaks.
|
|
110
|
+
* P-02: Also sets isDestroyed flag to prevent timer callbacks from executing.
|
|
111
|
+
*/
|
|
112
|
+
destroy() {
|
|
113
|
+
this.isDestroyed = !0, this.cancelRefresh(), this.onRefreshNeeded = null, this.onSessionExpired = null, this.onRefreshError = null, this.tokens = null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get time until token expiry in ms
|
|
117
|
+
*/
|
|
118
|
+
getTimeUntilExpiry() {
|
|
119
|
+
return this.tokens ? Math.max(0, this.expiresAt - Date.now()) : 0;
|
|
120
|
+
}
|
|
121
|
+
scheduleRefresh() {
|
|
122
|
+
if (this.cancelRefresh(), !this.tokens || !this.onRefreshNeeded) return;
|
|
123
|
+
const t = this.getTimeUntilExpiry(), A = Math.max(0, t - Ke);
|
|
124
|
+
if (A <= 0) {
|
|
125
|
+
if (this.isDestroyed) return;
|
|
126
|
+
this.onRefreshNeeded().catch((r) => {
|
|
127
|
+
if (this.isDestroyed) return;
|
|
128
|
+
const n = r instanceof Error ? r : new Error("Token refresh failed");
|
|
129
|
+
this.onRefreshError?.(n), this.clear(), this.onSessionExpired?.();
|
|
130
|
+
});
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
this.refreshTimer = setTimeout(() => {
|
|
134
|
+
this.isDestroyed || this.onRefreshNeeded?.().catch((r) => {
|
|
135
|
+
if (this.isDestroyed) return;
|
|
136
|
+
const n = r instanceof Error ? r : new Error("Token refresh failed");
|
|
137
|
+
this.onRefreshError?.(n), this.clear(), this.onSessionExpired?.();
|
|
138
|
+
});
|
|
139
|
+
}, A);
|
|
140
|
+
}
|
|
141
|
+
cancelRefresh() {
|
|
142
|
+
this.refreshTimer && (clearTimeout(this.refreshTimer), this.refreshTimer = null);
|
|
143
|
+
}
|
|
144
|
+
loadFromStorage() {
|
|
145
|
+
if (this.storage !== "memory" && !(typeof window > "u") && !(!this.allowWebStorage && (this.storage === "localStorage" || this.storage === "sessionStorage")))
|
|
146
|
+
try {
|
|
147
|
+
if (this.storage === "localStorage" || this.storage === "sessionStorage") {
|
|
148
|
+
const t = this.storage === "localStorage" ? localStorage : sessionStorage, A = t.getItem(this.storageKey);
|
|
149
|
+
if (A) {
|
|
150
|
+
const r = JSON.parse(A);
|
|
151
|
+
this.isValidStoredTokenData(r) ? r.expiresAt > Date.now() ? (this.tokens = r.tokens, this.expiresAt = r.expiresAt) : t.removeItem(this.storageKey) : t.removeItem(this.storageKey);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
} catch {
|
|
155
|
+
if (this.storage === "localStorage" || this.storage === "sessionStorage") {
|
|
156
|
+
const t = this.storage === "localStorage" ? localStorage : sessionStorage;
|
|
157
|
+
try {
|
|
158
|
+
t.removeItem(this.storageKey);
|
|
159
|
+
} catch {
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Validate that parsed data matches expected StoredTokenData structure
|
|
166
|
+
*/
|
|
167
|
+
isValidStoredTokenData(t) {
|
|
168
|
+
if (typeof t != "object" || t === null) return !1;
|
|
169
|
+
const A = t;
|
|
170
|
+
if (typeof A.expiresAt != "number" || typeof A.tokens != "object" || A.tokens === null) return !1;
|
|
171
|
+
const r = A.tokens;
|
|
172
|
+
return !(typeof r.accessToken != "string" || typeof r.refreshToken != "string" || typeof r.expiresIn != "number");
|
|
173
|
+
}
|
|
174
|
+
saveToStorage() {
|
|
175
|
+
if (!(this.storage === "memory" || !this.tokens) && !(typeof window > "u") && !(!this.allowWebStorage && (this.storage === "localStorage" || this.storage === "sessionStorage")))
|
|
176
|
+
try {
|
|
177
|
+
if (this.storage === "localStorage" || this.storage === "sessionStorage") {
|
|
178
|
+
const t = this.storage === "localStorage" ? localStorage : sessionStorage, A = {
|
|
179
|
+
tokens: this.tokens,
|
|
180
|
+
expiresAt: this.expiresAt
|
|
181
|
+
};
|
|
182
|
+
t.setItem(this.storageKey, JSON.stringify(A));
|
|
183
|
+
}
|
|
184
|
+
} catch {
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
clearStorage() {
|
|
188
|
+
if (this.storage !== "memory" && !(typeof window > "u") && !(!this.allowWebStorage && (this.storage === "localStorage" || this.storage === "sessionStorage")))
|
|
189
|
+
try {
|
|
190
|
+
(this.storage === "localStorage" || this.storage === "sessionStorage") && (this.storage === "localStorage" ? localStorage : sessionStorage).removeItem(this.storageKey);
|
|
191
|
+
} catch {
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const Je = "cedros_auth_sync";
|
|
196
|
+
class Me {
|
|
197
|
+
channel = null;
|
|
198
|
+
callback = null;
|
|
199
|
+
boundHandler = null;
|
|
200
|
+
constructor() {
|
|
201
|
+
typeof window < "u" && "BroadcastChannel" in window && (this.channel = new BroadcastChannel(Je), this.boundHandler = this.handleMessage.bind(this), this.channel.addEventListener("message", this.boundHandler));
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Handle incoming sync messages
|
|
205
|
+
*/
|
|
206
|
+
handleMessage(t) {
|
|
207
|
+
this.callback?.(t.data);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Set the callback for sync events from other tabs
|
|
211
|
+
*/
|
|
212
|
+
setCallback(t) {
|
|
213
|
+
this.callback = t;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Broadcast login event to other tabs
|
|
217
|
+
*/
|
|
218
|
+
broadcastLogin(t) {
|
|
219
|
+
this.channel?.postMessage({ type: "login", user: t });
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Broadcast logout event to other tabs
|
|
223
|
+
*/
|
|
224
|
+
broadcastLogout() {
|
|
225
|
+
this.channel?.postMessage({ type: "logout" });
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Broadcast token refresh event to other tabs
|
|
229
|
+
*/
|
|
230
|
+
broadcastRefresh() {
|
|
231
|
+
this.channel?.postMessage({ type: "refresh" });
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Close the channel and clean up references
|
|
235
|
+
* UI-6: Use removeEventListener for proper cleanup
|
|
236
|
+
*/
|
|
237
|
+
close() {
|
|
238
|
+
this.channel && (this.boundHandler && (this.channel.removeEventListener("message", this.boundHandler), this.boundHandler = null), this.channel.close(), this.channel = null), this.callback = null;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const ce = 20;
|
|
242
|
+
function ne() {
|
|
243
|
+
if (typeof document > "u") return null;
|
|
244
|
+
const e = document.querySelector('meta[name="csrf-token"]');
|
|
245
|
+
if (e) {
|
|
246
|
+
const A = e.getAttribute("content");
|
|
247
|
+
if (A && A.length >= ce)
|
|
248
|
+
return A;
|
|
249
|
+
}
|
|
250
|
+
const t = document.cookie.split(";");
|
|
251
|
+
for (const A of t) {
|
|
252
|
+
const [r, ...n] = A.trim().split("="), i = n.join("="), o = r.toLowerCase();
|
|
253
|
+
if (o === "xsrf-token" || o === "csrf-token")
|
|
254
|
+
try {
|
|
255
|
+
const I = decodeURIComponent(i.trim());
|
|
256
|
+
if (I.length >= ce)
|
|
257
|
+
return I;
|
|
258
|
+
} catch {
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
function X(e) {
|
|
265
|
+
if (typeof e != "object" || e === null) return !1;
|
|
266
|
+
const t = e;
|
|
267
|
+
if (typeof t.user != "object" || t.user === null) return !1;
|
|
268
|
+
const A = t.user;
|
|
269
|
+
return typeof A.id == "string" && A.id.length > 0;
|
|
270
|
+
}
|
|
271
|
+
function Ne(e) {
|
|
272
|
+
if (typeof e != "object" || e === null) return !1;
|
|
273
|
+
const t = e;
|
|
274
|
+
return typeof t.accessToken == "string" && t.accessToken.length > 0 && typeof t.refreshToken == "string" && t.refreshToken.length > 0 && typeof t.expiresIn == "number" && t.expiresIn > 0;
|
|
275
|
+
}
|
|
276
|
+
function Ve({
|
|
277
|
+
serverUrl: e,
|
|
278
|
+
session: t,
|
|
279
|
+
callbacks: A,
|
|
280
|
+
requestTimeoutMs: r
|
|
281
|
+
}) {
|
|
282
|
+
const [n, i] = U(null), [o, I] = U("idle"), c = P(null), w = P(null), B = P(A), p = P(!0), f = P(null);
|
|
283
|
+
K(() => {
|
|
284
|
+
B.current = A;
|
|
285
|
+
}, [A]), K(() => (p.current = !0, () => {
|
|
286
|
+
p.current = !1;
|
|
287
|
+
}), []);
|
|
288
|
+
const Q = k((s) => {
|
|
289
|
+
p.current && i(s);
|
|
290
|
+
}, []), u = k((s) => {
|
|
291
|
+
p.current && I(s);
|
|
292
|
+
}, []), h = O(
|
|
293
|
+
() => ({
|
|
294
|
+
storage: t?.storage ?? "cookie",
|
|
295
|
+
autoRefresh: t?.autoRefresh ?? !0,
|
|
296
|
+
syncTabs: t?.syncTabs ?? !0,
|
|
297
|
+
persistKey: t?.persistKey,
|
|
298
|
+
allowWebStorage: t?.allowWebStorage ?? !1
|
|
299
|
+
}),
|
|
300
|
+
[
|
|
301
|
+
t?.storage,
|
|
302
|
+
t?.autoRefresh,
|
|
303
|
+
t?.syncTabs,
|
|
304
|
+
t?.persistKey,
|
|
305
|
+
t?.allowWebStorage
|
|
306
|
+
]
|
|
307
|
+
);
|
|
308
|
+
K(() => (c.current = new He(h.storage, h.persistKey, {
|
|
309
|
+
allowWebStorage: h.allowWebStorage
|
|
310
|
+
}), h.syncTabs && (w.current = new Me()), () => {
|
|
311
|
+
c.current?.destroy(), c.current = null, w.current?.close();
|
|
312
|
+
}), [
|
|
313
|
+
h.storage,
|
|
314
|
+
h.syncTabs,
|
|
315
|
+
h.persistKey,
|
|
316
|
+
h.allowWebStorage
|
|
317
|
+
]);
|
|
318
|
+
const a = k(async () => {
|
|
319
|
+
if (f.current)
|
|
320
|
+
return f.current;
|
|
321
|
+
const s = c.current?.getRefreshToken(), E = !!s, F = ne(), b = {};
|
|
322
|
+
E && (b["Content-Type"] = "application/json"), F && (b["X-CSRF-Token"] = F);
|
|
323
|
+
const N = (async () => {
|
|
324
|
+
const V = new AbortController(), L = r ?? 1e4, Ue = window.setTimeout(() => V.abort(), L);
|
|
325
|
+
try {
|
|
326
|
+
const ge = await fetch(`${e}/refresh`, {
|
|
327
|
+
method: "POST",
|
|
328
|
+
headers: Object.keys(b).length > 0 ? b : void 0,
|
|
329
|
+
credentials: "include",
|
|
330
|
+
body: E ? JSON.stringify({ refreshToken: s }) : void 0,
|
|
331
|
+
signal: V.signal
|
|
332
|
+
});
|
|
333
|
+
if (!ge.ok)
|
|
334
|
+
throw new Error("Token refresh failed");
|
|
335
|
+
const z = await ge.json();
|
|
336
|
+
if (z.tokens) {
|
|
337
|
+
if (!Ne(z.tokens))
|
|
338
|
+
throw new Error("Invalid token response structure");
|
|
339
|
+
c.current?.setTokens(z.tokens);
|
|
340
|
+
} else if (h.storage !== "cookie")
|
|
341
|
+
throw new Error("Token refresh failed");
|
|
342
|
+
w.current?.broadcastRefresh();
|
|
343
|
+
} finally {
|
|
344
|
+
window.clearTimeout(Ue);
|
|
345
|
+
}
|
|
346
|
+
})();
|
|
347
|
+
f.current = N;
|
|
348
|
+
try {
|
|
349
|
+
await N;
|
|
350
|
+
} finally {
|
|
351
|
+
f.current = null;
|
|
352
|
+
}
|
|
353
|
+
}, [e, h.storage, r]), g = k(() => {
|
|
354
|
+
if (h.storage === "cookie") return;
|
|
355
|
+
const s = c.current?.getAccessToken();
|
|
356
|
+
if (s)
|
|
357
|
+
return { Authorization: `Bearer ${s}` };
|
|
358
|
+
}, [h.storage]), C = k(() => {
|
|
359
|
+
c.current?.clear(), Q(null), u("unauthenticated"), B.current?.onSessionExpired?.();
|
|
360
|
+
}, [u, Q]);
|
|
361
|
+
K(() => {
|
|
362
|
+
c.current && (h.autoRefresh && c.current.setRefreshCallback(a), c.current.setSessionExpiredCallback(C));
|
|
363
|
+
}, [h.autoRefresh, a, C]);
|
|
364
|
+
const d = k(async () => {
|
|
365
|
+
try {
|
|
366
|
+
const s = await fetch(`${e}/user`, {
|
|
367
|
+
credentials: "include",
|
|
368
|
+
headers: g()
|
|
369
|
+
});
|
|
370
|
+
if (s.ok) {
|
|
371
|
+
const E = await s.json();
|
|
372
|
+
if (X(E)) {
|
|
373
|
+
Q(E.user), u("authenticated");
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
if (s.status === 401 && h.autoRefresh) {
|
|
378
|
+
try {
|
|
379
|
+
await a();
|
|
380
|
+
} catch {
|
|
381
|
+
C();
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const E = await fetch(`${e}/user`, {
|
|
385
|
+
credentials: "include",
|
|
386
|
+
headers: g()
|
|
387
|
+
});
|
|
388
|
+
if (E.ok) {
|
|
389
|
+
const F = await E.json();
|
|
390
|
+
if (X(F)) {
|
|
391
|
+
Q(F.user), u("authenticated");
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
Q(null), u("unauthenticated");
|
|
397
|
+
} catch {
|
|
398
|
+
}
|
|
399
|
+
}, [
|
|
400
|
+
e,
|
|
401
|
+
h.autoRefresh,
|
|
402
|
+
a,
|
|
403
|
+
g,
|
|
404
|
+
C,
|
|
405
|
+
u,
|
|
406
|
+
Q
|
|
407
|
+
]);
|
|
408
|
+
K(() => {
|
|
409
|
+
!w.current || !h.syncTabs || w.current.setCallback((s) => {
|
|
410
|
+
switch (s.type) {
|
|
411
|
+
case "login":
|
|
412
|
+
Q(s.user), u("authenticated");
|
|
413
|
+
break;
|
|
414
|
+
case "logout":
|
|
415
|
+
Q(null), u("unauthenticated"), c.current?.clear();
|
|
416
|
+
break;
|
|
417
|
+
case "refresh":
|
|
418
|
+
d();
|
|
419
|
+
break;
|
|
420
|
+
default:
|
|
421
|
+
console.warn("[Cedros Login] Unhandled tab sync event:", s);
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}, [h.syncTabs, d, u, Q]), K(() => {
|
|
425
|
+
const s = new AbortController(), E = r ?? 1e4, F = window.setTimeout(() => s.abort(), E);
|
|
426
|
+
return (async () => {
|
|
427
|
+
u("loading");
|
|
428
|
+
try {
|
|
429
|
+
const N = await fetch(`${e}/user`, {
|
|
430
|
+
credentials: "include",
|
|
431
|
+
headers: g(),
|
|
432
|
+
signal: s.signal
|
|
433
|
+
});
|
|
434
|
+
if (N.ok) {
|
|
435
|
+
const V = await N.json();
|
|
436
|
+
if (X(V)) {
|
|
437
|
+
Q(V.user), u("authenticated");
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (N.status === 401 && h.autoRefresh) {
|
|
442
|
+
try {
|
|
443
|
+
await a();
|
|
444
|
+
} catch {
|
|
445
|
+
C();
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const V = await fetch(`${e}/user`, {
|
|
449
|
+
credentials: "include",
|
|
450
|
+
headers: g(),
|
|
451
|
+
signal: s.signal
|
|
452
|
+
});
|
|
453
|
+
if (V.ok) {
|
|
454
|
+
const L = await V.json();
|
|
455
|
+
if (X(L)) {
|
|
456
|
+
Q(L.user), u("authenticated");
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
Q(null), u("unauthenticated");
|
|
462
|
+
} catch {
|
|
463
|
+
Q(null), u("unauthenticated");
|
|
464
|
+
}
|
|
465
|
+
})(), () => {
|
|
466
|
+
window.clearTimeout(F), s.abort();
|
|
467
|
+
};
|
|
468
|
+
}, [
|
|
469
|
+
e,
|
|
470
|
+
h.autoRefresh,
|
|
471
|
+
a,
|
|
472
|
+
g,
|
|
473
|
+
C,
|
|
474
|
+
u,
|
|
475
|
+
Q,
|
|
476
|
+
r
|
|
477
|
+
]);
|
|
478
|
+
const D = k(
|
|
479
|
+
(s, E) => {
|
|
480
|
+
Q(s), u("authenticated"), E && c.current?.setTokens(E), p.current && w.current?.broadcastLogin(s);
|
|
481
|
+
},
|
|
482
|
+
[Q, u]
|
|
483
|
+
), y = k(async () => {
|
|
484
|
+
const s = ne();
|
|
485
|
+
try {
|
|
486
|
+
await fetch(`${e}/logout`, {
|
|
487
|
+
method: "POST",
|
|
488
|
+
headers: {
|
|
489
|
+
...s ? { "X-CSRF-Token": s } : {},
|
|
490
|
+
...g() ?? {}
|
|
491
|
+
},
|
|
492
|
+
credentials: "include"
|
|
493
|
+
});
|
|
494
|
+
} catch {
|
|
495
|
+
} finally {
|
|
496
|
+
Q(null), u("unauthenticated"), c.current?.clear(), w.current?.broadcastLogout(), B.current?.onLogout?.();
|
|
497
|
+
}
|
|
498
|
+
}, [e, g, Q, u]), l = k(() => c.current?.getAccessToken() ?? null, []);
|
|
499
|
+
return {
|
|
500
|
+
user: n,
|
|
501
|
+
authState: o,
|
|
502
|
+
handleLoginSuccess: D,
|
|
503
|
+
logout: y,
|
|
504
|
+
refreshUser: d,
|
|
505
|
+
getAccessToken: l
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
function Be() {
|
|
509
|
+
const e = we(ae);
|
|
510
|
+
if (!e)
|
|
511
|
+
throw new Error("useCedrosLogin must be used within a CedrosLoginProvider");
|
|
512
|
+
return e;
|
|
513
|
+
}
|
|
514
|
+
function de() {
|
|
515
|
+
return we(ae);
|
|
516
|
+
}
|
|
517
|
+
const Oe = {
|
|
518
|
+
mCost: 19456,
|
|
519
|
+
// 19 MiB
|
|
520
|
+
tCost: 2,
|
|
521
|
+
pCost: 1
|
|
522
|
+
};
|
|
523
|
+
function Pe(e) {
|
|
524
|
+
return e.length === 16;
|
|
525
|
+
}
|
|
526
|
+
function xe(e) {
|
|
527
|
+
if (e.length === 16) return !0;
|
|
528
|
+
if (e.length < 18) return !1;
|
|
529
|
+
const t = e[0];
|
|
530
|
+
return !(t !== 128 && t !== 8);
|
|
531
|
+
}
|
|
532
|
+
function Ye(e) {
|
|
533
|
+
return e.length === 32;
|
|
534
|
+
}
|
|
535
|
+
function ve(e) {
|
|
536
|
+
return e.length === 12;
|
|
537
|
+
}
|
|
538
|
+
function Te(e) {
|
|
539
|
+
return e.length >= 16;
|
|
540
|
+
}
|
|
541
|
+
function Re(e) {
|
|
542
|
+
return e.length === 32;
|
|
543
|
+
}
|
|
544
|
+
function Le(e) {
|
|
545
|
+
if (!Pe(e))
|
|
546
|
+
throw new Error(`Invalid seed length: expected 16, got ${e.length}`);
|
|
547
|
+
return e;
|
|
548
|
+
}
|
|
549
|
+
function qt(e) {
|
|
550
|
+
if (!xe(e))
|
|
551
|
+
throw new Error(`Invalid share length: expected >=16, got ${e.length}`);
|
|
552
|
+
return e;
|
|
553
|
+
}
|
|
554
|
+
function Ee(e) {
|
|
555
|
+
if (!Ye(e))
|
|
556
|
+
throw new Error(`Invalid key length: expected 32, got ${e.length}`);
|
|
557
|
+
return e;
|
|
558
|
+
}
|
|
559
|
+
function Xe(e) {
|
|
560
|
+
if (!ve(e))
|
|
561
|
+
throw new Error(`Invalid nonce length: expected 12, got ${e.length}`);
|
|
562
|
+
return e;
|
|
563
|
+
}
|
|
564
|
+
function We(e) {
|
|
565
|
+
if (!Te(e))
|
|
566
|
+
throw new Error(`Invalid salt length: expected >=16, got ${e.length}`);
|
|
567
|
+
return e;
|
|
568
|
+
}
|
|
569
|
+
function je(e) {
|
|
570
|
+
if (!Re(e))
|
|
571
|
+
throw new Error(`Invalid PRF salt length: expected 32, got ${e.length}`);
|
|
572
|
+
return e;
|
|
573
|
+
}
|
|
574
|
+
function x(e) {
|
|
575
|
+
return new Uint8Array(e);
|
|
576
|
+
}
|
|
577
|
+
function q(e) {
|
|
578
|
+
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
579
|
+
throw new Error(
|
|
580
|
+
"WebCrypto API not available. Secure random generation requires a modern browser."
|
|
581
|
+
);
|
|
582
|
+
const t = new Uint8Array(e);
|
|
583
|
+
return crypto.getRandomValues(t), t;
|
|
584
|
+
}
|
|
585
|
+
function _t() {
|
|
586
|
+
return Le(q(16));
|
|
587
|
+
}
|
|
588
|
+
function Ze() {
|
|
589
|
+
return Xe(q(12));
|
|
590
|
+
}
|
|
591
|
+
function $t() {
|
|
592
|
+
return We(q(16));
|
|
593
|
+
}
|
|
594
|
+
function qe() {
|
|
595
|
+
return je(q(32));
|
|
596
|
+
}
|
|
597
|
+
function pe(e) {
|
|
598
|
+
if (!(!e || e.length === 0)) {
|
|
599
|
+
e.fill(0);
|
|
600
|
+
for (let t = 0; t < e.length; t++)
|
|
601
|
+
e[t] = t * 90 & 255;
|
|
602
|
+
e.fill(0);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
function zt(...e) {
|
|
606
|
+
for (const t of e)
|
|
607
|
+
t && pe(t);
|
|
608
|
+
}
|
|
609
|
+
async function _e(e) {
|
|
610
|
+
return crypto.subtle.importKey(
|
|
611
|
+
"raw",
|
|
612
|
+
x(e),
|
|
613
|
+
{ name: "AES-GCM", length: 256 },
|
|
614
|
+
!1,
|
|
615
|
+
// not extractable
|
|
616
|
+
["encrypt", "decrypt"]
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
async function $e(e, t, A) {
|
|
620
|
+
const r = A ?? Ze(), n = await _e(t), i = await crypto.subtle.encrypt(
|
|
621
|
+
{ name: "AES-GCM", iv: x(r) },
|
|
622
|
+
n,
|
|
623
|
+
x(e)
|
|
624
|
+
);
|
|
625
|
+
return {
|
|
626
|
+
ciphertext: new Uint8Array(i),
|
|
627
|
+
nonce: r
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
async function eA(e, t) {
|
|
631
|
+
const A = await $e(e, t);
|
|
632
|
+
return {
|
|
633
|
+
ciphertext: Z(A.ciphertext),
|
|
634
|
+
nonce: Z(A.nonce)
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
function Z(e) {
|
|
638
|
+
const A = [];
|
|
639
|
+
for (let r = 0; r < e.length; r += 32768) {
|
|
640
|
+
const n = e.subarray(r, Math.min(r + 32768, e.length));
|
|
641
|
+
A.push(String.fromCharCode(...n));
|
|
642
|
+
}
|
|
643
|
+
return btoa(A.join(""));
|
|
644
|
+
}
|
|
645
|
+
function ze(e) {
|
|
646
|
+
let t;
|
|
647
|
+
try {
|
|
648
|
+
t = atob(e);
|
|
649
|
+
} catch {
|
|
650
|
+
throw new Error("Invalid base64 string: input is malformed or contains invalid characters");
|
|
651
|
+
}
|
|
652
|
+
const A = new Uint8Array(t.length);
|
|
653
|
+
for (let r = 0; r < t.length; r++)
|
|
654
|
+
A[r] = t.charCodeAt(r);
|
|
655
|
+
return A;
|
|
656
|
+
}
|
|
657
|
+
async function et(e, t, A, r = 32) {
|
|
658
|
+
const n = await crypto.subtle.importKey(
|
|
659
|
+
"raw",
|
|
660
|
+
x(e),
|
|
661
|
+
"HKDF",
|
|
662
|
+
!1,
|
|
663
|
+
["deriveBits"]
|
|
664
|
+
), i = new TextEncoder().encode(A), o = await crypto.subtle.deriveBits(
|
|
665
|
+
{
|
|
666
|
+
name: "HKDF",
|
|
667
|
+
hash: "SHA-256",
|
|
668
|
+
salt: x(t ?? new Uint8Array(32)),
|
|
669
|
+
// Zero salt if not provided
|
|
670
|
+
info: x(i)
|
|
671
|
+
},
|
|
672
|
+
n,
|
|
673
|
+
r * 8
|
|
674
|
+
// bits
|
|
675
|
+
);
|
|
676
|
+
return new Uint8Array(o);
|
|
677
|
+
}
|
|
678
|
+
async function tA(e, t) {
|
|
679
|
+
const A = await et(e, t, "cedros-wallet-share-b-encryption", 32);
|
|
680
|
+
return Ee(A);
|
|
681
|
+
}
|
|
682
|
+
async function tt() {
|
|
683
|
+
try {
|
|
684
|
+
const e = await crypto.subtle.importKey("raw", new Uint8Array(32), "HKDF", !1, [
|
|
685
|
+
"deriveBits"
|
|
686
|
+
]);
|
|
687
|
+
return await crypto.subtle.deriveBits(
|
|
688
|
+
{
|
|
689
|
+
name: "HKDF",
|
|
690
|
+
hash: "SHA-256",
|
|
691
|
+
salt: new Uint8Array(32),
|
|
692
|
+
info: new Uint8Array(0)
|
|
693
|
+
},
|
|
694
|
+
e,
|
|
695
|
+
256
|
|
696
|
+
), !0;
|
|
697
|
+
} catch {
|
|
698
|
+
return !1;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function Y(e, t, A, r) {
|
|
702
|
+
function n(i) {
|
|
703
|
+
return i instanceof A ? i : new A(function(o) {
|
|
704
|
+
o(i);
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
return new (A || (A = Promise))(function(i, o) {
|
|
708
|
+
function I(B) {
|
|
709
|
+
try {
|
|
710
|
+
w(r.next(B));
|
|
711
|
+
} catch (p) {
|
|
712
|
+
o(p);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
function c(B) {
|
|
716
|
+
try {
|
|
717
|
+
w(r.throw(B));
|
|
718
|
+
} catch (p) {
|
|
719
|
+
o(p);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
function w(B) {
|
|
723
|
+
B.done ? i(B.value) : n(B.value).then(I, c);
|
|
724
|
+
}
|
|
725
|
+
w((r = r.apply(e, [])).next());
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
class S {
|
|
729
|
+
constructor() {
|
|
730
|
+
this.mutex = Promise.resolve();
|
|
731
|
+
}
|
|
732
|
+
lock() {
|
|
733
|
+
let t = () => {
|
|
734
|
+
};
|
|
735
|
+
return this.mutex = this.mutex.then(() => new Promise(t)), new Promise((A) => {
|
|
736
|
+
t = A;
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
dispatch(t) {
|
|
740
|
+
return Y(this, void 0, void 0, function* () {
|
|
741
|
+
const A = yield this.lock();
|
|
742
|
+
try {
|
|
743
|
+
return yield Promise.resolve(t());
|
|
744
|
+
} finally {
|
|
745
|
+
A();
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
var ee;
|
|
751
|
+
function At() {
|
|
752
|
+
return typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global;
|
|
753
|
+
}
|
|
754
|
+
const oe = At(), te = (ee = oe.Buffer) !== null && ee !== void 0 ? ee : null, rt = oe.TextEncoder ? new oe.TextEncoder() : null;
|
|
755
|
+
function ye(e, t) {
|
|
756
|
+
return (e & 15) + (e >> 6 | e >> 3 & 8) << 4 | (t & 15) + (t >> 6 | t >> 3 & 8);
|
|
757
|
+
}
|
|
758
|
+
function ke(e, t) {
|
|
759
|
+
const A = t.length >> 1;
|
|
760
|
+
for (let r = 0; r < A; r++) {
|
|
761
|
+
const n = r << 1;
|
|
762
|
+
e[r] = ye(t.charCodeAt(n), t.charCodeAt(n + 1));
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
function it(e, t) {
|
|
766
|
+
if (e.length !== t.length * 2)
|
|
767
|
+
return !1;
|
|
768
|
+
for (let A = 0; A < t.length; A++) {
|
|
769
|
+
const r = A << 1;
|
|
770
|
+
if (t[A] !== ye(e.charCodeAt(r), e.charCodeAt(r + 1)))
|
|
771
|
+
return !1;
|
|
772
|
+
}
|
|
773
|
+
return !0;
|
|
774
|
+
}
|
|
775
|
+
const le = 87, he = 48;
|
|
776
|
+
function se(e, t, A) {
|
|
777
|
+
let r = 0;
|
|
778
|
+
for (let n = 0; n < A; n++) {
|
|
779
|
+
let i = t[n] >>> 4;
|
|
780
|
+
e[r++] = i > 9 ? i + le : i + he, i = t[n] & 15, e[r++] = i > 9 ? i + le : i + he;
|
|
781
|
+
}
|
|
782
|
+
return String.fromCharCode.apply(null, e);
|
|
783
|
+
}
|
|
784
|
+
const M = te !== null ? (e) => {
|
|
785
|
+
if (typeof e == "string") {
|
|
786
|
+
const t = te.from(e, "utf8");
|
|
787
|
+
return new Uint8Array(t.buffer, t.byteOffset, t.length);
|
|
788
|
+
}
|
|
789
|
+
if (te.isBuffer(e))
|
|
790
|
+
return new Uint8Array(e.buffer, e.byteOffset, e.length);
|
|
791
|
+
if (ArrayBuffer.isView(e))
|
|
792
|
+
return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
793
|
+
throw new Error("Invalid data type!");
|
|
794
|
+
} : (e) => {
|
|
795
|
+
if (typeof e == "string")
|
|
796
|
+
return rt.encode(e);
|
|
797
|
+
if (ArrayBuffer.isView(e))
|
|
798
|
+
return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
799
|
+
throw new Error("Invalid data type!");
|
|
800
|
+
}, G = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", T = new Uint8Array(256);
|
|
801
|
+
for (let e = 0; e < G.length; e++)
|
|
802
|
+
T[G.charCodeAt(e)] = e;
|
|
803
|
+
function Ce(e, t = !0) {
|
|
804
|
+
const A = e.length, r = A % 3, n = [], i = A - r;
|
|
805
|
+
for (let o = 0; o < i; o += 3) {
|
|
806
|
+
const I = (e[o] << 16 & 16711680) + (e[o + 1] << 8 & 65280) + (e[o + 2] & 255), c = G.charAt(I >> 18 & 63) + G.charAt(I >> 12 & 63) + G.charAt(I >> 6 & 63) + G.charAt(I & 63);
|
|
807
|
+
n.push(c);
|
|
808
|
+
}
|
|
809
|
+
if (r === 1) {
|
|
810
|
+
const o = e[A - 1], I = G.charAt(o >> 2), c = G.charAt(o << 4 & 63);
|
|
811
|
+
n.push(`${I}${c}`), t && n.push("==");
|
|
812
|
+
} else if (r === 2) {
|
|
813
|
+
const o = (e[A - 2] << 8) + e[A - 1], I = G.charAt(o >> 10), c = G.charAt(o >> 4 & 63), w = G.charAt(o << 2 & 63);
|
|
814
|
+
n.push(`${I}${c}${w}`), t && n.push("=");
|
|
815
|
+
}
|
|
816
|
+
return n.join("");
|
|
817
|
+
}
|
|
818
|
+
function nt(e) {
|
|
819
|
+
let t = Math.floor(e.length * 0.75);
|
|
820
|
+
const A = e.length;
|
|
821
|
+
return e[A - 1] === "=" && (t -= 1, e[A - 2] === "=" && (t -= 1)), t;
|
|
822
|
+
}
|
|
823
|
+
function ot(e) {
|
|
824
|
+
const t = nt(e), A = e.length, r = new Uint8Array(t);
|
|
825
|
+
let n = 0;
|
|
826
|
+
for (let i = 0; i < A; i += 4) {
|
|
827
|
+
const o = T[e.charCodeAt(i)], I = T[e.charCodeAt(i + 1)], c = T[e.charCodeAt(i + 2)], w = T[e.charCodeAt(i + 3)];
|
|
828
|
+
r[n] = o << 2 | I >> 4, n += 1, r[n] = (I & 15) << 4 | c >> 2, n += 1, r[n] = (c & 3) << 6 | w & 63, n += 1;
|
|
829
|
+
}
|
|
830
|
+
return r;
|
|
831
|
+
}
|
|
832
|
+
const W = 16 * 1024, v = 4, st = new S(), Ae = /* @__PURE__ */ new Map();
|
|
833
|
+
function Se(e, t) {
|
|
834
|
+
return Y(this, void 0, void 0, function* () {
|
|
835
|
+
let A = null, r = null, n = !1;
|
|
836
|
+
if (typeof WebAssembly > "u")
|
|
837
|
+
throw new Error("WebAssembly is not supported in this environment!");
|
|
838
|
+
const i = (l, s = 0) => {
|
|
839
|
+
r.set(l, s);
|
|
840
|
+
}, o = () => r, I = () => A.exports, c = (l) => {
|
|
841
|
+
A.exports.Hash_SetMemorySize(l);
|
|
842
|
+
const s = A.exports.Hash_GetBuffer(), E = A.exports.memory.buffer;
|
|
843
|
+
r = new Uint8Array(E, s, l);
|
|
844
|
+
}, w = () => new DataView(A.exports.memory.buffer).getUint32(A.exports.STATE_SIZE, !0), B = st.dispatch(() => Y(this, void 0, void 0, function* () {
|
|
845
|
+
if (!Ae.has(e.name)) {
|
|
846
|
+
const s = ot(e.data), E = WebAssembly.compile(s);
|
|
847
|
+
Ae.set(e.name, E);
|
|
848
|
+
}
|
|
849
|
+
const l = yield Ae.get(e.name);
|
|
850
|
+
A = yield WebAssembly.instantiate(l, {
|
|
851
|
+
// env: {
|
|
852
|
+
// emscripten_memcpy_big: (dest, src, num) => {
|
|
853
|
+
// const memoryBuffer = wasmInstance.exports.memory.buffer;
|
|
854
|
+
// const memView = new Uint8Array(memoryBuffer, 0);
|
|
855
|
+
// memView.set(memView.subarray(src, src + num), dest);
|
|
856
|
+
// },
|
|
857
|
+
// print_memory: (offset, len) => {
|
|
858
|
+
// const memoryBuffer = wasmInstance.exports.memory.buffer;
|
|
859
|
+
// const memView = new Uint8Array(memoryBuffer, 0);
|
|
860
|
+
// console.log('print_int32', memView.subarray(offset, offset + len));
|
|
861
|
+
// },
|
|
862
|
+
// },
|
|
863
|
+
});
|
|
864
|
+
})), p = () => Y(this, void 0, void 0, function* () {
|
|
865
|
+
A || (yield B);
|
|
866
|
+
const l = A.exports.Hash_GetBuffer(), s = A.exports.memory.buffer;
|
|
867
|
+
r = new Uint8Array(s, l, W);
|
|
868
|
+
}), f = (l = null) => {
|
|
869
|
+
n = !0, A.exports.Hash_Init(l);
|
|
870
|
+
}, Q = (l) => {
|
|
871
|
+
let s = 0;
|
|
872
|
+
for (; s < l.length; ) {
|
|
873
|
+
const E = l.subarray(s, s + W);
|
|
874
|
+
s += E.length, r.set(E), A.exports.Hash_Update(E.length);
|
|
875
|
+
}
|
|
876
|
+
}, u = (l) => {
|
|
877
|
+
if (!n)
|
|
878
|
+
throw new Error("update() called before init()");
|
|
879
|
+
const s = M(l);
|
|
880
|
+
Q(s);
|
|
881
|
+
}, h = new Uint8Array(t * 2), a = (l, s = null) => {
|
|
882
|
+
if (!n)
|
|
883
|
+
throw new Error("digest() called before init()");
|
|
884
|
+
return n = !1, A.exports.Hash_Final(s), l === "binary" ? r.slice(0, t) : se(h, r, t);
|
|
885
|
+
}, g = () => {
|
|
886
|
+
if (!n)
|
|
887
|
+
throw new Error("save() can only be called after init() and before digest()");
|
|
888
|
+
const l = A.exports.Hash_GetState(), s = w(), E = A.exports.memory.buffer, F = new Uint8Array(E, l, s), b = new Uint8Array(v + s);
|
|
889
|
+
return ke(b, e.hash), b.set(F, v), b;
|
|
890
|
+
}, C = (l) => {
|
|
891
|
+
if (!(l instanceof Uint8Array))
|
|
892
|
+
throw new Error("load() expects an Uint8Array generated by save()");
|
|
893
|
+
const s = A.exports.Hash_GetState(), E = w(), F = v + E, b = A.exports.memory.buffer;
|
|
894
|
+
if (l.length !== F)
|
|
895
|
+
throw new Error(`Bad state length (expected ${F} bytes, got ${l.length})`);
|
|
896
|
+
if (!it(e.hash, l.subarray(0, v)))
|
|
897
|
+
throw new Error("This state was written by an incompatible hash implementation");
|
|
898
|
+
const N = l.subarray(v);
|
|
899
|
+
new Uint8Array(b, s, E).set(N), n = !0;
|
|
900
|
+
}, d = (l) => typeof l == "string" ? l.length < W / 4 : l.byteLength < W;
|
|
901
|
+
let D = d;
|
|
902
|
+
switch (e.name) {
|
|
903
|
+
case "argon2":
|
|
904
|
+
case "scrypt":
|
|
905
|
+
D = () => !0;
|
|
906
|
+
break;
|
|
907
|
+
case "blake2b":
|
|
908
|
+
case "blake2s":
|
|
909
|
+
D = (l, s) => s <= 512 && d(l);
|
|
910
|
+
break;
|
|
911
|
+
case "blake3":
|
|
912
|
+
D = (l, s) => s === 0 && d(l);
|
|
913
|
+
break;
|
|
914
|
+
case "xxhash64":
|
|
915
|
+
// cannot simplify
|
|
916
|
+
case "xxhash3":
|
|
917
|
+
case "xxhash128":
|
|
918
|
+
case "crc64":
|
|
919
|
+
D = () => !1;
|
|
920
|
+
break;
|
|
921
|
+
}
|
|
922
|
+
const y = (l, s = null, E = null) => {
|
|
923
|
+
if (!D(l, s))
|
|
924
|
+
return f(s), u(l), a("hex", E);
|
|
925
|
+
const F = M(l);
|
|
926
|
+
return r.set(F), A.exports.Hash_Calculate(F.length, s, E), se(h, r, t);
|
|
927
|
+
};
|
|
928
|
+
return yield p(), {
|
|
929
|
+
getMemory: o,
|
|
930
|
+
writeMemory: i,
|
|
931
|
+
getExports: I,
|
|
932
|
+
setMemorySize: c,
|
|
933
|
+
init: f,
|
|
934
|
+
update: u,
|
|
935
|
+
digest: a,
|
|
936
|
+
save: g,
|
|
937
|
+
load: C,
|
|
938
|
+
calculate: y,
|
|
939
|
+
hashLength: t
|
|
940
|
+
};
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
new S();
|
|
944
|
+
var It = "argon2", at = "AGFzbQEAAAABKQVgAX8Bf2AAAX9gEH9/f39/f39/f39/f39/f38AYAR/f39/AGACf38AAwYFAAECAwQFBgEBAoCAAgYIAX8BQZCoBAsHQQQGbWVtb3J5AgASSGFzaF9TZXRNZW1vcnlTaXplAAAOSGFzaF9HZXRCdWZmZXIAAQ5IYXNoX0NhbGN1bGF0ZQAECvEyBVgBAn9BACEBAkAgAEEAKAKICCICRg0AAkAgACACayIAQRB2IABBgIB8cSAASWoiAEAAQX9HDQBB/wHADwtBACEBQQBBACkDiAggAEEQdK18NwOICAsgAcALcAECfwJAQQAoAoAIIgANAEEAPwBBEHQiADYCgAhBACgCiAgiAUGAgCBGDQACQEGAgCAgAWsiAEEQdiAAQYCAfHEgAElqIgBAAEF/Rw0AQQAPC0EAQQApA4gIIABBEHStfDcDiAhBACgCgAghAAsgAAvcDgECfiAAIAQpAwAiECAAKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAMIBAgDCkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgBCAQIAQpAwCFQiiJIhA3AwAgACAQIAApAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAwgECAMKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAEIBAgBCkDAIVCAYk3AwAgASAFKQMAIhAgASkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDSAQIA0pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAEgECABKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACANIBAgDSkDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAIgBikDACIQIAIpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIA4gECAOKQMAhUIgiSIQNwMAIAogECAKKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACACIBAgAikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDiAQIA4pAwCFQjCJIhA3AwAgCiAQIAopAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACADIAcpAwAiECADKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAPIBAgDykDAIVCIIkiEDcDACALIBAgCykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAyAQIAMpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA8gECAPKQMAhUIwiSIQNwMAIAsgECALKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgACAFKQMAIhAgACkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDyAQIA8pAwCFQiCJIhA3AwAgCiAQIAopAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAAgECAAKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAPIBAgDykDAIVCMIkiEDcDACAKIBAgCikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAEgBikDACIQIAEpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAwgECAMKQMAhUIgiSIQNwMAIAsgECALKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACABIBAgASkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDCAQIAwpAwCFQjCJIhA3AwAgCyAQIAspAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACACIAcpAwAiECACKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACANIBAgDSkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAiAQIAIpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA0gECANKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgAyAEKQMAIhAgAykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDiAQIA4pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAQgECAEKQMAhUIoiSIQNwMAIAMgECADKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAOIBAgDikDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBCAQIAQpAwCFQgGJNwMAC98aAQN/QQAhBEEAIAIpAwAgASkDAIU3A5AIQQAgAikDCCABKQMIhTcDmAhBACACKQMQIAEpAxCFNwOgCEEAIAIpAxggASkDGIU3A6gIQQAgAikDICABKQMghTcDsAhBACACKQMoIAEpAyiFNwO4CEEAIAIpAzAgASkDMIU3A8AIQQAgAikDOCABKQM4hTcDyAhBACACKQNAIAEpA0CFNwPQCEEAIAIpA0ggASkDSIU3A9gIQQAgAikDUCABKQNQhTcD4AhBACACKQNYIAEpA1iFNwPoCEEAIAIpA2AgASkDYIU3A/AIQQAgAikDaCABKQNohTcD+AhBACACKQNwIAEpA3CFNwOACUEAIAIpA3ggASkDeIU3A4gJQQAgAikDgAEgASkDgAGF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BQQBBACkDmIsBQp/Y+dnCkdqCm3+FNwOoiQFBAEEAKQOgiwFC6/qG2r+19sEfhTcDsIkBQQBBACkDqIsBQvnC+JuRo7Pw2wCFNwO4iQFBACADp0H/AXE2AuSKAQJAIAFBAUgNACACQgA3A3ggAkIANwNwIAJCADcDaCACQgA3A2AgAkIANwNYIAJCADcDUCACQgA3A0ggAkIANwNAIAJCADcDOCACQgA3AzAgAkIANwMoIAJCADcDICACQgA3AxggAkIANwMQIAJCADcDCCACQgA3AwBBACEEA0AgAiAAaiAAQYAJai0AADoAACAAQQFqIQAgBEEBaiIEQf8BcSABSA0ACyACQYABEAELIAJBgAFqJAALEgAgAEEDdkH/P3EgAEEQdhAECwkAQYAJIAAQAQsGAEGAiQELGwAgAUEDdkH/P3EgAUEQdhAEQYAJIAAQARADCwsLAQBBgAgLBPAAAAA=", Ct = "c6f286e6", ut = {
|
|
949
|
+
name: lt,
|
|
950
|
+
data: ht,
|
|
951
|
+
hash: Ct
|
|
952
|
+
};
|
|
953
|
+
new S();
|
|
954
|
+
function ue(e) {
|
|
955
|
+
return !Number.isInteger(e) || e < 8 || e > 512 || e % 8 !== 0 ? new Error("Invalid variant! Valid values: 8, 16, ..., 512") : null;
|
|
956
|
+
}
|
|
957
|
+
function ft(e, t) {
|
|
958
|
+
return e | t << 16;
|
|
959
|
+
}
|
|
960
|
+
function Ie(e = 512, t = null) {
|
|
961
|
+
if (ue(e))
|
|
962
|
+
return Promise.reject(ue(e));
|
|
963
|
+
let A = null, r = e;
|
|
964
|
+
if (t !== null) {
|
|
965
|
+
if (A = M(t), A.length > 64)
|
|
966
|
+
return Promise.reject(new Error("Max key length is 64 bytes"));
|
|
967
|
+
r = ft(e, A.length);
|
|
968
|
+
}
|
|
969
|
+
const n = e / 8;
|
|
970
|
+
return Se(ut, n).then((i) => {
|
|
971
|
+
r > 512 && i.writeMemory(A), i.init(r);
|
|
972
|
+
const o = {
|
|
973
|
+
init: r > 512 ? () => (i.writeMemory(A), i.init(r), o) : () => (i.init(r), o),
|
|
974
|
+
update: (I) => (i.update(I), o),
|
|
975
|
+
// biome-ignore lint/suspicious/noExplicitAny: Conflict with IHasher type
|
|
976
|
+
digest: (I) => i.digest(I),
|
|
977
|
+
save: () => i.save(),
|
|
978
|
+
load: (I) => (i.load(I), o),
|
|
979
|
+
blockSize: 128,
|
|
980
|
+
digestSize: n
|
|
981
|
+
};
|
|
982
|
+
return o;
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
function wt(e, t, A) {
|
|
986
|
+
const r = [
|
|
987
|
+
`m=${t.memorySize}`,
|
|
988
|
+
`t=${t.iterations}`,
|
|
989
|
+
`p=${t.parallelism}`
|
|
990
|
+
].join(",");
|
|
991
|
+
return `$argon2${t.hashType}$v=19$${r}$${Ce(e, !1)}$${Ce(A, !1)}`;
|
|
992
|
+
}
|
|
993
|
+
const fe = new DataView(new ArrayBuffer(4));
|
|
994
|
+
function J(e) {
|
|
995
|
+
return fe.setInt32(0, e, !0), new Uint8Array(fe.buffer);
|
|
996
|
+
}
|
|
997
|
+
function re(e, t, A) {
|
|
998
|
+
return Y(this, void 0, void 0, function* () {
|
|
999
|
+
if (A <= 64) {
|
|
1000
|
+
const c = yield Ie(A * 8);
|
|
1001
|
+
return c.update(J(A)), c.update(t), c.digest("binary");
|
|
1002
|
+
}
|
|
1003
|
+
const r = Math.ceil(A / 32) - 2, n = new Uint8Array(A);
|
|
1004
|
+
e.init(), e.update(J(A)), e.update(t);
|
|
1005
|
+
let i = e.digest("binary");
|
|
1006
|
+
n.set(i.subarray(0, 32), 0);
|
|
1007
|
+
for (let c = 1; c < r; c++)
|
|
1008
|
+
e.init(), e.update(i), i = e.digest("binary"), n.set(i.subarray(0, 32), c * 32);
|
|
1009
|
+
const o = A - 32 * r;
|
|
1010
|
+
let I;
|
|
1011
|
+
return o === 64 ? (I = e, I.init()) : I = yield Ie(o * 8), I.update(i), i = I.digest("binary"), n.set(i.subarray(0, o), r * 32), n;
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
function Qt(e) {
|
|
1015
|
+
switch (e) {
|
|
1016
|
+
case "d":
|
|
1017
|
+
return 0;
|
|
1018
|
+
case "i":
|
|
1019
|
+
return 1;
|
|
1020
|
+
default:
|
|
1021
|
+
return 2;
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
function Bt(e) {
|
|
1025
|
+
return Y(this, void 0, void 0, function* () {
|
|
1026
|
+
var t;
|
|
1027
|
+
const { parallelism: A, iterations: r, hashLength: n } = e, i = M(e.password), o = M(e.salt), I = 19, c = Qt(e.hashType), { memorySize: w } = e, B = M((t = e.secret) !== null && t !== void 0 ? t : ""), [p, f] = yield Promise.all([
|
|
1028
|
+
Se(ct, 1024),
|
|
1029
|
+
Ie(512)
|
|
1030
|
+
]);
|
|
1031
|
+
p.setMemorySize(w * 1024 + 1024);
|
|
1032
|
+
const Q = new Uint8Array(24), u = new DataView(Q.buffer);
|
|
1033
|
+
u.setInt32(0, A, !0), u.setInt32(4, n, !0), u.setInt32(8, w, !0), u.setInt32(12, r, !0), u.setInt32(16, I, !0), u.setInt32(20, c, !0), p.writeMemory(Q, w * 1024), f.init(), f.update(Q), f.update(J(i.length)), f.update(i), f.update(J(o.length)), f.update(o), f.update(J(B.length)), f.update(B), f.update(J(0));
|
|
1034
|
+
const a = Math.floor(w / (A * 4)) * 4, g = new Uint8Array(72), C = f.digest("binary");
|
|
1035
|
+
g.set(C);
|
|
1036
|
+
for (let y = 0; y < A; y++) {
|
|
1037
|
+
g.set(J(0), 64), g.set(J(y), 68);
|
|
1038
|
+
let l = y * a, s = yield re(f, g, 1024);
|
|
1039
|
+
p.writeMemory(s, l * 1024), l += 1, g.set(J(1), 64), s = yield re(f, g, 1024), p.writeMemory(s, l * 1024);
|
|
1040
|
+
}
|
|
1041
|
+
const d = new Uint8Array(1024);
|
|
1042
|
+
ke(d, p.calculate(new Uint8Array([]), w));
|
|
1043
|
+
const D = yield re(f, d, n);
|
|
1044
|
+
if (e.outputType === "hex") {
|
|
1045
|
+
const y = new Uint8Array(n * 2);
|
|
1046
|
+
return se(y, D, n);
|
|
1047
|
+
}
|
|
1048
|
+
return e.outputType === "encoded" ? wt(o, e, D) : D;
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
const dt = (e) => {
|
|
1052
|
+
var t;
|
|
1053
|
+
if (!e || typeof e != "object")
|
|
1054
|
+
throw new Error("Invalid options parameter. It requires an object.");
|
|
1055
|
+
if (!e.password)
|
|
1056
|
+
throw new Error("Password must be specified");
|
|
1057
|
+
if (e.password = M(e.password), e.password.length < 1)
|
|
1058
|
+
throw new Error("Password must be specified");
|
|
1059
|
+
if (!e.salt)
|
|
1060
|
+
throw new Error("Salt must be specified");
|
|
1061
|
+
if (e.salt = M(e.salt), e.salt.length < 8)
|
|
1062
|
+
throw new Error("Salt should be at least 8 bytes long");
|
|
1063
|
+
if (e.secret = M((t = e.secret) !== null && t !== void 0 ? t : ""), !Number.isInteger(e.iterations) || e.iterations < 1)
|
|
1064
|
+
throw new Error("Iterations should be a positive number");
|
|
1065
|
+
if (!Number.isInteger(e.parallelism) || e.parallelism < 1)
|
|
1066
|
+
throw new Error("Parallelism should be a positive number");
|
|
1067
|
+
if (!Number.isInteger(e.hashLength) || e.hashLength < 4)
|
|
1068
|
+
throw new Error("Hash length should be at least 4 bytes.");
|
|
1069
|
+
if (!Number.isInteger(e.memorySize))
|
|
1070
|
+
throw new Error("Memory size should be specified.");
|
|
1071
|
+
if (e.memorySize < 8 * e.parallelism)
|
|
1072
|
+
throw new Error("Memory size should be at least 8 * parallelism.");
|
|
1073
|
+
if (e.outputType === void 0 && (e.outputType = "hex"), !["hex", "binary", "encoded"].includes(e.outputType))
|
|
1074
|
+
throw new Error(`Insupported output type ${e.outputType}. Valid values: ['hex', 'binary', 'encoded']`);
|
|
1075
|
+
};
|
|
1076
|
+
function De(e) {
|
|
1077
|
+
return Y(this, void 0, void 0, function* () {
|
|
1078
|
+
return dt(e), Bt(Object.assign(Object.assign({}, e), { hashType: "id" }));
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
new S();
|
|
1082
|
+
new S();
|
|
1083
|
+
new S();
|
|
1084
|
+
new S();
|
|
1085
|
+
new S();
|
|
1086
|
+
new S();
|
|
1087
|
+
new S();
|
|
1088
|
+
new S();
|
|
1089
|
+
new S();
|
|
1090
|
+
new S();
|
|
1091
|
+
new S();
|
|
1092
|
+
new S();
|
|
1093
|
+
new S();
|
|
1094
|
+
new S();
|
|
1095
|
+
new S();
|
|
1096
|
+
new S();
|
|
1097
|
+
new S();
|
|
1098
|
+
new S();
|
|
1099
|
+
new S();
|
|
1100
|
+
new S();
|
|
1101
|
+
const Et = 32;
|
|
1102
|
+
async function AA(e, t, A = Oe) {
|
|
1103
|
+
pt(A);
|
|
1104
|
+
try {
|
|
1105
|
+
const r = await De({
|
|
1106
|
+
password: e,
|
|
1107
|
+
salt: t,
|
|
1108
|
+
iterations: A.tCost,
|
|
1109
|
+
memorySize: A.mCost,
|
|
1110
|
+
parallelism: A.pCost,
|
|
1111
|
+
hashLength: Et,
|
|
1112
|
+
outputType: "binary"
|
|
1113
|
+
});
|
|
1114
|
+
return Ee(r);
|
|
1115
|
+
} catch {
|
|
1116
|
+
throw new Error("Key derivation failed");
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
function pt(e) {
|
|
1120
|
+
if (e.mCost < 16384)
|
|
1121
|
+
throw new Error("KDF memory cost too low (minimum 16 MiB)");
|
|
1122
|
+
if (e.mCost > 1048576)
|
|
1123
|
+
throw new Error("KDF memory cost too high (maximum 1 GiB)");
|
|
1124
|
+
if (e.tCost < 1)
|
|
1125
|
+
throw new Error("KDF time cost must be at least 1");
|
|
1126
|
+
if (e.tCost > 10)
|
|
1127
|
+
throw new Error("KDF time cost too high (maximum 10)");
|
|
1128
|
+
if (e.pCost < 1)
|
|
1129
|
+
throw new Error("KDF parallelism must be at least 1");
|
|
1130
|
+
if (e.pCost > 4)
|
|
1131
|
+
throw new Error("KDF parallelism too high (maximum 4)");
|
|
1132
|
+
}
|
|
1133
|
+
async function yt() {
|
|
1134
|
+
try {
|
|
1135
|
+
const e = await De({
|
|
1136
|
+
password: "test",
|
|
1137
|
+
salt: new Uint8Array(16),
|
|
1138
|
+
iterations: 1,
|
|
1139
|
+
memorySize: 1024,
|
|
1140
|
+
// 1 MiB for quick test
|
|
1141
|
+
parallelism: 1,
|
|
1142
|
+
hashLength: 32,
|
|
1143
|
+
outputType: "binary"
|
|
1144
|
+
});
|
|
1145
|
+
return e.length !== 32 ? !1 : (pe(e), !0);
|
|
1146
|
+
} catch {
|
|
1147
|
+
return !1;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
function kt(e) {
|
|
1151
|
+
return e === "localhost" || e === "127.0.0.1" || e.endsWith(".localhost");
|
|
1152
|
+
}
|
|
1153
|
+
function Fe(e) {
|
|
1154
|
+
if (typeof window > "u")
|
|
1155
|
+
return;
|
|
1156
|
+
const t = window.location.hostname;
|
|
1157
|
+
if (!kt(t)) {
|
|
1158
|
+
console.warn(
|
|
1159
|
+
"[Cedros] SEC-004: WebAuthn RP domain validation not configured. In production, set wallet.allowedRpDomains to prevent passkey phishing."
|
|
1160
|
+
);
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
function _() {
|
|
1165
|
+
return typeof window < "u" && typeof window.PublicKeyCredential < "u" && typeof navigator.credentials < "u";
|
|
1166
|
+
}
|
|
1167
|
+
async function St() {
|
|
1168
|
+
if (!_())
|
|
1169
|
+
return !1;
|
|
1170
|
+
try {
|
|
1171
|
+
if (!await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable())
|
|
1172
|
+
return !1;
|
|
1173
|
+
if ("getClientCapabilities" in PublicKeyCredential && typeof PublicKeyCredential.getClientCapabilities == "function") {
|
|
1174
|
+
const t = await PublicKeyCredential.getClientCapabilities();
|
|
1175
|
+
if (t && "prf" in t)
|
|
1176
|
+
return t.prf === !0;
|
|
1177
|
+
}
|
|
1178
|
+
return !0;
|
|
1179
|
+
} catch {
|
|
1180
|
+
return !1;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
async function rA(e, t, A, r, n) {
|
|
1184
|
+
if (!_())
|
|
1185
|
+
throw new Error("WebAuthn is not available in this browser");
|
|
1186
|
+
Fe();
|
|
1187
|
+
const i = r ?? qe(), o = await navigator.credentials.create({
|
|
1188
|
+
publicKey: {
|
|
1189
|
+
challenge: crypto.getRandomValues(new Uint8Array(32)),
|
|
1190
|
+
rp: {
|
|
1191
|
+
name: "Cedros Wallet",
|
|
1192
|
+
id: window.location.hostname
|
|
1193
|
+
},
|
|
1194
|
+
user: {
|
|
1195
|
+
id: x(e),
|
|
1196
|
+
name: t,
|
|
1197
|
+
displayName: A
|
|
1198
|
+
},
|
|
1199
|
+
pubKeyCredParams: [
|
|
1200
|
+
{ type: "public-key", alg: -7 },
|
|
1201
|
+
// ES256
|
|
1202
|
+
{ type: "public-key", alg: -257 }
|
|
1203
|
+
// RS256
|
|
1204
|
+
],
|
|
1205
|
+
authenticatorSelection: {
|
|
1206
|
+
authenticatorAttachment: "platform",
|
|
1207
|
+
userVerification: "required",
|
|
1208
|
+
residentKey: "required"
|
|
1209
|
+
},
|
|
1210
|
+
timeout: 6e4,
|
|
1211
|
+
attestation: "none",
|
|
1212
|
+
extensions: {
|
|
1213
|
+
prf: {
|
|
1214
|
+
eval: {
|
|
1215
|
+
first: i
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
});
|
|
1221
|
+
if (!o)
|
|
1222
|
+
throw new Error("Passkey registration was cancelled");
|
|
1223
|
+
const I = o.getClientExtensionResults();
|
|
1224
|
+
if (!I.prf?.enabled || !I.prf?.results?.first)
|
|
1225
|
+
throw new Error(
|
|
1226
|
+
"PRF extension is not supported by this authenticator. Please use a device with a compatible platform authenticator."
|
|
1227
|
+
);
|
|
1228
|
+
const c = I.prf?.results?.first;
|
|
1229
|
+
if (!c)
|
|
1230
|
+
throw new Error("PRF extension did not return a result");
|
|
1231
|
+
const w = new Uint8Array(c);
|
|
1232
|
+
if (w.length !== 32)
|
|
1233
|
+
throw new Error(
|
|
1234
|
+
`Unexpected PRF output length: expected 32 bytes, got ${w.length}. The authenticator may not be compatible.`
|
|
1235
|
+
);
|
|
1236
|
+
return {
|
|
1237
|
+
credentialId: Z(new Uint8Array(o.rawId)),
|
|
1238
|
+
prfSalt: Z(i),
|
|
1239
|
+
prfOutput: w
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
async function iA(e, t) {
|
|
1243
|
+
if (!_())
|
|
1244
|
+
throw new Error("WebAuthn is not available in this browser");
|
|
1245
|
+
Fe();
|
|
1246
|
+
const A = ze(e), r = await navigator.credentials.get({
|
|
1247
|
+
publicKey: {
|
|
1248
|
+
challenge: crypto.getRandomValues(new Uint8Array(32)),
|
|
1249
|
+
rpId: window.location.hostname,
|
|
1250
|
+
// Empty allowCredentials lets browser show all discoverable credentials
|
|
1251
|
+
allowCredentials: [],
|
|
1252
|
+
userVerification: "required",
|
|
1253
|
+
timeout: 6e4,
|
|
1254
|
+
extensions: {
|
|
1255
|
+
prf: {
|
|
1256
|
+
eval: {
|
|
1257
|
+
first: A
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
if (!r)
|
|
1264
|
+
throw new Error("Passkey authentication was cancelled");
|
|
1265
|
+
const i = r.getClientExtensionResults().prf?.results?.first;
|
|
1266
|
+
if (!i)
|
|
1267
|
+
throw new Error("PRF extension did not return a result during authentication");
|
|
1268
|
+
return {
|
|
1269
|
+
prfOutput: new Uint8Array(i)
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
async function Dt() {
|
|
1273
|
+
const [e, t, A, r, n, i, o] = await Promise.all([
|
|
1274
|
+
Ft(),
|
|
1275
|
+
Ut(),
|
|
1276
|
+
tt(),
|
|
1277
|
+
mt(),
|
|
1278
|
+
Promise.resolve(_()),
|
|
1279
|
+
St(),
|
|
1280
|
+
yt()
|
|
1281
|
+
]);
|
|
1282
|
+
return {
|
|
1283
|
+
webCrypto: e,
|
|
1284
|
+
aesGcm: t,
|
|
1285
|
+
hkdf: A,
|
|
1286
|
+
ed25519: r,
|
|
1287
|
+
webAuthn: n,
|
|
1288
|
+
webAuthnPrf: i,
|
|
1289
|
+
argon2: o,
|
|
1290
|
+
allSupported: e && t && A && n && i && o
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
async function Ft() {
|
|
1294
|
+
try {
|
|
1295
|
+
return typeof crypto < "u" && typeof crypto.subtle < "u" && typeof crypto.getRandomValues == "function";
|
|
1296
|
+
} catch {
|
|
1297
|
+
return !1;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
async function Ut() {
|
|
1301
|
+
try {
|
|
1302
|
+
const e = await crypto.subtle.generateKey({ name: "AES-GCM", length: 256 }, !1, [
|
|
1303
|
+
"encrypt",
|
|
1304
|
+
"decrypt"
|
|
1305
|
+
]), t = new Uint8Array([1, 2, 3, 4]), A = crypto.getRandomValues(new Uint8Array(12)), r = await crypto.subtle.encrypt({ name: "AES-GCM", iv: A }, e, t), n = await crypto.subtle.decrypt({ name: "AES-GCM", iv: A }, e, r), i = new Uint8Array(n);
|
|
1306
|
+
return i.length === t.length && i.every((o, I) => o === t[I]);
|
|
1307
|
+
} catch {
|
|
1308
|
+
return !1;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
async function mt() {
|
|
1312
|
+
try {
|
|
1313
|
+
return await crypto.subtle.generateKey("Ed25519", !1, ["sign", "verify"]), !0;
|
|
1314
|
+
} catch {
|
|
1315
|
+
return !1;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
function nA(e) {
|
|
1319
|
+
if (e.allSupported)
|
|
1320
|
+
return null;
|
|
1321
|
+
const t = [];
|
|
1322
|
+
return e.webCrypto || t.push("Web Crypto API"), e.aesGcm || t.push("AES-GCM encryption"), e.hkdf || t.push("HKDF key derivation"), e.webAuthn || t.push("WebAuthn/Passkeys"), e.webAuthnPrf || t.push("WebAuthn PRF extension (requires platform authenticator)"), e.argon2 || t.push("Argon2 password hashing"), t.length === 0 ? null : `Your browser or device is missing required features: ${t.join(", ")}. Please use a modern browser with a platform authenticator (e.g., Touch ID, Face ID, Windows Hello).`;
|
|
1323
|
+
}
|
|
1324
|
+
function oA() {
|
|
1325
|
+
const e = typeof navigator < "u" ? navigator.userAgent : "", t = e.match(/Chrome\/(\d+)/);
|
|
1326
|
+
if (t) {
|
|
1327
|
+
const i = parseInt(t[1], 10);
|
|
1328
|
+
return {
|
|
1329
|
+
browser: "Chrome",
|
|
1330
|
+
version: t[1],
|
|
1331
|
+
likelySupported: i >= 116
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
const A = e.match(/Version\/(\d+)/);
|
|
1335
|
+
if (A && e.includes("Safari") && !e.includes("Chrome")) {
|
|
1336
|
+
const i = parseInt(A[1], 10);
|
|
1337
|
+
return {
|
|
1338
|
+
browser: "Safari",
|
|
1339
|
+
version: A[1],
|
|
1340
|
+
likelySupported: i >= 17
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
const r = e.match(/Firefox\/(\d+)/);
|
|
1344
|
+
if (r)
|
|
1345
|
+
return {
|
|
1346
|
+
browser: "Firefox",
|
|
1347
|
+
version: r[1],
|
|
1348
|
+
likelySupported: !1
|
|
1349
|
+
// Firefox PRF support is limited
|
|
1350
|
+
};
|
|
1351
|
+
const n = e.match(/Edg\/(\d+)/);
|
|
1352
|
+
if (n) {
|
|
1353
|
+
const i = parseInt(n[1], 10);
|
|
1354
|
+
return {
|
|
1355
|
+
browser: "Edge",
|
|
1356
|
+
version: n[1],
|
|
1357
|
+
likelySupported: i >= 116
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
return {
|
|
1361
|
+
browser: "Unknown",
|
|
1362
|
+
version: "Unknown",
|
|
1363
|
+
likelySupported: !1
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
let j = null;
|
|
1367
|
+
async function bt(e = !1) {
|
|
1368
|
+
return !e && j !== null || (j = await Dt()), j;
|
|
1369
|
+
}
|
|
1370
|
+
const Gt = 1e4, Kt = 2;
|
|
1371
|
+
function Ht(e, t) {
|
|
1372
|
+
return {
|
|
1373
|
+
code: e.code || "SERVER_ERROR",
|
|
1374
|
+
message: e.message || t,
|
|
1375
|
+
details: e.details
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
function Jt() {
|
|
1379
|
+
return {
|
|
1380
|
+
code: "NETWORK_ERROR",
|
|
1381
|
+
message: "Unable to connect to server"
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
async function Mt(e, t, A) {
|
|
1385
|
+
const r = new AbortController(), n = setTimeout(() => r.abort(), A);
|
|
1386
|
+
try {
|
|
1387
|
+
return await fetch(e, {
|
|
1388
|
+
...t,
|
|
1389
|
+
signal: r.signal
|
|
1390
|
+
});
|
|
1391
|
+
} finally {
|
|
1392
|
+
clearTimeout(n);
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
function Nt(e) {
|
|
1396
|
+
if (e instanceof Error) {
|
|
1397
|
+
if (e.retryable) return !0;
|
|
1398
|
+
if (e.name === "AbortError") return !1;
|
|
1399
|
+
if (e.message.includes("fetch")) return !0;
|
|
1400
|
+
}
|
|
1401
|
+
return !1;
|
|
1402
|
+
}
|
|
1403
|
+
function Vt(e) {
|
|
1404
|
+
return new Promise((t) => setTimeout(t, e));
|
|
1405
|
+
}
|
|
1406
|
+
class Ot {
|
|
1407
|
+
baseUrl;
|
|
1408
|
+
timeoutMs;
|
|
1409
|
+
retryAttempts;
|
|
1410
|
+
getAccessToken;
|
|
1411
|
+
constructor(t) {
|
|
1412
|
+
this.baseUrl = t.baseUrl, this.timeoutMs = t.timeoutMs ?? Gt, this.retryAttempts = t.retryAttempts ?? Kt, this.getAccessToken = t.getAccessToken;
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Make an API request with timeout and optional retry
|
|
1416
|
+
*/
|
|
1417
|
+
async request(t) {
|
|
1418
|
+
const { method: A, path: r, body: n, credentials: i = "include", skipRetry: o = !1, validator: I } = t, c = `${this.baseUrl}${r}`, B = o || !(A === "GET" || A === "HEAD" || A === "PUT" || A === "DELETE") ? 1 : this.retryAttempts + 1, p = {};
|
|
1419
|
+
n !== void 0 && (p["Content-Type"] = "application/json");
|
|
1420
|
+
const f = this.getAccessToken?.();
|
|
1421
|
+
f && (p.Authorization = `Bearer ${f}`);
|
|
1422
|
+
const Q = ne();
|
|
1423
|
+
Q && (p["X-CSRF-Token"] = Q);
|
|
1424
|
+
let u;
|
|
1425
|
+
for (let h = 1; h <= B; h++)
|
|
1426
|
+
try {
|
|
1427
|
+
const a = await Mt(
|
|
1428
|
+
c,
|
|
1429
|
+
{
|
|
1430
|
+
method: A,
|
|
1431
|
+
headers: p,
|
|
1432
|
+
credentials: i,
|
|
1433
|
+
body: n !== void 0 ? JSON.stringify(n) : void 0
|
|
1434
|
+
},
|
|
1435
|
+
this.timeoutMs
|
|
1436
|
+
), g = a.headers.get("content-type") || "";
|
|
1437
|
+
let C = {};
|
|
1438
|
+
if (g.includes("application/json")) {
|
|
1439
|
+
if (a.status !== 204)
|
|
1440
|
+
try {
|
|
1441
|
+
C = await a.json();
|
|
1442
|
+
} catch (d) {
|
|
1443
|
+
const D = d instanceof Error ? d.message : "parse failed";
|
|
1444
|
+
throw new Error(`Invalid JSON response: ${D}`);
|
|
1445
|
+
}
|
|
1446
|
+
} else {
|
|
1447
|
+
const d = await a.text();
|
|
1448
|
+
if (d) {
|
|
1449
|
+
const D = d.length > 200 ? d.slice(0, 200) + "..." : d;
|
|
1450
|
+
C = {
|
|
1451
|
+
message: g.includes("text/html") || d.trimStart().startsWith("<") ? `Unexpected HTML response (${a.status}). The server may be unavailable.` : D
|
|
1452
|
+
};
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
if (!a.ok) {
|
|
1456
|
+
if (a.status >= 400 && a.status < 500)
|
|
1457
|
+
throw { isApiError: !0, data: C, status: a.status };
|
|
1458
|
+
const d = new Error(`Server error: ${a.status}`);
|
|
1459
|
+
throw d.retryable = !0, d;
|
|
1460
|
+
}
|
|
1461
|
+
if (I)
|
|
1462
|
+
try {
|
|
1463
|
+
return I(C);
|
|
1464
|
+
} catch (d) {
|
|
1465
|
+
throw new Error(
|
|
1466
|
+
`Response validation failed: ${d instanceof Error ? d.message : "Invalid response shape"}`
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1469
|
+
return C;
|
|
1470
|
+
} catch (a) {
|
|
1471
|
+
if (u = a, typeof a == "object" && a !== null && "isApiError" in a)
|
|
1472
|
+
throw a;
|
|
1473
|
+
if (h < B && Nt(a)) {
|
|
1474
|
+
await Vt(100 * Math.pow(2, h - 1));
|
|
1475
|
+
continue;
|
|
1476
|
+
}
|
|
1477
|
+
throw a;
|
|
1478
|
+
}
|
|
1479
|
+
throw u;
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* POST request helper
|
|
1483
|
+
*/
|
|
1484
|
+
async post(t, A, r) {
|
|
1485
|
+
return this.request({ method: "POST", path: t, body: A, ...r });
|
|
1486
|
+
}
|
|
1487
|
+
/**
|
|
1488
|
+
* GET request helper
|
|
1489
|
+
*/
|
|
1490
|
+
async get(t, A) {
|
|
1491
|
+
return this.request({ method: "GET", path: t, ...A });
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* PATCH request helper
|
|
1495
|
+
*/
|
|
1496
|
+
async patch(t, A, r) {
|
|
1497
|
+
return this.request({ method: "PATCH", path: t, body: A, ...r });
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* DELETE request helper
|
|
1501
|
+
*/
|
|
1502
|
+
async delete(t, A) {
|
|
1503
|
+
return this.request({ method: "DELETE", path: t, ...A });
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
function Pt(e) {
|
|
1507
|
+
return typeof e == "object" && e !== null && "isApiError" in e;
|
|
1508
|
+
}
|
|
1509
|
+
function xt(e) {
|
|
1510
|
+
return typeof e == "object" && e !== null && "code" in e && "message" in e;
|
|
1511
|
+
}
|
|
1512
|
+
function H(e, t) {
|
|
1513
|
+
if (xt(e))
|
|
1514
|
+
return e;
|
|
1515
|
+
if (Pt(e))
|
|
1516
|
+
return Ht(e.data, t);
|
|
1517
|
+
if (e instanceof Error) {
|
|
1518
|
+
if (e.name === "AbortError")
|
|
1519
|
+
return {
|
|
1520
|
+
code: "NETWORK_ERROR",
|
|
1521
|
+
message: "Request timed out"
|
|
1522
|
+
};
|
|
1523
|
+
if (e.message.startsWith("Server error:") || e.message.startsWith("Invalid JSON response"))
|
|
1524
|
+
return {
|
|
1525
|
+
code: "SERVER_ERROR",
|
|
1526
|
+
message: t
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
return Jt();
|
|
1530
|
+
}
|
|
1531
|
+
function Yt(e) {
|
|
1532
|
+
switch (e.type) {
|
|
1533
|
+
case "password":
|
|
1534
|
+
return { password: e.password };
|
|
1535
|
+
case "prfOutput":
|
|
1536
|
+
return { prfOutput: e.prfOutput };
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
function vt() {
|
|
1540
|
+
const e = de(), [t, A] = U(!1), [r, n] = U(null), i = O(() => e ? new Ot({
|
|
1541
|
+
baseUrl: e.config.serverUrl,
|
|
1542
|
+
timeoutMs: e.config.requestTimeout,
|
|
1543
|
+
retryAttempts: e.config.retryAttempts,
|
|
1544
|
+
getAccessToken: e._internal?.getAccessToken
|
|
1545
|
+
}) : null, [e]), o = k(async () => {
|
|
1546
|
+
if (!i)
|
|
1547
|
+
throw new Error("useWalletMaterial must be used within a CedrosLoginProvider");
|
|
1548
|
+
A(!0), n(null);
|
|
1549
|
+
try {
|
|
1550
|
+
return await i.get("/wallet/status");
|
|
1551
|
+
} catch (a) {
|
|
1552
|
+
const g = H(a, "Failed to fetch wallet status");
|
|
1553
|
+
throw n(g.message), g;
|
|
1554
|
+
} finally {
|
|
1555
|
+
A(!1);
|
|
1556
|
+
}
|
|
1557
|
+
}, [i]), I = k(async () => {
|
|
1558
|
+
if (!i)
|
|
1559
|
+
throw new Error("useWalletMaterial must be used within a CedrosLoginProvider");
|
|
1560
|
+
A(!0), n(null);
|
|
1561
|
+
try {
|
|
1562
|
+
return await i.get("/wallet/material");
|
|
1563
|
+
} catch (a) {
|
|
1564
|
+
const g = H(a, "Failed to fetch wallet material");
|
|
1565
|
+
if (g.code === "NOT_FOUND")
|
|
1566
|
+
return null;
|
|
1567
|
+
throw n(g.message), g;
|
|
1568
|
+
} finally {
|
|
1569
|
+
A(!1);
|
|
1570
|
+
}
|
|
1571
|
+
}, [i]), c = k(
|
|
1572
|
+
async (a) => {
|
|
1573
|
+
if (!i)
|
|
1574
|
+
throw new Error("useWalletMaterial must be used within a CedrosLoginProvider");
|
|
1575
|
+
A(!0), n(null);
|
|
1576
|
+
try {
|
|
1577
|
+
await i.post("/wallet/enroll", a);
|
|
1578
|
+
} catch (g) {
|
|
1579
|
+
const C = H(g, "Failed to enroll wallet");
|
|
1580
|
+
throw n(C.message), C;
|
|
1581
|
+
} finally {
|
|
1582
|
+
A(!1);
|
|
1583
|
+
}
|
|
1584
|
+
},
|
|
1585
|
+
[i]
|
|
1586
|
+
), w = k(
|
|
1587
|
+
async (a) => {
|
|
1588
|
+
if (!i)
|
|
1589
|
+
throw new Error("useWalletMaterial must be used within a CedrosLoginProvider");
|
|
1590
|
+
A(!0), n(null);
|
|
1591
|
+
try {
|
|
1592
|
+
await i.post("/wallet/recover", a);
|
|
1593
|
+
} catch (g) {
|
|
1594
|
+
const C = H(g, "Failed to recover wallet");
|
|
1595
|
+
throw n(C.message), C;
|
|
1596
|
+
} finally {
|
|
1597
|
+
A(!1);
|
|
1598
|
+
}
|
|
1599
|
+
},
|
|
1600
|
+
[i]
|
|
1601
|
+
), B = k(
|
|
1602
|
+
async (a) => {
|
|
1603
|
+
if (!i)
|
|
1604
|
+
throw new Error("useWalletMaterial must be used within a CedrosLoginProvider");
|
|
1605
|
+
A(!0), n(null);
|
|
1606
|
+
try {
|
|
1607
|
+
return await i.post("/wallet/sign", a);
|
|
1608
|
+
} catch (g) {
|
|
1609
|
+
const C = H(g, "Failed to sign transaction");
|
|
1610
|
+
throw n(C.message), C;
|
|
1611
|
+
} finally {
|
|
1612
|
+
A(!1);
|
|
1613
|
+
}
|
|
1614
|
+
},
|
|
1615
|
+
[i]
|
|
1616
|
+
), p = k(
|
|
1617
|
+
async (a) => {
|
|
1618
|
+
if (!i)
|
|
1619
|
+
throw new Error("useWalletMaterial must be used within a CedrosLoginProvider");
|
|
1620
|
+
A(!0), n(null);
|
|
1621
|
+
try {
|
|
1622
|
+
await i.post("/wallet/rotate-user-secret", a);
|
|
1623
|
+
} catch (g) {
|
|
1624
|
+
const C = H(g, "Failed to rotate user secret");
|
|
1625
|
+
throw n(C.message), C;
|
|
1626
|
+
} finally {
|
|
1627
|
+
A(!1);
|
|
1628
|
+
}
|
|
1629
|
+
},
|
|
1630
|
+
[i]
|
|
1631
|
+
), f = k(
|
|
1632
|
+
async (a) => {
|
|
1633
|
+
if (!i)
|
|
1634
|
+
throw new Error("useWalletMaterial must be used within a CedrosLoginProvider");
|
|
1635
|
+
A(!0), n(null);
|
|
1636
|
+
try {
|
|
1637
|
+
return await i.post(
|
|
1638
|
+
"/wallet/unlock",
|
|
1639
|
+
Yt(a)
|
|
1640
|
+
);
|
|
1641
|
+
} catch (g) {
|
|
1642
|
+
const C = H(g, "Failed to unlock wallet");
|
|
1643
|
+
throw n(C.message), C;
|
|
1644
|
+
} finally {
|
|
1645
|
+
A(!1);
|
|
1646
|
+
}
|
|
1647
|
+
},
|
|
1648
|
+
[i]
|
|
1649
|
+
), Q = k(async () => {
|
|
1650
|
+
if (!i)
|
|
1651
|
+
throw new Error("useWalletMaterial must be used within a CedrosLoginProvider");
|
|
1652
|
+
A(!0), n(null);
|
|
1653
|
+
try {
|
|
1654
|
+
await i.post("/wallet/lock", {});
|
|
1655
|
+
} catch (a) {
|
|
1656
|
+
const g = H(a, "Failed to lock wallet");
|
|
1657
|
+
throw n(g.message), g;
|
|
1658
|
+
} finally {
|
|
1659
|
+
A(!1);
|
|
1660
|
+
}
|
|
1661
|
+
}, [i]), u = k(
|
|
1662
|
+
async (a) => {
|
|
1663
|
+
if (!i)
|
|
1664
|
+
throw new Error("useWalletMaterial must be used within a CedrosLoginProvider");
|
|
1665
|
+
A(!0), n(null);
|
|
1666
|
+
try {
|
|
1667
|
+
return await i.post("/wallet/share-b", a);
|
|
1668
|
+
} catch (g) {
|
|
1669
|
+
const C = H(g, "Failed to get Share B for recovery");
|
|
1670
|
+
throw n(C.message), C;
|
|
1671
|
+
} finally {
|
|
1672
|
+
A(!1);
|
|
1673
|
+
}
|
|
1674
|
+
},
|
|
1675
|
+
[i]
|
|
1676
|
+
), h = k(() => n(null), []);
|
|
1677
|
+
return {
|
|
1678
|
+
getStatus: o,
|
|
1679
|
+
getMaterial: I,
|
|
1680
|
+
enroll: c,
|
|
1681
|
+
recover: w,
|
|
1682
|
+
signTransaction: B,
|
|
1683
|
+
rotateUserSecret: p,
|
|
1684
|
+
unlock: f,
|
|
1685
|
+
lock: Q,
|
|
1686
|
+
getShareBForRecovery: u,
|
|
1687
|
+
isLoading: t,
|
|
1688
|
+
error: r,
|
|
1689
|
+
clearError: h
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
const Tt = {
|
|
1693
|
+
status: "not_enrolled",
|
|
1694
|
+
solanaPubkey: null,
|
|
1695
|
+
authMethod: null,
|
|
1696
|
+
hasExternalWallet: !1,
|
|
1697
|
+
isUnlocked: !1,
|
|
1698
|
+
capabilities: null,
|
|
1699
|
+
isSupported: !1,
|
|
1700
|
+
error: null,
|
|
1701
|
+
refresh: async () => {
|
|
1702
|
+
},
|
|
1703
|
+
clearError: () => {
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
function Rt() {
|
|
1707
|
+
const t = de() !== null, [A, r] = U("loading"), [n, i] = U(null), [o, I] = U(null), [c, w] = U(!1), [B, p] = U(!1), [f, Q] = U(null), [u, h] = U(null), { getStatus: a, isLoading: g } = vt(), C = P(!1);
|
|
1708
|
+
K(() => {
|
|
1709
|
+
if (!t) return;
|
|
1710
|
+
let y = !1;
|
|
1711
|
+
return (async () => {
|
|
1712
|
+
try {
|
|
1713
|
+
const s = await bt();
|
|
1714
|
+
if (y) return;
|
|
1715
|
+
Q(s), s.allSupported || (r("error"), h(
|
|
1716
|
+
"Your browser or device does not support all required features. Please use a modern browser with a platform authenticator."
|
|
1717
|
+
));
|
|
1718
|
+
} catch {
|
|
1719
|
+
if (y) return;
|
|
1720
|
+
Q(null), r("error"), h("Failed to check crypto capabilities");
|
|
1721
|
+
}
|
|
1722
|
+
})(), () => {
|
|
1723
|
+
y = !0;
|
|
1724
|
+
};
|
|
1725
|
+
}, [t]);
|
|
1726
|
+
const d = k(async () => {
|
|
1727
|
+
if (!(!t || !f?.allSupported)) {
|
|
1728
|
+
r("loading"), h(null);
|
|
1729
|
+
try {
|
|
1730
|
+
const y = await a();
|
|
1731
|
+
i(y.solanaPubkey ?? null), I(y.authMethod ?? null), w(y.hasExternalWallet), p(y.unlocked), y.hasExternalWallet ? r("enrolled_unlocked") : y.enrolled ? r(y.unlocked ? "enrolled_unlocked" : "enrolled_locked") : r("not_enrolled");
|
|
1732
|
+
} catch (y) {
|
|
1733
|
+
r("error"), h(y instanceof Error ? y.message : "Failed to fetch wallet status");
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
}, [t, f?.allSupported, a]);
|
|
1737
|
+
K(() => {
|
|
1738
|
+
t && f?.allSupported && !g && !C.current && (C.current = !0, d());
|
|
1739
|
+
}, [t, f?.allSupported, g, d]);
|
|
1740
|
+
const D = k(() => h(null), []);
|
|
1741
|
+
return t ? {
|
|
1742
|
+
status: A,
|
|
1743
|
+
solanaPubkey: n,
|
|
1744
|
+
authMethod: o,
|
|
1745
|
+
hasExternalWallet: c,
|
|
1746
|
+
isUnlocked: B,
|
|
1747
|
+
capabilities: f,
|
|
1748
|
+
isSupported: f?.allSupported ?? !1,
|
|
1749
|
+
error: u,
|
|
1750
|
+
refresh: d,
|
|
1751
|
+
clearError: D
|
|
1752
|
+
} : Tt;
|
|
1753
|
+
}
|
|
1754
|
+
const $ = "__CEDROS_EMBEDDED_WALLET__";
|
|
1755
|
+
function Lt(e) {
|
|
1756
|
+
typeof window < "u" && (window[$] = e);
|
|
1757
|
+
}
|
|
1758
|
+
function ie() {
|
|
1759
|
+
typeof window < "u" && delete window[$];
|
|
1760
|
+
}
|
|
1761
|
+
function sA() {
|
|
1762
|
+
return typeof window > "u" ? !1 : window[$]?.available ?? !1;
|
|
1763
|
+
}
|
|
1764
|
+
function IA() {
|
|
1765
|
+
return typeof window > "u" ? null : window[$] ?? null;
|
|
1766
|
+
}
|
|
1767
|
+
function Xt() {
|
|
1768
|
+
const { config: e, user: t } = Be(), { status: A, solanaPubkey: r, hasExternalWallet: n } = Rt(), i = e.wallet?.exposeAvailability ?? !1, o = e.wallet?.exposePublicKey ?? !1;
|
|
1769
|
+
return K(() => {
|
|
1770
|
+
if (!i || !t) {
|
|
1771
|
+
ie();
|
|
1772
|
+
return;
|
|
1773
|
+
}
|
|
1774
|
+
if (n) {
|
|
1775
|
+
ie();
|
|
1776
|
+
return;
|
|
1777
|
+
}
|
|
1778
|
+
if (A === "loading")
|
|
1779
|
+
return;
|
|
1780
|
+
const I = A === "enrolled_locked" || A === "enrolled_unlocked";
|
|
1781
|
+
return Lt({
|
|
1782
|
+
available: I,
|
|
1783
|
+
publicKey: o && I ? r : null
|
|
1784
|
+
}), () => {
|
|
1785
|
+
ie();
|
|
1786
|
+
};
|
|
1787
|
+
}, [i, o, t, A, r, n]), null;
|
|
1788
|
+
}
|
|
1789
|
+
function aA({ config: e, children: t }) {
|
|
1790
|
+
const [A, r] = U(null), [n, i] = U(!1), o = O(
|
|
1791
|
+
() => JSON.stringify(e.themeOverrides ?? null),
|
|
1792
|
+
[e.themeOverrides]
|
|
1793
|
+
), I = O(() => JSON.stringify(e.session ?? null), [e.session]), c = O(() => JSON.stringify(e.features ?? null), [e.features]), w = O(() => JSON.stringify(e.forms ?? null), [e.forms]), B = O(
|
|
1794
|
+
() => e,
|
|
1795
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- Using serialized keys for deep comparison
|
|
1796
|
+
[
|
|
1797
|
+
e.serverUrl,
|
|
1798
|
+
e.googleClientId,
|
|
1799
|
+
e.requestTimeout,
|
|
1800
|
+
e.retryAttempts,
|
|
1801
|
+
e.theme,
|
|
1802
|
+
o,
|
|
1803
|
+
I,
|
|
1804
|
+
c,
|
|
1805
|
+
w,
|
|
1806
|
+
e.callbacks
|
|
1807
|
+
]
|
|
1808
|
+
);
|
|
1809
|
+
be({
|
|
1810
|
+
theme: B.theme,
|
|
1811
|
+
themeOverrides: B.themeOverrides
|
|
1812
|
+
});
|
|
1813
|
+
const {
|
|
1814
|
+
user: p,
|
|
1815
|
+
authState: f,
|
|
1816
|
+
handleLoginSuccess: Q,
|
|
1817
|
+
logout: u,
|
|
1818
|
+
refreshUser: h,
|
|
1819
|
+
getAccessToken: a
|
|
1820
|
+
} = Ve({
|
|
1821
|
+
serverUrl: B.serverUrl,
|
|
1822
|
+
session: B.session,
|
|
1823
|
+
callbacks: B.callbacks,
|
|
1824
|
+
requestTimeoutMs: B.requestTimeout
|
|
1825
|
+
}), g = k(async () => {
|
|
1826
|
+
r(null), await u();
|
|
1827
|
+
}, [u]), C = k(
|
|
1828
|
+
(...l) => {
|
|
1829
|
+
r(null), Q(...l);
|
|
1830
|
+
},
|
|
1831
|
+
[Q]
|
|
1832
|
+
), d = k(() => i(!0), []), D = k(() => i(!1), []), y = O(
|
|
1833
|
+
() => ({
|
|
1834
|
+
config: B,
|
|
1835
|
+
user: p,
|
|
1836
|
+
authState: f,
|
|
1837
|
+
error: A,
|
|
1838
|
+
logout: g,
|
|
1839
|
+
refreshUser: h,
|
|
1840
|
+
isModalOpen: n,
|
|
1841
|
+
openModal: d,
|
|
1842
|
+
closeModal: D,
|
|
1843
|
+
_internal: {
|
|
1844
|
+
handleLoginSuccess: C,
|
|
1845
|
+
getAccessToken: a
|
|
1846
|
+
}
|
|
1847
|
+
}),
|
|
1848
|
+
[
|
|
1849
|
+
B,
|
|
1850
|
+
p,
|
|
1851
|
+
f,
|
|
1852
|
+
A,
|
|
1853
|
+
g,
|
|
1854
|
+
h,
|
|
1855
|
+
n,
|
|
1856
|
+
d,
|
|
1857
|
+
D,
|
|
1858
|
+
C,
|
|
1859
|
+
a
|
|
1860
|
+
]
|
|
1861
|
+
);
|
|
1862
|
+
return /* @__PURE__ */ R(ae.Provider, { value: y, children: [
|
|
1863
|
+
/* @__PURE__ */ m(Xt, {}),
|
|
1864
|
+
t
|
|
1865
|
+
] });
|
|
1866
|
+
}
|
|
1867
|
+
function gA() {
|
|
1868
|
+
const { user: e, authState: t, error: A, logout: r, refreshUser: n, openModal: i, closeModal: o } = Be();
|
|
1869
|
+
return {
|
|
1870
|
+
user: e,
|
|
1871
|
+
authState: t,
|
|
1872
|
+
error: A,
|
|
1873
|
+
isAuthenticated: t === "authenticated" && e !== null,
|
|
1874
|
+
isLoading: t === "loading",
|
|
1875
|
+
logout: r,
|
|
1876
|
+
refreshUser: n,
|
|
1877
|
+
openLoginModal: i,
|
|
1878
|
+
closeLoginModal: o
|
|
1879
|
+
};
|
|
1880
|
+
}
|
|
1881
|
+
const Wt = {
|
|
1882
|
+
sm: 16,
|
|
1883
|
+
md: 24,
|
|
1884
|
+
lg: 32,
|
|
1885
|
+
xl: 48
|
|
1886
|
+
// H-04: Added for WalletUnlock component
|
|
1887
|
+
}, cA = Qe(function({
|
|
1888
|
+
size: t = "md",
|
|
1889
|
+
className: A = "",
|
|
1890
|
+
style: r,
|
|
1891
|
+
label: n = "Loading",
|
|
1892
|
+
announce: i = !1
|
|
1893
|
+
}) {
|
|
1894
|
+
const o = Wt[t], I = /* @__PURE__ */ R(
|
|
1895
|
+
"svg",
|
|
1896
|
+
{
|
|
1897
|
+
className: `cedros-spinner ${A}`,
|
|
1898
|
+
width: o,
|
|
1899
|
+
height: o,
|
|
1900
|
+
viewBox: "0 0 24 24",
|
|
1901
|
+
fill: "none",
|
|
1902
|
+
style: r,
|
|
1903
|
+
"aria-label": n,
|
|
1904
|
+
role: "status",
|
|
1905
|
+
"aria-hidden": i ? "true" : void 0,
|
|
1906
|
+
children: [
|
|
1907
|
+
/* @__PURE__ */ m(
|
|
1908
|
+
"circle",
|
|
1909
|
+
{
|
|
1910
|
+
className: "cedros-spinner-track",
|
|
1911
|
+
cx: "12",
|
|
1912
|
+
cy: "12",
|
|
1913
|
+
r: "10",
|
|
1914
|
+
stroke: "currentColor",
|
|
1915
|
+
strokeWidth: "3",
|
|
1916
|
+
strokeOpacity: "0.25"
|
|
1917
|
+
}
|
|
1918
|
+
),
|
|
1919
|
+
/* @__PURE__ */ m(
|
|
1920
|
+
"circle",
|
|
1921
|
+
{
|
|
1922
|
+
className: "cedros-spinner-head",
|
|
1923
|
+
cx: "12",
|
|
1924
|
+
cy: "12",
|
|
1925
|
+
r: "10",
|
|
1926
|
+
stroke: "currentColor",
|
|
1927
|
+
strokeWidth: "3",
|
|
1928
|
+
strokeLinecap: "round",
|
|
1929
|
+
strokeDasharray: "31.4 31.4",
|
|
1930
|
+
transform: "rotate(-90 12 12)",
|
|
1931
|
+
children: /* @__PURE__ */ m(
|
|
1932
|
+
"animateTransform",
|
|
1933
|
+
{
|
|
1934
|
+
attributeName: "transform",
|
|
1935
|
+
type: "rotate",
|
|
1936
|
+
from: "0 12 12",
|
|
1937
|
+
to: "360 12 12",
|
|
1938
|
+
dur: "1s",
|
|
1939
|
+
repeatCount: "indefinite"
|
|
1940
|
+
}
|
|
1941
|
+
)
|
|
1942
|
+
}
|
|
1943
|
+
)
|
|
1944
|
+
]
|
|
1945
|
+
}
|
|
1946
|
+
);
|
|
1947
|
+
return i ? /* @__PURE__ */ R("span", { "aria-live": "polite", "aria-busy": "true", children: [
|
|
1948
|
+
I,
|
|
1949
|
+
/* @__PURE__ */ m("span", { className: "cedros-sr-only", children: n })
|
|
1950
|
+
] }) : I;
|
|
1951
|
+
}), lA = Qe(function({
|
|
1952
|
+
error: t,
|
|
1953
|
+
className: A = "",
|
|
1954
|
+
onDismiss: r,
|
|
1955
|
+
autoFocus: n = !1
|
|
1956
|
+
}) {
|
|
1957
|
+
const i = P(null);
|
|
1958
|
+
if (K(() => {
|
|
1959
|
+
t && n && i.current && i.current.focus();
|
|
1960
|
+
}, [t, n]), !t) return null;
|
|
1961
|
+
const o = typeof t == "string" ? t : t.message;
|
|
1962
|
+
return /* @__PURE__ */ R(
|
|
1963
|
+
"div",
|
|
1964
|
+
{
|
|
1965
|
+
ref: i,
|
|
1966
|
+
className: `cedros-error ${A}`,
|
|
1967
|
+
role: "alert",
|
|
1968
|
+
"aria-live": "assertive",
|
|
1969
|
+
tabIndex: n ? -1 : void 0,
|
|
1970
|
+
children: [
|
|
1971
|
+
/* @__PURE__ */ R(
|
|
1972
|
+
"svg",
|
|
1973
|
+
{
|
|
1974
|
+
className: "cedros-error-icon",
|
|
1975
|
+
width: "16",
|
|
1976
|
+
height: "16",
|
|
1977
|
+
viewBox: "0 0 16 16",
|
|
1978
|
+
fill: "none",
|
|
1979
|
+
"aria-hidden": "true",
|
|
1980
|
+
children: [
|
|
1981
|
+
/* @__PURE__ */ m("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
1982
|
+
/* @__PURE__ */ m("path", { d: "M8 4.5v4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
|
|
1983
|
+
/* @__PURE__ */ m("circle", { cx: "8", cy: "11", r: "0.75", fill: "currentColor" })
|
|
1984
|
+
]
|
|
1985
|
+
}
|
|
1986
|
+
),
|
|
1987
|
+
/* @__PURE__ */ m("span", { className: "cedros-error-message", children: o }),
|
|
1988
|
+
r && /* @__PURE__ */ m(
|
|
1989
|
+
"button",
|
|
1990
|
+
{
|
|
1991
|
+
type: "button",
|
|
1992
|
+
className: "cedros-error-dismiss",
|
|
1993
|
+
onClick: r,
|
|
1994
|
+
"aria-label": "Dismiss error",
|
|
1995
|
+
children: /* @__PURE__ */ m("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ m(
|
|
1996
|
+
"path",
|
|
1997
|
+
{
|
|
1998
|
+
d: "M10.5 3.5L3.5 10.5M3.5 3.5l7 7",
|
|
1999
|
+
stroke: "currentColor",
|
|
2000
|
+
strokeWidth: "1.5",
|
|
2001
|
+
strokeLinecap: "round"
|
|
2002
|
+
}
|
|
2003
|
+
) })
|
|
2004
|
+
}
|
|
2005
|
+
)
|
|
2006
|
+
]
|
|
2007
|
+
}
|
|
2008
|
+
);
|
|
2009
|
+
});
|
|
2010
|
+
export {
|
|
2011
|
+
Ot as A,
|
|
2012
|
+
aA as C,
|
|
2013
|
+
Oe as D,
|
|
2014
|
+
lA as E,
|
|
2015
|
+
cA as L,
|
|
2016
|
+
gA as a,
|
|
2017
|
+
AA as b,
|
|
2018
|
+
Le as c,
|
|
2019
|
+
$t as d,
|
|
2020
|
+
eA as e,
|
|
2021
|
+
Ee as f,
|
|
2022
|
+
_t as g,
|
|
2023
|
+
H as h,
|
|
2024
|
+
Z as i,
|
|
2025
|
+
zt as j,
|
|
2026
|
+
nA as k,
|
|
2027
|
+
oA as l,
|
|
2028
|
+
de as m,
|
|
2029
|
+
vt as n,
|
|
2030
|
+
qe as o,
|
|
2031
|
+
iA as p,
|
|
2032
|
+
tA as q,
|
|
2033
|
+
rA as r,
|
|
2034
|
+
Yt as s,
|
|
2035
|
+
qt as t,
|
|
2036
|
+
Be as u,
|
|
2037
|
+
ze as v,
|
|
2038
|
+
pe as w,
|
|
2039
|
+
Rt as x,
|
|
2040
|
+
sA as y,
|
|
2041
|
+
IA as z
|
|
2042
|
+
};
|