@pisell/pisellos 3.0.68 → 3.0.70
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/modules/Order/index.js +4 -2
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/plugins/request.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +5 -1
- package/dist/solution/BookingByStep/index.js +31 -7
- package/dist/solution/RegisterAndLogin/config.d.ts +87 -0
- package/dist/solution/RegisterAndLogin/config.js +792 -0
- package/dist/solution/RegisterAndLogin/index.d.ts +189 -0
- package/dist/solution/RegisterAndLogin/index.js +2667 -0
- package/dist/solution/RegisterAndLogin/types.d.ts +444 -0
- package/dist/solution/RegisterAndLogin/types.js +231 -0
- package/dist/solution/RegisterAndLogin/utils.d.ts +95 -0
- package/dist/solution/RegisterAndLogin/utils.js +322 -0
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/lib/modules/Order/index.js +5 -2
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/plugins/request.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +5 -1
- package/lib/solution/BookingByStep/index.js +9 -2
- package/lib/solution/RegisterAndLogin/config.d.ts +87 -0
- package/lib/solution/RegisterAndLogin/config.js +594 -0
- package/lib/solution/RegisterAndLogin/index.d.ts +189 -0
- package/lib/solution/RegisterAndLogin/index.js +1593 -0
- package/lib/solution/RegisterAndLogin/types.d.ts +444 -0
- package/lib/solution/RegisterAndLogin/types.js +78 -0
- package/lib/solution/RegisterAndLogin/utils.d.ts +95 -0
- package/lib/solution/RegisterAndLogin/utils.js +279 -0
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/solution/RegisterAndLogin/utils.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
debounce: () => debounce,
|
|
23
|
+
deepClone: () => deepClone,
|
|
24
|
+
formatEmailDisplay: () => formatEmailDisplay,
|
|
25
|
+
formatPhoneDisplay: () => formatPhoneDisplay,
|
|
26
|
+
formatTimestamp: () => formatTimestamp,
|
|
27
|
+
generateRandomString: () => generateRandomString,
|
|
28
|
+
getDeviceType: () => getDeviceType,
|
|
29
|
+
getOAuthProviderDisplayName: () => getOAuthProviderDisplayName,
|
|
30
|
+
getOAuthProviderIconUrl: () => getOAuthProviderIconUrl,
|
|
31
|
+
getTimeDifference: () => getTimeDifference,
|
|
32
|
+
isAndroidDevice: () => isAndroidDevice,
|
|
33
|
+
isIOSDevice: () => isIOSDevice,
|
|
34
|
+
isMobileDevice: () => isMobileDevice,
|
|
35
|
+
isTimestampExpired: () => isTimestampExpired,
|
|
36
|
+
isWebAuthnSupported: () => isWebAuthnSupported,
|
|
37
|
+
safeJsonParse: () => safeJsonParse,
|
|
38
|
+
safeJsonStringify: () => safeJsonStringify,
|
|
39
|
+
throttle: () => throttle,
|
|
40
|
+
validateEmail: () => validateEmail,
|
|
41
|
+
validatePassword: () => validatePassword,
|
|
42
|
+
validatePhone: () => validatePhone,
|
|
43
|
+
validateVerificationCode: () => validateVerificationCode
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(utils_exports);
|
|
46
|
+
var import_types = require("./types");
|
|
47
|
+
function validateEmail(email) {
|
|
48
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
49
|
+
return emailRegex.test(email);
|
|
50
|
+
}
|
|
51
|
+
function validatePhone(phone) {
|
|
52
|
+
const cleanPhone = phone.replace(/[^\d+]/g, "");
|
|
53
|
+
const phoneRegex = /^(\+\d{1,3}[- ]?)?\d{10,14}$/;
|
|
54
|
+
return phoneRegex.test(cleanPhone);
|
|
55
|
+
}
|
|
56
|
+
function validatePassword(password) {
|
|
57
|
+
const errors = [];
|
|
58
|
+
if (password.length < 8) {
|
|
59
|
+
errors.push("密码长度至少为8位");
|
|
60
|
+
}
|
|
61
|
+
if (password.length > 128) {
|
|
62
|
+
errors.push("密码长度不能超过128位");
|
|
63
|
+
}
|
|
64
|
+
if (!/[a-z]/.test(password)) {
|
|
65
|
+
errors.push("密码必须包含至少一个小写字母");
|
|
66
|
+
}
|
|
67
|
+
if (!/[A-Z]/.test(password)) {
|
|
68
|
+
errors.push("密码必须包含至少一个大写字母");
|
|
69
|
+
}
|
|
70
|
+
if (!/\d/.test(password)) {
|
|
71
|
+
errors.push("密码必须包含至少一个数字");
|
|
72
|
+
}
|
|
73
|
+
if (!/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/.test(password)) {
|
|
74
|
+
errors.push("密码必须包含至少一个特殊字符");
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
isValid: errors.length === 0,
|
|
78
|
+
errors
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function validateVerificationCode(code, type) {
|
|
82
|
+
const cleanCode = code.replace(/\s/g, "");
|
|
83
|
+
switch (type) {
|
|
84
|
+
case import_types.VerificationCodeType.EMAIL:
|
|
85
|
+
case import_types.VerificationCodeType.SMS:
|
|
86
|
+
return /^\d{4,8}$/.test(cleanCode);
|
|
87
|
+
default:
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function formatPhoneDisplay(phone) {
|
|
92
|
+
const cleanPhone = phone.replace(/[^\d+]/g, "");
|
|
93
|
+
if (/^\d{11}$/.test(cleanPhone)) {
|
|
94
|
+
return cleanPhone.replace(/(\d{3})(\d{4})(\d{4})/, "$1 $2 $3");
|
|
95
|
+
}
|
|
96
|
+
if (cleanPhone.startsWith("+")) {
|
|
97
|
+
return cleanPhone;
|
|
98
|
+
}
|
|
99
|
+
return phone;
|
|
100
|
+
}
|
|
101
|
+
function formatEmailDisplay(email, maskLength = 3) {
|
|
102
|
+
const [localPart, domain] = email.split("@");
|
|
103
|
+
if (!localPart || !domain) {
|
|
104
|
+
return email;
|
|
105
|
+
}
|
|
106
|
+
if (localPart.length <= maskLength * 2) {
|
|
107
|
+
return email;
|
|
108
|
+
}
|
|
109
|
+
const visibleStart = localPart.substring(0, maskLength);
|
|
110
|
+
const visibleEnd = localPart.substring(localPart.length - maskLength);
|
|
111
|
+
const maskedPart = "*".repeat(localPart.length - maskLength * 2);
|
|
112
|
+
return `${visibleStart}${maskedPart}${visibleEnd}@${domain}`;
|
|
113
|
+
}
|
|
114
|
+
function generateRandomString(length = 32) {
|
|
115
|
+
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
116
|
+
let result = "";
|
|
117
|
+
for (let i = 0; i < length; i++) {
|
|
118
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
function getOAuthProviderDisplayName(provider) {
|
|
123
|
+
const displayNames = {
|
|
124
|
+
[import_types.OAuthProvider.FACEBOOK]: "Facebook",
|
|
125
|
+
[import_types.OAuthProvider.APPLE]: "Apple",
|
|
126
|
+
[import_types.OAuthProvider.GOOGLE]: "Google",
|
|
127
|
+
[import_types.OAuthProvider.WECHAT]: "微信",
|
|
128
|
+
[import_types.OAuthProvider.GITHUB]: "GitHub"
|
|
129
|
+
};
|
|
130
|
+
return displayNames[provider] || provider;
|
|
131
|
+
}
|
|
132
|
+
function getOAuthProviderIconUrl(provider) {
|
|
133
|
+
const iconUrls = {
|
|
134
|
+
[import_types.OAuthProvider.FACEBOOK]: "https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/facebook.svg",
|
|
135
|
+
[import_types.OAuthProvider.APPLE]: "https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/apple.svg",
|
|
136
|
+
[import_types.OAuthProvider.GOOGLE]: "https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/google.svg",
|
|
137
|
+
[import_types.OAuthProvider.WECHAT]: "https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/wechat.svg",
|
|
138
|
+
[import_types.OAuthProvider.GITHUB]: "https://cdn.jsdelivr.net/npm/simple-icons@v9/icons/github.svg"
|
|
139
|
+
};
|
|
140
|
+
return iconUrls[provider] || "";
|
|
141
|
+
}
|
|
142
|
+
function isMobileDevice() {
|
|
143
|
+
if (typeof window === "undefined") {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
147
|
+
navigator.userAgent
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
function isWebAuthnSupported() {
|
|
151
|
+
if (typeof window === "undefined") {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
return !!(navigator.credentials && navigator.credentials.create);
|
|
155
|
+
}
|
|
156
|
+
function isIOSDevice() {
|
|
157
|
+
if (typeof window === "undefined") {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
return /iPad|iPhone|iPod/.test(navigator.userAgent);
|
|
161
|
+
}
|
|
162
|
+
function isAndroidDevice() {
|
|
163
|
+
if (typeof window === "undefined") {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
return /Android/.test(navigator.userAgent);
|
|
167
|
+
}
|
|
168
|
+
function getDeviceType() {
|
|
169
|
+
if (typeof window === "undefined") {
|
|
170
|
+
return "desktop";
|
|
171
|
+
}
|
|
172
|
+
const userAgent = navigator.userAgent;
|
|
173
|
+
if (/iPad/.test(userAgent)) {
|
|
174
|
+
return "tablet";
|
|
175
|
+
}
|
|
176
|
+
if (/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent)) {
|
|
177
|
+
return "mobile";
|
|
178
|
+
}
|
|
179
|
+
return "desktop";
|
|
180
|
+
}
|
|
181
|
+
function debounce(func, wait) {
|
|
182
|
+
let timeout = null;
|
|
183
|
+
return (...args) => {
|
|
184
|
+
if (timeout) {
|
|
185
|
+
clearTimeout(timeout);
|
|
186
|
+
}
|
|
187
|
+
timeout = setTimeout(() => {
|
|
188
|
+
func(...args);
|
|
189
|
+
}, wait);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function throttle(func, wait) {
|
|
193
|
+
let lastTime = 0;
|
|
194
|
+
return (...args) => {
|
|
195
|
+
const now = Date.now();
|
|
196
|
+
if (now - lastTime >= wait) {
|
|
197
|
+
lastTime = now;
|
|
198
|
+
func(...args);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function deepClone(obj) {
|
|
203
|
+
if (obj === null || typeof obj !== "object") {
|
|
204
|
+
return obj;
|
|
205
|
+
}
|
|
206
|
+
if (obj instanceof Date) {
|
|
207
|
+
return new Date(obj.getTime());
|
|
208
|
+
}
|
|
209
|
+
if (obj instanceof Array) {
|
|
210
|
+
return obj.map((item) => deepClone(item));
|
|
211
|
+
}
|
|
212
|
+
if (typeof obj === "object") {
|
|
213
|
+
const cloned = {};
|
|
214
|
+
for (const key in obj) {
|
|
215
|
+
if (obj.hasOwnProperty(key)) {
|
|
216
|
+
cloned[key] = deepClone(obj[key]);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return cloned;
|
|
220
|
+
}
|
|
221
|
+
return obj;
|
|
222
|
+
}
|
|
223
|
+
function safeJsonParse(jsonString, defaultValue) {
|
|
224
|
+
try {
|
|
225
|
+
return JSON.parse(jsonString);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.warn("JSON 解析失败:", error);
|
|
228
|
+
return defaultValue;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function safeJsonStringify(obj, defaultValue = "{}") {
|
|
232
|
+
try {
|
|
233
|
+
return JSON.stringify(obj);
|
|
234
|
+
} catch (error) {
|
|
235
|
+
console.warn("JSON 字符串化失败:", error);
|
|
236
|
+
return defaultValue;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function formatTimestamp(timestamp, format = "YYYY-MM-DD HH:mm:ss") {
|
|
240
|
+
const date = new Date(timestamp);
|
|
241
|
+
const year = date.getFullYear();
|
|
242
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
243
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
244
|
+
const hours = String(date.getHours()).padStart(2, "0");
|
|
245
|
+
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
246
|
+
const seconds = String(date.getSeconds()).padStart(2, "0");
|
|
247
|
+
return format.replace("YYYY", year.toString()).replace("MM", month).replace("DD", day).replace("HH", hours).replace("mm", minutes).replace("ss", seconds);
|
|
248
|
+
}
|
|
249
|
+
function getTimeDifference(timestamp1, timestamp2) {
|
|
250
|
+
return Math.abs(timestamp1 - timestamp2) / 1e3;
|
|
251
|
+
}
|
|
252
|
+
function isTimestampExpired(timestamp, expirationTime = 5 * 60 * 1e3) {
|
|
253
|
+
return Date.now() - timestamp > expirationTime;
|
|
254
|
+
}
|
|
255
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
256
|
+
0 && (module.exports = {
|
|
257
|
+
debounce,
|
|
258
|
+
deepClone,
|
|
259
|
+
formatEmailDisplay,
|
|
260
|
+
formatPhoneDisplay,
|
|
261
|
+
formatTimestamp,
|
|
262
|
+
generateRandomString,
|
|
263
|
+
getDeviceType,
|
|
264
|
+
getOAuthProviderDisplayName,
|
|
265
|
+
getOAuthProviderIconUrl,
|
|
266
|
+
getTimeDifference,
|
|
267
|
+
isAndroidDevice,
|
|
268
|
+
isIOSDevice,
|
|
269
|
+
isMobileDevice,
|
|
270
|
+
isTimestampExpired,
|
|
271
|
+
isWebAuthnSupported,
|
|
272
|
+
safeJsonParse,
|
|
273
|
+
safeJsonStringify,
|
|
274
|
+
throttle,
|
|
275
|
+
validateEmail,
|
|
276
|
+
validatePassword,
|
|
277
|
+
validatePhone,
|
|
278
|
+
validateVerificationCode
|
|
279
|
+
});
|
package/lib/solution/index.d.ts
CHANGED
package/lib/solution/index.js
CHANGED
|
@@ -19,9 +19,11 @@ module.exports = __toCommonJS(solution_exports);
|
|
|
19
19
|
__reExport(solution_exports, require("./BuyTickets"), module.exports);
|
|
20
20
|
__reExport(solution_exports, require("./BookingByStep"), module.exports);
|
|
21
21
|
__reExport(solution_exports, require("./ShopDiscount"), module.exports);
|
|
22
|
+
__reExport(solution_exports, require("./RegisterAndLogin"), module.exports);
|
|
22
23
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23
24
|
0 && (module.exports = {
|
|
24
25
|
...require("./BuyTickets"),
|
|
25
26
|
...require("./BookingByStep"),
|
|
26
|
-
...require("./ShopDiscount")
|
|
27
|
+
...require("./ShopDiscount"),
|
|
28
|
+
...require("./RegisterAndLogin")
|
|
27
29
|
});
|