axm0121 commited on
Commit
ac3f217
·
verified ·
1 Parent(s): ef194a6

Adapt iDEAL UI and submitted proxy pools

Browse files

Use the opll frontend structure, remove Provider input, and route Checkout and Promotion through separate required submitted pools.

Files changed (3) hide show
  1. README.md +7 -9
  2. src/index.html +406 -1004
  3. src/lib.rs +262 -70
README.md CHANGED
@@ -24,9 +24,9 @@ Configure the following Space Secret before starting the container:
24
 
25
  Optional Secrets:
26
 
27
- - `OPENAI_PAY_DEFAULT_PROXY`: required for live extraction requests. The UI,
28
- database migration, authentication, and health endpoint can start without it,
29
- but extraction will fail until it is configured.
30
  - `LINUXDO_CLIENT_ID`, `LINUXDO_CLIENT_SECRET`, and `LINUXDO_REDIRECT_URI`: only
31
  needed when LinuxDo OAuth is enabled.
32
 
@@ -40,10 +40,8 @@ the Hugging Face Space settings and must not be committed to this repository.
40
  - currency: `EUR`
41
  - checkout UI mode: `custom`
42
  - client fingerprint: `apple-safari`
43
- - NL bootstrap checkout proxy region: `NL`
44
- - promotion update proxy region: `VN`
45
- - provider proxy region: `NL`
46
- - approve proxy region: `NL`
47
  - approve attempts: `20`
48
  - approve concurrency: `1`
49
 
@@ -66,10 +64,10 @@ Direct CLI extraction is not available; extraction is intentionally exposed only
66
  - `GET /api/auth/me` to read the current LinuxDo user, CDK, and remaining uses.
67
  - `POST /api/auth/logout` to clear the local session.
68
  - `POST /api/cdk/bind` with `{ "cdk" }` to activate a browser session with a CDK when not logged in, or to bind a pre-provisioned CDK after the active CDK is exhausted and no jobs are pending.
69
- - `POST /api/extract` with `{ "access_token" }` to enqueue a job.
70
  - `GET /api/extract/{job_id}` to poll queued/running/completed status.
71
 
72
- The server binds to the address you pass with `--listen`. Use loopback (`IP_REDACTED` or `localhost`) for local operation; the UI does not print the access token in the result view. Browser extraction loads the proxy from `.env` using `OPENAI_PAY_DEFAULT_PROXY`. The web API runs extraction through a bounded FIFO queue so concurrent browser submissions do not execute all at once; excess accepted jobs show queued status, and a full queue returns HTTP `429`.
73
 
74
  Extraction requests without an activated CDK/session return HTTP `401`. Activated users with no remaining CDK uses receive HTTP `403`.
75
 
 
24
 
25
  Optional Secrets:
26
 
27
+ - `OPENAI_PAY_DEFAULT_PROXY`: retained only for legacy/internal compatibility.
28
+ Browser extraction requires the operator to submit both the Checkout and
29
+ Promotion Update proxy pools in the page instead of reading this Secret.
30
  - `LINUXDO_CLIENT_ID`, `LINUXDO_CLIENT_SECRET`, and `LINUXDO_REDIRECT_URI`: only
31
  needed when LinuxDo OAuth is enabled.
32
 
 
40
  - currency: `EUR`
41
  - checkout UI mode: `custom`
42
  - client fingerprint: `apple-safari`
43
+ - Checkout/Stripe/provider/approve route: selected from the submitted Checkout pool
44
+ - promotion update route: selected from the submitted Promotion Update pool
 
 
45
  - approve attempts: `20`
46
  - approve concurrency: `1`
47
 
 
64
  - `GET /api/auth/me` to read the current LinuxDo user, CDK, and remaining uses.
65
  - `POST /api/auth/logout` to clear the local session.
66
  - `POST /api/cdk/bind` with `{ "cdk" }` to activate a browser session with a CDK when not logged in, or to bind a pre-provisioned CDK after the active CDK is exhausted and no jobs are pending.
67
+ - `POST /api/extract` with `{ "access_token", "checkout_proxy_pool", "promotion_proxy_pool" }` to enqueue a job. Both proxy pools are required newline-delimited strings.
68
  - `GET /api/extract/{job_id}` to poll queued/running/completed status.
69
 
70
+ The server binds to the address you pass with `--listen`. Use loopback (`IP_REDACTED` or `localhost`) for local operation; the UI does not print the access token or proxy credentials in the result view. Browser extraction reads two required proxy pools from the request: one Checkout route reused for Checkout, Stripe, tax, provider resolution, and approve within an attempt, plus one Promotion Update route used only for that update call. The web API runs extraction through a bounded FIFO queue so concurrent browser submissions do not execute all at once; excess accepted jobs show queued status, and a full queue returns HTTP `429`.
71
 
72
  Extraction requests without an activated CDK/session return HTTP `401`. Activated users with no remaining CDK uses receive HTTP `403`.
73
 
src/index.html CHANGED
@@ -5,1090 +5,492 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
  <link rel="icon" href="data:," />
7
  <title>iDEAL 链接提取器</title>
8
- <link rel="preconnect" href="https://fonts.googleapis.com">
9
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
11
  <style>
12
  :root {
13
- --bg-gradient-start: #000000;
14
- --bg-gradient-end: #0a0a0a;
15
- --surface: rgba(20, 20, 20, 0.6);
16
- --surface-solid: #111111;
17
- --ink: #f8fafc;
18
- --ink-muted: #94a3b8;
19
- --border: rgba(255, 255, 255, 0.1);
20
- --border-hover: rgba(255, 255, 255, 0.2);
21
- --accent: #3b82f6;
22
- --accent-hover: #60a5fa;
23
- --accent-glow: rgba(59, 130, 246, 0.6);
24
- --ok: #10b981;
25
- --ok-bg: rgba(16, 185, 129, 0.1);
26
- --bad: #ef4444;
27
- --bad-bg: rgba(239, 68, 68, 0.1);
28
- --warning: #f59e0b;
29
-
30
- --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
31
- --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
32
-
33
- --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
34
- --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.6), 0 2px 4px -1px rgba(0, 0, 0, 0.4);
35
- --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.8), 0 10px 10px -5px rgba(0, 0, 0, 0.6);
36
- --shadow-glow: 0 0 20px var(--accent-glow);
37
-
38
- --radius-sm: 8px;
39
- --radius-md: 16px;
40
- --radius-lg: 24px;
41
- --radius-full: 9999px;
42
- }
43
-
44
- * {
45
- box-sizing: border-box;
46
- }
47
 
48
  body {
49
  margin: 0;
50
- background-color: #000000;
51
- background-image:
52
- radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
53
- radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 25%);
54
- color: var(--ink);
55
- font-family: var(--font-ui);
56
- -webkit-font-smoothing: antialiased;
57
  min-height: 100vh;
58
- display: flex;
59
- justify-content: center;
60
- align-items: center;
61
- padding: 40px 20px;
62
- position: relative;
63
- overflow-x: hidden;
64
- }
65
-
66
- /* Noise overlay for premium texture */
67
- body::before {
68
- content: "";
69
- position: fixed;
70
- top: 0; left: 0; width: 100vw; height: 100vh;
71
- background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
72
- opacity: 0.03;
73
- z-index: 9999;
74
- pointer-events: none;
75
- }
76
-
77
- main.layout {
78
- display: grid;
79
- grid-template-columns: 320px 1fr;
80
- width: 100%;
81
- max-width: 1100px;
82
- background: var(--surface);
83
- backdrop-filter: blur(24px);
84
- -webkit-backdrop-filter: blur(24px);
85
- border: 1px solid var(--border);
86
- border-radius: var(--radius-lg);
87
- box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.05);
88
- min-height: 650px;
89
- overflow: hidden;
90
- transition: all 0.3s ease;
91
- }
92
-
93
- @media (max-width: 860px) {
94
- main.layout {
95
- grid-template-columns: 1fr;
96
- min-height: auto;
97
- }
98
- }
99
-
100
- .sidebar {
101
- padding: 40px 32px;
102
- border-right: 1px solid var(--border);
103
- display: flex;
104
- flex-direction: column;
105
- background: rgba(10, 10, 10, 0.4);
106
- z-index: 1;
107
- }
108
-
109
- @media (max-width: 860px) {
110
- .sidebar {
111
- border-right: none;
112
- border-bottom: 1px solid var(--border);
113
- padding: 32px 24px;
114
- }
115
- }
116
-
117
- .brand {
118
- margin-bottom: 40px;
119
  }
120
 
121
- .brand h1 {
122
- font-size: 32px;
123
- font-weight: 800;
124
- margin: 0;
125
- background: linear-gradient(to right, #fff, #a1a1aa);
126
- -webkit-background-clip: text;
127
- -webkit-text-fill-color: transparent;
128
- letter-spacing: -0.03em;
129
- display: inline-block;
130
- }
131
-
132
- .brand p {
133
- margin: 4px 0 0 0;
134
- font-size: 13px;
135
- color: var(--accent);
136
- font-weight: 600;
137
- letter-spacing: 0.05em;
138
- text-transform: uppercase;
139
  }
140
 
141
- .account-section {
142
  display: flex;
143
- align-items: center;
144
  justify-content: space-between;
145
- font-size: 14px;
146
- margin-bottom: 24px;
147
- padding-bottom: 24px;
148
- border-bottom: 1px solid var(--border);
149
  }
150
 
151
- .account-status {
152
- display: flex;
153
- align-items: center;
154
- gap: 8px;
155
- }
156
 
157
- .status-dot {
158
- width: 8px;
159
- height: 8px;
160
- border-radius: 50%;
161
- background: var(--ink-muted);
162
- transition: background 0.3s ease;
163
- }
164
-
165
- .account-status.logged-in .status-dot {
166
- background: var(--ok);
167
- box-shadow: 0 0 10px rgba(16, 185, 129, 0.8);
168
  }
169
 
170
- #account-note {
171
- font-weight: 500;
172
- color: var(--ink-muted);
173
- }
174
- .account-status.logged-in #account-note {
175
- color: var(--ink);
176
  }
177
 
178
- #account-pill {
179
- font-weight: 600;
180
- color: var(--ink);
181
- background: rgba(255, 255, 255, 0.1);
182
- padding: 4px 10px;
183
- border-radius: var(--radius-full);
184
- font-size: 12px;
185
- border: 1px solid rgba(255, 255, 255, 0.05);
186
- }
187
 
188
- #auth-panel {
189
- margin-bottom: 40px;
190
- }
 
191
 
