eocene-auth-sdk 0.2.2 → 0.3.0
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/CHANGELOG.md +25 -0
- package/README.md +22 -5
- package/dist/index.d.ts +35 -6
- package/dist/index.js +204 -29
- package/dist/index.js.map +1 -1
- package/dist/styles.css +20 -23
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Telegram login.** `AuthSocialMethod` gains `'telegram'`:
|
|
8
|
+
- Web: `login('telegram')` runs the standard OAuth redirect (control-plane
|
|
9
|
+
speaks Telegram OIDC; requires `TELEGRAM_CLIENT_ID/SECRET` on eocene-worker).
|
|
10
|
+
- Mini App: `loginTelegramMiniApp()` (also on `useAuth()`) exchanges the
|
|
11
|
+
bot-signed `window.Telegram.WebApp.initData` for a session — no redirect.
|
|
12
|
+
`login('telegram')` automatically takes this path inside the Telegram
|
|
13
|
+
webview.
|
|
14
|
+
- New exports `isTelegramMiniApp()` / `getTelegramInitData()` for hosts that
|
|
15
|
+
want to auto-login on entry.
|
|
16
|
+
- New label `loginTelegram` (default `'Telegram'`).
|
|
17
|
+
- Older control-planes simply never advertise `providers.telegram`, so the
|
|
18
|
+
button stays hidden — no version coupling.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Auth UI palette aligned to the Eocene mark (`#3B82D6` / `#1D3E90` / `#85CEEA`); navy-tinted surfaces, cyan glows.
|
|
23
|
+
- Auth UI lockup now reads **EOCENE Research** (stacked wordmark) instead of the old mixed-case "Eocene" wordmark.
|
|
24
|
+
- Login panel asks for confirmation before redirecting to Google / GitHub / X / Apple.
|
|
25
|
+
- `authConfigFromViteEnv` reads `VITE_EOCENE_*` (stock Vite).
|
|
26
|
+
- Dev mock identities use `{provider}@eocene.local`.
|
|
27
|
+
|
|
3
28
|
## 0.2.2
|
|
4
29
|
|
|
5
30
|
### Fixed
|
package/README.md
CHANGED
|
@@ -24,11 +24,28 @@ Environment variables (Vite):
|
|
|
24
24
|
|
|
25
25
|
| Key | Description |
|
|
26
26
|
|---|---|
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
29
|
-
| `
|
|
30
|
-
| `
|
|
31
|
-
| `
|
|
27
|
+
| `VITE_EOCENE_PROJECT_ID` | Public project id (required for end-user OAuth) |
|
|
28
|
+
| `VITE_EOCENE_CONTROL_URL` | Optional. Default `https://api.eocene.io` |
|
|
29
|
+
| `VITE_EOCENE_OAUTH_RETURN_TO` | Optional. Default `{origin}/login/eocene-callback` |
|
|
30
|
+
| `VITE_EOCENE_CHAIN_ID` | Optional. Default `1` |
|
|
31
|
+
| `VITE_EOCENE_OAUTH_FALLBACK_DEV` | Optional. Local mock `{provider}@eocene.local` when IdP is off |
|
|
32
|
+
|
|
33
|
+
Unprefixed `EOCENE_*` still works if you set Vite `envPrefix` to include `EOCENE_`.
|
|
34
|
+
|
|
35
|
+
The built-in `AuthLoginPanel` confirms before redirecting to the IdP.
|
|
36
|
+
|
|
37
|
+
**Telegram** (`'telegram'` method, control-plane must have `TELEGRAM_CLIENT_ID/SECRET` + `TELEGRAM_BOT_TOKEN`):
|
|
38
|
+
web login uses the same OAuth redirect as the other providers; inside a
|
|
39
|
+
Telegram Mini App the signed `initData` is exchanged directly — call
|
|
40
|
+
`loginTelegramMiniApp()` from `useAuth()` (or just `login('telegram')`, which
|
|
41
|
+
detects the webview), and use `isTelegramMiniApp()` to auto-login on entry:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
const { loginTelegramMiniApp } = useAuth()
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (isTelegramMiniApp()) void loginTelegramMiniApp()
|
|
47
|
+
}, [])
|
|
48
|
+
```
|
|
32
49
|
|
|
33
50
|
Production control default: `https://api.eocene.io`
|
|
34
51
|
|
package/dist/index.d.ts
CHANGED
|
@@ -188,9 +188,14 @@ type AuthSdkLabels = {
|
|
|
188
188
|
loginTwitter: string;
|
|
189
189
|
loginGithub: string;
|
|
190
190
|
loginApple: string;
|
|
191
|
+
loginTelegram: string;
|
|
191
192
|
loginConnecting: string;
|
|
192
193
|
loginError: string;
|
|
193
194
|
loginNoMethods: string;
|
|
195
|
+
loginConfirmTitle: string;
|
|
196
|
+
loginConfirmBody: string;
|
|
197
|
+
loginConfirmContinue: string;
|
|
198
|
+
loginConfirmCancel: string;
|
|
194
199
|
oauthWorking: string;
|
|
195
200
|
oauthFailed: string;
|
|
196
201
|
oauthBack: string;
|
|
@@ -254,14 +259,14 @@ type AuthSdkComponents = {
|
|
|
254
259
|
LoginPanel?: ComponentType<LoginPanelProps>;
|
|
255
260
|
};
|
|
256
261
|
|
|
257
|
-
type AuthSocialMethod = 'google' | 'twitter' | 'github' | 'apple';
|
|
262
|
+
type AuthSocialMethod = 'google' | 'twitter' | 'github' | 'apple' | 'telegram';
|
|
258
263
|
type AuthSdkConfig = {
|
|
259
264
|
controlBaseUrl: string;
|
|
260
265
|
/** Full URL control-plane redirects to after OAuth (host route). */
|
|
261
266
|
oauthReturnTo: string;
|
|
262
267
|
/**
|
|
263
268
|
* When IdP credentials are missing on control-plane, allow `loginDev`
|
|
264
|
-
* mock `{provider}@
|
|
269
|
+
* mock `{provider}@eocene.local`. Default false.
|
|
265
270
|
*/
|
|
266
271
|
allowDevLoginFallback?: boolean;
|
|
267
272
|
/** Scope end-user OAuth / wallets to this project. */
|
|
@@ -340,6 +345,13 @@ declare class AuthClient {
|
|
|
340
345
|
*/
|
|
341
346
|
listAvailableMethods(): Promise<AuthSocialMethod[]>;
|
|
342
347
|
login(method: AuthSocialMethod): Promise<AuthLoginResult>;
|
|
348
|
+
/**
|
|
349
|
+
* Silent login for apps running inside the Telegram webview: no redirect,
|
|
350
|
+
* no popup — the bot-signed `initData` is exchanged directly for a session.
|
|
351
|
+
* `initData` defaults to `window.Telegram.WebApp.initData`; pass it
|
|
352
|
+
* explicitly only in tests.
|
|
353
|
+
*/
|
|
354
|
+
loginTelegramMiniApp(initData?: string): Promise<AuthLoginResult>;
|
|
343
355
|
completeOAuthFromHash(hashOrSearch: string): Promise<AuthLoginResult>;
|
|
344
356
|
takeOAuthReturnPath(): string | null;
|
|
345
357
|
markActive(on: boolean): void;
|
|
@@ -349,6 +361,22 @@ declare class AuthClient {
|
|
|
349
361
|
clearPassword(password: string): Promise<void>;
|
|
350
362
|
}
|
|
351
363
|
|
|
364
|
+
/**
|
|
365
|
+
* Telegram Mini App detection.
|
|
366
|
+
*
|
|
367
|
+
* Inside the Telegram webview `window.Telegram.WebApp` is injected by
|
|
368
|
+
* telegram-web-app.js and `initData` carries the bot-signed login payload.
|
|
369
|
+
* Only the raw string is ever read here — the parsed `initDataUnsafe` object
|
|
370
|
+
* is not trustworthy and never leaves the client.
|
|
371
|
+
*/
|
|
372
|
+
/**
|
|
373
|
+
* True when running inside Telegram with a signed login payload available.
|
|
374
|
+
* Hosts use this to switch the login screen to the silent Mini App path.
|
|
375
|
+
*/
|
|
376
|
+
declare function isTelegramMiniApp(): boolean;
|
|
377
|
+
/** The raw signed initData string, or null outside Telegram. */
|
|
378
|
+
declare function getTelegramInitData(): string | null;
|
|
379
|
+
|
|
352
380
|
/** Thin wrapper — prefer AuthClient.getProvider(); exported for advanced hosts. */
|
|
353
381
|
declare function createAuthEip1193Provider(client: WaasClient, requestApproval?: (req: WaasSignApprovalRequest) => Promise<WaasSignApprovalResult>): WaasEip1193Provider;
|
|
354
382
|
|
|
@@ -363,6 +391,8 @@ type AuthContextValue = {
|
|
|
363
391
|
login: (args: {
|
|
364
392
|
method: AuthSocialMethod;
|
|
365
393
|
}) => Promise<AuthLoginResult>;
|
|
394
|
+
/** Silent Telegram Mini App login (inside the Telegram webview only). */
|
|
395
|
+
loginTelegramMiniApp: () => Promise<AuthLoginResult>;
|
|
366
396
|
logout: () => void;
|
|
367
397
|
markActive: (on: boolean) => void;
|
|
368
398
|
restoreIfNeeded: () => boolean;
|
|
@@ -413,7 +443,7 @@ type AuthOAuthCallbackProps = {
|
|
|
413
443
|
*/
|
|
414
444
|
declare function AuthOAuthCallback({ hashOrSearch, onWalletReady, children, onBackHref, }: AuthOAuthCallbackProps): react.JSX.Element;
|
|
415
445
|
|
|
416
|
-
/** Build AuthSdkConfig from Vite `
|
|
446
|
+
/** Build AuthSdkConfig from Vite `VITE_EOCENE_*` (and unprefixed / legacy WAAS aliases). */
|
|
417
447
|
declare function authConfigFromViteEnv(env?: object): AuthSdkConfig;
|
|
418
448
|
|
|
419
449
|
declare function SignConfirmModal({ open, request, labels, password, busy, error, locked, onPasswordChange, onApprove, onReject, onOpenSetPassword, }: SignApprovalProps): react.JSX.Element | null;
|
|
@@ -421,8 +451,7 @@ declare function SignConfirmModal({ open, request, labels, password, busy, error
|
|
|
421
451
|
declare function SetPasswordModal({ open, passwordEnabled, labels, busy, error, onSubmitSet, onSubmitClear, onClose, }: PasswordSettingsProps): react.JSX.Element | null;
|
|
422
452
|
|
|
423
453
|
/**
|
|
424
|
-
*
|
|
425
|
-
* brand refresh. Inline for npm consumers (no asset fetch); transparent
|
|
454
|
+
* EOCENE Research mark and lockup. Inline SVG (no asset fetch); transparent
|
|
426
455
|
* background so it sits on either theme.
|
|
427
456
|
*/
|
|
428
457
|
declare function EoceneMark({ size, title, ...props }: SVGProps<SVGSVGElement> & {
|
|
@@ -434,4 +463,4 @@ declare function EoceneWordmark({ className, markSize, }: {
|
|
|
434
463
|
markSize?: number;
|
|
435
464
|
}): react.JSX.Element;
|
|
436
465
|
|
|
437
|
-
export { AuthClient, type AuthConnectorShim, type AuthContextValue, AuthLoginPanel, type AuthLoginResult, AuthOAuthCallback, type AuthOAuthCallbackProps, AuthProvider, type AuthProviderProps, type AuthSdkComponents, type AuthSdkConfig, type AuthSdkLabels, type AuthSocialMethod, type AuthUser, DEFAULT_CONTROL_BASE_URL, DEFAULT_LABELS, DEFAULT_OAUTH_PENDING_KEY, DEFAULT_STORAGE_KEY, EoceneMark, EoceneWordmark, type LoginPanelProps, type PasswordSettingsProps, SetPasswordModal, type SignApprovalProps, SignConfirmModal, type WaasEip1193Provider, WaasHttpError, type WaasSignApprovalRequest, type WaasSignApprovalResult, type WaasSignAuthError, authConfigFromViteEnv, createAuthEip1193Provider, isWaasHttpError, resolveControlAbsoluteUrl, useAuthContext as useAuth };
|
|
466
|
+
export { AuthClient, type AuthConnectorShim, type AuthContextValue, AuthLoginPanel, type AuthLoginResult, AuthOAuthCallback, type AuthOAuthCallbackProps, AuthProvider, type AuthProviderProps, type AuthSdkComponents, type AuthSdkConfig, type AuthSdkLabels, type AuthSocialMethod, type AuthUser, DEFAULT_CONTROL_BASE_URL, DEFAULT_LABELS, DEFAULT_OAUTH_PENDING_KEY, DEFAULT_STORAGE_KEY, EoceneMark, EoceneWordmark, type LoginPanelProps, type PasswordSettingsProps, SetPasswordModal, type SignApprovalProps, SignConfirmModal, type WaasEip1193Provider, WaasHttpError, type WaasSignApprovalRequest, type WaasSignApprovalResult, type WaasSignAuthError, authConfigFromViteEnv, createAuthEip1193Provider, getTelegramInitData, isTelegramMiniApp, isWaasHttpError, resolveControlAbsoluteUrl, useAuthContext as useAuth };
|
package/dist/index.js
CHANGED
|
@@ -3027,8 +3027,21 @@ function clearPersistedState(storageKey = DEFAULT_STORAGE_KEY) {
|
|
|
3027
3027
|
sessionStorage.removeItem(storageKey);
|
|
3028
3028
|
}
|
|
3029
3029
|
|
|
3030
|
+
// src/client/telegramMiniApp.ts
|
|
3031
|
+
function readWebApp() {
|
|
3032
|
+
if (typeof window === "undefined") return null;
|
|
3033
|
+
const tg = window.Telegram;
|
|
3034
|
+
return tg?.WebApp ?? null;
|
|
3035
|
+
}
|
|
3036
|
+
function isTelegramMiniApp() {
|
|
3037
|
+
return Boolean(readWebApp()?.initData);
|
|
3038
|
+
}
|
|
3039
|
+
function getTelegramInitData() {
|
|
3040
|
+
return readWebApp()?.initData || null;
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3030
3043
|
// src/client/AuthClient.ts
|
|
3031
|
-
var SOCIAL_METHODS = ["google", "twitter", "github", "apple"];
|
|
3044
|
+
var SOCIAL_METHODS = ["google", "twitter", "github", "apple", "telegram"];
|
|
3032
3045
|
var AuthClient = class {
|
|
3033
3046
|
config;
|
|
3034
3047
|
storageKey;
|
|
@@ -3147,6 +3160,9 @@ var AuthClient = class {
|
|
|
3147
3160
|
}
|
|
3148
3161
|
}
|
|
3149
3162
|
async login(method) {
|
|
3163
|
+
if (method === "telegram" && getTelegramInitData()) {
|
|
3164
|
+
return this.loginTelegramMiniApp();
|
|
3165
|
+
}
|
|
3150
3166
|
const status = await this.fetchOAuthProviders();
|
|
3151
3167
|
if (status.providers[method]) {
|
|
3152
3168
|
if (typeof sessionStorage !== "undefined") {
|
|
@@ -3174,7 +3190,7 @@ var AuthClient = class {
|
|
|
3174
3190
|
`${method} OAuth is not configured on eocene-worker (providers.${method}=false). Set GOOGLE_CLIENT_ID/SECRET in eocene-worker/.env and restart, or set EOCENE_OAUTH_FALLBACK_DEV=true for local mock.`
|
|
3175
3191
|
);
|
|
3176
3192
|
}
|
|
3177
|
-
const email = `${method}@
|
|
3193
|
+
const email = `${method}@eocene.local`;
|
|
3178
3194
|
await this.client.loginDev(email, method, {
|
|
3179
3195
|
projectId: this.config.projectId,
|
|
3180
3196
|
asDeveloper: this.config.asDeveloper
|
|
@@ -3197,6 +3213,37 @@ var AuthClient = class {
|
|
|
3197
3213
|
this.provider = null;
|
|
3198
3214
|
return wallet;
|
|
3199
3215
|
}
|
|
3216
|
+
/**
|
|
3217
|
+
* Silent login for apps running inside the Telegram webview: no redirect,
|
|
3218
|
+
* no popup — the bot-signed `initData` is exchanged directly for a session.
|
|
3219
|
+
* `initData` defaults to `window.Telegram.WebApp.initData`; pass it
|
|
3220
|
+
* explicitly only in tests.
|
|
3221
|
+
*/
|
|
3222
|
+
async loginTelegramMiniApp(initData) {
|
|
3223
|
+
const data = initData ?? getTelegramInitData();
|
|
3224
|
+
if (!data) {
|
|
3225
|
+
throw new Error("Not inside a Telegram Mini App (window.Telegram.WebApp.initData is empty).");
|
|
3226
|
+
}
|
|
3227
|
+
if (!this.config.projectId) {
|
|
3228
|
+
throw new Error("Telegram Mini App login requires config.projectId.");
|
|
3229
|
+
}
|
|
3230
|
+
const base = resolveControlAbsoluteUrl(this.config.controlBaseUrl);
|
|
3231
|
+
const res = await fetch(`${base}/auth/telegram/miniapp`, {
|
|
3232
|
+
method: "POST",
|
|
3233
|
+
headers: { "content-type": "application/json" },
|
|
3234
|
+
body: JSON.stringify({ initData: data, projectId: this.config.projectId })
|
|
3235
|
+
});
|
|
3236
|
+
const body = await res.json().catch(() => ({}));
|
|
3237
|
+
if (!res.ok || !body.sessionToken) {
|
|
3238
|
+
throw new Error(body.error ?? `telegram miniapp login HTTP ${res.status}`);
|
|
3239
|
+
}
|
|
3240
|
+
await this.client.loginWithSessionToken(body.sessionToken);
|
|
3241
|
+
const wallet = await this.client.ensureWallet();
|
|
3242
|
+
this.persist();
|
|
3243
|
+
this.active = true;
|
|
3244
|
+
this.provider = null;
|
|
3245
|
+
return { ...wallet, provider: "telegram" };
|
|
3246
|
+
}
|
|
3200
3247
|
async completeOAuthFromHash(hashOrSearch) {
|
|
3201
3248
|
const raw = hashOrSearch.startsWith("#") || hashOrSearch.startsWith("?") ? hashOrSearch.slice(1) : hashOrSearch;
|
|
3202
3249
|
const params = new URLSearchParams(raw);
|
|
@@ -3320,7 +3367,7 @@ function formatSignAuthError(err, labels) {
|
|
|
3320
3367
|
}
|
|
3321
3368
|
function EoceneMark({
|
|
3322
3369
|
size = 28,
|
|
3323
|
-
title = "
|
|
3370
|
+
title = "EOCENE Research",
|
|
3324
3371
|
...props
|
|
3325
3372
|
}) {
|
|
3326
3373
|
return /* @__PURE__ */ jsxs(
|
|
@@ -3360,29 +3407,67 @@ function EoceneWordmark({
|
|
|
3360
3407
|
className,
|
|
3361
3408
|
markSize = 28
|
|
3362
3409
|
}) {
|
|
3410
|
+
const nameSize = Math.round(markSize * 0.5);
|
|
3411
|
+
const researchSize = Math.round(markSize * 0.3);
|
|
3363
3412
|
return /* @__PURE__ */ jsxs(
|
|
3364
3413
|
"span",
|
|
3365
3414
|
{
|
|
3366
3415
|
className,
|
|
3416
|
+
role: "img",
|
|
3417
|
+
"aria-label": "EOCENE Research",
|
|
3367
3418
|
style: {
|
|
3368
3419
|
display: "inline-flex",
|
|
3369
3420
|
alignItems: "center",
|
|
3370
|
-
gap:
|
|
3371
|
-
fontWeight: 700,
|
|
3372
|
-
letterSpacing: "-0.03em",
|
|
3421
|
+
gap: Math.round(markSize * 0.32),
|
|
3373
3422
|
lineHeight: 1
|
|
3374
3423
|
},
|
|
3375
3424
|
children: [
|
|
3376
|
-
/* @__PURE__ */ jsx(EoceneMark, { size: markSize }),
|
|
3377
|
-
/* @__PURE__ */ jsxs(
|
|
3378
|
-
"
|
|
3379
|
-
|
|
3380
|
-
|
|
3425
|
+
/* @__PURE__ */ jsx(EoceneMark, { size: markSize, "aria-hidden": true }),
|
|
3426
|
+
/* @__PURE__ */ jsxs(
|
|
3427
|
+
"span",
|
|
3428
|
+
{
|
|
3429
|
+
style: {
|
|
3430
|
+
display: "flex",
|
|
3431
|
+
flexDirection: "column",
|
|
3432
|
+
justifyContent: "center",
|
|
3433
|
+
gap: 3
|
|
3434
|
+
},
|
|
3435
|
+
children: [
|
|
3436
|
+
/* @__PURE__ */ jsx(
|
|
3437
|
+
"span",
|
|
3438
|
+
{
|
|
3439
|
+
style: {
|
|
3440
|
+
fontSize: nameSize,
|
|
3441
|
+
fontWeight: 700,
|
|
3442
|
+
letterSpacing: "0.16em",
|
|
3443
|
+
textTransform: "uppercase",
|
|
3444
|
+
color: "var(--auth-sdk-text, currentColor)",
|
|
3445
|
+
fontFamily: "ui-sans-serif, system-ui, sans-serif"
|
|
3446
|
+
},
|
|
3447
|
+
children: "EOCENE"
|
|
3448
|
+
}
|
|
3449
|
+
),
|
|
3450
|
+
/* @__PURE__ */ jsx(
|
|
3451
|
+
"span",
|
|
3452
|
+
{
|
|
3453
|
+
style: {
|
|
3454
|
+
fontSize: researchSize,
|
|
3455
|
+
fontWeight: 400,
|
|
3456
|
+
letterSpacing: "0.02em",
|
|
3457
|
+
color: "var(--auth-sdk-muted, #8ba3b8)",
|
|
3458
|
+
fontFamily: "ui-sans-serif, system-ui, sans-serif"
|
|
3459
|
+
},
|
|
3460
|
+
children: "Research"
|
|
3461
|
+
}
|
|
3462
|
+
)
|
|
3463
|
+
]
|
|
3464
|
+
}
|
|
3465
|
+
)
|
|
3381
3466
|
]
|
|
3382
3467
|
}
|
|
3383
3468
|
);
|
|
3384
3469
|
}
|
|
3385
|
-
var DEFAULT_METHODS = ["google", "twitter", "github", "apple"];
|
|
3470
|
+
var DEFAULT_METHODS = ["google", "twitter", "github", "apple", "telegram"];
|
|
3386
3471
|
function methodLabel(method, labels) {
|
|
3387
3472
|
switch (method) {
|
|
3388
3473
|
case "google":
|
|
@@ -3393,6 +3478,8 @@ function methodLabel(method, labels) {
|
|
|
3393
3478
|
return labels.loginGithub;
|
|
3394
3479
|
case "apple":
|
|
3395
3480
|
return labels.loginApple;
|
|
3481
|
+
case "telegram":
|
|
3482
|
+
return labels.loginTelegram;
|
|
3396
3483
|
}
|
|
3397
3484
|
}
|
|
3398
3485
|
function AuthLoginPanel({
|
|
@@ -3403,11 +3490,20 @@ function AuthLoginPanel({
|
|
|
3403
3490
|
error,
|
|
3404
3491
|
onLogin
|
|
3405
3492
|
}) {
|
|
3493
|
+
const [pendingMethod, setPendingMethod] = useState(null);
|
|
3494
|
+
const [submitted, setSubmitted] = useState(false);
|
|
3495
|
+
const busy = submitted || pendingMethod != null && loadingMethod === pendingMethod;
|
|
3496
|
+
useEffect(() => {
|
|
3497
|
+
if (pendingMethod == null || busy) return;
|
|
3498
|
+
const onKeyDown = (e) => {
|
|
3499
|
+
if (e.key === "Escape") setPendingMethod(null);
|
|
3500
|
+
};
|
|
3501
|
+
window.addEventListener("keydown", onKeyDown);
|
|
3502
|
+
return () => window.removeEventListener("keydown", onKeyDown);
|
|
3503
|
+
}, [pendingMethod, busy]);
|
|
3406
3504
|
return /* @__PURE__ */ jsxs("div", { className: "auth-sdk-root auth-sdk-login", children: [
|
|
3407
|
-
/* @__PURE__ */
|
|
3408
|
-
|
|
3409
|
-
/* @__PURE__ */ jsx("p", { className: "auth-sdk-login-title", children: labels.loginTitle })
|
|
3410
|
-
] }),
|
|
3505
|
+
/* @__PURE__ */ jsx("div", { className: "auth-sdk-login-brand", children: /* @__PURE__ */ jsx(EoceneWordmark, { markSize: 32 }) }),
|
|
3506
|
+
/* @__PURE__ */ jsx("p", { className: "auth-sdk-login-title", children: labels.loginTitle }),
|
|
3411
3507
|
/* @__PURE__ */ jsx("div", { className: "auth-sdk-login-stack", children: loadingMethods ? (
|
|
3412
3508
|
// Skeleton rows while the enabled-methods list loads — avoids
|
|
3413
3509
|
// flashing every provider then removing the disabled ones.
|
|
@@ -3416,20 +3512,73 @@ function AuthLoginPanel({
|
|
|
3416
3512
|
/* @__PURE__ */ jsx("span", { className: "auth-sdk-login-skeleton", "aria-hidden": true })
|
|
3417
3513
|
] })
|
|
3418
3514
|
) : methods.length === 0 ? /* @__PURE__ */ jsx("p", { className: "auth-sdk-login-empty", children: labels.loginNoMethods }) : methods.map((method) => {
|
|
3419
|
-
const
|
|
3515
|
+
const methodBusy = loadingMethod === method;
|
|
3420
3516
|
return /* @__PURE__ */ jsx(
|
|
3421
3517
|
"button",
|
|
3422
3518
|
{
|
|
3423
3519
|
type: "button",
|
|
3424
3520
|
className: "auth-sdk-login-btn",
|
|
3425
|
-
disabled: loadingMethod != null,
|
|
3426
|
-
onClick: () =>
|
|
3427
|
-
|
|
3521
|
+
disabled: pendingMethod != null || loadingMethod != null,
|
|
3522
|
+
onClick: () => {
|
|
3523
|
+
setSubmitted(false);
|
|
3524
|
+
setPendingMethod(method);
|
|
3525
|
+
},
|
|
3526
|
+
children: methodBusy ? labels.loginConnecting : methodLabel(method, labels)
|
|
3428
3527
|
},
|
|
3429
3528
|
method
|
|
3430
3529
|
);
|
|
3431
3530
|
}) }),
|
|
3432
|
-
error ? /* @__PURE__ */ jsx("p", { className: "auth-sdk-login-error", children: error }) : null
|
|
3531
|
+
error ? /* @__PURE__ */ jsx("p", { className: "auth-sdk-login-error", children: error }) : null,
|
|
3532
|
+
pendingMethod ? /* @__PURE__ */ jsxs("div", { className: "auth-sdk-root", role: "presentation", children: [
|
|
3533
|
+
/* @__PURE__ */ jsx(
|
|
3534
|
+
"div",
|
|
3535
|
+
{
|
|
3536
|
+
className: "auth-sdk-backdrop",
|
|
3537
|
+
onClick: busy ? void 0 : () => setPendingMethod(null),
|
|
3538
|
+
"aria-hidden": true
|
|
3539
|
+
}
|
|
3540
|
+
),
|
|
3541
|
+
/* @__PURE__ */ jsxs(
|
|
3542
|
+
"div",
|
|
3543
|
+
{
|
|
3544
|
+
className: "auth-sdk-sign-panel",
|
|
3545
|
+
role: "dialog",
|
|
3546
|
+
"aria-modal": "true",
|
|
3547
|
+
"aria-labelledby": "auth-sdk-login-confirm-title",
|
|
3548
|
+
children: [
|
|
3549
|
+
/* @__PURE__ */ jsx("h2", { id: "auth-sdk-login-confirm-title", className: "auth-sdk-sign-title", children: labels.loginConfirmTitle.replace("{provider}", methodLabel(pendingMethod, labels)) }),
|
|
3550
|
+
/* @__PURE__ */ jsx("p", { className: "auth-sdk-sign-subtitle", children: labels.loginConfirmBody }),
|
|
3551
|
+
/* @__PURE__ */ jsxs("div", { className: "auth-sdk-actions", children: [
|
|
3552
|
+
/* @__PURE__ */ jsx(
|
|
3553
|
+
"button",
|
|
3554
|
+
{
|
|
3555
|
+
type: "button",
|
|
3556
|
+
className: "auth-sdk-btn auth-sdk-btn-secondary",
|
|
3557
|
+
onClick: () => setPendingMethod(null),
|
|
3558
|
+
disabled: busy,
|
|
3559
|
+
children: labels.loginConfirmCancel
|
|
3560
|
+
}
|
|
3561
|
+
),
|
|
3562
|
+
/* @__PURE__ */ jsx(
|
|
3563
|
+
"button",
|
|
3564
|
+
{
|
|
3565
|
+
type: "button",
|
|
3566
|
+
className: "auth-sdk-btn auth-sdk-btn-primary",
|
|
3567
|
+
autoFocus: true,
|
|
3568
|
+
onClick: () => {
|
|
3569
|
+
if (busy) return;
|
|
3570
|
+
setSubmitted(true);
|
|
3571
|
+
onLogin(pendingMethod);
|
|
3572
|
+
},
|
|
3573
|
+
disabled: busy,
|
|
3574
|
+
children: busy ? labels.loginConnecting : labels.loginConfirmContinue
|
|
3575
|
+
}
|
|
3576
|
+
)
|
|
3577
|
+
] })
|
|
3578
|
+
]
|
|
3579
|
+
}
|
|
3580
|
+
)
|
|
3581
|
+
] }) : null
|
|
3433
3582
|
] });
|
|
3434
3583
|
}
|
|
3435
3584
|
function SetPasswordModal({
|
|
@@ -3756,9 +3905,14 @@ var DEFAULT_LABELS = {
|
|
|
3756
3905
|
loginTwitter: "X",
|
|
3757
3906
|
loginGithub: "GitHub",
|
|
3758
3907
|
loginApple: "Apple",
|
|
3908
|
+
loginTelegram: "Telegram",
|
|
3759
3909
|
loginConnecting: "Connecting\u2026",
|
|
3760
3910
|
loginError: "Sign-in failed",
|
|
3761
3911
|
loginNoMethods: "No sign-in methods are enabled for this app yet.",
|
|
3912
|
+
loginConfirmTitle: "Continue with {provider}?",
|
|
3913
|
+
loginConfirmBody: "You'll leave this page to sign in, then return here.",
|
|
3914
|
+
loginConfirmContinue: "Continue",
|
|
3915
|
+
loginConfirmCancel: "Cancel",
|
|
3762
3916
|
oauthWorking: "Completing sign-in\u2026",
|
|
3763
3917
|
oauthFailed: "OAuth failed",
|
|
3764
3918
|
oauthBack: "Back to login",
|
|
@@ -3885,6 +4039,11 @@ function AuthProvider({
|
|
|
3885
4039
|
},
|
|
3886
4040
|
[bump]
|
|
3887
4041
|
);
|
|
4042
|
+
const loginTelegramMiniApp = useCallback(async () => {
|
|
4043
|
+
const result = await clientRef.current.loginTelegramMiniApp();
|
|
4044
|
+
bump();
|
|
4045
|
+
return result;
|
|
4046
|
+
}, [bump]);
|
|
3888
4047
|
const logout = useCallback(() => {
|
|
3889
4048
|
clientRef.current.logout();
|
|
3890
4049
|
bump();
|
|
@@ -4041,6 +4200,7 @@ function AuthProvider({
|
|
|
4041
4200
|
user,
|
|
4042
4201
|
passwordEnabled,
|
|
4043
4202
|
login,
|
|
4203
|
+
loginTelegramMiniApp,
|
|
4044
4204
|
logout,
|
|
4045
4205
|
markActive,
|
|
4046
4206
|
restoreIfNeeded,
|
|
@@ -4064,6 +4224,7 @@ function AuthProvider({
|
|
|
4064
4224
|
user,
|
|
4065
4225
|
passwordEnabled,
|
|
4066
4226
|
login,
|
|
4227
|
+
loginTelegramMiniApp,
|
|
4067
4228
|
logout,
|
|
4068
4229
|
markActive,
|
|
4069
4230
|
restoreIfNeeded,
|
|
@@ -4123,13 +4284,13 @@ function AuthOAuthCallback({
|
|
|
4123
4284
|
if (children) return /* @__PURE__ */ jsx(Fragment, { children: children({ phase, error }) });
|
|
4124
4285
|
if (error) {
|
|
4125
4286
|
return /* @__PURE__ */ jsxs("div", { className: "auth-sdk-root auth-sdk-oauth-page", children: [
|
|
4126
|
-
/* @__PURE__ */ jsx(
|
|
4287
|
+
/* @__PURE__ */ jsx(EoceneWordmark, { markSize: 40 }),
|
|
4127
4288
|
/* @__PURE__ */ jsx("p", { className: "auth-sdk-oauth-error", children: error }),
|
|
4128
4289
|
/* @__PURE__ */ jsx("a", { className: "auth-sdk-link", href: onBackHref, children: labels.oauthBack })
|
|
4129
4290
|
] });
|
|
4130
4291
|
}
|
|
4131
4292
|
return /* @__PURE__ */ jsxs("div", { className: "auth-sdk-root auth-sdk-oauth-page", children: [
|
|
4132
|
-
/* @__PURE__ */ jsx(
|
|
4293
|
+
/* @__PURE__ */ jsx(EoceneWordmark, { markSize: 40 }),
|
|
4133
4294
|
/* @__PURE__ */ jsx("p", { children: phase })
|
|
4134
4295
|
] });
|
|
4135
4296
|
}
|
|
@@ -4154,14 +4315,28 @@ function flagAny(env, keys, defaultOn = false) {
|
|
|
4154
4315
|
}
|
|
4155
4316
|
function authConfigFromViteEnv(env = {}) {
|
|
4156
4317
|
const e = env;
|
|
4157
|
-
const oauthReturnTo = readAny(e, [
|
|
4158
|
-
|
|
4159
|
-
|
|
4318
|
+
const oauthReturnTo = readAny(e, [
|
|
4319
|
+
"VITE_EOCENE_OAUTH_RETURN_TO",
|
|
4320
|
+
"EOCENE_OAUTH_RETURN_TO",
|
|
4321
|
+
"VITE_WAAS_OAUTH_RETURN_TO",
|
|
4322
|
+
"WAAS_OAUTH_RETURN_TO"
|
|
4323
|
+
]);
|
|
4324
|
+
const projectId = readAny(e, ["VITE_EOCENE_PROJECT_ID", "EOCENE_PROJECT_ID", "VITE_WAAS_PROJECT_ID", "WAAS_PROJECT_ID"]) || void 0;
|
|
4325
|
+
const chainRaw = readAny(e, ["VITE_EOCENE_CHAIN_ID", "EOCENE_CHAIN_ID", "VITE_WAAS_CHAIN_ID", "WAAS_CHAIN_ID"]);
|
|
4160
4326
|
const chainId = chainRaw && Number.isFinite(Number(chainRaw)) ? Number(chainRaw) : void 0;
|
|
4161
4327
|
return {
|
|
4162
|
-
controlBaseUrl: readAny(e, ["EOCENE_CONTROL_URL", "WAAS_CONTROL_URL"]) || DEFAULT_CONTROL_BASE_URL,
|
|
4328
|
+
controlBaseUrl: readAny(e, ["VITE_EOCENE_CONTROL_URL", "EOCENE_CONTROL_URL", "VITE_WAAS_CONTROL_URL", "WAAS_CONTROL_URL"]) || DEFAULT_CONTROL_BASE_URL,
|
|
4163
4329
|
oauthReturnTo: oauthReturnTo || (typeof window !== "undefined" ? `${window.location.origin}/login/eocene-callback` : "http://127.0.0.1:5173/login/eocene-callback"),
|
|
4164
|
-
allowDevLoginFallback: flagAny(
|
|
4330
|
+
allowDevLoginFallback: flagAny(
|
|
4331
|
+
e,
|
|
4332
|
+
[
|
|
4333
|
+
"VITE_EOCENE_OAUTH_FALLBACK_DEV",
|
|
4334
|
+
"EOCENE_OAUTH_FALLBACK_DEV",
|
|
4335
|
+
"VITE_WAAS_OAUTH_FALLBACK_DEV",
|
|
4336
|
+
"WAAS_OAUTH_FALLBACK_DEV"
|
|
4337
|
+
],
|
|
4338
|
+
false
|
|
4339
|
+
),
|
|
4165
4340
|
projectId,
|
|
4166
4341
|
chainId,
|
|
4167
4342
|
storageKey: DEFAULT_STORAGE_KEY,
|
|
@@ -4182,6 +4357,6 @@ function authConfigFromViteEnv(env = {}) {
|
|
|
4182
4357
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
4183
4358
|
*/
|
|
4184
4359
|
|
|
4185
|
-
export { AuthClient, AuthLoginPanel, AuthOAuthCallback, AuthProvider, DEFAULT_CONTROL_BASE_URL, DEFAULT_LABELS, DEFAULT_OAUTH_PENDING_KEY, DEFAULT_STORAGE_KEY, EoceneMark, EoceneWordmark, SetPasswordModal, SignConfirmModal, authConfigFromViteEnv, createAuthEip1193Provider, isWaasHttpError, resolveControlAbsoluteUrl, useAuthContext as useAuth };
|
|
4360
|
+
export { AuthClient, AuthLoginPanel, AuthOAuthCallback, AuthProvider, DEFAULT_CONTROL_BASE_URL, DEFAULT_LABELS, DEFAULT_OAUTH_PENDING_KEY, DEFAULT_STORAGE_KEY, EoceneMark, EoceneWordmark, SetPasswordModal, SignConfirmModal, authConfigFromViteEnv, createAuthEip1193Provider, getTelegramInitData, isTelegramMiniApp, isWaasHttpError, resolveControlAbsoluteUrl, useAuthContext as useAuth };
|
|
4186
4361
|
//# sourceMappingURL=index.js.map
|
|
4187
4362
|
//# sourceMappingURL=index.js.map
|