@youidian/sdk 3.0.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.
@@ -0,0 +1,62 @@
1
+ import { a as HostedFrameMessage } from './hosted-modal-BZmYmXTU.js';
2
+
3
+ type LoginEventType = "LOGIN_SUCCESS" | "LOGIN_CANCELLED" | "LOGIN_CLOSE" | "LOGIN_RESIZE" | "LOGIN_ERROR";
4
+ interface LoginResult {
5
+ avatar?: string | null;
6
+ channel?: string;
7
+ email?: string | null;
8
+ expiresAt?: string;
9
+ legacyCasdoorId?: string;
10
+ loginToken?: string;
11
+ name?: string | null;
12
+ userId?: string;
13
+ wechatOpenId?: string | null;
14
+ wechatUnionId?: string | null;
15
+ }
16
+ interface LoginEventData extends HostedFrameMessage, LoginResult {
17
+ type: LoginEventType;
18
+ error?: string;
19
+ message?: string;
20
+ }
21
+ interface LoginUIOptions {
22
+ /** Origin to validate postMessage (defaults to '*', set for security) */
23
+ allowedOrigin?: string;
24
+ /** Whether the SDK should close the popup after receiving LOGIN_CLOSE. Defaults to true. */
25
+ autoClose?: boolean;
26
+ onCancel?: () => void;
27
+ onClose?: () => void;
28
+ onError?: (message?: string, data?: LoginEventData) => void;
29
+ onSuccess?: (result: LoginResult) => void;
30
+ }
31
+ interface LoginParams {
32
+ appId: string;
33
+ /**
34
+ * @deprecated Use loginUrl instead
35
+ * Defaults to https://pay.imgto.link
36
+ */
37
+ baseUrl?: string;
38
+ /**
39
+ * Hosted login page base URL (e.g. https://pay.youidian.com)
40
+ * Defaults to https://pay.imgto.link
41
+ */
42
+ loginUrl?: string;
43
+ /**
44
+ * Optional locale prefix to prepend to the hosted login path.
45
+ * If omitted, the SDK automatically resolves the locale from the browser language.
46
+ */
47
+ locale?: string;
48
+ /** Preferred provider/channel code */
49
+ preferredChannel?: string;
50
+ }
51
+ declare class LoginUI {
52
+ private popup;
53
+ private messageHandler;
54
+ private closeMonitor;
55
+ private completed;
56
+ private cleanup;
57
+ close(): void;
58
+ openLogin(params: LoginParams, options?: LoginUIOptions): void;
59
+ }
60
+ declare function createLoginUI(): LoginUI;
61
+
62
+ export { type LoginEventData, type LoginEventType, type LoginParams, type LoginResult, LoginUI, type LoginUIOptions, createLoginUI };
package/dist/login.js ADDED
@@ -0,0 +1,332 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ // src/hosted-modal.ts
6
+ var SDK_SUPPORTED_LOCALES = [
7
+ "en",
8
+ "zh-CN",
9
+ "zh-Hant",
10
+ "fr",
11
+ "de",
12
+ "ja",
13
+ "es",
14
+ "ko",
15
+ "nl",
16
+ "it",
17
+ "pt"
18
+ ];
19
+ var SDK_DEFAULT_LOCALE = "zh-CN";
20
+ var SDK_LOCALE_ALIASES = {
21
+ en: "en",
22
+ "en-us": "en",
23
+ "en-gb": "en",
24
+ zh: "zh-CN",
25
+ "zh-cn": "zh-CN",
26
+ "zh-tw": "zh-Hant",
27
+ "zh-hk": "zh-Hant",
28
+ "zh-hant": "zh-Hant",
29
+ "zh-hans": "zh-CN",
30
+ fr: "fr",
31
+ de: "de",
32
+ ja: "ja",
33
+ es: "es",
34
+ ko: "ko",
35
+ nl: "nl",
36
+ it: "it",
37
+ pt: "pt"
38
+ };
39
+ function matchSupportedBaseLocale(locale) {
40
+ const base = locale.toLowerCase().split("-")[0];
41
+ return SDK_SUPPORTED_LOCALES.find((item) => item.toLowerCase() === base);
42
+ }
43
+ function normalizeSdkLocale(locale) {
44
+ if (!locale) return;
45
+ const sanitized = locale.trim().replace(/_/g, "-");
46
+ if (!sanitized) return;
47
+ const lower = sanitized.toLowerCase();
48
+ if (SDK_LOCALE_ALIASES[lower]) {
49
+ return SDK_LOCALE_ALIASES[lower];
50
+ }
51
+ let canonical;
52
+ try {
53
+ canonical = Intl.getCanonicalLocales(sanitized)[0];
54
+ } catch {
55
+ canonical = void 0;
56
+ }
57
+ const candidates = [canonical, sanitized].filter(Boolean);
58
+ for (const candidate of candidates) {
59
+ const candidateLower = candidate.toLowerCase();
60
+ if (SDK_LOCALE_ALIASES[candidateLower]) {
61
+ return SDK_LOCALE_ALIASES[candidateLower];
62
+ }
63
+ if (SDK_SUPPORTED_LOCALES.includes(candidate)) {
64
+ return candidate;
65
+ }
66
+ const baseMatch = matchSupportedBaseLocale(candidate);
67
+ if (baseMatch) {
68
+ return baseMatch;
69
+ }
70
+ }
71
+ }
72
+ function getBrowserLocale() {
73
+ if (typeof navigator === "undefined") return;
74
+ for (const candidate of navigator.languages || []) {
75
+ const normalized = normalizeSdkLocale(candidate);
76
+ if (normalized) return normalized;
77
+ }
78
+ return normalizeSdkLocale(navigator.language);
79
+ }
80
+ function getAutoResolvedLocale(locale) {
81
+ return normalizeSdkLocale(locale) || getBrowserLocale() || SDK_DEFAULT_LOCALE;
82
+ }
83
+ function applyLocaleToUrl(urlValue, locale) {
84
+ if (!locale) return urlValue;
85
+ try {
86
+ const url = new URL(urlValue);
87
+ const localePrefix = `/${locale}`;
88
+ if (!url.pathname.startsWith(`${localePrefix}/`) && url.pathname !== localePrefix) {
89
+ url.pathname = `${localePrefix}${url.pathname}`;
90
+ }
91
+ return url.toString();
92
+ } catch (_error) {
93
+ const localePrefix = `/${locale}`;
94
+ if (!urlValue.startsWith(`${localePrefix}/`) && urlValue !== localePrefix) {
95
+ return `${localePrefix}${urlValue.startsWith("/") ? "" : "/"}${urlValue}`;
96
+ }
97
+ return urlValue;
98
+ }
99
+ }
100
+
101
+ // src/login.ts
102
+ function getOrigin(value) {
103
+ if (!value) return null;
104
+ try {
105
+ return new URL(value).origin;
106
+ } catch {
107
+ return null;
108
+ }
109
+ }
110
+ function buildLoginUrl(params) {
111
+ const { appId, baseUrl = "https://pay.imgto.link", loginUrl } = params;
112
+ const rawBase = (loginUrl || baseUrl).replace(/\/$/, "");
113
+ const parentOrigin = typeof window !== "undefined" ? window.location.origin : void 0;
114
+ let finalUrl;
115
+ try {
116
+ const url = new URL(rawBase);
117
+ if (!/\/auth\/connect\/[^/]+$/.test(url.pathname)) {
118
+ url.pathname = `${url.pathname.replace(/\/$/, "")}/auth/connect/${appId}`.replace(
119
+ /\/{2,}/g,
120
+ "/"
121
+ );
122
+ }
123
+ finalUrl = url.toString();
124
+ } catch (_error) {
125
+ if (/\/auth\/connect\/[^/]+$/.test(rawBase)) {
126
+ finalUrl = rawBase;
127
+ } else {
128
+ finalUrl = `${rawBase}/auth/connect/${appId}`.replace(/\/{2,}/g, "/");
129
+ }
130
+ }
131
+ finalUrl = applyLocaleToUrl(finalUrl, getAutoResolvedLocale(params.locale));
132
+ try {
133
+ const url = new URL(finalUrl);
134
+ if (params.preferredChannel) {
135
+ url.searchParams.set("preferredChannel", params.preferredChannel);
136
+ }
137
+ if (parentOrigin) {
138
+ url.searchParams.set("origin", parentOrigin);
139
+ }
140
+ return url.toString();
141
+ } catch (_error) {
142
+ const searchParams = new URLSearchParams();
143
+ if (params.preferredChannel) {
144
+ searchParams.set("preferredChannel", params.preferredChannel);
145
+ }
146
+ if (parentOrigin) {
147
+ searchParams.set("origin", parentOrigin);
148
+ }
149
+ const query = searchParams.toString();
150
+ if (!query) {
151
+ return finalUrl;
152
+ }
153
+ const separator = finalUrl.includes("?") ? "&" : "?";
154
+ return `${finalUrl}${separator}${query}`;
155
+ }
156
+ }
157
+ function extractLoginResult(data) {
158
+ return {
159
+ avatar: data.avatar,
160
+ channel: data.channel,
161
+ email: data.email,
162
+ expiresAt: data.expiresAt,
163
+ legacyCasdoorId: data.legacyCasdoorId,
164
+ loginToken: data.loginToken,
165
+ name: data.name,
166
+ userId: data.userId,
167
+ wechatOpenId: data.wechatOpenId,
168
+ wechatUnionId: data.wechatUnionId
169
+ };
170
+ }
171
+ var LOGIN_UI_LOG_PREFIX = "[Youidian LoginUI]";
172
+ function logLoginDebug(message, details) {
173
+ if (typeof console === "undefined") return;
174
+ console.debug(LOGIN_UI_LOG_PREFIX, message, details || {});
175
+ }
176
+ function logLoginInfo(message, details) {
177
+ if (typeof console === "undefined") return;
178
+ console.info(LOGIN_UI_LOG_PREFIX, message, details || {});
179
+ }
180
+ function logLoginWarn(message, details) {
181
+ if (typeof console === "undefined") return;
182
+ console.warn(LOGIN_UI_LOG_PREFIX, message, details || {});
183
+ }
184
+ var LoginUI = class {
185
+ constructor() {
186
+ __publicField(this, "popup", null);
187
+ __publicField(this, "messageHandler", null);
188
+ __publicField(this, "closeMonitor", null);
189
+ __publicField(this, "completed", false);
190
+ }
191
+ cleanup() {
192
+ if (typeof window !== "undefined" && this.messageHandler) {
193
+ window.removeEventListener("message", this.messageHandler);
194
+ }
195
+ if (typeof window !== "undefined" && this.closeMonitor) {
196
+ window.clearInterval(this.closeMonitor);
197
+ }
198
+ this.messageHandler = null;
199
+ this.closeMonitor = null;
200
+ this.popup = null;
201
+ this.completed = false;
202
+ }
203
+ close() {
204
+ logLoginInfo("close() called", {
205
+ hasPopup: Boolean(this.popup),
206
+ popupClosed: this.popup?.closed ?? true
207
+ });
208
+ if (this.popup && !this.popup.closed) {
209
+ this.popup.close();
210
+ }
211
+ this.cleanup();
212
+ }
213
+ openLogin(params, options) {
214
+ if (typeof window === "undefined") return;
215
+ if (this.popup && !this.popup.closed) return;
216
+ const finalUrl = buildLoginUrl(params);
217
+ logLoginInfo("Opening hosted login popup", {
218
+ appId: params.appId,
219
+ loginUrl: finalUrl,
220
+ allowedOrigin: options?.allowedOrigin || null,
221
+ autoClose: options?.autoClose ?? true
222
+ });
223
+ const popupWidth = 520;
224
+ const popupHeight = 720;
225
+ const left = Math.max(
226
+ 0,
227
+ Math.round(window.screenX + (window.outerWidth - popupWidth) / 2)
228
+ );
229
+ const top = Math.max(
230
+ 0,
231
+ Math.round(window.screenY + (window.outerHeight - popupHeight) / 2)
232
+ );
233
+ const features = [
234
+ "popup=yes",
235
+ `width=${popupWidth}`,
236
+ `height=${popupHeight}`,
237
+ `left=${left}`,
238
+ `top=${top}`,
239
+ "resizable=yes",
240
+ "scrollbars=yes"
241
+ ].join(",");
242
+ const popup = window.open(finalUrl, "youidian-login", features);
243
+ if (!popup) {
244
+ logLoginWarn("Popup blocked by the browser");
245
+ options?.onError?.("Login popup was blocked");
246
+ return;
247
+ }
248
+ this.popup = popup;
249
+ this.completed = false;
250
+ const allowedOrigin = options?.allowedOrigin;
251
+ const popupOrigin = getOrigin(finalUrl);
252
+ this.messageHandler = (event) => {
253
+ if (allowedOrigin && allowedOrigin !== "*" && event.origin !== allowedOrigin) {
254
+ logLoginWarn("Ignored message due to allowedOrigin mismatch", {
255
+ allowedOrigin,
256
+ eventOrigin: event.origin
257
+ });
258
+ return;
259
+ }
260
+ if (!allowedOrigin && popupOrigin && event.origin !== popupOrigin) {
261
+ logLoginWarn("Ignored message due to popup origin mismatch", {
262
+ expectedOrigin: popupOrigin,
263
+ eventOrigin: event.origin
264
+ });
265
+ return;
266
+ }
267
+ const data = event.data;
268
+ if (!data || typeof data !== "object" || !data.type) {
269
+ logLoginDebug("Ignored non-login postMessage payload");
270
+ return;
271
+ }
272
+ logLoginInfo("Received login event", {
273
+ type: data.type,
274
+ eventOrigin: event.origin
275
+ });
276
+ switch (data.type) {
277
+ case "LOGIN_SUCCESS":
278
+ this.completed = true;
279
+ logLoginInfo("Login succeeded", {
280
+ channel: data.channel || null,
281
+ userId: data.userId || null
282
+ });
283
+ options?.onSuccess?.(extractLoginResult(data));
284
+ break;
285
+ case "LOGIN_CANCELLED":
286
+ logLoginInfo("Login cancelled");
287
+ options?.onCancel?.();
288
+ break;
289
+ case "LOGIN_RESIZE":
290
+ break;
291
+ case "LOGIN_ERROR":
292
+ logLoginWarn("Login flow reported an error", {
293
+ message: data.message || data.error || null
294
+ });
295
+ options?.onError?.(data.message || data.error, data);
296
+ break;
297
+ case "LOGIN_CLOSE":
298
+ if (options?.autoClose === false) {
299
+ logLoginInfo("Login popup requested close; autoClose disabled, keeping popup open");
300
+ options?.onClose?.();
301
+ break;
302
+ }
303
+ logLoginInfo("Login popup requested close; autoClose enabled");
304
+ this.close();
305
+ options?.onClose?.();
306
+ break;
307
+ }
308
+ };
309
+ window.addEventListener("message", this.messageHandler);
310
+ this.closeMonitor = window.setInterval(() => {
311
+ if (!this.popup || this.popup.closed) {
312
+ const shouldTreatAsCancel = !this.completed;
313
+ logLoginInfo("Detected popup closed", {
314
+ shouldTreatAsCancel
315
+ });
316
+ this.cleanup();
317
+ if (shouldTreatAsCancel) {
318
+ options?.onCancel?.();
319
+ }
320
+ options?.onClose?.();
321
+ }
322
+ }, 500);
323
+ }
324
+ };
325
+ function createLoginUI() {
326
+ return new LoginUI();
327
+ }
328
+ export {
329
+ LoginUI,
330
+ createLoginUI
331
+ };
332
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hosted-modal.ts","../src/login.ts"],"sourcesContent":["export interface HostedFrameMessage {\n\ttype: string\n\theight?: number\n}\n\ntype HostedFrameOptions<TData extends HostedFrameMessage> = {\n\tallowedOrigin?: string\n\theight?: string\n\tonCloseButton?: () => void\n\tonMessage: (data: TData, container: HTMLDivElement) => void\n\twidth?: string\n}\n\nconst SDK_SUPPORTED_LOCALES = [\n\t\"en\",\n\t\"zh-CN\",\n\t\"zh-Hant\",\n\t\"fr\",\n\t\"de\",\n\t\"ja\",\n\t\"es\",\n\t\"ko\",\n\t\"nl\",\n\t\"it\",\n\t\"pt\",\n] as const\n\nconst SDK_DEFAULT_LOCALE = \"zh-CN\"\n\nconst SDK_LOCALE_ALIASES: Record<string, string> = {\n\ten: \"en\",\n\t\"en-us\": \"en\",\n\t\"en-gb\": \"en\",\n\tzh: \"zh-CN\",\n\t\"zh-cn\": \"zh-CN\",\n\t\"zh-tw\": \"zh-Hant\",\n\t\"zh-hk\": \"zh-Hant\",\n\t\"zh-hant\": \"zh-Hant\",\n\t\"zh-hans\": \"zh-CN\",\n\tfr: \"fr\",\n\tde: \"de\",\n\tja: \"ja\",\n\tes: \"es\",\n\tko: \"ko\",\n\tnl: \"nl\",\n\tit: \"it\",\n\tpt: \"pt\",\n}\n\nfunction matchSupportedBaseLocale(locale: string): string | undefined {\n\tconst base = locale.toLowerCase().split(\"-\")[0]\n\treturn SDK_SUPPORTED_LOCALES.find((item) => item.toLowerCase() === base)\n}\n\nexport function normalizeSdkLocale(locale?: string): string | undefined {\n\tif (!locale) return\n\n\tconst sanitized = locale.trim().replace(/_/g, \"-\")\n\tif (!sanitized) return\n\n\tconst lower = sanitized.toLowerCase()\n\tif (SDK_LOCALE_ALIASES[lower]) {\n\t\treturn SDK_LOCALE_ALIASES[lower]\n\t}\n\n\tlet canonical: string | undefined\n\ttry {\n\t\tcanonical = Intl.getCanonicalLocales(sanitized)[0]\n\t} catch {\n\t\tcanonical = undefined\n\t}\n\n\tconst candidates = [canonical, sanitized].filter(Boolean) as string[]\n\n\tfor (const candidate of candidates) {\n\t\tconst candidateLower = candidate.toLowerCase()\n\n\t\tif (SDK_LOCALE_ALIASES[candidateLower]) {\n\t\t\treturn SDK_LOCALE_ALIASES[candidateLower]\n\t\t}\n\t\tif ((SDK_SUPPORTED_LOCALES as readonly string[]).includes(candidate)) {\n\t\t\treturn candidate\n\t\t}\n\n\t\tconst baseMatch = matchSupportedBaseLocale(candidate)\n\t\tif (baseMatch) {\n\t\t\treturn baseMatch\n\t\t}\n\t}\n}\n\nexport function getBrowserLocale(): string | undefined {\n\tif (typeof navigator === \"undefined\") return\n\n\tfor (const candidate of navigator.languages || []) {\n\t\tconst normalized = normalizeSdkLocale(candidate)\n\t\tif (normalized) return normalized\n\t}\n\n\treturn normalizeSdkLocale(navigator.language)\n}\n\nexport function getAutoResolvedLocale(locale?: string): string {\n\treturn normalizeSdkLocale(locale) || getBrowserLocale() || SDK_DEFAULT_LOCALE\n}\n\nexport function applyLocaleToUrl(urlValue: string, locale?: string): string {\n\tif (!locale) return urlValue\n\n\ttry {\n\t\tconst url = new URL(urlValue)\n\t\tconst localePrefix = `/${locale}`\n\t\tif (\n\t\t\t!url.pathname.startsWith(`${localePrefix}/`) &&\n\t\t\turl.pathname !== localePrefix\n\t\t) {\n\t\t\turl.pathname = `${localePrefix}${url.pathname}`\n\t\t}\n\t\treturn url.toString()\n\t} catch (_error) {\n\t\tconst localePrefix = `/${locale}`\n\t\tif (!urlValue.startsWith(`${localePrefix}/`) && urlValue !== localePrefix) {\n\t\t\treturn `${localePrefix}${urlValue.startsWith(\"/\") ? \"\" : \"/\"}${urlValue}`\n\t\t}\n\t\treturn urlValue\n\t}\n}\n\nexport class HostedFrameModal<TData extends HostedFrameMessage> {\n\tprotected iframe: HTMLIFrameElement | null = null\n\tprotected modal: HTMLDivElement | null = null\n\tprotected messageHandler: ((event: MessageEvent) => void) | null = null\n\n\tprotected openHostedFrame(\n\t\turl: string,\n\t\toptions: HostedFrameOptions<TData>,\n\t): void {\n\t\tif (typeof document === \"undefined\") return\n\t\tif (this.modal) return\n\n\t\tthis.modal = document.createElement(\"div\")\n\t\tObject.assign(this.modal.style, {\n\t\t\tposition: \"fixed\",\n\t\t\ttop: \"0\",\n\t\t\tleft: \"0\",\n\t\t\twidth: \"100%\",\n\t\t\theight: \"100%\",\n\t\t\tbackgroundColor: \"rgba(15,23,42,0.52)\",\n\t\t\tdisplay: \"flex\",\n\t\t\talignItems: \"center\",\n\t\t\tjustifyContent: \"center\",\n\t\t\tzIndex: \"9999\",\n\t\t\ttransition: \"opacity 0.3s ease\",\n\t\t\tbackdropFilter: \"blur(14px)\",\n\t\t\tpadding: \"16px\",\n\t\t})\n\n\t\tconst container = document.createElement(\"div\")\n\t\tObject.assign(container.style, {\n\t\t\twidth: options.width || \"450px\",\n\t\t\theight: options.height || \"min(600px, 90vh)\",\n\t\t\tbackgroundColor: \"transparent\",\n\t\t\tborderRadius: \"28px\",\n\t\t\toverflow: \"visible\",\n\t\t\tposition: \"relative\",\n\t\t\tboxShadow: \"none\",\n\t\t\tmaxWidth: \"calc(100vw - 32px)\",\n\t\t\tmaxHeight: \"calc(100vh - 32px)\",\n\t\t\ttransition: \"height 180ms ease\",\n\t\t\twillChange: \"height\",\n\t\t})\n\n\t\tconst closeBtn = document.createElement(\"button\")\n\t\tcloseBtn.innerHTML = \"×\"\n\t\tObject.assign(closeBtn.style, {\n\t\t\tposition: \"absolute\",\n\t\t\tright: \"-14px\",\n\t\t\ttop: \"-14px\",\n\t\t\tfontSize: \"20px\",\n\t\t\twidth: \"36px\",\n\t\t\theight: \"36px\",\n\t\t\tborderRadius: \"9999px\",\n\t\t\tborder: \"1px solid rgba(255,255,255,0.5)\",\n\t\t\tbackground: \"rgba(255,255,255,0.9)\",\n\t\t\tcursor: \"pointer\",\n\t\t\tcolor: \"#475569\",\n\t\t\tzIndex: \"2\",\n\t\t\tboxShadow: \"0 10px 30px rgba(15,23,42,0.16)\",\n\t\t})\n\t\tcloseBtn.onclick = () => {\n\t\t\tthis.close()\n\t\t\toptions.onCloseButton?.()\n\t\t}\n\n\t\tthis.iframe = document.createElement(\"iframe\")\n\t\tthis.iframe.src = url\n\t\tObject.assign(this.iframe.style, {\n\t\t\twidth: \"100%\",\n\t\t\theight: \"100%\",\n\t\t\tborder: \"none\",\n\t\t\tborderRadius: \"28px\",\n\t\t\tbackground: \"transparent\",\n\t\t\tdisplay: \"block\",\n\t\t})\n\n\t\tcontainer.appendChild(closeBtn)\n\t\tcontainer.appendChild(this.iframe)\n\t\tthis.modal.appendChild(container)\n\t\tdocument.body.appendChild(this.modal)\n\n\t\tthis.messageHandler = (event: MessageEvent) => {\n\t\t\tif (options.allowedOrigin && options.allowedOrigin !== \"*\") {\n\t\t\t\tif (event.origin !== options.allowedOrigin) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst data = event.data as TData\n\t\t\tif (!data || typeof data !== \"object\" || !data.type) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\toptions.onMessage(data, container)\n\t\t}\n\n\t\twindow.addEventListener(\"message\", this.messageHandler)\n\t}\n\n\tclose() {\n\t\tif (typeof window === \"undefined\") return\n\n\t\tif (this.messageHandler) {\n\t\t\twindow.removeEventListener(\"message\", this.messageHandler)\n\t\t\tthis.messageHandler = null\n\t\t}\n\n\t\tif (this.modal?.parentNode) {\n\t\t\tthis.modal.parentNode.removeChild(this.modal)\n\t\t}\n\n\t\tthis.modal = null\n\t\tthis.iframe = null\n\t}\n}\n","import {\n\tapplyLocaleToUrl,\n\tgetAutoResolvedLocale,\n\ttype HostedFrameMessage,\n} from \"./hosted-modal\"\n\nexport type LoginEventType =\n\t| \"LOGIN_SUCCESS\"\n\t| \"LOGIN_CANCELLED\"\n\t| \"LOGIN_CLOSE\"\n\t| \"LOGIN_RESIZE\"\n\t| \"LOGIN_ERROR\"\n\nexport interface LoginResult {\n\tavatar?: string | null\n\tchannel?: string\n\temail?: string | null\n\texpiresAt?: string\n\tlegacyCasdoorId?: string\n\tloginToken?: string\n\tname?: string | null\n\tuserId?: string\n\twechatOpenId?: string | null\n\twechatUnionId?: string | null\n}\n\nexport interface LoginEventData extends HostedFrameMessage, LoginResult {\n\ttype: LoginEventType\n\terror?: string\n\tmessage?: string\n}\n\nexport interface LoginUIOptions {\n\t/** Origin to validate postMessage (defaults to '*', set for security) */\n\tallowedOrigin?: string\n\t/** Whether the SDK should close the popup after receiving LOGIN_CLOSE. Defaults to true. */\n\tautoClose?: boolean\n\tonCancel?: () => void\n\tonClose?: () => void\n\tonError?: (message?: string, data?: LoginEventData) => void\n\tonSuccess?: (result: LoginResult) => void\n}\n\nexport interface LoginParams {\n\tappId: string\n\n\t/**\n\t * @deprecated Use loginUrl instead\n\t * Defaults to https://pay.imgto.link\n\t */\n\tbaseUrl?: string\n\n\t/**\n\t * Hosted login page base URL (e.g. https://pay.youidian.com)\n\t * Defaults to https://pay.imgto.link\n\t */\n\tloginUrl?: string\n\n\t/**\n\t * Optional locale prefix to prepend to the hosted login path.\n\t * If omitted, the SDK automatically resolves the locale from the browser language.\n\t */\n\tlocale?: string\n\n\t/** Preferred provider/channel code */\n\tpreferredChannel?: string\n}\n\nfunction getOrigin(value?: string): string | null {\n\tif (!value) return null\n\ttry {\n\t\treturn new URL(value).origin\n\t} catch {\n\t\treturn null\n\t}\n}\n\nfunction buildLoginUrl(params: LoginParams): string {\n\tconst { appId, baseUrl = \"https://pay.imgto.link\", loginUrl } = params\n\tconst rawBase = (loginUrl || baseUrl).replace(/\\/$/, \"\")\n\tconst parentOrigin =\n\t\ttypeof window !== \"undefined\" ? window.location.origin : undefined\n\n\tlet finalUrl: string\n\ttry {\n\t\tconst url = new URL(rawBase)\n\t\tif (!/\\/auth\\/connect\\/[^/]+$/.test(url.pathname)) {\n\t\t\turl.pathname =\n\t\t\t\t`${url.pathname.replace(/\\/$/, \"\")}/auth/connect/${appId}`.replace(\n\t\t\t\t\t/\\/{2,}/g,\n\t\t\t\t\t\"/\",\n\t\t\t\t)\n\t\t}\n\t\tfinalUrl = url.toString()\n\t} catch (_error) {\n\t\tif (/\\/auth\\/connect\\/[^/]+$/.test(rawBase)) {\n\t\t\tfinalUrl = rawBase\n\t\t} else {\n\t\t\tfinalUrl = `${rawBase}/auth/connect/${appId}`.replace(/\\/{2,}/g, \"/\")\n\t\t}\n\t}\n\n\tfinalUrl = applyLocaleToUrl(finalUrl, getAutoResolvedLocale(params.locale))\n\n\ttry {\n\t\tconst url = new URL(finalUrl)\n\t\tif (params.preferredChannel) {\n\t\t\turl.searchParams.set(\"preferredChannel\", params.preferredChannel)\n\t\t}\n\t\tif (parentOrigin) {\n\t\t\turl.searchParams.set(\"origin\", parentOrigin)\n\t\t}\n\t\treturn url.toString()\n\t} catch (_error) {\n\t\tconst searchParams = new URLSearchParams()\n\t\tif (params.preferredChannel) {\n\t\t\tsearchParams.set(\"preferredChannel\", params.preferredChannel)\n\t\t}\n\t\tif (parentOrigin) {\n\t\t\tsearchParams.set(\"origin\", parentOrigin)\n\t\t}\n\t\tconst query = searchParams.toString()\n\t\tif (!query) {\n\t\t\treturn finalUrl\n\t\t}\n\t\tconst separator = finalUrl.includes(\"?\") ? \"&\" : \"?\"\n\t\treturn `${finalUrl}${separator}${query}`\n\t}\n}\n\nfunction extractLoginResult(data: LoginEventData): LoginResult {\n\treturn {\n\t\tavatar: data.avatar,\n\t\tchannel: data.channel,\n\t\temail: data.email,\n\t\texpiresAt: data.expiresAt,\n\t\tlegacyCasdoorId: data.legacyCasdoorId,\n\t\tloginToken: data.loginToken,\n\t\tname: data.name,\n\t\tuserId: data.userId,\n\t\twechatOpenId: data.wechatOpenId,\n\t\twechatUnionId: data.wechatUnionId,\n\t}\n}\n\nconst LOGIN_UI_LOG_PREFIX = \"[Youidian LoginUI]\"\n\nfunction logLoginDebug(message: string, details?: Record<string, unknown>) {\n\tif (typeof console === \"undefined\") return\n\tconsole.debug(LOGIN_UI_LOG_PREFIX, message, details || {})\n}\n\nfunction logLoginInfo(message: string, details?: Record<string, unknown>) {\n\tif (typeof console === \"undefined\") return\n\tconsole.info(LOGIN_UI_LOG_PREFIX, message, details || {})\n}\n\nfunction logLoginWarn(message: string, details?: Record<string, unknown>) {\n\tif (typeof console === \"undefined\") return\n\tconsole.warn(LOGIN_UI_LOG_PREFIX, message, details || {})\n}\n\nexport class LoginUI {\n\tprivate popup: Window | null = null\n\tprivate messageHandler: ((event: MessageEvent) => void) | null = null\n\tprivate closeMonitor: number | null = null\n\tprivate completed = false\n\n\tprivate cleanup() {\n\t\tif (typeof window !== \"undefined\" && this.messageHandler) {\n\t\t\twindow.removeEventListener(\"message\", this.messageHandler)\n\t\t}\n\t\tif (typeof window !== \"undefined\" && this.closeMonitor) {\n\t\t\twindow.clearInterval(this.closeMonitor)\n\t\t}\n\t\tthis.messageHandler = null\n\t\tthis.closeMonitor = null\n\t\tthis.popup = null\n\t\tthis.completed = false\n\t}\n\n\tclose() {\n\t\tlogLoginInfo(\"close() called\", {\n\t\t\thasPopup: Boolean(this.popup),\n\t\t\tpopupClosed: this.popup?.closed ?? true,\n\t\t})\n\t\tif (this.popup && !this.popup.closed) {\n\t\t\tthis.popup.close()\n\t\t}\n\t\tthis.cleanup()\n\t}\n\n\topenLogin(params: LoginParams, options?: LoginUIOptions) {\n\t\tif (typeof window === \"undefined\") return\n\t\tif (this.popup && !this.popup.closed) return\n\n\t\tconst finalUrl = buildLoginUrl(params)\n\t\tlogLoginInfo(\"Opening hosted login popup\", {\n\t\t\tappId: params.appId,\n\t\t\tloginUrl: finalUrl,\n\t\t\tallowedOrigin: options?.allowedOrigin || null,\n\t\t\tautoClose: options?.autoClose ?? true,\n\t\t})\n\t\tconst popupWidth = 520\n\t\tconst popupHeight = 720\n\t\tconst left = Math.max(\n\t\t\t0,\n\t\t\tMath.round(window.screenX + (window.outerWidth - popupWidth) / 2),\n\t\t)\n\t\tconst top = Math.max(\n\t\t\t0,\n\t\t\tMath.round(window.screenY + (window.outerHeight - popupHeight) / 2),\n\t\t)\n\t\tconst features = [\n\t\t\t\"popup=yes\",\n\t\t\t`width=${popupWidth}`,\n\t\t\t`height=${popupHeight}`,\n\t\t\t`left=${left}`,\n\t\t\t`top=${top}`,\n\t\t\t\"resizable=yes\",\n\t\t\t\"scrollbars=yes\",\n\t\t].join(\",\")\n\n\t\tconst popup = window.open(finalUrl, \"youidian-login\", features)\n\t\tif (!popup) {\n\t\t\tlogLoginWarn(\"Popup blocked by the browser\")\n\t\t\toptions?.onError?.(\"Login popup was blocked\")\n\t\t\treturn\n\t\t}\n\n\t\tthis.popup = popup\n\t\tthis.completed = false\n\n\t\tconst allowedOrigin = options?.allowedOrigin\n\t\tconst popupOrigin = getOrigin(finalUrl)\n\n\t\tthis.messageHandler = (event: MessageEvent) => {\n\t\t\tif (\n\t\t\t\tallowedOrigin &&\n\t\t\t\tallowedOrigin !== \"*\" &&\n\t\t\t\tevent.origin !== allowedOrigin\n\t\t\t) {\n\t\t\t\tlogLoginWarn(\"Ignored message due to allowedOrigin mismatch\", {\n\t\t\t\t\tallowedOrigin,\n\t\t\t\t\teventOrigin: event.origin,\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (!allowedOrigin && popupOrigin && event.origin !== popupOrigin) {\n\t\t\t\tlogLoginWarn(\"Ignored message due to popup origin mismatch\", {\n\t\t\t\t\texpectedOrigin: popupOrigin,\n\t\t\t\t\teventOrigin: event.origin,\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst data = event.data as LoginEventData\n\t\t\tif (!data || typeof data !== \"object\" || !data.type) {\n\t\t\t\tlogLoginDebug(\"Ignored non-login postMessage payload\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tlogLoginInfo(\"Received login event\", {\n\t\t\t\ttype: data.type,\n\t\t\t\teventOrigin: event.origin,\n\t\t\t})\n\n\t\t\tswitch (data.type) {\n\t\t\t\tcase \"LOGIN_SUCCESS\":\n\t\t\t\t\tthis.completed = true\n\t\t\t\t\tlogLoginInfo(\"Login succeeded\", {\n\t\t\t\t\t\tchannel: data.channel || null,\n\t\t\t\t\t\tuserId: data.userId || null,\n\t\t\t\t\t})\n\t\t\t\t\toptions?.onSuccess?.(extractLoginResult(data))\n\t\t\t\t\tbreak\n\t\t\t\tcase \"LOGIN_CANCELLED\":\n\t\t\t\t\tlogLoginInfo(\"Login cancelled\")\n\t\t\t\t\toptions?.onCancel?.()\n\t\t\t\t\tbreak\n\t\t\t\tcase \"LOGIN_RESIZE\":\n\t\t\t\t\tbreak\n\t\t\t\tcase \"LOGIN_ERROR\":\n\t\t\t\t\tlogLoginWarn(\"Login flow reported an error\", {\n\t\t\t\t\t\tmessage: data.message || data.error || null,\n\t\t\t\t\t})\n\t\t\t\t\toptions?.onError?.(data.message || data.error, data)\n\t\t\t\t\tbreak\n\t\t\t\tcase \"LOGIN_CLOSE\":\n\t\t\t\t\tif (options?.autoClose === false) {\n\t\t\t\t\t\tlogLoginInfo(\"Login popup requested close; autoClose disabled, keeping popup open\",)\n\t\t\t\t\t\toptions?.onClose?.()\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tlogLoginInfo(\"Login popup requested close; autoClose enabled\")\n\t\t\t\t\tthis.close()\n\t\t\t\t\toptions?.onClose?.()\n\t\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\twindow.addEventListener(\"message\", this.messageHandler)\n\n\t\tthis.closeMonitor = window.setInterval(() => {\n\t\t\tif (!this.popup || this.popup.closed) {\n\t\t\t\tconst shouldTreatAsCancel = !this.completed\n\t\t\t\tlogLoginInfo(\"Detected popup closed\", {\n\t\t\t\t\tshouldTreatAsCancel,\n\t\t\t\t})\n\t\t\t\tthis.cleanup()\n\t\t\t\tif (shouldTreatAsCancel) {\n\t\t\t\t\toptions?.onCancel?.()\n\t\t\t\t}\n\t\t\t\toptions?.onClose?.()\n\t\t\t}\n\t\t}, 500)\n\t}\n}\n\nexport function createLoginUI(): LoginUI {\n\treturn new LoginUI()\n}\n"],"mappings":";;;;;AAaA,IAAM,wBAAwB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,IAAM,qBAAqB;AAE3B,IAAM,qBAA6C;AAAA,EAClD,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,WAAW;AAAA,EACX,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACL;AAEA,SAAS,yBAAyB,QAAoC;AACrE,QAAM,OAAO,OAAO,YAAY,EAAE,MAAM,GAAG,EAAE,CAAC;AAC9C,SAAO,sBAAsB,KAAK,CAAC,SAAS,KAAK,YAAY,MAAM,IAAI;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