192
- .btn {
193
- display: inline-flex;
194
- justify-content: center;
195
- align-items: center;
196
- gap: 8px;
197
- padding: 12px 20px;
198
- font-size: 14px;
199
- font-weight: 600;
200
- border-radius: var(--radius-md);
201
- text-decoration: none;
202
- cursor: pointer;
203
- transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
204
- border: 1px solid transparent;
205
  width: 100%;
206
- outline: none;
207
- }
208
-
209
- .btn:disabled {
210
- opacity: 0.5;
211
- cursor: not-allowed;
212
- pointer-events: none;
213
- }
214
-
215
- .btn:active:not(:disabled) {
216
- transform: scale(0.97);
217
- }
218
-
219
- .btn-primary {
220
- background: var(--ink);
221
- color: #000;
222
- box-shadow: var(--shadow-sm);
223
- }
224
-
225
- .btn-primary:hover:not(:disabled) {
226
  background: #fff;
227
- box-shadow: 0 0 20px rgba(255,255,255,0.2);
228
- }
229
-
230
- .btn-secondary {
231
- background: rgba(255,255,255,0.05);
232
- color: var(--ink);
233
- border: 1px solid var(--border);
234
- box-shadow: var(--shadow-sm);
235
- }
236
-
237
- .btn-secondary:hover:not(:disabled) {
238
- background: rgba(255,255,255,0.1);
239
- border-color: var(--border-hover);
240
- }
241
-
242
- .btn-danger {
243
- background: rgba(239, 68, 68, 0.12);
244
- color: #fecaca;
245
- border: 1px solid rgba(239, 68, 68, 0.35);
246
- box-shadow: var(--shadow-sm);
247
- }
248
-
249
- .btn-danger:hover:not(:disabled) {
250
- background: rgba(239, 68, 68, 0.2);
251
- border-color: rgba(239, 68, 68, 0.55);
252
- }
253
-
254
- .btn-ghost {
255
- background: transparent;
256
- color: var(--ink-muted);
257
- font-size: 13px;
258
- padding: 6px 12px;
259
- width: auto;
260
- font-weight: 500;
261
- }
262
-
263
- .btn-ghost:hover {
264
- color: var(--ink);
265
- background: rgba(255, 255, 255, 0.1);
266
- }
267
-
268
- .btn-ghost.hidden {
269
- display: none !important;
270
- }
271
-
272
- .cdk-section {
273
- display: flex;
274
- flex-direction: column;
275
- gap: 20px;
276
- margin-top: auto;
277
- }
278
-
279
- .quota-display {
280
- font-family: var(--font-mono);
281
- font-size: 13px;
282
- line-height: 1.6;
283
- padding: 16px;
284
- background: rgba(0, 0, 0, 0.4);
285
- border: 1px solid var(--border);
286
- border-radius: var(--radius-md);
287
- color: var(--ink);
288
- white-space: pre-line;
289
- }
290
-
291
- .cdk-form {
292
- display: flex;
293
- flex-direction: column;
294
- gap: 8px;
295
- }
296
-
297
- .cdk-form label {
298
- font-size: 12px;
299
- font-weight: 600;
300
- color: var(--ink-muted);
301
- text-transform: uppercase;
302
- letter-spacing: 0.05em;
303
- margin-left: 2px;
304
- }
305
-
306
- .cdk-input-group {
307
- display: flex;
308
- position: relative;
309
- }
310
-
311
- #cdk-input {
312
- flex: 1;
313
- background: rgba(0, 0, 0, 0.4);
314
- border: 1px solid var(--border);
315
- padding: 12px 44px 12px 16px;
316
- border-radius: var(--radius-md);
317
- font-family: var(--font-mono);
318
- font-size: 13px;
319
  color: var(--ink);
 
 
320
  outline: none;
321
- min-width: 0;
322
- transition: all 0.2s;
323
  }
324
 
325
- #cdk-input:focus {
326
- border-color: var(--ink);
327
- background: rgba(255, 255, 255, 0.05);
328
- }
329
-
330
- #cdk-input:disabled {
331
- background: rgba(0, 0, 0, 0.2);
332
- color: var(--ink-muted);
333
- }
334
-
335
- #cdk-input::placeholder {
336
- color: var(--ink-muted);
337
- }
338
 
339
- #bind-cdk {
340
- position: absolute;
341
- right: 4px;
342
- top: 4px;
343
- bottom: 4px;
344
- width: 36px;
345
- background: var(--ink);
346
- color: #000;
347
- border: none;
348
- border-radius: calc(var(--radius-md) - 4px);
349
- cursor: pointer;
350
- display: flex;
351
  align-items: center;
352
- justify-content: center;
353
- transition: all 0.2s;
354
- }
355
-
356
- #bind-cdk:hover:not(:disabled) {
357
- background: #fff;
358
- box-shadow: 0 0 10px rgba(255,255,255,0.2);
359
- }
360
-
361
- #bind-cdk:disabled {
362
- background: rgba(255,255,255,0.1);
363
- cursor: not-allowed;
364
- color: var(--ink-muted);
365
- }
366
-
367
- .meta-text {
368
- font-size: 13px;
369
- color: var(--ink-muted);
370
- line-height: 1.6;
371
- margin: 0;
372
- padding: 12px;
373
- background: rgba(0, 0, 0, 0.3);
374
- border-radius: var(--radius-md);
375
- border: 1px solid var(--border);
376
- }
377
-
378
- .main-content {
379
- padding: 48px 56px;
380
- display: flex;
381
- flex-direction: column;
382
- background: transparent;
383
- position: relative;
384
- }
385
-
386
- @media (max-width: 860px) {
387
- .main-content {
388
- padding: 32px 24px;
389
- }
390
- }
391
-
392
- .extract-form {
393
- display: flex;
394
- flex-direction: column;
395
- min-height: 0;
396
- }
397
-
398
- .input-group {
399
- display: flex;
400
- flex-direction: column;
401
  gap: 12px;
402
- flex: 1;
 
403
  }
404
 
405
- .input-group label {
406
- font-size: 16px;
407
- font-weight: 600;
408
- color: var(--ink);
409
- display: flex;
410
- align-items: center;
411
- gap: 8px;
412
- }
413
-
414
- .input-group label::before {
415
- content: "";
416
- display: inline-block;
417
- width: 4px;
418
- height: 16px;
419
- background: var(--ink);
420
- border-radius: 2px;
421
- }
422
-
423
- .mode-group {
424
- display: grid;
425
- grid-template-columns: repeat(2, minmax(0, 1fr));
426
- gap: 6px;
427
- width: min(320px, 100%);
428
- padding: 4px;
429
- margin-bottom: 18px;
430
- border: 1px solid var(--border);
431
- border-radius: var(--radius-md);
432
- background: rgba(0, 0, 0, 0.3);
433
- }
434
-
435
- .mode-button {
436
- min-height: 38px;
437
- border: 0;
438
- border-radius: calc(var(--radius-md) - 3px);
439
- background: transparent;
440
- color: var(--ink-muted);
441
- font: inherit;
442
- font-size: 13px;
443
- font-weight: 700;
444
- cursor: pointer;
445
- }
446
-
447
- .mode-button.active {
448
- background: var(--ink);
449
- color: #000;
450
- box-shadow: 0 6px 18px rgba(255, 255, 255, 0.12);
451
- }
452
 
453
- .mode-button:disabled {
454
- cursor: not-allowed;
455
- opacity: 0.55;
456
- }
457
-
458
- #access-token {
459
- flex: 1;
460
- min-height: 280px;
461
- background: rgba(0, 0, 0, 0.4);
462
- border: 1px solid var(--border);
463
- border-radius: var(--radius-md);
464
- padding: 20px;
465
- font-family: var(--font-mono);
466
- font-size: 14px;
467
- line-height: 1.6;
468
- color: var(--ink);
469
- resize: vertical;
470
- outline: none;
471
- transition: all 0.2s ease;
472
- }
473
-
474
- #access-token:focus {
475
- border-color: var(--ink);
476
- background: rgba(255, 255, 255, 0.02);
477
- }
478
-
479
- #access-token:disabled {
480
- background: rgba(0, 0, 0, 0.2);
481
- color: var(--ink-muted);
482
- }
483
-
484
- #access-token::placeholder {
485
- color: var(--ink-muted);
486
- }
487
-
488
- .actions-row {
489
- display: flex;
490
- align-items: center;
491
- gap: 16px;
492
- margin-top: 24px;
493
- flex-wrap: wrap;
494
- }
495
-
496
- .actions-row .btn {
497
- width: auto;
498
- min-width: 120px;
499
- }
500
-
501
- .status-msg {
502
- font-size: 13px;
503
- font-weight: 500;
504
- display: flex;
505
  align-items: center;
506
- gap: 6px;
507
- animation: fadeIn 0.3s ease;
508
- }
509
-
510
- .status-msg:empty {
511
- display: none;
512
- }
513
-
514
- @keyframes fadeIn {
515
- from { opacity: 0; transform: translateY(-4px); }
516
- to { opacity: 1; transform: translateY(0); }
517
- }
518
-
519
- .status-msg.error {
520
- color: var(--bad);
521
- }
522
-
523
- .status-msg.ok {
524
- color: var(--ok);
525
- }
526
-
527
- .status-msg.queued,
528
- .status-msg.running {
529
- color: var(--warning);
530
- }
531
-
532
- .spinner {
533
- display: inline-block;
534
- width: 14px;
535
- height: 14px;
536
- border: 2px solid currentColor;
537
- border-right-color: transparent;
538
- border-radius: 50%;
539
- animation: spin 0.75s linear infinite;
540
- }
541
-
542
- @keyframes spin {
543
- 100% { transform: rotate(360deg); }
544
- }
545
-
546
- .progress-log {
547
- margin-top: 24px;
548
- padding: 18px;
549
- background: rgba(0, 0, 0, 0.35);
550
- border: 1px solid var(--border);
551
- border-radius: var(--radius-md);
552
- max-height: 260px;
553
- overflow-y: auto;
554
- animation: fadeIn 0.3s ease;
555
- }
556
-
557
- .progress-log-title {
558
- margin-bottom: 14px;
559
- font-size: 13px;
560
- font-weight: 700;
561
- color: var(--ink);
562
- }
563
-
564
- .progress-list {
565
- list-style: none;
566
- margin: 0;
567
- padding: 0;
568
- display: flex;
569
- flex-direction: column;
570
- gap: 12px;
571
- }
572
-
573
- .progress-item {
574
- display: grid;
575
- grid-template-columns: 18px minmax(0, 1fr);
576
- gap: 10px;
577
- align-items: start;
578
- color: var(--ink-muted);
579
- font-size: 13px;
580
- }
581
-
582
- .progress-dot {
583
- width: 9px;
584
- height: 9px;
585
- border-radius: 50%;
586
- margin-top: 5px;
587
- background: var(--ink-muted);
588
- }
589
-
590
- .progress-item.ok .progress-dot {
591
- background: var(--ok);
592
- box-shadow: 0 0 8px rgba(16, 185, 129, 0.55);
593
- }
594
-
595
- .progress-item.queued .progress-dot,
596
- .progress-item.running .progress-dot,
597
- .progress-item.warn .progress-dot {
598
- background: var(--warning);
599
- box-shadow: 0 0 8px rgba(245, 158, 11, 0.45);
600
- }
601
-
602
- .progress-item.info .progress-dot {
603
- background: var(--accent);
604
- box-shadow: 0 0 8px rgba(59, 130, 246, 0.45);
605
- }
606
-
607
- .progress-item.running .progress-dot {
608
- animation: pulse 1s ease-in-out infinite;
609
- }
610
-
611
- .progress-item.error .progress-dot {
612
- background: var(--bad);
613
- box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
614
- }
615
-
616
- @keyframes pulse {
617
- 0%, 100% { opacity: 0.45; transform: scale(0.85); }
618
- 50% { opacity: 1; transform: scale(1); }
619
- }
620
-
621
- .progress-name {
622
- color: var(--ink);
623
- font-weight: 600;
624
- line-height: 1.4;
625
- }
626
-
627
- .progress-detail {
628
- margin-top: 3px;
629
- color: var(--ink-muted);
630
- font-family: var(--font-mono);
631
- font-size: 12px;
632
- line-height: 1.5;
633
- word-break: break-all;
634
- }
635
-
636
- #result {
637
- margin-top: 32px;
638
- padding: 24px;
639
- background: rgba(16, 185, 129, 0.05);
640
- border: 1px solid rgba(16, 185, 129, 0.2);
641
- border-radius: var(--radius-md);
642
- display: none;
643
- animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
644
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
645
- position: relative;
646
- overflow: visible;
647
- min-height: fit-content;
648
- }
649
-
650
- #result::before {
651
- content: "";
652
- position: absolute;
653
- top: 0; left: 0; width: 4px; height: 100%;
654
- background: var(--ok);
655
- box-shadow: 0 0 10px var(--ok);
656
- }
657
-
658
- @keyframes slideUp {
659
- from { opacity: 0; transform: translateY(10px); }
660
- to { opacity: 1; transform: translateY(0); }
661
- }
662
-
663
- #result.visible {
664
- display: block;
665
- }
666
-
667
- .result-url {
668
- font-family: var(--font-mono);
669
- font-size: 14px;
670
- color: #34d399;
671
- text-decoration: none;
672
- word-break: break-all;
673
- overflow-wrap: anywhere;
674
- line-height: 1.6;
675
- display: block;
676
- font-weight: 500;
677
- padding-bottom: 2px;
678
- }
679
-
680
- .result-url:hover {
681
- text-decoration: underline;
682
- text-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
683
- }
684
-
685
- .hidden {
686
- display: none !important;
687
- }
688
-
689
- main.layout.auth-only {
690
- grid-template-columns: minmax(320px, 440px);
691
- max-width: 440px;
692
- min-height: 400px;
693
- margin: 0 auto;
694
  }
