@jetthai/cuora 1.1.481-api.2 → 1.1.481
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/package.json
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# JT-1776243420: Third-Party Register Carry Phone / Email Payload
|
|
2
|
+
|
|
3
|
+
## Key Changes
|
|
4
|
+
|
|
5
|
+
1. Extended third-party redirect payload assembly to read `tp_phone`, `tp_countryCode`, and `tp_email` from storage.
|
|
6
|
+
2. Preserved existing affiliate code / nickname behavior and appended new fields only when values are valid.
|
|
7
|
+
3. Cleans the temporary third-party storage keys after composing the redirect query.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Key Findings
|
|
12
|
+
|
|
13
|
+
### Strengths
|
|
14
|
+
|
|
15
|
+
1. The change is tightly scoped to the third-party auth redirect builder in `src/machine/auth.js:477-520`.
|
|
16
|
+
2. Existing affiliate code and nickname logic remains unchanged while phone / email are additive only.
|
|
17
|
+
3. Temporary keys are removed after payload composition, reducing leakage into later unrelated auth flows.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
### Behavior Observed
|
|
22
|
+
|
|
23
|
+
1. Static review confirms `phone`, `countryCode`, and `email` are appended only when storage values are not `undefined` / `null`.
|
|
24
|
+
2. Channel and subchannel fallback logic stays intact after the new fields are added.
|
|
25
|
+
3. No unrelated file changes were present in this repo for the review scope.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 🔧 Change Type
|
|
30
|
+
|
|
31
|
+
- [ ] 🐛 Bug fix
|
|
32
|
+
- [x] ✨ New feature
|
|
33
|
+
- [ ] 💄 Style
|
|
34
|
+
- [ ] ♻️ Refactor
|
|
35
|
+
- [ ] ⚡ Performance
|
|
36
|
+
- [ ] 🔧 Chore
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 📱 Impact Scope
|
|
41
|
+
|
|
42
|
+
- Third-party register / login redirect query assembly in cuora shared auth machine.
|
|
43
|
+
- Downstream PWA clients that store `tp_phone`, `tp_countryCode`, and `tp_email` before `LOGIN_3PARTY`.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Test Completion Status
|
|
48
|
+
|
|
49
|
+
| Item | Validation Tested | Status |
|
|
50
|
+
| -------------------------- | --------------------------------------------------------------------- | ------- |
|
|
51
|
+
| Diff hygiene | `git diff --check` in `cuora-module` | PASS |
|
|
52
|
+
| Shared auth payload review | Reviewed `src/machine/auth.js:477-520` against ticket intent | PASS |
|
|
53
|
+
| Runtime redirect execution | Not run in this repo directly; validated through client repos instead | NOT RUN |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 📋 Spec Validation (Aligned with review-playbook)
|
|
58
|
+
|
|
59
|
+
| Spec Item | Evidence (File/Line/Result) | Status |
|
|
60
|
+
| ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ------ |
|
|
61
|
+
| Third-party flow can carry phone when client stored it | `src/machine/auth.js:479-520` reads `tp_phone` / `tp_countryCode` and appends them to `referralObj` | PASS |
|
|
62
|
+
| Third-party flow can carry email when client stored it | `src/machine/auth.js:481-520` reads `tp_email` and appends it to `referralObj` | PASS |
|
|
63
|
+
| Affiliate code and nickname keep original logic | `src/machine/auth.js:477-500` keeps `ac` / `nick_name` handling unchanged | PASS |
|
|
64
|
+
| Temporary third-party data does not leak into later unrelated flows | `src/machine/auth.js:518-520` removes the temporary storage keys after composing the redirect URL | PASS |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 📋 Standards Checklist (Summary)
|
|
69
|
+
|
|
70
|
+
| Category | Result | Notes |
|
|
71
|
+
| ---------------------- | ------- | --------------------------------------------------------------------------- |
|
|
72
|
+
| Memory Safety | PASS | Simple storage reads and object assembly only. |
|
|
73
|
+
| Rendering Performance | PASS | No rendering code touched. |
|
|
74
|
+
| Network Requests | PASS | Existing redirect flow only; no extra requests added. |
|
|
75
|
+
| Bundle Optimization | PASS | No new imports or heavy logic added. |
|
|
76
|
+
| Code Quality | PASS | Scope is narrow and branch contains only the required file change. |
|
|
77
|
+
| Vue / Nuxt Standards | NOT RUN | Shared module; not a Vue / Nuxt surface. |
|
|
78
|
+
| SSR Security Standards | PASS | Query parameters are assembled from existing client-side storage path only. |
|
|
79
|
+
| Project Conventions | PASS | Matches existing storage-guard pattern used for affiliate / nickname. |
|
|
80
|
+
|
|
81
|
+
## Conclusion
|
|
82
|
+
|
|
83
|
+
This repo’s shared auth-machine change matches the ticket intent and is internally consistent. Runtime behavior was not executed in `cuora-module` directly, but both client repos now pass the new storage keys into this shared payload path.
|
|
84
|
+
|
|
85
|
+
**Overall Result:** PASS (PARTIAL)
|
package/src/request/request.js
CHANGED
|
@@ -5,8 +5,6 @@ import { getErr998SentryExtra } from '../util/err998SentryExtra.js'
|
|
|
5
5
|
// 暫停 ERR_998 上報:在組裝 Sentry 資料之前就中止,不建立事件;仍照常 reject ERR_998 給呼叫端。恢復時改回 false 即可
|
|
6
6
|
const IS_ERR_998_REPORT_PAUSED = true
|
|
7
7
|
|
|
8
|
-
const CANCELLED_MESSAGE = 'Requests Cancelled'
|
|
9
|
-
|
|
10
8
|
// const pickBy = require('lodash/pickBy')
|
|
11
9
|
const supportVersion2List = [
|
|
12
10
|
// 04-09 Update
|
|
@@ -162,9 +160,6 @@ export default class Request {
|
|
|
162
160
|
this.errorHandler = null
|
|
163
161
|
this.hosts = []
|
|
164
162
|
this.isBlocked = false
|
|
165
|
-
this.activeRequests = new Set() // { source, token }:僅追蹤非 public 且帶 token 的在途請求,供 revokeToken 取消
|
|
166
|
-
this.revokedToken = null
|
|
167
|
-
this.tokenGate = null
|
|
168
163
|
this.clientIp = '' // 由外部 plugin(如 clientIp.client.js)非同步寫入,用於 ERR_998 Sentry 回報
|
|
169
164
|
this.hostTester = null // 由外部 plugin(如 host.client.js)寫入,需提供 lastResults 陣列供 ERR_998 Sentry 回報使用
|
|
170
165
|
this.initialize()
|
|
@@ -242,75 +237,15 @@ export default class Request {
|
|
|
242
237
|
this.errorHandler = handler
|
|
243
238
|
}
|
|
244
239
|
|
|
245
|
-
// 作廢指定 token:取消同 token 的在途請求,並讓之後仍帶此 token 的 send() 直接 reject。
|
|
246
|
-
// 只在 token 仍是目前身分時作用,舊身分遲到的錯誤不得影響新身分;重新登入後 token 改變即自然恢復
|
|
247
|
-
revokeToken(token) {
|
|
248
|
-
if (!token || token !== this.getToken()) return
|
|
249
|
-
this.revokedToken = token
|
|
250
|
-
this.activeRequests.forEach((item) => {
|
|
251
|
-
if (item.token === token) item.source.cancel(CANCELLED_MESSAGE)
|
|
252
|
-
})
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// 回前景時先確認 token 仍有效:promise 結算(成功或失敗)或逾時即放行,之後的 send() 才會送出
|
|
256
|
-
beginTokenGate(promise, timeoutMs = 3000) {
|
|
257
|
-
let timer
|
|
258
|
-
const timeout = new Promise((resolve) => {
|
|
259
|
-
timer = setTimeout(resolve, timeoutMs)
|
|
260
|
-
})
|
|
261
|
-
const gate = Promise.race([Promise.resolve(promise).catch(() => {}), timeout]).then(() => {
|
|
262
|
-
clearTimeout(timer)
|
|
263
|
-
if (this.tokenGate === gate) this.tokenGate = null
|
|
264
|
-
})
|
|
265
|
-
this.tokenGate = gate
|
|
266
|
-
return gate
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// 帶 ERR_800 讓下游既有的 `if (!error.code)` 判斷(如 Sentry 上報)把取消視為預期錯誤
|
|
270
|
-
_cancelledError() {
|
|
271
|
-
return Object.assign(new Error(CANCELLED_MESSAGE), { code: 'ERR_800' })
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
_throwIfRevoked() {
|
|
275
|
-
if (this.revokedToken && this.getToken() === this.revokedToken) {
|
|
276
|
-
throw this._cancelledError()
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
_isCancelled(error) {
|
|
281
|
-
return !!this.axios.isCancel?.(error) || error?.message === CANCELLED_MESSAGE
|
|
282
|
-
}
|
|
283
|
-
|
|
284
240
|
async send(req, customToken) {
|
|
285
|
-
let tracked = null
|
|
286
|
-
let requestToken = null
|
|
287
241
|
try {
|
|
288
242
|
// 非 public 請求缺 token 直接 reject:reject → onError → leaving → 乾淨登出,且不送網路 → 洪水照止
|
|
289
243
|
if (!req.isPublic && !this.getToken()) return Promise.reject({ code: 'ERR_A103' })
|
|
290
244
|
|
|
291
|
-
// 公開請求不帶 token,作廢期間 token 仍留在 storage 也不可誤拒(如 autoLogin 前後的 getConfig)
|
|
292
|
-
if (!req.isPublic) this._throwIfRevoked()
|
|
293
|
-
|
|
294
|
-
// /self 是 gate 自己的探測請求,不可等待 gate,否則死鎖
|
|
295
|
-
if (this.tokenGate && !req.isPublic && req.url.split('?')[0] !== 'self') {
|
|
296
|
-
await this.tokenGate
|
|
297
|
-
this._throwIfRevoked()
|
|
298
|
-
if (!this.getToken()) return Promise.reject({ code: 'ERR_A103' })
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
requestToken = req.isPublic ? null : this.getToken()
|
|
302
|
-
|
|
303
245
|
// axios <0.22 對 cancelToken.promise 註冊的取消 handler 永不退訂(xhr.js 無 unsubscribe),
|
|
304
246
|
// 預設掛長壽命共用 token 會使 handler 隨請求數線性累積(掛機過夜 OOM,TI-15555)。
|
|
305
|
-
//
|
|
306
|
-
|
|
307
|
-
let cancelToken = customToken
|
|
308
|
-
if (!customToken && requestToken && this.axios.CancelToken) {
|
|
309
|
-
const source = this.axios.CancelToken.source()
|
|
310
|
-
tracked = { source, token: requestToken }
|
|
311
|
-
this.activeRequests.add(tracked)
|
|
312
|
-
cancelToken = source.token
|
|
313
|
-
}
|
|
247
|
+
// 故預設不掛 cancelToken,僅呼叫端明確傳入 customToken(自行管理其生命週期)時才附加。
|
|
248
|
+
const cancelToken = customToken
|
|
314
249
|
|
|
315
250
|
const requestConfig = this._createConfig(req, cancelToken)
|
|
316
251
|
const configUrls = ['getConfig', 'get-config']
|
|
@@ -321,19 +256,11 @@ export default class Request {
|
|
|
321
256
|
return data
|
|
322
257
|
}
|
|
323
258
|
} catch (error) {
|
|
324
|
-
if (this._isCancelled(error)) throw this._cancelledError()
|
|
325
|
-
// 不可列舉:避免 Bearer token 隨 JSON.stringify/Sentry 序列化外洩,但 error.requestToken 仍可讀取
|
|
326
|
-
if (requestToken && error && typeof error === 'object' && Object.isExtensible(error)) {
|
|
327
|
-
Object.defineProperty(error, 'requestToken', { value: requestToken, enumerable: false, configurable: true })
|
|
328
|
-
}
|
|
329
259
|
if (error.code === 'ERR_F108') {
|
|
330
260
|
this.isBlocked = true
|
|
331
261
|
this.errorHandler && this.errorHandler(error)
|
|
332
262
|
throw error
|
|
333
263
|
}
|
|
334
|
-
// 舊身分遲到的錯誤不進 errorHandler;目前沒 token(TTL 過期或已 CLEAR)時維持原路由,A204 等彈窗才不會被吞
|
|
335
|
-
const currentToken = this.getToken()
|
|
336
|
-
if (requestToken && currentToken && currentToken !== requestToken) throw error
|
|
337
264
|
if (error.code === 'ERR_998') {
|
|
338
265
|
throw error
|
|
339
266
|
}
|
|
@@ -343,8 +270,6 @@ export default class Request {
|
|
|
343
270
|
}
|
|
344
271
|
throw error
|
|
345
272
|
}
|
|
346
|
-
} finally {
|
|
347
|
-
if (tracked) this.activeRequests.delete(tracked)
|
|
348
273
|
}
|
|
349
274
|
}
|
|
350
275
|
|