@ixo/oracle-runtime-workers 0.33.1 → 0.33.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/hub-actions/transfer.ts +19 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ixo/oracle-runtime-workers",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.2",
|
|
4
4
|
"description": "QiForge oracle runtime for Cloudflare Workers — Durable Object per user (SQLite in WASM over DO storage), Matrix E2EE gateway Durable Object, Hono HTTP/SSE shell.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"@ixo/topic-protocol": "1.0.0-rc.8",
|
|
69
69
|
"survey-core": "2.3.11",
|
|
70
70
|
"@ixo/common": "1.7.1",
|
|
71
|
-
"@ixo/
|
|
72
|
-
"@ixo/
|
|
71
|
+
"@ixo/ixo-transaction": "0.2.0",
|
|
72
|
+
"@ixo/ucan": "2.3.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@cloudflare/vitest-pool-workers": "^0.22.0",
|
|
@@ -406,6 +406,16 @@ const HUB_TRANSIENT_CODES: Readonly<Record<number, readonly string[]>> = {
|
|
|
406
406
|
503: ['transfer_unavailable'],
|
|
407
407
|
};
|
|
408
408
|
|
|
409
|
+
/**
|
|
410
|
+
* Auth Hub's 409 `sequence_reserved`: another card of the owner's is still
|
|
411
|
+
* waiting for their review and holds the account's next transaction, so no
|
|
412
|
+
* new card can be made until that one is approved or declined. Plain words
|
|
413
|
+
* and the next step; the account's sequence is never named (the model
|
|
414
|
+
* repeated "reserved transaction sequence" to the person on devnet).
|
|
415
|
+
*/
|
|
416
|
+
export const PENDING_CARD_WORDS =
|
|
417
|
+
'The owner already has another card waiting for their review, so this one cannot be prepared yet. Tell them, in these words or close to them: “You already have another card waiting for your review. Approve or decline that one first, then I can prepare this.” Do not retry until they have, and never mention sequences or anything technical.';
|
|
418
|
+
|
|
409
419
|
function hubErrorBody(
|
|
410
420
|
body: unknown,
|
|
411
421
|
): { error: string; reason?: string } | null {
|
|
@@ -436,6 +446,8 @@ const HUB_REASON_MAX = 200;
|
|
|
436
446
|
* `not_authorized`, `operation_not_registered`: the transfer or
|
|
437
447
|
* transaction as asked cannot go ahead (with the Hub's reason, quoted and
|
|
438
448
|
* labelled as data, see `quoteHubText`);
|
|
449
|
+
* - 409 `sequence_reserved`: another card is waiting for the owner's
|
|
450
|
+
* review; approve or decline it first (`PENDING_CARD_WORDS`);
|
|
439
451
|
* - 409 `sequence_mismatch`, 503 `transfer_unavailable`: temporary, try
|
|
440
452
|
* again shortly;
|
|
441
453
|
* - any other 409: the account may not use this operation (deterministic,
|
|
@@ -484,10 +496,16 @@ export function hubPrepareRefusal(
|
|
|
484
496
|
undefined,
|
|
485
497
|
status,
|
|
486
498
|
);
|
|
499
|
+
if (status === 409 && parsed.error === 'sequence_reserved')
|
|
500
|
+
return new HubActionRefused('refused', PENDING_CARD_WORDS, undefined, 409);
|
|
487
501
|
if (HUB_TRANSIENT_CODES[status]?.includes(parsed.error))
|
|
488
502
|
return new HubActionRefused(
|
|
489
503
|
'refused',
|
|
490
|
-
|
|
504
|
+
// A sequence race is named by its effect only: the code would read as
|
|
505
|
+
// jargon if repeated to the person.
|
|
506
|
+
parsed.error === 'sequence_mismatch'
|
|
507
|
+
? 'Auth Hub could not prepare this just now because the account changed while it was being prepared; try again shortly.'
|
|
508
|
+
: `Auth Hub is temporarily unavailable for this (${parsed.error}); try again shortly.`,
|
|
491
509
|
undefined,
|
|
492
510
|
status,
|
|
493
511
|
);
|