@obbyx/x402-obyte 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +65 -2
- package/dist/batch/client-store.d.ts +50 -0
- package/dist/batch/client-store.d.ts.map +1 -0
- package/dist/batch/client-store.js +93 -0
- package/dist/batch/client-store.js.map +1 -0
- package/dist/batch/client.d.ts +63 -0
- package/dist/batch/client.d.ts.map +1 -0
- package/dist/batch/client.js +226 -0
- package/dist/batch/client.js.map +1 -0
- package/dist/batch/facilitator.d.ts +73 -0
- package/dist/batch/facilitator.d.ts.map +1 -0
- package/dist/batch/facilitator.js +341 -0
- package/dist/batch/facilitator.js.map +1 -0
- package/dist/batch/gateway.d.ts +21 -0
- package/dist/batch/gateway.d.ts.map +1 -0
- package/dist/batch/gateway.js +2 -0
- package/dist/batch/gateway.js.map +1 -0
- package/dist/batch/requirements.d.ts +52 -0
- package/dist/batch/requirements.d.ts.map +1 -0
- package/dist/batch/requirements.js +80 -0
- package/dist/batch/requirements.js.map +1 -0
- package/dist/batch/store.d.ts +112 -0
- package/dist/batch/store.d.ts.map +1 -0
- package/dist/batch/store.js +198 -0
- package/dist/batch/store.js.map +1 -0
- package/dist/batch/watcher-protocol.d.ts +91 -0
- package/dist/batch/watcher-protocol.d.ts.map +1 -0
- package/dist/batch/watcher-protocol.js +82 -0
- package/dist/batch/watcher-protocol.js.map +1 -0
- package/dist/binding/binding.d.ts +32 -0
- package/dist/binding/binding.d.ts.map +1 -0
- package/dist/binding/binding.js +19 -0
- package/dist/binding/binding.js.map +1 -0
- package/dist/coins/composer.d.ts +58 -0
- package/dist/coins/composer.d.ts.map +1 -0
- package/dist/coins/composer.js +102 -0
- package/dist/coins/composer.js.map +1 -0
- package/dist/coins/index.d.ts +4 -0
- package/dist/coins/index.d.ts.map +1 -0
- package/dist/coins/index.js +4 -0
- package/dist/coins/index.js.map +1 -0
- package/dist/coins/reservations.d.ts +37 -0
- package/dist/coins/reservations.d.ts.map +1 -0
- package/dist/coins/reservations.js +102 -0
- package/dist/coins/reservations.js.map +1 -0
- package/dist/coins/selection.d.ts +42 -0
- package/dist/coins/selection.d.ts.map +1 -0
- package/dist/coins/selection.js +60 -0
- package/dist/coins/selection.js.map +1 -0
- package/dist/exact/client.d.ts +33 -0
- package/dist/exact/client.d.ts.map +1 -0
- package/dist/exact/client.js +93 -0
- package/dist/exact/client.js.map +1 -0
- package/dist/exact/facilitator-v1.d.ts +48 -0
- package/dist/exact/facilitator-v1.d.ts.map +1 -0
- package/dist/exact/facilitator-v1.js +81 -0
- package/dist/exact/facilitator-v1.js.map +1 -0
- package/dist/exact/facilitator.d.ts +94 -0
- package/dist/exact/facilitator.d.ts.map +1 -0
- package/dist/exact/facilitator.js +361 -0
- package/dist/exact/facilitator.js.map +1 -0
- package/dist/exact/finality.d.ts +18 -0
- package/dist/exact/finality.d.ts.map +1 -0
- package/dist/exact/finality.js +45 -0
- package/dist/exact/finality.js.map +1 -0
- package/dist/exact/ledger-checks.d.ts +15 -0
- package/dist/exact/ledger-checks.d.ts.map +1 -0
- package/dist/exact/ledger-checks.js +85 -0
- package/dist/exact/ledger-checks.js.map +1 -0
- package/dist/exact/reasons.d.ts +29 -0
- package/dist/exact/reasons.d.ts.map +1 -0
- package/dist/exact/reasons.js +21 -0
- package/dist/exact/reasons.js.map +1 -0
- package/dist/exact/requirements.d.ts +37 -0
- package/dist/exact/requirements.d.ts.map +1 -0
- package/dist/exact/requirements.js +80 -0
- package/dist/exact/requirements.js.map +1 -0
- package/dist/exact/store.d.ts +136 -0
- package/dist/exact/store.d.ts.map +1 -0
- package/dist/exact/store.js +217 -0
- package/dist/exact/store.js.map +1 -0
- package/dist/hub/heartbeat.d.ts +12 -0
- package/dist/hub/heartbeat.d.ts.map +1 -0
- package/dist/hub/heartbeat.js +17 -0
- package/dist/hub/heartbeat.js.map +1 -0
- package/dist/hub/hub-call.d.ts +20 -0
- package/dist/hub/hub-call.d.ts.map +1 -0
- package/dist/hub/hub-call.js +30 -0
- package/dist/hub/hub-call.js.map +1 -0
- package/dist/hub/schemas.d.ts +41 -0
- package/dist/hub/schemas.d.ts.map +1 -0
- package/dist/hub/schemas.js +71 -0
- package/dist/hub/schemas.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/util/keyed-queue.d.ts +13 -0
- package/dist/util/keyed-queue.d.ts.map +1 -0
- package/dist/util/keyed-queue.js +25 -0
- package/dist/util/keyed-queue.js.map +1 -0
- package/package.json +51 -3
- package/src/batch/client-store.ts +167 -0
- package/src/batch/client.ts +317 -0
- package/src/batch/facilitator.ts +461 -0
- package/src/batch/gateway.ts +22 -0
- package/src/batch/requirements.ts +108 -0
- package/src/batch/store.ts +359 -0
- package/src/batch/watcher-protocol.ts +89 -0
- package/src/binding/binding.ts +50 -0
- package/src/coins/composer.ts +159 -0
- package/src/coins/index.ts +9 -0
- package/src/coins/reservations.ts +139 -0
- package/src/coins/selection.ts +93 -0
- package/src/exact/client.ts +144 -0
- package/src/exact/facilitator-v1.ts +137 -0
- package/src/exact/facilitator.ts +496 -0
- package/src/exact/finality.ts +56 -0
- package/src/exact/ledger-checks.ts +113 -0
- package/src/exact/reasons.ts +25 -0
- package/src/exact/requirements.ts +109 -0
- package/src/exact/store.ts +399 -0
- package/src/hub/heartbeat.ts +18 -0
- package/src/hub/hub-call.ts +46 -0
- package/src/hub/schemas.ts +89 -0
- package/src/index.ts +111 -0
- package/src/util/keyed-queue.ts +25 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export { type HubOutcome, hubCall } from './hub/hub-call.js';
|
|
2
|
+
export {
|
|
3
|
+
EXACT_SCHEME,
|
|
4
|
+
type ExactExtra,
|
|
5
|
+
type ParsedExactRequirements,
|
|
6
|
+
acceptedMatches,
|
|
7
|
+
canonical,
|
|
8
|
+
exactExtraSchema,
|
|
9
|
+
parseExactRequirements,
|
|
10
|
+
} from './exact/requirements.js';
|
|
11
|
+
export {
|
|
12
|
+
type NewSettlement,
|
|
13
|
+
type SettlementEvent,
|
|
14
|
+
type SettlementRecord,
|
|
15
|
+
type SettlementState,
|
|
16
|
+
type SettlementStore,
|
|
17
|
+
SqliteSettlementStore,
|
|
18
|
+
type TransitionPatch,
|
|
19
|
+
StoreLockedError,
|
|
20
|
+
TERMINAL_STATES,
|
|
21
|
+
} from './exact/store.js';
|
|
22
|
+
export {
|
|
23
|
+
EXACT_SETTLE_REASONS,
|
|
24
|
+
HISTORY_PROBE_ADDRESS,
|
|
25
|
+
ExactObyteFacilitator,
|
|
26
|
+
type ExactObyteFacilitatorOptions,
|
|
27
|
+
type FinalityPolicy,
|
|
28
|
+
} from './exact/facilitator.js';
|
|
29
|
+
export { ExactObyteClient, type ExactObyteClientOptions } from './exact/client.js';
|
|
30
|
+
export { type WatcherGateway, type WatcherHealth } from './batch/gateway.js';
|
|
31
|
+
export {
|
|
32
|
+
BATCH_REASONS,
|
|
33
|
+
BATCH_SCHEME,
|
|
34
|
+
type BatchExtra,
|
|
35
|
+
type ParsedBatchRequirements,
|
|
36
|
+
type VoucherMessage,
|
|
37
|
+
batchExtraSchema,
|
|
38
|
+
parseBatchRequirements,
|
|
39
|
+
voucherMessageSchema,
|
|
40
|
+
} from './batch/requirements.js';
|
|
41
|
+
export {
|
|
42
|
+
type AppendInput,
|
|
43
|
+
type AppendResult,
|
|
44
|
+
type BatchStore,
|
|
45
|
+
SqliteBatchStore,
|
|
46
|
+
type ChannelRow,
|
|
47
|
+
type CommitmentRow,
|
|
48
|
+
type CommitmentState,
|
|
49
|
+
} from './batch/store.js';
|
|
50
|
+
export { BatchObyteFacilitator, type BatchObyteFacilitatorOptions } from './batch/facilitator.js';
|
|
51
|
+
export {
|
|
52
|
+
type ClientMessage,
|
|
53
|
+
type CommitmentMessage,
|
|
54
|
+
type ServerMessage,
|
|
55
|
+
WATCHER_LOGIN_PURPOSE,
|
|
56
|
+
clientMessageSchema,
|
|
57
|
+
commitmentMessageSchema,
|
|
58
|
+
loginMessage,
|
|
59
|
+
serverMessageSchema,
|
|
60
|
+
verifyWatcherLogin,
|
|
61
|
+
} from './batch/watcher-protocol.js';
|
|
62
|
+
export { startHeartbeat } from './hub/heartbeat.js';
|
|
63
|
+
export {
|
|
64
|
+
ClientChannelStore,
|
|
65
|
+
type ClientChannel,
|
|
66
|
+
type PendingVoucher,
|
|
67
|
+
} from './batch/client-store.js';
|
|
68
|
+
export {
|
|
69
|
+
BatchObyteClient,
|
|
70
|
+
type BatchClientOptions,
|
|
71
|
+
MIN_DEPOSIT,
|
|
72
|
+
TRIGGER_FEE,
|
|
73
|
+
addressOfKey,
|
|
74
|
+
closeChannel,
|
|
75
|
+
confirmClose,
|
|
76
|
+
deposit,
|
|
77
|
+
openChannel,
|
|
78
|
+
} from './batch/client.js';
|
|
79
|
+
export {
|
|
80
|
+
CoinReservations,
|
|
81
|
+
type HistoryJoint,
|
|
82
|
+
type ReservationRow,
|
|
83
|
+
ReservingComposer,
|
|
84
|
+
type ReservingComposerOptions,
|
|
85
|
+
type Utxo,
|
|
86
|
+
inputKey,
|
|
87
|
+
selectCoins,
|
|
88
|
+
unspentOutputs,
|
|
89
|
+
} from './coins/index.js';
|
|
90
|
+
export {
|
|
91
|
+
type BindingInput,
|
|
92
|
+
bindingsEqual,
|
|
93
|
+
computeBinding,
|
|
94
|
+
newQuoteId,
|
|
95
|
+
sha256Hex,
|
|
96
|
+
} from './binding/binding.js';
|
|
97
|
+
export {
|
|
98
|
+
ExactObyteFacilitatorV1,
|
|
99
|
+
type PaymentPayloadV1,
|
|
100
|
+
type PaymentRequirementsV1,
|
|
101
|
+
requirementsV1ToV2,
|
|
102
|
+
requirementsV2ToV1,
|
|
103
|
+
} from './exact/facilitator-v1.js';
|
|
104
|
+
export {
|
|
105
|
+
type LedgerUnit,
|
|
106
|
+
type ProofchainBall,
|
|
107
|
+
parseHistory,
|
|
108
|
+
parseLedgerUnit,
|
|
109
|
+
parseStateVars,
|
|
110
|
+
} from './hub/schemas.js';
|
|
111
|
+
export { KeyedQueue } from './util/keyed-queue.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs tasks one at a time per key, in arrival order; different keys run in
|
|
3
|
+
* parallel. A failing task never blocks the ones queued after it. Used where
|
|
4
|
+
* check-then-act must not interleave within one process: per channel in the
|
|
5
|
+
* batch facilitator and in the seller watcher.
|
|
6
|
+
*/
|
|
7
|
+
export class KeyedQueue {
|
|
8
|
+
private readonly tails = new Map<string, Promise<unknown>>();
|
|
9
|
+
|
|
10
|
+
run<T>(key: string, task: () => Promise<T>): Promise<T> {
|
|
11
|
+
const previous = this.tails.get(key) ?? Promise.resolve();
|
|
12
|
+
const result = previous.then(task, task);
|
|
13
|
+
const tail = result.catch(() => undefined);
|
|
14
|
+
this.tails.set(key, tail);
|
|
15
|
+
void tail.then(() => {
|
|
16
|
+
if (this.tails.get(key) === tail) this.tails.delete(key);
|
|
17
|
+
});
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Keys with queued or running tasks (for tests and diagnostics). */
|
|
22
|
+
get size(): number {
|
|
23
|
+
return this.tails.size;
|
|
24
|
+
}
|
|
25
|
+
}
|