695
 
696
- main.layout.auth-only .sidebar {
697
- border-right: none;
698
- padding: 48px 40px;
699
- }
 
 
 
 
 
700
 
701
- main.layout.auth-only .account-section,
702
- main.layout.auth-only .cdk-section,
703
- main.layout.auth-only .main-content {
704
- display: none;
705
- }
706
-
707
- #login {
708
  display: flex;
709
- justify-content: center;
 
710
  gap: 12px;
711
- font-size: 15px;
712
- padding: 14px 24px;
713
- }
714
-
715
- #login svg {
716
- width: 20px;
717
- height: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
718
  }
719
  </style>
720
  </head>
721
  <body>
722
- <main class="layout" id="app-shell">
723
- <aside class="sidebar">
724
- <div class="brand">
725
- <h1>iDEAL</h1>
 
726
  </div>
727
- <p class="meta-text">粘贴 accessToken 后即可生成链接。</p>
728
- </aside>
729
-
730
- <section class="main-content">
731
- <form id="extract-form" class="extract-form">
732
- <div class="mode-group" role="tablist" aria-label="link type">
733
- <button class="mode-button active" type="button" data-link-type="ideal" role="tab" aria-selected="true">iDEAL</button>
734
- <button class="mode-button" type="button" data-link-type="paypal" role="tab" aria-selected="false">PayPal</button>
 
 
 
 
 
 
 
 
735
  </div>
736
- <div class="input-group">
737
- <label for="access-token">accessToken</label>
738
- <textarea id="access-token" autocomplete="off" spellcheck="false" placeholder="在这里粘贴 AT" disabled></textarea>
 
 
 
 
 
 
 
 
 
 
 
739
  </div>
740
- <div class="actions-row">
741
- <button id="generate" type="submit" class="btn btn-primary" disabled>
742
- <svg aria-hidden="true" focusable="false" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></svg>
743
- <span id="generate-label">生成 iDEAL 链接</span>
744
- </button>
745
- <button id="clear" type="button" class="btn btn-secondary" disabled>清空</button>
746
- <button id="cancel" type="button" class="btn btn-danger hidden" disabled>中断提链</button>
747
- <span id="status" class="status-msg" role="status" aria-live="polite"></span>
748
  </div>
749
- </form>
 
 
 
 
 
 
750
 
751
- <div id="progress-log" class="progress-log hidden" aria-live="polite">
752
- <div class="progress-log-title">提取进度</div>
753
- <ol id="progress-list" class="progress-list"></ol>
754
- </div>
755
 
756
- <div id="result" aria-live="polite">
757
- <a id="long-url" class="result-url" href="#" target="_blank" rel="noreferrer" aria-label="生成的链接"></a>
758
- </div>
 
 
 
 
 
 
 
 
 
 
 
759
  </section>
760
  </main>
761
 
762
  <script>
763
- const form = document.getElementById("extract-form");
764
- const token = document.getElementById("access-token");
765
- const statusEl = document.getElementById("status");
766
- const generate = document.getElementById("generate");
767
- const generateLabel = document.getElementById("generate-label");
768
- const clear = document.getElementById("clear");
769
- const cancel = document.getElementById("cancel");
770
- const modeButtons = Array.from(document.querySelectorAll(".mode-button"));
771
- const result = document.getElementById("result");
772
- const longUrl = document.getElementById("long-url");
773
- const progressLog = document.getElementById("progress-log");
774
- const progressList = document.getElementById("progress-list");
775
- let pollTimer = null;
776
- let activeJobId = null;
777
- let currentLinkType = "ideal";
778
- let latestProgressSteps = [];
779
- let transientPollErrors = 0;
780
 
781
- const setStatus = (message, type = "") => {
782
- statusEl.textContent = message;
783
- statusEl.className = `status-msg ${type}`.trim();
784
- };
785
 
786
- const updateRunControls = () => {
787
- const active = Boolean(activeJobId);
788
- token.disabled = active;
789
- clear.disabled = active;
790
- generate.disabled = active;
791
- cancel.classList.toggle("hidden", !active);
792
- cancel.disabled = !active;
793
- for (const button of modeButtons) {
794
- button.disabled = active;
795
- }
796
- };
797
 
798
- const transientStatusCodes = new Set([502, 503, 504, 520, 521, 522, 523, 524]);
 
 
 
 
 
 
 
 
799
 
800
- const apiError = (message, response) => {
801
- const error = new Error(message);
802
- error.status = response?.status || 0;
803
- error.transient = transientStatusCodes.has(error.status);
804
- return error;
805
- };
806
 
807
- const parseApiJson = async (response) => {
808
- const contentType = (response.headers.get("content-type") || "").toLowerCase();
809
  const text = await response.text();
810
- const trimmed = text.trim();
811
- const looksJson = trimmed.startsWith("{") || trimmed.startsWith("[");
812
- if (!trimmed) {
813
- throw apiError(`服务暂时没有返回内容(HTTP ${response.status})。`, response);
814
- }
815
- if (!contentType.includes("application/json") && !looksJson) {
816
- const message = transientStatusCodes.has(response.status)
817
- ? "服务网关暂时不可用,正在重试状态查询。"
818
- : `服务返回了非 JSON 响应(HTTP ${response.status})。`;
819
- throw apiError(message, response);
820
- }
821
- try {
822
- return JSON.parse(trimmed);
823
- } catch (error) {
824
- throw apiError(`服务返回的 JSON 无法解析(HTTP ${response.status})。`, response);
825
- }
826
- };
827
-
828
- const fetchApiJson = async (url, options) => {
829
- const response = await fetch(url, options);
830
- const payload = await parseApiJson(response);
831
- return { response, payload };
832
- };
833
-
834
- const stepNames = {
835
- queued: "排队",
836
- running: "开始执行",
837
- "locked config": "固定配置",
838
- checkout: "NL 创建 checkout",
839
- "stripe init": "NL 初始化 Stripe",
840
- "VN promotion update": "VN 应用优惠",
841
- "VN promotion Stripe init": "VN 优惠后初始化 Stripe",
842
- "iDEAL ChatGPT taxes": "同步 iDEAL 税费",
843
- "iDEAL Stripe tax region": "同步 Stripe 税区",
844
- "iDEAL tax Stripe init": "税费后初始化 Stripe",
845
- "payment method": "创建支付方式",
846
- "paypal tax region": "设置 PayPal 税区",
847
- "stripe confirm": "确认 Stripe",
848
- "approve retry policy": "审批重试策略",
849
- approve: "ChatGPT 审批",
850
- "approve retry": "审批重试",
851
- "approved proxy cache": "已审批代理缓存",
852
- "proxy chain": "代理链",
853
- "rebuild checkout": "重建 checkout",
854
- "rebuild retry": "重试重建",
855
- "provider fallback": "回退 hosted 链接",
856
- "stripe redirect retry": "Stripe 跳转轮询",
857
- "provider redirect": "提取最终链接",
858
- canceled: "已中断",
859
- error: "失败",
860
- };
861
-
862
- const renderProgress = (steps = []) => {
863
- const visibleSteps = Array.isArray(steps) ? steps : [];
864
- latestProgressSteps = visibleSteps;
865
- progressList.replaceChildren();
866
- if (visibleSteps.length === 0) {
867
- progressLog.classList.add("hidden");
868
- return;
869
- }
870
- progressLog.classList.remove("hidden");
871
- for (const step of visibleSteps) {
872
- const status = String(step.status || "").toLowerCase();
873
- const item = document.createElement("li");
874
- item.className = `progress-item ${status || "ok"}`;
875
-
876
- const marker = document.createElement("span");
877
- marker.className = "progress-dot";
878
- item.appendChild(marker);
879
-
880
- const body = document.createElement("div");
881
- const name = document.createElement("div");
882
- name.className = "progress-name";
883
- name.textContent = stepNames[step.name] || step.name || "处理步骤";
884
- body.appendChild(name);
885
-
886
- if (step.detail) {
887
- const detail = document.createElement("div");
888
- detail.className = "progress-detail";
889
- detail.textContent = step.detail;
890
- body.appendChild(detail);
891
- }
892
-
893
- item.appendChild(body);
894
- progressList.appendChild(item);
895
- }
896
- progressLog.scrollTop = progressLog.scrollHeight;
897
- };
898
-
899
- const renderJobProgress = (job, output) => {
900
- const jobSteps = Array.isArray(job?.steps) ? job.steps : [];
901
- const outputSteps = Array.isArray(output?.steps) ? output.steps : [];
902
- renderProgress(jobSteps.length > 0 ? jobSteps : outputSteps);
903
- };
904
-
905
- const appendProgressError = (message) => {
906
- if (latestProgressSteps.length === 0) return;
907
- if (latestProgressSteps.some((step) => String(step.status || "").toLowerCase() === "error")) return;
908
- renderProgress([
909
- ...latestProgressSteps,
910
- { name: "error", status: "error", detail: message },
911
- ]);
912
- };
913
-
914
- const hideResult = () => {
915
- result.classList.remove("visible");
916
- longUrl.textContent = "";
917
- longUrl.removeAttribute("href");
918
- renderProgress([]);
919
- };
920
-
921
- const linkTypeLabels = {
922
- ideal: "iDEAL",
923
- paypal: "PayPal",
924
  };
925
 
