@jetthai/cuora 1.1.454-dev.0 → 1.1.455-dev.0

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.
@@ -60,7 +60,7 @@ export { api, machine, Request, Config, util, constant, storage }
60
60
  - **API versioning**: `supportVersion2List` array defines 158 endpoints (`request.js:5-158`), auto-converts V1 camelCase paths to V2 kebab-case
61
61
  - **Maintenance detection**: `ERR_F108` error triggers `isBlocked` flag, blocking subsequent non-config requests (`request.js:254-258`)
62
62
  - **Custom serialization**: Avoids double-encoding for `q` parameter (`request.js:187-195`)
63
- - **Request cancellation**: Batch cancellation via Axios CancelToken (`request.js:269-272`)
63
+ - **Request cancellation**: Opt-in via the `customToken` second argument of `send()`; no CancelToken is attached by default (TI-15555, see 1.2)
64
64
 
65
65
  **Config class** (`config.js`):
66
66
 
package/AGENTS.md CHANGED
@@ -60,7 +60,7 @@ export { api, machine, Request, Config, util, constant, storage }
60
60
  - **API versioning**: `supportVersion2List` array defines 158 endpoints (`request.js:5-158`), auto-converts V1 camelCase paths to V2 kebab-case
61
61
  - **Maintenance detection**: `ERR_F108` error triggers `isBlocked` flag, blocking subsequent non-config requests (`request.js:254-258`)
62
62
  - **Custom serialization**: Avoids double-encoding for `q` parameter (`request.js:187-195`)
63
- - **Request cancellation**: Batch cancellation via Axios CancelToken (`request.js:269-272`)
63
+ - **Request cancellation**: Opt-in via the `customToken` second argument of `send()`; no CancelToken is attached by default (TI-15555, see 1.2)
64
64
 
65
65
  **Config class** (`config.js`):
66
66
 
@@ -122,7 +122,7 @@ export { api, machine, Request, Config, util, constant, storage }
122
122
  - **API 版本控制**:`supportVersion2List` 陣列定義 144 個端點(`request.js:5-158`),自動將 V1 camelCase 路徑轉為 V2 kebab-case
123
123
  - **維護模式偵測**:`ERR_F108` 錯誤觸發 `isBlocked` 旗標,阻擋後續非設定請求(`request.js:254-258`)
124
124
  - **自訂序列化**:針對 `q` 參數避免雙重編碼(`request.js:187-195`)
125
- - **請求取消**:透過 Axios CancelToken 支援批次取消(`request.js:269-272`)
125
+ - **請求取消**:透過 `send()` 第二參數 `customToken` 選擇性啟用;預設不附加 CancelToken(TI-15555,詳見 1.2)
126
126
 
127
127
  **Config 類別**(`config.js`):
128
128
 
