@jetthai/cuora 1.1.450 → 1.1.451-dev.2

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.
@@ -2,6 +2,20 @@ import { assign, createMachine } from 'xstate'
2
2
  import auth from '../api/auth.js'
3
3
  import storage from '../util/storage.js'
4
4
 
5
+ // 註冊強制綁定多型出款:轉發各綁定型別欄位(BANK / CRYPTO / EWALLET),只帶有值的欄位
6
+ const BIND_FIELDS = [
7
+ 'bindingType',
8
+ 'cryptoCurrency',
9
+ 'cryptoNetwork',
10
+ 'cryptoAddress',
11
+ 'walletCode',
12
+ 'ifscCode',
13
+ 'pixType',
14
+ 'firstNameLocale',
15
+ 'lastNameLocale',
16
+ ]
17
+ const pickBindData = (data = {}) => BIND_FIELDS.reduce((acc, key) => (data[key] !== undefined ? { ...acc, [key]: data[key] } : acc), {})
18
+
5
19
  export default function (request) {
6
20
  const { sentry } = request.config
7
21
  return createMachine(
@@ -72,11 +86,27 @@ export default function (request) {
72
86
  return { fc }
73
87
  }),
74
88
  setSignUpId: assign((context, event) => {
75
- const { email, username, nick_name, password, countryCode, phone, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } =
76
- event.data
89
+ const {
90
+ email,
91
+ username,
92
+ nick_name,
93
+ password,
94
+ countryCode,
95
+ phone,
96
+ bankCode,
97
+ bankAccount,
98
+ holderName,
99
+ branch,
100
+ branchCode,
101
+ affiliateCode,
102
+ birthday,
103
+ } = event.data
77
104
  return {
78
105
  signUpData: {
79
106
  provider: 'local',
107
+ birthday,
108
+ ...pickBindData(event.data),
109
+ birthday,
80
110
  email,
81
111
  username,
82
112
  nick_name,
@@ -93,10 +123,14 @@ export default function (request) {
93
123
  }
94
124
  }),
95
125
  setSignUpPhone: assign((context, event) => {
96
- const { email, countryCode, phone, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } = event.data
126
+ const { email, countryCode, phone, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode, birthday } =
127
+ event.data
97
128
  return {
98
129
  signUpData: {
99
130
  provider: 'phone',
131
+ birthday,
132
+ ...pickBindData(event.data),
133
+ birthday,
100
134
  email,
101
135
  countryCode,
102
136
  phone,
@@ -112,10 +146,14 @@ export default function (request) {
112
146
  }
113
147
  }),
114
148
  setSignUpEmail: assign((context, event) => {
115
- const { email, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode, countryCode, phone } = event.data
149
+ const { email, nick_name, password, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode, countryCode, phone, birthday } =
150
+ event.data
116
151
  return {
117
152
  signUpData: {
118
153
  provider: 'email',
154
+ birthday,
155
+ ...pickBindData(event.data),
156
+ birthday,
119
157
  email,
120
158
  nick_name,
121
159
  password,
@@ -254,7 +254,7 @@ export default class Request {
254
254
  // reject → onError → leaving → 乾淨登出,且一樣不送網路 → 洪水照止
255
255
  if (!req.isPublic && !this.getToken()) return Promise.reject({ code: 'ERR_A103' })
256
256
 
257
- const cancelToken = customToken || this.source.token
257
+ const cancelToken = customToken
258
258
 
259
259
  // ERR_A103 No token provided 改由後端回傳:不再於送出前自行 throw,
260
260
  const requestConfig = this._createConfig(req, cancelToken)
@@ -283,6 +283,8 @@ export default class Request {
283
283
  }
284
284
  }
285
285
 
286
+ // 注意:send() 已不再預設附加 this.source.token(見 send 內註解),
287
+ // sourceUpdate 僅對「呼叫端明確以 this.source.token 為 customToken」的請求有效;保留以維持 API 相容。
286
288
  sourceUpdate() {
287
289
  this.source.cancel('Requests Cancelled')
288
290
  this.source = this.axios.CancelToken.source()