creditdaddy 1.7.2 → 1.8.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/LICENSE +701 -2
- package/README.md +454 -440
- package/bin/creditdaddy.js +6 -0
- package/build.json +3 -3
- package/package.json +34 -34
- package/src/accounts.js +15 -0
- package/src/assets/donate-alipay.svg +1 -1
- package/src/assets/donate-ifdian.svg +1 -1
- package/src/assets/donate-wechat.svg +1 -1
- package/src/assets/providers/catpaw.png +0 -0
- package/src/assets/providers/codebuddy-ide.png +0 -0
- package/src/assets/providers/dumate.png +0 -0
- package/src/assets/providers/loomy.png +0 -0
- package/src/assets/providers/meoo.png +0 -0
- package/src/assets/providers/mirasim.png +0 -0
- package/src/bgdaemon.js +341 -341
- package/src/buildInfo.js +65 -65
- package/src/catpawClient.js +103 -103
- package/src/catpawLocal.js +236 -236
- package/src/checkin.js +98 -5
- package/src/codebuddyIdeLocal.js +381 -381
- package/src/constants.js +121 -117
- package/src/cookieSites.js +340 -301
- package/src/daemon.js +2720 -2443
- package/src/doubaoClient.js +167 -167
- package/src/dumateClient.js +517 -0
- package/src/dumateLocal.js +298 -0
- package/src/dumateQr.js +337 -0
- package/src/externalQuota.js +577 -574
- package/src/formatDuration.js +17 -17
- package/src/i18n/en.json +257 -7
- package/src/i18n/ja.json +257 -7
- package/src/i18n/ko.json +257 -7
- package/src/i18n/zh-TW.json +257 -7
- package/src/i18n.js +47 -47
- package/src/lingxiClient.js +373 -373
- package/src/localDetect.js +147 -147
- package/src/longcatClient.js +260 -260
- package/src/loomyAuth.js +230 -230
- package/src/loomyClient.js +366 -366
- package/src/loomyLocal.js +206 -206
- package/src/meooAuth.js +246 -0
- package/src/meooClient.js +250 -0
- package/src/minimaxGateway.js +520 -520
- package/src/minimaxLocal.js +344 -344
- package/src/mirasimClient.js +211 -211
- package/src/mirasimLocal.js +392 -392
- package/src/modelscopeClient.js +275 -275
- package/src/panel.html +704 -85
- package/src/prodIcons.json +7 -5
- package/src/providers.js +34 -0
- package/src/qoderApp.js +578 -578
- package/src/qoderClient.js +266 -266
- package/src/qoderUmid.js +199 -199
- package/src/quotaRefresh.js +119 -119
- package/src/refreshGuard.js +75 -75
- package/src/riverClient.js +372 -372
- package/src/store.js +2 -1
- package/src/tenrouterAccounts.js +237 -232
- package/src/traeAuth.js +601 -599
- package/src/traeClient.js +356 -360
- package/src/traeGateway.js +875 -875
- package/src/traeLocal.js +463 -371
- package/src/transfer.js +4 -0
- package/src/usageSync.js +535 -523
- package/src/winProc.js +134 -134
- package/src/xiaomiMimoClient.js +206 -206
- package/src/zcodeAuth.js +131 -131
- package/src/zcodeAutoClaim.js +53 -6
- package/src/zcodeClient.js +55 -2
- package/src/zcodeGateway.js +850 -850
- package/src/zcodeLocal.js +340 -340
- package/src/zcrypto.js +160 -160
package/src/loomyAuth.js
CHANGED
|
@@ -1,230 +1,230 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 讯飞 Loomy 独立登录授权模拟器(无需安装客户端,支持纯手机号验证码两步直登)。
|
|
3
|
-
*
|
|
4
|
-
* 逆向自讯飞 Loomy 生产客户端(account.xfinfr.com HMAC-SHA1 签名体系):
|
|
5
|
-
* - AppId: GM3LOOMY
|
|
6
|
-
* - AccessKeyId: 2thryby66wxi53sk
|
|
7
|
-
* - AccessKeySecret: zsak6eadrbawz683wf5r3m2snrwj868r
|
|
8
|
-
* - BaseUrl: https://account.xfinfr.com
|
|
9
|
-
*
|
|
10
|
-
* 流程:
|
|
11
|
-
* 1. sendLoomySms(phone) -> POST /login/phone/sendMsgCode (获取 msgid)
|
|
12
|
-
* 2. loginLoomyBySms({ phone, code, msgid }) -> POST /login/phone/checkCode (换取 14 天 session token)
|
|
13
|
-
* 3. registerLoomyByPhone({ phone, code }) -> POST /register/phone/submit (新手机号注册;与登录共用同一条验证码)
|
|
14
|
-
* 4. fetchLoomyIdentity(session) -> POST /userinfo/query/baseInfo (会话校验 / 昵称)
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import crypto from 'node:crypto';
|
|
18
|
-
|
|
19
|
-
export const LOOMY_AUTH_CONFIG = {
|
|
20
|
-
baseUrl: 'https://account.xfinfr.com',
|
|
21
|
-
accessKeyId: '2thryby66wxi53sk',
|
|
22
|
-
accessKeySecret: 'zsak6eadrbawz683wf5r3m2snrwj868r',
|
|
23
|
-
appId: 'GM3LOOMY',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function contentMD5(body) {
|
|
27
|
-
if (!body) return '';
|
|
28
|
-
const bodyStr = typeof body === 'string' ? body : JSON.stringify(body);
|
|
29
|
-
const hash = crypto.createHash('md5').update(bodyStr, 'utf8').digest();
|
|
30
|
-
return hash.toString('base64');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function escapePathSegment(segment) {
|
|
34
|
-
return encodeURIComponent(segment)
|
|
35
|
-
.replace(/!/g, '%21')
|
|
36
|
-
.replace(/'/g, '%27')
|
|
37
|
-
.replace(/\(/g, '%28')
|
|
38
|
-
.replace(/\)/g, '%29')
|
|
39
|
-
.replace(/\*/g, '%2A');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function buildEscapedPath(path) {
|
|
43
|
-
let cleanPath = path.startsWith('/') ? path : '/' + path;
|
|
44
|
-
if (cleanPath.length > 1 && cleanPath.endsWith('/')) {
|
|
45
|
-
cleanPath = cleanPath.slice(0, -1);
|
|
46
|
-
}
|
|
47
|
-
return cleanPath.split('/').map((seg) => (seg ? escapePathSegment(seg) : '')).join('/');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function generateSignature({ method, path, queryParams = {}, body = '', contentType = 'application/json', date, nonce, accessKeySecret }) {
|
|
51
|
-
const escapedPath = buildEscapedPath(path);
|
|
52
|
-
const md5 = contentMD5(body);
|
|
53
|
-
const parts = [
|
|
54
|
-
method.toUpperCase(),
|
|
55
|
-
escapedPath,
|
|
56
|
-
'', // escapedQuery
|
|
57
|
-
md5,
|
|
58
|
-
contentType,
|
|
59
|
-
date,
|
|
60
|
-
nonce,
|
|
61
|
-
'', // signedHeaders
|
|
62
|
-
'' // canonicalizedHeaders
|
|
63
|
-
];
|
|
64
|
-
const stringToSign = parts.join('\n');
|
|
65
|
-
const hmac = crypto.createHmac('sha1', accessKeySecret);
|
|
66
|
-
hmac.update(stringToSign, 'utf8');
|
|
67
|
-
return hmac.digest('base64');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function generateRequestHeaders({ method, path, body = '', contentType = 'application/json' }) {
|
|
71
|
-
const date = new Date().toUTCString();
|
|
72
|
-
const nonce = crypto.randomUUID();
|
|
73
|
-
const signature = generateSignature({
|
|
74
|
-
method,
|
|
75
|
-
path,
|
|
76
|
-
body,
|
|
77
|
-
contentType,
|
|
78
|
-
date,
|
|
79
|
-
nonce,
|
|
80
|
-
accessKeySecret: LOOMY_AUTH_CONFIG.accessKeySecret,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const authorization = `account ${LOOMY_AUTH_CONFIG.accessKeyId}:${signature}`;
|
|
84
|
-
const md5 = contentMD5(body);
|
|
85
|
-
|
|
86
|
-
const headers = {
|
|
87
|
-
Authorization: authorization,
|
|
88
|
-
Date: date,
|
|
89
|
-
Nonce: nonce,
|
|
90
|
-
'Content-Type': contentType,
|
|
91
|
-
Accept: 'application/json',
|
|
92
|
-
};
|
|
93
|
-
if (md5) headers['Content-MD5'] = md5;
|
|
94
|
-
return headers;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function makeBase() {
|
|
98
|
-
return {
|
|
99
|
-
appid: LOOMY_AUTH_CONFIG.appId,
|
|
100
|
-
modelid: 'Web',
|
|
101
|
-
version: '1.0.0',
|
|
102
|
-
devid: 'web',
|
|
103
|
-
ua: 'Loomy|Desktop|Electron|Windows',
|
|
104
|
-
traceid: crypto.randomUUID().replace(/-/g, ''),
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async function requestLoomy(path, body) {
|
|
109
|
-
const bodyString = JSON.stringify(body);
|
|
110
|
-
const headers = generateRequestHeaders({
|
|
111
|
-
method: 'POST',
|
|
112
|
-
path,
|
|
113
|
-
body: bodyString,
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const url = `${LOOMY_AUTH_CONFIG.baseUrl}${path}`;
|
|
117
|
-
const res = await fetch(url, {
|
|
118
|
-
method: 'POST',
|
|
119
|
-
headers,
|
|
120
|
-
body: bodyString,
|
|
121
|
-
signal: AbortSignal.timeout(15000),
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
if (!res.ok) {
|
|
125
|
-
const text = await res.text().catch(() => '');
|
|
126
|
-
throw new Error(`讯飞认证接口 HTTP ${res.status}: ${text}`);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const json = await res.json().catch(() => ({}));
|
|
130
|
-
if (json.code && json.code !== '000000') {
|
|
131
|
-
const err = new Error(json.desc || json.message || `业务错误 (${json.code})`);
|
|
132
|
-
err.code = json.code;
|
|
133
|
-
// 100002 / 020002 与客户端 AUTH_ERROR_CODES 同口径:登录态无效
|
|
134
|
-
if (json.code === '100002' || json.code === '020002') err.auth = true;
|
|
135
|
-
throw err;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return json.data;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** 发送手机验证码 */
|
|
142
|
-
export async function sendLoomySms(phone) {
|
|
143
|
-
const cleanPhone = String(phone || '').trim();
|
|
144
|
-
if (!/^1[3-9]\d{9}$/.test(cleanPhone)) {
|
|
145
|
-
throw new Error('手机号格式不正确');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const data = await requestLoomy('/login/phone/sendMsgCode', {
|
|
149
|
-
base: makeBase(),
|
|
150
|
-
param: {
|
|
151
|
-
ccode: '86',
|
|
152
|
-
phone: cleanPhone,
|
|
153
|
-
expire: 300,
|
|
154
|
-
},
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
if (!data?.msgid) {
|
|
158
|
-
throw new Error('讯飞接口未返回 msgid');
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return { success: true, msgid: data.msgid };
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/** 提交手机验证码换取 Session */
|
|
165
|
-
export async function loginLoomyBySms({ phone, code, msgid }) {
|
|
166
|
-
const cleanPhone = String(phone || '').trim();
|
|
167
|
-
const cleanCode = String(code || '').trim();
|
|
168
|
-
const cleanMsgid = String(msgid || '').trim();
|
|
169
|
-
|
|
170
|
-
if (!cleanPhone || !cleanCode || !cleanMsgid) {
|
|
171
|
-
throw new Error('手机号、验证码和 msgid 均为必填项');
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const data = await requestLoomy('/login/phone/checkCode', {
|
|
175
|
-
base: makeBase(),
|
|
176
|
-
param: {
|
|
177
|
-
ccode: '86',
|
|
178
|
-
phone: cleanPhone,
|
|
179
|
-
mcode: cleanCode,
|
|
180
|
-
msgid: cleanMsgid,
|
|
181
|
-
expire: 14 * 24 * 3600, // 14 天有效
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
if (!data?.session) {
|
|
186
|
-
throw new Error('登录未返回 session 凭据');
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return {
|
|
190
|
-
session: data.session,
|
|
191
|
-
userid: data.userid || data.uid,
|
|
192
|
-
phone: cleanPhone,
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* 新手机号注册(与登录共用同一条短信验证码,param 不带 msgid)。
|
|
198
|
-
* 渲染层 registerByPhone 同款:phone + code(可选 password,这里不设密码)。
|
|
199
|
-
*/
|
|
200
|
-
export async function registerLoomyByPhone({ phone, code }) {
|
|
201
|
-
const cleanPhone = String(phone || '').trim();
|
|
202
|
-
const cleanCode = String(code || '').trim();
|
|
203
|
-
if (!/^1[3-9]\d{9}$/.test(cleanPhone)) throw new Error('手机号格式不正确');
|
|
204
|
-
if (!cleanCode) throw new Error('验证码不能为空');
|
|
205
|
-
|
|
206
|
-
const data = await requestLoomy('/register/phone/submit', {
|
|
207
|
-
base: makeBase(),
|
|
208
|
-
param: { phone: cleanPhone, code: cleanCode },
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
// 注册成功即视为已登录(服务端语义同客户端:注册后可直接 checkCode 换 session)
|
|
212
|
-
return { success: true, ...data };
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/** 会话校验 / 资料查询:POST /userinfo/query/baseInfo { param: { session } } */
|
|
216
|
-
export async function fetchLoomyIdentity(session) {
|
|
217
|
-
const cleanSession = String(session || '').trim();
|
|
218
|
-
if (!cleanSession) throw new Error('缺少 session');
|
|
219
|
-
|
|
220
|
-
const data = await requestLoomy('/userinfo/query/baseInfo', {
|
|
221
|
-
base: makeBase(),
|
|
222
|
-
param: { session: cleanSession },
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
return {
|
|
226
|
-
userid: String(data?.userid || ''),
|
|
227
|
-
phone: String(data?.phone || ''),
|
|
228
|
-
nickname: String(data?.nickname || '').trim() || null,
|
|
229
|
-
};
|
|
230
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 讯飞 Loomy 独立登录授权模拟器(无需安装客户端,支持纯手机号验证码两步直登)。
|
|
3
|
+
*
|
|
4
|
+
* 逆向自讯飞 Loomy 生产客户端(account.xfinfr.com HMAC-SHA1 签名体系):
|
|
5
|
+
* - AppId: GM3LOOMY
|
|
6
|
+
* - AccessKeyId: 2thryby66wxi53sk
|
|
7
|
+
* - AccessKeySecret: zsak6eadrbawz683wf5r3m2snrwj868r
|
|
8
|
+
* - BaseUrl: https://account.xfinfr.com
|
|
9
|
+
*
|
|
10
|
+
* 流程:
|
|
11
|
+
* 1. sendLoomySms(phone) -> POST /login/phone/sendMsgCode (获取 msgid)
|
|
12
|
+
* 2. loginLoomyBySms({ phone, code, msgid }) -> POST /login/phone/checkCode (换取 14 天 session token)
|
|
13
|
+
* 3. registerLoomyByPhone({ phone, code }) -> POST /register/phone/submit (新手机号注册;与登录共用同一条验证码)
|
|
14
|
+
* 4. fetchLoomyIdentity(session) -> POST /userinfo/query/baseInfo (会话校验 / 昵称)
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import crypto from 'node:crypto';
|
|
18
|
+
|
|
19
|
+
export const LOOMY_AUTH_CONFIG = {
|
|
20
|
+
baseUrl: 'https://account.xfinfr.com',
|
|
21
|
+
accessKeyId: '2thryby66wxi53sk',
|
|
22
|
+
accessKeySecret: 'zsak6eadrbawz683wf5r3m2snrwj868r',
|
|
23
|
+
appId: 'GM3LOOMY',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function contentMD5(body) {
|
|
27
|
+
if (!body) return '';
|
|
28
|
+
const bodyStr = typeof body === 'string' ? body : JSON.stringify(body);
|
|
29
|
+
const hash = crypto.createHash('md5').update(bodyStr, 'utf8').digest();
|
|
30
|
+
return hash.toString('base64');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function escapePathSegment(segment) {
|
|
34
|
+
return encodeURIComponent(segment)
|
|
35
|
+
.replace(/!/g, '%21')
|
|
36
|
+
.replace(/'/g, '%27')
|
|
37
|
+
.replace(/\(/g, '%28')
|
|
38
|
+
.replace(/\)/g, '%29')
|
|
39
|
+
.replace(/\*/g, '%2A');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function buildEscapedPath(path) {
|
|
43
|
+
let cleanPath = path.startsWith('/') ? path : '/' + path;
|
|
44
|
+
if (cleanPath.length > 1 && cleanPath.endsWith('/')) {
|
|
45
|
+
cleanPath = cleanPath.slice(0, -1);
|
|
46
|
+
}
|
|
47
|
+
return cleanPath.split('/').map((seg) => (seg ? escapePathSegment(seg) : '')).join('/');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function generateSignature({ method, path, queryParams = {}, body = '', contentType = 'application/json', date, nonce, accessKeySecret }) {
|
|
51
|
+
const escapedPath = buildEscapedPath(path);
|
|
52
|
+
const md5 = contentMD5(body);
|
|
53
|
+
const parts = [
|
|
54
|
+
method.toUpperCase(),
|
|
55
|
+
escapedPath,
|
|
56
|
+
'', // escapedQuery
|
|
57
|
+
md5,
|
|
58
|
+
contentType,
|
|
59
|
+
date,
|
|
60
|
+
nonce,
|
|
61
|
+
'', // signedHeaders
|
|
62
|
+
'' // canonicalizedHeaders
|
|
63
|
+
];
|
|
64
|
+
const stringToSign = parts.join('\n');
|
|
65
|
+
const hmac = crypto.createHmac('sha1', accessKeySecret);
|
|
66
|
+
hmac.update(stringToSign, 'utf8');
|
|
67
|
+
return hmac.digest('base64');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function generateRequestHeaders({ method, path, body = '', contentType = 'application/json' }) {
|
|
71
|
+
const date = new Date().toUTCString();
|
|
72
|
+
const nonce = crypto.randomUUID();
|
|
73
|
+
const signature = generateSignature({
|
|
74
|
+
method,
|
|
75
|
+
path,
|
|
76
|
+
body,
|
|
77
|
+
contentType,
|
|
78
|
+
date,
|
|
79
|
+
nonce,
|
|
80
|
+
accessKeySecret: LOOMY_AUTH_CONFIG.accessKeySecret,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const authorization = `account ${LOOMY_AUTH_CONFIG.accessKeyId}:${signature}`;
|
|
84
|
+
const md5 = contentMD5(body);
|
|
85
|
+
|
|
86
|
+
const headers = {
|
|
87
|
+
Authorization: authorization,
|
|
88
|
+
Date: date,
|
|
89
|
+
Nonce: nonce,
|
|
90
|
+
'Content-Type': contentType,
|
|
91
|
+
Accept: 'application/json',
|
|
92
|
+
};
|
|
93
|
+
if (md5) headers['Content-MD5'] = md5;
|
|
94
|
+
return headers;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function makeBase() {
|
|
98
|
+
return {
|
|
99
|
+
appid: LOOMY_AUTH_CONFIG.appId,
|
|
100
|
+
modelid: 'Web',
|
|
101
|
+
version: '1.0.0',
|
|
102
|
+
devid: 'web',
|
|
103
|
+
ua: 'Loomy|Desktop|Electron|Windows',
|
|
104
|
+
traceid: crypto.randomUUID().replace(/-/g, ''),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function requestLoomy(path, body) {
|
|
109
|
+
const bodyString = JSON.stringify(body);
|
|
110
|
+
const headers = generateRequestHeaders({
|
|
111
|
+
method: 'POST',
|
|
112
|
+
path,
|
|
113
|
+
body: bodyString,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const url = `${LOOMY_AUTH_CONFIG.baseUrl}${path}`;
|
|
117
|
+
const res = await fetch(url, {
|
|
118
|
+
method: 'POST',
|
|
119
|
+
headers,
|
|
120
|
+
body: bodyString,
|
|
121
|
+
signal: AbortSignal.timeout(15000),
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
if (!res.ok) {
|
|
125
|
+
const text = await res.text().catch(() => '');
|
|
126
|
+
throw new Error(`讯飞认证接口 HTTP ${res.status}: ${text}`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const json = await res.json().catch(() => ({}));
|
|
130
|
+
if (json.code && json.code !== '000000') {
|
|
131
|
+
const err = new Error(json.desc || json.message || `业务错误 (${json.code})`);
|
|
132
|
+
err.code = json.code;
|
|
133
|
+
// 100002 / 020002 与客户端 AUTH_ERROR_CODES 同口径:登录态无效
|
|
134
|
+
if (json.code === '100002' || json.code === '020002') err.auth = true;
|
|
135
|
+
throw err;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return json.data;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** 发送手机验证码 */
|
|
142
|
+
export async function sendLoomySms(phone) {
|
|
143
|
+
const cleanPhone = String(phone || '').trim();
|
|
144
|
+
if (!/^1[3-9]\d{9}$/.test(cleanPhone)) {
|
|
145
|
+
throw new Error('手机号格式不正确');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const data = await requestLoomy('/login/phone/sendMsgCode', {
|
|
149
|
+
base: makeBase(),
|
|
150
|
+
param: {
|
|
151
|
+
ccode: '86',
|
|
152
|
+
phone: cleanPhone,
|
|
153
|
+
expire: 300,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
if (!data?.msgid) {
|
|
158
|
+
throw new Error('讯飞接口未返回 msgid');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return { success: true, msgid: data.msgid };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** 提交手机验证码换取 Session */
|
|
165
|
+
export async function loginLoomyBySms({ phone, code, msgid }) {
|
|
166
|
+
const cleanPhone = String(phone || '').trim();
|
|
167
|
+
const cleanCode = String(code || '').trim();
|
|
168
|
+
const cleanMsgid = String(msgid || '').trim();
|
|
169
|
+
|
|
170
|
+
if (!cleanPhone || !cleanCode || !cleanMsgid) {
|
|
171
|
+
throw new Error('手机号、验证码和 msgid 均为必填项');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const data = await requestLoomy('/login/phone/checkCode', {
|
|
175
|
+
base: makeBase(),
|
|
176
|
+
param: {
|
|
177
|
+
ccode: '86',
|
|
178
|
+
phone: cleanPhone,
|
|
179
|
+
mcode: cleanCode,
|
|
180
|
+
msgid: cleanMsgid,
|
|
181
|
+
expire: 14 * 24 * 3600, // 14 天有效
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
if (!data?.session) {
|
|
186
|
+
throw new Error('登录未返回 session 凭据');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
session: data.session,
|
|
191
|
+
userid: data.userid || data.uid,
|
|
192
|
+
phone: cleanPhone,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 新手机号注册(与登录共用同一条短信验证码,param 不带 msgid)。
|
|
198
|
+
* 渲染层 registerByPhone 同款:phone + code(可选 password,这里不设密码)。
|
|
199
|
+
*/
|
|
200
|
+
export async function registerLoomyByPhone({ phone, code }) {
|
|
201
|
+
const cleanPhone = String(phone || '').trim();
|
|
202
|
+
const cleanCode = String(code || '').trim();
|
|
203
|
+
if (!/^1[3-9]\d{9}$/.test(cleanPhone)) throw new Error('手机号格式不正确');
|
|
204
|
+
if (!cleanCode) throw new Error('验证码不能为空');
|
|
205
|
+
|
|
206
|
+
const data = await requestLoomy('/register/phone/submit', {
|
|
207
|
+
base: makeBase(),
|
|
208
|
+
param: { phone: cleanPhone, code: cleanCode },
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// 注册成功即视为已登录(服务端语义同客户端:注册后可直接 checkCode 换 session)
|
|
212
|
+
return { success: true, ...data };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** 会话校验 / 资料查询:POST /userinfo/query/baseInfo { param: { session } } */
|
|
216
|
+
export async function fetchLoomyIdentity(session) {
|
|
217
|
+
const cleanSession = String(session || '').trim();
|
|
218
|
+
if (!cleanSession) throw new Error('缺少 session');
|
|
219
|
+
|
|
220
|
+
const data = await requestLoomy('/userinfo/query/baseInfo', {
|
|
221
|
+
base: makeBase(),
|
|
222
|
+
param: { session: cleanSession },
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
userid: String(data?.userid || ''),
|
|
227
|
+
phone: String(data?.phone || ''),
|
|
228
|
+
nickname: String(data?.nickname || '').trim() || null,
|
|
229
|
+
};
|
|
230
|
+
}
|