926
- const setLinkType = (linkType) => {
927
- currentLinkType = linkType === "paypal" ? "paypal" : "ideal";
928
- for (const button of modeButtons) {
929
- const active = button.dataset.linkType === currentLinkType;
930
- button.classList.toggle("active", active);
931
- button.setAttribute("aria-selected", active ? "true" : "false");
 
 
 
 
 
 
 
 
 
 
 
 
 
932
  }
933
- generateLabel.textContent = `生成 ${linkTypeLabels[currentLinkType]} 链接`;
934
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
935
 
936
- for (const button of modeButtons) {
937
- button.addEventListener("click", () => {
938
- if (button.disabled) return;
939
- setLinkType(button.dataset.linkType);
940
- hideResult();
941
- setStatus("");
942
- });
943
  }
944
 
945
- const stopPolling = () => {
946
- if (pollTimer) {
947
- clearTimeout(pollTimer);
948
- pollTimer = null;
949
- }
950
- activeJobId = null;
951
- transientPollErrors = 0;
952
- updateRunControls();
953
- };
954
 
955
- const statusText = (job) => {
956
- if (!job) return "任务已提交,正在排队…";
957
- if (job.status === "queued") {
958
- return job.position > 1
959
- ? `排队中,前面还有 ${job.position - 1} 个任务。`
960
- : "排队中,即将开始。";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
961
  }
962
- if (job.status === "running") return "正在提取链接,请稍候…";
963
- if (job.status === "canceled") return "任务已中断。";
964
- return "任务已提交,正在排队…";
965
- };
966
-
967
- const showOutput = (output) => {
968
- longUrl.textContent = output.long_url;
969
- longUrl.href = output.long_url;
970
- result.classList.add("visible");
971
- setStatus("链接已生成。", "ok");
972
- };
973
 
974
- const schedulePoll = (jobId, delay = 1500) => {
975
- pollTimer = setTimeout(() => {
976
- pollJob(jobId).catch((error) => {
977
- if (error.transient && activeJobId === jobId && transientPollErrors < 20) {
978
- transientPollErrors += 1;
979
- setStatus(`${error.message}(第 ${transientPollErrors} 次)`, "queued");
980
- schedulePoll(jobId, Math.min(5000, 1500 + transientPollErrors * 300));
981
- return;
982
- }
983
- stopPolling();
984
- const message = error.message || String(error);
985
- appendProgressError(message);
986
- setStatus(message, "error");
987
- });
988
- }, delay);
989
- };
 
 
 
 
990
 
991
- const pollJob = async (jobId) => {
992
- const { response, payload } = await fetchApiJson(`/api/extract/${encodeURIComponent(jobId)}`);
993
- transientPollErrors = 0;
994
- const job = payload.job;
995
- renderJobProgress(job, payload.output || job?.output);
996
- if (job?.status === "completed") {
997
- showOutput(payload.output || job.output);
998
- stopPolling();
999
- return;
1000
- }
1001
- if (job?.status === "canceled") {
1002
- stopPolling();
1003
- setStatus(payload.error || job.error || "任务已中断。", "queued");
1004
- return;
1005
- }
1006
- if (job?.status === "failed") {
1007
- throw new Error(payload.error || job.error || "提取失败。");
1008
- }
1009
- if (!response.ok || !payload.ok) {
1010
- throw new Error(payload.error || `请求失败:HTTP ${response.status}`);
1011
- }
1012
- setStatus(statusText(job), job?.status === "running" ? "running" : "queued");
1013
- schedulePoll(jobId);
1014
- };
1015
 
1016
- cancel.addEventListener("click", async () => {
 
 
 
 
 
 
 
 
 
1017
  if (!activeJobId) return;
1018
  const jobId = activeJobId;
1019
- cancel.disabled = true;
1020
- setStatus("正在中断任务…", "queued");
1021
  try {
1022
- const { response, payload } = await fetchApiJson(`/api/extract/${encodeURIComponent(jobId)}/cancel`, {
1023
- method: "POST",
1024
- });
1025
- if (!response.ok || !payload.ok) {
1026
- throw new Error(payload.error || `请求失败:HTTP ${response.status}`);
1027
- }
1028
- renderJobProgress(payload.job, payload.output || payload.job?.output);
1029
  stopPolling();
1030
- setStatus(payload.error || payload.job?.error || "任务已中断。", "queued");
1031
  } catch (error) {
1032
- const message = error.message || String(error);
1033
- setStatus(message, "error");
1034
- cancel.disabled = false;
1035
  }
1036
  });
1037
-
1038
- clear.addEventListener("click", () => {
1039
- stopPolling();
1040
- form.reset();
1041
- hideResult();
1042
- setStatus("");
1043
- updateRunControls();
1044
  });
1045
-
1046
- form.addEventListener("submit", async (event) => {
1047
- event.preventDefault();
1048
- stopPolling();
1049
- hideResult();
1050
- if (!token.value.trim()) {
1051
- setStatus("请先粘贴 accessToken。", "error");
1052
- return;
1053
- }
1054
- setStatus("正在提交任务…");
1055
- renderProgress([{ name: "queued", status: "queued", detail: "正在提交任务。" }]);
1056
- generate.disabled = true;
1057
- try {
1058
- const { response, payload } = await fetchApiJson("/api/extract", {
1059
- method: "POST",
1060
- headers: { "content-type": "application/json" },
1061
- body: JSON.stringify({
1062
- access_token: token.value,
1063
- link_type: currentLinkType,
1064
- }),
1065
- });
1066
- if (!response.ok || !payload.ok) {
1067
- throw new Error(payload.error || `请求失败:HTTP ${response.status}`);
1068
- }
1069
- if (payload.output) {
1070
- renderJobProgress(null, payload.output);
1071
- showOutput(payload.output);
1072
- generate.disabled = false;
1073
- return;
1074
- }
1075
- const job = payload.job;
1076
- if (!job?.job_id) throw new Error("服务没有返回任务编号。");
1077
- activeJobId = job.job_id;
1078
- updateRunControls();
1079
- renderJobProgress(job);
1080
- setStatus(statusText(job), job.status === "running" ? "running" : "queued");
1081
- await pollJob(activeJobId);
1082
- } catch (error) {
1083
- stopPolling();
1084
- const message = error.message || String(error);
1085
- appendProgressError(message);
1086
- setStatus(message, "error");
1087
- }
1088
  });
1089
 
1090
- setLinkType("ideal");
1091
- updateRunControls();
1092
  </script>
1093
  </body>
1094
  </html>
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
  <link rel="icon" href="data:," />
7
  <title>iDEAL 链接提取器</title>
 
 
 
8
  <style>
9
  :root {
10
+ color-scheme: light;
11
+ --bg: #f4f6f8;
12
+ --panel: #ffffff;
13
+ --ink: #161b22;
14
+ --muted: #667085;
15
+ --line: #d9dee7;
16
+ --soft: #eef3f7;
17
+ --accent: #087443;
18
+ --accent-dark: #075f38;
19
+ --blue: #155eef;
20
+ --danger: #b42318;
21
+ --warning: #b54708;
22
+ }
23
+
24
+ * { box-sizing: border-box; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  body {
27
  margin: 0;
 
 
 
 
 
 
 
28
  min-height: 100vh;
29
+ background: var(--bg);
30
+ color: var(--ink);
31
+ font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
+ main {
35
+ width: min(980px, calc(100vw - 32px));
36
+ margin: 0 auto;
37
+ padding: 36px 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
 
40
+ header {
41
  display: flex;
 
42
  justify-content: space-between;
43
+ align-items: end;
44
+ gap: 20px;
45
+ margin-bottom: 16px;
 
46
  }
47
 
48
+ h1 { margin: 0 0 8px; font-size: 30px; line-height: 1.15; }
49
+ p { margin: 0; color: var(--muted); }
 
 
 
50
 
51
+ .stats {
52
+ display: grid;
53
+ grid-template-columns: repeat(3, minmax(92px, 1fr));
54
+ gap: 8px;
55
+ min-width: 320px;
 
 
 
 
 
 
56
  }
57
 
58
+ .stat, .panel {
59
+ border: 1px solid var(--line);
60
+ border-radius: 8px;
61
+ background: var(--panel);
 
 
62
  }
63
 
64
+ .stat { padding: 10px 12px; }
65
+ .stat strong { display: block; font-size: 18px; }
66
+ .stat span, small { color: var(--muted); font-size: 12px; }
 
 
 
 
 
 
67
 
68
+ .tool { display: grid; gap: 16px; padding: 18px; }
69
+ .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
70
+ .field { display: grid; gap: 8px; }
71
+ label { font-size: 13px; font-weight: 700; }
72
 
73
+ textarea, input {
 
 
 
 
 
 
 
 
 
 
 
 
74
  width: 100%;
75
+ border: 1px solid var(--line);
76
+ border-radius: 6px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  background: #fff;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  color: var(--ink);
79
+ font: inherit;
80
+ padding: 10px 12px;
81
  outline: none;
 
 
82
  }
83
 
84
+ textarea { min-height: 160px; resize: vertical; }
85
+ textarea.proxy-list { min-height: 118px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
86
+ textarea:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8, 116, 67, .14); }
87
+ textarea:disabled, input:disabled { background: #f2f4f7; color: var(--muted); }
 
 
 
 
 
 
 
 
 
88
 
89
+ .session-panel {
90
+ display: grid;
91
+ grid-template-columns: minmax(0, 1fr) auto;
 
 
 
 
 
 
 
 
 
92
  align-items: center;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  gap: 12px;
94
+ padding: 12px 14px;
95
+ background: #fbfcfd;
96
  }
97
 
98
+ .session-copy strong { display: block; }
99
+ .session-copy span { color: var(--muted); font-size: 13px; }
100
+ .cdk-row { display: flex; gap: 8px; margin-top: 9px; }
101
+ .cdk-row input { min-width: 220px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
+ button, a.button {
104
+ display: inline-flex;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  align-items: center;
106
+ justify-content: center;
107
+ min-height: 42px;
108
+ border: 0;
109
+ border-radius: 6px;
110
+ padding: 0 16px;
111
+ background: var(--accent);
112
+ color: #fff;
113
+ font: inherit;
114
+ font-weight: 800;
115
+ text-decoration: none;
116
+ cursor: pointer;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  }
118
 
119
+ button:hover, a.button:hover { background: var(--accent-dark); }
120
+ button.secondary, a.button.secondary { background: var(--soft); color: var(--ink); }
121
+ button.danger { background: var(--danger); }
122
+ button:disabled, a.button.disabled { pointer-events: none; cursor: wait; opacity: .58; }
123
+ .actions, .result-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
124
+ .status { min-height: 22px; color: var(--muted); }
125
+ .status.error { color: var(--danger); }
126
+ .status.ok { color: var(--accent); }
127
+ .status.running { color: var(--warning); }
128
 
129
+ .task-control {
 
 
 
 
 
 
130
  display: flex;
131
+ justify-content: space-between;
132
+ align-items: center;
133
  gap: 12px;
134
+ padding: 12px 14px;
135
+ background: #fff8f7;
136
+ border-color: #f0b8b1;
137
+ }
138
+
139
+ .task-control span { color: var(--muted); font-size: 13px; }
140
+ .progress-panel { display: none; gap: 10px; padding: 14px; background: #fbfcfd; }
141
+ .progress-panel.show { display: grid; }
142
+ .progress-head { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
143
+ .progress-list { display: grid; gap: 7px; max-height: 320px; overflow: auto; }
144
+ .progress-item { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 9px; padding: 8px; border-radius: 5px; background: var(--soft); }
145
+ .dot { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--blue); }
146
+ .progress-item.ok .dot { background: var(--accent); }
147
+ .progress-item.warn .dot, .progress-item.queued .dot, .progress-item.running .dot { background: #f79009; }
148
+ .progress-item.error .dot { background: var(--danger); }
149
+ .progress-name { font-weight: 700; }
150
+ .progress-detail { color: var(--muted); font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
151
+
152
+ .result { display: none; gap: 12px; padding: 14px; background: #fbfcfd; }
153
+ .result.show { display: grid; }
154
+ .row { display: grid; gap: 6px; }
155
+ code { display: block; padding: 12px; border-radius: 6px; background: var(--soft); overflow-wrap: anywhere; }
156
+ .hidden { display: none !important; }
157
+
158
+ @media (max-width: 840px) {
159
+ main { width: min(100vw - 24px, 980px); padding: 24px 0; }
160
+ header, .grid, .session-panel { display: grid; }
161
+ .stats { width: 100%; min-width: 0; }
162
+ .grid { grid-template-columns: 1fr; }
163
+ .cdk-row { flex-wrap: wrap; }
164
+ .cdk-row input { min-width: 0; }
165
  }
166
  </style>
167
  </head>
168
  <body>
169
+ <main>
170
+ <header>
171
+ <div>
172
+ <h1>iDEAL 链接提取器</h1>
173
+ <p>固定 NL/EUR/custom/Safari。Checkout 全链路与 Promotion Update 分别使用下方两个代理池。</p>
174
  </div>
175
+ <div class="stats" aria-label="locked configuration">
176
+ <div class="stat"><strong>iDEAL</strong><span>NL / EUR</span></div>
177
+ <div class="stat"><strong>5 轮</strong><span>代理池依次轮换</span></div>
178
+ <div class="stat"><strong>成功后</strong><span>扣除一次 CDK</span></div>
179
+ </div>
180
+ </header>
181
+
182
+ <section class="panel tool">
183
+ <section class="panel session-panel" aria-label="CDK session">
184
+ <div class="session-copy">
185
+ <strong id="session-title">CDK 激活状态</strong>
186
+ <span id="session-detail">正在读取当前会话…</span>
187
+ <div id="cdk-row" class="cdk-row">
188
+ <input id="cdk-input" autocomplete="off" placeholder="输入 CDK 激活页面" />
189
+ <button id="bind-cdk" type="button">激活</button>
190
+ </div>
191
  </div>
192
+ <button id="logout" class="secondary hidden" type="button">退出会话</button>
193
+ </section>
194
+
195
+ <div class="field">
196
+ <label for="access-token">Access Token 或 session JSON</label>
197
+ <textarea id="access-token" autocomplete="off" spellcheck="false" placeholder="在这里粘贴 Access Token"></textarea>
198
+ <small>Token 不会写入磁盘,也不会显示在结果中。</small>
199
+ </div>
200
+
201
+ <div class="grid">
202
+ <div class="field">
203
+ <label for="checkout-proxy-pool">iDEAL Checkout 主代理池(每行一个)</label>
204
+ <textarea id="checkout-proxy-pool" class="proxy-list" spellcheck="false" placeholder="user:pass@host:port&#10;user:pass@host:port"></textarea>
205
+ <small>用于 Checkout、Stripe、税务、PaymentMethod、confirm、approve 和最终 iDEAL 跳转。</small>
206
  </div>
207
+ <div class="field">
208
+ <label for="promotion-proxy-pool">iDEAL Promotion Update 代理池(每行一个)</label>
209
+ <textarea id="promotion-proxy-pool" class="proxy-list" spellcheck="false" placeholder="user:pass@host:port&#10;user:pass@host:port"></textarea>
210
+ <small>只用于同一个 Checkout 的 Promotion Update,完成后立即切回本轮 Checkout 代理。</small>
 
 
 
 
211
  </div>
212
+ </div>
213
+
214
+ <div class="actions">
215
+ <button id="generate" type="button">提取 iDEAL 链</button>
216
+ <button id="clear" class="secondary" type="button">清空</button>
217
+ <span id="status" class="status" role="status" aria-live="polite">两个代理池都必须填写。</span>
218
+ </div>
219
 
220
+ <section id="task-control" class="panel task-control hidden">
221
+ <div><strong>任务运行中</strong><br /><span id="task-hint">正在排队。</span></div>
222
+ <button id="cancel" class="danger" type="button">终止当前任务</button>
223
+ </section>
224
 
225
+ <section id="progress-panel" class="panel progress-panel" aria-live="polite">
226
+ <div class="progress-head"><strong>提取进度</strong><span id="progress-state">准备</span></div>
227
+ <div id="progress-list" class="progress-list"></div>
228
+ </section>
229
+
230
+ <section id="result" class="panel result" aria-live="polite">
231
+ <div class="result-actions">
232
+ <a id="open-link" class="button disabled" target="_blank" rel="noopener">打开 iDEAL 链</a>
233
+ <button id="copy-link" class="secondary" type="button" disabled>复制链接</button>
234
+ </div>
235
+ <div class="row"><label>iDEAL 长链</label><code id="long-url"></code></div>
236
+ <div class="row"><label>Checkout / 金额</label><code id="summary"></code></div>
237
+ <div class="row"><label>Stripe Redirect URL</label><code id="stripe-url"></code></div>
238
+ </section>
239
  </section>
240
  </main>
241
 
242
  <script>
243
+ const $ = (id) => document.getElementById(id);
244
+ const tokenInput = $("access-token");
245
+ const checkoutPoolInput = $("checkout-proxy-pool");
246
+ const promotionPoolInput = $("promotion-proxy-pool");
247
+ const generateButton = $("generate");
248
+ const cancelButton = $("cancel");
249
+ let activeJobId = "";
250
+ let pollTimer = 0;
251
+ let currentLongUrl = "";
 
 
 
 
 
 
 
 
252
 
253
+ function setStatus(message, kind = "") {
254
+ $("status").textContent = message;
255
+ $("status").className = `status ${kind}`.trim();
256
+ }
257
 
258
+ function proxyLines(value) {
259
+ return value.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
260
+ }
 
 
 
 
 
 
 
 
261
 
262
+ function setBusy(busy) {
263
+ tokenInput.disabled = busy;
264
+ checkoutPoolInput.disabled = busy;
265
+ promotionPoolInput.disabled = busy;
266
+ generateButton.disabled = busy;
267
+ $("clear").disabled = busy;
268
+ $("task-control").classList.toggle("hidden", !busy);
269
+ cancelButton.disabled = !busy;
270
+ }
271
 
272
+ function stopPolling() {
273
+ if (pollTimer) window.clearTimeout(pollTimer);
274
+ pollTimer = 0;
275
+ activeJobId = "";
276
+ setBusy(false);
277
+ }
278
 
279
+ async function readJson(response) {
 
280
  const text = await response.text();
281
+ if (!text.trim()) throw new Error(`服务没有返回内容(HTTP ${response.status})。`);
282
+ try { return JSON.parse(text); }
283
+ catch (_) { throw new Error(`服务返回了无法解析的响应(HTTP ${response.status})。`); }
284
+ }
285
+
286
+ const stepLabels = {
287
+ queued: "排队",
288
+ running: "开始执行",
289
+ "locked config": "固定 iDEAL 配置",
290
+ "proxy chain": "选择本轮代理",
291
+ checkout: "创建 NL Checkout",
292
+ "stripe init": "初始化 Stripe",
293
+ "VN promotion update": "Promotion Update",
294
+ "VN promotion Stripe init": "优惠后刷新 Stripe",
295
+ "iDEAL ChatGPT taxes": "同步 ChatGPT 税费",
296
+ "iDEAL Stripe tax region": "同步 Stripe 税区",
297
+ "iDEAL tax Stripe init": "税费后刷新 Stripe",
298
+ "payment method": "创建 iDEAL PaymentMethod",
299
+ "stripe confirm": "确认 Stripe",
300
+ approve: "ChatGPT approve",
301
+ "approve retry": "approve 重试",
302
+ "stripe redirect retry": "轮询 Stripe 跳转",
303
+ "provider redirect": "解析最终 iDEAL 链",
304
+ "rebuild checkout": "重建 Checkout",
305
+ "rebuild retry": "进入下一轮",
306
+ canceled: "任务已终止",
307
+ error: "失败",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  };
309
 
310
+ function renderSteps(steps = []) {
311
+ const list = $("progress-list");
312
+ list.replaceChildren();
313
+ $("progress-panel").classList.toggle("show", steps.length > 0);
314
+ for (const step of steps) {
315
+ const item = document.createElement("div");
316
+ item.className = `progress-item ${String(step.status || "info").toLowerCase()}`;
317
+ const dot = document.createElement("span");
318
+ dot.className = "dot";
319
+ const body = document.createElement("div");
320
+ const name = document.createElement("div");
321
+ name.className = "progress-name";
322
+ name.textContent = stepLabels[step.name] || step.name || "处理步骤";
323
+ const detail = document.createElement("div");
324
+ detail.className = "progress-detail";
325
+ detail.textContent = step.detail || "";
326
+ body.append(name, detail);
327
+ item.append(dot, body);
328
+ list.appendChild(item);
329
  }
330
+ list.scrollTop = list.scrollHeight;
331
+ }
332
+
333
+ function showResult(output) {
334
+ currentLongUrl = output.long_url || "";
335
+ $("long-url").textContent = currentLongUrl;
336
+ $("summary").textContent = `${output.cs_id || ""} / ${output.amount_display || output.amount || ""}`;
337
+ $("stripe-url").textContent = output.stripe_redirect_url || "";
338
+ $("open-link").href = currentLongUrl || "#";
339
+ $("open-link").classList.toggle("disabled", !currentLongUrl);
340
+ $("copy-link").disabled = !currentLongUrl;
341
+ $("result").classList.add("show");
342
+ }
343
+
344
+ function jobStatusText(job) {
345
+ if (job?.status === "running") return "正在执行完整 iDEAL 链路。";
346
+ if (job?.status === "queued") return job.position > 1 ? `排队中,前面还有 ${job.position - 1} 个任务。` : "排队中,即将开始。";
347
+ return "正在处理。";
348
+ }
349
+
350
+ async function pollJob(jobId) {
351
+ if (activeJobId !== jobId) return;
352
+ const response = await fetch(`/api/extract/${encodeURIComponent(jobId)}`, { cache: "no-store" });
353
+ const payload = await readJson(response);
354
+ const job = payload.job;
355
+ renderSteps(job?.steps || payload.output?.steps || []);
356
+ $("progress-state").textContent = job?.status || "running";
357
+ if (job?.status === "completed") {
358
+ showResult(payload.output || job.output);
359
+ setStatus("iDEAL 链提取完成。", "ok");
360
+ stopPolling();
361
+ return;
362
+ }
363
+ if (job?.status === "failed" || job?.status === "canceled") {
364
+ throw new Error(payload.error || job.error || "任务失败。");
365
+ }
366
+ if (!response.ok || !payload.ok) throw new Error(payload.error || `请求失败:HTTP ${response.status}`);
367
+ $("task-hint").textContent = jobStatusText(job);
368
+ setStatus(jobStatusText(job), "running");
369
+ pollTimer = window.setTimeout(() => pollJob(jobId).catch(handleTaskError), 1500);
370
+ }
371
 
372
+ function handleTaskError(error) {
373
+ const message = error instanceof Error ? error.message : String(error);
374
+ renderSteps([{ name: "error", status: "error", detail: message }]);
375
+ setStatus(message, "error");
376
+ stopPolling();
 
 
377
  }
378
 
379
+ async function startExtraction() {
380
+ const accessToken = tokenInput.value.trim();
381
+ const checkoutPool = proxyLines(checkoutPoolInput.value);
382
+ const promotionPool = proxyLines(promotionPoolInput.value);
383
+ if (!accessToken) return setStatus("Access Token 不能为空。", "error");
384
+ if (!checkoutPool.length) return setStatus("iDEAL Checkout 主代理池不能为空。", "error");
385
+ if (!promotionPool.length) return setStatus("iDEAL Promotion Update 代理池不能为空。", "error");
 
 
386
 
387
+ $("result").classList.remove("show");
388
+ renderSteps([{ name: "queued", status: "queued", detail: "正在提交任务。" }]);
389
+ setBusy(true);
390
+ setStatus("正在提交任务…", "running");
391
+ try {
392
+ const response = await fetch("/api/extract", {
393
+ method: "POST",
394
+ headers: { "content-type": "application/json" },
395
+ body: JSON.stringify({
396
+ access_token: accessToken,
397
+ checkout_proxy_pool: checkoutPool.join("\n"),
398
+ promotion_proxy_pool: promotionPool.join("\n"),
399
+ }),
400
+ });
401
+ const payload = await readJson(response);
402
+ if (!response.ok || !payload.ok) throw new Error(payload.error || `请求失败:HTTP ${response.status}`);
403
+ const job = payload.job;
404
+ if (!job?.job_id) throw new Error("服务没有返回任务编号。");
405
+ activeJobId = job.job_id;
406
+ renderSteps(job.steps || []);
407
+ $("task-hint").textContent = jobStatusText(job);
408
+ await pollJob(activeJobId);
409
+ } catch (error) {
410
+ handleTaskError(error);
411
  }
412
+ }
 
 
 
 
 
 
 
 
 
 
413
 
414
+ async function refreshSession() {
415
+ try {
416
+ const response = await fetch("/api/auth/me", { cache: "no-store" });
417
+ const payload = await readJson(response);
418
+ const user = payload.user;
419
+ if (!response.ok || !payload.ok || !user) {
420
+ $("session-title").textContent = "输入 CDK 激活页面";
421
+ $("session-detail").textContent = payload.error || "当前会话尚未激活。";
422
+ $("cdk-row").classList.remove("hidden");
423
+ $("logout").classList.add("hidden");
424
+ return;
425
+ }
426
+ $("session-title").textContent = user.display_name || user.username || "已激活";
427
+ $("session-detail").textContent = `CDK ${user.cdk || ""} · 剩余 ${user.available_uses ?? user.remaining_uses ?? 0} 次`;
428
+ $("cdk-row").classList.add("hidden");
429
+ $("logout").classList.remove("hidden");
430
+ } catch (_) {
431
+ $("session-detail").textContent = "会话状态读取失败,可稍后重试。";
432
+ }
433
+ }
434
 
435
+ async function bindCdk() {
436
+ const cdk = $("cdk-input").value.trim();
437
+ if (!cdk) return setStatus("CDK 不能为空。", "error");
438
+ $("bind-cdk").disabled = true;
439
+ try {
440
+ const response = await fetch("/api/cdk/bind", {
441
+ method: "POST",
442
+ headers: { "content-type": "application/json" },
443
+ body: JSON.stringify({ cdk }),
444
+ });
445
+ const payload = await readJson(response);
446
+ if (!response.ok || !payload.ok) throw new Error(payload.error || "CDK 激活失败。");
447
+ $("cdk-input").value = "";
448
+ setStatus("CDK 已激活。", "ok");
449
+ await refreshSession();
450
+ } catch (error) {
451
+ setStatus(error instanceof Error ? error.message : String(error), "error");
452
+ } finally {
453
+ $("bind-cdk").disabled = false;
454
+ }
455
+ }
 
 
 
456
 
457
+ generateButton.addEventListener("click", startExtraction);
458
+ $("clear").addEventListener("click", () => {
459
+ tokenInput.value = "";
460
+ checkoutPoolInput.value = "";
461
+ promotionPoolInput.value = "";
462
+ $("result").classList.remove("show");
463
+ renderSteps([]);
464
+ setStatus("两个代理池都必须填写。");
465
+ });
466
+ cancelButton.addEventListener("click", async () => {
467
  if (!activeJobId) return;
468
  const jobId = activeJobId;
469
+ cancelButton.disabled = true;
 
470
  try {
471
+ const response = await fetch(`/api/extract/${encodeURIComponent(jobId)}/cancel`, { method: "POST" });
472
+ const payload = await readJson(response);
473
+ if (!response.ok || !payload.ok) throw new Error(payload.error || "终止失败。");
474
+ renderSteps(payload.job?.steps || []);
475
+ setStatus("任务已终止。", "running");
 
 
476
  stopPolling();
 
477
  } catch (error) {
478
+ handleTaskError(error);
 
 
479
  }
480
  });
481
+ $("copy-link").addEventListener("click", async () => {
482
+ if (!currentLongUrl) return;
483
+ await navigator.clipboard.writeText(currentLongUrl);
484
+ setStatus("链接已复制。", "ok");
 
 
 
485
  });
486
+ $("bind-cdk").addEventListener("click", bindCdk);
487
+ $("logout").addEventListener("click", async () => {
488
+ await fetch("/api/auth/logout", { method: "POST" });
489
+ await refreshSession();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
490
  });
491
 
492
+ setBusy(false);
493
+ refreshSession();
494
  </script>
495
  </body>
496
  </html>
src/lib.rs CHANGED
@@ -136,10 +136,12 @@ impl LinkType {
136
  }
137
  }
138
 
139
- #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
140
  pub struct ExtractInput {
141
  pub access_token: String,
142
  pub proxy: String,
 
 
143
  pub base_url: String,
144
  pub link_type: String,
145
  }
@@ -149,6 +151,10 @@ pub struct ExtractApiInput {
149
  pub access_token: String,
150
  #[serde(default)]
151
  pub link_type: Option<String>,
 
 
 
 
152
  }
153
 
154
  #[derive(Debug, Clone, Serialize, PartialEq, Eq)]
@@ -1645,6 +1651,10 @@ pub struct HttpResponse {
1645
  pub enum ExtractError {
1646
  #[error("Access Token is required")]
1647
  MissingToken,
 
 
 
 
1648
  #[error("任务已中断。")]
1649
  Canceled,
1650
  #[error("non-default --base-url must be localhost or loopback: {0}")]
@@ -1909,7 +1919,10 @@ pub async fn api_extract(
1909
  if normalize_access_token(&input.access_token).is_none() {
1910
  return api_error(StatusCode::BAD_REQUEST, ExtractError::MissingToken);
1911
  }
1912
- let input = extract_input_for_api(input, configured_default_proxy());
 
 
 
1913
  match state.queue.enqueue(input).await {
1914
  Ok(job) => (
1915
  StatusCode::ACCEPTED,
@@ -2016,13 +2029,35 @@ fn api_queue_error(
2016
  )
2017
  }
2018
 
2019
- fn extract_input_for_api(input: ExtractApiInput, proxy: String) -> ExtractInput {
2020
- ExtractInput {
 
 
 
 
 
 
 
 
2021
  access_token: input.access_token,
2022
- proxy,
 
 
2023
  base_url: String::new(),
2024
- link_type: input.link_type.unwrap_or_else(|| "ideal".to_string()),
 
 
 
 
 
 
 
 
 
 
 
2025
  }
 
2026
  }
2027
 
2028
  fn configured_default_proxy() -> String {
@@ -2436,12 +2471,7 @@ async fn extract_ideal_link_with_progress<T: Transport>(
2436
  let progress = progress.as_ref();
2437
  let token = normalize_access_token(&input.access_token).ok_or(ExtractError::MissingToken)?;
2438
  let base = EndpointBase::new(&input.base_url)?;
2439
- if input.proxy.trim().is_empty() {
2440
- return Err(ExtractError::BadResponse(
2441
- "proxy is required for strict NL-bootstrap / VN-promotion / NL-iDEAL extraction"
2442
- .to_string(),
2443
- ));
2444
- }
2445
  let mut steps = Vec::new();
2446
  add_step_with_progress(
2447
  &mut steps,
@@ -2453,6 +2483,8 @@ async fn extract_ideal_link_with_progress<T: Transport>(
2453
 
2454
  let mut last_error = None;
2455
  for attempt in 1..=MAX_REBUILD_ATTEMPTS {
 
 
2456
  if attempt > 1 {
2457
  add_step_with_progress(
2458
  &mut steps,
@@ -2468,7 +2500,12 @@ async fn extract_ideal_link_with_progress<T: Transport>(
2468
  transport,
2469
  &base,
2470
  &token,
2471
- &input.proxy,
 
 
 
 
 
2472
  attempt,
2473
  &mut steps,
2474
  progress,
@@ -2504,29 +2541,67 @@ async fn extract_ideal_link_with_progress<T: Transport>(
2504
  }))
2505
  }
2506
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2507
  async fn run_ideal_attempt<T: Transport>(
2508
  transport: &mut T,
2509
  base: &EndpointBase,
2510
  token: &str,
2511
- proxy: &str,
 
 
 
 
 
2512
  attempt: usize,
2513
  steps: &mut Vec<Step>,
2514
  progress: Option<&ProgressSink>,
2515
  ) -> Result<ExtractOutput, ExtractError> {
2516
- let attempt_proxy = proxy_seed_for_attempt(proxy, attempt);
2517
- let checkout_proxy = proxy_for_region(&attempt_proxy, CHECKOUT_REGION);
2518
- let promotion_proxy = proxy_for_region(&attempt_proxy, PROMOTION_REGION);
2519
- let provider_proxy = proxy_for_region(&attempt_proxy, PROVIDER_REGION);
2520
- // Keep the normal approval leg on the same vetted NL route that created
2521
- // the iDEAL-capable Checkout Session. approve_with_retries itself rotates
2522
- // to fresh SIDs only after an unsuccessful approval response.
2523
- let approve_proxy = provider_proxy.clone();
2524
  add_step_with_progress(
2525
  steps,
2526
  "proxy chain",
2527
  "ok",
2528
  &format!(
2529
- "attempt {attempt}/{MAX_REBUILD_ATTEMPTS}; NL bootstrap checkout={CHECKOUT_REGION}; VN promotion={PROMOTION_REGION}; provider={PROVIDER_REGION}; approve={APPROVE_REGION}"
2530
  ),
2531
  progress,
2532
  );
@@ -2536,7 +2611,7 @@ async fn run_ideal_attempt<T: Transport>(
2536
  transport,
2537
  &base,
2538
  &chatgpt_headers,
2539
- &checkout_proxy,
2540
  LinkType::Ideal,
2541
  )
2542
  .await?;
@@ -2584,7 +2659,7 @@ async fn run_ideal_attempt<T: Transport>(
2584
  &base,
2585
  &chatgpt_headers,
2586
  &checkout,
2587
- &promotion_proxy,
2588
  )
2589
  .await?;
2590
  add_step_with_progress(
@@ -2720,7 +2795,7 @@ async fn run_ideal_attempt<T: Transport>(
2720
  &base,
2721
  &chatgpt_headers,
2722
  &checkout,
2723
- &approve_proxy,
2724
  LinkType::Ideal,
2725
  Some(ApproveRedirectPoll {
2726
  stripe_pk: &stripe_pk,
@@ -5587,6 +5662,8 @@ mod tests {
5587
  access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
5588
  .to_string(),
5589
  proxy: "http://user-region-US-sid-old-t-1:pass@proxy.example:3010".to_string(),
 
 
5590
  base_url: "http://IP_REDACTED:8792".to_string(),
5591
  link_type: "ideal".to_string(),
5592
  },
@@ -5675,6 +5752,67 @@ mod tests {
5675
  );
5676
  }
5677
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5678
  #[test]
5679
  fn ideal_method_guard_accepts_nl_checkout_and_rejects_card_link_only_session() {
5680
  let supported = serde_json::json!({
@@ -5778,6 +5916,8 @@ mod tests {
5778
  access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
5779
  .to_string(),
5780
  proxy: "http://user-region-US-sid-old-t-1:pass@proxy.example:3010".to_string(),
 
 
5781
  base_url: "http://IP_REDACTED:8792".to_string(),
5782
  link_type: "ideal".to_string(),
5783
  },
@@ -5799,6 +5939,8 @@ mod tests {
5799
  ExtractInput {
5800
  access_token: " ".to_string(),
5801
  proxy: String::new(),
 
 
5802
  base_url: "http://IP_REDACTED:8792".to_string(),
5803
  link_type: "ideal".to_string(),
5804
  },
@@ -5821,6 +5963,8 @@ mod tests {
5821
  access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
5822
  .to_string(),
5823
  proxy: String::new(),
 
 
5824
  base_url: "https://collector.example.test".to_string(),
5825
  link_type: "ideal".to_string(),
5826
  },
@@ -5850,6 +5994,8 @@ mod tests {
5850
  access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
5851
  .to_string(),
5852
  proxy: String::new(),
 
 
5853
  base_url: base_url.to_string(),
5854
  link_type: "ideal".to_string(),
5855
  },
@@ -5945,42 +6091,29 @@ mod tests {
5945
  let html = frontend_html();
5946
 
5947
  assert!(html.contains("iDEAL 链接提取器"));
5948
- assert!(html.contains("粘贴 accessToken 后即可生成链接。"));
5949
- assert!(html.contains("accessToken"));
5950
- assert!(html.contains("生成 iDEAL 链接"));
5951
  assert!(html.contains("id=\"access-token\""));
 
 
 
 
 
 
5952
  assert!(html.contains("/api/extract"));
5953
- assert!(html.contains("任务已提交,正在排队…"));
5954
  assert!(html.contains("排队中"));
5955
- assert!(html.contains("正在提取链接"));
5956
  assert!(html.contains("id=\"long-url\""));
5957
  assert!(html.contains("overflow-wrap: anywhere"));
5958
- assert!(html.contains("word-break: break-all"));
5959
- assert!(!html.contains("/api/config"));
5960
- assert!(!html.contains("Rust local console"));
5961
- assert!(!html.contains("AT iDEAL Link Extractor"));
5962
- assert!(!html.contains("Locked config"));
5963
- assert!(!html.contains("Proxy is loaded"));
5964
- assert!(!html.contains("apple-safari"));
5965
- assert!(!html.contains("VN → NL → VN"));
5966
- assert!(!html.contains("20×1"));
5967
- assert!(!html.contains("id=\"config-badges\""));
5968
- assert!(!html.contains("id=\"steps\""));
5969
- assert!(!html.contains("Copy link"));
5970
- assert!(!html.contains("Open link"));
5971
- assert!(!html.contains("id=\"token-file\""));
5972
- assert!(!html.contains("id=\"proxy\""));
5973
- assert!(!html.contains("id=\"base-url\""));
5974
- assert!(!html.contains("Import at.txt"));
5975
- assert!(!html.contains("Proxy (optional)"));
5976
- assert!(!html.contains("Mock base URL"));
5977
- assert!(!html.contains("先登录,再生成。"));
5978
- assert!(!html.contains("无需 LinuxDo 登录"));
5979
- assert!(!html.contains("CDK"));
5980
- assert!(!html.contains("自动绑定 10 次 CDK"));
5981
- assert!(!html.contains("登录后可查看 CDK 额度"));
5982
- assert!(!html.contains("LinuxDo 登录 · CDK 额度 · PostgreSQL 存储"));
5983
- assert!(!html.contains("访问令牌"));
5984
  }
5985
 
5986
  #[test]
@@ -5999,21 +6132,64 @@ mod tests {
5999
  }
6000
 
6001
  #[test]
6002
- fn api_input_uses_env_proxy_and_default_base_url() {
6003
- let input = extract_input_for_api(
6004
- ExtractApiInput {
6005
- access_token: "at_test".to_string(),
6006
- link_type: None,
6007
- },
6008
- "http://user-region-US-sid-old-t-1:pass@proxy.example:3010".to_string(),
6009
- );
6010
 
6011
  assert_eq!(input.access_token, "at_test");
 
 
 
 
 
 
 
 
 
6012
  assert_eq!(
6013
- input.proxy,
6014
- "http://user-region-US-sid-old-t-1:pass@proxy.example:3010"
 
 
 
 
 
 
 
 
 
 
6015
  );
6016
- assert!(input.base_url.is_empty());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6017
  }
6018
 
6019
  #[tokio::test]
@@ -6041,6 +6217,8 @@ mod tests {
6041
  axum::Json(ExtractApiInput {
6042
  access_token: " ".to_string(),
6043
  link_type: None,
 
 
6044
  }),
6045
  )
6046
  .await;
@@ -6064,6 +6242,8 @@ mod tests {
6064
  access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
6065
  .to_string(),
6066
  link_type: None,
 
 
6067
  }),
6068
  )
6069
  .await;
@@ -6098,6 +6278,8 @@ mod tests {
6098
  axum::Json(ExtractApiInput {
6099
  access_token: token.clone(),
6100
  link_type: None,
 
 
6101
  }),
6102
  )
6103
  .await;
@@ -6110,6 +6292,8 @@ mod tests {
6110
  axum::Json(ExtractApiInput {
6111
  access_token: token,
6112
  link_type: None,
 
 
6113
  }),
6114
  )
6115
  .await;
@@ -6131,6 +6315,8 @@ mod tests {
6131
  axum::Json(ExtractApiInput {
6132
  access_token: "at_test".to_string(),
6133
  link_type: None,
 
 
6134
  }),
6135
  )
6136
  .await;
@@ -6152,6 +6338,8 @@ mod tests {
6152
  axum::Json(ExtractApiInput {
6153
  access_token: "at_test".to_string(),
6154
  link_type: None,
 
 
6155
  }),
6156
  )
6157
  .await;
@@ -6174,6 +6362,8 @@ mod tests {
6174
  axum::Json(ExtractApiInput {
6175
  access_token: "at_test".to_string(),
6176
  link_type: None,
 
 
6177
  }),
6178
  )
6179
  .await;
@@ -6368,9 +6558,11 @@ mod tests {
6368
  access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
6369
  .to_string(),
6370
  link_type: None,
 
 
6371
  },
6372
- String::new(),
6373
- );
6374
 
6375
  assert!(response.base_url.is_empty());
6376
  }
 
136
  }
137
  }
138
 
139
+ #[derive(Debug, Clone, PartialEq, Eq)]
140
  pub struct ExtractInput {
141
  pub access_token: String,
142
  pub proxy: String,
143
+ pub checkout_proxy_pool: Vec<String>,
144
+ pub promotion_proxy_pool: Vec<String>,
145
  pub base_url: String,
146
  pub link_type: String,
147
  }
 
151
  pub access_token: String,
152
  #[serde(default)]
153
  pub link_type: Option<String>,
154
+ #[serde(default)]
155
+ pub checkout_proxy_pool: String,
156
+ #[serde(default)]
157
+ pub promotion_proxy_pool: String,
158
  }
159
 
160
  #[derive(Debug, Clone, Serialize, PartialEq, Eq)]
 
1651
  pub enum ExtractError {
1652
  #[error("Access Token is required")]
1653
  MissingToken,
1654
+ #[error("iDEAL Checkout 主代理池不能为空。")]
1655
+ MissingCheckoutProxyPool,
1656
+ #[error("iDEAL Promotion Update 代理池不能为空。")]
1657
+ MissingPromotionProxyPool,
1658
  #[error("任务已中断。")]
1659
  Canceled,
1660
  #[error("non-default --base-url must be localhost or loopback: {0}")]
 
1919
  if normalize_access_token(&input.access_token).is_none() {
1920
  return api_error(StatusCode::BAD_REQUEST, ExtractError::MissingToken);
1921
  }
1922
+ let input = match extract_input_for_api(input) {
1923
+ Ok(input) => input,
1924
+ Err(error) => return api_error(StatusCode::BAD_REQUEST, error),
1925
+ };
1926
  match state.queue.enqueue(input).await {
1927
  Ok(job) => (
1928
  StatusCode::ACCEPTED,
 
2029
  )
2030
  }
2031
 
2032
+ fn extract_input_for_api(input: ExtractApiInput) -> Result<ExtractInput, ExtractError> {
2033
+ let checkout_proxy_pool = parse_proxy_pool(&input.checkout_proxy_pool);
2034
+ if checkout_proxy_pool.is_empty() {
2035
+ return Err(ExtractError::MissingCheckoutProxyPool);
2036
+ }
2037
+ let promotion_proxy_pool = parse_proxy_pool(&input.promotion_proxy_pool);
2038
+ if promotion_proxy_pool.is_empty() {
2039
+ return Err(ExtractError::MissingPromotionProxyPool);
2040
+ }
2041
+ Ok(ExtractInput {
2042
  access_token: input.access_token,
2043
+ proxy: checkout_proxy_pool[0].clone(),
2044
+ checkout_proxy_pool,
2045
+ promotion_proxy_pool,
2046
  base_url: String::new(),
2047
+ link_type: "ideal".to_string(),
2048
+ })
2049
+ }
2050
+
2051
+ fn parse_proxy_pool(text: &str) -> Vec<String> {
2052
+ let mut proxies = Vec::new();
2053
+ for line in text.lines() {
2054
+ let proxy = normalize_proxy_url_for_reqwest(line.trim());
2055
+ if proxy.is_empty() || proxies.contains(&proxy) {
2056
+ continue;
2057
+ }
2058
+ proxies.push(proxy);
2059
  }
2060
+ proxies
2061
  }
2062
 
2063
  fn configured_default_proxy() -> String {
 
2471
  let progress = progress.as_ref();
2472
  let token = normalize_access_token(&input.access_token).ok_or(ExtractError::MissingToken)?;
2473
  let base = EndpointBase::new(&input.base_url)?;
2474
+ let _ = ideal_proxies_for_attempt(&input, 1)?;
 
 
 
 
 
2475
  let mut steps = Vec::new();
2476
  add_step_with_progress(
2477
  &mut steps,
 
2483
 
2484
  let mut last_error = None;
2485
  for attempt in 1..=MAX_REBUILD_ATTEMPTS {
2486
+ let (checkout_proxy, promotion_proxy, checkout_index, promotion_index) =
2487
+ ideal_proxies_for_attempt(&input, attempt)?;
2488
  if attempt > 1 {
2489
  add_step_with_progress(
2490
  &mut steps,
 
2500
  transport,
2501
  &base,
2502
  &token,
2503
+ &checkout_proxy,
2504
+ &promotion_proxy,
2505
+ checkout_index,
2506
+ input.checkout_proxy_pool.len().max(1),
2507
+ promotion_index,
2508
+ input.promotion_proxy_pool.len().max(1),
2509
  attempt,
2510
  &mut steps,
2511
  progress,
 
2541
  }))
2542
  }
2543
 
2544
+ fn ideal_proxies_for_attempt(
2545
+ input: &ExtractInput,
2546
+ attempt: usize,
2547
+ ) -> Result<(String, String, usize, usize), ExtractError> {
2548
+ if !input.checkout_proxy_pool.is_empty() || !input.promotion_proxy_pool.is_empty() {
2549
+ if input.checkout_proxy_pool.is_empty() {
2550
+ return Err(ExtractError::MissingCheckoutProxyPool);
2551
+ }
2552
+ if input.promotion_proxy_pool.is_empty() {
2553
+ return Err(ExtractError::MissingPromotionProxyPool);
2554
+ }
2555
+ let checkout_index = (attempt.saturating_sub(1)) % input.checkout_proxy_pool.len();
2556
+ let promotion_index = (attempt.saturating_sub(1)) % input.promotion_proxy_pool.len();
2557
+ return Ok((
2558
+ input.checkout_proxy_pool[checkout_index].clone(),
2559
+ input.promotion_proxy_pool[promotion_index].clone(),
2560
+ checkout_index + 1,
2561
+ promotion_index + 1,
2562
+ ));
2563
+ }
2564
+
2565
+ if input.proxy.trim().is_empty() {
2566
+ return Err(ExtractError::BadResponse(
2567
+ "proxy is required for strict NL-bootstrap / VN-promotion / NL-iDEAL extraction"
2568
+ .to_string(),
2569
+ ));
2570
+ }
2571
+ let attempt_proxy = proxy_seed_for_attempt(&input.proxy, attempt);
2572
+ Ok((
2573
+ proxy_for_region(&attempt_proxy, CHECKOUT_REGION),
2574
+ proxy_for_region(&attempt_proxy, PROMOTION_REGION),
2575
+ 1,
2576
+ 1,
2577
+ ))
2578
+ }
2579
+
2580
  async fn run_ideal_attempt<T: Transport>(
2581
  transport: &mut T,
2582
  base: &EndpointBase,
2583
  token: &str,
2584
+ checkout_proxy: &str,
2585
+ promotion_proxy: &str,
2586
+ checkout_proxy_index: usize,
2587
+ checkout_proxy_count: usize,
2588
+ promotion_proxy_index: usize,
2589
+ promotion_proxy_count: usize,
2590
  attempt: usize,
2591
  steps: &mut Vec<Step>,
2592
  progress: Option<&ProgressSink>,
2593
  ) -> Result<ExtractOutput, ExtractError> {
2594
+ let provider_proxy = checkout_proxy;
2595
+ // Provider resolution and approval reuse the submitted Checkout route.
2596
+ // approve_with_retries may refresh a rotating-proxy SID after an
2597
+ // unsuccessful response, but it never switches to another configured pool.
2598
+ let approve_proxy = checkout_proxy;
 
 
 
2599
  add_step_with_progress(
2600
  steps,
2601
  "proxy chain",
2602
  "ok",
2603
  &format!(
2604
+ "attempt {attempt}/{MAX_REBUILD_ATTEMPTS}; checkout pool {checkout_proxy_index}/{checkout_proxy_count}; promotion pool {promotion_proxy_index}/{promotion_proxy_count}; provider/approve reuse checkout"
2605
  ),
2606
  progress,
2607
  );
 
2611
  transport,
2612
  &base,
2613
  &chatgpt_headers,
2614
+ checkout_proxy,
2615
  LinkType::Ideal,
2616
  )
2617
  .await?;
 
2659
  &base,
2660
  &chatgpt_headers,
2661
  &checkout,
2662
+ promotion_proxy,
2663
  )
2664
  .await?;
2665
  add_step_with_progress(
 
2795
  &base,
2796
  &chatgpt_headers,
2797
  &checkout,
2798
+ approve_proxy,
2799
  LinkType::Ideal,
2800
  Some(ApproveRedirectPoll {
2801
  stripe_pk: &stripe_pk,
 
5662
  access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
5663
  .to_string(),
5664
  proxy: "http://user-region-US-sid-old-t-1:pass@proxy.example:3010".to_string(),
5665
+ checkout_proxy_pool: Vec::new(),
5666
+ promotion_proxy_pool: Vec::new(),
5667
  base_url: "http://IP_REDACTED:8792".to_string(),
5668
  link_type: "ideal".to_string(),
5669
  },
 
5752
  );
5753
  }
5754
 
5755
+ #[tokio::test]
5756
+ async fn submitted_ideal_pools_route_promotion_only_through_promotion_proxy() {
5757
+ let checkout_proxy = "http://checkout-user:pass@checkout.example:3010";
5758
+ let promotion_proxy = "http://promotion-user:pass@promotion.example:3020";
5759
+ let mut transport = FakeTransport::default();
5760
+ extract_ideal_link(
5761
+ &mut transport,
5762
+ ExtractInput {
5763
+ access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
5764
+ .to_string(),
5765
+ proxy: checkout_proxy.to_string(),
5766
+ checkout_proxy_pool: vec![checkout_proxy.to_string()],
5767
+ promotion_proxy_pool: vec![promotion_proxy.to_string()],
5768
+ base_url: "http://IP_REDACTED:8792".to_string(),
5769
+ link_type: "ideal".to_string(),
5770
+ },
5771
+ )
5772
+ .await
5773
+ .expect("submitted proxy pools should complete the fake iDEAL flow");
5774
+
5775
+ for request in &transport.requests {
5776
+ if request
5777
+ .url
5778
+ .ends_with("/backend-api/payments/checkout/update")
5779
+ {
5780
+ assert_eq!(request.proxy_url, promotion_proxy);
5781
+ } else {
5782
+ assert_eq!(
5783
+ request.proxy_url, checkout_proxy,
5784
+ "non-promotion request unexpectedly changed proxy: {}",
5785
+ request.url
5786
+ );
5787
+ }
5788
+ }
5789
+ }
5790
+
5791
+ #[test]
5792
+ fn submitted_ideal_pools_rotate_independently_by_rebuild_attempt() {
5793
+ let input = ExtractInput {
5794
+ access_token: "at_test".to_string(),
5795
+ proxy: "http://checkout-one.example:3010".to_string(),
5796
+ checkout_proxy_pool: vec![
5797
+ "http://checkout-one.example:3010".to_string(),
5798
+ "http://checkout-two.example:3010".to_string(),
5799
+ ],
5800
+ promotion_proxy_pool: vec![
5801
+ "http://promotion-one.example:3020".to_string(),
5802
+ "http://promotion-two.example:3020".to_string(),
5803
+ "http://promotion-three.example:3020".to_string(),
5804
+ ],
5805
+ base_url: String::new(),
5806
+ link_type: "ideal".to_string(),
5807
+ };
5808
+
5809
+ let attempt_four = ideal_proxies_for_attempt(&input, 4)
5810
+ .expect("both submitted pools should be selectable");
5811
+ assert_eq!(attempt_four.0, "http://checkout-two.example:3010");
5812
+ assert_eq!(attempt_four.1, "http://promotion-one.example:3020");
5813
+ assert_eq!((attempt_four.2, attempt_four.3), (2, 1));
5814
+ }
5815
+
5816
  #[test]
5817
  fn ideal_method_guard_accepts_nl_checkout_and_rejects_card_link_only_session() {
5818
  let supported = serde_json::json!({
 
5916
  access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
5917
  .to_string(),
5918
  proxy: "http://user-region-US-sid-old-t-1:pass@proxy.example:3010".to_string(),
5919
+ checkout_proxy_pool: Vec::new(),
5920
+ promotion_proxy_pool: Vec::new(),
5921
  base_url: "http://IP_REDACTED:8792".to_string(),
5922
  link_type: "ideal".to_string(),
5923
  },
 
5939
  ExtractInput {
5940
  access_token: " ".to_string(),
5941
  proxy: String::new(),
5942
+ checkout_proxy_pool: Vec::new(),
5943
+ promotion_proxy_pool: Vec::new(),
5944
  base_url: "http://IP_REDACTED:8792".to_string(),
5945
  link_type: "ideal".to_string(),
5946
  },
 
5963
  access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
5964
  .to_string(),
5965
  proxy: String::new(),
5966
+ checkout_proxy_pool: Vec::new(),
5967
+ promotion_proxy_pool: Vec::new(),
5968
  base_url: "https://collector.example.test".to_string(),
5969
  link_type: "ideal".to_string(),
5970
  },
 
5994
  access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
5995
  .to_string(),
5996
  proxy: String::new(),
5997
+ checkout_proxy_pool: Vec::new(),
5998
+ promotion_proxy_pool: Vec::new(),
5999
  base_url: base_url.to_string(),
6000
  link_type: "ideal".to_string(),
6001
  },
 
6091
  let html = frontend_html();
6092
 
6093
  assert!(html.contains("iDEAL 链接提取器"));
6094
+ assert!(html.contains("Access Token 或 session JSON"));
6095
+ assert!(html.contains("提取 iDEAL 链"));
 
6096
  assert!(html.contains("id=\"access-token\""));
6097
+ assert!(html.contains("id=\"checkout-proxy-pool\""));
6098
+ assert!(html.contains("id=\"promotion-proxy-pool\""));
6099
+ assert!(html.contains("iDEAL Checkout 主代理池(每行一个)"));
6100
+ assert!(html.contains("iDEAL Promotion Update 代理池(每行一个)"));
6101
+ assert!(html.contains("checkout_proxy_pool"));
6102
+ assert!(html.contains("promotion_proxy_pool"));
6103
  assert!(html.contains("/api/extract"));
 
6104
  assert!(html.contains("排队中"));
6105
+ assert!(html.contains("正在执行完整 iDEAL 链路"));
6106
  assert!(html.contains("id=\"long-url\""));
6107
  assert!(html.contains("overflow-wrap: anywhere"));
6108
+ assert!(html.contains("/api/auth/me"));
6109
+ assert!(html.contains("/api/cdk/bind"));
6110
+ assert!(html.contains("/cancel"));
6111
+ assert!(!html.contains("id=\"provider-proxy"));
6112
+ assert!(!html.contains("providerProxy"));
6113
+ assert!(!html.contains("link_type:"));
6114
+ assert!(!html.contains("localStorage"));
6115
+ assert!(!html.contains("PayPal"));
6116
+ assert!(!html.contains("UPI"));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6117
  }
6118
 
6119
  #[test]
 
6132
  }
6133
 
6134
  #[test]
6135
+ fn api_input_uses_submitted_proxy_pools_and_default_base_url() {
6136
+ let input = extract_input_for_api(ExtractApiInput {
6137
+ access_token: "at_test".to_string(),
6138
+ link_type: None,
6139
+ checkout_proxy_pool: "checkout.example:3010\ncheckout.example:3010".to_string(),
6140
+ promotion_proxy_pool: "http://promotion.example:3010".to_string(),
6141
+ })
6142
+ .expect("both submitted pools should be accepted");
6143
 
6144
  assert_eq!(input.access_token, "at_test");
6145
+ assert_eq!(input.proxy, "http://checkout.example:3010");
6146
+ assert_eq!(input.checkout_proxy_pool, vec!["http://checkout.example:3010"]);
6147
+ assert_eq!(input.promotion_proxy_pool, vec!["http://promotion.example:3010"]);
6148
+ assert!(input.base_url.is_empty());
6149
+ assert_eq!(input.link_type, "ideal");
6150
+ }
6151
+
6152
+ #[test]
6153
+ fn proxy_pool_parser_is_line_based_normalized_and_order_preserving() {
6154
  assert_eq!(
6155
+ parse_proxy_pool(
6156
+ " host-one.example:8000 \r\n\r\nhttp://user:pass@host-two.example:9000\n host-one.example:8000 "
6157
+ ),
6158
+ vec![
6159
+ "http://host-one.example:8000".to_string(),
6160
+ "http://user:pass@host-two.example:9000".to_string(),
6161
+ ]
6162
+ );
6163
+ assert_eq!(
6164
+ parse_proxy_pool("one.example:80,two.example:81"),
6165
+ vec!["http://one.example:80,two.example:81".to_string()],
6166
+ "commas are part of a line; only newlines split pool entries"
6167
  );
6168
+ }
6169
+
6170
+ #[test]
6171
+ fn api_input_requires_both_proxy_pools() {
6172
+ let missing_checkout = extract_input_for_api(ExtractApiInput {
6173
+ access_token: "at_test".to_string(),
6174
+ link_type: None,
6175
+ checkout_proxy_pool: String::new(),
6176
+ promotion_proxy_pool: "promotion.example:3010".to_string(),
6177
+ });
6178
+ assert!(matches!(
6179
+ missing_checkout,
6180
+ Err(ExtractError::MissingCheckoutProxyPool)
6181
+ ));
6182
+
6183
+ let missing_promotion = extract_input_for_api(ExtractApiInput {
6184
+ access_token: "at_test".to_string(),
6185
+ link_type: None,
6186
+ checkout_proxy_pool: "checkout.example:3010".to_string(),
6187
+ promotion_proxy_pool: String::new(),
6188
+ });
6189
+ assert!(matches!(
6190
+ missing_promotion,
6191
+ Err(ExtractError::MissingPromotionProxyPool)
6192
+ ));
6193
  }
6194
 
6195
  #[tokio::test]
 
6217
  axum::Json(ExtractApiInput {
6218
  access_token: " ".to_string(),
6219
  link_type: None,
6220
+ checkout_proxy_pool: "checkout.example:3010".to_string(),
6221
+ promotion_proxy_pool: "promotion.example:3010".to_string(),
6222
  }),
6223
  )
6224
  .await;
 
6242
  access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
6243
  .to_string(),
6244
  link_type: None,
6245
+ checkout_proxy_pool: "checkout.example:3010".to_string(),
6246
+ promotion_proxy_pool: "promotion.example:3010".to_string(),
6247
  }),
6248
  )
6249
  .await;
 
6278
  axum::Json(ExtractApiInput {
6279
  access_token: token.clone(),
6280
  link_type: None,
6281
+ checkout_proxy_pool: "checkout.example:3010".to_string(),
6282
+ promotion_proxy_pool: "promotion.example:3010".to_string(),
6283
  }),
6284
  )
6285
  .await;
 
6292
  axum::Json(ExtractApiInput {
6293
  access_token: token,
6294
  link_type: None,
6295
+ checkout_proxy_pool: "checkout.example:3010".to_string(),
6296
+ promotion_proxy_pool: "promotion.example:3010".to_string(),
6297
  }),
6298
  )
6299
  .await;
 
6315
  axum::Json(ExtractApiInput {
6316
  access_token: "at_test".to_string(),
6317
  link_type: None,
6318
+ checkout_proxy_pool: "checkout.example:3010".to_string(),
6319
+ promotion_proxy_pool: "promotion.example:3010".to_string(),
6320
  }),
6321
  )
6322
  .await;
 
6338
  axum::Json(ExtractApiInput {
6339
  access_token: "at_test".to_string(),
6340
  link_type: None,
6341
+ checkout_proxy_pool: "checkout.example:3010".to_string(),
6342
+ promotion_proxy_pool: "promotion.example:3010".to_string(),
6343
  }),
6344
  )
6345
  .await;
 
6362
  axum::Json(ExtractApiInput {
6363
  access_token: "at_test".to_string(),
6364
  link_type: None,
6365
+ checkout_proxy_pool: "checkout.example:3010".to_string(),
6366
+ promotion_proxy_pool: "promotion.example:3010".to_string(),
6367
  }),
6368
  )
6369
  .await;
 
6558
  access_token: "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6ImpAZXhhbXBsZS5jb20ifQ.sig"
6559
  .to_string(),
6560
  link_type: None,
6561
+ checkout_proxy_pool: "checkout.example:3010".to_string(),
6562
+ promotion_proxy_pool: "promotion.example:3010".to_string(),
6563
  },
6564
+ )
6565
+ .expect("valid pools should be accepted");
6566
 
6567
  assert!(response.base_url.is_empty());
6568
  }