@sneat/auth-ui 0.27.49 → 0.27.51
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/esm2022/lib/pages/login-page/auth-panel.component.js +38 -8
- package/esm2022/lib/pages/login-page/auth-panel.component.js.map +1 -1
- package/esm2022/lib/pages/login-page/email-login-form/email-login-form.component.js +2 -2
- package/esm2022/lib/pages/login-page/email-login-form/email-login-form.component.js.map +1 -1
- package/esm2022/lib/pages/login-page/login-with-telegram.component.js +63 -6
- package/esm2022/lib/pages/login-page/login-with-telegram.component.js.map +1 -1
- package/esm2022/lib/pages/login-page/sign-in-failure-notice.component.js +109 -0
- package/esm2022/lib/pages/login-page/sign-in-failure-notice.component.js.map +1 -0
- package/lib/pages/login-page/auth-panel.component.d.ts +7 -1
- package/lib/pages/login-page/login-with-telegram.component.d.ts +10 -0
- package/lib/pages/login-page/sign-in-failure-notice.component.d.ts +15 -0
- package/package.json +1 -1
- package/tsconfig.lib.prod.tsbuildinfo +1 -1
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import { DOCUMENT } from '@angular/common';
|
|
2
2
|
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, inject, input, output, signal, } from '@angular/core';
|
|
3
3
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
+
import { IonNote } from '@ionic/angular';
|
|
4
5
|
import { ErrorLogger } from '@sneat/core';
|
|
5
6
|
import { newRandomId } from '@sneat/random';
|
|
6
7
|
import { SneatAuthWithTelegramService, } from './sneat-auth-with-telegram.service';
|
|
7
8
|
import { TelegramLoginConfig, TelegramAuthApi, telegramAuthApiFactory, resolveTelegramBotID, } from './telegram-login-config';
|
|
8
9
|
import { loadTelegramLoginScript, telegramLoginApi, } from './telegram-login-js';
|
|
9
10
|
import * as i0 from "@angular/core";
|
|
11
|
+
/** fetch()'s rejection messages for a request that got no response. */
|
|
12
|
+
const FETCH_FAILURE = /Failed to fetch|NetworkError|Load failed/;
|
|
13
|
+
/**
|
|
14
|
+
* A request that got no HTTP response at all: blocked by CORS, offline, or
|
|
15
|
+
* DNS. Angular reports these as status 0; fetch rejects with a TypeError
|
|
16
|
+
* whose message is browser-specific. Any other TypeError is a bug, not a
|
|
17
|
+
* network failure, and keeps the legacy-widget fallback.
|
|
18
|
+
*/
|
|
19
|
+
export function isNetworkError(err) {
|
|
20
|
+
if (err instanceof TypeError)
|
|
21
|
+
return FETCH_FAILURE.test(err.message);
|
|
22
|
+
return (typeof err === 'object' &&
|
|
23
|
+
err !== null &&
|
|
24
|
+
err.status === 0);
|
|
25
|
+
}
|
|
10
26
|
/** Server nonces live 10 minutes; refresh well inside that. */
|
|
11
27
|
const OIDC_NONCE_REFRESH_MS = 8 * 60 * 1000;
|
|
12
28
|
/**
|
|
@@ -42,12 +58,16 @@ export class LoginWithTelegramComponent {
|
|
|
42
58
|
...(ngDevMode ? [{ debugName: "requestAccess" }] : /* istanbul ignore next */ []));
|
|
43
59
|
this.userPic = input(true, /* @ts-ignore */
|
|
44
60
|
...(ngDevMode ? [{ debugName: "userPic" }] : /* istanbul ignore next */ []));
|
|
61
|
+
/** Set when the nonce request never reached the server (CORS, offline). */
|
|
62
|
+
this.unreachable = signal(false, /* @ts-ignore */
|
|
63
|
+
...(ngDevMode ? [{ debugName: "unreachable" }] : /* istanbul ignore next */ []));
|
|
45
64
|
/** Set once the OpenID popup can be offered: Client ID plus a live nonce. */
|
|
46
65
|
this.oidc = signal(undefined, /* @ts-ignore */
|
|
47
66
|
...(ngDevMode ? [{ debugName: "oidc" }] : /* istanbul ignore next */ []));
|
|
48
67
|
// Register while the view is alive, never from a late loader continuation.
|
|
49
68
|
this.destroyRef.onDestroy(() => {
|
|
50
69
|
clearInterval(this.nonceTimer);
|
|
70
|
+
this.widgetObserver?.disconnect();
|
|
51
71
|
const host = this.document.defaultView;
|
|
52
72
|
if (host && host[this.legacyCallbackName] === this.legacyCallback)
|
|
53
73
|
delete host[this.legacyCallbackName];
|
|
@@ -71,8 +91,20 @@ export class LoginWithTelegramComponent {
|
|
|
71
91
|
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
72
92
|
.subscribe({
|
|
73
93
|
next: (cfg) => this.startOIDC(botID, cfg),
|
|
74
|
-
|
|
75
|
-
|
|
94
|
+
error: (err) => {
|
|
95
|
+
if (isNetworkError(err)) {
|
|
96
|
+
// CORS or offline: the legacy widget would need the same server
|
|
97
|
+
// to finish sign-in, so explain instead of failing silently.
|
|
98
|
+
// Shown inline below; still reported, a CORS misconfig is ours.
|
|
99
|
+
this.errorLogger.logError(err, 'Telegram login server unreachable', {
|
|
100
|
+
show: false,
|
|
101
|
+
});
|
|
102
|
+
this.unreachable.set(true);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
// The server answers 400 for a bot without OpenID login configured.
|
|
106
|
+
this.startLegacyWidget(botID);
|
|
107
|
+
},
|
|
76
108
|
});
|
|
77
109
|
}
|
|
78
110
|
loginWithOIDC(cfg) {
|
|
@@ -105,6 +137,7 @@ export class LoginWithTelegramComponent {
|
|
|
105
137
|
return;
|
|
106
138
|
this.oidc.set(cfg);
|
|
107
139
|
clearInterval(this.nonceTimer);
|
|
140
|
+
this.widgetObserver?.disconnect();
|
|
108
141
|
this.nonceTimer = setInterval(() => this.refreshNonce(botID), OIDC_NONCE_REFRESH_MS);
|
|
109
142
|
}, this.errorLogger.logErrorHandler('Failed to load Telegram login library'));
|
|
110
143
|
}
|
|
@@ -142,13 +175,30 @@ export class LoginWithTelegramComponent {
|
|
|
142
175
|
script.setAttribute('data-userpic', 'false');
|
|
143
176
|
}
|
|
144
177
|
script.setAttribute('data-onauth', `${this.legacyCallbackName}(user)`);
|
|
145
|
-
|
|
178
|
+
// The legacy widget inserts its iframe asynchronously without a title.
|
|
179
|
+
// Observe only this widget, and leave an upstream accessible name intact.
|
|
180
|
+
const element = this.el.nativeElement;
|
|
181
|
+
this.widgetObserver = new MutationObserver(() => {
|
|
182
|
+
for (const frame of element.querySelectorAll('iframe')) {
|
|
183
|
+
if (!frame.title.trim())
|
|
184
|
+
frame.title = 'Log in with Telegram';
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
this.widgetObserver.observe(element, { childList: true, subtree: true });
|
|
188
|
+
element.appendChild(script);
|
|
146
189
|
}
|
|
147
190
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: LoginWithTelegramComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
148
191
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: LoginWithTelegramComponent, isStandalone: true, selector: "sneat-login-with-telegram", inputs: { isUserAuthenticated: { classPropertyName: "isUserAuthenticated", publicName: "isUserAuthenticated", isSignal: true, isRequired: false, transformFunction: null }, botID: { classPropertyName: "botID", publicName: "botID", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, requestAccess: { classPropertyName: "requestAccess", publicName: "requestAccess", isSignal: true, isRequired: false, transformFunction: null }, userPic: { classPropertyName: "userPic", publicName: "userPic", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { authenticated: "authenticated", authenticationFailed: "authenticationFailed" }, providers: [
|
|
149
192
|
SneatAuthWithTelegramService,
|
|
150
193
|
{ provide: TelegramAuthApi, useFactory: telegramAuthApiFactory },
|
|
151
194
|
], ngImport: i0, template: `
|
|
195
|
+
@if (unreachable()) {
|
|
196
|
+
<ion-note class="tg-unreachable" color="danger" role="status">
|
|
197
|
+
Telegram login is unavailable: we couldn't reach the sign-in server
|
|
198
|
+
(network or site configuration problem). Please use another method or
|
|
199
|
+
try again later.
|
|
200
|
+
</ion-note>
|
|
201
|
+
}
|
|
152
202
|
@if (oidc(); as cfg) {
|
|
153
203
|
<button
|
|
154
204
|
type="button"
|
|
@@ -159,14 +209,21 @@ export class LoginWithTelegramComponent {
|
|
|
159
209
|
Log in with Telegram
|
|
160
210
|
</button>
|
|
161
211
|
}
|
|
162
|
-
`, isInline: true, styles: [".tg-oidc-login{background:#54a9eb;color:#
|
|
212
|
+
`, isInline: true, styles: [".tg-oidc-login{background:#54a9eb;color:#082f49;border:0;border-radius:20px;font-weight:500;cursor:pointer;font-size:16px;padding:10px 21px}.tg-oidc-login[data-size=medium]{font-size:14px;padding:8px 16px}.tg-oidc-login[data-size=small]{font-size:13px;padding:6px 12px}\n"], dependencies: [{ kind: "component", type: IonNote, selector: "ion-note", inputs: ["color", "mode"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
163
213
|
}
|
|
164
214
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: LoginWithTelegramComponent, decorators: [{
|
|
165
215
|
type: Component,
|
|
166
216
|
args: [{ providers: [
|
|
167
217
|
SneatAuthWithTelegramService,
|
|
168
218
|
{ provide: TelegramAuthApi, useFactory: telegramAuthApiFactory },
|
|
169
|
-
], selector: 'sneat-login-with-telegram', changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
219
|
+
], selector: 'sneat-login-with-telegram', changeDetection: ChangeDetectionStrategy.OnPush, imports: [IonNote], template: `
|
|
220
|
+
@if (unreachable()) {
|
|
221
|
+
<ion-note class="tg-unreachable" color="danger" role="status">
|
|
222
|
+
Telegram login is unavailable: we couldn't reach the sign-in server
|
|
223
|
+
(network or site configuration problem). Please use another method or
|
|
224
|
+
try again later.
|
|
225
|
+
</ion-note>
|
|
226
|
+
}
|
|
170
227
|
@if (oidc(); as cfg) {
|
|
171
228
|
<button
|
|
172
229
|
type="button"
|
|
@@ -177,6 +234,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
177
234
|
Log in with Telegram
|
|
178
235
|
</button>
|
|
179
236
|
}
|
|
180
|
-
`, styles: [".tg-oidc-login{background:#54a9eb;color:#
|
|
237
|
+
`, styles: [".tg-oidc-login{background:#54a9eb;color:#082f49;border:0;border-radius:20px;font-weight:500;cursor:pointer;font-size:16px;padding:10px 21px}.tg-oidc-login[data-size=medium]{font-size:14px;padding:8px 16px}.tg-oidc-login[data-size=small]{font-size:13px;padding:6px 12px}\n"] }]
|
|
181
238
|
}], ctorParameters: () => [], propDecorators: { authenticated: [{ type: i0.Output, args: ["authenticated"] }], authenticationFailed: [{ type: i0.Output, args: ["authenticationFailed"] }], isUserAuthenticated: [{ type: i0.Input, args: [{ isSignal: true, alias: "isUserAuthenticated", required: false }] }], botID: [{ type: i0.Input, args: [{ isSignal: true, alias: "botID", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], requestAccess: [{ type: i0.Input, args: [{ isSignal: true, alias: "requestAccess", required: false }] }], userPic: [{ type: i0.Input, args: [{ isSignal: true, alias: "userPic", required: false }] }] } });
|
|
182
239
|
//# sourceMappingURL=login-with-telegram.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-with-telegram.component.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/pages/login-page/login-with-telegram.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,UAAU,EACV,UAAU,EAEV,MAAM,EACN,KAAK,EACL,MAAM,EACN,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAgB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAGL,4BAA4B,GAC7B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,uBA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AC,qBAAqB,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;QACjE,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACpB,MAAM,CAAC,YAAY,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;QACD,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC,kBAAkB,QAAQ,CAAC,CAAC;QACvE,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;8GAxJU,0BAA0B;kGAA1B,0BAA0B,40BAzC1B;YACT,4BAA4B;YAC5B,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,sBAAsB,EAAE;SACjE,0BAGS;;;;;;;;;;;GAWT;;2FAwBU,0BAA0B;kBA1CtC,SAAS;gCACG;wBACT,4BAA4B;wBAC5B,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,sBAAsB,EAAE;qBACjE,YACS,2BAA2B,mBACpB,uBAAuB,CAAC,MAAM,YACrC;;;;;;;;;;;GAWT","sourcesContent":["import { DOCUMENT } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n OnInit,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { ErrorLogger, IErrorLogger } from '@sneat/core';\nimport { newRandomId } from '@sneat/random';\nimport {\n ITelegramAuthData,\n ITelegramOIDCNonce,\n SneatAuthWithTelegramService,\n} from './sneat-auth-with-telegram.service';\nimport {\n TelegramLoginConfig,\n TelegramAuthApi,\n telegramAuthApiFactory,\n resolveTelegramBotID,\n} from './telegram-login-config';\nimport {\n ITelegramLoginResult,\n loadTelegramLoginScript,\n telegramLoginApi,\n} from './telegram-login-js';\n\n/** Server nonces live 10 minutes; refresh well inside that. */\nconst OIDC_NONCE_REFRESH_MS = 8 * 60 * 1000;\n\ntype LegacyTelegramWindow = Window & {\n [name: `sneatTelegramAuth_${string}`]:\n ((data: ITelegramAuthData) => void) | undefined;\n};\n\n/**\n * Telegram login button. Bots with OpenID login configured server-side use\n * Telegram's OpenID popup (telegram-login.js); others keep the legacy Login\n * Widget (telegram-widget.js), e.g. the local dev bot.\n */\n@Component({\n providers: [\n SneatAuthWithTelegramService,\n { provide: TelegramAuthApi, useFactory: telegramAuthApiFactory },\n ],\n selector: 'sneat-login-with-telegram',\n changeDetection: ChangeDetectionStrategy.OnPush,\n template: `\n @if (oidc(); as cfg) {\n <button\n type=\"button\"\n class=\"tg-oidc-login\"\n [attr.data-size]=\"size()\"\n (click)=\"loginWithOIDC(cfg)\"\n >\n Log in with Telegram\n </button>\n }\n `,\n styles: [\n `\n .tg-oidc-login {\n background: #54a9eb;\n color: #fff;\n border: 0;\n border-radius: 20px;\n font-weight: 500;\n cursor: pointer;\n font-size: 16px;\n padding: 10px 21px;\n }\n .tg-oidc-login[data-size='medium'] {\n font-size: 14px;\n padding: 8px 16px;\n }\n .tg-oidc-login[data-size='small'] {\n font-size: 13px;\n padding: 6px 12px;\n }\n `,\n ],\n})\nexport class LoginWithTelegramComponent implements OnInit {\n private readonly el = inject(ElementRef);\n private readonly document = inject<Document>(DOCUMENT);\n private readonly destroyRef = inject(DestroyRef);\n private readonly errorLogger = inject<IErrorLogger>(ErrorLogger);\n readonly authWithTelegram = inject(SneatAuthWithTelegramService);\n private readonly telegramLoginConfig = inject(TelegramLoginConfig, {\n optional: true,\n });\n\n private nonceTimer?: ReturnType<typeof setInterval>;\n private legacyCallback?: (data: ITelegramAuthData) => void;\n private readonly legacyCallbackName = `sneatTelegramAuth_${newRandomId({\n len: 20,\n digits: true,\n lowerCaseLetters: true,\n upperCaseLetters: true,\n })}` as const;\n\n constructor() {\n // Register while the view is alive, never from a late loader continuation.\n this.destroyRef.onDestroy(() => {\n clearInterval(this.nonceTimer);\n const host = this.document.defaultView as LegacyTelegramWindow | null;\n if (host && host[this.legacyCallbackName] === this.legacyCallback)\n delete host[this.legacyCallbackName];\n });\n }\n\n public readonly authenticated = output<void>();\n public readonly authenticationFailed = output<void>();\n\n public readonly isUserAuthenticated = input(false);\n\n public readonly botID = input<string>(\n resolveTelegramBotID(this.telegramLoginConfig, location.hostname),\n );\n\n public readonly size = input<'small' | 'medium' | 'large'>('large');\n public readonly requestAccess = input<'write' | 'read'>('write');\n public readonly userPic = input(true);\n\n /** Set once the OpenID popup can be offered: Client ID plus a live nonce. */\n protected readonly oidc = signal<ITelegramOIDCNonce | undefined>(undefined);\n\n ngOnInit() {\n this.authWithTelegram.authenticationResult\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe((success) => {\n if (success) this.authenticated.emit();\n else this.authenticationFailed.emit();\n });\n const botID = this.botID();\n if (!botID) {\n return;\n }\n this.authWithTelegram\n .getTelegramOIDCNonce(botID)\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe({\n next: (cfg) => this.startOIDC(botID, cfg),\n // The server answers 400 for a bot without OpenID login configured.\n error: () => this.startLegacyWidget(botID),\n });\n }\n\n protected loginWithOIDC(cfg: ITelegramOIDCNonce): void {\n if (this.destroyRef.destroyed) return;\n const api = telegramLoginApi(this.document.defaultView ?? window);\n if (!api) {\n this.errorLogger.logErrorHandler('Telegram login library not loaded')(\n new Error('window.Telegram.Login is undefined'),\n );\n return;\n }\n const botID = this.botID();\n // Called straight from the click handler: the library opens its popup\n // synchronously, which keeps the browser's popup blocker out of the way.\n api.auth(\n {\n client_id: Number(cfg.clientID),\n nonce: cfg.nonce,\n request_access: this.requestAccess() === 'write' ? ['write'] : [],\n },\n (result: ITelegramLoginResult) => {\n if (result.id_token && !this.destroyRef.destroyed) {\n this.authWithTelegram.loginWithTelegramOIDC(\n botID,\n result.id_token,\n this.isUserAuthenticated(),\n );\n this.refreshNonce(botID);\n }\n // result.error (e.g. the user closed the popup) needs no action:\n // the button stays, and the user can try again.\n },\n );\n }\n\n private startOIDC(botID: string, cfg: ITelegramOIDCNonce): void {\n loadTelegramLoginScript(this.document).then(() => {\n if (this.destroyRef.destroyed) return;\n this.oidc.set(cfg);\n clearInterval(this.nonceTimer);\n this.nonceTimer = setInterval(\n () => this.refreshNonce(botID),\n OIDC_NONCE_REFRESH_MS,\n );\n }, this.errorLogger.logErrorHandler('Failed to load Telegram login library'));\n }\n\n private refreshNonce(botID: string): void {\n this.authWithTelegram\n .getTelegramOIDCNonce(botID)\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe({\n next: (cfg) => this.oidc.set(cfg),\n error: this.errorLogger.logErrorHandler(\n 'Failed to refresh Telegram login nonce',\n ),\n });\n }\n\n private startLegacyWidget(botID: string): void {\n if (this.destroyRef.destroyed) return;\n this.legacyCallback = (tgAuthData: ITelegramAuthData) => {\n if (this.destroyRef.destroyed) return;\n // https://core.telegram.org/widgets/login-legacy\n // After a successful authorization, the widget returns data\n // by calling the callback function data-onauth with the JSON-object containing\n // id, first_name, last_name, username, photo_url, auth_date and hash fields.\n this.authWithTelegram.loginWithTelegram(\n botID,\n tgAuthData,\n this.isUserAuthenticated(),\n );\n };\n\n const host = this.document.defaultView as LegacyTelegramWindow | null;\n if (!host) return;\n host[this.legacyCallbackName] = this.legacyCallback;\n const script = this.document.createElement('script');\n\n script.src = 'https://telegram.org/js/telegram-widget.js?22';\n script.setAttribute('data-telegram-login', botID);\n script.setAttribute('data-request-access', this.requestAccess());\n script.setAttribute('data-size', this.size());\n if (!this.userPic()) {\n script.setAttribute('data-userpic', 'false');\n }\n script.setAttribute('data-onauth', `${this.legacyCallbackName}(user)`);\n this.el.nativeElement.appendChild(script);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"login-with-telegram.component.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/pages/login-page/login-with-telegram.component.ts"],"names":[],"mappings":"AAAA,OAAO,EA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ACG;wBACT,4BAA4B;wBAC5B,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,sBAAsB,EAAE;qBACjE,YACS,2BAA2B,mBACpB,uBAAuB,CAAC,MAAM,WACtC,CAAC,OAAO,CAAC,YACR;;;;;;;;;;;;;;;;;;GAkBT","sourcesContent":["import { DOCUMENT } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n OnInit,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { IonNote } from '@ionic/angular';\nimport { ErrorLogger, IErrorLogger } from '@sneat/core';\nimport { newRandomId } from '@sneat/random';\nimport {\n ITelegramAuthData,\n ITelegramOIDCNonce,\n SneatAuthWithTelegramService,\n} from './sneat-auth-with-telegram.service';\nimport {\n TelegramLoginConfig,\n TelegramAuthApi,\n telegramAuthApiFactory,\n resolveTelegramBotID,\n} from './telegram-login-config';\nimport {\n ITelegramLoginResult,\n loadTelegramLoginScript,\n telegramLoginApi,\n} from './telegram-login-js';\n\n/** fetch()'s rejection messages for a request that got no response. */\nconst FETCH_FAILURE = /Failed to fetch|NetworkError|Load failed/;\n\n/**\n * A request that got no HTTP response at all: blocked by CORS, offline, or\n * DNS. Angular reports these as status 0; fetch rejects with a TypeError\n * whose message is browser-specific. Any other TypeError is a bug, not a\n * network failure, and keeps the legacy-widget fallback.\n */\nexport function isNetworkError(err: unknown): boolean {\n if (err instanceof TypeError) return FETCH_FAILURE.test(err.message);\n return (\n typeof err === 'object' &&\n err !== null &&\n (err as { status?: unknown }).status === 0\n );\n}\n\n/** Server nonces live 10 minutes; refresh well inside that. */\nconst OIDC_NONCE_REFRESH_MS = 8 * 60 * 1000;\n\ntype LegacyTelegramWindow = Window & {\n [name: `sneatTelegramAuth_${string}`]:\n ((data: ITelegramAuthData) => void) | undefined;\n};\n\n/**\n * Telegram login button. Bots with OpenID login configured server-side use\n * Telegram's OpenID popup (telegram-login.js); others keep the legacy Login\n * Widget (telegram-widget.js), e.g. the local dev bot.\n */\n@Component({\n providers: [\n SneatAuthWithTelegramService,\n { provide: TelegramAuthApi, useFactory: telegramAuthApiFactory },\n ],\n selector: 'sneat-login-with-telegram',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [IonNote],\n template: `\n @if (unreachable()) {\n <ion-note class=\"tg-unreachable\" color=\"danger\" role=\"status\">\n Telegram login is unavailable: we couldn't reach the sign-in server\n (network or site configuration problem). Please use another method or\n try again later.\n </ion-note>\n }\n @if (oidc(); as cfg) {\n <button\n type=\"button\"\n class=\"tg-oidc-login\"\n [attr.data-size]=\"size()\"\n (click)=\"loginWithOIDC(cfg)\"\n >\n Log in with Telegram\n </button>\n }\n `,\n styles: [\n `\n .tg-oidc-login {\n background: #54a9eb;\n color: #082f49;\n border: 0;\n border-radius: 20px;\n font-weight: 500;\n cursor: pointer;\n font-size: 16px;\n padding: 10px 21px;\n }\n .tg-oidc-login[data-size='medium'] {\n font-size: 14px;\n padding: 8px 16px;\n }\n .tg-oidc-login[data-size='small'] {\n font-size: 13px;\n padding: 6px 12px;\n }\n `,\n ],\n})\nexport class LoginWithTelegramComponent implements OnInit {\n private readonly el = inject(ElementRef);\n private readonly document = inject<Document>(DOCUMENT);\n private readonly destroyRef = inject(DestroyRef);\n private readonly errorLogger = inject<IErrorLogger>(ErrorLogger);\n readonly authWithTelegram = inject(SneatAuthWithTelegramService);\n private readonly telegramLoginConfig = inject(TelegramLoginConfig, {\n optional: true,\n });\n\n private nonceTimer?: ReturnType<typeof setInterval>;\n private widgetObserver?: MutationObserver;\n private legacyCallback?: (data: ITelegramAuthData) => void;\n private readonly legacyCallbackName = `sneatTelegramAuth_${newRandomId({\n len: 20,\n digits: true,\n lowerCaseLetters: true,\n upperCaseLetters: true,\n })}` as const;\n\n constructor() {\n // Register while the view is alive, never from a late loader continuation.\n this.destroyRef.onDestroy(() => {\n clearInterval(this.nonceTimer);\n this.widgetObserver?.disconnect();\n const host = this.document.defaultView as LegacyTelegramWindow | null;\n if (host && host[this.legacyCallbackName] === this.legacyCallback)\n delete host[this.legacyCallbackName];\n });\n }\n\n public readonly authenticated = output<void>();\n public readonly authenticationFailed = output<void>();\n\n public readonly isUserAuthenticated = input(false);\n\n public readonly botID = input<string>(\n resolveTelegramBotID(this.telegramLoginConfig, location.hostname),\n );\n\n public readonly size = input<'small' | 'medium' | 'large'>('large');\n public readonly requestAccess = input<'write' | 'read'>('write');\n public readonly userPic = input(true);\n\n /** Set when the nonce request never reached the server (CORS, offline). */\n protected readonly unreachable = signal(false);\n\n /** Set once the OpenID popup can be offered: Client ID plus a live nonce. */\n protected readonly oidc = signal<ITelegramOIDCNonce | undefined>(undefined);\n\n ngOnInit() {\n this.authWithTelegram.authenticationResult\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe((success) => {\n if (success) this.authenticated.emit();\n else this.authenticationFailed.emit();\n });\n const botID = this.botID();\n if (!botID) {\n return;\n }\n this.authWithTelegram\n .getTelegramOIDCNonce(botID)\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe({\n next: (cfg) => this.startOIDC(botID, cfg),\n error: (err: unknown) => {\n if (isNetworkError(err)) {\n // CORS or offline: the legacy widget would need the same server\n // to finish sign-in, so explain instead of failing silently.\n // Shown inline below; still reported, a CORS misconfig is ours.\n this.errorLogger.logError(\n err,\n 'Telegram login server unreachable',\n {\n show: false,\n },\n );\n this.unreachable.set(true);\n return;\n }\n // The server answers 400 for a bot without OpenID login configured.\n this.startLegacyWidget(botID);\n },\n });\n }\n\n protected loginWithOIDC(cfg: ITelegramOIDCNonce): void {\n if (this.destroyRef.destroyed) return;\n const api = telegramLoginApi(this.document.defaultView ?? window);\n if (!api) {\n this.errorLogger.logErrorHandler('Telegram login library not loaded')(\n new Error('window.Telegram.Login is undefined'),\n );\n return;\n }\n const botID = this.botID();\n // Called straight from the click handler: the library opens its popup\n // synchronously, which keeps the browser's popup blocker out of the way.\n api.auth(\n {\n client_id: Number(cfg.clientID),\n nonce: cfg.nonce,\n request_access: this.requestAccess() === 'write' ? ['write'] : [],\n },\n (result: ITelegramLoginResult) => {\n if (result.id_token && !this.destroyRef.destroyed) {\n this.authWithTelegram.loginWithTelegramOIDC(\n botID,\n result.id_token,\n this.isUserAuthenticated(),\n );\n this.refreshNonce(botID);\n }\n // result.error (e.g. the user closed the popup) needs no action:\n // the button stays, and the user can try again.\n },\n );\n }\n\n private startOIDC(botID: string, cfg: ITelegramOIDCNonce): void {\n loadTelegramLoginScript(this.document).then(() => {\n if (this.destroyRef.destroyed) return;\n this.oidc.set(cfg);\n clearInterval(this.nonceTimer);\n this.widgetObserver?.disconnect();\n this.nonceTimer = setInterval(\n () => this.refreshNonce(botID),\n OIDC_NONCE_REFRESH_MS,\n );\n }, this.errorLogger.logErrorHandler('Failed to load Telegram login library'));\n }\n\n private refreshNonce(botID: string): void {\n this.authWithTelegram\n .getTelegramOIDCNonce(botID)\n .pipe(takeUntilDestroyed(this.destroyRef))\n .subscribe({\n next: (cfg) => this.oidc.set(cfg),\n error: this.errorLogger.logErrorHandler(\n 'Failed to refresh Telegram login nonce',\n ),\n });\n }\n\n private startLegacyWidget(botID: string): void {\n if (this.destroyRef.destroyed) return;\n this.legacyCallback = (tgAuthData: ITelegramAuthData) => {\n if (this.destroyRef.destroyed) return;\n // https://core.telegram.org/widgets/login-legacy\n // After a successful authorization, the widget returns data\n // by calling the callback function data-onauth with the JSON-object containing\n // id, first_name, last_name, username, photo_url, auth_date and hash fields.\n this.authWithTelegram.loginWithTelegram(\n botID,\n tgAuthData,\n this.isUserAuthenticated(),\n );\n };\n\n const host = this.document.defaultView as LegacyTelegramWindow | null;\n if (!host) return;\n host[this.legacyCallbackName] = this.legacyCallback;\n const script = this.document.createElement('script');\n\n script.src = 'https://telegram.org/js/telegram-widget.js?22';\n script.setAttribute('data-telegram-login', botID);\n script.setAttribute('data-request-access', this.requestAccess());\n script.setAttribute('data-size', this.size());\n if (!this.userPic()) {\n script.setAttribute('data-userpic', 'false');\n }\n script.setAttribute('data-onauth', `${this.legacyCallbackName}(user)`);\n // The legacy widget inserts its iframe asynchronously without a title.\n // Observe only this widget, and leave an upstream accessible name intact.\n const element = this.el.nativeElement as HTMLElement;\n this.widgetObserver = new MutationObserver(() => {\n for (const frame of element.querySelectorAll('iframe')) {\n if (!frame.title.trim()) frame.title = 'Log in with Telegram';\n }\n });\n this.widgetObserver.observe(element, { childList: true, subtree: true });\n element.appendChild(script);\n }\n}\n"]}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input, output, } from '@angular/core';
|
|
2
|
+
import { IonButton, IonItem, IonLabel, IonNote, IonText } from '@ionic/angular';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Explains why the user is still on the sign-in form: a short summary, what
|
|
6
|
+
* to try, and the technical details support needs. Non-blocking — the sign-in
|
|
7
|
+
* methods stay usable below it.
|
|
8
|
+
*/
|
|
9
|
+
export class SignInFailureNoticeComponent {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.failure = input(/* @ts-ignore */
|
|
12
|
+
...(ngDevMode ? [undefined, { debugName: "failure" }] : /* istanbul ignore next */ []));
|
|
13
|
+
this.canRetry = input(false, /* @ts-ignore */
|
|
14
|
+
...(ngDevMode ? [{ debugName: "canRetry" }] : /* istanbul ignore next */ []));
|
|
15
|
+
this.retry = output();
|
|
16
|
+
this.dismiss = output();
|
|
17
|
+
}
|
|
18
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SignInFailureNoticeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
19
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.3", type: SignInFailureNoticeComponent, isStandalone: true, selector: "sneat-sign-in-failure-notice", inputs: { failure: { classPropertyName: "failure", publicName: "failure", isSignal: true, isRequired: false, transformFunction: null }, canRetry: { classPropertyName: "canRetry", publicName: "canRetry", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { retry: "retry", dismiss: "dismiss" }, ngImport: i0, template: `
|
|
20
|
+
@if (failure(); as f) {
|
|
21
|
+
<div role="alert">
|
|
22
|
+
<ion-item lines="none">
|
|
23
|
+
<ion-label class="ion-text-wrap">
|
|
24
|
+
<h2>
|
|
25
|
+
<ion-text color="danger">{{ f.summary }}</ion-text>
|
|
26
|
+
</h2>
|
|
27
|
+
@for (hint of f.hints; track hint) {
|
|
28
|
+
<p class="sign-in-failure-hint">{{ hint }}</p>
|
|
29
|
+
}
|
|
30
|
+
<ion-note class="sign-in-failure-details">
|
|
31
|
+
Details:
|
|
32
|
+
@if (f.code) {
|
|
33
|
+
<code>{{ f.code }}</code>
|
|
34
|
+
}
|
|
35
|
+
@if (f.message) {
|
|
36
|
+
— {{ f.message }}
|
|
37
|
+
}
|
|
38
|
+
@if (f.host) {
|
|
39
|
+
(on {{ f.host }})
|
|
40
|
+
}
|
|
41
|
+
</ion-note>
|
|
42
|
+
</ion-label>
|
|
43
|
+
</ion-item>
|
|
44
|
+
<div class="ion-padding-horizontal">
|
|
45
|
+
@if (canRetry()) {
|
|
46
|
+
<ion-button size="small" fill="outline" (click)="retry.emit()">
|
|
47
|
+
Try again
|
|
48
|
+
</ion-button>
|
|
49
|
+
}
|
|
50
|
+
<ion-button
|
|
51
|
+
size="small"
|
|
52
|
+
fill="clear"
|
|
53
|
+
color="medium"
|
|
54
|
+
(click)="dismiss.emit()"
|
|
55
|
+
>
|
|
56
|
+
Dismiss
|
|
57
|
+
</ion-button>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
}
|
|
61
|
+
`, isInline: true, styles: [".sign-in-failure-details{display:block;font-size:smaller;margin-top:4px;-webkit-user-select:text;user-select:text}\n"], dependencies: [{ kind: "component", type: IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"], outputs: ["ionFocus", "ionBlur"] }, { kind: "component", type: IonItem, selector: "ion-item", inputs: ["button", "color", "detail", "detailIcon", "disabled", "download", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonLabel, selector: "ion-label", inputs: ["color", "mode", "position"] }, { kind: "component", type: IonNote, selector: "ion-note", inputs: ["color", "mode"] }, { kind: "component", type: IonText, selector: "ion-text", inputs: ["color", "mode"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
62
|
+
}
|
|
63
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SignInFailureNoticeComponent, decorators: [{
|
|
64
|
+
type: Component,
|
|
65
|
+
args: [{ selector: 'sneat-sign-in-failure-notice', changeDetection: ChangeDetectionStrategy.OnPush, imports: [IonButton, IonItem, IonLabel, IonNote, IonText], template: `
|
|
66
|
+
@if (failure(); as f) {
|
|
67
|
+
<div role="alert">
|
|
68
|
+
<ion-item lines="none">
|
|
69
|
+
<ion-label class="ion-text-wrap">
|
|
70
|
+
<h2>
|
|
71
|
+
<ion-text color="danger">{{ f.summary }}</ion-text>
|
|
72
|
+
</h2>
|
|
73
|
+
@for (hint of f.hints; track hint) {
|
|
74
|
+
<p class="sign-in-failure-hint">{{ hint }}</p>
|
|
75
|
+
}
|
|
76
|
+
<ion-note class="sign-in-failure-details">
|
|
77
|
+
Details:
|
|
78
|
+
@if (f.code) {
|
|
79
|
+
<code>{{ f.code }}</code>
|
|
80
|
+
}
|
|
81
|
+
@if (f.message) {
|
|
82
|
+
— {{ f.message }}
|
|
83
|
+
}
|
|
84
|
+
@if (f.host) {
|
|
85
|
+
(on {{ f.host }})
|
|
86
|
+
}
|
|
87
|
+
</ion-note>
|
|
88
|
+
</ion-label>
|
|
89
|
+
</ion-item>
|
|
90
|
+
<div class="ion-padding-horizontal">
|
|
91
|
+
@if (canRetry()) {
|
|
92
|
+
<ion-button size="small" fill="outline" (click)="retry.emit()">
|
|
93
|
+
Try again
|
|
94
|
+
</ion-button>
|
|
95
|
+
}
|
|
96
|
+
<ion-button
|
|
97
|
+
size="small"
|
|
98
|
+
fill="clear"
|
|
99
|
+
color="medium"
|
|
100
|
+
(click)="dismiss.emit()"
|
|
101
|
+
>
|
|
102
|
+
Dismiss
|
|
103
|
+
</ion-button>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
}
|
|
107
|
+
`, styles: [".sign-in-failure-details{display:block;font-size:smaller;margin-top:4px;-webkit-user-select:text;user-select:text}\n"] }]
|
|
108
|
+
}], propDecorators: { failure: [{ type: i0.Input, args: [{ isSignal: true, alias: "failure", required: false }] }], canRetry: [{ type: i0.Input, args: [{ isSignal: true, alias: "canRetry", required: false }] }], retry: [{ type: i0.Output, args: ["retry"] }], dismiss: [{ type: i0.Output, args: ["dismiss"] }] } });
|
|
109
|
+
//# sourceMappingURL=sign-in-failure-notice.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-in-failure-notice.component.js","sourceRoot":"","sources":["../../../../../../../../libs/auth/ui/src/lib/pages/login-page/sign-in-failure-notice.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,SAAS,EACT,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;;AAGhF;;;;GAIG;AA2DH,MAAM,OAAO,4BAA4B;IA1DzC;QA2DW,YAAO,GAAG,KAAK;+FAA8B,CAAC;QAC9C,aAAQ,GAAG,KAAK,CAAC,KAAK;qFAAC,CAAC;QACxB,UAAK,GAAG,MAAM,EAAQ,CAAC;QACvB,YAAO,GAAG,MAAM,EAAQ,CAAC;KACnC;8GALY,4BAA4B;kGAA5B,4BAA4B,oZAtD7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CT,8LA3CS,SAAS,sRAAE,OAAO,0NAAE,QAAQ,6FAAE,OAAO,gFAAE,OAAO;;2FAuD7C,4BAA4B;kBA1DxC,SAAS;+BACE,8BAA8B,mBACvB,uBAAuB,CAAC,MAAM,WACtC,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,YAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CT","sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n input,\n output,\n} from '@angular/core';\nimport { IonButton, IonItem, IonLabel, IonNote, IonText } from '@ionic/angular';\nimport { ISignInFailure } from '@sneat/auth-core';\n\n/**\n * Explains why the user is still on the sign-in form: a short summary, what\n * to try, and the technical details support needs. Non-blocking — the sign-in\n * methods stay usable below it.\n */\n@Component({\n selector: 'sneat-sign-in-failure-notice',\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [IonButton, IonItem, IonLabel, IonNote, IonText],\n template: `\n @if (failure(); as f) {\n <div role=\"alert\">\n <ion-item lines=\"none\">\n <ion-label class=\"ion-text-wrap\">\n <h2>\n <ion-text color=\"danger\">{{ f.summary }}</ion-text>\n </h2>\n @for (hint of f.hints; track hint) {\n <p class=\"sign-in-failure-hint\">{{ hint }}</p>\n }\n <ion-note class=\"sign-in-failure-details\">\n Details:\n @if (f.code) {\n <code>{{ f.code }}</code>\n }\n @if (f.message) {\n — {{ f.message }}\n }\n @if (f.host) {\n (on {{ f.host }})\n }\n </ion-note>\n </ion-label>\n </ion-item>\n <div class=\"ion-padding-horizontal\">\n @if (canRetry()) {\n <ion-button size=\"small\" fill=\"outline\" (click)=\"retry.emit()\">\n Try again\n </ion-button>\n }\n <ion-button\n size=\"small\"\n fill=\"clear\"\n color=\"medium\"\n (click)=\"dismiss.emit()\"\n >\n Dismiss\n </ion-button>\n </div>\n </div>\n }\n `,\n styles: [\n `\n .sign-in-failure-details {\n display: block;\n font-size: smaller;\n margin-top: 4px;\n user-select: text;\n }\n `,\n ],\n})\nexport class SignInFailureNoticeComponent {\n readonly failure = input<ISignInFailure | undefined>();\n readonly canRetry = input(false);\n readonly retry = output<void>();\n readonly dismiss = output<void>();\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter, OnInit } from '@angular/core';
|
|
2
|
-
import { AuthProviderID } from '@sneat/auth-core';
|
|
2
|
+
import { AuthProviderID, ISignInFailure } from '@sneat/auth-core';
|
|
3
3
|
import { UserCredential } from 'firebase/auth';
|
|
4
4
|
import { AuthPanelInitialMode, EmailFormSigningWith } from './email-login-form/email-login-form.component';
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
@@ -20,6 +20,9 @@ export declare class AuthPanelComponent implements OnInit {
|
|
|
20
20
|
protected readonly oauthProviders: ("apple.com" | "google.com" | "microsoft.com" | "facebook.com" | "github.com")[];
|
|
21
21
|
protected readonly oauthSigningWith: import("@angular/core").Signal<"apple.com" | "google.com" | "microsoft.com" | "facebook.com" | "github.com" | undefined>;
|
|
22
22
|
protected readonly authRecoveryNeeded: import("@angular/core").WritableSignal<boolean>;
|
|
23
|
+
/** A sign-in that did not complete, explained above the sign-in methods. */
|
|
24
|
+
protected readonly signInFailure: import("@angular/core").WritableSignal<ISignInFailure | undefined>;
|
|
25
|
+
protected readonly canRetrySignIn: import("@angular/core").Signal<boolean>;
|
|
23
26
|
/**
|
|
24
27
|
* Set when sign-in hit an email that already has an account: names the
|
|
25
28
|
* provider that will be connected once the user signs in the usual way.
|
|
@@ -40,7 +43,10 @@ export declare class AuthPanelComponent implements OnInit {
|
|
|
40
43
|
private readonly userService;
|
|
41
44
|
private readonly errorLogger;
|
|
42
45
|
private readonly destroyRef;
|
|
46
|
+
constructor();
|
|
43
47
|
ngOnInit(): void;
|
|
48
|
+
protected retrySignIn(): void;
|
|
49
|
+
protected dismissSignInFailure(): void;
|
|
44
50
|
protected retryUserRecordInitialization(): void;
|
|
45
51
|
protected onEmailFormStatusChanged(signingWith?: EmailFormSigningWith): void;
|
|
46
52
|
protected loginWith(provider: AuthProviderID): Promise<void>;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { OnInit } from '@angular/core';
|
|
2
2
|
import { ITelegramOIDCNonce, SneatAuthWithTelegramService } from './sneat-auth-with-telegram.service';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* A request that got no HTTP response at all: blocked by CORS, offline, or
|
|
6
|
+
* DNS. Angular reports these as status 0; fetch rejects with a TypeError
|
|
7
|
+
* whose message is browser-specific. Any other TypeError is a bug, not a
|
|
8
|
+
* network failure, and keeps the legacy-widget fallback.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isNetworkError(err: unknown): boolean;
|
|
4
11
|
/**
|
|
5
12
|
* Telegram login button. Bots with OpenID login configured server-side use
|
|
6
13
|
* Telegram's OpenID popup (telegram-login.js); others keep the legacy Login
|
|
@@ -14,6 +21,7 @@ export declare class LoginWithTelegramComponent implements OnInit {
|
|
|
14
21
|
readonly authWithTelegram: SneatAuthWithTelegramService;
|
|
15
22
|
private readonly telegramLoginConfig;
|
|
16
23
|
private nonceTimer?;
|
|
24
|
+
private widgetObserver?;
|
|
17
25
|
private legacyCallback?;
|
|
18
26
|
private readonly legacyCallbackName;
|
|
19
27
|
constructor();
|
|
@@ -24,6 +32,8 @@ export declare class LoginWithTelegramComponent implements OnInit {
|
|
|
24
32
|
readonly size: import("@angular/core").InputSignal<"medium" | "small" | "large">;
|
|
25
33
|
readonly requestAccess: import("@angular/core").InputSignal<"write" | "read">;
|
|
26
34
|
readonly userPic: import("@angular/core").InputSignal<boolean>;
|
|
35
|
+
/** Set when the nonce request never reached the server (CORS, offline). */
|
|
36
|
+
protected readonly unreachable: import("@angular/core").WritableSignal<boolean>;
|
|
27
37
|
/** Set once the OpenID popup can be offered: Client ID plus a live nonce. */
|
|
28
38
|
protected readonly oidc: import("@angular/core").WritableSignal<ITelegramOIDCNonce | undefined>;
|
|
29
39
|
ngOnInit(): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ISignInFailure } from '@sneat/auth-core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Explains why the user is still on the sign-in form: a short summary, what
|
|
5
|
+
* to try, and the technical details support needs. Non-blocking — the sign-in
|
|
6
|
+
* methods stay usable below it.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SignInFailureNoticeComponent {
|
|
9
|
+
readonly failure: import("@angular/core").InputSignal<ISignInFailure | undefined>;
|
|
10
|
+
readonly canRetry: import("@angular/core").InputSignal<boolean>;
|
|
11
|
+
readonly retry: import("@angular/core").OutputEmitterRef<void>;
|
|
12
|
+
readonly dismiss: import("@angular/core").OutputEmitterRef<void>;
|
|
13
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SignInFailureNoticeComponent, never>;
|
|
14
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SignInFailureNoticeComponent, "sneat-sign-in-failure-notice", never, { "failure": { "alias": "failure"; "required": false; "isSignal": true; }; "canRetry": { "alias": "canRetry"; "required": false; "isSignal": true; }; }, { "retry": "retry"; "dismiss": "dismiss"; }, never, never, true, never>;
|
|
15
|
+
}
|