@youidian/pay-sdk 1.1.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.cjs +118 -89
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +4 -8
- package/dist/client.d.ts +4 -8
- package/dist/client.js +117 -90
- package/dist/client.js.map +1 -1
- package/dist/hosted-modal-BZmYmXTU.d.cts +20 -0
- package/dist/hosted-modal-BZmYmXTU.d.ts +20 -0
- package/dist/index.cjs +127 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +127 -90
- package/dist/index.js.map +1 -1
- package/dist/login.cjs +304 -0
- package/dist/login.cjs.map +1 -0
- package/dist/login.d.cts +60 -0
- package/dist/login.d.ts +60 -0
- package/dist/login.js +278 -0
- package/dist/login.js.map +1 -0
- package/dist/server.cjs +10 -0
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +21 -1
- package/dist/server.d.ts +21 -1
- package/dist/server.js +10 -0
- package/dist/server.js.map +1 -1
- package/package.json +7 -2
package/dist/login.cjs
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
|
|
22
|
+
// src/login.ts
|
|
23
|
+
var login_exports = {};
|
|
24
|
+
__export(login_exports, {
|
|
25
|
+
LoginUI: () => LoginUI,
|
|
26
|
+
createLoginUI: () => createLoginUI
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(login_exports);
|
|
29
|
+
|
|
30
|
+
// src/hosted-modal.ts
|
|
31
|
+
var SDK_SUPPORTED_LOCALES = [
|
|
32
|
+
"en",
|
|
33
|
+
"zh-CN",
|
|
34
|
+
"zh-Hant",
|
|
35
|
+
"fr",
|
|
36
|
+
"de",
|
|
37
|
+
"ja",
|
|
38
|
+
"es",
|
|
39
|
+
"ko",
|
|
40
|
+
"nl",
|
|
41
|
+
"it",
|
|
42
|
+
"pt"
|
|
43
|
+
];
|
|
44
|
+
var SDK_DEFAULT_LOCALE = "zh-CN";
|
|
45
|
+
var SDK_LOCALE_ALIASES = {
|
|
46
|
+
en: "en",
|
|
47
|
+
"en-us": "en",
|
|
48
|
+
"en-gb": "en",
|
|
49
|
+
zh: "zh-CN",
|
|
50
|
+
"zh-cn": "zh-CN",
|
|
51
|
+
"zh-tw": "zh-Hant",
|
|
52
|
+
"zh-hk": "zh-Hant",
|
|
53
|
+
"zh-hant": "zh-Hant",
|
|
54
|
+
"zh-hans": "zh-CN",
|
|
55
|
+
fr: "fr",
|
|
56
|
+
de: "de",
|
|
57
|
+
ja: "ja",
|
|
58
|
+
es: "es",
|
|
59
|
+
ko: "ko",
|
|
60
|
+
nl: "nl",
|
|
61
|
+
it: "it",
|
|
62
|
+
pt: "pt"
|
|
63
|
+
};
|
|
64
|
+
function matchSupportedBaseLocale(locale) {
|
|
65
|
+
const base = locale.toLowerCase().split("-")[0];
|
|
66
|
+
return SDK_SUPPORTED_LOCALES.find((item) => item.toLowerCase() === base);
|
|
67
|
+
}
|
|
68
|
+
function normalizeSdkLocale(locale) {
|
|
69
|
+
if (!locale) return;
|
|
70
|
+
const sanitized = locale.trim().replace(/_/g, "-");
|
|
71
|
+
if (!sanitized) return;
|
|
72
|
+
const lower = sanitized.toLowerCase();
|
|
73
|
+
if (SDK_LOCALE_ALIASES[lower]) {
|
|
74
|
+
return SDK_LOCALE_ALIASES[lower];
|
|
75
|
+
}
|
|
76
|
+
let canonical;
|
|
77
|
+
try {
|
|
78
|
+
canonical = Intl.getCanonicalLocales(sanitized)[0];
|
|
79
|
+
} catch {
|
|
80
|
+
canonical = void 0;
|
|
81
|
+
}
|
|
82
|
+
const candidates = [canonical, sanitized].filter(Boolean);
|
|
83
|
+
for (const candidate of candidates) {
|
|
84
|
+
const candidateLower = candidate.toLowerCase();
|
|
85
|
+
if (SDK_LOCALE_ALIASES[candidateLower]) {
|
|
86
|
+
return SDK_LOCALE_ALIASES[candidateLower];
|
|
87
|
+
}
|
|
88
|
+
if (SDK_SUPPORTED_LOCALES.includes(candidate)) {
|
|
89
|
+
return candidate;
|
|
90
|
+
}
|
|
91
|
+
const baseMatch = matchSupportedBaseLocale(candidate);
|
|
92
|
+
if (baseMatch) {
|
|
93
|
+
return baseMatch;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function getBrowserLocale() {
|
|
98
|
+
if (typeof navigator === "undefined") return;
|
|
99
|
+
for (const candidate of navigator.languages || []) {
|
|
100
|
+
const normalized = normalizeSdkLocale(candidate);
|
|
101
|
+
if (normalized) return normalized;
|
|
102
|
+
}
|
|
103
|
+
return normalizeSdkLocale(navigator.language);
|
|
104
|
+
}
|
|
105
|
+
function getAutoResolvedLocale(locale) {
|
|
106
|
+
return normalizeSdkLocale(locale) || getBrowserLocale() || SDK_DEFAULT_LOCALE;
|
|
107
|
+
}
|
|
108
|
+
function applyLocaleToUrl(urlValue, locale) {
|
|
109
|
+
if (!locale) return urlValue;
|
|
110
|
+
try {
|
|
111
|
+
const url = new URL(urlValue);
|
|
112
|
+
const localePrefix = `/${locale}`;
|
|
113
|
+
if (!url.pathname.startsWith(`${localePrefix}/`) && url.pathname !== localePrefix) {
|
|
114
|
+
url.pathname = `${localePrefix}${url.pathname}`;
|
|
115
|
+
}
|
|
116
|
+
return url.toString();
|
|
117
|
+
} catch (_error) {
|
|
118
|
+
const localePrefix = `/${locale}`;
|
|
119
|
+
if (!urlValue.startsWith(`${localePrefix}/`) && urlValue !== localePrefix) {
|
|
120
|
+
return `${localePrefix}${urlValue.startsWith("/") ? "" : "/"}${urlValue}`;
|
|
121
|
+
}
|
|
122
|
+
return urlValue;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/login.ts
|
|
127
|
+
function getOrigin(value) {
|
|
128
|
+
if (!value) return null;
|
|
129
|
+
try {
|
|
130
|
+
return new URL(value).origin;
|
|
131
|
+
} catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function buildLoginUrl(params) {
|
|
136
|
+
const { appId, baseUrl = "https://pay.imgto.link", loginUrl } = params;
|
|
137
|
+
const rawBase = (loginUrl || baseUrl).replace(/\/$/, "");
|
|
138
|
+
const parentOrigin = typeof window !== "undefined" ? window.location.origin : void 0;
|
|
139
|
+
let finalUrl;
|
|
140
|
+
try {
|
|
141
|
+
const url = new URL(rawBase);
|
|
142
|
+
if (!/\/auth\/connect\/[^/]+$/.test(url.pathname)) {
|
|
143
|
+
url.pathname = `${url.pathname.replace(/\/$/, "")}/auth/connect/${appId}`.replace(
|
|
144
|
+
/\/{2,}/g,
|
|
145
|
+
"/"
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
finalUrl = url.toString();
|
|
149
|
+
} catch (_error) {
|
|
150
|
+
if (/\/auth\/connect\/[^/]+$/.test(rawBase)) {
|
|
151
|
+
finalUrl = rawBase;
|
|
152
|
+
} else {
|
|
153
|
+
finalUrl = `${rawBase}/auth/connect/${appId}`.replace(/\/{2,}/g, "/");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
finalUrl = applyLocaleToUrl(finalUrl, getAutoResolvedLocale(params.locale));
|
|
157
|
+
try {
|
|
158
|
+
const url = new URL(finalUrl);
|
|
159
|
+
if (params.preferredChannel) {
|
|
160
|
+
url.searchParams.set("preferredChannel", params.preferredChannel);
|
|
161
|
+
}
|
|
162
|
+
if (parentOrigin) {
|
|
163
|
+
url.searchParams.set("origin", parentOrigin);
|
|
164
|
+
}
|
|
165
|
+
return url.toString();
|
|
166
|
+
} catch (_error) {
|
|
167
|
+
const searchParams = new URLSearchParams();
|
|
168
|
+
if (params.preferredChannel) {
|
|
169
|
+
searchParams.set("preferredChannel", params.preferredChannel);
|
|
170
|
+
}
|
|
171
|
+
if (parentOrigin) {
|
|
172
|
+
searchParams.set("origin", parentOrigin);
|
|
173
|
+
}
|
|
174
|
+
const query = searchParams.toString();
|
|
175
|
+
if (!query) {
|
|
176
|
+
return finalUrl;
|
|
177
|
+
}
|
|
178
|
+
const separator = finalUrl.includes("?") ? "&" : "?";
|
|
179
|
+
return `${finalUrl}${separator}${query}`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function extractLoginResult(data) {
|
|
183
|
+
return {
|
|
184
|
+
avatar: data.avatar,
|
|
185
|
+
channel: data.channel,
|
|
186
|
+
email: data.email,
|
|
187
|
+
expiresAt: data.expiresAt,
|
|
188
|
+
legacyCasdoorId: data.legacyCasdoorId,
|
|
189
|
+
loginToken: data.loginToken,
|
|
190
|
+
name: data.name,
|
|
191
|
+
userId: data.userId,
|
|
192
|
+
wechatOpenId: data.wechatOpenId,
|
|
193
|
+
wechatUnionId: data.wechatUnionId
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
var LoginUI = class {
|
|
197
|
+
constructor() {
|
|
198
|
+
__publicField(this, "popup", null);
|
|
199
|
+
__publicField(this, "messageHandler", null);
|
|
200
|
+
__publicField(this, "closeMonitor", null);
|
|
201
|
+
__publicField(this, "completed", false);
|
|
202
|
+
}
|
|
203
|
+
cleanup() {
|
|
204
|
+
if (typeof window !== "undefined" && this.messageHandler) {
|
|
205
|
+
window.removeEventListener("message", this.messageHandler);
|
|
206
|
+
}
|
|
207
|
+
if (typeof window !== "undefined" && this.closeMonitor) {
|
|
208
|
+
window.clearInterval(this.closeMonitor);
|
|
209
|
+
}
|
|
210
|
+
this.messageHandler = null;
|
|
211
|
+
this.closeMonitor = null;
|
|
212
|
+
this.popup = null;
|
|
213
|
+
this.completed = false;
|
|
214
|
+
}
|
|
215
|
+
close() {
|
|
216
|
+
if (this.popup && !this.popup.closed) {
|
|
217
|
+
this.popup.close();
|
|
218
|
+
}
|
|
219
|
+
this.cleanup();
|
|
220
|
+
}
|
|
221
|
+
openLogin(params, options) {
|
|
222
|
+
if (typeof window === "undefined") return;
|
|
223
|
+
if (this.popup && !this.popup.closed) return;
|
|
224
|
+
const finalUrl = buildLoginUrl(params);
|
|
225
|
+
const popupWidth = 520;
|
|
226
|
+
const popupHeight = 720;
|
|
227
|
+
const left = Math.max(
|
|
228
|
+
0,
|
|
229
|
+
Math.round(window.screenX + (window.outerWidth - popupWidth) / 2)
|
|
230
|
+
);
|
|
231
|
+
const top = Math.max(
|
|
232
|
+
0,
|
|
233
|
+
Math.round(window.screenY + (window.outerHeight - popupHeight) / 2)
|
|
234
|
+
);
|
|
235
|
+
const features = [
|
|
236
|
+
"popup=yes",
|
|
237
|
+
`width=${popupWidth}`,
|
|
238
|
+
`height=${popupHeight}`,
|
|
239
|
+
`left=${left}`,
|
|
240
|
+
`top=${top}`,
|
|
241
|
+
"resizable=yes",
|
|
242
|
+
"scrollbars=yes"
|
|
243
|
+
].join(",");
|
|
244
|
+
const popup = window.open(finalUrl, "youidian-login", features);
|
|
245
|
+
if (!popup) {
|
|
246
|
+
options?.onError?.("Login popup was blocked");
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
this.popup = popup;
|
|
250
|
+
this.completed = false;
|
|
251
|
+
const allowedOrigin = options?.allowedOrigin;
|
|
252
|
+
const popupOrigin = getOrigin(finalUrl);
|
|
253
|
+
this.messageHandler = (event) => {
|
|
254
|
+
if (allowedOrigin && allowedOrigin !== "*" && event.origin !== allowedOrigin) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (!allowedOrigin && popupOrigin && event.origin !== popupOrigin) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const data = event.data;
|
|
261
|
+
if (!data || typeof data !== "object" || !data.type) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
switch (data.type) {
|
|
265
|
+
case "LOGIN_SUCCESS":
|
|
266
|
+
this.completed = true;
|
|
267
|
+
options?.onSuccess?.(extractLoginResult(data));
|
|
268
|
+
break;
|
|
269
|
+
case "LOGIN_CANCELLED":
|
|
270
|
+
options?.onCancel?.(extractLoginResult(data));
|
|
271
|
+
break;
|
|
272
|
+
case "LOGIN_RESIZE":
|
|
273
|
+
break;
|
|
274
|
+
case "LOGIN_ERROR":
|
|
275
|
+
options?.onError?.(data.message || data.error, data);
|
|
276
|
+
break;
|
|
277
|
+
case "LOGIN_CLOSE":
|
|
278
|
+
this.close();
|
|
279
|
+
options?.onClose?.();
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
window.addEventListener("message", this.messageHandler);
|
|
284
|
+
this.closeMonitor = window.setInterval(() => {
|
|
285
|
+
if (!this.popup || this.popup.closed) {
|
|
286
|
+
const shouldTreatAsCancel = !this.completed;
|
|
287
|
+
this.cleanup();
|
|
288
|
+
if (shouldTreatAsCancel) {
|
|
289
|
+
options?.onCancel?.();
|
|
290
|
+
}
|
|
291
|
+
options?.onClose?.();
|
|
292
|
+
}
|
|
293
|
+
}, 500);
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
function createLoginUI() {
|
|
297
|
+
return new LoginUI();
|
|
298
|
+
}
|
|
299
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
300
|
+
0 && (module.exports = {
|
|
301
|
+
LoginUI,
|
|
302
|
+
createLoginUI
|
|
303
|
+
});
|
|
304
|
+
//# sourceMappingURL=login.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/login.ts","../src/hosted-modal.ts"],"sourcesContent":["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\tonCancel?: (result?: LoginResult) => 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\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\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\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\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\treturn\n\t\t\t}\n\t\t\tif (!allowedOrigin && popupOrigin && event.origin !== popupOrigin) {\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\treturn\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\toptions?.onSuccess?.(extractLoginResult(data))\n\t\t\t\t\tbreak\n\t\t\t\tcase \"LOGIN_CANCELLED\":\n\t\t\t\t\toptions?.onCancel?.(extractLoginResult(data))\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\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\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\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","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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ACrB;AACA,iBAAS,UAAU;AAAA,MACpB;AAAA,IACD,GAAG,GAAG;AAAA,EACP;AACD;AAEO,SAAS,gBAAyB;AACxC,SAAO,IAAI,QAAQ;AACpB;","names":[]}
|
package/dist/login.d.cts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { a as HostedFrameMessage } from './hosted-modal-BZmYmXTU.cjs';
|
|
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
|
+
onCancel?: (result?: LoginResult) => void;
|
|
25
|
+
onClose?: () => void;
|
|
26
|
+
onError?: (message?: string, data?: LoginEventData) => void;
|
|
27
|
+
onSuccess?: (result: LoginResult) => void;
|
|
28
|
+
}
|
|
29
|
+
interface LoginParams {
|
|
30
|
+
appId: string;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Use loginUrl instead
|
|
33
|
+
* Defaults to https://pay.imgto.link
|
|
34
|
+
*/
|
|
35
|
+
baseUrl?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Hosted login page base URL (e.g. https://pay.youidian.com)
|
|
38
|
+
* Defaults to https://pay.imgto.link
|
|
39
|
+
*/
|
|
40
|
+
loginUrl?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Optional locale prefix to prepend to the hosted login path.
|
|
43
|
+
* If omitted, the SDK automatically resolves the locale from the browser language.
|
|
44
|
+
*/
|
|
45
|
+
locale?: string;
|
|
46
|
+
/** Preferred provider/channel code */
|
|
47
|
+
preferredChannel?: string;
|
|
48
|
+
}
|
|
49
|
+
declare class LoginUI {
|
|
50
|
+
private popup;
|
|
51
|
+
private messageHandler;
|
|
52
|
+
private closeMonitor;
|
|
53
|
+
private completed;
|
|
54
|
+
private cleanup;
|
|
55
|
+
close(): void;
|
|
56
|
+
openLogin(params: LoginParams, options?: LoginUIOptions): void;
|
|
57
|
+
}
|
|
58
|
+
declare function createLoginUI(): LoginUI;
|
|
59
|
+
|
|
60
|
+
export { type LoginEventData, type LoginEventType, type LoginParams, type LoginResult, LoginUI, type LoginUIOptions, createLoginUI };
|
package/dist/login.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
onCancel?: (result?: LoginResult) => void;
|
|
25
|
+
onClose?: () => void;
|
|
26
|
+
onError?: (message?: string, data?: LoginEventData) => void;
|
|
27
|
+
onSuccess?: (result: LoginResult) => void;
|
|
28
|
+
}
|
|
29
|
+
interface LoginParams {
|
|
30
|
+
appId: string;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Use loginUrl instead
|
|
33
|
+
* Defaults to https://pay.imgto.link
|
|
34
|
+
*/
|
|
35
|
+
baseUrl?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Hosted login page base URL (e.g. https://pay.youidian.com)
|
|
38
|
+
* Defaults to https://pay.imgto.link
|
|
39
|
+
*/
|
|
40
|
+
loginUrl?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Optional locale prefix to prepend to the hosted login path.
|
|
43
|
+
* If omitted, the SDK automatically resolves the locale from the browser language.
|
|
44
|
+
*/
|
|
45
|
+
locale?: string;
|
|
46
|
+
/** Preferred provider/channel code */
|
|
47
|
+
preferredChannel?: string;
|
|
48
|
+
}
|
|
49
|
+
declare class LoginUI {
|
|
50
|
+
private popup;
|
|
51
|
+
private messageHandler;
|
|
52
|
+
private closeMonitor;
|
|
53
|
+
private completed;
|
|
54
|
+
private cleanup;
|
|
55
|
+
close(): void;
|
|
56
|
+
openLogin(params: LoginParams, options?: LoginUIOptions): void;
|
|
57
|
+
}
|
|
58
|
+
declare function createLoginUI(): LoginUI;
|
|
59
|
+
|
|
60
|
+
export { type LoginEventData, type LoginEventType, type LoginParams, type LoginResult, LoginUI, type LoginUIOptions, createLoginUI };
|