@integraledger/profile-facilitator 0.3.1 → 0.5.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/README.md +642 -456
- package/dist/answers.d.ts +11 -4
- package/dist/answers.js +24 -0
- package/dist/core.d.ts +51 -0
- package/dist/core.js +758 -0
- package/dist/http.d.ts +20 -3
- package/dist/http.js +32 -7
- package/dist/index.d.ts +12 -36
- package/dist/index.js +9 -162
- package/dist/module.d.ts +372 -0
- package/dist/module.js +13 -0
- package/dist/modules/algorand/index.d.ts +22 -0
- package/dist/modules/algorand/index.js +247 -0
- package/dist/modules/algorand/own.d.ts +26 -0
- package/dist/modules/algorand/own.js +231 -0
- package/dist/modules/aptos/index.d.ts +23 -0
- package/dist/modules/aptos/index.js +232 -0
- package/dist/modules/cardano/index.d.ts +18 -0
- package/dist/modules/cardano/index.js +124 -0
- package/dist/modules/casper/index.d.ts +120 -0
- package/dist/modules/casper/index.js +442 -0
- package/dist/modules/concordium/index.d.ts +16 -0
- package/dist/modules/concordium/index.js +77 -0
- package/dist/modules/erc7710/index.d.ts +26 -0
- package/dist/modules/erc7710/index.js +220 -0
- package/dist/modules/evm/forms.d.ts +74 -0
- package/dist/modules/evm/forms.js +182 -0
- package/dist/modules/evm/index.d.ts +40 -0
- package/dist/modules/evm/index.js +148 -0
- package/dist/modules/evm/node.d.ts +29 -0
- package/dist/modules/evm/node.js +222 -0
- package/dist/modules/hedera/executor.d.ts +63 -0
- package/dist/modules/hedera/executor.js +343 -0
- package/dist/modules/hedera/index.d.ts +23 -0
- package/dist/modules/hedera/index.js +136 -0
- package/dist/modules/hedera/mirror.d.ts +32 -0
- package/dist/modules/hedera/mirror.js +111 -0
- package/dist/modules/index.d.ts +23 -0
- package/dist/modules/index.js +24 -0
- package/dist/modules/lnbtc/index.d.ts +10 -0
- package/dist/modules/lnbtc/index.js +111 -0
- package/dist/modules/near/index.d.ts +18 -0
- package/dist/modules/near/index.js +246 -0
- package/dist/modules/polkadot/index.d.ts +12 -0
- package/dist/modules/polkadot/index.js +149 -0
- package/dist/modules/polkadot/rail.d.ts +40 -0
- package/dist/{polkadot.js → modules/polkadot/rail.js} +214 -288
- package/dist/modules/solana/index.d.ts +60 -0
- package/dist/modules/solana/index.js +304 -0
- package/dist/modules/solana/reader.d.ts +25 -0
- package/dist/modules/solana/reader.js +194 -0
- package/dist/modules/solana/state.d.ts +6 -0
- package/dist/modules/solana/state.js +103 -0
- package/dist/modules/starknet/index.d.ts +35 -0
- package/dist/modules/starknet/index.js +541 -0
- package/dist/modules/starknet/node.d.ts +78 -0
- package/dist/modules/starknet/node.js +339 -0
- package/dist/modules/stellar/index.d.ts +44 -0
- package/dist/modules/stellar/index.js +481 -0
- package/dist/modules/stellar/node.d.ts +57 -0
- package/dist/modules/stellar/node.js +151 -0
- package/dist/modules/sui/index.d.ts +16 -0
- package/dist/modules/sui/index.js +309 -0
- package/dist/modules/sui/node.d.ts +49 -0
- package/dist/modules/sui/node.js +197 -0
- package/dist/modules/ton/index.d.ts +16 -0
- package/dist/modules/ton/index.js +73 -0
- package/dist/modules/tron/index.d.ts +12 -0
- package/dist/modules/tron/index.js +120 -0
- package/dist/modules/tron/rail.d.ts +32 -0
- package/dist/{tron.js → modules/tron/rail.js} +206 -195
- package/dist/modules/xrpl/index.d.ts +28 -0
- package/dist/modules/xrpl/index.js +299 -0
- package/dist/modules/xrpl/node.d.ts +52 -0
- package/dist/modules/xrpl/node.js +231 -0
- package/dist/modules/xrpl/upto.d.ts +5 -0
- package/dist/modules/xrpl/upto.js +269 -0
- package/dist/record.d.ts +131 -0
- package/dist/record.js +330 -0
- package/dist/unexpected.d.ts +3 -2
- package/dist/unexpected.js +2 -1
- package/dist/wrapper.d.ts +68 -0
- package/dist/wrapper.js +126 -0
- package/package.json +47 -12
- package/dist/polkadot.d.ts +0 -21
- package/dist/store.d.ts +0 -59
- package/dist/store.js +0 -103
- package/dist/tron.d.ts +0 -12
- /package/dist/{base58check.d.ts → modules/tron/base58check.d.ts} +0 -0
- /package/dist/{base58check.js → modules/tron/base58check.js} +0 -0
package/dist/answers.d.ts
CHANGED
|
@@ -20,11 +20,12 @@ export interface FacilitatorRequest {
|
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* The reasons a payment is refused. The x402 codes are the x402 specification's (§9); `invalid_transaction_state` in
|
|
23
|
-
* a verify answer is
|
|
24
|
-
* `invalid_transaction` are this facilitator's: a Tron owner permission that does not accept the
|
|
25
|
-
*
|
|
23
|
+
* a verify answer is an instrument the record or the chain already holds. `unsupported_permission`,
|
|
24
|
+
* `invalid_transaction` and `fee_budget_spent` are this facilitator's: a Tron owner permission that does not accept the
|
|
25
|
+
* transaction's signatures, a transaction the node refuses in simulation or validation, and a network whose fee budget
|
|
26
|
+
* is spent, so that nothing is sent. A published class's own reasons pass unchanged.
|
|
26
27
|
*/
|
|
27
|
-
export type InvalidReason = "invalid_x402_version" | "unsupported_scheme" | "invalid_network" | "invalid_payment_requirements" | "invalid_payload" | "unsupported_permission" | "invalid_transaction" | "invalid_transaction_state" | "unexpected_verify_error";
|
|
28
|
+
export type InvalidReason = "invalid_x402_version" | "unsupported_scheme" | "invalid_network" | "invalid_payment_requirements" | "invalid_payload" | "unsupported_permission" | "invalid_transaction" | "invalid_transaction_state" | "fee_budget_spent" | "unexpected_verify_error";
|
|
28
29
|
export type VerifyAnswer = {
|
|
29
30
|
isValid: true;
|
|
30
31
|
payer: string;
|
|
@@ -78,3 +79,9 @@ export declare function isObject(v: unknown): v is Record<string, unknown>;
|
|
|
78
79
|
* request, or the reason it is refused.
|
|
79
80
|
*/
|
|
80
81
|
export declare function readRequest(body: unknown): FacilitatorRequest | InvalidReason;
|
|
82
|
+
/**
|
|
83
|
+
* The shape checks of a request for any scheme: the versions, the objects a module reads, and the scheme and the
|
|
84
|
+
* network as strings. Returns the typed request, or the reason it is refused. Which scheme and network the settler
|
|
85
|
+
* serves is the core's to answer, from its configuration.
|
|
86
|
+
*/
|
|
87
|
+
export declare function readShape(body: unknown): FacilitatorRequest | InvalidReason;
|
package/dist/answers.js
CHANGED
|
@@ -82,3 +82,27 @@ export function readRequest(body) {
|
|
|
82
82
|
return "invalid_network";
|
|
83
83
|
return body;
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* The shape checks of a request for any scheme: the versions, the objects a module reads, and the scheme and the
|
|
87
|
+
* network as strings. Returns the typed request, or the reason it is refused. Which scheme and network the settler
|
|
88
|
+
* serves is the core's to answer, from its configuration.
|
|
89
|
+
*/
|
|
90
|
+
export function readShape(body) {
|
|
91
|
+
if (!isObject(body))
|
|
92
|
+
return "invalid_payload";
|
|
93
|
+
if (body["x402Version"] !== 2)
|
|
94
|
+
return "invalid_x402_version";
|
|
95
|
+
const p = body["paymentPayload"];
|
|
96
|
+
const r = body["paymentRequirements"];
|
|
97
|
+
if (!isObject(p) || !isObject(r))
|
|
98
|
+
return "invalid_payload";
|
|
99
|
+
if (p["x402Version"] !== 2)
|
|
100
|
+
return "invalid_x402_version";
|
|
101
|
+
if (!isObject(p["payload"]))
|
|
102
|
+
return "invalid_payload";
|
|
103
|
+
if (typeof r["scheme"] !== "string")
|
|
104
|
+
return "unsupported_scheme";
|
|
105
|
+
if (typeof r["network"] !== "string")
|
|
106
|
+
return "invalid_network";
|
|
107
|
+
return body;
|
|
108
|
+
}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Network } from "@x402/core/types";
|
|
2
|
+
import type { ModuleName } from "./module.js";
|
|
3
|
+
import type { Listed, ModulesConfig } from "./modules/index.js";
|
|
4
|
+
/** One network's fee budget as the operator configures it: an amount of its fee asset over a period of seconds. */
|
|
5
|
+
export interface FeeBudgetConfig {
|
|
6
|
+
readonly network: Network;
|
|
7
|
+
/** In the smallest unit of the network's fee asset: a `bigint`, or its decimal digits. */
|
|
8
|
+
readonly amount: bigint | string;
|
|
9
|
+
readonly periodSeconds: number;
|
|
10
|
+
}
|
|
11
|
+
/** The members of the configuration the core reads; each listed module's own member is with them. */
|
|
12
|
+
export interface SettlerConfig {
|
|
13
|
+
/** "host:port" */
|
|
14
|
+
listen: string;
|
|
15
|
+
/** Postgres: the record, the fee count and the modules' durable state. */
|
|
16
|
+
store: {
|
|
17
|
+
url: string;
|
|
18
|
+
};
|
|
19
|
+
/** How long `/settle` waits for inclusion before answering `settlement_pending`; default 30 000. */
|
|
20
|
+
settleWaitMs: number;
|
|
21
|
+
/**
|
|
22
|
+
* The credential every call must present as `Authorization: Bearer <credential>`. A deployment with a module that
|
|
23
|
+
* holds a key does not start without one, since the caller names the payee and the amount and the key pays a fee
|
|
24
|
+
* for whatever is submitted. Its characters are those RFC 6750 admits in a bearer token.
|
|
25
|
+
*/
|
|
26
|
+
credential?: string;
|
|
27
|
+
/** The fee budgets, at most one per network, each on a network a configured module serves. */
|
|
28
|
+
feeBudgets?: readonly FeeBudgetConfig[];
|
|
29
|
+
/**
|
|
30
|
+
* Receives every entry for the operator: what the facilitator saw that its answer does not carry, with `network`,
|
|
31
|
+
* `payer` and `transaction` naming the payment where they are known. `cause` is the error that caused the entry,
|
|
32
|
+
* when there is one; the answer to the client is the same either way, and carries nothing from it. Called once per
|
|
33
|
+
* entry; what it throws, or a promise it returns that rejects, goes to the default with an `operator-log-failed`
|
|
34
|
+
* entry. Default: one JSON line per entry on standard error, the cause as its `cause` (name, message, stack and its
|
|
35
|
+
* own `cause` chain).
|
|
36
|
+
*/
|
|
37
|
+
operatorLog?: (entry: {
|
|
38
|
+
event: string;
|
|
39
|
+
network?: string;
|
|
40
|
+
payer?: string;
|
|
41
|
+
transaction?: string;
|
|
42
|
+
[field: string]: unknown;
|
|
43
|
+
}, cause?: unknown) => void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Starts the settler with the modules of `list` that `c` names. The public start function passes the settler's own
|
|
47
|
+
* list; a test passes one of its own.
|
|
48
|
+
*/
|
|
49
|
+
export declare function serveSettler<List extends readonly Listed<ModuleName, never>[]>(c: SettlerConfig & ModulesConfig<List>, list: List): Promise<{
|
|
50
|
+
close(): Promise<void>;
|
|
51
|
+
}>;
|