@jetthai/cuora 1.1.483 → 1.1.485-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/commands/sync-ai-prompts.md +88 -1
- package/.claude/settings.local.json +3 -1
- package/.github/copilot-instructions.md +19 -10
- package/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/.prettierignore +2 -1
- package/AGENTS.md +19 -10
- package/AI_PROMPT_SOURCE.md +19 -10
- package/CHANGELOG.md +386 -23
- package/CLAUDE.md +19 -10
- package/GEMINI.md +19 -10
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/branch-transfer.md +14 -0
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-preparation.json +40 -0
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/cash-module-verification.md +41 -0
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/implementation-ledger.md +87 -0
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/module-report.md +73 -0
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/plan.md +309 -0
- package/docs/my-claude/feat-sharon-JT-1790247240-socket/test-cases.md +245 -0
- package/docs/my-claude/feat-sharon-JT-1791180540-onesignal/transfer.md +9 -0
- package/e2e/feature-map.md +61 -0
- package/package.json +1 -1
- package/prepare-for-pr/JT-1776243420.md +85 -0
- package/prepare-for-pr/TI-16026/STATE.md +17 -0
- package/prepare-for-pr/TI-16026/after-prepare-authorization.md +3 -0
- package/prepare-for-pr/TI-16026/analysis.md +38 -0
- package/prepare-for-pr/TI-16026/answer-analyze-01.md +1 -0
- package/prepare-for-pr/TI-16026/answer-commit-01.md +2 -0
- package/prepare-for-pr/TI-16026/answer-commit-02.md +1 -0
- package/prepare-for-pr/TI-16026/bundle.json +18 -0
- package/prepare-for-pr/TI-16026/checklist.md +39 -0
- package/prepare-for-pr/TI-16026/claude-after-model +1 -0
- package/prepare-for-pr/TI-16026/claude-commit-session +1 -0
- package/prepare-for-pr/TI-16026/claude-harvest-session +1 -0
- package/prepare-for-pr/TI-16026/claude-hops/01-analyze.err +1 -0
- package/prepare-for-pr/TI-16026/claude-hops/01-analyze.out +2 -0
- package/prepare-for-pr/TI-16026/claude-hops/02-analyze.err +1 -0
- package/prepare-for-pr/TI-16026/claude-hops/02-analyze.out +4 -0
- package/prepare-for-pr/TI-16026/claude-hops/03-dev.err +1 -0
- package/prepare-for-pr/TI-16026/claude-hops/03-dev.out +4 -0
- package/prepare-for-pr/TI-16026/claude-hops/04-dev.err +1 -0
- package/prepare-for-pr/TI-16026/claude-hops/04-dev.out +4 -0
- package/prepare-for-pr/TI-16026/claude-hops/05-dev.err +1 -0
- package/prepare-for-pr/TI-16026/claude-hops/05-dev.out +3 -0
- package/prepare-for-pr/TI-16026/claude-hops/06-after.err +1 -0
- package/prepare-for-pr/TI-16026/claude-hops/06-after.out +2 -0
- package/prepare-for-pr/TI-16026/claude-hops/07-commit.err +1 -0
- package/prepare-for-pr/TI-16026/claude-hops/07-commit.out +2 -0
- package/prepare-for-pr/TI-16026/claude-hops/08-commit.err +1 -0
- package/prepare-for-pr/TI-16026/claude-hops/08-commit.out +2 -0
- package/prepare-for-pr/TI-16026/claude-hops/09-commit.err +1 -0
- package/prepare-for-pr/TI-16026/claude-hops/09-commit.out +8 -0
- package/prepare-for-pr/TI-16026/claude-hops/10-harvest.err +1 -0
- package/prepare-for-pr/TI-16026/claude-hops/10-harvest.out +3 -0
- package/prepare-for-pr/TI-16026/commit-note.md +5 -0
- package/prepare-for-pr/TI-16026/feature-map.before.md +61 -0
- package/prepare-for-pr/TI-16026/harvest-redaction.out +1 -0
- package/prepare-for-pr/TI-16026/harvest.md +37 -0
- package/prepare-for-pr/TI-16026/lessons.md +5 -0
- package/prepare-for-pr/TI-16026/open-questions.md +6 -0
- package/prepare-for-pr/TI-16026/publish.md +28 -0
- package/prepare-for-pr/TI-16026/review-convergence-response.md +3 -0
- package/prepare-for-pr/TI-16026/review-input/scope.md +18 -0
- package/prepare-for-pr/TI-16026/review-log.md +57 -0
- package/prepare-for-pr/TI-16026/review-notes.md +97 -0
- package/prepare-for-pr/TI-16026/review-response-r1.md +7 -0
- package/prepare-for-pr/TI-16026/spec-proposal.md +34 -0
- package/prepare-for-pr/TI-16026/spec-snapshot.md +291 -0
- package/prepare-for-pr/TI-16026/state-log.md +35 -0
- package/prepare-for-pr/TI-16026/user-messages/01.md +12 -0
- package/prepare-for-pr/TI-16026/user-messages/02.md +20 -0
- package/prepare-for-pr/TI-16026/user-messages/03.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/04.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/05.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/06.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/07.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/08.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/09.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/10.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/11.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/12.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/13.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/14.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/15.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/16.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/17.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/18.md +10 -0
- package/prepare-for-pr/TI-16026/user-messages/19.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/20.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/21.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/22.md +1 -0
- package/prepare-for-pr/TI-16026/user-messages/23.md +8 -0
- package/prepare-for-pr/TI-16026/user-question.md +24 -0
- package/prepare-for-pr/TI-16026/verify-after.md +15 -0
- package/prepare-for-pr/TI-16026.md +408 -0
- package/scripts/auto-version.js +1 -0
- package/scripts/branch-auto-npm-publish.js +9 -2
- package/src/api/payment.js +1 -0
- package/src/machine/auth_otp_v3.js +59 -20
- package/src/machine/honor_board_cash.js +15 -18
- package/src/machine/reward_cash.js +2 -2
- package/src/machine/user_sign_up.js +3 -0
- package/src/machine/websocket.js +380 -311
- package/src/machine/withdraw/withdraw_manual_cash.js +7 -4
- package/src/util/constant.js +4 -0
- package/src/util/socketPolicy.js +57 -0
- package/test/auth_otp_v3.test.js +323 -0
- package/test/withdraw_manual_cash.test.js +149 -0
- package/tests/websocket.test.mjs +779 -0
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
# TI-16026: Withdraw submitted-state REFRESH review
|
|
2
|
+
|
|
3
|
+
## Key Changes
|
|
4
|
+
|
|
5
|
+
1. `submitted` accepts REFRESH -> loading and reuses fetchInitData. The r2 fix makes loading.onError return to submitted when processing exists, preserving the pending order and allowing retry; first-load failure still falls back to loaded (`src/machine/withdraw/withdraw_manual_cash.js:40`, :98-101).
|
|
6
|
+
2. Target: feat/stone/JT-1791856380-ws-refresh; HEAD/base c9186b6b3f424d74a9fe1363e64b17eb63809b58. Product changes and test/withdraw_manual_cash.test.js remain uncommitted. The r2 incremental review verified the failure fix; its fresh independent convergence check reviews the complete base-to-working-tree change, including the original submitted REFRESH handler and all six untracked tests.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Key Findings
|
|
11
|
+
|
|
12
|
+
### Strengths
|
|
13
|
+
|
|
14
|
+
1. The fix reuses isProcessing and existing state names, keeps successful initialization unchanged and adds observable rejection/retry assertions with a bound bank.
|
|
15
|
+
2. A memory-only old-onError negative control makes exactly the new retry test fail, proving that it detects the original defect.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
### Behavior Observed
|
|
20
|
+
|
|
21
|
+
1. **F-r1-01 [medium], ACCEPT, verified in r2: yes.** Pending W-1 + bound bank -> REFRESH -> second pendingOrder rejects ERR_998 -> submitted with W-1 retained -> next REFRESH makes request 3 and reaches loaded. No new findings in r2. The historical finding and response remain in review-log.md.
|
|
22
|
+
2. Initial pendingOrder rejection with processing=null still reaches loaded. Successful submitted reload enters loading; an empty response clears processing and reaches loaded; another pending order replaces W-1/500 with W-2/800 and reaches submitted. All six targeted tests pass.
|
|
23
|
+
3. Root REFRESH remains conditional outside submitted. The loaded bank/no-bank transition probe passes both outcomes; other non-submitted definitions were inspected, not individually executed.
|
|
24
|
+
4. The fresh whole-change reviewer formed observations from spec/diff/source before reading the full prior STATE/log/notes, then independently reproduced the six passing tests, the negative-control failure and root boundary results. No additional finding or re-raise was identified. The driver owns the next check-review.sh invocation and STATE update; this report does not declare loop convergence.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 🔧 Change Type
|
|
29
|
+
|
|
30
|
+
- [x] 🐛 Bug fix
|
|
31
|
+
- [ ] ✨ New feature
|
|
32
|
+
- [ ] 💄 Style
|
|
33
|
+
- [ ] ♻️ Refactor
|
|
34
|
+
- [ ] ⚡ Performance
|
|
35
|
+
- [ ] 🔧 Chore
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 📱 Impact Scope
|
|
40
|
+
|
|
41
|
+
The shared SDK factory now accepts REFRESH from submitted regardless of bound banks, enters loading and fetches status again. Empty pending-order results reach loaded; a remaining order replaces processing and returns submitted. If initialization fails with an existing processing order, callers retain submitted and the previous order, then retry with the same REFRESH event. Import/export contracts, factory arguments, event/state names and successful initialization remain unchanged.
|
|
42
|
+
|
|
43
|
+
Internal unchanged consumers were searched with `rg -n 'withdraw_manual_cash|withdraw/index|\.\.\.withdraw|machine/index' src`: src/machine/withdraw/index.js:4 -> src/machine/index.js:18/:54 -> src/index.js:2/:7. Each is an export-forwarding layer without state/error decisions, needs no adaptation, and is listed in the r2 Impact block. The supplied scope also names client-pwa-cash; its exact consumer paths and rendering were not verified because no other repo was inspected. Other frontends using the factory receive the same corrected failure state.
|
|
44
|
+
|
|
45
|
+
The user selected unit tests and review for this SDK repo: adapter=none, delivery local, no SDK screenshots. Cash UI, WebSocket strict-ID behavior, real backend payloads and published-package integration remain with the cash verification flow. The convergence reviewer independently confirmed that src/machine/websocket.js:296-301 already forwards payment-info without a windowType toast filter; the spec's conditional relaxation therefore needs no additional patch on that static criterion. No real socket event was exercised. client-pwa-cash is an explicit downstream consumer; exact downstream paths were not inspected. client-pwa and client-pwa-ssr have no established direct callsite in this scoped input and were not inspected; any caller using this factory receives the same SDK behavior.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Test Completion Status
|
|
50
|
+
|
|
51
|
+
| Item | Validation Tested | Status |
|
|
52
|
+
| -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
|
|
53
|
+
| R2-E1 — accepted failure fix and success regression | node --test test/withdraw_manual_cash.test.js; six cases listed below, 6 passed, 0 failed, exit 0. | PASS |
|
|
54
|
+
| R2-E2 — test sensitivity | Same suite with only old unconditional loading.onError restored in memory: failed retry case times out waiting for submitted; 5 passed, 1 failed, exit 1 expected. | PASS |
|
|
55
|
+
| R2-E3 — root REFRESH boundary | Pure transitions: loaded with no bank -> loading; loaded with bound bank -> loaded; assertions pass, exit 0, no request. | PASS |
|
|
56
|
+
| R2-E4 — code/whitespace | git diff --check, empty output, exit 0; inspect onError, onDone, guard, initializer and exports. | PASS |
|
|
57
|
+
| C2-E1–C2-E4 — independent whole-change convergence | Fresh spec/source review, complete base-to-working-tree diff and untracked test; independently rerun six tests (6 pass), old-onError negative control (expected 1 failure), root boundaries (pass) and whitespace check (pass). Raw output below. | PASS |
|
|
58
|
+
| Full suite / alternate wallet gates / OTP / other errors | Not selected for this scoped whole-change review: services, wallet gating and OTP definitions are unchanged; no exhaustive event or error enumeration. | NOT RUN |
|
|
59
|
+
| Cash UI / real backend / published package | Outside this SDK review and not executed; user choice A replaces SDK screenshot evidence. | NOT RUN |
|
|
60
|
+
|
|
61
|
+
Evidence is embedded in this report because only this report, review-log.md and review-notes.md are writable. All commands ran from cuora-module. Local response stubs exercise the real XState factory and initializer without transport/backend calls or transactions.
|
|
62
|
+
|
|
63
|
+
R2-E1 raw output:
|
|
64
|
+
|
|
65
|
+
```text
|
|
66
|
+
$ node --test test/withdraw_manual_cash.test.js
|
|
67
|
+
✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.531542ms)
|
|
68
|
+
✔ REFRESH in submitted returns to the form when no order is pending (0.86175ms)
|
|
69
|
+
✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.483625ms)
|
|
70
|
+
✔ a failed refresh in submitted keeps the pending order and a later REFRESH retries (0.742208ms)
|
|
71
|
+
✔ a failed first load without a pending order still shows the form (0.394833ms)
|
|
72
|
+
✔ REFRESH in loaded with a bound bank is still ignored (22.485208ms)
|
|
73
|
+
ℹ tests 6
|
|
74
|
+
ℹ suites 0
|
|
75
|
+
ℹ pass 6
|
|
76
|
+
ℹ fail 0
|
|
77
|
+
ℹ cancelled 0
|
|
78
|
+
ℹ skipped 0
|
|
79
|
+
ℹ todo 0
|
|
80
|
+
ℹ duration_ms 114.366834
|
|
81
|
+
exit: 0
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
R2-E2 exact command (memory only):
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
node --input-type=module <<'NODE'
|
|
88
|
+
import test from 'node:test'
|
|
89
|
+
import assert from 'node:assert/strict'
|
|
90
|
+
import { readFileSync } from 'node:fs'
|
|
91
|
+
import { interpret, createMachine } from 'xstate'
|
|
92
|
+
import original from './src/machine/withdraw/withdraw_manual_cash.js'
|
|
93
|
+
const suite = readFileSync('test/withdraw_manual_cash.test.js', 'utf8').replace(/^import .*\n/gm, '')
|
|
94
|
+
const mutant = (...args) => {
|
|
95
|
+
const machine = original(...args)
|
|
96
|
+
return createMachine({ ...machine.config, states: { ...machine.config.states, loading: { ...machine.config.states.loading, invoke: { ...machine.config.states.loading.invoke, onError: { target: 'loaded' } } } } }, machine.options)
|
|
97
|
+
}
|
|
98
|
+
console.log('NEGATIVE CONTROL ONLY: restore old loading.onError in memory; files unchanged')
|
|
99
|
+
new Function('test', 'assert', 'interpret', 'withdrawManualCash', suite)(test, assert, interpret, mutant)
|
|
100
|
+
NODE
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```text
|
|
104
|
+
NEGATIVE CONTROL ONLY: restore old loading.onError in memory; files unchanged
|
|
105
|
+
✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.642166ms)
|
|
106
|
+
✔ REFRESH in submitted returns to the form when no order is pending (1.186167ms)
|
|
107
|
+
✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.146458ms)
|
|
108
|
+
✖ a failed refresh in submitted keeps the pending order and a later REFRESH retries (1001.534792ms)
|
|
109
|
+
✔ a failed first load without a pending order still shows the form (0.655125ms)
|
|
110
|
+
✔ REFRESH in loaded with a bound bank is still ignored (22.874459ms)
|
|
111
|
+
ℹ tests 6
|
|
112
|
+
ℹ suites 0
|
|
113
|
+
ℹ pass 5
|
|
114
|
+
ℹ fail 1
|
|
115
|
+
ℹ cancelled 0
|
|
116
|
+
ℹ skipped 0
|
|
117
|
+
ℹ todo 0
|
|
118
|
+
ℹ duration_ms 1034.528792
|
|
119
|
+
Error: Timed out waiting for submitted
|
|
120
|
+
at Timeout.eval [as _onTimeout] (eval at <anonymous> (.../[eval1]:12:1), <anonymous>:7:45)
|
|
121
|
+
at listOnTimeout (node:internal/timers:605:17)
|
|
122
|
+
at process.processTimers (node:internal/timers:541:7)
|
|
123
|
+
exit: 1 (expected)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
R2-E3 exact command and output:
|
|
127
|
+
|
|
128
|
+
```sh
|
|
129
|
+
node --input-type=module <<'NODE'
|
|
130
|
+
import assert from 'node:assert/strict'
|
|
131
|
+
import factory from './src/machine/withdraw/withdraw_manual_cash.js'
|
|
132
|
+
const machine = factory({ send() { throw new Error('No requests expected') } })
|
|
133
|
+
assert.equal(machine.transition('loaded', 'REFRESH').value, 'loading')
|
|
134
|
+
const withBank = machine.withContext({ ...machine.context, userBanks: [{ bankCode: 'BANK' }] })
|
|
135
|
+
assert.equal(withBank.transition('loaded', 'REFRESH').value, 'loaded')
|
|
136
|
+
console.log('PASS: root REFRESH no bank -> loading; bound bank -> loaded; no requests')
|
|
137
|
+
NODE
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```text
|
|
141
|
+
PASS: root REFRESH no bank -> loading; bound bank -> loaded; no requests
|
|
142
|
+
exit: 0
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Fresh r2 whole-change convergence evidence
|
|
146
|
+
|
|
147
|
+
C2-E1 repeats `node --test test/withdraw_manual_cash.test.js` against the actual working tree:
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.552ms)
|
|
151
|
+
✔ REFRESH in submitted returns to the form when no order is pending (1.1955ms)
|
|
152
|
+
✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.1305ms)
|
|
153
|
+
✔ a failed refresh in submitted keeps the pending order and a later REFRESH retries (0.741834ms)
|
|
154
|
+
✔ a failed first load without a pending order still shows the form (0.394833ms)
|
|
155
|
+
✔ REFRESH in loaded with a bound bank is still ignored (22.575125ms)
|
|
156
|
+
ℹ tests 6
|
|
157
|
+
ℹ suites 0
|
|
158
|
+
ℹ pass 6
|
|
159
|
+
ℹ fail 0
|
|
160
|
+
ℹ cancelled 0
|
|
161
|
+
ℹ skipped 0
|
|
162
|
+
ℹ todo 0
|
|
163
|
+
ℹ duration_ms 118.840542
|
|
164
|
+
exit: 0
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
C2-E2 independently repeats the R2-E2 memory-only command above (only the console label changes):
|
|
168
|
+
|
|
169
|
+
```text
|
|
170
|
+
NEGATIVE CONTROL: old loading.onError in memory; files unchanged
|
|
171
|
+
✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.803667ms)
|
|
172
|
+
✔ REFRESH in submitted returns to the form when no order is pending (1.337542ms)
|
|
173
|
+
✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.228041ms)
|
|
174
|
+
✖ a failed refresh in submitted keeps the pending order and a later REFRESH retries (1002.164458ms)
|
|
175
|
+
✔ a failed first load without a pending order still shows the form (2.062334ms)
|
|
176
|
+
✔ REFRESH in loaded with a bound bank is still ignored (24.000333ms)
|
|
177
|
+
ℹ tests 6
|
|
178
|
+
ℹ suites 0
|
|
179
|
+
ℹ pass 5
|
|
180
|
+
ℹ fail 1
|
|
181
|
+
ℹ cancelled 0
|
|
182
|
+
ℹ skipped 0
|
|
183
|
+
ℹ todo 0
|
|
184
|
+
ℹ duration_ms 1039.1935
|
|
185
|
+
Error: Timed out waiting for submitted
|
|
186
|
+
at Timeout.eval (.../[eval1]:12:1, <anonymous>:7:45)
|
|
187
|
+
at listOnTimeout (node:internal/timers:605:17)
|
|
188
|
+
at process.processTimers (node:internal/timers:541:7)
|
|
189
|
+
exit: 1 (expected)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
C2-E3 independently repeats the exact R2-E3 root-boundary command:
|
|
193
|
+
|
|
194
|
+
```text
|
|
195
|
+
PASS: root REFRESH no bank -> loading; bound bank -> loaded; no requests
|
|
196
|
+
exit: 0
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
C2-E4: `git diff --check` produced no output. `shasum -a 256 src/machine/withdraw/withdraw_manual_cash.js test/withdraw_manual_cash.test.js` confirms the same reviewed product/test artifacts:
|
|
200
|
+
|
|
201
|
+
```text
|
|
202
|
+
13cfd851560c1b60c1bdf206d1c67d1db04d2f2db6652dde698659a34ec391f9 src/machine/withdraw/withdraw_manual_cash.js
|
|
203
|
+
fecacc81d718bc118f791d125768c0ee0204d89b9d3762d0ca15c45725c29268 test/withdraw_manual_cash.test.js
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
`ps -eo pid,rss,command` was denied (`operation not permitted`). No server or background process was started; each Node tool call returned an exit status. No product file was changed by any probe.
|
|
207
|
+
|
|
208
|
+
### Historical r1 evidence
|
|
209
|
+
|
|
210
|
+
These runs predate the r2 fix and preserve E1–E6 references in the append-only review log/notes. E5 records the original defect; current verification is R2-E1–E3 above.
|
|
211
|
+
|
|
212
|
+
E1 command and raw output (final targeted run):
|
|
213
|
+
|
|
214
|
+
```text
|
|
215
|
+
$ node --test test/withdraw_manual_cash.test.js
|
|
216
|
+
✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.575458ms)
|
|
217
|
+
✔ REFRESH in submitted returns to the form when no order is pending (0.872334ms)
|
|
218
|
+
✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.584917ms)
|
|
219
|
+
✔ REFRESH in loaded with a bound bank is still ignored (23.343833ms)
|
|
220
|
+
ℹ tests 4
|
|
221
|
+
ℹ suites 0
|
|
222
|
+
ℹ pass 4
|
|
223
|
+
ℹ fail 0
|
|
224
|
+
ℹ cancelled 0
|
|
225
|
+
ℹ skipped 0
|
|
226
|
+
ℹ todo 0
|
|
227
|
+
ℹ duration_ms 119.1075
|
|
228
|
+
exit: 0
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
E2 exact read-only probe:
|
|
232
|
+
|
|
233
|
+
```sh
|
|
234
|
+
node --input-type=module <<'NODE'
|
|
235
|
+
import assert from 'node:assert/strict'
|
|
236
|
+
import factory from './src/machine/withdraw/withdraw_manual_cash.js'
|
|
237
|
+
const machine = factory({ send() { throw new Error('Pure transition check must not send requests') } })
|
|
238
|
+
assert.equal(machine.transition('loaded', 'REFRESH').value, 'loading')
|
|
239
|
+
const withBank = machine.withContext({ ...machine.context, userBanks: [{ bankCode: 'BANK' }] })
|
|
240
|
+
assert.equal(withBank.transition('loaded', 'REFRESH').value, 'loaded')
|
|
241
|
+
console.log('PASS: loaded + no bank -> loading; loaded + bound bank -> loaded (pure transitions, no network)')
|
|
242
|
+
NODE
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
```text
|
|
246
|
+
PASS: loaded + no bank -> loading; loaded + bound bank -> loaded (pure transitions, no network)
|
|
247
|
+
exit: 0
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
E3 exact negative-control command (the changed guard exists only in a new in-memory machine):
|
|
251
|
+
|
|
252
|
+
```sh
|
|
253
|
+
node --input-type=module <<'NODE'
|
|
254
|
+
import test from 'node:test'
|
|
255
|
+
import assert from 'node:assert/strict'
|
|
256
|
+
import { readFileSync } from 'node:fs'
|
|
257
|
+
import { interpret } from 'xstate'
|
|
258
|
+
import original from './src/machine/withdraw/withdraw_manual_cash.js'
|
|
259
|
+
const suite = readFileSync('test/withdraw_manual_cash.test.js', 'utf8').replace(/^import .*\n/gm, '')
|
|
260
|
+
const mutant = (...args) => original(...args).withConfig({ guards: { hasNoBank: () => true } })
|
|
261
|
+
console.log('NEGATIVE CONTROL ONLY: force hasNoBank=true in memory; repository files are unchanged')
|
|
262
|
+
new Function('test', 'assert', 'interpret', 'withdrawManualCash', suite)(test, assert, interpret, mutant)
|
|
263
|
+
NODE
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
```text
|
|
267
|
+
NEGATIVE CONTROL ONLY: force hasNoBank=true in memory; repository files are unchanged
|
|
268
|
+
✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.814583ms)
|
|
269
|
+
✔ REFRESH in submitted returns to the form when no order is pending (1.313709ms)
|
|
270
|
+
✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.213916ms)
|
|
271
|
+
✖ REFRESH in loaded with a bound bank is still ignored (1.107ms)
|
|
272
|
+
ℹ tests 4
|
|
273
|
+
ℹ suites 0
|
|
274
|
+
ℹ pass 3
|
|
275
|
+
ℹ fail 1
|
|
276
|
+
ℹ cancelled 0
|
|
277
|
+
ℹ skipped 0
|
|
278
|
+
ℹ todo 0
|
|
279
|
+
ℹ duration_ms 11.370083
|
|
280
|
+
|
|
281
|
+
✖ failing tests:
|
|
282
|
+
|
|
283
|
+
✖ REFRESH in loaded with a bound bank is still ignored (1.107ms)
|
|
284
|
+
AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
|
|
285
|
+
false !== true
|
|
286
|
+
at TestContext.eval (...[eval1]:9:1), <anonymous>:103:12)
|
|
287
|
+
code: ERR_ASSERTION; actual: false; expected: true; operator: strictEqual
|
|
288
|
+
exit: 1 (expected)
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
The negative control corresponds to `test/withdraw_manual_cash.test.js:105`; in the evaluated copy, import removal and Function wrapping shift the displayed line number. No files needed restoration.
|
|
292
|
+
|
|
293
|
+
E5 exact read-only convergence reproduction (local stub, no network or transaction):
|
|
294
|
+
|
|
295
|
+
```sh
|
|
296
|
+
node --input-type=module <<'NODE'
|
|
297
|
+
import assert from 'node:assert/strict'
|
|
298
|
+
import { interpret } from 'xstate'
|
|
299
|
+
import factory from './src/machine/withdraw/withdraw_manual_cash.js'
|
|
300
|
+
const pending = { applyId: 'W-1', amount: 500 }
|
|
301
|
+
let pendingCalls = 0
|
|
302
|
+
const request = {
|
|
303
|
+
async send({ url }) {
|
|
304
|
+
if (url === 'payment/v2/getBindingPaymentInfo') return { bankList: [{ bankCode: 'BANK' }], ewalletList: [], cryptoList: [] }
|
|
305
|
+
if (url === 'payment/v2/withdrawRule') return { enableWithdraw: true }
|
|
306
|
+
if (url === 'payment/v2/pendingOrder') {
|
|
307
|
+
if (++pendingCalls === 1) return [pending]
|
|
308
|
+
throw { code: 'ERR_998' }
|
|
309
|
+
}
|
|
310
|
+
throw new Error(`Unexpected descriptor: ${url}`)
|
|
311
|
+
},
|
|
312
|
+
}
|
|
313
|
+
const service = interpret(factory(request, {
|
|
314
|
+
paymentDetail: [{ category: 'manual', transferType: 'withdraw', method: 'MANUAL', minimum: 100, maximum: 10000 }],
|
|
315
|
+
})).start()
|
|
316
|
+
async function waitFor(value) {
|
|
317
|
+
for (let i = 0; i < 100; i++) {
|
|
318
|
+
if (service.state.matches(value)) return
|
|
319
|
+
await new Promise(resolve => setTimeout(resolve, 1))
|
|
320
|
+
}
|
|
321
|
+
throw new Error(`Did not reach ${value}: ${service.state.value}`)
|
|
322
|
+
}
|
|
323
|
+
try {
|
|
324
|
+
await waitFor('submitted')
|
|
325
|
+
service.send('REFRESH')
|
|
326
|
+
await waitFor('loaded')
|
|
327
|
+
assert.deepEqual(service.state.context.processing, pending)
|
|
328
|
+
assert.equal(pendingCalls, 2)
|
|
329
|
+
service.send('REFRESH')
|
|
330
|
+
assert.equal(service.state.value, 'loaded')
|
|
331
|
+
assert.equal(pendingCalls, 2)
|
|
332
|
+
console.log('REPRODUCED: pendingOrder ERR_998 after submitted REFRESH -> loaded, stale processing W-1; bound-bank REFRESH retry ignored (2 calls).')
|
|
333
|
+
} finally {
|
|
334
|
+
service.stop()
|
|
335
|
+
}
|
|
336
|
+
NODE
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
```text
|
|
340
|
+
REPRODUCED: pendingOrder ERR_998 after submitted REFRESH -> loaded, stale processing W-1; bound-bank REFRESH retry ignored (2 calls).
|
|
341
|
+
exit: 0
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
This run asserts the observed bad outcome to prove the counterexample. It does not claim that error recovery passed. The production Request path rethrows ERR_998 without errorHandler (`src/request/request.js:337–338`), matching the stub's rejection contract. No duplicate submission or rendered downstream outcome was tested.
|
|
345
|
+
|
|
346
|
+
E6 command and raw output:
|
|
347
|
+
|
|
348
|
+
```text
|
|
349
|
+
$ node --test test/withdraw_manual_cash.test.js
|
|
350
|
+
✔ REFRESH in submitted re-runs loading and fetches the pending order again (4.547083ms)
|
|
351
|
+
✔ REFRESH in submitted returns to the form when no order is pending (0.8585ms)
|
|
352
|
+
✔ REFRESH in submitted keeps submitted with the updated order when one is still pending (1.423208ms)
|
|
353
|
+
✔ REFRESH in loaded with a bound bank is still ignored (22.29425ms)
|
|
354
|
+
ℹ tests 4
|
|
355
|
+
ℹ suites 0
|
|
356
|
+
ℹ pass 4
|
|
357
|
+
ℹ fail 0
|
|
358
|
+
ℹ cancelled 0
|
|
359
|
+
ℹ skipped 0
|
|
360
|
+
ℹ todo 0
|
|
361
|
+
ℹ duration_ms 115.091791
|
|
362
|
+
exit: 0
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Conditional Review Triggers
|
|
368
|
+
|
|
369
|
+
| Trigger | Hit | Action |
|
|
370
|
+
| ---------------------------------- | --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
371
|
+
| Stateful SDK error/retry selection | YES | Trace invoke rejection, guarded transition, context preservation, successful assignment/checking, handler precedence and root guard. No identity/storage/attribution/queue changes, so those sdk-state.md sections do not apply. |
|
|
372
|
+
| Required SDK UI checks | NO | No SDK UI runtime; explicit user choice A. Rendered cash evidence is outside this repo review. |
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## 📋 Spec Validation (Aligned with review-playbook)
|
|
377
|
+
|
|
378
|
+
The driver restricts review inputs; no checklist or author analysis was read. Rows cite raw spec clauses and the explicit acceptance criteria rather than claim unseen checklist alignment. The fresh convergence check repeats the whole-change source review and C2-E1–C2-E3 checks independently.
|
|
379
|
+
|
|
380
|
+
| Spec Item | Evidence (File/Line/Result) | Status |
|
|
381
|
+
| ----------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
|
|
382
|
+
| Confirmed — submitted REFRESH reloads pending order (spec-snapshot.md:76) | Handler :100 -> invoke :34 -> getPendingOrder :276; test :58-70 asserts loading and query 2; R2-E1. | PASS |
|
|
383
|
+
| Confirmed — empty response returns form; remaining order updates pending (spec-snapshot.md:71), SDK state portion | setInitData :172-184 -> checking :44; tests :72-100 assert undefined processing/loaded and replacement W-2/submitted; R2-E1. | PASS |
|
|
384
|
+
| Confirmed r2 — failure preserves Pending and permits bound-bank retry | onError :40 uses isProcessing :229-230 and skips assignment; test :106-121 proves retained W-1 and call 3; R2-E1/E2. F-r1-01 verified yes. | PASS |
|
|
385
|
+
| Confirmed r2 — first-load failure preserves previous behavior | processing starts null at :21; fallback :40 -> loaded; test :123-133, R2-E1. | PASS |
|
|
386
|
+
| Confirmed r2 regression — non-submitted root guard unchanged | Root :159 and hasNoBank :226-227 unchanged; test :135-149 and R2-E3. Other non-submitted states inspected only. | PASS |
|
|
387
|
+
| Conditional SDK WebSocket filter relaxation (spec-snapshot.md:77) | src/machine/websocket.js:296-301 already forwards payment-info without a toast filter; no additional filter patch required on this static criterion. Real payload behavior is unverified. | PASS |
|
|
388
|
+
| Full cash UI / WebSocket strict-ID / published-package integration | Outside SDK repo review; cash flow owns verification. | NOT RUN |
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## 📋 Standards Checklist (Summary)
|
|
393
|
+
|
|
394
|
+
| Category | Result | Notes |
|
|
395
|
+
| ------------------- | ------- | ------------------------------------------------------------------------------------------------------------- |
|
|
396
|
+
| XState v4 / context | PASS | Reuses isProcessing; rejection adds no assignment; successful onDone unchanged. |
|
|
397
|
+
| Correctness | PASS | All selected whole-change SDK acceptance cases pass; F-r1-01 independently verified again during convergence. |
|
|
398
|
+
| Security | NOT RUN | No wider security audit; no auth/request-boundary edits or remote requests. |
|
|
399
|
+
| Performance | PASS | Static inspection: no new timer, loop or dependency; retries remain explicit REFRESH events. No benchmark. |
|
|
400
|
+
| Project Conventions | PASS | Minimal guarded transition fits existing checking pattern; whitespace check passes. No formatter/lint run. |
|
|
401
|
+
|
|
402
|
+
## Conclusion
|
|
403
|
+
|
|
404
|
+
The fresh r2 convergence reviewer independently checked the complete base-to-working-tree change before reading prior review records and found no additional product-code defect. F-r1-01 remains ACCEPT + verified in r2 yes. Targeted tests pass 6/6, the old-onError negative control fails exactly the new retry case as expected, and both root guard boundaries pass. The r2 Impact block now covers the whole change with one line for each of the three internal consumers. This independent review is complete within the assigned SDK scope. The driver must run check-review.sh and update STATE; this report does not declare loop convergence or readiness to publish.
|
|
405
|
+
|
|
406
|
+
Limits: injected local ERR_998 responses exercise the real initializer but not transport/backend, cash rendering, real WebSocket payloads, published-package wiring, alternate wallet gates, OTP, exhaustive non-submitted events or other errors. No browser ran, so browser exceptions were not assessed. ps -eo pid,rss,command was denied (operation not permitted); no server/background process started, all Node commands exited. Only three assigned review files were written; STATE remains the driver's responsibility. Convergence pre-edit backups: /var/folders/s8/rjb4nddx2f1c_nl7p_wwz8kh0000gn/T/TI-16026-cuora-r2-convergence.iivyDMK8Pm/.
|
|
407
|
+
|
|
408
|
+
**Overall Result:** PASS
|
package/scripts/auto-version.js
CHANGED
|
@@ -14,8 +14,15 @@ const { version } = JSON.parse(readFileSync('package.json', 'utf8'))
|
|
|
14
14
|
console.log(`Branch: ${branch}`)
|
|
15
15
|
console.log(`Version: ${version}`)
|
|
16
16
|
|
|
17
|
-
// 推送 commit
|
|
18
|
-
execSync(`git push --no-verify
|
|
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
|
+
}
|
|
19
26
|
|
|
20
27
|
// 發布到 npm,使用分支名稱作為 dist-tag(例如 npm install @jetthai/cuora@dev)
|
|
21
28
|
try {
|
package/src/api/payment.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import user from '../api/user.js'
|
|
3
3
|
import otp from '../api/otp.js'
|
|
4
|
+
import { AUTO_VERIFY_MAX_USER_INFO_UPDATES, AUTO_VERIFY_WAIT_MS } from '../util/constant.js'
|
|
5
|
+
|
|
6
|
+
function isStrategyVerified(strategy, userInfo) {
|
|
7
|
+
if (strategy === 'phone') return !!(userInfo?.phone || userInfo?.tel) && !!userInfo?.phone_verification_status
|
|
8
|
+
if (strategy === 'email') return !!userInfo?.email && !!userInfo?.email_verification_status
|
|
9
|
+
return false
|
|
10
|
+
}
|
|
4
11
|
|
|
5
12
|
export default function (request) {
|
|
6
13
|
return createMachine(
|
|
@@ -18,6 +25,7 @@ export default function (request) {
|
|
|
18
25
|
requestId: null,
|
|
19
26
|
status: null,
|
|
20
27
|
ttl: 0,
|
|
28
|
+
autoVerifyUpdates: 0,
|
|
21
29
|
},
|
|
22
30
|
states: {
|
|
23
31
|
idle: {
|
|
@@ -48,16 +56,44 @@ export default function (request) {
|
|
|
48
56
|
{ target: 'notVerified', cond: 'isNotVerified' },
|
|
49
57
|
],
|
|
50
58
|
},
|
|
59
|
+
autoVerifying: {
|
|
60
|
+
invoke: {
|
|
61
|
+
src: 'fetchUserInfo',
|
|
62
|
+
onDone: {
|
|
63
|
+
target: 'checkingAutoVerification',
|
|
64
|
+
actions: 'setUserInfo',
|
|
65
|
+
},
|
|
66
|
+
onError: { target: 'fail' },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
checkingAutoVerification: {
|
|
70
|
+
always: [{ target: 'verified', cond: 'isVerified' }, { target: 'autoVerifyWaiting' }],
|
|
71
|
+
},
|
|
72
|
+
// 後端寫入驗證狀態到 /self 反映之間有延遲(主動打的那次可能還是舊值),
|
|
73
|
+
// 改等下游轉送 auth 例行輪詢的 /self 結果,不另開輪詢以免重複打 /self
|
|
74
|
+
autoVerifyWaiting: {
|
|
75
|
+
entry: 'resetAutoVerifyUpdates',
|
|
76
|
+
after: {
|
|
77
|
+
AUTO_VERIFY_TIMEOUT: { target: 'fail' },
|
|
78
|
+
},
|
|
79
|
+
on: {
|
|
80
|
+
USER_INFO_UPDATED: [
|
|
81
|
+
{ target: 'verified', cond: 'isUpdatedUserInfoVerified', actions: 'setUserInfo' },
|
|
82
|
+
{ target: 'fail', cond: 'isLastAutoVerifyUpdate', actions: 'setUserInfo' },
|
|
83
|
+
{ actions: ['setUserInfo', 'countAutoVerifyUpdate'] },
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
51
87
|
notVerified: {
|
|
52
88
|
initial: 'checkingStatus',
|
|
53
89
|
states: {
|
|
54
90
|
checkingStatus: {
|
|
55
91
|
invoke: {
|
|
56
92
|
src: 'verify',
|
|
57
|
-
onDone:
|
|
58
|
-
target: '
|
|
59
|
-
actions: 'setVerificationData',
|
|
60
|
-
|
|
93
|
+
onDone: [
|
|
94
|
+
{ target: '#auth_otp.autoVerifying', cond: 'doesNotNeedAcknowledge' },
|
|
95
|
+
{ target: 'otp', actions: 'setVerificationData' },
|
|
96
|
+
],
|
|
61
97
|
onError: {
|
|
62
98
|
target: 'errorChecking',
|
|
63
99
|
actions: 'setError',
|
|
@@ -86,20 +122,20 @@ export default function (request) {
|
|
|
86
122
|
sendingPhone: {
|
|
87
123
|
invoke: {
|
|
88
124
|
src: 'sendPhone',
|
|
89
|
-
onDone:
|
|
90
|
-
target: '
|
|
91
|
-
actions: 'setVerificationData',
|
|
92
|
-
|
|
125
|
+
onDone: [
|
|
126
|
+
{ target: '#auth_otp.autoVerifying', cond: 'doesNotNeedAcknowledge' },
|
|
127
|
+
{ target: 'otp', actions: 'setVerificationData' },
|
|
128
|
+
],
|
|
93
129
|
onError: { target: 'phone' },
|
|
94
130
|
},
|
|
95
131
|
},
|
|
96
132
|
sendingEmail: {
|
|
97
133
|
invoke: {
|
|
98
134
|
src: 'sendEmail',
|
|
99
|
-
onDone:
|
|
100
|
-
target: '
|
|
101
|
-
actions: 'setVerificationData',
|
|
102
|
-
|
|
135
|
+
onDone: [
|
|
136
|
+
{ target: '#auth_otp.autoVerifying', cond: 'doesNotNeedAcknowledge' },
|
|
137
|
+
{ target: 'otp', actions: 'setVerificationData' },
|
|
138
|
+
],
|
|
103
139
|
onError: { target: 'email' },
|
|
104
140
|
},
|
|
105
141
|
},
|
|
@@ -163,6 +199,9 @@ export default function (request) {
|
|
|
163
199
|
},
|
|
164
200
|
},
|
|
165
201
|
{
|
|
202
|
+
delays: {
|
|
203
|
+
AUTO_VERIFY_TIMEOUT: AUTO_VERIFY_WAIT_MS,
|
|
204
|
+
},
|
|
166
205
|
actions: {
|
|
167
206
|
setStrategy: assign((context, event) => {
|
|
168
207
|
return {
|
|
@@ -193,6 +232,8 @@ export default function (request) {
|
|
|
193
232
|
ttl: Math.max(ms - 1000, 0),
|
|
194
233
|
}
|
|
195
234
|
}),
|
|
235
|
+
resetAutoVerifyUpdates: assign(() => ({ autoVerifyUpdates: 0 })),
|
|
236
|
+
countAutoVerifyUpdate: assign((context) => ({ autoVerifyUpdates: context.autoVerifyUpdates + 1 })),
|
|
196
237
|
setError: assign((context, event) => {
|
|
197
238
|
return {
|
|
198
239
|
error: event.data,
|
|
@@ -213,12 +254,10 @@ export default function (request) {
|
|
|
213
254
|
}),
|
|
214
255
|
},
|
|
215
256
|
guards: {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
return false
|
|
221
|
-
},
|
|
257
|
+
doesNotNeedAcknowledge: (context, event) => event.data?.needAcknowledge === false,
|
|
258
|
+
isVerified: (context, event) => isStrategyVerified(context.strategy, context.userInfo),
|
|
259
|
+
isUpdatedUserInfoVerified: (context, event) => isStrategyVerified(context.strategy, event.data),
|
|
260
|
+
isLastAutoVerifyUpdate: (context, event) => context.autoVerifyUpdates + 1 >= AUTO_VERIFY_MAX_USER_INFO_UPDATES,
|
|
222
261
|
isNotVerified: (context, event) => {
|
|
223
262
|
const { strategy, userInfo } = context
|
|
224
263
|
if (!userInfo) return false
|
|
@@ -228,11 +267,11 @@ export default function (request) {
|
|
|
228
267
|
},
|
|
229
268
|
isPhoneNotVerified: (context, event) => {
|
|
230
269
|
const { strategy, userInfo } = context
|
|
231
|
-
return strategy === 'phone' && !!userInfo && !userInfo.
|
|
270
|
+
return strategy === 'phone' && !!userInfo && !(userInfo.phone || userInfo.tel)
|
|
232
271
|
},
|
|
233
272
|
isEmailNotVerified: (context, event) => {
|
|
234
273
|
const { strategy, userInfo } = context
|
|
235
|
-
return strategy === 'email' && !!userInfo && !userInfo.
|
|
274
|
+
return strategy === 'email' && !!userInfo && !userInfo.email
|
|
236
275
|
},
|
|
237
276
|
hasNoPhone: (context, event) => {
|
|
238
277
|
const { error } = context
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { createMachine, assign } from 'xstate'
|
|
2
2
|
import activity from '../api/activity.js'
|
|
3
3
|
|
|
4
|
+
const TAB_KEY_BY_TYPE = {
|
|
5
|
+
CASH_RAIN: 'cashRain',
|
|
6
|
+
DEPOSIT: 'deposit',
|
|
7
|
+
FREE_ROULETTE_SPIN: 'roulette',
|
|
8
|
+
JACKPOT: 'jackpot',
|
|
9
|
+
WIN_SCORE: 'bigWin',
|
|
10
|
+
WIN_MULTIPLIER: 'maxBet',
|
|
11
|
+
WITHDRAW: 'withdraw',
|
|
12
|
+
LATEST_BET: 'latestBet',
|
|
13
|
+
}
|
|
14
|
+
|
|
4
15
|
export default function (request) {
|
|
5
16
|
const { appSecret } = request.config
|
|
6
17
|
return createMachine(
|
|
@@ -17,6 +28,7 @@ export default function (request) {
|
|
|
17
28
|
bigWin: {},
|
|
18
29
|
maxBet: {},
|
|
19
30
|
withdraw: {},
|
|
31
|
+
latestBet: {},
|
|
20
32
|
},
|
|
21
33
|
states: {
|
|
22
34
|
fetching: {
|
|
@@ -44,24 +56,8 @@ export default function (request) {
|
|
|
44
56
|
actions: {
|
|
45
57
|
setHonorBoardList: assign((context, event) => {
|
|
46
58
|
return {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
case 'CASH_RAIN':
|
|
50
|
-
return 'cashRain'
|
|
51
|
-
case 'DEPOSIT':
|
|
52
|
-
return 'deposit'
|
|
53
|
-
case 'FREE_ROULETTE_SPIN':
|
|
54
|
-
return 'roulette'
|
|
55
|
-
case 'JACKPOT':
|
|
56
|
-
return 'jackpot'
|
|
57
|
-
case 'WIN_SCORE':
|
|
58
|
-
return 'bigWin'
|
|
59
|
-
case 'WIN_MULTIPLIER':
|
|
60
|
-
return 'maxBet'
|
|
61
|
-
case 'WITHDRAW':
|
|
62
|
-
return 'withdraw'
|
|
63
|
-
}
|
|
64
|
-
}),
|
|
59
|
+
// 後端新增的類型若尚未對應 tab key,略過以免產生 undefined tab
|
|
60
|
+
tabs: (event.data || []).map((list) => TAB_KEY_BY_TYPE[list.type]).filter(Boolean),
|
|
65
61
|
cashRain: (event.data || []).find((item) => item.type === 'CASH_RAIN') || {},
|
|
66
62
|
deposit: (event.data || []).find((item) => item.type === 'DEPOSIT') || {},
|
|
67
63
|
roulette: (event.data || []).find((item) => item.type === 'FREE_ROULETTE_SPIN') || {},
|
|
@@ -69,6 +65,7 @@ export default function (request) {
|
|
|
69
65
|
bigWin: (event.data || []).find((item) => item.type === 'WIN_SCORE') || {},
|
|
70
66
|
maxBet: (event.data || []).find((item) => item.type === 'WIN_MULTIPLIER') || {},
|
|
71
67
|
withdraw: (event.data || []).find((item) => item.type === 'WITHDRAW') || {},
|
|
68
|
+
latestBet: (event.data || []).find((item) => item.type === 'LATEST_BET') || {},
|
|
72
69
|
}
|
|
73
70
|
}),
|
|
74
71
|
},
|