@rubicon-caliga/core 0.1.0 → 0.1.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/dist/contract.d.ts +3 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/networks.d.ts +10 -0
- package/dist/networks.d.ts.map +1 -0
- package/dist/networks.js +33 -0
- package/dist/networks.js.map +1 -0
- package/dist/pricing.d.ts +7 -6
- package/dist/pricing.d.ts.map +1 -1
- package/dist/pricing.js.map +1 -1
- package/dist/protocol.d.ts +133 -6
- package/dist/protocol.d.ts.map +1 -1
- package/dist/session.d.ts +6 -4
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +3 -3
- package/dist/session.js.map +1 -1
- package/package.json +3 -4
- package/src/contract.ts +3 -0
- package/src/index.ts +1 -0
- package/src/networks.ts +47 -0
- package/src/pricing.ts +7 -6
- package/src/protocol.ts +136 -6
- package/src/session.ts +6 -4
package/dist/contract.d.ts
CHANGED
|
@@ -91,6 +91,9 @@ export interface PaymentActivity {
|
|
|
91
91
|
payTo?: `0x${string}`;
|
|
92
92
|
transactionHash?: string;
|
|
93
93
|
transactionHashes?: string[];
|
|
94
|
+
settlementId?: string;
|
|
95
|
+
settlementIds?: string[];
|
|
96
|
+
buyerWalletAddress?: `0x${string}`;
|
|
94
97
|
transferId?: string;
|
|
95
98
|
createdAt: string;
|
|
96
99
|
}
|
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;;;;;GASG;AAEH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAA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AM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,YAAY,CAAC;IACzB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,YAAY,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface SettlementNetworkInfo {
|
|
2
|
+
network: string;
|
|
3
|
+
networkLabel: string;
|
|
4
|
+
circleChain?: string;
|
|
5
|
+
environment: "testnet" | "mainnet" | "unknown";
|
|
6
|
+
fundingMethod: string;
|
|
7
|
+
buyerWalletExplanation?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function settlementNetworkInfo(network: string | undefined): SettlementNetworkInfo;
|
|
10
|
+
//# sourceMappingURL=networks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../src/networks.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAC/C,aAAa,EAAE,MAAM,CAAC;IACtB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAeD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,qBAAqB,CAwBxF"}
|
package/dist/networks.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const ARC_TESTNET = {
|
|
2
|
+
network: "eip155:5042002",
|
|
3
|
+
networkLabel: "Arc Testnet",
|
|
4
|
+
circleChain: "ARC-TESTNET",
|
|
5
|
+
environment: "testnet",
|
|
6
|
+
fundingMethod: "Circle testnet funds on ARC-TESTNET. Use Circle's testnet faucet / Gateway testnet funding flow; do not send mainnet fiat or crypto.",
|
|
7
|
+
buyerWalletExplanation: "Circle CLI signs with the Agent Wallet, while x402/Gateway receipts may show the Gateway backing EOA that actually authorizes settlement.",
|
|
8
|
+
};
|
|
9
|
+
const NETWORKS = [ARC_TESTNET];
|
|
10
|
+
export function settlementNetworkInfo(network) {
|
|
11
|
+
if (!network) {
|
|
12
|
+
return {
|
|
13
|
+
network: "",
|
|
14
|
+
networkLabel: "Unknown",
|
|
15
|
+
environment: "unknown",
|
|
16
|
+
fundingMethod: "Funding method unknown. Inspect the article paymentTerms.network before funding.",
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const normalized = network.trim().toLowerCase();
|
|
20
|
+
const found = NETWORKS.find((candidate) => candidate.network.toLowerCase() === normalized ||
|
|
21
|
+
candidate.networkLabel.toLowerCase() === normalized ||
|
|
22
|
+
candidate.circleChain?.toLowerCase() === normalized ||
|
|
23
|
+
normalized === "arc-testnet");
|
|
24
|
+
if (found)
|
|
25
|
+
return found;
|
|
26
|
+
return {
|
|
27
|
+
network,
|
|
28
|
+
networkLabel: network,
|
|
29
|
+
environment: network.toLowerCase().includes("test") ? "testnet" : "unknown",
|
|
30
|
+
fundingMethod: "Funding method unknown. Confirm the mapped Circle chain before funding.",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=networks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networks.js","sourceRoot":"","sources":["../src/networks.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,GAA0B;IACzC,OAAO,EAAE,gBAAgB;IACzB,YAAY,EAAE,aAAa;IAC3B,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,SAAS;IACtB,aAAa,EACX,sIAAsI;IACxI,sBAAsB,EACpB,2IAA2I;CAC9I,CAAC;AAEF,MAAM,QAAQ,GAA4B,CAAC,WAAW,CAAC,CAAC;AAExD,MAAM,UAAU,qBAAqB,CAAC,OAA2B;IAC/D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,OAAO,EAAE,EAAE;YACX,YAAY,EAAE,SAAS;YACvB,WAAW,EAAE,SAAS;YACtB,aAAa,EAAE,kFAAkF;SAClG,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CACzB,CAAC,SAAS,EAAE,EAAE,CACZ,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,UAAU;QAC9C,SAAS,CAAC,YAAY,CAAC,WAAW,EAAE,KAAK,UAAU;QACnD,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,UAAU;QACnD,UAAU,KAAK,aAAa,CAC/B,CAAC;IACF,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IACxB,OAAO;QACL,OAAO;QACP,YAAY,EAAE,OAAO;QACrB,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC3E,aAAa,EAAE,yEAAyE;KACzF,CAAC;AACJ,CAAC"}
|
package/dist/pricing.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export type MeteringUnit = "word";
|
|
2
2
|
/**
|
|
3
3
|
* The atomic content unit in Rubicon is exactly one word. A quote describes the
|
|
4
|
-
* price the creator earns for a single word and the amount
|
|
5
|
-
* release one additional word.
|
|
4
|
+
* price the creator earns for a single word and the amount deducted from the
|
|
5
|
+
* buyer's session or chunk authorization to release one additional word.
|
|
6
6
|
*
|
|
7
|
-
* Rubicon never
|
|
8
|
-
*
|
|
7
|
+
* Rubicon never changes the product unit to chunks. Circle / Arc authorization
|
|
8
|
+
* may cover a whole session or multiple words, but application-level accounting
|
|
9
|
+
* is always one delivered word = one paid unit.
|
|
9
10
|
*/
|
|
10
11
|
export interface WordPriceQuote {
|
|
11
12
|
currency: "USDC";
|
|
@@ -14,12 +15,12 @@ export interface WordPriceQuote {
|
|
|
14
15
|
pricePerWordAtomic: `${bigint}`;
|
|
15
16
|
/** Rubicon gateway fee in basis points. Defaults to 0. */
|
|
16
17
|
gatewayFeeBps: number;
|
|
17
|
-
/** Exact amount the buyer
|
|
18
|
+
/** Exact amount consumed from the buyer authorization for one word. */
|
|
18
19
|
wordPaymentAtomic: `${bigint}`;
|
|
19
20
|
}
|
|
20
21
|
export interface WordUsageReport {
|
|
21
22
|
unit: MeteringUnit;
|
|
22
|
-
/** Number of individually delivered, individually
|
|
23
|
+
/** Number of individually delivered, individually metered words. */
|
|
23
24
|
wordsDelivered: number;
|
|
24
25
|
/** Full word price accruing to the creator (no Rubicon fee deducted). */
|
|
25
26
|
creatorAmountAtomic: `${bigint}`;
|
package/dist/pricing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC
|
|
1
|
+
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,YAAY,CAAC;IAC3B,sDAAsD;IACtD,kBAAkB,EAAE,GAAG,MAAM,EAAE,CAAC;IAChC,0DAA0D;IAC1D,aAAa,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,iBAAiB,EAAE,GAAG,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,YAAY,CAAC;IACnB,oEAAoE;IACpE,cAAc,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,mBAAmB,EAAE,GAAG,MAAM,EAAE,CAAC;IACjC,wEAAwE;IACxE,gBAAgB,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9B,wDAAwD;IACxD,eAAe,EAAE,GAAG,MAAM,EAAE,CAAC;CAC9B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,cAAc,CAUjB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,eAAe,CAWlB"}
|
package/dist/pricing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAoC5C,MAAM,UAAU,YAAY,CAAC,KAG5B;IACC,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,IAAI,CAAC,CAAC;IAC/C,MAAM,WAAW,GAAG,cAAc,CAAC,KAAK,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;IAC5E,OAAO;QACL,QAAQ,EAAE,MAAM;QAChB,YAAY,EAAE,MAAM;QACpB,kBAAkB,EAAE,GAAG,KAAK,CAAC,kBAAkB,EAAE;QACjD,aAAa;QACb,iBAAiB,EAAE,GAAG,WAAW,EAAE;KACpC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAI7B;IACC,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,IAAI,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAG,KAAK,CAAC,kBAAkB,GAAG,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC9E,MAAM,KAAK,GAAG,cAAc,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IAC3D,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,mBAAmB,EAAE,GAAG,aAAa,EAAE;QACvC,gBAAgB,EAAE,GAAG,KAAK,GAAG,aAAa,EAAE;QAC5C,eAAe,EAAE,GAAG,KAAK,EAAE;KAC5B,CAAC;AACJ,CAAC"}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export interface Budget {
|
|
|
6
6
|
currency: "USDC";
|
|
7
7
|
maxAmountAtomic: AtomicAmount;
|
|
8
8
|
}
|
|
9
|
+
export type AuthorizationMode = "session" | "chunk" | "word";
|
|
10
|
+
export type StreamMode = "bundled" | "word";
|
|
9
11
|
/** Safe public article metadata. Never includes unpaid body text. */
|
|
10
12
|
export interface ArticleSummary {
|
|
11
13
|
articleId: string;
|
|
@@ -18,8 +20,21 @@ export interface ArticleSummary {
|
|
|
18
20
|
pricePerWordAtomic: AtomicAmount;
|
|
19
21
|
/** Maximum possible total price to read the whole article. */
|
|
20
22
|
maxArticlePriceAtomic: AtomicAmount;
|
|
23
|
+
/** Public seller settlement terms for paid reads. Present when a verified wallet exists. */
|
|
24
|
+
paymentTerms?: SellerPaymentTerms;
|
|
21
25
|
sections: ArticleSectionSummary[];
|
|
22
26
|
}
|
|
27
|
+
export interface SellerPaymentTerms {
|
|
28
|
+
asset: "USDC";
|
|
29
|
+
network: string;
|
|
30
|
+
networkLabel?: string;
|
|
31
|
+
circleChain?: string;
|
|
32
|
+
environment?: "testnet" | "mainnet" | "unknown";
|
|
33
|
+
fundingMethod?: string;
|
|
34
|
+
payTo: `0x${string}`;
|
|
35
|
+
pricePerWordAtomic: AtomicAmount;
|
|
36
|
+
meteringUnit: "word";
|
|
37
|
+
}
|
|
23
38
|
/** Safe per-section navigation metadata. Headings only, no body content. */
|
|
24
39
|
export interface ArticleSectionSummary {
|
|
25
40
|
sectionId: string;
|
|
@@ -80,8 +95,26 @@ export interface StartSessionRequest {
|
|
|
80
95
|
conversationId?: string;
|
|
81
96
|
sectionId?: string;
|
|
82
97
|
budget: Budget;
|
|
98
|
+
/** Optional buyer estimate used to size a session or chunk authorization. */
|
|
99
|
+
predictedWords?: number;
|
|
83
100
|
metadata?: Record<string, unknown>;
|
|
84
101
|
}
|
|
102
|
+
export interface SessionAuthorizationRequired {
|
|
103
|
+
sessionId: string;
|
|
104
|
+
authorizationMode: AuthorizationMode;
|
|
105
|
+
meteringUnit: "word";
|
|
106
|
+
asset: "USDC";
|
|
107
|
+
network?: string;
|
|
108
|
+
payTo?: `0x${string}`;
|
|
109
|
+
pricePerWordAtomic: AtomicAmount;
|
|
110
|
+
/** Maximum USDC the buyer is willing to authorize for this session/chunk. */
|
|
111
|
+
maxAuthorizedAtomic: AtomicAmount;
|
|
112
|
+
/** Number of words covered by the current authorization cap. */
|
|
113
|
+
maxAuthorizedWords: number;
|
|
114
|
+
settlement: "actual_usage_on_close" | "actual_usage_per_chunk" | "per_word_compatibility";
|
|
115
|
+
resource: string;
|
|
116
|
+
expiresAt: string;
|
|
117
|
+
}
|
|
85
118
|
export interface StartSessionResponse {
|
|
86
119
|
sessionId: string;
|
|
87
120
|
state: SessionState;
|
|
@@ -95,20 +128,35 @@ export interface StartSessionResponse {
|
|
|
95
128
|
/** Exact amount the buyer pays to release one additional word. */
|
|
96
129
|
wordPaymentAtomic: AtomicAmount;
|
|
97
130
|
gatewayFeeBps: number;
|
|
98
|
-
/**
|
|
131
|
+
/** Circle / Arc payment requirement for a session or chunk authorization. */
|
|
132
|
+
authorizationRequired?: SessionAuthorizationRequired;
|
|
133
|
+
/** @deprecated Compatibility challenge for legacy one-word x402 clients. */
|
|
99
134
|
paymentRequired?: unknown;
|
|
100
135
|
expiresAt: string;
|
|
136
|
+
authorizationMode?: AuthorizationMode;
|
|
137
|
+
wordsAuthorized?: number;
|
|
101
138
|
wordsPaid: number;
|
|
102
139
|
wordsDelivered: number;
|
|
103
140
|
paidAtomic: AtomicAmount;
|
|
104
141
|
}
|
|
105
142
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
143
|
+
* Authorization for a session stream. The gateway meters delivered words against
|
|
144
|
+
* the authorized cap and settles actual usage when the session closes.
|
|
145
|
+
*/
|
|
146
|
+
export interface StreamAuthorizationRequest {
|
|
147
|
+
authorizationPayload: unknown;
|
|
148
|
+
idempotencyKey?: string;
|
|
149
|
+
maxWords?: number;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Chunk or legacy word-level payment. `idempotencyKey` ties the authorization to
|
|
153
|
+
* a specific stream position so retries never release or charge words twice.
|
|
108
154
|
*/
|
|
109
155
|
export interface StreamPaymentRequest {
|
|
110
156
|
paymentPayload: unknown;
|
|
111
157
|
idempotencyKey?: string;
|
|
158
|
+
/** Multi-word fallback cap. Omitted or 1 preserves legacy one-word behavior. */
|
|
159
|
+
maxWords?: number;
|
|
112
160
|
}
|
|
113
161
|
export interface StreamPaymentResponse {
|
|
114
162
|
accepted: boolean;
|
|
@@ -121,11 +169,41 @@ export interface StreamPaymentResponse {
|
|
|
121
169
|
completed: boolean;
|
|
122
170
|
/** Canonical, per-word settlement receipt. Present whenever a word is released. */
|
|
123
171
|
payment?: WordPaymentReceipt;
|
|
124
|
-
|
|
172
|
+
authorizationMode?: AuthorizationMode;
|
|
173
|
+
remainingAuthorizedAtomic?: AtomicAmount;
|
|
174
|
+
/** On-chain settlement transaction hash, when the payment facilitator returns one. */
|
|
125
175
|
transactionHash?: string;
|
|
126
176
|
/** All on-chain settlement transaction hashes for this payment, when available. */
|
|
127
177
|
transactionHashes?: string[];
|
|
128
|
-
/**
|
|
178
|
+
/** Gateway/facilitator settlement identifier, such as a Circle x402 transfer UUID. */
|
|
179
|
+
settlementId?: string;
|
|
180
|
+
settlementIds?: string[];
|
|
181
|
+
buyerWalletAddress?: `0x${string}`;
|
|
182
|
+
/** Gateway/facilitator transfer identifier, when distinct from an on-chain hash. */
|
|
183
|
+
transferId?: string;
|
|
184
|
+
}
|
|
185
|
+
export interface StreamChunkResponse {
|
|
186
|
+
accepted: boolean;
|
|
187
|
+
words: Array<{
|
|
188
|
+
sequence: number;
|
|
189
|
+
word: string;
|
|
190
|
+
priceAtomic: AtomicAmount;
|
|
191
|
+
/** @deprecated Bundled reads now report one payment on the chunk response. */
|
|
192
|
+
payment?: WordPaymentReceipt;
|
|
193
|
+
}>;
|
|
194
|
+
text: string;
|
|
195
|
+
wordsPaid: number;
|
|
196
|
+
wordsDelivered: number;
|
|
197
|
+
paidAtomic: AtomicAmount;
|
|
198
|
+
completed: boolean;
|
|
199
|
+
authorizationMode?: AuthorizationMode;
|
|
200
|
+
/** Canonical receipt for the bundled authorization that released these words. */
|
|
201
|
+
payment?: WordPaymentReceipt;
|
|
202
|
+
transactionHash?: string;
|
|
203
|
+
transactionHashes?: string[];
|
|
204
|
+
settlementId?: string;
|
|
205
|
+
settlementIds?: string[];
|
|
206
|
+
buyerWalletAddress?: `0x${string}`;
|
|
129
207
|
transferId?: string;
|
|
130
208
|
}
|
|
131
209
|
export interface WordPaymentReceipt {
|
|
@@ -135,12 +213,28 @@ export interface WordPaymentReceipt {
|
|
|
135
213
|
sequence: number;
|
|
136
214
|
meteringUnit: "word";
|
|
137
215
|
amountAtomic: AtomicAmount;
|
|
216
|
+
/** Present when one payment authorized more than one delivered word. */
|
|
217
|
+
bundleSequence?: number;
|
|
218
|
+
/** Present for bundle receipts; first delivered word sequence in the bundle. */
|
|
219
|
+
startSequence?: number;
|
|
220
|
+
/** Present for bundle receipts; last delivered word sequence in the bundle. */
|
|
221
|
+
endSequence?: number;
|
|
222
|
+
/** Number of words released by this payment. Defaults to 1 for legacy receipts. */
|
|
223
|
+
wordsDelivered?: number;
|
|
224
|
+
/** Creator price for each delivered word before bundle multiplication. */
|
|
225
|
+
pricePerWordAtomic?: AtomicAmount;
|
|
226
|
+
/** Text released by this payment. */
|
|
227
|
+
text?: string;
|
|
138
228
|
currency: "USDC";
|
|
139
229
|
network?: string;
|
|
140
230
|
payTo?: `0x${string}`;
|
|
141
231
|
transactionHash?: string;
|
|
142
232
|
transactionHashes?: string[];
|
|
143
|
-
/**
|
|
233
|
+
/** Gateway/facilitator settlement identifier, such as a Circle x402 transfer UUID. */
|
|
234
|
+
settlementId?: string;
|
|
235
|
+
settlementIds?: string[];
|
|
236
|
+
buyerWalletAddress?: `0x${string}`;
|
|
237
|
+
/** Gateway/facilitator transfer identifier, when distinct from an on-chain hash. */
|
|
144
238
|
transferId?: string;
|
|
145
239
|
settledAt: string;
|
|
146
240
|
}
|
|
@@ -148,9 +242,15 @@ export interface PaymentVerification {
|
|
|
148
242
|
accepted: boolean;
|
|
149
243
|
transactionHash?: string;
|
|
150
244
|
transactionHashes?: string[];
|
|
245
|
+
settlementId?: string;
|
|
246
|
+
settlementIds?: string[];
|
|
247
|
+
buyerWalletAddress?: `0x${string}`;
|
|
151
248
|
transferId?: string;
|
|
152
249
|
network?: string;
|
|
153
250
|
payTo?: `0x${string}`;
|
|
251
|
+
authorizationMode?: AuthorizationMode;
|
|
252
|
+
maxAuthorizedAtomic?: AtomicAmount;
|
|
253
|
+
maxAuthorizedWords?: number;
|
|
154
254
|
amountAtomic?: AtomicAmount;
|
|
155
255
|
reason?: string;
|
|
156
256
|
}
|
|
@@ -169,6 +269,14 @@ export type GatewayEvent = {
|
|
|
169
269
|
role: "seller";
|
|
170
270
|
message: string;
|
|
171
271
|
recommendedSectionId?: string;
|
|
272
|
+
} | {
|
|
273
|
+
type: "authorization.accepted";
|
|
274
|
+
sessionId: string;
|
|
275
|
+
authorizationMode: AuthorizationMode;
|
|
276
|
+
maxAuthorizedAtomic: AtomicAmount;
|
|
277
|
+
maxAuthorizedWords: number;
|
|
278
|
+
network?: string;
|
|
279
|
+
payTo?: `0x${string}`;
|
|
172
280
|
} | {
|
|
173
281
|
type: "word.payment_accepted";
|
|
174
282
|
sessionId: string;
|
|
@@ -189,6 +297,25 @@ export type GatewayEvent = {
|
|
|
189
297
|
priceAtomic: AtomicAmount;
|
|
190
298
|
totalWordsStreamed: number;
|
|
191
299
|
totalPaidAtomic: AtomicAmount;
|
|
300
|
+
} | {
|
|
301
|
+
type: "article.bundle";
|
|
302
|
+
sessionId: string;
|
|
303
|
+
articleId: string;
|
|
304
|
+
bundleSequence: number;
|
|
305
|
+
startSequence: number;
|
|
306
|
+
endSequence: number;
|
|
307
|
+
words: Array<{
|
|
308
|
+
sequence: number;
|
|
309
|
+
word: string;
|
|
310
|
+
priceAtomic: AtomicAmount;
|
|
311
|
+
}>;
|
|
312
|
+
text: string;
|
|
313
|
+
wordCount: number;
|
|
314
|
+
pricePerWordAtomic: AtomicAmount;
|
|
315
|
+
amountAtomic: AtomicAmount;
|
|
316
|
+
paymentId?: string;
|
|
317
|
+
totalWordsStreamed: number;
|
|
318
|
+
totalPaidAtomic: AtomicAmount;
|
|
192
319
|
} | {
|
|
193
320
|
type: "article.usage";
|
|
194
321
|
sessionId: string;
|
package/dist/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,YAAY,CAAC;CAC/B;AAED,qEAAqE;A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,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,YAAY,CAAC;CAC/B,GACD;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/session.d.ts
CHANGED
|
@@ -21,12 +21,14 @@ export interface SessionRecord {
|
|
|
21
21
|
sellerWallet: `0x${string}`;
|
|
22
22
|
metadata: Record<string, unknown>;
|
|
23
23
|
state: SessionState;
|
|
24
|
-
/** Words
|
|
24
|
+
/** Words covered by accepted metering/settlement, regardless of authorization scope. */
|
|
25
25
|
wordsPaid: number;
|
|
26
26
|
/** Words actually delivered to the buyer. */
|
|
27
27
|
wordsDelivered: number;
|
|
28
28
|
/** Total atomic USDC the buyer has paid in this session. */
|
|
29
29
|
paidAtomic: bigint;
|
|
30
|
+
/** Exact provider payment requirement issued when the session was opened. */
|
|
31
|
+
paymentRequired?: unknown;
|
|
30
32
|
createdAt: Date;
|
|
31
33
|
updatedAt: Date;
|
|
32
34
|
expiresAt: Date;
|
|
@@ -45,11 +47,11 @@ export declare function createSession(input: {
|
|
|
45
47
|
metadata?: Record<string, unknown>;
|
|
46
48
|
ttlMs: number;
|
|
47
49
|
}): SessionRecord;
|
|
48
|
-
/** Whether one more word
|
|
50
|
+
/** Whether one more delivered word fits inside the session budget. */
|
|
49
51
|
export declare function canAffordNextWord(session: SessionRecord, wordPaymentAtomic: bigint): boolean;
|
|
50
|
-
/** Record that one word
|
|
52
|
+
/** Record that one delivered word has been metered for payment. */
|
|
51
53
|
export declare function recordWordPayment(session: SessionRecord, amountAtomic: AtomicAmount): SessionRecord;
|
|
52
|
-
/** Record that one
|
|
54
|
+
/** Record that one authorized word has been delivered. */
|
|
53
55
|
export declare function recordWordDelivery(session: SessionRecord): SessionRecord;
|
|
54
56
|
export declare function isSessionExpired(session: SessionRecord, now?: Date): boolean;
|
|
55
57
|
//# sourceMappingURL=session.d.ts.map
|
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnF;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,YAAY,EAAE,KAAK,MAAM,EAAE,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,KAAK,EAAE,YAAY,CAAC;IACpB
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,YAA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,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,aAAa,CAsBhB;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAE5F;AAED,mEAAmE;AACnE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,GAAG,aAAa,CAQnG;AAED,0DAA0D;AAC1D,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAIxE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,OAAa,GAAG,OAAO,CAElF"}
|
package/dist/session.js
CHANGED
|
@@ -22,11 +22,11 @@ export function createSession(input) {
|
|
|
22
22
|
expiresAt: new Date(now.getTime() + input.ttlMs),
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
/** Whether one more word
|
|
25
|
+
/** Whether one more delivered word fits inside the session budget. */
|
|
26
26
|
export function canAffordNextWord(session, wordPaymentAtomic) {
|
|
27
27
|
return session.paidAtomic + wordPaymentAtomic <= BigInt(session.budget.maxAmountAtomic);
|
|
28
28
|
}
|
|
29
|
-
/** Record that one word
|
|
29
|
+
/** Record that one delivered word has been metered for payment. */
|
|
30
30
|
export function recordWordPayment(session, amountAtomic) {
|
|
31
31
|
session.paidAtomic += BigInt(amountAtomic);
|
|
32
32
|
session.wordsPaid += 1;
|
|
@@ -36,7 +36,7 @@ export function recordWordPayment(session, amountAtomic) {
|
|
|
36
36
|
}
|
|
37
37
|
return session;
|
|
38
38
|
}
|
|
39
|
-
/** Record that one
|
|
39
|
+
/** Record that one authorized word has been delivered. */
|
|
40
40
|
export function recordWordDelivery(session) {
|
|
41
41
|
session.wordsDelivered += 1;
|
|
42
42
|
session.updatedAt = new Date();
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAwCzC,MAAM,UAAU,aAAa,CAAC,KAa7B;IACC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IACvB,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,EAAE,IAAI,UAAU,EAAE;QAC5B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;QAC5C,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,EAAE;QAC9B,KAAK,EAAE,MAAM;QACb,SAAS,EAAE,CAAC;QACZ,cAAc,EAAE,CAAC;QACjB,UAAU,EAAE,EAAE;QACd,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,GAAG;QACd,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC;KACjD,CAAC;AACJ,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,iBAAiB,CAAC,OAAsB,EAAE,iBAAyB;IACjF,OAAO,OAAO,CAAC,UAAU,GAAG,iBAAiB,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AAC1F,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,iBAAiB,CAAC,OAAsB,EAAE,YAA0B;IAClF,OAAO,CAAC,UAAU,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;IAC3C,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC/B,IAAI,OAAO,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;QAC7B,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC;IAC3B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,kBAAkB,CAAC,OAAsB;IACvD,OAAO,CAAC,cAAc,IAAI,CAAC,CAAC;IAC5B,OAAO,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC/B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAsB,EAAE,GAAG,GAAG,IAAI,IAAI,EAAE;IACvE,OAAO,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;AACtD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rubicon-caliga/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Shared protocol types, pricing math, and session primitives for the Rubicon x402 streaming gateway.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"dev": "tsx src/index.ts",
|
|
30
30
|
"lint": "tsc -p tsconfig.json --noEmit",
|
|
31
31
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
32
|
-
"test": "node --test dist/**/*.test.js"
|
|
33
|
-
"prepublishOnly": "pnpm run build"
|
|
32
|
+
"test": "node --test dist/**/*.test.js"
|
|
34
33
|
}
|
|
35
|
-
}
|
|
34
|
+
}
|
package/src/contract.ts
CHANGED
|
@@ -103,6 +103,9 @@ export interface PaymentActivity {
|
|
|
103
103
|
payTo?: `0x${string}`;
|
|
104
104
|
transactionHash?: string;
|
|
105
105
|
transactionHashes?: string[];
|
|
106
|
+
settlementId?: string;
|
|
107
|
+
settlementIds?: string[];
|
|
108
|
+
buyerWalletAddress?: `0x${string}`;
|
|
106
109
|
transferId?: string;
|
|
107
110
|
createdAt: string;
|
|
108
111
|
}
|
package/src/index.ts
CHANGED
package/src/networks.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface SettlementNetworkInfo {
|
|
2
|
+
network: string;
|
|
3
|
+
networkLabel: string;
|
|
4
|
+
circleChain?: string;
|
|
5
|
+
environment: "testnet" | "mainnet" | "unknown";
|
|
6
|
+
fundingMethod: string;
|
|
7
|
+
buyerWalletExplanation?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const ARC_TESTNET: SettlementNetworkInfo = {
|
|
11
|
+
network: "eip155:5042002",
|
|
12
|
+
networkLabel: "Arc Testnet",
|
|
13
|
+
circleChain: "ARC-TESTNET",
|
|
14
|
+
environment: "testnet",
|
|
15
|
+
fundingMethod:
|
|
16
|
+
"Circle testnet funds on ARC-TESTNET. Use Circle's testnet faucet / Gateway testnet funding flow; do not send mainnet fiat or crypto.",
|
|
17
|
+
buyerWalletExplanation:
|
|
18
|
+
"Circle CLI signs with the Agent Wallet, while x402/Gateway receipts may show the Gateway backing EOA that actually authorizes settlement.",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const NETWORKS: SettlementNetworkInfo[] = [ARC_TESTNET];
|
|
22
|
+
|
|
23
|
+
export function settlementNetworkInfo(network: string | undefined): SettlementNetworkInfo {
|
|
24
|
+
if (!network) {
|
|
25
|
+
return {
|
|
26
|
+
network: "",
|
|
27
|
+
networkLabel: "Unknown",
|
|
28
|
+
environment: "unknown",
|
|
29
|
+
fundingMethod: "Funding method unknown. Inspect the article paymentTerms.network before funding.",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const normalized = network.trim().toLowerCase();
|
|
33
|
+
const found = NETWORKS.find(
|
|
34
|
+
(candidate) =>
|
|
35
|
+
candidate.network.toLowerCase() === normalized ||
|
|
36
|
+
candidate.networkLabel.toLowerCase() === normalized ||
|
|
37
|
+
candidate.circleChain?.toLowerCase() === normalized ||
|
|
38
|
+
normalized === "arc-testnet",
|
|
39
|
+
);
|
|
40
|
+
if (found) return found;
|
|
41
|
+
return {
|
|
42
|
+
network,
|
|
43
|
+
networkLabel: network,
|
|
44
|
+
environment: network.toLowerCase().includes("test") ? "testnet" : "unknown",
|
|
45
|
+
fundingMethod: "Funding method unknown. Confirm the mapped Circle chain before funding.",
|
|
46
|
+
};
|
|
47
|
+
}
|
package/src/pricing.ts
CHANGED
|
@@ -4,11 +4,12 @@ export type MeteringUnit = "word";
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The atomic content unit in Rubicon is exactly one word. A quote describes the
|
|
7
|
-
* price the creator earns for a single word and the amount
|
|
8
|
-
* release one additional word.
|
|
7
|
+
* price the creator earns for a single word and the amount deducted from the
|
|
8
|
+
* buyer's session or chunk authorization to release one additional word.
|
|
9
9
|
*
|
|
10
|
-
* Rubicon never
|
|
11
|
-
*
|
|
10
|
+
* Rubicon never changes the product unit to chunks. Circle / Arc authorization
|
|
11
|
+
* may cover a whole session or multiple words, but application-level accounting
|
|
12
|
+
* is always one delivered word = one paid unit.
|
|
12
13
|
*/
|
|
13
14
|
export interface WordPriceQuote {
|
|
14
15
|
currency: "USDC";
|
|
@@ -17,13 +18,13 @@ export interface WordPriceQuote {
|
|
|
17
18
|
pricePerWordAtomic: `${bigint}`;
|
|
18
19
|
/** Rubicon gateway fee in basis points. Defaults to 0. */
|
|
19
20
|
gatewayFeeBps: number;
|
|
20
|
-
/** Exact amount the buyer
|
|
21
|
+
/** Exact amount consumed from the buyer authorization for one word. */
|
|
21
22
|
wordPaymentAtomic: `${bigint}`;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export interface WordUsageReport {
|
|
25
26
|
unit: MeteringUnit;
|
|
26
|
-
/** Number of individually delivered, individually
|
|
27
|
+
/** Number of individually delivered, individually metered words. */
|
|
27
28
|
wordsDelivered: number;
|
|
28
29
|
/** Full word price accruing to the creator (no Rubicon fee deducted). */
|
|
29
30
|
creatorAmountAtomic: `${bigint}`;
|
package/src/protocol.ts
CHANGED
|
@@ -8,6 +8,9 @@ export interface Budget {
|
|
|
8
8
|
maxAmountAtomic: AtomicAmount;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export type AuthorizationMode = "session" | "chunk" | "word";
|
|
12
|
+
export type StreamMode = "bundled" | "word";
|
|
13
|
+
|
|
11
14
|
/** Safe public article metadata. Never includes unpaid body text. */
|
|
12
15
|
export interface ArticleSummary {
|
|
13
16
|
articleId: string;
|
|
@@ -20,9 +23,23 @@ export interface ArticleSummary {
|
|
|
20
23
|
pricePerWordAtomic: AtomicAmount;
|
|
21
24
|
/** Maximum possible total price to read the whole article. */
|
|
22
25
|
maxArticlePriceAtomic: AtomicAmount;
|
|
26
|
+
/** Public seller settlement terms for paid reads. Present when a verified wallet exists. */
|
|
27
|
+
paymentTerms?: SellerPaymentTerms;
|
|
23
28
|
sections: ArticleSectionSummary[];
|
|
24
29
|
}
|
|
25
30
|
|
|
31
|
+
export interface SellerPaymentTerms {
|
|
32
|
+
asset: "USDC";
|
|
33
|
+
network: string;
|
|
34
|
+
networkLabel?: string;
|
|
35
|
+
circleChain?: string;
|
|
36
|
+
environment?: "testnet" | "mainnet" | "unknown";
|
|
37
|
+
fundingMethod?: string;
|
|
38
|
+
payTo: `0x${string}`;
|
|
39
|
+
pricePerWordAtomic: AtomicAmount;
|
|
40
|
+
meteringUnit: "word";
|
|
41
|
+
}
|
|
42
|
+
|
|
26
43
|
/** Safe per-section navigation metadata. Headings only, no body content. */
|
|
27
44
|
export interface ArticleSectionSummary {
|
|
28
45
|
sectionId: string;
|
|
@@ -106,9 +123,28 @@ export interface StartSessionRequest {
|
|
|
106
123
|
conversationId?: string;
|
|
107
124
|
sectionId?: string;
|
|
108
125
|
budget: Budget;
|
|
126
|
+
/** Optional buyer estimate used to size a session or chunk authorization. */
|
|
127
|
+
predictedWords?: number;
|
|
109
128
|
metadata?: Record<string, unknown>;
|
|
110
129
|
}
|
|
111
130
|
|
|
131
|
+
export interface SessionAuthorizationRequired {
|
|
132
|
+
sessionId: string;
|
|
133
|
+
authorizationMode: AuthorizationMode;
|
|
134
|
+
meteringUnit: "word";
|
|
135
|
+
asset: "USDC";
|
|
136
|
+
network?: string;
|
|
137
|
+
payTo?: `0x${string}`;
|
|
138
|
+
pricePerWordAtomic: AtomicAmount;
|
|
139
|
+
/** Maximum USDC the buyer is willing to authorize for this session/chunk. */
|
|
140
|
+
maxAuthorizedAtomic: AtomicAmount;
|
|
141
|
+
/** Number of words covered by the current authorization cap. */
|
|
142
|
+
maxAuthorizedWords: number;
|
|
143
|
+
settlement: "actual_usage_on_close" | "actual_usage_per_chunk" | "per_word_compatibility";
|
|
144
|
+
resource: string;
|
|
145
|
+
expiresAt: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
112
148
|
export interface StartSessionResponse {
|
|
113
149
|
sessionId: string;
|
|
114
150
|
state: SessionState;
|
|
@@ -122,21 +158,37 @@ export interface StartSessionResponse {
|
|
|
122
158
|
/** Exact amount the buyer pays to release one additional word. */
|
|
123
159
|
wordPaymentAtomic: AtomicAmount;
|
|
124
160
|
gatewayFeeBps: number;
|
|
125
|
-
/**
|
|
161
|
+
/** Circle / Arc payment requirement for a session or chunk authorization. */
|
|
162
|
+
authorizationRequired?: SessionAuthorizationRequired;
|
|
163
|
+
/** @deprecated Compatibility challenge for legacy one-word x402 clients. */
|
|
126
164
|
paymentRequired?: unknown;
|
|
127
165
|
expiresAt: string;
|
|
166
|
+
authorizationMode?: AuthorizationMode;
|
|
167
|
+
wordsAuthorized?: number;
|
|
128
168
|
wordsPaid: number;
|
|
129
169
|
wordsDelivered: number;
|
|
130
170
|
paidAtomic: AtomicAmount;
|
|
131
171
|
}
|
|
132
172
|
|
|
133
173
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
174
|
+
* Authorization for a session stream. The gateway meters delivered words against
|
|
175
|
+
* the authorized cap and settles actual usage when the session closes.
|
|
176
|
+
*/
|
|
177
|
+
export interface StreamAuthorizationRequest {
|
|
178
|
+
authorizationPayload: unknown;
|
|
179
|
+
idempotencyKey?: string;
|
|
180
|
+
maxWords?: number;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Chunk or legacy word-level payment. `idempotencyKey` ties the authorization to
|
|
185
|
+
* a specific stream position so retries never release or charge words twice.
|
|
136
186
|
*/
|
|
137
187
|
export interface StreamPaymentRequest {
|
|
138
188
|
paymentPayload: unknown;
|
|
139
189
|
idempotencyKey?: string;
|
|
190
|
+
/** Multi-word fallback cap. Omitted or 1 preserves legacy one-word behavior. */
|
|
191
|
+
maxWords?: number;
|
|
140
192
|
}
|
|
141
193
|
|
|
142
194
|
export interface StreamPaymentResponse {
|
|
@@ -150,11 +202,42 @@ export interface StreamPaymentResponse {
|
|
|
150
202
|
completed: boolean;
|
|
151
203
|
/** Canonical, per-word settlement receipt. Present whenever a word is released. */
|
|
152
204
|
payment?: WordPaymentReceipt;
|
|
153
|
-
|
|
205
|
+
authorizationMode?: AuthorizationMode;
|
|
206
|
+
remainingAuthorizedAtomic?: AtomicAmount;
|
|
207
|
+
/** On-chain settlement transaction hash, when the payment facilitator returns one. */
|
|
154
208
|
transactionHash?: string;
|
|
155
209
|
/** All on-chain settlement transaction hashes for this payment, when available. */
|
|
156
210
|
transactionHashes?: string[];
|
|
157
|
-
/**
|
|
211
|
+
/** Gateway/facilitator settlement identifier, such as a Circle x402 transfer UUID. */
|
|
212
|
+
settlementId?: string;
|
|
213
|
+
settlementIds?: string[];
|
|
214
|
+
buyerWalletAddress?: `0x${string}`;
|
|
215
|
+
/** Gateway/facilitator transfer identifier, when distinct from an on-chain hash. */
|
|
216
|
+
transferId?: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface StreamChunkResponse {
|
|
220
|
+
accepted: boolean;
|
|
221
|
+
words: Array<{
|
|
222
|
+
sequence: number;
|
|
223
|
+
word: string;
|
|
224
|
+
priceAtomic: AtomicAmount;
|
|
225
|
+
/** @deprecated Bundled reads now report one payment on the chunk response. */
|
|
226
|
+
payment?: WordPaymentReceipt;
|
|
227
|
+
}>;
|
|
228
|
+
text: string;
|
|
229
|
+
wordsPaid: number;
|
|
230
|
+
wordsDelivered: number;
|
|
231
|
+
paidAtomic: AtomicAmount;
|
|
232
|
+
completed: boolean;
|
|
233
|
+
authorizationMode?: AuthorizationMode;
|
|
234
|
+
/** Canonical receipt for the bundled authorization that released these words. */
|
|
235
|
+
payment?: WordPaymentReceipt;
|
|
236
|
+
transactionHash?: string;
|
|
237
|
+
transactionHashes?: string[];
|
|
238
|
+
settlementId?: string;
|
|
239
|
+
settlementIds?: string[];
|
|
240
|
+
buyerWalletAddress?: `0x${string}`;
|
|
158
241
|
transferId?: string;
|
|
159
242
|
}
|
|
160
243
|
|
|
@@ -165,12 +248,28 @@ export interface WordPaymentReceipt {
|
|
|
165
248
|
sequence: number;
|
|
166
249
|
meteringUnit: "word";
|
|
167
250
|
amountAtomic: AtomicAmount;
|
|
251
|
+
/** Present when one payment authorized more than one delivered word. */
|
|
252
|
+
bundleSequence?: number;
|
|
253
|
+
/** Present for bundle receipts; first delivered word sequence in the bundle. */
|
|
254
|
+
startSequence?: number;
|
|
255
|
+
/** Present for bundle receipts; last delivered word sequence in the bundle. */
|
|
256
|
+
endSequence?: number;
|
|
257
|
+
/** Number of words released by this payment. Defaults to 1 for legacy receipts. */
|
|
258
|
+
wordsDelivered?: number;
|
|
259
|
+
/** Creator price for each delivered word before bundle multiplication. */
|
|
260
|
+
pricePerWordAtomic?: AtomicAmount;
|
|
261
|
+
/** Text released by this payment. */
|
|
262
|
+
text?: string;
|
|
168
263
|
currency: "USDC";
|
|
169
264
|
network?: string;
|
|
170
265
|
payTo?: `0x${string}`;
|
|
171
266
|
transactionHash?: string;
|
|
172
267
|
transactionHashes?: string[];
|
|
173
|
-
/**
|
|
268
|
+
/** Gateway/facilitator settlement identifier, such as a Circle x402 transfer UUID. */
|
|
269
|
+
settlementId?: string;
|
|
270
|
+
settlementIds?: string[];
|
|
271
|
+
buyerWalletAddress?: `0x${string}`;
|
|
272
|
+
/** Gateway/facilitator transfer identifier, when distinct from an on-chain hash. */
|
|
174
273
|
transferId?: string;
|
|
175
274
|
settledAt: string;
|
|
176
275
|
}
|
|
@@ -179,9 +278,15 @@ export interface PaymentVerification {
|
|
|
179
278
|
accepted: boolean;
|
|
180
279
|
transactionHash?: string;
|
|
181
280
|
transactionHashes?: string[];
|
|
281
|
+
settlementId?: string;
|
|
282
|
+
settlementIds?: string[];
|
|
283
|
+
buyerWalletAddress?: `0x${string}`;
|
|
182
284
|
transferId?: string;
|
|
183
285
|
network?: string;
|
|
184
286
|
payTo?: `0x${string}`;
|
|
287
|
+
authorizationMode?: AuthorizationMode;
|
|
288
|
+
maxAuthorizedAtomic?: AtomicAmount;
|
|
289
|
+
maxAuthorizedWords?: number;
|
|
185
290
|
amountAtomic?: AtomicAmount;
|
|
186
291
|
reason?: string;
|
|
187
292
|
}
|
|
@@ -208,6 +313,15 @@ export type GatewayEvent =
|
|
|
208
313
|
message: string;
|
|
209
314
|
recommendedSectionId?: string;
|
|
210
315
|
}
|
|
316
|
+
| {
|
|
317
|
+
type: "authorization.accepted";
|
|
318
|
+
sessionId: string;
|
|
319
|
+
authorizationMode: AuthorizationMode;
|
|
320
|
+
maxAuthorizedAtomic: AtomicAmount;
|
|
321
|
+
maxAuthorizedWords: number;
|
|
322
|
+
network?: string;
|
|
323
|
+
payTo?: `0x${string}`;
|
|
324
|
+
}
|
|
211
325
|
| {
|
|
212
326
|
type: "word.payment_accepted";
|
|
213
327
|
sessionId: string;
|
|
@@ -230,6 +344,22 @@ export type GatewayEvent =
|
|
|
230
344
|
totalWordsStreamed: number;
|
|
231
345
|
totalPaidAtomic: AtomicAmount;
|
|
232
346
|
}
|
|
347
|
+
| {
|
|
348
|
+
type: "article.bundle";
|
|
349
|
+
sessionId: string;
|
|
350
|
+
articleId: string;
|
|
351
|
+
bundleSequence: number;
|
|
352
|
+
startSequence: number;
|
|
353
|
+
endSequence: number;
|
|
354
|
+
words: Array<{ sequence: number; word: string; priceAtomic: AtomicAmount }>;
|
|
355
|
+
text: string;
|
|
356
|
+
wordCount: number;
|
|
357
|
+
pricePerWordAtomic: AtomicAmount;
|
|
358
|
+
amountAtomic: AtomicAmount;
|
|
359
|
+
paymentId?: string;
|
|
360
|
+
totalWordsStreamed: number;
|
|
361
|
+
totalPaidAtomic: AtomicAmount;
|
|
362
|
+
}
|
|
233
363
|
| {
|
|
234
364
|
type: "article.usage";
|
|
235
365
|
sessionId: string;
|
package/src/session.ts
CHANGED
|
@@ -25,12 +25,14 @@ export interface SessionRecord {
|
|
|
25
25
|
sellerWallet: `0x${string}`;
|
|
26
26
|
metadata: Record<string, unknown>;
|
|
27
27
|
state: SessionState;
|
|
28
|
-
/** Words
|
|
28
|
+
/** Words covered by accepted metering/settlement, regardless of authorization scope. */
|
|
29
29
|
wordsPaid: number;
|
|
30
30
|
/** Words actually delivered to the buyer. */
|
|
31
31
|
wordsDelivered: number;
|
|
32
32
|
/** Total atomic USDC the buyer has paid in this session. */
|
|
33
33
|
paidAtomic: bigint;
|
|
34
|
+
/** Exact provider payment requirement issued when the session was opened. */
|
|
35
|
+
paymentRequired?: unknown;
|
|
34
36
|
createdAt: Date;
|
|
35
37
|
updatedAt: Date;
|
|
36
38
|
expiresAt: Date;
|
|
@@ -73,12 +75,12 @@ export function createSession(input: {
|
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
/** Whether one more word
|
|
78
|
+
/** Whether one more delivered word fits inside the session budget. */
|
|
77
79
|
export function canAffordNextWord(session: SessionRecord, wordPaymentAtomic: bigint): boolean {
|
|
78
80
|
return session.paidAtomic + wordPaymentAtomic <= BigInt(session.budget.maxAmountAtomic);
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
/** Record that one word
|
|
83
|
+
/** Record that one delivered word has been metered for payment. */
|
|
82
84
|
export function recordWordPayment(session: SessionRecord, amountAtomic: AtomicAmount): SessionRecord {
|
|
83
85
|
session.paidAtomic += BigInt(amountAtomic);
|
|
84
86
|
session.wordsPaid += 1;
|
|
@@ -89,7 +91,7 @@ export function recordWordPayment(session: SessionRecord, amountAtomic: AtomicAm
|
|
|
89
91
|
return session;
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
/** Record that one
|
|
94
|
+
/** Record that one authorized word has been delivered. */
|
|
93
95
|
export function recordWordDelivery(session: SessionRecord): SessionRecord {
|
|
94
96
|
session.wordsDelivered += 1;
|
|
95
97
|
session.updatedAt = new Date();
|