@jetthai/cuora 1.1.488-dev.1 → 1.1.488
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/.claude/commands/sync-ai-prompts.md +1 -88
- package/.claude/settings.local.json +1 -3
- package/.github/copilot-instructions.md +6 -17
- package/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/.prettierignore +1 -2
- package/AGENTS.md +6 -17
- package/AI_PROMPT_SOURCE.md +6 -17
- package/CHANGELOG.md +23 -420
- package/CLAUDE.md +6 -17
- package/GEMINI.md +6 -17
- package/package.json +1 -1
- package/scripts/auto-version.js +0 -1
- package/scripts/branch-auto-npm-publish.js +2 -9
- package/src/api/payment.js +0 -1
- package/src/machine/auth.js +33 -36
- package/src/machine/game_v2_1.js +0 -15
- package/src/machine/user_sign_up.js +0 -3
- package/src/machine/withdraw/withdraw_manual_cash.js +7 -17
- package/src/request/request.js +4 -103
- package/src/util/constant.js +0 -6
- package/e2e/feature-map.md +0 -19
- package/prepare-for-pr/JT-1776243420.md +0 -85
- package/prepare-for-pr/TI-16026/STATE.md +0 -18
- package/prepare-for-pr/TI-16026/after-prepare-authorization.md +0 -3
- package/prepare-for-pr/TI-16026/analysis.md +0 -38
- package/prepare-for-pr/TI-16026/answer-analyze-01.md +0 -1
- package/prepare-for-pr/TI-16026/answer-commit-01.md +0 -2
- package/prepare-for-pr/TI-16026/answer-commit-02.md +0 -1
- package/prepare-for-pr/TI-16026/bundle.json +0 -18
- package/prepare-for-pr/TI-16026/checklist.md +0 -196
- package/prepare-for-pr/TI-16026/checklist.unit-test-original.md +0 -39
- package/prepare-for-pr/TI-16026/claude-after-model +0 -1
- package/prepare-for-pr/TI-16026/claude-commit-session +0 -1
- package/prepare-for-pr/TI-16026/claude-harvest-session +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/01-analyze.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/01-analyze.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/02-analyze.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/02-analyze.out +0 -4
- package/prepare-for-pr/TI-16026/claude-hops/03-dev.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/03-dev.out +0 -4
- package/prepare-for-pr/TI-16026/claude-hops/04-dev.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/04-dev.out +0 -4
- package/prepare-for-pr/TI-16026/claude-hops/05-dev.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/05-dev.out +0 -3
- package/prepare-for-pr/TI-16026/claude-hops/06-after.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/06-after.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/07-commit.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/07-commit.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/08-commit.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/08-commit.out +0 -2
- package/prepare-for-pr/TI-16026/claude-hops/09-commit.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/09-commit.out +0 -8
- package/prepare-for-pr/TI-16026/claude-hops/10-harvest.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/10-harvest.out +0 -3
- package/prepare-for-pr/TI-16026/claude-hops/11-harvest.err +0 -1
- package/prepare-for-pr/TI-16026/claude-hops/11-harvest.out +0 -3
- package/prepare-for-pr/TI-16026/commit-note.md +0 -5
- package/prepare-for-pr/TI-16026/evidence-index.json +0 -215
- package/prepare-for-pr/TI-16026/feature-map.before.md +0 -61
- package/prepare-for-pr/TI-16026/harvest-redaction.json +0 -34
- package/prepare-for-pr/TI-16026/harvest-redaction.out +0 -37
- package/prepare-for-pr/TI-16026/harvest.md +0 -46
- package/prepare-for-pr/TI-16026/lessons.md +0 -5
- package/prepare-for-pr/TI-16026/note-harvest-redaction.md +0 -1
- package/prepare-for-pr/TI-16026/open-questions.md +0 -6
- package/prepare-for-pr/TI-16026/publish.md +0 -32
- package/prepare-for-pr/TI-16026/review-convergence-response.md +0 -3
- package/prepare-for-pr/TI-16026/review-input/scope.md +0 -18
- package/prepare-for-pr/TI-16026/review-log.md +0 -57
- package/prepare-for-pr/TI-16026/review-notes.md +0 -97
- package/prepare-for-pr/TI-16026/review-response-r1.md +0 -7
- package/prepare-for-pr/TI-16026/self-test-report.md +0 -67
- package/prepare-for-pr/TI-16026/spec-proposal.md +0 -34
- package/prepare-for-pr/TI-16026/spec-snapshot.md +0 -291
- package/prepare-for-pr/TI-16026/state-log.md +0 -57
- package/prepare-for-pr/TI-16026/user-messages/01.md +0 -12
- package/prepare-for-pr/TI-16026/user-messages/02.md +0 -20
- package/prepare-for-pr/TI-16026/user-messages/03.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/04.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/05.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/06.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/07.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/08.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/09.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/10.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/11.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/12.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/13.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/14.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/15.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/16.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/17.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/18.md +0 -10
- package/prepare-for-pr/TI-16026/user-messages/19.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/20.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/21.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/22.md +0 -1
- package/prepare-for-pr/TI-16026/user-messages/23.md +0 -8
- package/prepare-for-pr/TI-16026/user-messages/24.md +0 -24
- package/prepare-for-pr/TI-16026/user-question.md +0 -24
- package/prepare-for-pr/TI-16026/verify/metrics-check.json +0 -13
- package/prepare-for-pr/TI-16026/verify/redaction.json +0 -38
- package/prepare-for-pr/TI-16026/verify/row-closure.json +0 -45
- package/prepare-for-pr/TI-16026/verify/s04-ws-capture.md +0 -23
- package/prepare-for-pr/TI-16026/verify-after.md +0 -23
- package/prepare-for-pr/TI-16026/verify.json +0 -80
- package/prepare-for-pr/TI-16026.md +0 -408
- package/src/util/tokenStore.js +0 -44
- package/test/auth_self_timeout.test.js +0 -171
- package/test/request_self.test.js +0 -288
- package/test/withdraw_manual_cash.test.js +0 -149
- package/tests/session.test.mjs +0 -177
package/GEMINI.md
CHANGED
|
@@ -144,7 +144,7 @@ State machines **do not directly reference each other**; they communicate indire
|
|
|
144
144
|
| `ERR_F108` | System under maintenance (**dual interception**: `request.js` sets `isBlocked` to block subsequent non-config requests; `error.js` routes to logout) |
|
|
145
145
|
| `ERR_A103` | Missing auth token |
|
|
146
146
|
| `ERR_A104` / `ERR_A113` / `ERR_A201` / `ERR_A204` | Auth invalidation / logout class |
|
|
147
|
-
| `ERR_A108` |
|
|
147
|
+
| `ERR_A108` | OTP auth related |
|
|
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 |
|
|
@@ -161,25 +161,16 @@ This section explains how each module actually operates, its non-obvious behavio
|
|
|
161
161
|
|
|
162
162
|
### 2.1 Authentication & Token Lifecycle
|
|
163
163
|
|
|
164
|
-
**Token survival strategy**: the token TTL is only 5 minutes (`maxAge: 300`), kept alive by continuous `fetchUserInfo` polling. On each successful poll, `extendToken` rewrites
|
|
164
|
+
**Token survival strategy**: the token TTL is only 5 minutes (`maxAge: 300`), kept alive by continuous `fetchUserInfo` polling. On each successful poll, `extendToken` rewrites storage and resets the TTL. **Tokens are never auto-renewed** — if `fetchUserInfo` fails, the token expires naturally and the session terminates on its own.
|
|
165
165
|
|
|
166
166
|
```
|
|
167
167
|
Token 5min TTL → fetchUserInfo success → extendToken resets TTL → poll again
|
|
168
168
|
fetchUserInfo failure → leaving state → logout
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
- **Single-flight must be paired with a timeout**: without one, a `/self` that never answers permanently stops the polling that shares it. Do the same when adding single-flight to another endpoint.
|
|
174
|
-
- **The read timeout must not be switched to axios's `timeout`**: `ECONNABORTED` gets re-sent by the downstream axios-retry; a cancelled error carries no `config` and is not retried. `POST self` (`_isSelfWrite`) is deliberately the opposite: each attempt gets 15 seconds and is retried per the downstream's existing settings, so it uses axios's `timeout` plus `'axios-retry': { shouldResetTimeout: true }`; when the retries are exhausted and it still times out, the error becomes `{ code: 'ERR_998', isTimeout: true }` and does not reach `errorHandler`.
|
|
175
|
-
- **A successful `GET /self` extends the token**: on a successful read (all three channels count), `_extendToken` resets the token's TTL to 5 minutes (only while the token sent is still the current one). While the main polling keeps timing out, a single successful read from another channel keeps the TTL from logging the user out. A successful `POST self` does **not** extend it: the backend renews the token only on `GET /self`.
|
|
176
|
-
- **A `/self` timeout never logs out**: the `isSelfTimeout` guard in `auth.js` only accepts `event.data.isTimeout === true`, and a timeout re-sends instead — `authenticated` → `userInfoRetrying`, `tokenAuthenticated` re-enters itself, `inline.fetching` / `login.checkDeviceTokenDone` / `login.fetching` → `pending` (wait for the next tick). A plain `ERR_998` (a network error that fails immediately) and authentication failures still go to `leaving`. Only once the token's 5-minute TTL has expired does `send()` return `ERR_A103` and the flow naturally reaches `leaving`.
|
|
177
|
-
- **`userInfoRetrying` is an externally visible state**: when the first `/self` after login times out, the machine stays here re-sending and moves to `otpChecking` on success. It deliberately does not re-enter `authenticated` — downstream fires one-off side effects on `state.matches('authenticated')` (saving credentials, registration conversion tracking), and re-entering would fire them again. Downstream code that enumerates auth states (loading checks, etc.) must treat it as a continuation of `authenticated`.
|
|
178
|
-
|
|
179
|
-
- **Storage location**: a cookie named `cuora_{clientId}`, with no `Domain` attribute (not shared across subdomains), `SameSite=Lax`, plus `Secure` under https. It is read and written only through `Request`'s `getToken()` / `setToken()` / `extendToken()` / `removeToken()` (implemented in `util/tokenStore.js`); **downstream frontends must not read or write this cookie themselves, and must no longer use `storage.get('cuora_{clientId}')` to determine login state** — `storage` is still localStorage, and the token no longer lives there. When `Request` is constructed, it clears any leftover same-named value from localStorage rather than reusing the old token
|
|
180
|
-
- **Unreadable in cross-site iframes**: a `SameSite=Lax` cookie cannot be read or written inside a cross-site iframe (e.g. a Mini App embedded in Telegram Web), so login state cannot be maintained in that context; this is an accepted limitation
|
|
171
|
+
- **Storage location**: localStorage, key `cuora_{clientId}` (a contract shared with the downstream frontends)
|
|
181
172
|
- **Injection**: the request interceptor automatically adds `Authorization: Bearer {token}`
|
|
182
|
-
- **TTL**: token 300 seconds
|
|
173
|
+
- **TTL**: token 300 seconds, account info 31 days, cookie data 7 days
|
|
183
174
|
|
|
184
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.
|
|
185
176
|
|
|
@@ -290,7 +281,6 @@ There are only 4 guards: `hasNoBank` (`REFRESH` only reloads when no account is
|
|
|
290
281
|
- **Parallel architecture** (`game_v2_1.js`): `flow` (UI interaction and game loading) and `timer` (auto-update every 20 seconds) run simultaneously
|
|
291
282
|
- **Static-data fallback**: when logged out, `staticData` is used, slicing 20 entries per page from cache with **no API call**
|
|
292
283
|
- **Game-switching mechanism**: when switching to another game while in one, `connectSwitching` disconnects the old game first, then `connecting` connects to the new one
|
|
293
|
-
- **Two ways to leave a game**: `EXIT_GAME` goes through `disconnect`, which calls `game/logout`; `ABANDON_GAME` returns straight to `idle` and clears the game URL, **without calling `game/logout`**. The latter is only for when "the session has been replaced (re-login) and the game page must be left" — logging the old session out of the game no longer serves any purpose. Once `ABANDON_GAME` has been sent, the `EXIT_GAME` that is still sent as usual when the page unloads is not handled in `idle`
|
|
294
284
|
- **Provider-specific behavior**: some providers use `${origin}${base}return` as the returnURL, while the rest use `window.location.href` (with the query string stripped). The allowlist is `returnProviders` in `game_v2_1.js`
|
|
295
285
|
- **Response mapping**: backend `redirect_url` → `gameURL`, `wallet_type` → `gameWalletType`; some games return embedded `gameHtml` instead of a URL
|
|
296
286
|
|
|
@@ -392,14 +382,14 @@ A `CONNECT_ERROR` / `DISCONNECT` sent in by downstream itself, without `internal
|
|
|
392
382
|
8. Custom paramsSerializer: special encoding for the q parameter (avoids double-encoding)
|
|
393
383
|
9. axios.request(config)
|
|
394
384
|
10. Response interceptor: response.data.error present → reject; Network Error / 404 → ERR_998 + Sentry
|
|
395
|
-
11. Error handling (in order): cancellation → reject ERR_800 (never reaches errorHandler);
|
|
385
|
+
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
|
|
396
386
|
```
|
|
397
387
|
|
|
398
388
|
**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.**
|
|
399
389
|
|
|
400
390
|
### 2.9 Critical Design Constraints & Gotchas
|
|
401
391
|
|
|
402
|
-
1. **Token extension only happens when
|
|
392
|
+
1. **Token extension only happens when `fetchUserInfo` succeeds**: tokens are never auto-renewed and depend on successful polling. API failure → the session terminates.
|
|
403
393
|
2. **A leading slash changes routing**: `/payment/v2/...` (the withdrawal OTP endpoints) **deliberately** bypasses `url-join`'s baseURL composition and starts from the API root. Regular endpoints should not have a leading slash.
|
|
404
394
|
3. **`register` mixes parameter passing**: `channel`/`subchannel`/`ac`/`fc` are appended to the URL query string while the rest go in the body. **This is the only endpoint using this pattern.**
|
|
405
395
|
4. **OTP endpoints marked `isPublic`**: the withdrawal OTP `acknowledge`/`reset` endpoints are `isPublic: true` even though the operations are sensitive — this is because the token may already have expired during the OTP flow, and is **not a security oversight**.
|
|
@@ -413,7 +403,6 @@ A `CONNECT_ERROR` / `DISCONNECT` sent in by downstream itself, without `internal
|
|
|
413
403
|
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.
|
|
414
404
|
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.
|
|
415
405
|
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.
|
|
416
|
-
15. **`ERR_A108` is resent only once, and only after asking `/self`**: when a token-carrying non-public request receives `ERR_A108`, `send()` first sends a single `silent` `/self`; only if that succeeds and the token has not changed is the original request resent, once. `/self` itself, an already-resent request, and a request whose identity changed during the renewal are never resent; if the renewal fails or the resent request still gets `ERR_A108`, the original error follows the existing routing into errorHandler. **Never turn this into a retry loop** — a failed `/self` means the session has really ended, and downstream relies on this error to log out.
|
|
417
406
|
|
|
418
407
|
---
|
|
419
408
|
|
package/package.json
CHANGED
package/scripts/auto-version.js
CHANGED
|
@@ -14,15 +14,8 @@ const { version } = JSON.parse(readFileSync('package.json', 'utf8'))
|
|
|
14
14
|
console.log(`Branch: ${branch}`)
|
|
15
15
|
console.log(`Version: ${version}`)
|
|
16
16
|
|
|
17
|
-
// 推送 commit 到遠端(--no-verify 避免觸發 pre-push hook 造成無限迴圈)
|
|
18
|
-
execSync(`git push --no-verify ${remote} ${branch}`, { stdio: 'inherit' })
|
|
19
|
-
|
|
20
|
-
// 單獨推送 tag;tag 已存在於 remote 時視為成功(不中斷 npm publish)
|
|
21
|
-
try {
|
|
22
|
-
execSync(`git push --no-verify ${remote} refs/tags/v${version}`, { stdio: 'inherit' })
|
|
23
|
-
} catch {
|
|
24
|
-
console.warn(`⚠ tag v${version} push 失敗(可能已存在),繼續 npm publish`)
|
|
25
|
-
}
|
|
17
|
+
// 推送 commit 與 tag 到遠端(--no-verify 避免觸發 pre-push hook 造成無限迴圈)
|
|
18
|
+
execSync(`git push --no-verify --follow-tags ${remote} ${branch}`, { stdio: 'inherit' })
|
|
26
19
|
|
|
27
20
|
// 發布到 npm,使用分支名稱作為 dist-tag(例如 npm install @jetthai/cuora@dev)
|
|
28
21
|
try {
|
package/src/api/payment.js
CHANGED
package/src/machine/auth.js
CHANGED
|
@@ -8,7 +8,8 @@ import pickBy from 'lodash/pickBy.js'
|
|
|
8
8
|
import { readParamFromLocation, writeParam, normalize, AC_KEYS, FC_KEYS } from '../util/paramStore.js'
|
|
9
9
|
|
|
10
10
|
export default function (request) {
|
|
11
|
-
const { appSecret, sentry } = request.config
|
|
11
|
+
const { appSecret, clientId, sentry } = request.config
|
|
12
|
+
const tokenKey = `cuora_${clientId}`
|
|
12
13
|
const phoneCountryCode = 'phone_countrycode'
|
|
13
14
|
const accountPhoneKey = 'account_phone'
|
|
14
15
|
const accountEmailKey = 'account_email'
|
|
@@ -84,22 +85,7 @@ export default function (request) {
|
|
|
84
85
|
target: 'otpChecking',
|
|
85
86
|
actions: ['setUserInfo', 'extendToken'],
|
|
86
87
|
},
|
|
87
|
-
onError:
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
// 登入後第一筆 /self 逾時的重發。獨立成一個狀態而不重進 authenticated:
|
|
91
|
-
// 下游以 state.matches('authenticated') 觸發一次性副作用(存帳密、註冊轉換追蹤),重進會重複觸發
|
|
92
|
-
userInfoRetrying: {
|
|
93
|
-
invoke: {
|
|
94
|
-
src: 'fetchUserInfo',
|
|
95
|
-
onDone: {
|
|
96
|
-
target: 'otpChecking',
|
|
97
|
-
actions: ['setUserInfo', 'extendToken'],
|
|
98
|
-
},
|
|
99
|
-
onError: [{ target: 'userInfoRetrying', cond: 'isSelfTimeout' }, { target: 'leaving' }],
|
|
100
|
-
},
|
|
101
|
-
on: {
|
|
102
|
-
LOGOUT: {
|
|
88
|
+
onError: {
|
|
103
89
|
target: 'leaving',
|
|
104
90
|
},
|
|
105
91
|
},
|
|
@@ -190,8 +176,9 @@ export default function (request) {
|
|
|
190
176
|
target: 'inline',
|
|
191
177
|
actions: ['setUserInfo', 'extendToken'],
|
|
192
178
|
},
|
|
193
|
-
|
|
194
|
-
|
|
179
|
+
onError: {
|
|
180
|
+
target: 'leaving',
|
|
181
|
+
},
|
|
195
182
|
},
|
|
196
183
|
},
|
|
197
184
|
inline: {
|
|
@@ -207,12 +194,14 @@ export default function (request) {
|
|
|
207
194
|
},
|
|
208
195
|
fetching: {
|
|
209
196
|
invoke: {
|
|
210
|
-
src: '
|
|
197
|
+
src: 'fetchUserInfo',
|
|
211
198
|
onDone: {
|
|
212
199
|
target: 'pending',
|
|
213
200
|
actions: ['setUserInfo', 'extendToken'],
|
|
214
201
|
},
|
|
215
|
-
onError:
|
|
202
|
+
onError: {
|
|
203
|
+
target: '#auth.leaving',
|
|
204
|
+
},
|
|
216
205
|
},
|
|
217
206
|
},
|
|
218
207
|
},
|
|
@@ -247,17 +236,21 @@ export default function (request) {
|
|
|
247
236
|
target: 'pending',
|
|
248
237
|
actions: ['setUserInfo', 'extendToken'],
|
|
249
238
|
},
|
|
250
|
-
onError:
|
|
239
|
+
onError: {
|
|
240
|
+
target: '#auth.leaving',
|
|
241
|
+
},
|
|
251
242
|
},
|
|
252
243
|
},
|
|
253
244
|
fetching: {
|
|
254
245
|
invoke: {
|
|
255
|
-
src: '
|
|
246
|
+
src: 'fetchUserInfo',
|
|
256
247
|
onDone: {
|
|
257
248
|
target: 'pending',
|
|
258
249
|
actions: ['setUserInfo', 'extendToken'],
|
|
259
250
|
},
|
|
260
|
-
onError:
|
|
251
|
+
onError: {
|
|
252
|
+
target: '#auth.leaving',
|
|
253
|
+
},
|
|
261
254
|
},
|
|
262
255
|
},
|
|
263
256
|
pending: {
|
|
@@ -350,10 +343,6 @@ export default function (request) {
|
|
|
350
343
|
isNotInline: (context, event) => {
|
|
351
344
|
return !(context.userInfo?.rank >= 0)
|
|
352
345
|
},
|
|
353
|
-
// 只認請求層 15 秒逾時(request.js 的 isTimeout);一般 ERR_998 與驗證失敗維持原路由
|
|
354
|
-
isSelfTimeout: (context, event) => {
|
|
355
|
-
return event.data?.isTimeout === true
|
|
356
|
-
},
|
|
357
346
|
},
|
|
358
347
|
actions: {
|
|
359
348
|
setSiteConfig: assign((context, event) => {
|
|
@@ -426,12 +415,16 @@ export default function (request) {
|
|
|
426
415
|
}
|
|
427
416
|
}),
|
|
428
417
|
fetchToken: assign((context, event) => {
|
|
418
|
+
const token = storage.get(tokenKey)
|
|
429
419
|
return {
|
|
430
|
-
token
|
|
420
|
+
token,
|
|
431
421
|
}
|
|
432
422
|
}),
|
|
433
423
|
setToken: assign((context, event) => {
|
|
434
|
-
|
|
424
|
+
storage.set(tokenKey, event.data, {
|
|
425
|
+
path: '/',
|
|
426
|
+
maxAge: 300,
|
|
427
|
+
})
|
|
435
428
|
return {
|
|
436
429
|
token: event.data,
|
|
437
430
|
}
|
|
@@ -473,11 +466,19 @@ export default function (request) {
|
|
|
473
466
|
}
|
|
474
467
|
}),
|
|
475
468
|
removeToken: assign((context, event) => {
|
|
476
|
-
|
|
469
|
+
storage.remove(tokenKey, {
|
|
470
|
+
path: '/',
|
|
471
|
+
maxAge: 300,
|
|
472
|
+
})
|
|
477
473
|
return { token: null, dt: null }
|
|
478
474
|
}),
|
|
479
475
|
extendToken: assign((context, event) => {
|
|
480
|
-
|
|
476
|
+
const token = storage.get(tokenKey)
|
|
477
|
+
storage.set(tokenKey, token, {
|
|
478
|
+
path: '/',
|
|
479
|
+
maxAge: 300,
|
|
480
|
+
})
|
|
481
|
+
return { token }
|
|
481
482
|
}),
|
|
482
483
|
redirectTo3Party: async (context, event) => {
|
|
483
484
|
const { provider, fc } = event.data
|
|
@@ -565,10 +566,6 @@ export default function (request) {
|
|
|
565
566
|
fetchUserInfo: async (context, event) => {
|
|
566
567
|
return await request.send(user.getUserInfo())
|
|
567
568
|
},
|
|
568
|
-
// 例行輪詢的 /self 自成一類(channel),與各處單獨發的 /self 互不共用在途、互不影響
|
|
569
|
-
pollUserInfo: async (context, event) => {
|
|
570
|
-
return await request.send({ ...user.getUserInfo(), channel: 'polling' })
|
|
571
|
-
},
|
|
572
569
|
checkDeviceToken: async (context, event) => {
|
|
573
570
|
const deviceTokenEnable = context.siteConfig?.dtVerify
|
|
574
571
|
if (!deviceTokenEnable) return { dt: null }
|
package/src/machine/game_v2_1.js
CHANGED
|
@@ -6,8 +6,6 @@ import { GAME_SEARCH } from '../util/constant.js'
|
|
|
6
6
|
// 對應 intersectionObserver 版本
|
|
7
7
|
export default function (request) {
|
|
8
8
|
const { appSecret } = request.config
|
|
9
|
-
// 不呼叫 game/logout 直接回 idle:session 已換新時,舊 session 的遊戲登出沒有意義
|
|
10
|
-
const abandonGame = { target: 'idle', actions: 'clearGameURL' }
|
|
11
9
|
return createMachine(
|
|
12
10
|
{
|
|
13
11
|
id: 'game',
|
|
@@ -162,7 +160,6 @@ export default function (request) {
|
|
|
162
160
|
EXIT_GAME: {
|
|
163
161
|
target: 'disconnect',
|
|
164
162
|
},
|
|
165
|
-
ABANDON_GAME: abandonGame,
|
|
166
163
|
},
|
|
167
164
|
},
|
|
168
165
|
demoGame: {
|
|
@@ -181,7 +178,6 @@ export default function (request) {
|
|
|
181
178
|
EXIT_GAME: {
|
|
182
179
|
target: 'disconnect',
|
|
183
180
|
},
|
|
184
|
-
ABANDON_GAME: abandonGame,
|
|
185
181
|
},
|
|
186
182
|
},
|
|
187
183
|
connectSwitching: {
|
|
@@ -200,7 +196,6 @@ export default function (request) {
|
|
|
200
196
|
EXIT_GAME: {
|
|
201
197
|
target: 'disconnect',
|
|
202
198
|
},
|
|
203
|
-
ABANDON_GAME: abandonGame,
|
|
204
199
|
},
|
|
205
200
|
},
|
|
206
201
|
playing: {
|
|
@@ -208,7 +203,6 @@ export default function (request) {
|
|
|
208
203
|
EXIT_GAME: {
|
|
209
204
|
target: 'disconnect',
|
|
210
205
|
},
|
|
211
|
-
ABANDON_GAME: abandonGame,
|
|
212
206
|
REFRESH: {
|
|
213
207
|
target: 'refreshing',
|
|
214
208
|
},
|
|
@@ -230,7 +224,6 @@ export default function (request) {
|
|
|
230
224
|
EXIT_GAME: {
|
|
231
225
|
target: 'disconnect',
|
|
232
226
|
},
|
|
233
|
-
ABANDON_GAME: abandonGame,
|
|
234
227
|
EXIT_DEMO_GAME: {
|
|
235
228
|
target: 'idle',
|
|
236
229
|
},
|
|
@@ -252,9 +245,6 @@ export default function (request) {
|
|
|
252
245
|
actions: 'setGameURL',
|
|
253
246
|
},
|
|
254
247
|
},
|
|
255
|
-
on: {
|
|
256
|
-
ABANDON_GAME: abandonGame,
|
|
257
|
-
},
|
|
258
248
|
},
|
|
259
249
|
refreshPending: {
|
|
260
250
|
after: {
|
|
@@ -262,9 +252,6 @@ export default function (request) {
|
|
|
262
252
|
target: 'connecting',
|
|
263
253
|
},
|
|
264
254
|
},
|
|
265
|
-
on: {
|
|
266
|
-
ABANDON_GAME: abandonGame,
|
|
267
|
-
},
|
|
268
255
|
},
|
|
269
256
|
disconnect: {
|
|
270
257
|
invoke: {
|
|
@@ -279,7 +266,6 @@ export default function (request) {
|
|
|
279
266
|
},
|
|
280
267
|
},
|
|
281
268
|
on: {
|
|
282
|
-
ABANDON_GAME: abandonGame,
|
|
283
269
|
LOAD: {
|
|
284
270
|
target: 'routing',
|
|
285
271
|
actions: 'setLoadable',
|
|
@@ -440,7 +426,6 @@ export default function (request) {
|
|
|
440
426
|
return event.data.gameWalletType
|
|
441
427
|
},
|
|
442
428
|
}),
|
|
443
|
-
clearGameURL: assign({ type: undefined, gameToken: undefined, gameHtml: undefined, gameURL: undefined, gameWalletType: undefined }),
|
|
444
429
|
setGameInfo: assign((context, event) => {
|
|
445
430
|
const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name, gameName } = event.data.game
|
|
446
431
|
return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name, gameName } }
|
|
@@ -107,7 +107,6 @@ export default function (request) {
|
|
|
107
107
|
return {
|
|
108
108
|
signUpData: {
|
|
109
109
|
provider: 'local',
|
|
110
|
-
birthday,
|
|
111
110
|
...pickBindData(event.data),
|
|
112
111
|
birthday,
|
|
113
112
|
email,
|
|
@@ -131,7 +130,6 @@ export default function (request) {
|
|
|
131
130
|
return {
|
|
132
131
|
signUpData: {
|
|
133
132
|
provider: 'phone',
|
|
134
|
-
birthday,
|
|
135
133
|
...pickBindData(event.data),
|
|
136
134
|
birthday,
|
|
137
135
|
email,
|
|
@@ -154,7 +152,6 @@ export default function (request) {
|
|
|
154
152
|
return {
|
|
155
153
|
signUpData: {
|
|
156
154
|
provider: 'email',
|
|
157
|
-
birthday,
|
|
158
155
|
...pickBindData(event.data),
|
|
159
156
|
birthday,
|
|
160
157
|
email,
|
|
@@ -36,8 +36,9 @@ export default function (request, context) {
|
|
|
36
36
|
target: 'checking',
|
|
37
37
|
actions: 'setInitData',
|
|
38
38
|
},
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
onError: {
|
|
40
|
+
target: 'loaded',
|
|
41
|
+
},
|
|
41
42
|
},
|
|
42
43
|
},
|
|
43
44
|
checking: {
|
|
@@ -95,11 +96,7 @@ export default function (request, context) {
|
|
|
95
96
|
},
|
|
96
97
|
},
|
|
97
98
|
},
|
|
98
|
-
submitted: {
|
|
99
|
-
on: {
|
|
100
|
-
REFRESH: { target: 'loading', internal: false },
|
|
101
|
-
},
|
|
102
|
-
},
|
|
99
|
+
submitted: {},
|
|
103
100
|
otp: {
|
|
104
101
|
type: 'parallel',
|
|
105
102
|
states: {
|
|
@@ -135,16 +132,9 @@ export default function (request, context) {
|
|
|
135
132
|
target: '#withdraw_manual_cash.submitted',
|
|
136
133
|
actions: 'setProcessing',
|
|
137
134
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
target: 'idle',
|
|
142
|
-
cond: (context, event) => event.data?.code === 'ERR_M129',
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
target: '#withdraw_manual_cash.calculated',
|
|
146
|
-
},
|
|
147
|
-
],
|
|
135
|
+
onError: {
|
|
136
|
+
target: '#withdraw_manual_cash.calculated',
|
|
137
|
+
},
|
|
148
138
|
},
|
|
149
139
|
},
|
|
150
140
|
reset: {
|
package/src/request/request.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import pickBy from 'lodash/pickBy.js'
|
|
2
|
-
import
|
|
2
|
+
import storage from '../util/storage.js'
|
|
3
3
|
import { getErr998SentryExtra } from '../util/err998SentryExtra.js'
|
|
4
|
-
import { SELF_REQUEST_TIMEOUT_MS } from '../util/constant.js'
|
|
5
4
|
|
|
6
5
|
// 暫停 ERR_998 上報:在組裝 Sentry 資料之前就中止,不建立事件;仍照常 reject ERR_998 給呼叫端。恢復時改回 false 即可
|
|
7
6
|
const IS_ERR_998_REPORT_PAUSED = true
|
|
8
7
|
|
|
9
8
|
const CANCELLED_MESSAGE = 'Requests Cancelled'
|
|
10
9
|
|
|
11
|
-
const SELF_URL = 'self'
|
|
12
|
-
const TOKEN_EXPIRED_CODE = 'ERR_A108'
|
|
13
|
-
|
|
14
10
|
// const pickBy = require('lodash/pickBy')
|
|
15
11
|
const supportVersion2List = [
|
|
16
12
|
// 04-09 Update
|
|
@@ -163,12 +159,10 @@ export default class Request {
|
|
|
163
159
|
this.config = config
|
|
164
160
|
this.sentry = config.sentry
|
|
165
161
|
this.key = `cuora_${config.clientId}`
|
|
166
|
-
this.tokenStore = createTokenStore(this.key)
|
|
167
162
|
this.errorHandler = null
|
|
168
163
|
this.hosts = []
|
|
169
164
|
this.isBlocked = false
|
|
170
165
|
this.activeRequests = new Set() // { source, token }:僅追蹤非 public 且帶 token 的在途請求,供 revokeToken 取消
|
|
171
|
-
this.selfFlights = new Map() // 在途的 /self 讀取:同類別(channel)、同 token、同 descriptor 共用同一筆,結束即移除
|
|
172
166
|
this.revokedToken = null
|
|
173
167
|
this.tokenGate = null
|
|
174
168
|
this.clientIp = '' // 由外部 plugin(如 clientIp.client.js)非同步寫入,用於 ERR_998 Sentry 回報
|
|
@@ -287,69 +281,7 @@ export default class Request {
|
|
|
287
281
|
return !!this.axios.isCancel?.(error) || error?.message === CANCELLED_MESSAGE
|
|
288
282
|
}
|
|
289
283
|
|
|
290
|
-
_isSelf(req) {
|
|
291
|
-
return req.url.split('?')[0] === SELF_URL
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
_isSelfRead(req) {
|
|
295
|
-
return !req.isPublic && this._isSelf(req) && req.method.toUpperCase() === 'GET'
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
_isSelfWrite(req) {
|
|
299
|
-
return !req.isPublic && this._isSelf(req) && req.method.toUpperCase() === 'POST'
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// GET /self 成功(任何類別)即證明 token 仍有效:比照 auth machine 的 extendToken 續 5 分鐘。
|
|
303
|
-
// 主輪詢連續逾時期間,只要其他類別的 GET /self 有一筆成功就不該被 TTL 登出。
|
|
304
|
-
// POST /self 不續:後端只在 GET /self 續期 token
|
|
305
|
-
_extendToken(requestToken) {
|
|
306
|
-
if (requestToken && requestToken === this.getToken()) this.extendToken()
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// /self 讀取分三類(descriptor 的 channel):主輪詢 polling/免費遊戲輪詢 freeGame/單獨呼叫 standalone(預設)。
|
|
310
|
-
// 類別之間各發各的,不共用在途;同一類別內單一在途:在途期間相同的呼叫共用同一筆結果不另發。
|
|
311
|
-
// key 含 channel、token 與 descriptor:換身分或參數不同(錯誤處理不同)各自獨立;自帶 customToken 者由呼叫端管理,不共用
|
|
312
284
|
async send(req, customToken) {
|
|
313
|
-
const token = !customToken && this._isSelfRead(req) ? this.getToken() : null
|
|
314
|
-
if (!token) return this._send(req, customToken)
|
|
315
|
-
|
|
316
|
-
const key = JSON.stringify([req.channel || 'standalone', token, req.url, req.params ?? null, req.headers ?? null, !!req.silent])
|
|
317
|
-
const inFlight = this.selfFlights.get(key)
|
|
318
|
-
if (inFlight) return inFlight
|
|
319
|
-
|
|
320
|
-
const flight = this._send(req).finally(() => {
|
|
321
|
-
if (this.selfFlights.get(key) === flight) this.selfFlights.delete(key)
|
|
322
|
-
})
|
|
323
|
-
this.selfFlights.set(key, flight)
|
|
324
|
-
return flight
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// 逾時視同網路失敗(ERR_998:不進 errorHandler、不彈窗),並取消請求。
|
|
328
|
-
// 不用 axios 的 timeout:ECONNABORTED 會被下游 axios-retry 重試;取消的錯誤不帶 config,不會被重試
|
|
329
|
-
_requestWithTimeout(requestConfig, tracked, timeoutMs) {
|
|
330
|
-
let timer
|
|
331
|
-
const timeout = new Promise((resolve, reject) => {
|
|
332
|
-
timer = setTimeout(() => {
|
|
333
|
-
reject({ code: 'ERR_998', endpoint: requestConfig.url, isTimeout: true })
|
|
334
|
-
tracked?.source.cancel(CANCELLED_MESSAGE)
|
|
335
|
-
}, timeoutMs)
|
|
336
|
-
})
|
|
337
|
-
return Promise.race([this.axios.request(requestConfig), timeout]).finally(() => clearTimeout(timer))
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// ERR_A108 多半是續期的短暫落差:先以 /self 確認 session 仍在,成功才把原請求重送一次。
|
|
341
|
-
// /self 自己、已重送過的請求、送出後身分已變的請求都不重送
|
|
342
|
-
async _renewSession(req, requestToken) {
|
|
343
|
-
if (!requestToken || this._isSelf(req) || this.getToken() !== requestToken) return false
|
|
344
|
-
try {
|
|
345
|
-
await this._send({ url: SELF_URL, method: 'get', silent: true }, undefined, true)
|
|
346
|
-
} catch (error) {
|
|
347
|
-
return false
|
|
348
|
-
}
|
|
349
|
-
return this.getToken() === requestToken
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
async _send(req, customToken, isRetry) {
|
|
353
285
|
let tracked = null
|
|
354
286
|
let requestToken = null
|
|
355
287
|
try {
|
|
@@ -360,7 +292,7 @@ export default class Request {
|
|
|
360
292
|
if (!req.isPublic) this._throwIfRevoked()
|
|
361
293
|
|
|
362
294
|
// /self 是 gate 自己的探測請求,不可等待 gate,否則死鎖
|
|
363
|
-
if (this.tokenGate && !req.isPublic &&
|
|
295
|
+
if (this.tokenGate && !req.isPublic && req.url.split('?')[0] !== 'self') {
|
|
364
296
|
await this.tokenGate
|
|
365
297
|
this._throwIfRevoked()
|
|
366
298
|
if (!this.getToken()) return Promise.reject({ code: 'ERR_A103' })
|
|
@@ -385,33 +317,15 @@ export default class Request {
|
|
|
385
317
|
if (this.isBlocked && !configUrls.includes(requestConfig.url)) {
|
|
386
318
|
// 狀態是維護中&請求非siteConfig,終止所有的請求,除了維護頁需要的資料(siteConfig)
|
|
387
319
|
} else {
|
|
388
|
-
|
|
389
|
-
const isSelfWrite = this._isSelfWrite(req)
|
|
390
|
-
if (isSelfWrite) {
|
|
391
|
-
// 寫入與讀取相反:每次嘗試各 15 秒,逾時(ECONNABORTED)交給下游 axios-retry 照現行設定重試;
|
|
392
|
-
// shouldResetTimeout 讓每次重試各有完整期限,否則期限由所有嘗試共用
|
|
393
|
-
requestConfig.timeout = SELF_REQUEST_TIMEOUT_MS
|
|
394
|
-
requestConfig['axios-retry'] = { shouldResetTimeout: true }
|
|
395
|
-
}
|
|
396
|
-
const { data } = await (this._isSelfRead(req)
|
|
397
|
-
? this._requestWithTimeout(requestConfig, tracked, SELF_REQUEST_TIMEOUT_MS)
|
|
398
|
-
: this.axios.request(requestConfig))
|
|
399
|
-
if (this._isSelfRead(req)) this._extendToken(requestToken)
|
|
320
|
+
const { data } = await this.axios.request(requestConfig)
|
|
400
321
|
return data
|
|
401
322
|
}
|
|
402
323
|
} catch (error) {
|
|
403
324
|
if (this._isCancelled(error)) throw this._cancelledError()
|
|
404
|
-
if (error?.code === TOKEN_EXPIRED_CODE && !isRetry && (await this._renewSession(req, requestToken))) {
|
|
405
|
-
return await this._send(req, customToken, true)
|
|
406
|
-
}
|
|
407
325
|
// 不可列舉:避免 Bearer token 隨 JSON.stringify/Sentry 序列化外洩,但 error.requestToken 仍可讀取
|
|
408
326
|
if (requestToken && error && typeof error === 'object' && Object.isExtensible(error)) {
|
|
409
327
|
Object.defineProperty(error, 'requestToken', { value: requestToken, enumerable: false, configurable: true })
|
|
410
328
|
}
|
|
411
|
-
// POST /self 重試用完仍逾時:比照讀取的逾時(ERR_998:不進 errorHandler、不彈窗)
|
|
412
|
-
if (error?.code === 'ECONNABORTED' && this._isSelfWrite(req)) {
|
|
413
|
-
throw { code: 'ERR_998', endpoint: req.url, isTimeout: true }
|
|
414
|
-
}
|
|
415
329
|
if (error.code === 'ERR_F108') {
|
|
416
330
|
this.isBlocked = true
|
|
417
331
|
this.errorHandler && this.errorHandler(error)
|
|
@@ -507,19 +421,6 @@ export default class Request {
|
|
|
507
421
|
}
|
|
508
422
|
|
|
509
423
|
getToken() {
|
|
510
|
-
return
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
setToken(token) {
|
|
514
|
-
this.tokenStore.set(token)
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
// 回傳續期當下的 token;已不存在時回傳 null
|
|
518
|
-
extendToken() {
|
|
519
|
-
return this.tokenStore.extend()
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
removeToken() {
|
|
523
|
-
this.tokenStore.clear()
|
|
424
|
+
return storage.get(this.key)
|
|
524
425
|
}
|
|
525
426
|
}
|
package/src/util/constant.js
CHANGED
|
@@ -22,9 +22,3 @@ export const GAME_TYPE_LIST = [
|
|
|
22
22
|
// OTP 自動驗證:主動打的 /self 未通過後,最多再等幾次 auth 例行輪詢的 /self、等待上限多久
|
|
23
23
|
export const AUTO_VERIFY_MAX_USER_INFO_UPDATES = 2
|
|
24
24
|
export const AUTO_VERIFY_WAIT_MS = 5000
|
|
25
|
-
|
|
26
|
-
// 登入 token 的存活秒數:每次 /self 成功續期一次,逾時由瀏覽器自行移除 cookie
|
|
27
|
-
export const TOKEN_MAX_AGE = 300
|
|
28
|
-
|
|
29
|
-
// /self 讀取的逾時上限:後端 5 分鐘沒收到 /self 會移除 token,逾時釋放在途後由下一輪輪詢重發
|
|
30
|
-
export const SELF_REQUEST_TIMEOUT_MS = 15000
|
package/e2e/feature-map.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Feature map — cuora-module
|
|
2
|
-
|
|
3
|
-
Hints, not facts: verify any line you rely on with this task's own check.
|
|
4
|
-
Each line ends with (observed YYYY-MM-DD <TASK-id>) = the last task that confirmed it.
|
|
5
|
-
|
|
6
|
-
## Repo-wide
|
|
7
|
-
|
|
8
|
-
- SDK with no UI and no `e2e/review-playbook.md`: no browser captures; evidence is `node --test test/*.test.js` (no `test` script in `package.json`) plus code review (observed 2026-11-17 TI-16026)
|
|
9
|
-
- Commit hook runs `npm run format` (`prettier --write .`) even with `HUSKY=0`, so ignored `prepare-for-pr/` files (review reports included) get reformatted → re-check a protected report before relying on it (observed 2026-11-17 TI-16026)
|
|
10
|
-
- Claude's `Bash(git commit:*)` allow pattern does not match an env-prefixed `HUSKY=0 git commit` → allow the prefixed form explicitly (observed 2026-11-17 TI-16026)
|
|
11
|
-
- `NPM_TOKEN_WRITE` set but `npm whoami` returned E401 → run `npm whoami` before starting a release flow (observed 2026-11-17 TI-16026)
|
|
12
|
-
|
|
13
|
-
## withdraw_manual_cash machine
|
|
14
|
-
|
|
15
|
-
- Entry: `src/machine/withdraw/withdraw_manual_cash.js`; unit test pattern in `test/auth_otp_v3.test.js` (`node:test`, `interpret`, stubbed `request.send` keyed by `descriptor.url`) (observed 2026-11-17 TI-16026)
|
|
16
|
-
- Preconditions: context `doubleWalletWithdrawLimitCheck: '0'` and a `paymentDetail` entry `{ category: 'manual', transferType: 'withdraw', minimum, maximum, method }`; stub URLs come from `src/api/payment.js` (observed 2026-11-17 TI-16026)
|
|
17
|
-
- Selectors: `loading.onError` — `src/machine/withdraw/withdraw_manual_cash.js:40`; `submitted.on.REFRESH` — `:100`; root `REFRESH` with `hasNoBank` — `:159` (observed 2026-11-17 TI-16026)
|
|
18
|
-
- States: `submitted` with a pending order is reached via `loading` → `checking` → `isProcessing` guard; REFRESH there is unconditional because the state-level handler wins over the root one (observed 2026-11-17 TI-16026)
|
|
19
|
-
- Gotchas: a failed REFRESH inside `submitted` must return to `submitted` (guard `isProcessing`), not `loaded`, or the user leaves Pending; `setInitData` resets `selectedUserBank` to `userBanks[0]` and leaves OTP fields stale (observed 2026-11-17 TI-16026)
|