@pisell/pisellos 3.0.69 → 3.0.71

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,794 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
7
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
8
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ /**
14
+ * 注册登录解决方案配置
15
+ * 根据不同渠道配置不同的接口地址和参数
16
+ */
17
+
18
+ /**
19
+ * API 配置接口
20
+ */
21
+
22
+ /**
23
+ * 渠道配置接口
24
+ */
25
+
26
+ /**
27
+ * online-store 渠道配置
28
+ */
29
+ var onlineStoreConfig = {
30
+ sendEmailVerificationCode: {
31
+ url: '/auth/email/register-code',
32
+ method: 'GET',
33
+ transformParams: function transformParams(params) {
34
+ return {
35
+ email: params.target
36
+ };
37
+ }
38
+ },
39
+ sendEmailLoginCode: {
40
+ url: '/auth/send-email-code',
41
+ method: 'POST',
42
+ transformParams: function transformParams(params) {
43
+ return {
44
+ email: params.target,
45
+ purpose: params.purpose,
46
+ type: params.type
47
+ };
48
+ }
49
+ },
50
+ sendSmsRegisterCode: {
51
+ url: '/auth/mobile/sms-register',
52
+ method: 'POST',
53
+ transformParams: function transformParams(params) {
54
+ return {
55
+ phone: String(params.phone),
56
+ country_calling_code: String(params.country_calling_code)
57
+ };
58
+ }
59
+ },
60
+ sendEmailRegisterLink: {
61
+ url: '/auth/email/link/new-send-register-link',
62
+ method: 'POST',
63
+ transformParams: function transformParams(email) {
64
+ return {
65
+ email: email
66
+ };
67
+ }
68
+ },
69
+ verifyEmailRegistrationLink: {
70
+ url: '/auth/email/link/new-register',
71
+ method: 'POST',
72
+ transformParams: function transformParams(params) {
73
+ return {
74
+ code: params.code,
75
+ password: params.password
76
+ };
77
+ }
78
+ },
79
+ emailPasswordLogin: {
80
+ url: '/auth/email/login',
81
+ method: 'POST',
82
+ transformParams: function transformParams(params) {
83
+ return {
84
+ email: params.email,
85
+ password: params.password
86
+ };
87
+ },
88
+ options: {
89
+ withCredentials: true
90
+ }
91
+ },
92
+ emailCodeRegister: {
93
+ url: '/auth/email/register',
94
+ method: 'POST',
95
+ transformParams: function transformParams(params) {
96
+ return {
97
+ email: params.email,
98
+ code: params.code,
99
+ password: params.password
100
+ };
101
+ }
102
+ },
103
+ phoneCodeRegister: {
104
+ url: '/auth/mobile/register',
105
+ method: 'POST',
106
+ transformParams: function transformParams(params) {
107
+ return {
108
+ phone: String(params.phone),
109
+ password: params.password,
110
+ code: params.code,
111
+ country_calling_code: String(params.country_calling_code)
112
+ };
113
+ }
114
+ },
115
+ resendEmailRegisterLink: {
116
+ url: '/auth/email/link/resend_register_link',
117
+ method: 'POST',
118
+ transformParams: function transformParams(params) {
119
+ return {
120
+ code: params.code
121
+ };
122
+ }
123
+ },
124
+ checkEmailLinkCode: {
125
+ url: '/auth/email/link/new-register-check-code',
126
+ method: 'GET',
127
+ transformParams: function transformParams(params) {
128
+ return {
129
+ code: params.code
130
+ };
131
+ }
132
+ },
133
+ sendSmsLoginCode: {
134
+ url: '/auth/send-login-msg',
135
+ method: 'POST',
136
+ transformParams: function transformParams(params) {
137
+ return {
138
+ phone: String(params.phone),
139
+ country_calling_code: String(params.country_calling_code)
140
+ };
141
+ }
142
+ },
143
+ phoneCodeLogin: {
144
+ url: '/auth/mobile-login',
145
+ method: 'POST',
146
+ transformParams: function transformParams(params) {
147
+ return {
148
+ phone: String(params.phone),
149
+ country_calling_code: String(params.country_calling_code),
150
+ code: params.code
151
+ };
152
+ }
153
+ },
154
+ guestLogin: {
155
+ url: '/auth/guest/login',
156
+ method: 'POST',
157
+ transformParams: function transformParams(params) {
158
+ return {
159
+ login_channel: params.login_channel,
160
+ guest_code: params.guest_code
161
+ };
162
+ }
163
+ },
164
+ checkEmailExists: {
165
+ url: '/auth/email/check-email',
166
+ method: 'GET',
167
+ transformParams: function transformParams(params) {
168
+ return {
169
+ email: params.email,
170
+ sales_channel: 'online_store'
171
+ };
172
+ }
173
+ },
174
+ checkEmailCode: {
175
+ url: '/auth/email/check-email-code',
176
+ method: 'GET',
177
+ transformParams: function transformParams(params) {
178
+ return {
179
+ email: params.email,
180
+ code: params.code,
181
+ action: params.action
182
+ };
183
+ }
184
+ },
185
+ checkMobileCode: {
186
+ url: '/auth/mobile/check-mobile-code',
187
+ method: 'GET',
188
+ transformParams: function transformParams(params) {
189
+ return {
190
+ phone: String(params.phone),
191
+ code: params.code,
192
+ country_calling_code: String(params.country_calling_code),
193
+ action: params.action
194
+ };
195
+ }
196
+ },
197
+ phonePasswordLogin: {
198
+ url: '/auth/mobile/login',
199
+ method: 'POST',
200
+ transformParams: function transformParams(params) {
201
+ return {
202
+ phone: String(params.phone),
203
+ password: params.password,
204
+ country_calling_code: String(params.country_calling_code)
205
+ };
206
+ }
207
+ },
208
+ sendPasswordResetEmail: {
209
+ url: '/auth/email/reset-password-code',
210
+ method: 'GET',
211
+ transformParams: function transformParams(params) {
212
+ return {
213
+ email: params.email
214
+ };
215
+ }
216
+ },
217
+ sendPasswordResetSms: {
218
+ url: '/auth/mobile/sms-forget',
219
+ method: 'POST',
220
+ transformParams: function transformParams(params) {
221
+ return {
222
+ phone: String(params.phone),
223
+ country_calling_code: String(params.country_calling_code)
224
+ };
225
+ }
226
+ },
227
+ sendResetPasswordLink: {
228
+ url: '/auth/email/link/send_reset_pwd_link',
229
+ method: 'POST',
230
+ transformParams: function transformParams(params) {
231
+ return {
232
+ email: params.email
233
+ };
234
+ }
235
+ },
236
+ checkResetPasswordCode: {
237
+ url: '/auth/email/link/check_code',
238
+ method: 'GET',
239
+ transformParams: function transformParams(params) {
240
+ return {
241
+ code: params.code
242
+ };
243
+ }
244
+ },
245
+ resetPasswordByCode: {
246
+ url: '/auth/email/link/reset_pwd_by_code',
247
+ method: 'POST',
248
+ transformParams: function transformParams(params) {
249
+ return {
250
+ code: params.code,
251
+ password: params.password
252
+ };
253
+ }
254
+ },
255
+ resetPasswordByEmail: {
256
+ url: '/auth/email/reset-password',
257
+ method: 'POST',
258
+ transformParams: function transformParams(params) {
259
+ return {
260
+ email: params.email,
261
+ password: params.password,
262
+ code: params.code
263
+ };
264
+ }
265
+ },
266
+ resetPasswordByPhone: {
267
+ url: '/auth/mobile/reset-password',
268
+ method: 'POST',
269
+ transformParams: function transformParams(params) {
270
+ return {
271
+ phone: String(params.phone),
272
+ password: params.password,
273
+ code: params.code,
274
+ country_calling_code: String(params.country_calling_code)
275
+ };
276
+ }
277
+ },
278
+ verifyCode: {
279
+ url: '/auth/verify-code',
280
+ method: 'POST',
281
+ transformParams: function transformParams(params) {
282
+ return params;
283
+ }
284
+ },
285
+ register: {
286
+ url: '/auth/register',
287
+ method: 'POST',
288
+ transformParams: function transformParams(params) {
289
+ return params;
290
+ }
291
+ },
292
+ login: {
293
+ url: '/auth/login',
294
+ method: 'POST',
295
+ transformParams: function transformParams(params) {
296
+ return params;
297
+ }
298
+ },
299
+ oauthLogin: {
300
+ url: '/auth/oauth-login',
301
+ method: 'POST',
302
+ transformParams: function transformParams(params) {
303
+ return params;
304
+ }
305
+ },
306
+ validateToken: {
307
+ url: '/auth/validate',
308
+ method: 'GET',
309
+ transformParams: function transformParams(token) {
310
+ return {};
311
+ },
312
+ options: {
313
+ headers: function headers(token) {
314
+ return {
315
+ Authorization: "Bearer ".concat(token)
316
+ };
317
+ }
318
+ }
319
+ },
320
+ logout: {
321
+ url: '/auth/logout',
322
+ method: 'POST',
323
+ transformParams: function transformParams() {
324
+ return {};
325
+ }
326
+ },
327
+ getCountries: {
328
+ url: '/area/country',
329
+ method: 'GET',
330
+ transformParams: function transformParams() {
331
+ return {};
332
+ }
333
+ },
334
+ facebookLogin: {
335
+ url: '/auth/facebook/login',
336
+ method: 'POST',
337
+ transformParams: function transformParams(params) {
338
+ return {
339
+ token: params.token
340
+ };
341
+ }
342
+ },
343
+ appleLogin: {
344
+ url: '/auth/apple/login',
345
+ method: 'POST',
346
+ transformParams: function transformParams(params) {
347
+ return {
348
+ code: params.code
349
+ };
350
+ }
351
+ }
352
+ };
353
+
354
+ /**
355
+ * 默认配置(通用配置)
356
+ */
357
+ var defaultConfig = {
358
+ sendEmailVerificationCode: {
359
+ url: '/auth/send-email-code',
360
+ method: 'POST',
361
+ transformParams: function transformParams(params) {
362
+ return {
363
+ email: params.target,
364
+ purpose: params.purpose,
365
+ type: params.type
366
+ };
367
+ }
368
+ },
369
+ sendEmailLoginCode: {
370
+ url: '/auth/send-email-code',
371
+ method: 'POST',
372
+ transformParams: function transformParams(params) {
373
+ return {
374
+ email: params.target,
375
+ purpose: params.purpose,
376
+ type: params.type
377
+ };
378
+ }
379
+ },
380
+ sendSmsRegisterCode: {
381
+ url: '/auth/send-sms-register',
382
+ method: 'POST',
383
+ transformParams: function transformParams(params) {
384
+ return {
385
+ phone: String(params.phone),
386
+ country_calling_code: String(params.country_calling_code)
387
+ };
388
+ }
389
+ },
390
+ sendEmailRegisterLink: {
391
+ url: '/auth/send-email-register-link',
392
+ method: 'POST',
393
+ transformParams: function transformParams(email) {
394
+ return {
395
+ email: email
396
+ };
397
+ }
398
+ },
399
+ verifyEmailRegistrationLink: {
400
+ url: '/auth/verify-email-registration-link',
401
+ method: 'POST',
402
+ transformParams: function transformParams(code) {
403
+ return {
404
+ code: code
405
+ };
406
+ }
407
+ },
408
+ emailPasswordLogin: {
409
+ url: '/auth/email-password-login',
410
+ method: 'POST',
411
+ transformParams: function transformParams(params) {
412
+ return {
413
+ email: params.email,
414
+ password: params.password
415
+ };
416
+ }
417
+ },
418
+ emailCodeRegister: {
419
+ url: '/auth/email/register',
420
+ method: 'POST',
421
+ transformParams: function transformParams(params) {
422
+ return {
423
+ email: params.email,
424
+ code: params.code,
425
+ password: params.password
426
+ };
427
+ }
428
+ },
429
+ phoneCodeRegister: {
430
+ url: '/auth/mobile/register',
431
+ method: 'POST',
432
+ transformParams: function transformParams(params) {
433
+ return {
434
+ phone: String(params.phone),
435
+ password: params.password,
436
+ code: params.code,
437
+ country_calling_code: String(params.country_calling_code)
438
+ };
439
+ }
440
+ },
441
+ resendEmailRegisterLink: {
442
+ url: '/auth/resend-email-register-link',
443
+ method: 'POST',
444
+ transformParams: function transformParams(params) {
445
+ return {
446
+ code: params.code
447
+ };
448
+ }
449
+ },
450
+ checkEmailLinkCode: {
451
+ url: '/email/link/check_code',
452
+ method: 'GET',
453
+ transformParams: function transformParams(params) {
454
+ return {
455
+ code: params.code
456
+ };
457
+ }
458
+ },
459
+ sendSmsLoginCode: {
460
+ url: '/auth/send-sms-login-code',
461
+ method: 'POST',
462
+ transformParams: function transformParams(params) {
463
+ return {
464
+ phone: String(params.phone),
465
+ country_calling_code: String(params.country_calling_code)
466
+ };
467
+ }
468
+ },
469
+ phoneCodeLogin: {
470
+ url: '/auth/phone-code-login',
471
+ method: 'POST',
472
+ transformParams: function transformParams(params) {
473
+ return {
474
+ phone: String(params.phone),
475
+ country_calling_code: String(params.country_calling_code),
476
+ code: params.code
477
+ };
478
+ }
479
+ },
480
+ guestLogin: {
481
+ url: '/auth/guest-login',
482
+ method: 'POST',
483
+ transformParams: function transformParams(channel) {
484
+ return {
485
+ login_channel: channel
486
+ };
487
+ }
488
+ },
489
+ checkEmailExists: {
490
+ url: '/auth/check-email-exists',
491
+ method: 'GET',
492
+ transformParams: function transformParams(params) {
493
+ return {
494
+ email: params.email
495
+ };
496
+ }
497
+ },
498
+ checkEmailCode: {
499
+ url: '/auth/check-email-code',
500
+ method: 'GET',
501
+ transformParams: function transformParams(params) {
502
+ return {
503
+ email: params.email,
504
+ code: params.code
505
+ };
506
+ }
507
+ },
508
+ checkMobileCode: {
509
+ url: '/auth/check-mobile-code',
510
+ method: 'GET',
511
+ transformParams: function transformParams(params) {
512
+ return {
513
+ phone: String(params.phone),
514
+ code: params.code,
515
+ country_calling_code: String(params.country_calling_code),
516
+ action: params.action
517
+ };
518
+ }
519
+ },
520
+ phonePasswordLogin: {
521
+ url: '/auth/mobile-password-login',
522
+ method: 'POST',
523
+ transformParams: function transformParams(params) {
524
+ return {
525
+ phone: String(params.phone),
526
+ password: params.password,
527
+ country_calling_code: String(params.country_calling_code)
528
+ };
529
+ }
530
+ },
531
+ sendPasswordResetEmail: {
532
+ url: '/auth/send-password-reset-email',
533
+ method: 'GET',
534
+ transformParams: function transformParams(params) {
535
+ return {
536
+ email: params.email
537
+ };
538
+ }
539
+ },
540
+ sendPasswordResetSms: {
541
+ url: '/auth/send-password-reset-sms',
542
+ method: 'POST',
543
+ transformParams: function transformParams(params) {
544
+ return {
545
+ phone: String(params.phone),
546
+ country_calling_code: String(params.country_calling_code)
547
+ };
548
+ }
549
+ },
550
+ sendResetPasswordLink: {
551
+ url: '/auth/send-reset-password-link',
552
+ method: 'POST',
553
+ transformParams: function transformParams(params) {
554
+ return {
555
+ email: params.email
556
+ };
557
+ }
558
+ },
559
+ checkResetPasswordCode: {
560
+ url: '/auth/check-reset-password-code',
561
+ method: 'GET',
562
+ transformParams: function transformParams(params) {
563
+ return {
564
+ code: params.code
565
+ };
566
+ }
567
+ },
568
+ resetPasswordByCode: {
569
+ url: '/auth/reset-password-by-code',
570
+ method: 'GET',
571
+ transformParams: function transformParams(params) {
572
+ return {
573
+ code: params.code,
574
+ password: params.password
575
+ };
576
+ }
577
+ },
578
+ resetPasswordByEmail: {
579
+ url: '/auth/reset-password-email',
580
+ method: 'POST',
581
+ transformParams: function transformParams(params) {
582
+ return {
583
+ email: params.email,
584
+ password: params.password,
585
+ code: params.code
586
+ };
587
+ }
588
+ },
589
+ resetPasswordByPhone: {
590
+ url: '/auth/reset-password-phone',
591
+ method: 'POST',
592
+ transformParams: function transformParams(params) {
593
+ return {
594
+ phone: String(params.phone),
595
+ password: params.password,
596
+ code: params.code,
597
+ country_calling_code: String(params.country_calling_code)
598
+ };
599
+ }
600
+ },
601
+ verifyCode: {
602
+ url: '/auth/verify-code',
603
+ method: 'POST',
604
+ transformParams: function transformParams(params) {
605
+ return params;
606
+ }
607
+ },
608
+ register: {
609
+ url: '/auth/register',
610
+ method: 'POST',
611
+ transformParams: function transformParams(params) {
612
+ return params;
613
+ }
614
+ },
615
+ login: {
616
+ url: '/auth/login',
617
+ method: 'POST',
618
+ transformParams: function transformParams(params) {
619
+ return params;
620
+ }
621
+ },
622
+ oauthLogin: {
623
+ url: '/auth/oauth-login',
624
+ method: 'POST',
625
+ transformParams: function transformParams(params) {
626
+ return params;
627
+ }
628
+ },
629
+ validateToken: {
630
+ url: '/auth/validate',
631
+ method: 'GET',
632
+ transformParams: function transformParams(token) {
633
+ return {};
634
+ },
635
+ options: {
636
+ headers: function headers(token) {
637
+ return {
638
+ Authorization: "Bearer ".concat(token)
639
+ };
640
+ }
641
+ }
642
+ },
643
+ logout: {
644
+ url: '/auth/logout',
645
+ method: 'POST',
646
+ transformParams: function transformParams() {
647
+ return {};
648
+ }
649
+ },
650
+ getCountries: {
651
+ url: '/auth/countries',
652
+ method: 'GET',
653
+ transformParams: function transformParams() {
654
+ return {};
655
+ }
656
+ },
657
+ facebookLogin: {
658
+ url: '/auth/facebook/login',
659
+ method: 'POST',
660
+ transformParams: function transformParams(params) {
661
+ return {
662
+ token: params.token
663
+ };
664
+ }
665
+ },
666
+ appleLogin: {
667
+ url: '/auth/apple/login',
668
+ method: 'POST',
669
+ transformParams: function transformParams(params) {
670
+ return {
671
+ code: params.code
672
+ };
673
+ }
674
+ }
675
+ };
676
+
677
+ /**
678
+ * 渠道配置映射
679
+ */
680
+ export var channelConfigMap = {
681
+ 'online-store': onlineStoreConfig,
682
+ 'default': defaultConfig
683
+ };
684
+
685
+ /**
686
+ * 获取渠道配置
687
+ */
688
+ export function getChannelConfig(channel) {
689
+ return channelConfigMap[channel] || channelConfigMap['default'];
690
+ }
691
+
692
+ /**
693
+ * API 调用器类
694
+ * 负责根据配置执行 API 调用
695
+ */
696
+ export var ApiCaller = /*#__PURE__*/function () {
697
+ function ApiCaller(request, config) {
698
+ _classCallCheck(this, ApiCaller);
699
+ this.request = request;
700
+ this.config = config;
701
+ }
702
+
703
+ /**
704
+ * 执行 API 调用
705
+ */
706
+ _createClass(ApiCaller, [{
707
+ key: "call",
708
+ value: (function () {
709
+ var _call = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(apiName, params, additionalOptions) {
710
+ var apiConfig, transformedParams, requestOptions, response;
711
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
712
+ while (1) switch (_context.prev = _context.next) {
713
+ case 0:
714
+ apiConfig = this.config[apiName];
715
+ if (apiConfig) {
716
+ _context.next = 3;
717
+ break;
718
+ }
719
+ throw new Error("API \u914D\u7F6E\u672A\u627E\u5230: ".concat(String(apiName)));
720
+ case 3:
721
+ // 转换参数
722
+ transformedParams = apiConfig.transformParams ? apiConfig.transformParams(params) : params; // 构建请求选项
723
+ requestOptions = _objectSpread(_objectSpread({}, apiConfig.options), additionalOptions); // 处理动态 headers
724
+ if (requestOptions.headers && typeof requestOptions.headers === 'function') {
725
+ requestOptions.headers = requestOptions.headers(params);
726
+ }
727
+ requestOptions.customToast = function () {};
728
+
729
+ // 根据 HTTP 方法调用对应的请求方法
730
+ _context.t0 = apiConfig.method;
731
+ _context.next = _context.t0 === 'GET' ? 10 : _context.t0 === 'POST' ? 20 : _context.t0 === 'PUT' ? 24 : _context.t0 === 'DELETE' ? 28 : 32;
732
+ break;
733
+ case 10:
734
+ if (!(transformedParams && Object.keys(transformedParams).length > 0)) {
735
+ _context.next = 16;
736
+ break;
737
+ }
738
+ _context.next = 13;
739
+ return this.request.get(apiConfig.url, transformedParams, requestOptions);
740
+ case 13:
741
+ response = _context.sent;
742
+ _context.next = 19;
743
+ break;
744
+ case 16:
745
+ _context.next = 18;
746
+ return this.request.get(apiConfig.url, undefined, requestOptions);
747
+ case 18:
748
+ response = _context.sent;
749
+ case 19:
750
+ return _context.abrupt("break", 33);
751
+ case 20:
752
+ _context.next = 22;
753
+ return this.request.post(apiConfig.url, transformedParams, requestOptions);
754
+ case 22:
755
+ response = _context.sent;
756
+ return _context.abrupt("break", 33);
757
+ case 24:
758
+ _context.next = 26;
759
+ return this.request.put(apiConfig.url, transformedParams, requestOptions);
760
+ case 26:
761
+ response = _context.sent;
762
+ return _context.abrupt("break", 33);
763
+ case 28:
764
+ _context.next = 30;
765
+ return this.request.delete(apiConfig.url, requestOptions);
766
+ case 30:
767
+ response = _context.sent;
768
+ return _context.abrupt("break", 33);
769
+ case 32:
770
+ throw new Error("\u4E0D\u652F\u6301\u7684 HTTP \u65B9\u6CD5: ".concat(apiConfig.method));
771
+ case 33:
772
+ return _context.abrupt("return", apiConfig.transformResponse ? apiConfig.transformResponse(response) : response);
773
+ case 34:
774
+ case "end":
775
+ return _context.stop();
776
+ }
777
+ }, _callee, this);
778
+ }));
779
+ function call(_x, _x2, _x3) {
780
+ return _call.apply(this, arguments);
781
+ }
782
+ return call;
783
+ }())
784
+ }]);
785
+ return ApiCaller;
786
+ }();
787
+
788
+ /**
789
+ * 创建 API 调用器
790
+ */
791
+ export function createApiCaller(request, channel) {
792
+ var config = getChannelConfig(channel);
793
+ return new ApiCaller(request, config);
794
+ }