@jetthai/cuora 1.1.483-dev.0 → 1.1.483-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.
- package/.github/copilot-instructions.md +23 -14
- package/AGENTS.md +22 -13
- package/AI_PROMPT_SOURCE.md +22 -13
- package/CHANGELOG.md +13 -0
- package/CLAUDE.md +22 -13
- package/GEMINI.md +22 -13
- package/package.json +1 -1
- package/src/api/activity.js +2 -2
- package/src/machine/reward_cash.js +2 -2
- package/src/util/constant.js +1 -1
- package/test/auth_otp_v3.test.js +4 -4
|
@@ -148,7 +148,7 @@ State machines **do not directly reference each other**; they communicate indire
|
|
|
148
148
|
| `ERR_F106` | OTP verification failed |
|
|
149
149
|
| `ERR_G106` | Insufficient balance (→ deposit state) |
|
|
150
150
|
| `ERR_G124` / `ERR_G125` | Free game settlement / forfeit |
|
|
151
|
-
| `ERR_800` | Cancelled request (
|
|
151
|
+
| `ERR_800` | Cancelled request (never forwarded to errorHandler, but still rejects to the caller's `onError`) |
|
|
152
152
|
| `ERR_998` | Network error / 404 (reported to Sentry) |
|
|
153
153
|
|
|
154
154
|
When `error.extend` contains `unfinished_` → unfinished game; the gameCode is everything after the first underscore, taken via `error.extend.split(/_(.+)/)[1]`.
|
|
@@ -172,6 +172,13 @@ Token 5min TTL → fetchUserInfo success → extendToken resets TTL → poll aga
|
|
|
172
172
|
- **Injection**: the request interceptor automatically adds `Authorization: Bearer {token}`
|
|
173
173
|
- **TTL**: token 300 seconds, account info 31 days, cookie data 7 days
|
|
174
174
|
|
|
175
|
+
**Token revocation & foreground gate** (`request.js`): `revokeToken(token)` and `beginTokenGate(promise, timeoutMs = 3000)` are public `Request` methods with **no caller inside this package** — the downstream frontends call them on logout-class errors and when the app returns to the foreground; changing their signatures or semantics is a public-interface change.
|
|
176
|
+
|
|
177
|
+
- **Only the current identity can be revoked**: `revokeToken` only takes effect when `token === getToken()`, so a late error from a previous identity cannot revoke a newly logged-in token. Once in effect, it cancels in-flight requests carrying that token (for the scope, see item 11 of 2.9), and any later non-public `send()` still carrying it rejects `ERR_800` immediately without hitting the network; public requests are unaffected (the token stays in storage while revoked, and `getConfig` around autoLogin must not be wrongly rejected). There is no "un-revoke" API — logging in again changes the token, which lifts the revocation naturally.
|
|
178
|
+
- **The token to revoke comes from the error object**: when a token-carrying request fails, `send()` attaches a **non-enumerable** `error.requestToken` (the Bearer token at send time). It is non-enumerable so it doesn't leak through `JSON.stringify` / Sentry serialization — **never make it enumerable, and never copy it into enumerable fields, logs, or Sentry extra**. Cancellation `ERR_800` errors and the missing-token `ERR_A103` don't carry this field.
|
|
179
|
+
- **While a gate is active**: non-public requests first wait for the probe promise to settle (success and failure both release it) or for the timeout; once released, they re-check whether the token has been revoked and whether it still exists (missing → `ERR_A103`).
|
|
180
|
+
- **Hard-coded `'self'` coupling**: `send()` decides which request skips the gate by checking whether the descriptor's raw `url` (query stripped, before V2 conversion) is `'self'`, which corresponds to `getUserInfo` in `api/user.js` (`updateUserInfo`, sharing the same url, skips it too). Changing `getUserInfo`'s url (adding a leading slash, changing the path) requires updating this check in lockstep, otherwise `/self` gets blocked by the gate as well — a probe sent after the gate is created would then wait on its own gate until the timeout.
|
|
181
|
+
|
|
175
182
|
**inline vs login states** (the most central concept in `auth.js`):
|
|
176
183
|
|
|
177
184
|
- `inline`: authenticated but `rank < 0` (the account has not finished ranking/activation); polling continues until rank takes effect
|
|
@@ -191,7 +198,7 @@ Token 5min TTL → fetchUserInfo success → extendToken resets TTL → poll aga
|
|
|
191
198
|
| `LOGIN_TELEGRAM` | Telegram | additionalUserInfo |
|
|
192
199
|
| `LOGIN_3PARTY` | Third-party redirect | **Does not switch state**; uses `window.location.href` directly |
|
|
193
200
|
|
|
194
|
-
**OTP flow**: after a successful login it enters `otpChecking`, and only proceeds to `loginSuccess`
|
|
201
|
+
**OTP / bind-bank flow**: after a successful login it enters `otpChecking`; `OTP_VERIFIED` or `OTP_SKIP` moves it to `bindBankChecking`, and only `BIND_BANK_DONE` or `BIND_BANK_SKIP` proceeds to `loginSuccess` (either gate accepts `LOGOUT` to abort). Whether binding is required is decided by the downstream frontend; the machine only waits — **downstream must send one of these events in `bindBankChecking`, or the session stalls there**. The `tokenAuthenticated` path skips both gates.
|
|
195
202
|
|
|
196
203
|
**Account persistence**: the most recently used login account is stored in localStorage (31-day TTL) for form auto-fill. **Token expiration does not affect the account record.** However, `pruneRememberedAccounts`, which runs after `fetchSiteConfig` succeeds, **compares against `siteConfig.loginMethods` and clears the leftover account for any disabled login method** (`phone` clears the country code along with it) — fetching configuration, an apparently read-only action, carries the side effect of deleting from localStorage. The purpose is to prevent downstream frontends from back-filling a stale value into an input whose type has since changed after the backend disables a login method. When `loginMethods` is missing entirely, nothing is cleared, to avoid wiping everything by mistake.
|
|
197
204
|
|
|
@@ -327,19 +334,20 @@ io(`${socketURL}/frontend`, {
|
|
|
327
334
|
```
|
|
328
335
|
1. A state machine service calls request.send(api.xxx(params))
|
|
329
336
|
2. api.xxx(params) returns a descriptor object
|
|
330
|
-
3.
|
|
331
|
-
4.
|
|
337
|
+
3. Identity pre-checks (non-public only): no token → reject ERR_A103; token revoked via revokeToken → reject ERR_800; gate active and url is not 'self' → wait for the gate, then re-check (see 2.1)
|
|
338
|
+
4. Token-carrying request without customToken → attach a one-time CancelToken source and register it in activeRequests, removed in finally (see item 11 of 2.9)
|
|
332
339
|
5. _createConfig(req):
|
|
333
340
|
a. Strip the query string from the URL
|
|
334
341
|
b. Match against supportVersion2List (supports :param dynamic-path regex matching)
|
|
335
342
|
c. If matched → _convertUrlToKebabCase() (look up the specifyingPath mapping first, otherwise auto-convert)
|
|
336
343
|
d. GET → params goes in the params field; POST → params goes in the data field
|
|
337
344
|
e. pickBy filters out null/undefined values
|
|
338
|
-
6.
|
|
339
|
-
7.
|
|
340
|
-
8.
|
|
341
|
-
9.
|
|
342
|
-
10.
|
|
345
|
+
6. isBlocked check: under maintenance and not a config request → no request is sent, resolves undefined
|
|
346
|
+
7. Request interceptor: injects X-TH1GAMES-VERSION, X-TH1GAMES-PLATFORM, Authorization
|
|
347
|
+
8. Custom paramsSerializer: special encoding for the q parameter (avoids double-encoding)
|
|
348
|
+
9. axios.request(config)
|
|
349
|
+
10. Response interceptor: response.data.error present → reject; Network Error / 404 → ERR_998 + Sentry
|
|
350
|
+
11. Error handling (in order): cancellation → reject ERR_800 (never reaches errorHandler); token-carrying requests get a non-enumerable requestToken attached to the error; ERR_F108 → isBlocked + errorHandler; stale-identity error → thrown directly (see item 14 of 2.9); ERR_998 → thrown directly; everything else → errorHandler (skipped when the descriptor carries silent: true, still thrown); non-cancellation error whose code is already ERR_800 → resolves undefined
|
|
343
351
|
```
|
|
344
352
|
|
|
345
353
|
**V1→V2 conversion**: `supportVersion2List` supports dynamic paths (e.g. `payment/v2/:paymentType/transaction`, where `:param` is replaced by `[^/]+`); special paths are hard-coded in `specifyingPath`, and the rest are auto-converted via `/([a-z])([A-Z])/g`. **When adding an endpoint that needs V2 conversion, it must be added to the list manually.**
|
|
@@ -356,9 +364,10 @@ io(`${socketURL}/frontend`, {
|
|
|
356
364
|
8. **`appSecret` marks public endpoints**: nearly all `isPublic: true` endpoints require an `appSecret` parameter, **but the auth endpoints do not**.
|
|
357
365
|
9. **Unfinished-game infinite retry**: the `unfinishedGame` state in `error.js` returns to itself on `onError`, with **no backoff strategy and no retry cap** (a known issue, see "Known Technical Debt").
|
|
358
366
|
10. **`isMobile` is a string, not a boolean**: in `common.js`, `isMobile = userAgent?.device?.type` returns `'mobile'`/`'tablet'`/`undefined`, so comparisons must be string-based (e.g. `isMobile === 'mobile' ? 'y' : null`).
|
|
359
|
-
11. **
|
|
367
|
+
11. **CancelTokens must be one-time, never shared**: a token-carrying non-public request that passes no `customToken` gets its own **one-time** `CancelToken.source()` (registered in `activeRequests`, removed in `finally`, collected along with the request) so that `revokeToken` can cancel in-flight requests; when `customToken` is passed, it is used instead, the caller manages its lifecycle, and it is not registered (`revokeToken` cannot cancel it). In axios <0.22 the cancel handler is never unsubscribed — a shared long-lived token accumulates one handler per request, causing overnight OOM when left running (TI-15555). **Do not turn the one-time source into a shared token.** The one-time source is only created when the injected `axios` exposes `CancelToken` (axios's default export and `@nuxtjs/axios`'s `$axios` do; instances produced by `axios.create()` don't); without it, `revokeToken` cannot abort in-flight requests and only blocks subsequent `send()` calls.
|
|
360
368
|
12. **`silent: true` only skips errorHandler**: the error is still thrown to the caller's `onError`, and `ERR_F108` is still routed as usual; but every other error code — **including logout-class codes such as `ERR_A104`, and `ERR_G106` insufficient balance** — never reaches the error machine. Use it only for background requests whose session invalidation is already covered by `fetchUserInfo` polling; never add it to user-initiated requests.
|
|
361
|
-
13. **`send()` does not guarantee an object, and `assign()` must never throw**: non-config requests during maintenance (`isBlocked`) and `ERR_800`
|
|
369
|
+
13. **`send()` does not guarantee an object, and `assign()` must never throw**: non-config requests during maintenance (`isBlocked`) and non-cancellation errors that already carry `code: 'ERR_800'` make `send()` **resolve `undefined`** (they never reach `onError`); a 200 response with a non-JSON body resolves a string, so destructuring `{ data }` yields `undefined`. Cancellations (`customToken` cancellation, `revokeToken` revocation), by contrast, reject with `ERR_800` and **do reach `onError`** — they never resolve `undefined`. When an `assign()` throws, XState v4 clears the event queue and the state is not updated — the machine stays in the current invoke state and `after`-based polling stops until an external event (e.g. `REFRESH`) moves it out. **Validate response shapes inside the service and `throw` there (reject → `onError`)**; every assign in `onDone` must handle every value the service can resolve, including deliberate `return null` early exits.
|
|
370
|
+
14. **Late errors from a stale identity never reach errorHandler**: when the token a request was sent with differs from the current token (and a current token exists), the error is only thrown to the caller's `onError` and not forwarded to errorHandler — so a late logout-class error from an old session can't log out a newly logged-in identity. When there is no current token (TTL expired or already cleared), routing is unchanged so that `ERR_A204`-style popups aren't swallowed; the `ERR_F108` check comes before this one and still routes as usual.
|
|
362
371
|
|
|
363
372
|
---
|
|
364
373
|
|
|
@@ -373,12 +382,12 @@ io(`${socketURL}/frontend`, {
|
|
|
373
382
|
| lodash extension | `'lodash/pickBy.js'` and `'lodash/pickBy'` coexist | Consistently **without** the extension |
|
|
374
383
|
| URL leading slash | A few APIs carry a leading slash | Omit it (unless deliberately bypassing `url-join`, in which case comment the reason) |
|
|
375
384
|
| Query parameter placement | A few write them straight into the URL (`register?${qs}`, `mail?include=cl`), bypassing serialization | Always use the `params` field |
|
|
376
|
-
| Initial state naming | `idle`
|
|
385
|
+
| Initial state naming | `idle` / `loading` / `fetching` / `pending` / `checking` / `init` and others used interchangeably | By semantics: `idle` (awaiting action), `loading` (initial load), `fetching` (re-fetch), `submitting` / `submitted` |
|
|
377
386
|
| Magic numbers and strings | Activity type IDs, error codes, TTLs, polling ticks, `'DEPOSIT'`/`'WITHDRAW'`, `receiveStatus`, `connectStatus` are scattered around; `util/constant.js` currently holds **only** `GAME_SEARCH` / `GAME_TYPE_LIST`, two game-category constants | Centralize in `util/constant.js` (`ERROR_CODES` / `TTL` / `INTERVAL` / `TRANSFER_TYPE` / `RECEIVE_STATUS`) |
|
|
378
387
|
| Error handling | Three forms coexist: silent fallback to `idle` (most common, loses error info), transition to `fail`, infinite retry | `onError` with `actions: 'setError'` to preserve the error in context; distinguish recoverable from unrecoverable; retries must have a cap |
|
|
379
388
|
| Parameter naming | e.g. `getFreeGameReward(code)` is semantically unclear | Concrete names (`gameCode`) |
|
|
380
389
|
| Parameter validation | The API layer has no validation at all (e.g. the dynamic path following `checkDt()` is injected straight into the URL) | Validate at the system boundary: path parameters non-undefined and free of path-traversal characters, amounts positive |
|
|
381
|
-
| Deprecated APIs | `getPaymentInfo` in `api/payment.js` carries a "deprecated" comment
|
|
390
|
+
| Deprecated APIs | `getPaymentInfo` in `api/payment.js` only carries a "deprecated" comment | Add `@deprecated` first, then remove once confirmed unreferenced |
|
|
382
391
|
|
|
383
392
|
---
|
|
384
393
|
|
|
@@ -392,7 +401,7 @@ io(`${socketURL}/frontend`, {
|
|
|
392
401
|
- **No automatic token refresh** — the response interceptor in `request.js` does not handle 401, so an expired token simply fails.
|
|
393
402
|
- **No code splitting** — `machine/index.js` eagerly imports every state machine + the APIs + Socket.IO + lodash, so importing `machine` loads everything. Consider supporting individual imports to enable tree-shaking.
|
|
394
403
|
- **Timer management** — countdowns are largely implemented with self-referencing `after: { 1000 }` transitions (e.g. the OTP `countdown` in `withdraw_manual_cash.js`), producing one state transition per second (including a context clone + event dispatch). Consider a callback service + `setInterval`, and **compute elapsed time** rather than decrementing step by step to avoid cumulative drift.
|
|
395
|
-
- **Large state machine files** —
|
|
404
|
+
- **Large state machine files** — several state machines under `src/machine/` exceed 300 lines (`wc -l` is the source of truth for the actual list) and could be split into composable sub-machines.
|
|
396
405
|
- **Unused context fields** — several state machines declare context fields that are never assigned or read.
|
|
397
406
|
- **lodash exists for only two functions** — the whole repo has just 5 imports: `pickBy` (`request/request.js`, `api/auth.js`, `machine/auth.js`, `machine/common.js`) and `isEqual` (`activity/fafafa_activity.js`), yet the entire package is listed as a dependency. Both can be replaced with native implementations to drop the dependency; until then, at least unify the extension convention (see "Style Convergence Targets").
|
|
398
407
|
|
package/AGENTS.md
CHANGED
|
@@ -148,7 +148,7 @@ State machines **do not directly reference each other**; they communicate indire
|
|
|
148
148
|
| `ERR_F106` | OTP verification failed |
|
|
149
149
|
| `ERR_G106` | Insufficient balance (→ deposit state) |
|
|
150
150
|
| `ERR_G124` / `ERR_G125` | Free game settlement / forfeit |
|
|
151
|
-
| `ERR_800` | Cancelled request (
|
|
151
|
+
| `ERR_800` | Cancelled request (never forwarded to errorHandler, but still rejects to the caller's `onError`) |
|
|
152
152
|
| `ERR_998` | Network error / 404 (reported to Sentry) |
|
|
153
153
|
|
|
154
154
|
When `error.extend` contains `unfinished_` → unfinished game; the gameCode is everything after the first underscore, taken via `error.extend.split(/_(.+)/)[1]`.
|
|
@@ -172,6 +172,13 @@ Token 5min TTL → fetchUserInfo success → extendToken resets TTL → poll aga
|
|
|
172
172
|
- **Injection**: the request interceptor automatically adds `Authorization: Bearer {token}`
|
|
173
173
|
- **TTL**: token 300 seconds, account info 31 days, cookie data 7 days
|
|
174
174
|
|
|
175
|
+
**Token revocation & foreground gate** (`request.js`): `revokeToken(token)` and `beginTokenGate(promise, timeoutMs = 3000)` are public `Request` methods with **no caller inside this package** — the downstream frontends call them on logout-class errors and when the app returns to the foreground; changing their signatures or semantics is a public-interface change.
|
|
176
|
+
|
|
177
|
+
- **Only the current identity can be revoked**: `revokeToken` only takes effect when `token === getToken()`, so a late error from a previous identity cannot revoke a newly logged-in token. Once in effect, it cancels in-flight requests carrying that token (for the scope, see item 11 of 2.9), and any later non-public `send()` still carrying it rejects `ERR_800` immediately without hitting the network; public requests are unaffected (the token stays in storage while revoked, and `getConfig` around autoLogin must not be wrongly rejected). There is no "un-revoke" API — logging in again changes the token, which lifts the revocation naturally.
|
|
178
|
+
- **The token to revoke comes from the error object**: when a token-carrying request fails, `send()` attaches a **non-enumerable** `error.requestToken` (the Bearer token at send time). It is non-enumerable so it doesn't leak through `JSON.stringify` / Sentry serialization — **never make it enumerable, and never copy it into enumerable fields, logs, or Sentry extra**. Cancellation `ERR_800` errors and the missing-token `ERR_A103` don't carry this field.
|
|
179
|
+
- **While a gate is active**: non-public requests first wait for the probe promise to settle (success and failure both release it) or for the timeout; once released, they re-check whether the token has been revoked and whether it still exists (missing → `ERR_A103`).
|
|
180
|
+
- **Hard-coded `'self'` coupling**: `send()` decides which request skips the gate by checking whether the descriptor's raw `url` (query stripped, before V2 conversion) is `'self'`, which corresponds to `getUserInfo` in `api/user.js` (`updateUserInfo`, sharing the same url, skips it too). Changing `getUserInfo`'s url (adding a leading slash, changing the path) requires updating this check in lockstep, otherwise `/self` gets blocked by the gate as well — a probe sent after the gate is created would then wait on its own gate until the timeout.
|
|
181
|
+
|
|
175
182
|
**inline vs login states** (the most central concept in `auth.js`):
|
|
176
183
|
|
|
177
184
|
- `inline`: authenticated but `rank < 0` (the account has not finished ranking/activation); polling continues until rank takes effect
|
|
@@ -327,19 +334,20 @@ io(`${socketURL}/frontend`, {
|
|
|
327
334
|
```
|
|
328
335
|
1. A state machine service calls request.send(api.xxx(params))
|
|
329
336
|
2. api.xxx(params) returns a descriptor object
|
|
330
|
-
3.
|
|
331
|
-
4.
|
|
337
|
+
3. Identity pre-checks (non-public only): no token → reject ERR_A103; token revoked via revokeToken → reject ERR_800; gate active and url is not 'self' → wait for the gate, then re-check (see 2.1)
|
|
338
|
+
4. Token-carrying request without customToken → attach a one-time CancelToken source and register it in activeRequests, removed in finally (see item 11 of 2.9)
|
|
332
339
|
5. _createConfig(req):
|
|
333
340
|
a. Strip the query string from the URL
|
|
334
341
|
b. Match against supportVersion2List (supports :param dynamic-path regex matching)
|
|
335
342
|
c. If matched → _convertUrlToKebabCase() (look up the specifyingPath mapping first, otherwise auto-convert)
|
|
336
343
|
d. GET → params goes in the params field; POST → params goes in the data field
|
|
337
344
|
e. pickBy filters out null/undefined values
|
|
338
|
-
6.
|
|
339
|
-
7.
|
|
340
|
-
8.
|
|
341
|
-
9.
|
|
342
|
-
10.
|
|
345
|
+
6. isBlocked check: under maintenance and not a config request → no request is sent, resolves undefined
|
|
346
|
+
7. Request interceptor: injects X-TH1GAMES-VERSION, X-TH1GAMES-PLATFORM, Authorization
|
|
347
|
+
8. Custom paramsSerializer: special encoding for the q parameter (avoids double-encoding)
|
|
348
|
+
9. axios.request(config)
|
|
349
|
+
10. Response interceptor: response.data.error present → reject; Network Error / 404 → ERR_998 + Sentry
|
|
350
|
+
11. Error handling (in order): cancellation → reject ERR_800 (never reaches errorHandler); token-carrying requests get a non-enumerable requestToken attached to the error; ERR_F108 → isBlocked + errorHandler; stale-identity error → thrown directly (see item 14 of 2.9); ERR_998 → thrown directly; everything else → errorHandler (skipped when the descriptor carries silent: true, still thrown); non-cancellation error whose code is already ERR_800 → resolves undefined
|
|
343
351
|
```
|
|
344
352
|
|
|
345
353
|
**V1→V2 conversion**: `supportVersion2List` supports dynamic paths (e.g. `payment/v2/:paymentType/transaction`, where `:param` is replaced by `[^/]+`); special paths are hard-coded in `specifyingPath`, and the rest are auto-converted via `/([a-z])([A-Z])/g`. **When adding an endpoint that needs V2 conversion, it must be added to the list manually.**
|
|
@@ -356,9 +364,10 @@ io(`${socketURL}/frontend`, {
|
|
|
356
364
|
8. **`appSecret` marks public endpoints**: nearly all `isPublic: true` endpoints require an `appSecret` parameter, **but the auth endpoints do not**.
|
|
357
365
|
9. **Unfinished-game infinite retry**: the `unfinishedGame` state in `error.js` returns to itself on `onError`, with **no backoff strategy and no retry cap** (a known issue, see "Known Technical Debt").
|
|
358
366
|
10. **`isMobile` is a string, not a boolean**: in `common.js`, `isMobile = userAgent?.device?.type` returns `'mobile'`/`'tablet'`/`undefined`, so comparisons must be string-based (e.g. `isMobile === 'mobile' ? 'y' : null`).
|
|
359
|
-
11. **
|
|
367
|
+
11. **CancelTokens must be one-time, never shared**: a token-carrying non-public request that passes no `customToken` gets its own **one-time** `CancelToken.source()` (registered in `activeRequests`, removed in `finally`, collected along with the request) so that `revokeToken` can cancel in-flight requests; when `customToken` is passed, it is used instead, the caller manages its lifecycle, and it is not registered (`revokeToken` cannot cancel it). In axios <0.22 the cancel handler is never unsubscribed — a shared long-lived token accumulates one handler per request, causing overnight OOM when left running (TI-15555). **Do not turn the one-time source into a shared token.** The one-time source is only created when the injected `axios` exposes `CancelToken` (axios's default export and `@nuxtjs/axios`'s `$axios` do; instances produced by `axios.create()` don't); without it, `revokeToken` cannot abort in-flight requests and only blocks subsequent `send()` calls.
|
|
360
368
|
12. **`silent: true` only skips errorHandler**: the error is still thrown to the caller's `onError`, and `ERR_F108` is still routed as usual; but every other error code — **including logout-class codes such as `ERR_A104`, and `ERR_G106` insufficient balance** — never reaches the error machine. Use it only for background requests whose session invalidation is already covered by `fetchUserInfo` polling; never add it to user-initiated requests.
|
|
361
|
-
13. **`send()` does not guarantee an object, and `assign()` must never throw**: non-config requests during maintenance (`isBlocked`) and `ERR_800`
|
|
369
|
+
13. **`send()` does not guarantee an object, and `assign()` must never throw**: non-config requests during maintenance (`isBlocked`) and non-cancellation errors that already carry `code: 'ERR_800'` make `send()` **resolve `undefined`** (they never reach `onError`); a 200 response with a non-JSON body resolves a string, so destructuring `{ data }` yields `undefined`. Cancellations (`customToken` cancellation, `revokeToken` revocation), by contrast, reject with `ERR_800` and **do reach `onError`** — they never resolve `undefined`. When an `assign()` throws, XState v4 clears the event queue and the state is not updated — the machine stays in the current invoke state and `after`-based polling stops until an external event (e.g. `REFRESH`) moves it out. **Validate response shapes inside the service and `throw` there (reject → `onError`)**; every assign in `onDone` must handle every value the service can resolve, including deliberate `return null` early exits.
|
|
370
|
+
14. **Late errors from a stale identity never reach errorHandler**: when the token a request was sent with differs from the current token (and a current token exists), the error is only thrown to the caller's `onError` and not forwarded to errorHandler — so a late logout-class error from an old session can't log out a newly logged-in identity. When there is no current token (TTL expired or already cleared), routing is unchanged so that `ERR_A204`-style popups aren't swallowed; the `ERR_F108` check comes before this one and still routes as usual.
|
|
362
371
|
|
|
363
372
|
---
|
|
364
373
|
|
|
@@ -373,12 +382,12 @@ io(`${socketURL}/frontend`, {
|
|
|
373
382
|
| lodash extension | `'lodash/pickBy.js'` and `'lodash/pickBy'` coexist | Consistently **without** the extension |
|
|
374
383
|
| URL leading slash | A few APIs carry a leading slash | Omit it (unless deliberately bypassing `url-join`, in which case comment the reason) |
|
|
375
384
|
| Query parameter placement | A few write them straight into the URL (`register?${qs}`, `mail?include=cl`), bypassing serialization | Always use the `params` field |
|
|
376
|
-
| Initial state naming | `idle`
|
|
385
|
+
| Initial state naming | `idle` / `loading` / `fetching` / `pending` / `checking` / `init` and others used interchangeably | By semantics: `idle` (awaiting action), `loading` (initial load), `fetching` (re-fetch), `submitting` / `submitted` |
|
|
377
386
|
| Magic numbers and strings | Activity type IDs, error codes, TTLs, polling ticks, `'DEPOSIT'`/`'WITHDRAW'`, `receiveStatus`, `connectStatus` are scattered around; `util/constant.js` currently holds **only** `GAME_SEARCH` / `GAME_TYPE_LIST`, two game-category constants | Centralize in `util/constant.js` (`ERROR_CODES` / `TTL` / `INTERVAL` / `TRANSFER_TYPE` / `RECEIVE_STATUS`) |
|
|
378
387
|
| Error handling | Three forms coexist: silent fallback to `idle` (most common, loses error info), transition to `fail`, infinite retry | `onError` with `actions: 'setError'` to preserve the error in context; distinguish recoverable from unrecoverable; retries must have a cap |
|
|
379
388
|
| Parameter naming | e.g. `getFreeGameReward(code)` is semantically unclear | Concrete names (`gameCode`) |
|
|
380
389
|
| Parameter validation | The API layer has no validation at all (e.g. the dynamic path following `checkDt()` is injected straight into the URL) | Validate at the system boundary: path parameters non-undefined and free of path-traversal characters, amounts positive |
|
|
381
|
-
| Deprecated APIs | `getPaymentInfo` in `api/payment.js` carries a "deprecated" comment
|
|
390
|
+
| Deprecated APIs | `getPaymentInfo` in `api/payment.js` only carries a "deprecated" comment | Add `@deprecated` first, then remove once confirmed unreferenced |
|
|
382
391
|
|
|
383
392
|
---
|
|
384
393
|
|
|
@@ -392,7 +401,7 @@ io(`${socketURL}/frontend`, {
|
|
|
392
401
|
- **No automatic token refresh** — the response interceptor in `request.js` does not handle 401, so an expired token simply fails.
|
|
393
402
|
- **No code splitting** — `machine/index.js` eagerly imports every state machine + the APIs + Socket.IO + lodash, so importing `machine` loads everything. Consider supporting individual imports to enable tree-shaking.
|
|
394
403
|
- **Timer management** — countdowns are largely implemented with self-referencing `after: { 1000 }` transitions (e.g. the OTP `countdown` in `withdraw_manual_cash.js`), producing one state transition per second (including a context clone + event dispatch). Consider a callback service + `setInterval`, and **compute elapsed time** rather than decrementing step by step to avoid cumulative drift.
|
|
395
|
-
- **Large state machine files** —
|
|
404
|
+
- **Large state machine files** — several state machines under `src/machine/` exceed 300 lines (`wc -l` is the source of truth for the actual list) and could be split into composable sub-machines.
|
|
396
405
|
- **Unused context fields** — several state machines declare context fields that are never assigned or read.
|
|
397
406
|
- **lodash exists for only two functions** — the whole repo has just 5 imports: `pickBy` (`request/request.js`, `api/auth.js`, `machine/auth.js`, `machine/common.js`) and `isEqual` (`activity/fafafa_activity.js`), yet the entire package is listed as a dependency. Both can be replaced with native implementations to drop the dependency; until then, at least unify the extension convention (see "Style Convergence Targets").
|
|
398
407
|
|
package/AI_PROMPT_SOURCE.md
CHANGED
|
@@ -146,7 +146,7 @@ export default function (request) {
|
|
|
146
146
|
| `ERR_F106` | OTP 驗證失敗 |
|
|
147
147
|
| `ERR_G106` | 餘額不足(→ deposit 狀態) |
|
|
148
148
|
| `ERR_G124` / `ERR_G125` | 免費遊戲結算 / 放棄 |
|
|
149
|
-
| `ERR_800` |
|
|
149
|
+
| `ERR_800` | 已取消請求(不進 errorHandler,但會 reject 給呼叫端 `onError`) |
|
|
150
150
|
| `ERR_998` | 網路錯誤 / 404(回報 Sentry) |
|
|
151
151
|
|
|
152
152
|
`error.extend` 含 `unfinished_` → 未完成遊戲,gameCode 以 `error.extend.split(/_(.+)/)[1]` 取第一個底線後的全部內容。
|
|
@@ -170,6 +170,13 @@ Token 5min TTL → fetchUserInfo 成功 → extendToken 重設 TTL → 再次輪
|
|
|
170
170
|
- **注入方式**:請求攔截器自動添加 `Authorization: Bearer {token}`
|
|
171
171
|
- **TTL**:Token 300 秒、帳號資訊 31 天、Cookie 資料 7 天
|
|
172
172
|
|
|
173
|
+
**Token 作廢與回前景閘門**(`request.js`):`revokeToken(token)` 與 `beginTokenGate(promise, timeoutMs = 3000)` 是 `Request` 的公開方法,**本套件內沒有呼叫端**,由下游前端在收到登出類錯誤、App 回前景時呼叫;改簽名或語意屬對外介面變動。
|
|
174
|
+
|
|
175
|
+
- **只作廢目前身分**:`revokeToken` 只在 `token === getToken()` 時生效,舊身分遲到的錯誤作廢不了新登入的 Token。生效後取消同 Token 的在途請求(範圍見 2.9 第 11 點),之後仍帶此 Token 的非 public `send()` 不發網路、直接 reject `ERR_800`;public 請求不受影響(作廢期間 Token 仍留在 storage,autoLogin 前後的 `getConfig` 不可被誤拒)。沒有「解除作廢」的 API——重新登入換了 Token 即自然恢復。
|
|
176
|
+
- **作廢用的 Token 從錯誤物件取**:帶 Token 的請求失敗時,`send()` 會在錯誤上掛**不可列舉**的 `error.requestToken`(送出當下的 Bearer Token)。不可列舉是為了不隨 `JSON.stringify`/Sentry 序列化外洩——**不要改成可列舉,也不要複製到可列舉欄位、log 或 Sentry extra**。取消類 `ERR_800` 與缺 Token 的 `ERR_A103` 不帶此欄位。
|
|
177
|
+
- **閘門期間**:非 public 請求先等探測 promise 結算(成功、失敗都放行)或逾時,放行後再檢查一次是否已作廢、Token 是否還在(不在 → `ERR_A103`)。
|
|
178
|
+
- **`'self'` 硬編碼耦合**:`send()` 以描述物件原始 `url`(去掉 query、V2 轉換前)是否為 `'self'` 決定不等閘門,對應 `api/user.js` 的 `getUserInfo`(同 url 的 `updateUserInfo` 也一併不等)。改 `getUserInfo` 的 url(加前導斜線、換路徑)必須同步改這個判斷,否則 `/self` 也會被閘門擋住——探測請求若在閘門建立後才送出,會等自己的閘門直到逾時。
|
|
179
|
+
|
|
173
180
|
**inline vs login 狀態**(`auth.js` 最核心的概念):
|
|
174
181
|
|
|
175
182
|
- `inline`:已認證但 `rank < 0`(帳號尚未完成排名/開通),持續輪詢等待 rank 生效
|
|
@@ -325,19 +332,20 @@ io(`${socketURL}/frontend`, {
|
|
|
325
332
|
```
|
|
326
333
|
1. 狀態機 service 呼叫 request.send(api.xxx(params))
|
|
327
334
|
2. api.xxx(params) 回傳描述物件
|
|
328
|
-
3.
|
|
329
|
-
4.
|
|
335
|
+
3. 身分前置檢查(僅非 public):無 Token → reject ERR_A103;Token 已被 revokeToken 作廢 → reject ERR_800;閘門期間且 url 不是 'self' → 先等閘門再複查(見 2.1)
|
|
336
|
+
4. 帶 Token 且未傳 customToken → 掛一次性 CancelToken source 並登記 activeRequests,finally 移除(見 2.9 第 11 點)
|
|
330
337
|
5. _createConfig(req):
|
|
331
338
|
a. URL 去除 query string
|
|
332
339
|
b. 比對 supportVersion2List(支援 :param 動態路徑正則匹配)
|
|
333
340
|
c. 若匹配 → _convertUrlToKebabCase()(先查 specifyingPath 映射,否則自動轉換)
|
|
334
341
|
d. GET → params 放 params 欄位;POST → params 放 data 欄位
|
|
335
342
|
e. pickBy 過濾 null/undefined 值
|
|
336
|
-
6.
|
|
337
|
-
7.
|
|
338
|
-
8.
|
|
339
|
-
9.
|
|
340
|
-
10.
|
|
343
|
+
6. isBlocked 檢查:維護中且非 config 請求 → 不發請求,resolve undefined
|
|
344
|
+
7. 請求攔截器:注入 X-TH1GAMES-VERSION、X-TH1GAMES-PLATFORM、Authorization
|
|
345
|
+
8. 自訂 paramsSerializer:q 參數特殊編碼(避免雙重編碼)
|
|
346
|
+
9. axios.request(config)
|
|
347
|
+
10. 回應攔截器:response.data.error 存在 → reject;Network Error / 404 → ERR_998 + Sentry
|
|
348
|
+
11. 錯誤處理(依序):取消類 → reject ERR_800(不進 errorHandler);帶 Token 的請求在錯誤上掛不可列舉的 requestToken;ERR_F108 → isBlocked + errorHandler;舊身分的錯誤 → 直接 throw(見 2.9 第 14 點);ERR_998 → 直接 throw;其餘 → errorHandler(描述物件帶 silent: true 則略過,仍 throw);非取消但 code 已是 ERR_800 → resolve undefined
|
|
341
349
|
```
|
|
342
350
|
|
|
343
351
|
**V1→V2 轉換**:`supportVersion2List` 支援動態路徑(如 `payment/v2/:paymentType/transaction`,`:param` 替換為 `[^/]+`);特殊路徑由 `specifyingPath` 硬編碼映射,其餘用 `/([a-z])([A-Z])/g` 自動轉換。**新增需要 V2 轉換的端點時必須手動加入清單。**
|
|
@@ -354,9 +362,10 @@ io(`${socketURL}/frontend`, {
|
|
|
354
362
|
8. **`appSecret` 作為公開端點識別**:幾乎所有 `isPublic: true` 端點都需要 `appSecret` 參數,**但認證端點不需要**。
|
|
355
363
|
9. **unfinished game 無限重試**:`error.js` 的 `unfinishedGame` 狀態在 `onError` 時回到自身,**無退避策略也無重試上限**(已知問題,見「已知技術債」)。
|
|
356
364
|
10. **`isMobile` 是字串非布林值**:`common.js` 中 `isMobile = userAgent?.device?.type`,回傳 `'mobile'`/`'tablet'`/`undefined`,判斷時需比較字串(如 `isMobile === 'mobile' ? 'y' : null`)。
|
|
357
|
-
11.
|
|
365
|
+
11. **CancelToken 只能一次性、不可共用**:帶 Token 的非 public 請求在未傳 `customToken` 時,會各自建立**一次性** `CancelToken.source()`(登記在 `activeRequests`、`finally` 移除,隨請求回收),讓 `revokeToken` 能取消在途請求;傳了 `customToken` 則改用它、由呼叫端自行管理生命週期,也不登記(`revokeToken` 取消不到)。axios <0.22 的取消 handler 永不退訂——共用長壽命 token 會隨請求數累積 handler,導致掛機過夜 OOM(TI-15555)。**不要把一次性 source 改成共用 token。**一次性 source 只在注入的 `axios` 帶有 `CancelToken` 時才建立(axios 預設匯出與 `@nuxtjs/axios` 的 `$axios` 有,`axios.create()` 產生的實例沒有);沒有時 `revokeToken` 無法中止在途請求,只擋得住之後的 `send()`。
|
|
358
366
|
12. **`silent: true` 只略過 errorHandler**:錯誤仍會 throw 給呼叫端的 `onError`,`ERR_F108` 也照常路由;但其餘錯誤碼——**包含 `ERR_A104` 等登出類、`ERR_G106` 餘額不足**——都不會進 error machine。只用於背景呼叫、且 session 失效另有 `fetchUserInfo` 輪詢兜底的請求;使用者主動觸發的請求不可加。
|
|
359
|
-
13. **`send()` 不保證回傳物件,`assign()` 內不可拋錯**:維護中(`isBlocked`)的非 config
|
|
367
|
+
13. **`send()` 不保證回傳物件,`assign()` 內不可拋錯**:維護中(`isBlocked`)的非 config 請求、以及本身已帶 `code: 'ERR_800'` 的非取消錯誤會讓 `send()` **resolve `undefined`**(不進 `onError`);200 但 body 非 JSON 時 resolve 字串,解構 `{ data }` 得到 `undefined`。取消類(`customToken` 取消、`revokeToken` 作廢)則是 reject `ERR_800`,**會進 `onError`**,不會 resolve `undefined`。XState v4 在 `assign()` 內拋錯會清空事件佇列且狀態不更新——machine 停在當前 invoke 狀態、`after` 輪詢中止,直到外部事件(如 `REFRESH`)才離開。**回應格式驗證放 service 內 `throw`(reject → `onError`)**;`onDone` 的每個 assign 都必須承受 service 所有可能的 resolve 值,含刻意 `return null` 的早退路徑。
|
|
368
|
+
14. **舊身分遲到的錯誤不進 errorHandler**:請求送出時的 Token 與目前 Token 不同(且目前仍有 Token)時,錯誤只 throw 給呼叫端的 `onError`、不轉 errorHandler——避免舊 session 遲到的登出類錯誤把新登入的身分登出。目前沒有 Token(TTL 過期或已清除)時照原路由,`ERR_A204` 等彈窗才不會被吞;`ERR_F108` 的判斷在此之前,照常路由。
|
|
360
369
|
|
|
361
370
|
---
|
|
362
371
|
|
|
@@ -371,12 +380,12 @@ io(`${socketURL}/frontend`, {
|
|
|
371
380
|
| lodash 副檔名 | `'lodash/pickBy.js'` 與 `'lodash/pickBy'` 並存 | 統一**不帶**副檔名 |
|
|
372
381
|
| URL 前導斜線 | 少數 API 帶前導斜線 | 不加(除非刻意繞過 `url-join`,須註解原因) |
|
|
373
382
|
| 查詢參數位置 | 少數直接寫入 URL(`register?${qs}`、`mail?include=cl`),繞過序列化 | 一律用 `params` 欄位 |
|
|
374
|
-
| 初始狀態命名 | `idle`
|
|
383
|
+
| 初始狀態命名 | `idle` / `loading` / `fetching` / `pending` / `checking` / `init` 等混用 | 依語意:`idle`(等待操作)、`loading`(初始載入)、`fetching`(重新取得)、`submitting` / `submitted` |
|
|
375
384
|
| 魔法數字與字串 | 活動類型 ID、錯誤碼、TTL、輪詢 tick、`'DEPOSIT'`/`'WITHDRAW'`、`receiveStatus`、`connectStatus` 散佈各處;`util/constant.js` 目前**只有** `GAME_SEARCH` / `GAME_TYPE_LIST` 兩個遊戲分類常數 | 集中至 `util/constant.js`(`ERROR_CODES` / `TTL` / `INTERVAL` / `TRANSFER_TYPE` / `RECEIVE_STATUS`) |
|
|
376
385
|
| 錯誤處理 | 三種並存:靜默轉 `idle`(多數,錯誤資訊遺失)、轉 `fail`、無限重試 | `onError` 搭配 `actions: 'setError'` 保存錯誤至 context;區分可恢復 / 不可恢復;重試須設上限 |
|
|
377
386
|
| 參數命名 | 如 `getFreeGameReward(code)` 語意不明 | 具體命名(`gameCode`) |
|
|
378
387
|
| 參數驗證 | API 層無任何驗證(如 `checkDt()` 之後的動態路徑直接注入 URL) | 在系統邊界驗證:路徑參數非 undefined 且無路徑遍歷字元、金額為正數 |
|
|
379
|
-
| 已棄用 API | `api/payment.js` 的 `getPaymentInfo`
|
|
388
|
+
| 已棄用 API | `api/payment.js` 的 `getPaymentInfo` 只標了「棄用」註解 | 先補 `@deprecated`,確認無引用後再移除 |
|
|
380
389
|
|
|
381
390
|
---
|
|
382
391
|
|
|
@@ -390,7 +399,7 @@ io(`${socketURL}/frontend`, {
|
|
|
390
399
|
- **無 Token 自動刷新** — `request.js` 回應攔截器不處理 401,Token 過期即失敗。
|
|
391
400
|
- **無程式碼分割** — `machine/index.js` 即時匯入所有狀態機 + API + Socket.IO + lodash,匯入 `machine` 等於載入全部。建議支援個別匯入以啟用 tree-shaking。
|
|
392
401
|
- **計時器管理** — 大量以 `after: { 1000 }` 自我引用轉換做倒數(如 `withdraw_manual_cash.js` 的 OTP `countdown`),每秒一次狀態轉換(含 context clone + event dispatch)。建議改 callback service + `setInterval`,並**計算經過時間**而非逐次遞減以避免累積誤差。
|
|
393
|
-
- **大型狀態機檔案** — `
|
|
402
|
+
- **大型狀態機檔案** — `src/machine/` 下多台狀態機超過 300 行(實際清單以 `wc -l` 為準),可拆為可組合的子狀態機。
|
|
394
403
|
- **未使用的 context 欄位** — 多個狀態機宣告了從未賦值或讀取的 context 欄位。
|
|
395
404
|
- **lodash 只為兩個函式而存在** — 全 repo 只有 5 處 import:`pickBy`(`request/request.js`、`api/auth.js`、`machine/auth.js`、`machine/common.js`)與 `isEqual`(`activity/fafafa_activity.js`),卻整包列為 dependency。兩者都可用原生實作替代以移除依賴;在那之前至少要先統一副檔名寫法(見「風格收斂目標」)。
|
|
396
405
|
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
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.483-dev.2](https://github.com/jetthai/cuora-module/compare/v1.1.483-dev.1...v1.1.483-dev.2) (2026-11-13)
|
|
6
|
+
|
|
7
|
+
### [1.1.483](https://github.com/jetthai/cuora-module/compare/v1.1.482...v1.1.483) (2026-11-09)
|
|
8
|
+
|
|
9
|
+
### [1.1.482](https://github.com/jetthai/cuora-module/compare/v1.1.481-dev.1...v1.1.482) (2026-11-02)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **activity:** getRewardList 參數 orderColum 修正為 orderColumn ([4bcecf8](https://github.com/jetthai/cuora-module/commit/4bcecf843f36c32fc57d909619c437c709131d88))
|
|
15
|
+
|
|
16
|
+
### [1.1.483-dev.1](https://github.com/jetthai/cuora-module/compare/v1.1.483-dev.0...v1.1.483-dev.1) (2026-11-12)
|
|
17
|
+
|
|
5
18
|
### [1.1.483-dev.0](https://github.com/jetthai/cuora-module/compare/v1.1.481-dev.1...v1.1.483-dev.0) (2026-11-11)
|
|
6
19
|
|
|
7
20
|
|
package/CLAUDE.md
CHANGED
|
@@ -148,7 +148,7 @@ State machines **do not directly reference each other**; they communicate indire
|
|
|
148
148
|
| `ERR_F106` | OTP verification failed |
|
|
149
149
|
| `ERR_G106` | Insufficient balance (→ deposit state) |
|
|
150
150
|
| `ERR_G124` / `ERR_G125` | Free game settlement / forfeit |
|
|
151
|
-
| `ERR_800` | Cancelled request (
|
|
151
|
+
| `ERR_800` | Cancelled request (never forwarded to errorHandler, but still rejects to the caller's `onError`) |
|
|
152
152
|
| `ERR_998` | Network error / 404 (reported to Sentry) |
|
|
153
153
|
|
|
154
154
|
When `error.extend` contains `unfinished_` → unfinished game; the gameCode is everything after the first underscore, taken via `error.extend.split(/_(.+)/)[1]`.
|
|
@@ -172,6 +172,13 @@ Token 5min TTL → fetchUserInfo success → extendToken resets TTL → poll aga
|
|
|
172
172
|
- **Injection**: the request interceptor automatically adds `Authorization: Bearer {token}`
|
|
173
173
|
- **TTL**: token 300 seconds, account info 31 days, cookie data 7 days
|
|
174
174
|
|
|
175
|
+
**Token revocation & foreground gate** (`request.js`): `revokeToken(token)` and `beginTokenGate(promise, timeoutMs = 3000)` are public `Request` methods with **no caller inside this package** — the downstream frontends call them on logout-class errors and when the app returns to the foreground; changing their signatures or semantics is a public-interface change.
|
|
176
|
+
|
|
177
|
+
- **Only the current identity can be revoked**: `revokeToken` only takes effect when `token === getToken()`, so a late error from a previous identity cannot revoke a newly logged-in token. Once in effect, it cancels in-flight requests carrying that token (for the scope, see item 11 of 2.9), and any later non-public `send()` still carrying it rejects `ERR_800` immediately without hitting the network; public requests are unaffected (the token stays in storage while revoked, and `getConfig` around autoLogin must not be wrongly rejected). There is no "un-revoke" API — logging in again changes the token, which lifts the revocation naturally.
|
|
178
|
+
- **The token to revoke comes from the error object**: when a token-carrying request fails, `send()` attaches a **non-enumerable** `error.requestToken` (the Bearer token at send time). It is non-enumerable so it doesn't leak through `JSON.stringify` / Sentry serialization — **never make it enumerable, and never copy it into enumerable fields, logs, or Sentry extra**. Cancellation `ERR_800` errors and the missing-token `ERR_A103` don't carry this field.
|
|
179
|
+
- **While a gate is active**: non-public requests first wait for the probe promise to settle (success and failure both release it) or for the timeout; once released, they re-check whether the token has been revoked and whether it still exists (missing → `ERR_A103`).
|
|
180
|
+
- **Hard-coded `'self'` coupling**: `send()` decides which request skips the gate by checking whether the descriptor's raw `url` (query stripped, before V2 conversion) is `'self'`, which corresponds to `getUserInfo` in `api/user.js` (`updateUserInfo`, sharing the same url, skips it too). Changing `getUserInfo`'s url (adding a leading slash, changing the path) requires updating this check in lockstep, otherwise `/self` gets blocked by the gate as well — a probe sent after the gate is created would then wait on its own gate until the timeout.
|
|
181
|
+
|
|
175
182
|
**inline vs login states** (the most central concept in `auth.js`):
|
|
176
183
|
|
|
177
184
|
- `inline`: authenticated but `rank < 0` (the account has not finished ranking/activation); polling continues until rank takes effect
|
|
@@ -327,19 +334,20 @@ io(`${socketURL}/frontend`, {
|
|
|
327
334
|
```
|
|
328
335
|
1. A state machine service calls request.send(api.xxx(params))
|
|
329
336
|
2. api.xxx(params) returns a descriptor object
|
|
330
|
-
3.
|
|
331
|
-
4.
|
|
337
|
+
3. Identity pre-checks (non-public only): no token → reject ERR_A103; token revoked via revokeToken → reject ERR_800; gate active and url is not 'self' → wait for the gate, then re-check (see 2.1)
|
|
338
|
+
4. Token-carrying request without customToken → attach a one-time CancelToken source and register it in activeRequests, removed in finally (see item 11 of 2.9)
|
|
332
339
|
5. _createConfig(req):
|
|
333
340
|
a. Strip the query string from the URL
|
|
334
341
|
b. Match against supportVersion2List (supports :param dynamic-path regex matching)
|
|
335
342
|
c. If matched → _convertUrlToKebabCase() (look up the specifyingPath mapping first, otherwise auto-convert)
|
|
336
343
|
d. GET → params goes in the params field; POST → params goes in the data field
|
|
337
344
|
e. pickBy filters out null/undefined values
|
|
338
|
-
6.
|
|
339
|
-
7.
|
|
340
|
-
8.
|
|
341
|
-
9.
|
|
342
|
-
10.
|
|
345
|
+
6. isBlocked check: under maintenance and not a config request → no request is sent, resolves undefined
|
|
346
|
+
7. Request interceptor: injects X-TH1GAMES-VERSION, X-TH1GAMES-PLATFORM, Authorization
|
|
347
|
+
8. Custom paramsSerializer: special encoding for the q parameter (avoids double-encoding)
|
|
348
|
+
9. axios.request(config)
|
|
349
|
+
10. Response interceptor: response.data.error present → reject; Network Error / 404 → ERR_998 + Sentry
|
|
350
|
+
11. Error handling (in order): cancellation → reject ERR_800 (never reaches errorHandler); token-carrying requests get a non-enumerable requestToken attached to the error; ERR_F108 → isBlocked + errorHandler; stale-identity error → thrown directly (see item 14 of 2.9); ERR_998 → thrown directly; everything else → errorHandler (skipped when the descriptor carries silent: true, still thrown); non-cancellation error whose code is already ERR_800 → resolves undefined
|
|
343
351
|
```
|
|
344
352
|
|
|
345
353
|
**V1→V2 conversion**: `supportVersion2List` supports dynamic paths (e.g. `payment/v2/:paymentType/transaction`, where `:param` is replaced by `[^/]+`); special paths are hard-coded in `specifyingPath`, and the rest are auto-converted via `/([a-z])([A-Z])/g`. **When adding an endpoint that needs V2 conversion, it must be added to the list manually.**
|
|
@@ -356,9 +364,10 @@ io(`${socketURL}/frontend`, {
|
|
|
356
364
|
8. **`appSecret` marks public endpoints**: nearly all `isPublic: true` endpoints require an `appSecret` parameter, **but the auth endpoints do not**.
|
|
357
365
|
9. **Unfinished-game infinite retry**: the `unfinishedGame` state in `error.js` returns to itself on `onError`, with **no backoff strategy and no retry cap** (a known issue, see "Known Technical Debt").
|
|
358
366
|
10. **`isMobile` is a string, not a boolean**: in `common.js`, `isMobile = userAgent?.device?.type` returns `'mobile'`/`'tablet'`/`undefined`, so comparisons must be string-based (e.g. `isMobile === 'mobile' ? 'y' : null`).
|
|
359
|
-
11. **
|
|
367
|
+
11. **CancelTokens must be one-time, never shared**: a token-carrying non-public request that passes no `customToken` gets its own **one-time** `CancelToken.source()` (registered in `activeRequests`, removed in `finally`, collected along with the request) so that `revokeToken` can cancel in-flight requests; when `customToken` is passed, it is used instead, the caller manages its lifecycle, and it is not registered (`revokeToken` cannot cancel it). In axios <0.22 the cancel handler is never unsubscribed — a shared long-lived token accumulates one handler per request, causing overnight OOM when left running (TI-15555). **Do not turn the one-time source into a shared token.** The one-time source is only created when the injected `axios` exposes `CancelToken` (axios's default export and `@nuxtjs/axios`'s `$axios` do; instances produced by `axios.create()` don't); without it, `revokeToken` cannot abort in-flight requests and only blocks subsequent `send()` calls.
|
|
360
368
|
12. **`silent: true` only skips errorHandler**: the error is still thrown to the caller's `onError`, and `ERR_F108` is still routed as usual; but every other error code — **including logout-class codes such as `ERR_A104`, and `ERR_G106` insufficient balance** — never reaches the error machine. Use it only for background requests whose session invalidation is already covered by `fetchUserInfo` polling; never add it to user-initiated requests.
|
|
361
|
-
13. **`send()` does not guarantee an object, and `assign()` must never throw**: non-config requests during maintenance (`isBlocked`) and `ERR_800`
|
|
369
|
+
13. **`send()` does not guarantee an object, and `assign()` must never throw**: non-config requests during maintenance (`isBlocked`) and non-cancellation errors that already carry `code: 'ERR_800'` make `send()` **resolve `undefined`** (they never reach `onError`); a 200 response with a non-JSON body resolves a string, so destructuring `{ data }` yields `undefined`. Cancellations (`customToken` cancellation, `revokeToken` revocation), by contrast, reject with `ERR_800` and **do reach `onError`** — they never resolve `undefined`. When an `assign()` throws, XState v4 clears the event queue and the state is not updated — the machine stays in the current invoke state and `after`-based polling stops until an external event (e.g. `REFRESH`) moves it out. **Validate response shapes inside the service and `throw` there (reject → `onError`)**; every assign in `onDone` must handle every value the service can resolve, including deliberate `return null` early exits.
|
|
370
|
+
14. **Late errors from a stale identity never reach errorHandler**: when the token a request was sent with differs from the current token (and a current token exists), the error is only thrown to the caller's `onError` and not forwarded to errorHandler — so a late logout-class error from an old session can't log out a newly logged-in identity. When there is no current token (TTL expired or already cleared), routing is unchanged so that `ERR_A204`-style popups aren't swallowed; the `ERR_F108` check comes before this one and still routes as usual.
|
|
362
371
|
|
|
363
372
|
---
|
|
364
373
|
|
|
@@ -373,12 +382,12 @@ io(`${socketURL}/frontend`, {
|
|
|
373
382
|
| lodash extension | `'lodash/pickBy.js'` and `'lodash/pickBy'` coexist | Consistently **without** the extension |
|
|
374
383
|
| URL leading slash | A few APIs carry a leading slash | Omit it (unless deliberately bypassing `url-join`, in which case comment the reason) |
|
|
375
384
|
| Query parameter placement | A few write them straight into the URL (`register?${qs}`, `mail?include=cl`), bypassing serialization | Always use the `params` field |
|
|
376
|
-
| Initial state naming | `idle`
|
|
385
|
+
| Initial state naming | `idle` / `loading` / `fetching` / `pending` / `checking` / `init` and others used interchangeably | By semantics: `idle` (awaiting action), `loading` (initial load), `fetching` (re-fetch), `submitting` / `submitted` |
|
|
377
386
|
| Magic numbers and strings | Activity type IDs, error codes, TTLs, polling ticks, `'DEPOSIT'`/`'WITHDRAW'`, `receiveStatus`, `connectStatus` are scattered around; `util/constant.js` currently holds **only** `GAME_SEARCH` / `GAME_TYPE_LIST`, two game-category constants | Centralize in `util/constant.js` (`ERROR_CODES` / `TTL` / `INTERVAL` / `TRANSFER_TYPE` / `RECEIVE_STATUS`) |
|
|
378
387
|
| Error handling | Three forms coexist: silent fallback to `idle` (most common, loses error info), transition to `fail`, infinite retry | `onError` with `actions: 'setError'` to preserve the error in context; distinguish recoverable from unrecoverable; retries must have a cap |
|
|
379
388
|
| Parameter naming | e.g. `getFreeGameReward(code)` is semantically unclear | Concrete names (`gameCode`) |
|
|
380
389
|
| Parameter validation | The API layer has no validation at all (e.g. the dynamic path following `checkDt()` is injected straight into the URL) | Validate at the system boundary: path parameters non-undefined and free of path-traversal characters, amounts positive |
|
|
381
|
-
| Deprecated APIs | `getPaymentInfo` in `api/payment.js` carries a "deprecated" comment
|
|
390
|
+
| Deprecated APIs | `getPaymentInfo` in `api/payment.js` only carries a "deprecated" comment | Add `@deprecated` first, then remove once confirmed unreferenced |
|
|
382
391
|
|
|
383
392
|
---
|
|
384
393
|
|
|
@@ -392,7 +401,7 @@ io(`${socketURL}/frontend`, {
|
|
|
392
401
|
- **No automatic token refresh** — the response interceptor in `request.js` does not handle 401, so an expired token simply fails.
|
|
393
402
|
- **No code splitting** — `machine/index.js` eagerly imports every state machine + the APIs + Socket.IO + lodash, so importing `machine` loads everything. Consider supporting individual imports to enable tree-shaking.
|
|
394
403
|
- **Timer management** — countdowns are largely implemented with self-referencing `after: { 1000 }` transitions (e.g. the OTP `countdown` in `withdraw_manual_cash.js`), producing one state transition per second (including a context clone + event dispatch). Consider a callback service + `setInterval`, and **compute elapsed time** rather than decrementing step by step to avoid cumulative drift.
|
|
395
|
-
- **Large state machine files** —
|
|
404
|
+
- **Large state machine files** — several state machines under `src/machine/` exceed 300 lines (`wc -l` is the source of truth for the actual list) and could be split into composable sub-machines.
|
|
396
405
|
- **Unused context fields** — several state machines declare context fields that are never assigned or read.
|
|
397
406
|
- **lodash exists for only two functions** — the whole repo has just 5 imports: `pickBy` (`request/request.js`, `api/auth.js`, `machine/auth.js`, `machine/common.js`) and `isEqual` (`activity/fafafa_activity.js`), yet the entire package is listed as a dependency. Both can be replaced with native implementations to drop the dependency; until then, at least unify the extension convention (see "Style Convergence Targets").
|
|
398
407
|
|
package/GEMINI.md
CHANGED
|
@@ -148,7 +148,7 @@ State machines **do not directly reference each other**; they communicate indire
|
|
|
148
148
|
| `ERR_F106` | OTP verification failed |
|
|
149
149
|
| `ERR_G106` | Insufficient balance (→ deposit state) |
|
|
150
150
|
| `ERR_G124` / `ERR_G125` | Free game settlement / forfeit |
|
|
151
|
-
| `ERR_800` | Cancelled request (
|
|
151
|
+
| `ERR_800` | Cancelled request (never forwarded to errorHandler, but still rejects to the caller's `onError`) |
|
|
152
152
|
| `ERR_998` | Network error / 404 (reported to Sentry) |
|
|
153
153
|
|
|
154
154
|
When `error.extend` contains `unfinished_` → unfinished game; the gameCode is everything after the first underscore, taken via `error.extend.split(/_(.+)/)[1]`.
|
|
@@ -172,6 +172,13 @@ Token 5min TTL → fetchUserInfo success → extendToken resets TTL → poll aga
|
|
|
172
172
|
- **Injection**: the request interceptor automatically adds `Authorization: Bearer {token}`
|
|
173
173
|
- **TTL**: token 300 seconds, account info 31 days, cookie data 7 days
|
|
174
174
|
|
|
175
|
+
**Token revocation & foreground gate** (`request.js`): `revokeToken(token)` and `beginTokenGate(promise, timeoutMs = 3000)` are public `Request` methods with **no caller inside this package** — the downstream frontends call them on logout-class errors and when the app returns to the foreground; changing their signatures or semantics is a public-interface change.
|
|
176
|
+
|
|
177
|
+
- **Only the current identity can be revoked**: `revokeToken` only takes effect when `token === getToken()`, so a late error from a previous identity cannot revoke a newly logged-in token. Once in effect, it cancels in-flight requests carrying that token (for the scope, see item 11 of 2.9), and any later non-public `send()` still carrying it rejects `ERR_800` immediately without hitting the network; public requests are unaffected (the token stays in storage while revoked, and `getConfig` around autoLogin must not be wrongly rejected). There is no "un-revoke" API — logging in again changes the token, which lifts the revocation naturally.
|
|
178
|
+
- **The token to revoke comes from the error object**: when a token-carrying request fails, `send()` attaches a **non-enumerable** `error.requestToken` (the Bearer token at send time). It is non-enumerable so it doesn't leak through `JSON.stringify` / Sentry serialization — **never make it enumerable, and never copy it into enumerable fields, logs, or Sentry extra**. Cancellation `ERR_800` errors and the missing-token `ERR_A103` don't carry this field.
|
|
179
|
+
- **While a gate is active**: non-public requests first wait for the probe promise to settle (success and failure both release it) or for the timeout; once released, they re-check whether the token has been revoked and whether it still exists (missing → `ERR_A103`).
|
|
180
|
+
- **Hard-coded `'self'` coupling**: `send()` decides which request skips the gate by checking whether the descriptor's raw `url` (query stripped, before V2 conversion) is `'self'`, which corresponds to `getUserInfo` in `api/user.js` (`updateUserInfo`, sharing the same url, skips it too). Changing `getUserInfo`'s url (adding a leading slash, changing the path) requires updating this check in lockstep, otherwise `/self` gets blocked by the gate as well — a probe sent after the gate is created would then wait on its own gate until the timeout.
|
|
181
|
+
|
|
175
182
|
**inline vs login states** (the most central concept in `auth.js`):
|
|
176
183
|
|
|
177
184
|
- `inline`: authenticated but `rank < 0` (the account has not finished ranking/activation); polling continues until rank takes effect
|
|
@@ -327,19 +334,20 @@ io(`${socketURL}/frontend`, {
|
|
|
327
334
|
```
|
|
328
335
|
1. A state machine service calls request.send(api.xxx(params))
|
|
329
336
|
2. api.xxx(params) returns a descriptor object
|
|
330
|
-
3.
|
|
331
|
-
4.
|
|
337
|
+
3. Identity pre-checks (non-public only): no token → reject ERR_A103; token revoked via revokeToken → reject ERR_800; gate active and url is not 'self' → wait for the gate, then re-check (see 2.1)
|
|
338
|
+
4. Token-carrying request without customToken → attach a one-time CancelToken source and register it in activeRequests, removed in finally (see item 11 of 2.9)
|
|
332
339
|
5. _createConfig(req):
|
|
333
340
|
a. Strip the query string from the URL
|
|
334
341
|
b. Match against supportVersion2List (supports :param dynamic-path regex matching)
|
|
335
342
|
c. If matched → _convertUrlToKebabCase() (look up the specifyingPath mapping first, otherwise auto-convert)
|
|
336
343
|
d. GET → params goes in the params field; POST → params goes in the data field
|
|
337
344
|
e. pickBy filters out null/undefined values
|
|
338
|
-
6.
|
|
339
|
-
7.
|
|
340
|
-
8.
|
|
341
|
-
9.
|
|
342
|
-
10.
|
|
345
|
+
6. isBlocked check: under maintenance and not a config request → no request is sent, resolves undefined
|
|
346
|
+
7. Request interceptor: injects X-TH1GAMES-VERSION, X-TH1GAMES-PLATFORM, Authorization
|
|
347
|
+
8. Custom paramsSerializer: special encoding for the q parameter (avoids double-encoding)
|
|
348
|
+
9. axios.request(config)
|
|
349
|
+
10. Response interceptor: response.data.error present → reject; Network Error / 404 → ERR_998 + Sentry
|
|
350
|
+
11. Error handling (in order): cancellation → reject ERR_800 (never reaches errorHandler); token-carrying requests get a non-enumerable requestToken attached to the error; ERR_F108 → isBlocked + errorHandler; stale-identity error → thrown directly (see item 14 of 2.9); ERR_998 → thrown directly; everything else → errorHandler (skipped when the descriptor carries silent: true, still thrown); non-cancellation error whose code is already ERR_800 → resolves undefined
|
|
343
351
|
```
|
|
344
352
|
|
|
345
353
|
**V1→V2 conversion**: `supportVersion2List` supports dynamic paths (e.g. `payment/v2/:paymentType/transaction`, where `:param` is replaced by `[^/]+`); special paths are hard-coded in `specifyingPath`, and the rest are auto-converted via `/([a-z])([A-Z])/g`. **When adding an endpoint that needs V2 conversion, it must be added to the list manually.**
|
|
@@ -356,9 +364,10 @@ io(`${socketURL}/frontend`, {
|
|
|
356
364
|
8. **`appSecret` marks public endpoints**: nearly all `isPublic: true` endpoints require an `appSecret` parameter, **but the auth endpoints do not**.
|
|
357
365
|
9. **Unfinished-game infinite retry**: the `unfinishedGame` state in `error.js` returns to itself on `onError`, with **no backoff strategy and no retry cap** (a known issue, see "Known Technical Debt").
|
|
358
366
|
10. **`isMobile` is a string, not a boolean**: in `common.js`, `isMobile = userAgent?.device?.type` returns `'mobile'`/`'tablet'`/`undefined`, so comparisons must be string-based (e.g. `isMobile === 'mobile' ? 'y' : null`).
|
|
359
|
-
11. **
|
|
367
|
+
11. **CancelTokens must be one-time, never shared**: a token-carrying non-public request that passes no `customToken` gets its own **one-time** `CancelToken.source()` (registered in `activeRequests`, removed in `finally`, collected along with the request) so that `revokeToken` can cancel in-flight requests; when `customToken` is passed, it is used instead, the caller manages its lifecycle, and it is not registered (`revokeToken` cannot cancel it). In axios <0.22 the cancel handler is never unsubscribed — a shared long-lived token accumulates one handler per request, causing overnight OOM when left running (TI-15555). **Do not turn the one-time source into a shared token.** The one-time source is only created when the injected `axios` exposes `CancelToken` (axios's default export and `@nuxtjs/axios`'s `$axios` do; instances produced by `axios.create()` don't); without it, `revokeToken` cannot abort in-flight requests and only blocks subsequent `send()` calls.
|
|
360
368
|
12. **`silent: true` only skips errorHandler**: the error is still thrown to the caller's `onError`, and `ERR_F108` is still routed as usual; but every other error code — **including logout-class codes such as `ERR_A104`, and `ERR_G106` insufficient balance** — never reaches the error machine. Use it only for background requests whose session invalidation is already covered by `fetchUserInfo` polling; never add it to user-initiated requests.
|
|
361
|
-
13. **`send()` does not guarantee an object, and `assign()` must never throw**: non-config requests during maintenance (`isBlocked`) and `ERR_800`
|
|
369
|
+
13. **`send()` does not guarantee an object, and `assign()` must never throw**: non-config requests during maintenance (`isBlocked`) and non-cancellation errors that already carry `code: 'ERR_800'` make `send()` **resolve `undefined`** (they never reach `onError`); a 200 response with a non-JSON body resolves a string, so destructuring `{ data }` yields `undefined`. Cancellations (`customToken` cancellation, `revokeToken` revocation), by contrast, reject with `ERR_800` and **do reach `onError`** — they never resolve `undefined`. When an `assign()` throws, XState v4 clears the event queue and the state is not updated — the machine stays in the current invoke state and `after`-based polling stops until an external event (e.g. `REFRESH`) moves it out. **Validate response shapes inside the service and `throw` there (reject → `onError`)**; every assign in `onDone` must handle every value the service can resolve, including deliberate `return null` early exits.
|
|
370
|
+
14. **Late errors from a stale identity never reach errorHandler**: when the token a request was sent with differs from the current token (and a current token exists), the error is only thrown to the caller's `onError` and not forwarded to errorHandler — so a late logout-class error from an old session can't log out a newly logged-in identity. When there is no current token (TTL expired or already cleared), routing is unchanged so that `ERR_A204`-style popups aren't swallowed; the `ERR_F108` check comes before this one and still routes as usual.
|
|
362
371
|
|
|
363
372
|
---
|
|
364
373
|
|
|
@@ -373,12 +382,12 @@ io(`${socketURL}/frontend`, {
|
|
|
373
382
|
| lodash extension | `'lodash/pickBy.js'` and `'lodash/pickBy'` coexist | Consistently **without** the extension |
|
|
374
383
|
| URL leading slash | A few APIs carry a leading slash | Omit it (unless deliberately bypassing `url-join`, in which case comment the reason) |
|
|
375
384
|
| Query parameter placement | A few write them straight into the URL (`register?${qs}`, `mail?include=cl`), bypassing serialization | Always use the `params` field |
|
|
376
|
-
| Initial state naming | `idle`
|
|
385
|
+
| Initial state naming | `idle` / `loading` / `fetching` / `pending` / `checking` / `init` and others used interchangeably | By semantics: `idle` (awaiting action), `loading` (initial load), `fetching` (re-fetch), `submitting` / `submitted` |
|
|
377
386
|
| Magic numbers and strings | Activity type IDs, error codes, TTLs, polling ticks, `'DEPOSIT'`/`'WITHDRAW'`, `receiveStatus`, `connectStatus` are scattered around; `util/constant.js` currently holds **only** `GAME_SEARCH` / `GAME_TYPE_LIST`, two game-category constants | Centralize in `util/constant.js` (`ERROR_CODES` / `TTL` / `INTERVAL` / `TRANSFER_TYPE` / `RECEIVE_STATUS`) |
|
|
378
387
|
| Error handling | Three forms coexist: silent fallback to `idle` (most common, loses error info), transition to `fail`, infinite retry | `onError` with `actions: 'setError'` to preserve the error in context; distinguish recoverable from unrecoverable; retries must have a cap |
|
|
379
388
|
| Parameter naming | e.g. `getFreeGameReward(code)` is semantically unclear | Concrete names (`gameCode`) |
|
|
380
389
|
| Parameter validation | The API layer has no validation at all (e.g. the dynamic path following `checkDt()` is injected straight into the URL) | Validate at the system boundary: path parameters non-undefined and free of path-traversal characters, amounts positive |
|
|
381
|
-
| Deprecated APIs | `getPaymentInfo` in `api/payment.js` carries a "deprecated" comment
|
|
390
|
+
| Deprecated APIs | `getPaymentInfo` in `api/payment.js` only carries a "deprecated" comment | Add `@deprecated` first, then remove once confirmed unreferenced |
|
|
382
391
|
|
|
383
392
|
---
|
|
384
393
|
|
|
@@ -392,7 +401,7 @@ io(`${socketURL}/frontend`, {
|
|
|
392
401
|
- **No automatic token refresh** — the response interceptor in `request.js` does not handle 401, so an expired token simply fails.
|
|
393
402
|
- **No code splitting** — `machine/index.js` eagerly imports every state machine + the APIs + Socket.IO + lodash, so importing `machine` loads everything. Consider supporting individual imports to enable tree-shaking.
|
|
394
403
|
- **Timer management** — countdowns are largely implemented with self-referencing `after: { 1000 }` transitions (e.g. the OTP `countdown` in `withdraw_manual_cash.js`), producing one state transition per second (including a context clone + event dispatch). Consider a callback service + `setInterval`, and **compute elapsed time** rather than decrementing step by step to avoid cumulative drift.
|
|
395
|
-
- **Large state machine files** —
|
|
404
|
+
- **Large state machine files** — several state machines under `src/machine/` exceed 300 lines (`wc -l` is the source of truth for the actual list) and could be split into composable sub-machines.
|
|
396
405
|
- **Unused context fields** — several state machines declare context fields that are never assigned or read.
|
|
397
406
|
- **lodash exists for only two functions** — the whole repo has just 5 imports: `pickBy` (`request/request.js`, `api/auth.js`, `machine/auth.js`, `machine/common.js`) and `isEqual` (`activity/fafafa_activity.js`), yet the entire package is listed as a dependency. Both can be replaced with native implementations to drop the dependency; until then, at least unify the extension convention (see "Style Convergence Targets").
|
|
398
407
|
|
package/package.json
CHANGED
package/src/api/activity.js
CHANGED
|
@@ -44,10 +44,10 @@ export default {
|
|
|
44
44
|
method: 'get',
|
|
45
45
|
params: { rewardType },
|
|
46
46
|
}),
|
|
47
|
-
getRewardList: ({ rewardType, count, appSecret,
|
|
47
|
+
getRewardList: ({ rewardType, count, appSecret, orderColumn, lang }) => ({
|
|
48
48
|
url: 'activities/rewards',
|
|
49
49
|
method: 'get',
|
|
50
|
-
params: { rewardType, count, appSecret,
|
|
50
|
+
params: { rewardType, count, appSecret, orderColumn, lang },
|
|
51
51
|
}),
|
|
52
52
|
getCashRainReward: ({ activityNo, appSecret }) => ({
|
|
53
53
|
url: `activities/cashRain`,
|
|
@@ -197,7 +197,7 @@ export default function (request, context) {
|
|
|
197
197
|
)
|
|
198
198
|
const getOtherRewardAPI = request.send(
|
|
199
199
|
activity.getRewardList({
|
|
200
|
-
rewardType: 'CASH,FREE,PRIZE',
|
|
200
|
+
rewardType: 'CASH,FREE,PRIZE,GAME',
|
|
201
201
|
count: 30,
|
|
202
202
|
appSecret,
|
|
203
203
|
orderColumn,
|
|
@@ -212,7 +212,7 @@ export default function (request, context) {
|
|
|
212
212
|
const lang = context.lang
|
|
213
213
|
const getOtherRewardAPI = request.send(
|
|
214
214
|
activity.getRewardList({
|
|
215
|
-
rewardType: 'CASH,FREE,PRIZE',
|
|
215
|
+
rewardType: 'CASH,FREE,PRIZE,GAME',
|
|
216
216
|
count: 30,
|
|
217
217
|
appSecret,
|
|
218
218
|
orderColumn,
|
package/src/util/constant.js
CHANGED
package/test/auth_otp_v3.test.js
CHANGED
|
@@ -216,11 +216,11 @@ for (const entry of autoVerifyEntries) {
|
|
|
216
216
|
})
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
test('auto verify waiting fails after the
|
|
219
|
+
test('auto verify waiting fails after the 5 second limit without polled /self', async (t) => {
|
|
220
220
|
t.mock.timers.enable({ apis: ['setTimeout'] })
|
|
221
221
|
const { service } = await startAutoVerify(autoVerifyEntries[0])
|
|
222
222
|
try {
|
|
223
|
-
t.mock.timers.tick(
|
|
223
|
+
t.mock.timers.tick(4999)
|
|
224
224
|
assert.equal(service.state.matches('autoVerifyWaiting'), true)
|
|
225
225
|
t.mock.timers.tick(1)
|
|
226
226
|
assert.equal(service.state.matches('fail'), true)
|
|
@@ -229,11 +229,11 @@ test('auto verify waiting fails after the 4 second limit without polled /self',
|
|
|
229
229
|
}
|
|
230
230
|
})
|
|
231
231
|
|
|
232
|
-
test('the
|
|
232
|
+
test('the 5 second limit is not reset by a stale polled /self', async (t) => {
|
|
233
233
|
t.mock.timers.enable({ apis: ['setTimeout'] })
|
|
234
234
|
const { service, request } = await startAutoVerify(autoVerifyEntries[0])
|
|
235
235
|
try {
|
|
236
|
-
t.mock.timers.tick(
|
|
236
|
+
t.mock.timers.tick(4000)
|
|
237
237
|
service.send({ type: 'USER_INFO_UPDATED', data: { ...request.contact, phone_verification_status: false } })
|
|
238
238
|
t.mock.timers.tick(1000)
|
|
239
239
|
assert.equal(service.state.matches('fail'), true)
|