@pisell/pisellos 0.0.334 → 0.0.336

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