@@ -537,8 +537,6 @@ io(`${socketURL}/frontend`, {
537
537
 
538
538
  **廣播輪播機制**:`picking`(5 秒)→ `display`(5 秒)→ `picking`,從 `broadcastList` 中選取 `type === '0'` 的廣播,已顯示的加入 `sentNormalBroadcastList` 不再重複。
539
539
 
540
- **Cocos 原生 App 偵測**:`window.CC_JSB === true` 時跳過所有 agent/channel/cookie 設定(原生 App 不需要瀏覽器追蹤)。
541
-
542
540
  **行動裝置偵測**:`isMobile` 儲存的是裝置類型字串(如 `'mobile'`、`'tablet'`),**非布林值**。
543
541
 
544
542
  **信箱過濾**:若 `customerMessageEnable === false`,從信箱總數中扣除 CUSTOMER 類型訊息數。
package/CHANGELOG.md CHANGED
@@ -2,14 +2,61 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.455-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.455...v1.1.455-dev.0) (2026-08-04)
6
+
7
+ ### [1.1.454-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.453...v1.1.454-dev.0) (2026-07-29)
8
+
9
+
10
+ ### Features
11
+
12
+ * **api:** add GeeMee click-id & front-event fields to sendPixel builder ([d33e488](https://github.com/jetthai/cuora-module/commit/d33e488062f81976cff35ea43ea0f2c366a2a615))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **error:** 讓新錯誤可覆寫舊狀態避免 SET_ERROR 鎖死 ([4113751](https://github.com/jetthai/cuora-module/commit/4113751ee6cb4ced8fe1dc2fda0ce9fbac21ec06))
18
+ * **request:** 非 public 請求缺少 token 時提前返回,不再送出後端 ([065095e](https://github.com/jetthai/cuora-module/commit/065095e31ffe1cb640f9aaf6c76bbd5c6892355c))
19
+ * **request:** 非 public 請求缺少 token 時改為 reject ERR_A103,觸發登出流程 ([e46281f](https://github.com/jetthai/cuora-module/commit/e46281f3ea16679404160366e4532969c3bf02ff))
20
+ * **withdraw:** 修正法幣提款計算錯誤時的狀態轉移 ([a951ba8](https://github.com/jetthai/cuora-module/commit/a951ba803cccd1564a7dbe2645ea7c8d50f7da31))
21
+
22
+ ### [1.1.455](https://github.com/jetthai/cuora-module/compare/v1.1.453...v1.1.455) (2026-08-03)
23
+
24
+ ### Bug Fixes
25
+
26
+ - **request:** send() 預設不再附加共用 CancelToken,杜絕取消 handler 累積(TI-15555) ([fb14330](https://github.com/jetthai/cuora-module/commit/fb1433087668559c8cb7f1f515c59a8caaa26351))
27
+
5
28
  ### [1.1.454-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.451-dev.2...v1.1.454-dev.0) (2026-07-29)
6
29
 
30
+ ### [1.1.454](https://github.com/jetthai/cuora-module/compare/v1.1.453...v1.1.454) (2026-07-28)
31
+
32
+ ### [1.1.453](https://github.com/jetthai/cuora-module/compare/v1.1.452...v1.1.453) (2026-07-28)
33
+
34
+ ### Features
35
+
36
+ - **otp:** 重構 OTP 驗證支援 Phone + Email 雙驗證點 ([a9c8eb3](https://github.com/jetthai/cuora-module/commit/a9c8eb32b221804ea4e934981f0e455c1d5e7b66))
37
+
38
+ ### [1.1.452](https://github.com/jetthai/cuora-module/compare/v1.1.451...v1.1.452) (2026-07-28)
39
+
7
40
  ### [1.1.451-dev.2](https://github.com/jetthai/cuora-module/compare/v1.1.451-dev.1...v1.1.451-dev.2) (2026-07-27)
8
41
 
9
42
  ### [1.1.451-dev.1](https://github.com/jetthai/cuora-module/compare/v1.1.451-dev.0...v1.1.451-dev.1) (2026-07-26)
10
43
 
11
44
  ### [1.1.451-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.451...v1.1.451-dev.0) (2026-07-26)
12
45
 
46
+ ### [1.1.451](https://github.com/jetthai/cuora-module/compare/v1.1.450...v1.1.451) (2026-07-21)
47
+
48
+ ### [1.1.450](https://github.com/jetthai/cuora-module/compare/v1.1.449...v1.1.450) (2026-07-21)
49
+
50
+ ### Bug Fixes
51
+
52
+ - **auth:** setUserInfo 於 uid_site 存在時才呼叫 sentry.setUser ([cc9cc79](https://github.com/jetthai/cuora-module/commit/cc9cc79fd6a9ede0d1bb59279e5454116338e869))
53
+
54
+ ### [1.1.449](https://github.com/jetthai/cuora-module/compare/v1.1.448...v1.1.449) (2026-07-19)
55
+
56
+ ### Bug Fixes
57
+
58
+ - **request:** 非 public 請求缺少 token 時改為 reject ERR_A103,觸發登出流程 ([b086cca](https://github.com/jetthai/cuora-module/commit/b086ccafc4a642ead6ea3800f5215c76f747f336))
59
+
13
60
  ### [1.1.449-dev.1](https://github.com/jetthai/cuora-module/compare/v1.1.449...v1.1.449-dev.1) (2026-07-19)
14
61
 
15
62
 
@@ -37,6 +84,12 @@ All notable changes to this project will be documented in this file. See [standa
37
84
  * **request:** 非 public 請求缺少 token 時提前返回,不再送出後端 ([065095e](https://github.com/jetthai/cuora-module/commit/065095e31ffe1cb640f9aaf6c76bbd5c6892355c))
38
85
  * **request:** 非 public 請求缺少 token 時改為 reject ERR_A103,觸發登出流程 ([e46281f](https://github.com/jetthai/cuora-module/commit/e46281f3ea16679404160366e4532969c3bf02ff))
39
86
 
87
+ ### [1.1.448](https://github.com/jetthai/cuora-module/compare/v1.1.447...v1.1.448) (2026-07-17)
88
+
89
+ ### Bug Fixes
90
+
91
+ - **request:** 非 public 請求缺少 token 時提前返回,不再送出後端 ([48a36cb](https://github.com/jetthai/cuora-module/commit/48a36cbfa4df056e21ea39ef31923352885d2308))
92
+
40
93
  ### [1.1.447-dev.2](https://github.com/jetthai/cuora-module/compare/v1.1.447-dev.1...v1.1.447-dev.2) (2026-07-17)
41
94
 
42
95
 
package/CLAUDE.md CHANGED
@@ -60,7 +60,7 @@ export { api, machine, Request, Config, util, constant, storage }
60
60
  - **API versioning**: `supportVersion2List` array defines 158 endpoints (`request.js:5-158`), auto-converts V1 camelCase paths to V2 kebab-case
61
61
  - **Maintenance detection**: `ERR_F108` error triggers `isBlocked` flag, blocking subsequent non-config requests (`request.js:254-258`)
62
62
  - **Custom serialization**: Avoids double-encoding for `q` parameter (`request.js:187-195`)
63
- - **Request cancellation**: Batch cancellation via Axios CancelToken (`request.js:269-272`)
63
+ - **Request cancellation**: Opt-in via the `customToken` second argument of `send()`; no CancelToken is attached by default (TI-15555, see 1.2)
64
64
 
65
65
  **Config class** (`config.js`):
66
66
 
package/GEMINI.md CHANGED
@@ -60,7 +60,7 @@ export { api, machine, Request, Config, util, constant, storage }
60
60
  - **API versioning**: `supportVersion2List` array defines 158 endpoints (`request.js:5-158`), auto-converts V1 camelCase paths to V2 kebab-case
61
61
  - **Maintenance detection**: `ERR_F108` error triggers `isBlocked` flag, blocking subsequent non-config requests (`request.js:254-258`)
62
62
  - **Custom serialization**: Avoids double-encoding for `q` parameter (`request.js:187-195`)
63
- - **Request cancellation**: Batch cancellation via Axios CancelToken (`request.js:269-272`)
63
+ - **Request cancellation**: Opt-in via the `customToken` second argument of `send()`; no CancelToken is attached by default (TI-15555, see 1.2)
64
64
 
65
65
  **Config class** (`config.js`):
66
66
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.454-dev.0",
3
+ "version": "1.1.455-dev.0",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -2,6 +2,6 @@ import api from './api/index.js'
2
2
  import machine from './machine/index.js'
3
3
  import Request from './request/request.js'
4
4
  import Config from './request/config.js'
5
- import util, { constant, storage } from './util/index.js'
5
+ import util, { constant, storage, paramStore } from './util/index.js'
6
6
 
7
- export { api, machine, Request, Config, util, constant, storage }
7
+ export { api, machine, Request, Config, util, constant, storage, paramStore }
@@ -5,6 +5,7 @@ import user from '../api/user.js'
5
5
  import storage from '../util/storage.js'
6
6
  import common from '../api/common.js'
7
7
  import pickBy from 'lodash/pickBy.js'
8
+ import { readParamFromLocation, writeParam, normalize, AC_KEYS, FC_KEYS } from '../util/paramStore.js'
8
9
 
9
10
  export default function (request) {
10
11
  const { appSecret, clientId, sentry } = request.config
@@ -469,14 +470,27 @@ export default function (request) {
469
470
 
470
471
  const dt = deviceTokenEnable ? await request.config.getDt?.() : undefined
471
472
 
472
- const affiliateCode = storage.get('ac')
473
+ // 宿主若明確帶了 ac(使用者在補資料頁/代理碼彈窗按下確認,含刻意留白)以它為準:
474
+ // 網址層仍留著進站時的 ?ac=,不讓步的話使用者剛清掉的值會被網址撿回來又寫回兩個媒介
475
+ const hasExplicitAc = !!event.data && Object.prototype.hasOwnProperty.call(event.data, 'ac')
476
+ const acRead = readParamFromLocation(AC_KEYS)
477
+ const affiliateCode = hasExplicitAc ? normalize(event.data.ac) : acRead.value
478
+ // 尾綴 undefined 是刻意的:全空時維持原本序列化成 fc=undefined 的行為,不改為 fc=null
479
+ const friendCode = fc || readParamFromLocation(FC_KEYS).value || undefined
480
+
481
+ // 本段結尾以 window.location.href 離站,離站後 SPA 記憶體全丟;導頁前先落地雙寫
482
+ writeParam('ac', affiliateCode, { sentry })
483
+ writeParam('fc', friendCode, { sentry })
484
+
473
485
  const nickname = storage.get('nk')
474
486
  const phone = storage.get('tp_phone')
475
487
  const countryCode = storage.get('tp_countryCode')
476
488
  const email = storage.get('tp_email')
489
+ const birthday = storage.get('tp_birthday')
477
490
  const messages = {
478
491
  url: window.location.href,
479
492
  affiliateCode,
493
+ acSource: hasExplicitAc ? 'event' : acRead.from,
480
494
  nickname,
481
495
  }
482
496
 
@@ -503,9 +517,14 @@ export default function (request) {
503
517
  referralObj.email = email
504
518
  }
505
519
 
520
+ if (![undefined, 'undefined', null, 'null'].includes(birthday)) {
521
+ referralObj.birthday = birthday
522
+ }
523
+
506
524
  storage.remove('tp_phone')
507
525
  storage.remove('tp_countryCode')
508
526
  storage.remove('tp_email')
527
+ // tp_birthday 不在此移除:client 於回站登入完成後以 /self 補交作為備援,由 client 消費後移除
509
528
 
510
529
  const fullURL = request.config.fullURL
511
530
 
@@ -518,7 +537,7 @@ export default function (request) {
518
537
  ...referralObj,
519
538
  dt,
520
539
  platform: 'pwa',
521
- fc,
540
+ fc: friendCode,
522
541
  }).toString()
523
542
  )
524
543
 
@@ -3,9 +3,10 @@ import { assign, createMachine } from 'xstate'
3
3
  import pickBy from 'lodash/pickBy.js'
4
4
  import api from '../api/common.js'
5
5
  import storage from '../util/storage.js'
6
+ import { readParam, writeParam, AC_KEYS, FC_KEYS } from '../util/paramStore.js'
6
7
 
7
8
  export default function (request) {
8
- const { appSecret } = request.config
9
+ const { appSecret, sentry } = request.config
9
10
  return createMachine(
10
11
  {
11
12
  id: 'common',
@@ -276,28 +277,17 @@ export default function (request) {
276
277
  kpix,
277
278
  }
278
279
  }),
279
- setAgent: assign((context, event) => {
280
- if (window.CC_JSB === true) {
281
- // is cocos native app
282
- return
283
- } else {
284
- let urlParams = new URLSearchParams(window.location.search)
285
- const affiliateCode = urlParams.get('ac') || urlParams.get('referralCode') || storage.get('ac') || storage.get('referralCode')
286
- const friendCode = urlParams.get('fc') || urlParams.get('affiliate') || storage.get('fc') || storage.get('affiliate')
280
+ setAgent: assign(() => {
281
+ const urlParams = new URLSearchParams(window.location.search)
282
+ const ac = readParam(urlParams, AC_KEYS)
283
+ const fc = readParam(urlParams, FC_KEYS)
287
284
 
288
- storage.set('ac', affiliateCode, {
289
- path: '/',
290
- maxAge: 60 * 60 * 24 * 7,
291
- })
292
- storage.set('fc', friendCode, {
293
- path: '/',
294
- maxAge: 60 * 60 * 24 * 7,
295
- })
285
+ writeParam('ac', ac.value, { sentry })
286
+ writeParam('fc', fc.value, { sentry })
296
287
 
297
- return {
298
- affiliateCode,
299
- friendCode,
300
- }
288
+ return {
289
+ affiliateCode: ac.value,
290
+ friendCode: fc.value,
301
291
  }
302
292
  }),
303
293
  clearAnnouncements: assign((context, event) => {
@@ -1,6 +1,7 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import auth from '../api/auth.js'
3
3
  import storage from '../util/storage.js'
4
+ import { readParamFromLocation, normalize, AC_KEYS, FC_KEYS } from '../util/paramStore.js'
4
5
 
5
6
  // 註冊強制綁定多型出款:轉發各綁定型別欄位(BANK / CRYPTO / EWALLET),只帶有值的欄位
6
7
  const BIND_FIELDS = [
@@ -191,10 +192,17 @@ export default function (request) {
191
192
  const { signUpData, deviceTokenEnable } = context
192
193
  const dt = deviceTokenEnable ? await request.config.getDt?.() : undefined
193
194
 
194
- const affiliateCode = storage.get('ac') || signUpData?.affiliateCode
195
+ // 宿主明確帶入的 affiliateCode(註冊表單的代理碼欄位)優先於網址/儲存這類環境值;
196
+ // 以 key 是否存在判定而非真假值——使用者刻意清空送出的空字串也是明確決定,
197
+ // 用 `||` 會讓它退回三層解析,把剛清掉的舊代理碼從網址撿回來
198
+ const { affiliateCode: explicitAffiliateCode, ...signUpRest } = signUpData || {}
199
+ const hasExplicitAc = !!signUpData && Object.prototype.hasOwnProperty.call(signUpData, 'affiliateCode')
200
+ const acRead = readParamFromLocation(AC_KEYS)
201
+ const affiliateCode = hasExplicitAc ? normalize(explicitAffiliateCode) : acRead.value
195
202
  const messages = {
196
203
  url: window.location.href,
197
204
  affiliateCode,
205
+ acSource: hasExplicitAc ? 'signUpData' : acRead.from,
198
206
  }
199
207
 
200
208
  // 因 client-pwa-cash PR #805 的問題,暫時註解此 Sentry 上報
@@ -208,11 +216,11 @@ export default function (request) {
208
216
 
209
217
  return await request.send(
210
218
  auth.register({
211
- ...signUpData,
219
+ ...signUpRest,
212
220
  ...referralObj,
213
221
  dt,
214
222
  reCaptchaToken: context.reCaptchaToken,
215
- fc: context.fc,
223
+ fc: context.fc || readParamFromLocation(FC_KEYS).value || undefined,
216
224
  })
217
225
  )
218
226
  },
@@ -251,12 +251,14 @@ export default class Request {
251
251
 
252
252
  async send(req, customToken) {
253
253
  try {
254
- // reject → onError → leaving → 乾淨登出,且一樣不送網路 → 洪水照止
254
+ // 非 public 請求缺 token 直接 reject:reject → onError → leaving → 乾淨登出,且不送網路 → 洪水照止
255
255
  if (!req.isPublic && !this.getToken()) return Promise.reject({ code: 'ERR_A103' })
256
256
 
257
+ // axios <0.22 對 cancelToken.promise 註冊的取消 handler 永不退訂(xhr.js 無 unsubscribe),
258
+ // 預設掛長壽命共用 token 會使 handler 隨請求數線性累積(掛機過夜 OOM,TI-15555)。
259
+ // 故預設不掛 cancelToken,僅呼叫端明確傳入 customToken(自行管理其生命週期)時才附加。
257
260
  const cancelToken = customToken
258
261
 
259
- // ERR_A103 No token provided 改由後端回傳:不再於送出前自行 throw,
260
262
  const requestConfig = this._createConfig(req, cancelToken)
261
263
  const configUrls = ['getConfig', 'get-config']
262
264
  if (this.isBlocked && !configUrls.includes(requestConfig.url)) {
package/src/util/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import storage from './storage.js'
2
+ import paramStore from './paramStore.js'
2
3
  import * as constant from './constant.js'
3
4
  import { max } from './math.js'
4
5
 
5
6
  export default {}
6
- export { constant, storage, max }
7
+ export { constant, storage, paramStore, max }
@@ -0,0 +1,139 @@
1
+ import Cookies from 'universal-cookie'
2
+ import storage from './storage.js'
3
+
4
+ export const PARAM_MAX_AGE = 60 * 60 * 24 * 7
5
+ export const AC_KEYS = ['ac', 'referralCode']
6
+ export const FC_KEYS = ['fc', 'affiliate']
7
+
8
+ const DIRTY_VALUES = ['undefined', 'null', 'NaN']
9
+
10
+ const reportedOnce = new Set()
11
+
12
+ function cookieJar() {
13
+ return typeof document === 'undefined' ? null : new Cookies()
14
+ }
15
+
16
+ export function normalize(value) {
17
+ if (value === undefined || value === null) return null
18
+ const trimmed = String(value).trim()
19
+ if (trimmed === '' || DIRTY_VALUES.includes(trimmed)) return null
20
+ return trimmed
21
+ }
22
+
23
+ // storage.js 的 JSON.parse 未包在 try/catch 內,localStorage 若存有同名裸字串會 throw,
24
+ // 未攔截會沿 xstate entry chain 往上炸掉整條 setUA→setAgent→setPixel→setKPixel→setFbclid
25
+ function readLocal(name) {
26
+ try {
27
+ return normalize(storage.get(name))
28
+ } catch (error) {
29
+ return null
30
+ }
31
+ }
32
+
33
+ function readCookie(name) {
34
+ const jar = cookieJar()
35
+ if (!jar) return null
36
+ try {
37
+ return normalize(jar.get(name, { doNotParse: true }))
38
+ } catch (error) {
39
+ return null
40
+ }
41
+ }
42
+
43
+ export function readParam(urlParams, keys) {
44
+ for (const key of keys) {
45
+ const value = normalize(urlParams?.get?.(key))
46
+ if (value) return { value, from: `url:${key}` }
47
+ }
48
+ for (const key of keys) {
49
+ const value = readLocal(key)
50
+ if (value) return { value, from: `local:${key}` }
51
+ }
52
+ for (const key of keys) {
53
+ const value = readCookie(key)
54
+ if (value) return { value, from: `cookie:${key}` }
55
+ }
56
+ return { value: null, from: 'none' }
57
+ }
58
+
59
+ export function readParamFromLocation(keys) {
60
+ const search = typeof window === 'undefined' ? '' : window.location.search
61
+ return readParam(new URLSearchParams(search), keys)
62
+ }
63
+
64
+ function report(sentry, name, medium, reason) {
65
+ // 去重必須在確定送得出去之後才登錄,否則早於 sentry 注入的那次失敗會把 fingerprint 佔走,
66
+ // 導致之後真正有 sentry 時被自己的去重擋掉、永遠不上報
67
+ if (!sentry?.captureMessage) return
68
+ const fingerprint = `${name}:${medium}:${reason}`
69
+ if (reportedOnce.has(fingerprint)) return
70
+ reportedOnce.add(fingerprint)
71
+ sentry?.captureMessage?.(`[ParamStore] ${medium} persist ${reason}: ${name}`, {
72
+ level: 'warning',
73
+ tags: { feature: 'url-param-fallback', param_key: name, storage_medium: medium, failure_reason: reason },
74
+ })
75
+ }
76
+
77
+ function clearParam(name) {
78
+ const result = { local: 'ok', cookie: 'ok', cleared: true }
79
+ try {
80
+ storage.remove(name)
81
+ } catch (error) {
82
+ result.local = 'throw'
83
+ }
84
+ const jar = cookieJar()
85
+ if (jar) {
86
+ try {
87
+ jar.remove(name, { path: '/' })
88
+ } catch (error) {
89
+ result.cookie = 'throw'
90
+ }
91
+ }
92
+ return result
93
+ }
94
+
95
+ export function writeParam(name, value, options = {}) {
96
+ const { sentry, allowClear = false } = options
97
+ const normalized = normalize(value)
98
+
99
+ if (normalized === null) {
100
+ return allowClear ? clearParam(name) : { local: 'skipped', cookie: 'skipped', skipped: true }
101
+ }
102
+
103
+ const result = { local: 'ok', cookie: 'ok' }
104
+
105
+ try {
106
+ storage.set(name, normalized, { path: '/', maxAge: PARAM_MAX_AGE })
107
+ } catch (error) {
108
+ result.local = 'throw'
109
+ }
110
+ if (result.local === 'ok' && readLocal(name) !== normalized) {
111
+ result.local = 'mismatch'
112
+ }
113
+
114
+ const jar = cookieJar()
115
+ if (!jar) {
116
+ result.cookie = 'unavailable'
117
+ } else {
118
+ try {
119
+ jar.set(name, normalized, {
120
+ path: '/',
121
+ maxAge: PARAM_MAX_AGE,
122
+ sameSite: 'lax',
123
+ secure: typeof window !== 'undefined' && window.location.protocol === 'https:',
124
+ })
125
+ } catch (error) {
126
+ result.cookie = 'throw'
127
+ }
128
+ if (result.cookie === 'ok' && readCookie(name) !== normalized) {
129
+ result.cookie = 'mismatch'
130
+ }
131
+ }
132
+
133
+ if (result.local !== 'ok') report(sentry, name, 'localStorage', result.local)
134
+ if (result.cookie !== 'ok') report(sentry, name, 'cookie', result.cookie)
135
+
136
+ return result
137
+ }
138
+
139
+ export default { PARAM_MAX_AGE, AC_KEYS, FC_KEYS, normalize, readParam, readParamFromLocation, writeParam }
@@ -1,85 +0,0 @@
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)