@vallum/receipts 0.0.0-prerelease
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 +8 -0
- package/dist/ap2Receipt.d.ts +43 -0
- package/dist/ap2Receipt.js +75 -0
- package/dist/index.d.ts +368 -0
- package/dist/index.js +612 -0
- package/dist/x402Receipt.d.ts +31 -0
- package/dist/x402Receipt.js +48 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# @vallum/receipts
|
|
2
|
+
|
|
3
|
+
Receipt and contract workflow state machines for Vallum.
|
|
4
|
+
|
|
5
|
+
This package models local receipt state transitions for sponsored agent actions,
|
|
6
|
+
including escrow, pay-per-call, data-license, and service-bounty workflows. It
|
|
7
|
+
does not settle payments, make policy decisions, custody funds, verify
|
|
8
|
+
providers, or submit transactions.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { LinkedReceiptState } from "./index.js";
|
|
2
|
+
export type AP2ReceiptStatus = "Success" | "Error";
|
|
3
|
+
export interface AP2CheckoutReceipt {
|
|
4
|
+
readonly status: AP2ReceiptStatus;
|
|
5
|
+
readonly iss: string;
|
|
6
|
+
readonly iat: number;
|
|
7
|
+
readonly reference: string;
|
|
8
|
+
readonly error?: string;
|
|
9
|
+
readonly error_description?: string;
|
|
10
|
+
readonly order_id?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AP2PaymentReceipt {
|
|
13
|
+
readonly status: AP2ReceiptStatus;
|
|
14
|
+
readonly iss: string;
|
|
15
|
+
readonly iat: number;
|
|
16
|
+
readonly reference: string;
|
|
17
|
+
readonly error?: string;
|
|
18
|
+
readonly error_description?: string;
|
|
19
|
+
readonly payment_id: string;
|
|
20
|
+
readonly psp_confirmation_id?: string;
|
|
21
|
+
readonly network_confirmation_id?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface AP2ReceiptBundle {
|
|
24
|
+
readonly checkoutReceipt: AP2CheckoutReceipt;
|
|
25
|
+
readonly paymentReceipt: AP2PaymentReceipt;
|
|
26
|
+
}
|
|
27
|
+
export interface CreateAP2MandateReceiptStateInput extends AP2ReceiptBundle {
|
|
28
|
+
readonly manifestId: string;
|
|
29
|
+
readonly checkoutHash: string;
|
|
30
|
+
readonly paymentMandateId: string;
|
|
31
|
+
readonly disputeEvidenceReference?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface AP2MandateReceiptState {
|
|
34
|
+
readonly linkedState: LinkedReceiptState;
|
|
35
|
+
readonly metadata: Record<string, string>;
|
|
36
|
+
}
|
|
37
|
+
export type AP2ReceiptErrorCode = "INVALID_AP2_RECEIPT_STATUS" | "AP2_RECEIPT_REFERENCE_MISMATCH";
|
|
38
|
+
export declare class AP2ReceiptError extends Error {
|
|
39
|
+
readonly code: AP2ReceiptErrorCode;
|
|
40
|
+
constructor(code: AP2ReceiptErrorCode, message: string);
|
|
41
|
+
}
|
|
42
|
+
export declare function createAP2MandateReceiptState(input: CreateAP2MandateReceiptStateInput): AP2MandateReceiptState;
|
|
43
|
+
export declare function redactAP2MandateMetadata(value: unknown): unknown;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export class AP2ReceiptError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
constructor(code, message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.code = code;
|
|
6
|
+
this.name = "AP2ReceiptError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function createAP2MandateReceiptState(input) {
|
|
10
|
+
validateReceiptReferences(input);
|
|
11
|
+
const status = input.checkoutReceipt.status === "Success" && input.paymentReceipt.status === "Success"
|
|
12
|
+
? "succeeded"
|
|
13
|
+
: "failed";
|
|
14
|
+
const metadata = {
|
|
15
|
+
ap2ManifestId: input.manifestId,
|
|
16
|
+
ap2CheckoutHash: input.checkoutHash,
|
|
17
|
+
ap2PaymentMandateId: input.paymentMandateId,
|
|
18
|
+
ap2CheckoutReference: input.checkoutReceipt.reference,
|
|
19
|
+
ap2PaymentReference: input.paymentReceipt.reference,
|
|
20
|
+
ap2CheckoutReceiptStatus: input.checkoutReceipt.status,
|
|
21
|
+
ap2PaymentReceiptStatus: input.paymentReceipt.status,
|
|
22
|
+
ap2PaymentId: input.paymentReceipt.payment_id,
|
|
23
|
+
};
|
|
24
|
+
if (input.disputeEvidenceReference)
|
|
25
|
+
metadata.ap2DisputeEvidenceReference = input.disputeEvidenceReference;
|
|
26
|
+
if (input.checkoutReceipt.order_id)
|
|
27
|
+
metadata.ap2OrderId = input.checkoutReceipt.order_id;
|
|
28
|
+
if (input.checkoutReceipt.error)
|
|
29
|
+
metadata.ap2CheckoutError = input.checkoutReceipt.error;
|
|
30
|
+
if (input.paymentReceipt.error)
|
|
31
|
+
metadata.ap2PaymentError = input.paymentReceipt.error;
|
|
32
|
+
if (input.paymentReceipt.psp_confirmation_id)
|
|
33
|
+
metadata.ap2PspConfirmationId = input.paymentReceipt.psp_confirmation_id;
|
|
34
|
+
if (input.paymentReceipt.network_confirmation_id) {
|
|
35
|
+
metadata.ap2NetworkConfirmationId = input.paymentReceipt.network_confirmation_id;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
linkedState: {
|
|
39
|
+
status,
|
|
40
|
+
referenceId: `ap2:${input.paymentReceipt.payment_id}`,
|
|
41
|
+
},
|
|
42
|
+
metadata,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function validateReceiptReferences(input) {
|
|
46
|
+
requireReceiptStatus(input.checkoutReceipt.status);
|
|
47
|
+
requireReceiptStatus(input.paymentReceipt.status);
|
|
48
|
+
if (input.checkoutReceipt.reference !== input.checkoutHash) {
|
|
49
|
+
throw new AP2ReceiptError("AP2_RECEIPT_REFERENCE_MISMATCH", "AP2 checkout receipt reference must match the checkout mandate hash.");
|
|
50
|
+
}
|
|
51
|
+
if (input.paymentReceipt.reference !== input.paymentMandateId) {
|
|
52
|
+
throw new AP2ReceiptError("AP2_RECEIPT_REFERENCE_MISMATCH", "AP2 payment receipt reference must match the payment mandate id.");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function requireReceiptStatus(status) {
|
|
56
|
+
if (status !== "Success" && status !== "Error") {
|
|
57
|
+
throw new AP2ReceiptError("INVALID_AP2_RECEIPT_STATUS", "AP2 receipt status is unsupported.");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function redactAP2MandateMetadata(value) {
|
|
61
|
+
if (Array.isArray(value))
|
|
62
|
+
return value.map((item) => redactAP2MandateMetadata(item));
|
|
63
|
+
if (!isRecord(value))
|
|
64
|
+
return value;
|
|
65
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [
|
|
66
|
+
key,
|
|
67
|
+
isSensitiveAP2MetadataKey(key) ? "[REDACTED]" : redactAP2MandateMetadata(child),
|
|
68
|
+
]));
|
|
69
|
+
}
|
|
70
|
+
function isSensitiveAP2MetadataKey(key) {
|
|
71
|
+
return /^(checkout_jwt|payment_instrument|risk_data|.*authorization.*|.*credential.*|.*signature.*|.*token.*|.*card.*|.*bank.*)$/i.test(key);
|
|
72
|
+
}
|
|
73
|
+
function isRecord(value) {
|
|
74
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
75
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
export * from "./ap2Receipt.js";
|
|
2
|
+
export type ReceiptStatus = "attempted" | "denied" | "approved" | "sponsored" | "submitted" | "active" | "renewed" | "canceled" | "completed" | "released" | "refunded" | "disputed" | "revoked" | "failed";
|
|
3
|
+
export type EscrowStatus = "open" | "released" | "refunded" | "expired";
|
|
4
|
+
export interface ReceiptAmount {
|
|
5
|
+
readonly amount: string;
|
|
6
|
+
readonly asset: string;
|
|
7
|
+
}
|
|
8
|
+
export interface EscrowReceipt {
|
|
9
|
+
readonly receiptId: string;
|
|
10
|
+
readonly manifestId: string;
|
|
11
|
+
readonly idempotencyKey: string;
|
|
12
|
+
readonly agentId: string;
|
|
13
|
+
readonly ownerId: string;
|
|
14
|
+
readonly status: ReceiptStatus;
|
|
15
|
+
readonly amount: ReceiptAmount;
|
|
16
|
+
readonly escrow: EscrowState;
|
|
17
|
+
readonly createdAt: string;
|
|
18
|
+
readonly updatedAt: string;
|
|
19
|
+
readonly sponsorshipId?: string;
|
|
20
|
+
readonly transactionDigest?: string;
|
|
21
|
+
readonly evidenceHash?: string;
|
|
22
|
+
readonly releaseProofHash?: string;
|
|
23
|
+
readonly refundReason?: string;
|
|
24
|
+
readonly events: readonly ReceiptEvent[];
|
|
25
|
+
readonly externalPayment?: LinkedReceiptState;
|
|
26
|
+
readonly iotaReceipt?: LinkedReceiptState;
|
|
27
|
+
}
|
|
28
|
+
export interface PayPerCallReceipt {
|
|
29
|
+
readonly receiptId: string;
|
|
30
|
+
readonly manifestId: string;
|
|
31
|
+
readonly idempotencyKey: string;
|
|
32
|
+
readonly agentId: string;
|
|
33
|
+
readonly ownerId: string;
|
|
34
|
+
readonly providerId: string;
|
|
35
|
+
readonly toolName: string;
|
|
36
|
+
readonly status: ReceiptStatus;
|
|
37
|
+
readonly amount: ReceiptAmount;
|
|
38
|
+
readonly createdAt: string;
|
|
39
|
+
readonly updatedAt: string;
|
|
40
|
+
readonly sponsorshipId?: string;
|
|
41
|
+
readonly transactionDigest?: string;
|
|
42
|
+
readonly resultHash?: string;
|
|
43
|
+
readonly failureReason?: string;
|
|
44
|
+
readonly events: readonly ReceiptEvent[];
|
|
45
|
+
}
|
|
46
|
+
export interface DataLicenseReceipt {
|
|
47
|
+
readonly receiptId: string;
|
|
48
|
+
readonly manifestId: string;
|
|
49
|
+
readonly idempotencyKey: string;
|
|
50
|
+
readonly agentId: string;
|
|
51
|
+
readonly ownerId: string;
|
|
52
|
+
readonly providerId: string;
|
|
53
|
+
readonly licenseeId: string;
|
|
54
|
+
readonly datasetId: string;
|
|
55
|
+
readonly termsHash: string;
|
|
56
|
+
readonly status: ReceiptStatus;
|
|
57
|
+
readonly amount: ReceiptAmount;
|
|
58
|
+
readonly createdAt: string;
|
|
59
|
+
readonly updatedAt: string;
|
|
60
|
+
readonly sponsorshipId?: string;
|
|
61
|
+
readonly transactionDigest?: string;
|
|
62
|
+
readonly accessProofHash?: string;
|
|
63
|
+
readonly expiresAt?: string;
|
|
64
|
+
readonly failureReason?: string;
|
|
65
|
+
readonly revocationReason?: string;
|
|
66
|
+
readonly events: readonly ReceiptEvent[];
|
|
67
|
+
}
|
|
68
|
+
export interface ServiceBountyReceipt {
|
|
69
|
+
readonly receiptId: string;
|
|
70
|
+
readonly manifestId: string;
|
|
71
|
+
readonly idempotencyKey: string;
|
|
72
|
+
readonly agentId: string;
|
|
73
|
+
readonly ownerId: string;
|
|
74
|
+
readonly requesterId: string;
|
|
75
|
+
readonly providerId: string;
|
|
76
|
+
readonly bountyId: string;
|
|
77
|
+
readonly deliverableHash: string;
|
|
78
|
+
readonly status: ReceiptStatus;
|
|
79
|
+
readonly amount: ReceiptAmount;
|
|
80
|
+
readonly createdAt: string;
|
|
81
|
+
readonly updatedAt: string;
|
|
82
|
+
readonly sponsorshipId?: string;
|
|
83
|
+
readonly transactionDigest?: string;
|
|
84
|
+
readonly completionProofHash?: string;
|
|
85
|
+
readonly releaseProofHash?: string;
|
|
86
|
+
readonly failureReason?: string;
|
|
87
|
+
readonly events: readonly ReceiptEvent[];
|
|
88
|
+
}
|
|
89
|
+
export interface ReputationReceipt {
|
|
90
|
+
readonly receiptId: string;
|
|
91
|
+
readonly manifestId: string;
|
|
92
|
+
readonly idempotencyKey: string;
|
|
93
|
+
readonly agentId: string;
|
|
94
|
+
readonly ownerId: string;
|
|
95
|
+
readonly issuerId: string;
|
|
96
|
+
readonly subjectId: string;
|
|
97
|
+
readonly interactionId: string;
|
|
98
|
+
readonly criteriaHash: string;
|
|
99
|
+
readonly status: ReceiptStatus;
|
|
100
|
+
readonly amount: ReceiptAmount;
|
|
101
|
+
readonly createdAt: string;
|
|
102
|
+
readonly updatedAt: string;
|
|
103
|
+
readonly sponsorshipId?: string;
|
|
104
|
+
readonly transactionDigest?: string;
|
|
105
|
+
readonly score?: number;
|
|
106
|
+
readonly evidenceHash?: string;
|
|
107
|
+
readonly attestationHash?: string;
|
|
108
|
+
readonly failureReason?: string;
|
|
109
|
+
readonly events: readonly ReceiptEvent[];
|
|
110
|
+
}
|
|
111
|
+
export interface SubscriptionReceipt {
|
|
112
|
+
readonly receiptId: string;
|
|
113
|
+
readonly manifestId: string;
|
|
114
|
+
readonly idempotencyKey: string;
|
|
115
|
+
readonly agentId: string;
|
|
116
|
+
readonly ownerId: string;
|
|
117
|
+
readonly subscriberId: string;
|
|
118
|
+
readonly providerId: string;
|
|
119
|
+
readonly planId: string;
|
|
120
|
+
readonly termsHash: string;
|
|
121
|
+
readonly periodStart: string;
|
|
122
|
+
readonly periodEnd: string;
|
|
123
|
+
readonly renewalCount: number;
|
|
124
|
+
readonly status: ReceiptStatus;
|
|
125
|
+
readonly amount: ReceiptAmount;
|
|
126
|
+
readonly createdAt: string;
|
|
127
|
+
readonly updatedAt: string;
|
|
128
|
+
readonly sponsorshipId?: string;
|
|
129
|
+
readonly transactionDigest?: string;
|
|
130
|
+
readonly renewalSponsorshipId?: string;
|
|
131
|
+
readonly renewalTransactionDigest?: string;
|
|
132
|
+
readonly activationProofHash?: string;
|
|
133
|
+
readonly renewalProofHash?: string;
|
|
134
|
+
readonly cancellationReason?: string;
|
|
135
|
+
readonly failureReason?: string;
|
|
136
|
+
readonly events: readonly ReceiptEvent[];
|
|
137
|
+
}
|
|
138
|
+
export interface EscrowState {
|
|
139
|
+
readonly status: EscrowStatus;
|
|
140
|
+
readonly providerId: string;
|
|
141
|
+
readonly verifierId: string;
|
|
142
|
+
}
|
|
143
|
+
export interface LinkedReceiptState {
|
|
144
|
+
readonly status: "pending" | "succeeded" | "failed";
|
|
145
|
+
readonly referenceId: string;
|
|
146
|
+
}
|
|
147
|
+
export interface ReceiptEvent {
|
|
148
|
+
readonly type: "escrow_created" | "pay_per_call_created" | "data_license_created" | "service_bounty_created" | "reputation_receipt_created" | "subscription_created" | "approved" | "denied" | "sponsored" | "submitted" | "activated" | "renewed" | "canceled" | "completed" | "access_granted" | "access_revoked" | "released" | "refunded" | "expired" | "failed";
|
|
149
|
+
readonly at: string;
|
|
150
|
+
readonly reason?: string;
|
|
151
|
+
}
|
|
152
|
+
export interface CreateEscrowReceiptInput {
|
|
153
|
+
readonly receiptId: string;
|
|
154
|
+
readonly manifestId: string;
|
|
155
|
+
readonly idempotencyKey: string;
|
|
156
|
+
readonly agentId: string;
|
|
157
|
+
readonly ownerId: string;
|
|
158
|
+
readonly providerId: string;
|
|
159
|
+
readonly verifierId: string;
|
|
160
|
+
readonly amount: ReceiptAmount;
|
|
161
|
+
readonly createdAt: Date;
|
|
162
|
+
}
|
|
163
|
+
export interface CreatePayPerCallReceiptInput {
|
|
164
|
+
readonly receiptId: string;
|
|
165
|
+
readonly manifestId: string;
|
|
166
|
+
readonly idempotencyKey: string;
|
|
167
|
+
readonly agentId: string;
|
|
168
|
+
readonly ownerId: string;
|
|
169
|
+
readonly providerId: string;
|
|
170
|
+
readonly toolName: string;
|
|
171
|
+
readonly amount: ReceiptAmount;
|
|
172
|
+
readonly createdAt: Date;
|
|
173
|
+
}
|
|
174
|
+
export interface CreateDataLicenseReceiptInput {
|
|
175
|
+
readonly receiptId: string;
|
|
176
|
+
readonly manifestId: string;
|
|
177
|
+
readonly idempotencyKey: string;
|
|
178
|
+
readonly agentId: string;
|
|
179
|
+
readonly ownerId: string;
|
|
180
|
+
readonly providerId: string;
|
|
181
|
+
readonly licenseeId: string;
|
|
182
|
+
readonly datasetId: string;
|
|
183
|
+
readonly termsHash: string;
|
|
184
|
+
readonly amount: ReceiptAmount;
|
|
185
|
+
readonly createdAt: Date;
|
|
186
|
+
}
|
|
187
|
+
export interface CreateServiceBountyReceiptInput {
|
|
188
|
+
readonly receiptId: string;
|
|
189
|
+
readonly manifestId: string;
|
|
190
|
+
readonly idempotencyKey: string;
|
|
191
|
+
readonly agentId: string;
|
|
192
|
+
readonly ownerId: string;
|
|
193
|
+
readonly requesterId: string;
|
|
194
|
+
readonly providerId: string;
|
|
195
|
+
readonly bountyId: string;
|
|
196
|
+
readonly deliverableHash: string;
|
|
197
|
+
readonly amount: ReceiptAmount;
|
|
198
|
+
readonly createdAt: Date;
|
|
199
|
+
}
|
|
200
|
+
export interface CreateReputationReceiptInput {
|
|
201
|
+
readonly receiptId: string;
|
|
202
|
+
readonly manifestId: string;
|
|
203
|
+
readonly idempotencyKey: string;
|
|
204
|
+
readonly agentId: string;
|
|
205
|
+
readonly ownerId: string;
|
|
206
|
+
readonly issuerId: string;
|
|
207
|
+
readonly subjectId: string;
|
|
208
|
+
readonly interactionId: string;
|
|
209
|
+
readonly criteriaHash: string;
|
|
210
|
+
readonly amount: ReceiptAmount;
|
|
211
|
+
readonly createdAt: Date;
|
|
212
|
+
}
|
|
213
|
+
export interface CreateSubscriptionReceiptInput {
|
|
214
|
+
readonly receiptId: string;
|
|
215
|
+
readonly manifestId: string;
|
|
216
|
+
readonly idempotencyKey: string;
|
|
217
|
+
readonly agentId: string;
|
|
218
|
+
readonly ownerId: string;
|
|
219
|
+
readonly subscriberId: string;
|
|
220
|
+
readonly providerId: string;
|
|
221
|
+
readonly planId: string;
|
|
222
|
+
readonly termsHash: string;
|
|
223
|
+
readonly periodStart: string;
|
|
224
|
+
readonly periodEnd: string;
|
|
225
|
+
readonly amount: ReceiptAmount;
|
|
226
|
+
readonly createdAt: Date;
|
|
227
|
+
}
|
|
228
|
+
export interface TransitionOptions {
|
|
229
|
+
readonly at: Date;
|
|
230
|
+
}
|
|
231
|
+
export declare class ReceiptTransitionError extends Error {
|
|
232
|
+
readonly code: "INVALID_TRANSITION" | "UNAUTHORIZED_VERIFIER";
|
|
233
|
+
constructor(code: "INVALID_TRANSITION" | "UNAUTHORIZED_VERIFIER", message: string);
|
|
234
|
+
}
|
|
235
|
+
export declare class ReceiptInputError extends Error {
|
|
236
|
+
readonly code: "FIELD_REQUIRED";
|
|
237
|
+
constructor(code: "FIELD_REQUIRED", message: string);
|
|
238
|
+
}
|
|
239
|
+
export declare function createEscrowReceipt(input: CreateEscrowReceiptInput): EscrowReceipt;
|
|
240
|
+
export declare function createPayPerCallReceipt(input: CreatePayPerCallReceiptInput): PayPerCallReceipt;
|
|
241
|
+
export declare function createDataLicenseReceipt(input: CreateDataLicenseReceiptInput): DataLicenseReceipt;
|
|
242
|
+
export declare function createServiceBountyReceipt(input: CreateServiceBountyReceiptInput): ServiceBountyReceipt;
|
|
243
|
+
export declare function createReputationReceipt(input: CreateReputationReceiptInput): ReputationReceipt;
|
|
244
|
+
export declare function createSubscriptionReceipt(input: CreateSubscriptionReceiptInput): SubscriptionReceipt;
|
|
245
|
+
export declare function approveReceipt(receipt: EscrowReceipt, options: TransitionOptions): EscrowReceipt;
|
|
246
|
+
export declare function approvePayPerCallReceipt(receipt: PayPerCallReceipt, options: TransitionOptions): PayPerCallReceipt;
|
|
247
|
+
export declare function approveDataLicenseReceipt(receipt: DataLicenseReceipt, options: TransitionOptions): DataLicenseReceipt;
|
|
248
|
+
export declare function approveServiceBountyReceipt(receipt: ServiceBountyReceipt, options: TransitionOptions): ServiceBountyReceipt;
|
|
249
|
+
export declare function approveReputationReceipt(receipt: ReputationReceipt, options: TransitionOptions): ReputationReceipt;
|
|
250
|
+
export declare function approveSubscriptionReceipt(receipt: SubscriptionReceipt, options: TransitionOptions): SubscriptionReceipt;
|
|
251
|
+
export declare function denyReceipt(receipt: EscrowReceipt, options: TransitionOptions & {
|
|
252
|
+
readonly reason: string;
|
|
253
|
+
}): EscrowReceipt;
|
|
254
|
+
export declare function denyPayPerCallReceipt(receipt: PayPerCallReceipt, options: TransitionOptions & {
|
|
255
|
+
readonly reason: string;
|
|
256
|
+
}): PayPerCallReceipt;
|
|
257
|
+
export declare function denyDataLicenseReceipt(receipt: DataLicenseReceipt, options: TransitionOptions & {
|
|
258
|
+
readonly reason: string;
|
|
259
|
+
}): DataLicenseReceipt;
|
|
260
|
+
export declare function denyServiceBountyReceipt(receipt: ServiceBountyReceipt, options: TransitionOptions & {
|
|
261
|
+
readonly reason: string;
|
|
262
|
+
}): ServiceBountyReceipt;
|
|
263
|
+
export declare function denyReputationReceipt(receipt: ReputationReceipt, options: TransitionOptions & {
|
|
264
|
+
readonly reason: string;
|
|
265
|
+
}): ReputationReceipt;
|
|
266
|
+
export declare function denySubscriptionReceipt(receipt: SubscriptionReceipt, options: TransitionOptions & {
|
|
267
|
+
readonly reason: string;
|
|
268
|
+
}): SubscriptionReceipt;
|
|
269
|
+
export declare function sponsorReceipt(receipt: EscrowReceipt, options: TransitionOptions & {
|
|
270
|
+
readonly sponsorshipId: string;
|
|
271
|
+
}): EscrowReceipt;
|
|
272
|
+
export declare function sponsorPayPerCallReceipt(receipt: PayPerCallReceipt, options: TransitionOptions & {
|
|
273
|
+
readonly sponsorshipId: string;
|
|
274
|
+
}): PayPerCallReceipt;
|
|
275
|
+
export declare function sponsorDataLicenseReceipt(receipt: DataLicenseReceipt, options: TransitionOptions & {
|
|
276
|
+
readonly sponsorshipId: string;
|
|
277
|
+
}): DataLicenseReceipt;
|
|
278
|
+
export declare function sponsorServiceBountyReceipt(receipt: ServiceBountyReceipt, options: TransitionOptions & {
|
|
279
|
+
readonly sponsorshipId: string;
|
|
280
|
+
}): ServiceBountyReceipt;
|
|
281
|
+
export declare function sponsorReputationReceipt(receipt: ReputationReceipt, options: TransitionOptions & {
|
|
282
|
+
readonly sponsorshipId: string;
|
|
283
|
+
}): ReputationReceipt;
|
|
284
|
+
export declare function sponsorSubscriptionReceipt(receipt: SubscriptionReceipt, options: TransitionOptions & {
|
|
285
|
+
readonly sponsorshipId: string;
|
|
286
|
+
}): SubscriptionReceipt;
|
|
287
|
+
export declare function submitReceipt(receipt: EscrowReceipt, options: TransitionOptions & {
|
|
288
|
+
readonly transactionDigest: string;
|
|
289
|
+
}): EscrowReceipt;
|
|
290
|
+
export declare function submitPayPerCallReceipt(receipt: PayPerCallReceipt, options: TransitionOptions & {
|
|
291
|
+
readonly transactionDigest: string;
|
|
292
|
+
}): PayPerCallReceipt;
|
|
293
|
+
export declare function submitDataLicenseReceipt(receipt: DataLicenseReceipt, options: TransitionOptions & {
|
|
294
|
+
readonly transactionDigest: string;
|
|
295
|
+
}): DataLicenseReceipt;
|
|
296
|
+
export declare function submitServiceBountyReceipt(receipt: ServiceBountyReceipt, options: TransitionOptions & {
|
|
297
|
+
readonly transactionDigest: string;
|
|
298
|
+
}): ServiceBountyReceipt;
|
|
299
|
+
export declare function submitReputationReceipt(receipt: ReputationReceipt, options: TransitionOptions & {
|
|
300
|
+
readonly transactionDigest: string;
|
|
301
|
+
}): ReputationReceipt;
|
|
302
|
+
export declare function submitSubscriptionReceipt(receipt: SubscriptionReceipt, options: TransitionOptions & {
|
|
303
|
+
readonly transactionDigest: string;
|
|
304
|
+
}): SubscriptionReceipt;
|
|
305
|
+
export declare function completeEscrow(receipt: EscrowReceipt, options: TransitionOptions & {
|
|
306
|
+
readonly evidenceHash: string;
|
|
307
|
+
}): EscrowReceipt;
|
|
308
|
+
export declare function completePayPerCallReceipt(receipt: PayPerCallReceipt, options: TransitionOptions & {
|
|
309
|
+
readonly resultHash: string;
|
|
310
|
+
}): PayPerCallReceipt;
|
|
311
|
+
export declare function failPayPerCallReceipt(receipt: PayPerCallReceipt, options: TransitionOptions & {
|
|
312
|
+
readonly reason: string;
|
|
313
|
+
}): PayPerCallReceipt;
|
|
314
|
+
export declare function grantDataLicenseAccess(receipt: DataLicenseReceipt, options: TransitionOptions & {
|
|
315
|
+
readonly accessProofHash: string;
|
|
316
|
+
readonly expiresAt?: string;
|
|
317
|
+
}): DataLicenseReceipt;
|
|
318
|
+
export declare function failDataLicenseReceipt(receipt: DataLicenseReceipt, options: TransitionOptions & {
|
|
319
|
+
readonly reason: string;
|
|
320
|
+
}): DataLicenseReceipt;
|
|
321
|
+
export declare function completeServiceBountyReceipt(receipt: ServiceBountyReceipt, options: TransitionOptions & {
|
|
322
|
+
readonly completionProofHash: string;
|
|
323
|
+
}): ServiceBountyReceipt;
|
|
324
|
+
export declare function releaseServiceBountyReceipt(receipt: ServiceBountyReceipt, options: TransitionOptions & {
|
|
325
|
+
readonly releaseProofHash: string;
|
|
326
|
+
}): ServiceBountyReceipt;
|
|
327
|
+
export declare function failServiceBountyReceipt(receipt: ServiceBountyReceipt, options: TransitionOptions & {
|
|
328
|
+
readonly reason: string;
|
|
329
|
+
}): ServiceBountyReceipt;
|
|
330
|
+
export declare function completeReputationReceipt(receipt: ReputationReceipt, options: TransitionOptions & {
|
|
331
|
+
readonly score: number;
|
|
332
|
+
readonly evidenceHash: string;
|
|
333
|
+
readonly attestationHash: string;
|
|
334
|
+
}): ReputationReceipt;
|
|
335
|
+
export declare function failReputationReceipt(receipt: ReputationReceipt, options: TransitionOptions & {
|
|
336
|
+
readonly reason: string;
|
|
337
|
+
}): ReputationReceipt;
|
|
338
|
+
export declare function activateSubscriptionReceipt(receipt: SubscriptionReceipt, options: TransitionOptions & {
|
|
339
|
+
readonly activationProofHash: string;
|
|
340
|
+
}): SubscriptionReceipt;
|
|
341
|
+
export declare function renewSubscriptionReceipt(receipt: SubscriptionReceipt, options: TransitionOptions & {
|
|
342
|
+
readonly periodEnd: string;
|
|
343
|
+
readonly renewalProofHash: string;
|
|
344
|
+
readonly sponsorshipId?: string;
|
|
345
|
+
readonly transactionDigest?: string;
|
|
346
|
+
}): SubscriptionReceipt;
|
|
347
|
+
export declare function cancelSubscriptionReceipt(receipt: SubscriptionReceipt, options: TransitionOptions & {
|
|
348
|
+
readonly reason: string;
|
|
349
|
+
}): SubscriptionReceipt;
|
|
350
|
+
export declare function failSubscriptionReceipt(receipt: SubscriptionReceipt, options: TransitionOptions & {
|
|
351
|
+
readonly reason: string;
|
|
352
|
+
}): SubscriptionReceipt;
|
|
353
|
+
export declare function revokeDataLicenseAccess(receipt: DataLicenseReceipt, options: TransitionOptions & {
|
|
354
|
+
readonly reason: string;
|
|
355
|
+
}): DataLicenseReceipt;
|
|
356
|
+
export declare function releaseEscrow(receipt: EscrowReceipt, options: TransitionOptions & {
|
|
357
|
+
readonly verifierId: string;
|
|
358
|
+
readonly releaseProofHash: string;
|
|
359
|
+
}): EscrowReceipt;
|
|
360
|
+
export declare function refundEscrow(receipt: EscrowReceipt, options: TransitionOptions & {
|
|
361
|
+
readonly reason: string;
|
|
362
|
+
}): EscrowReceipt;
|
|
363
|
+
export declare function expireEscrow(receipt: EscrowReceipt, options: TransitionOptions & {
|
|
364
|
+
readonly reason: string;
|
|
365
|
+
}): EscrowReceipt;
|
|
366
|
+
export declare function linkExternalPaymentState(receipt: EscrowReceipt, state: LinkedReceiptState): EscrowReceipt;
|
|
367
|
+
export declare function linkIotaReceiptState(receipt: EscrowReceipt, state: LinkedReceiptState): EscrowReceipt;
|
|
368
|
+
export * from "./x402Receipt.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
export * from "./ap2Receipt.js";
|
|
2
|
+
export class ReceiptTransitionError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(code, message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.name = "ReceiptTransitionError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class ReceiptInputError extends Error {
|
|
11
|
+
code;
|
|
12
|
+
constructor(code, message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.name = "ReceiptInputError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function createEscrowReceipt(input) {
|
|
19
|
+
const at = input.createdAt.toISOString();
|
|
20
|
+
return {
|
|
21
|
+
receiptId: input.receiptId,
|
|
22
|
+
manifestId: input.manifestId,
|
|
23
|
+
idempotencyKey: input.idempotencyKey,
|
|
24
|
+
agentId: input.agentId,
|
|
25
|
+
ownerId: input.ownerId,
|
|
26
|
+
status: "attempted",
|
|
27
|
+
amount: input.amount,
|
|
28
|
+
escrow: {
|
|
29
|
+
status: "open",
|
|
30
|
+
providerId: input.providerId,
|
|
31
|
+
verifierId: input.verifierId,
|
|
32
|
+
},
|
|
33
|
+
createdAt: at,
|
|
34
|
+
updatedAt: at,
|
|
35
|
+
events: [{ type: "escrow_created", at }],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function createPayPerCallReceipt(input) {
|
|
39
|
+
const at = input.createdAt.toISOString();
|
|
40
|
+
return {
|
|
41
|
+
receiptId: input.receiptId,
|
|
42
|
+
manifestId: input.manifestId,
|
|
43
|
+
idempotencyKey: input.idempotencyKey,
|
|
44
|
+
agentId: input.agentId,
|
|
45
|
+
ownerId: input.ownerId,
|
|
46
|
+
providerId: input.providerId,
|
|
47
|
+
toolName: input.toolName,
|
|
48
|
+
status: "attempted",
|
|
49
|
+
amount: input.amount,
|
|
50
|
+
createdAt: at,
|
|
51
|
+
updatedAt: at,
|
|
52
|
+
events: [{ type: "pay_per_call_created", at }],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function createDataLicenseReceipt(input) {
|
|
56
|
+
requireNonEmpty(input.providerId, "providerId");
|
|
57
|
+
requireNonEmpty(input.licenseeId, "licenseeId");
|
|
58
|
+
requireNonEmpty(input.datasetId, "datasetId");
|
|
59
|
+
requireNonEmpty(input.termsHash, "termsHash");
|
|
60
|
+
const at = input.createdAt.toISOString();
|
|
61
|
+
return {
|
|
62
|
+
receiptId: input.receiptId,
|
|
63
|
+
manifestId: input.manifestId,
|
|
64
|
+
idempotencyKey: input.idempotencyKey,
|
|
65
|
+
agentId: input.agentId,
|
|
66
|
+
ownerId: input.ownerId,
|
|
67
|
+
providerId: input.providerId,
|
|
68
|
+
licenseeId: input.licenseeId,
|
|
69
|
+
datasetId: input.datasetId,
|
|
70
|
+
termsHash: input.termsHash,
|
|
71
|
+
status: "attempted",
|
|
72
|
+
amount: input.amount,
|
|
73
|
+
createdAt: at,
|
|
74
|
+
updatedAt: at,
|
|
75
|
+
events: [{ type: "data_license_created", at }],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function createServiceBountyReceipt(input) {
|
|
79
|
+
requireNonEmpty(input.requesterId, "requesterId");
|
|
80
|
+
requireNonEmpty(input.providerId, "providerId");
|
|
81
|
+
requireNonEmpty(input.bountyId, "bountyId");
|
|
82
|
+
requireNonEmpty(input.deliverableHash, "deliverableHash");
|
|
83
|
+
const at = input.createdAt.toISOString();
|
|
84
|
+
return {
|
|
85
|
+
receiptId: input.receiptId,
|
|
86
|
+
manifestId: input.manifestId,
|
|
87
|
+
idempotencyKey: input.idempotencyKey,
|
|
88
|
+
agentId: input.agentId,
|
|
89
|
+
ownerId: input.ownerId,
|
|
90
|
+
requesterId: input.requesterId,
|
|
91
|
+
providerId: input.providerId,
|
|
92
|
+
bountyId: input.bountyId,
|
|
93
|
+
deliverableHash: input.deliverableHash,
|
|
94
|
+
status: "attempted",
|
|
95
|
+
amount: input.amount,
|
|
96
|
+
createdAt: at,
|
|
97
|
+
updatedAt: at,
|
|
98
|
+
events: [{ type: "service_bounty_created", at }],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function createReputationReceipt(input) {
|
|
102
|
+
requireNonEmpty(input.issuerId, "issuerId");
|
|
103
|
+
requireNonEmpty(input.subjectId, "subjectId");
|
|
104
|
+
requireNonEmpty(input.interactionId, "interactionId");
|
|
105
|
+
requireNonEmpty(input.criteriaHash, "criteriaHash");
|
|
106
|
+
requireMatchingField(input.issuerId, input.agentId, "issuerId", "agentId");
|
|
107
|
+
const at = input.createdAt.toISOString();
|
|
108
|
+
return {
|
|
109
|
+
receiptId: input.receiptId,
|
|
110
|
+
manifestId: input.manifestId,
|
|
111
|
+
idempotencyKey: input.idempotencyKey,
|
|
112
|
+
agentId: input.agentId,
|
|
113
|
+
ownerId: input.ownerId,
|
|
114
|
+
issuerId: input.issuerId,
|
|
115
|
+
subjectId: input.subjectId,
|
|
116
|
+
interactionId: input.interactionId,
|
|
117
|
+
criteriaHash: input.criteriaHash,
|
|
118
|
+
status: "attempted",
|
|
119
|
+
amount: input.amount,
|
|
120
|
+
createdAt: at,
|
|
121
|
+
updatedAt: at,
|
|
122
|
+
events: [{ type: "reputation_receipt_created", at }],
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export function createSubscriptionReceipt(input) {
|
|
126
|
+
requireNonEmpty(input.subscriberId, "subscriberId");
|
|
127
|
+
requireNonEmpty(input.providerId, "providerId");
|
|
128
|
+
requireNonEmpty(input.planId, "planId");
|
|
129
|
+
requireSafeHashReference(input.termsHash, "termsHash");
|
|
130
|
+
requireNonEmpty(input.periodStart, "periodStart");
|
|
131
|
+
requireNonEmpty(input.periodEnd, "periodEnd");
|
|
132
|
+
requireMatchingField(input.subscriberId, input.agentId, "subscriberId", "agentId");
|
|
133
|
+
requirePeriodAfter(input.periodStart, input.periodEnd, "periodEnd");
|
|
134
|
+
const at = input.createdAt.toISOString();
|
|
135
|
+
return {
|
|
136
|
+
receiptId: input.receiptId,
|
|
137
|
+
manifestId: input.manifestId,
|
|
138
|
+
idempotencyKey: input.idempotencyKey,
|
|
139
|
+
agentId: input.agentId,
|
|
140
|
+
ownerId: input.ownerId,
|
|
141
|
+
subscriberId: input.subscriberId,
|
|
142
|
+
providerId: input.providerId,
|
|
143
|
+
planId: input.planId,
|
|
144
|
+
termsHash: input.termsHash,
|
|
145
|
+
periodStart: input.periodStart,
|
|
146
|
+
periodEnd: input.periodEnd,
|
|
147
|
+
renewalCount: 0,
|
|
148
|
+
status: "attempted",
|
|
149
|
+
amount: input.amount,
|
|
150
|
+
createdAt: at,
|
|
151
|
+
updatedAt: at,
|
|
152
|
+
events: [{ type: "subscription_created", at }],
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
export function approveReceipt(receipt, options) {
|
|
156
|
+
requireReceiptStatus(receipt, ["attempted"], "approve");
|
|
157
|
+
return withReceiptEvent(receipt, "approved", options.at, { status: "approved" });
|
|
158
|
+
}
|
|
159
|
+
export function approvePayPerCallReceipt(receipt, options) {
|
|
160
|
+
requireReceiptStatus(receipt, ["attempted"], "approve");
|
|
161
|
+
return withPayPerCallReceiptEvent(receipt, "approved", options.at, { status: "approved" });
|
|
162
|
+
}
|
|
163
|
+
export function approveDataLicenseReceipt(receipt, options) {
|
|
164
|
+
requireReceiptStatus(receipt, ["attempted"], "approve");
|
|
165
|
+
return withDataLicenseReceiptEvent(receipt, "approved", options.at, { status: "approved" });
|
|
166
|
+
}
|
|
167
|
+
export function approveServiceBountyReceipt(receipt, options) {
|
|
168
|
+
requireReceiptStatus(receipt, ["attempted"], "approve");
|
|
169
|
+
return withServiceBountyReceiptEvent(receipt, "approved", options.at, { status: "approved" });
|
|
170
|
+
}
|
|
171
|
+
export function approveReputationReceipt(receipt, options) {
|
|
172
|
+
requireReceiptStatus(receipt, ["attempted"], "approve");
|
|
173
|
+
return withReputationReceiptEvent(receipt, "approved", options.at, { status: "approved" });
|
|
174
|
+
}
|
|
175
|
+
export function approveSubscriptionReceipt(receipt, options) {
|
|
176
|
+
requireReceiptStatus(receipt, ["attempted"], "approve");
|
|
177
|
+
return withSubscriptionReceiptEvent(receipt, "approved", options.at, { status: "approved" });
|
|
178
|
+
}
|
|
179
|
+
export function denyReceipt(receipt, options) {
|
|
180
|
+
requireReceiptStatus(receipt, ["attempted"], "deny");
|
|
181
|
+
return withReceiptEvent(receipt, "denied", options.at, {
|
|
182
|
+
status: "denied",
|
|
183
|
+
}, options.reason);
|
|
184
|
+
}
|
|
185
|
+
export function denyPayPerCallReceipt(receipt, options) {
|
|
186
|
+
requireReceiptStatus(receipt, ["attempted"], "deny");
|
|
187
|
+
return withPayPerCallReceiptEvent(receipt, "denied", options.at, {
|
|
188
|
+
status: "denied",
|
|
189
|
+
failureReason: options.reason,
|
|
190
|
+
}, options.reason);
|
|
191
|
+
}
|
|
192
|
+
export function denyDataLicenseReceipt(receipt, options) {
|
|
193
|
+
requireReceiptStatus(receipt, ["attempted"], "deny");
|
|
194
|
+
return withDataLicenseReceiptEvent(receipt, "denied", options.at, {
|
|
195
|
+
status: "denied",
|
|
196
|
+
failureReason: options.reason,
|
|
197
|
+
}, options.reason);
|
|
198
|
+
}
|
|
199
|
+
export function denyServiceBountyReceipt(receipt, options) {
|
|
200
|
+
requireReceiptStatus(receipt, ["attempted"], "deny");
|
|
201
|
+
return withServiceBountyReceiptEvent(receipt, "denied", options.at, {
|
|
202
|
+
status: "denied",
|
|
203
|
+
failureReason: options.reason,
|
|
204
|
+
}, options.reason);
|
|
205
|
+
}
|
|
206
|
+
export function denyReputationReceipt(receipt, options) {
|
|
207
|
+
requireReceiptStatus(receipt, ["attempted"], "deny");
|
|
208
|
+
return withReputationReceiptEvent(receipt, "denied", options.at, {
|
|
209
|
+
status: "denied",
|
|
210
|
+
failureReason: options.reason,
|
|
211
|
+
}, options.reason);
|
|
212
|
+
}
|
|
213
|
+
export function denySubscriptionReceipt(receipt, options) {
|
|
214
|
+
requireReceiptStatus(receipt, ["attempted"], "deny");
|
|
215
|
+
return withSubscriptionReceiptEvent(receipt, "denied", options.at, {
|
|
216
|
+
status: "denied",
|
|
217
|
+
failureReason: options.reason,
|
|
218
|
+
}, options.reason);
|
|
219
|
+
}
|
|
220
|
+
export function sponsorReceipt(receipt, options) {
|
|
221
|
+
requireReceiptStatus(receipt, ["approved"], "sponsor");
|
|
222
|
+
return withReceiptEvent(receipt, "sponsored", options.at, {
|
|
223
|
+
status: "sponsored",
|
|
224
|
+
sponsorshipId: options.sponsorshipId,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
export function sponsorPayPerCallReceipt(receipt, options) {
|
|
228
|
+
requireReceiptStatus(receipt, ["approved"], "sponsor");
|
|
229
|
+
return withPayPerCallReceiptEvent(receipt, "sponsored", options.at, {
|
|
230
|
+
status: "sponsored",
|
|
231
|
+
sponsorshipId: options.sponsorshipId,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
export function sponsorDataLicenseReceipt(receipt, options) {
|
|
235
|
+
requireReceiptStatus(receipt, ["approved"], "sponsor");
|
|
236
|
+
return withDataLicenseReceiptEvent(receipt, "sponsored", options.at, {
|
|
237
|
+
status: "sponsored",
|
|
238
|
+
sponsorshipId: options.sponsorshipId,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
export function sponsorServiceBountyReceipt(receipt, options) {
|
|
242
|
+
requireReceiptStatus(receipt, ["approved"], "sponsor");
|
|
243
|
+
return withServiceBountyReceiptEvent(receipt, "sponsored", options.at, {
|
|
244
|
+
status: "sponsored",
|
|
245
|
+
sponsorshipId: options.sponsorshipId,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
export function sponsorReputationReceipt(receipt, options) {
|
|
249
|
+
requireReceiptStatus(receipt, ["approved"], "sponsor");
|
|
250
|
+
return withReputationReceiptEvent(receipt, "sponsored", options.at, {
|
|
251
|
+
status: "sponsored",
|
|
252
|
+
sponsorshipId: options.sponsorshipId,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
export function sponsorSubscriptionReceipt(receipt, options) {
|
|
256
|
+
requireReceiptStatus(receipt, ["approved"], "sponsor");
|
|
257
|
+
return withSubscriptionReceiptEvent(receipt, "sponsored", options.at, {
|
|
258
|
+
status: "sponsored",
|
|
259
|
+
sponsorshipId: options.sponsorshipId,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
export function submitReceipt(receipt, options) {
|
|
263
|
+
requireReceiptStatus(receipt, ["sponsored"], "submit");
|
|
264
|
+
return withReceiptEvent(receipt, "submitted", options.at, {
|
|
265
|
+
status: "submitted",
|
|
266
|
+
transactionDigest: options.transactionDigest,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
export function submitPayPerCallReceipt(receipt, options) {
|
|
270
|
+
requireReceiptStatus(receipt, ["sponsored"], "submit");
|
|
271
|
+
return withPayPerCallReceiptEvent(receipt, "submitted", options.at, {
|
|
272
|
+
status: "submitted",
|
|
273
|
+
transactionDigest: options.transactionDigest,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
export function submitDataLicenseReceipt(receipt, options) {
|
|
277
|
+
requireReceiptStatus(receipt, ["sponsored"], "submit");
|
|
278
|
+
return withDataLicenseReceiptEvent(receipt, "submitted", options.at, {
|
|
279
|
+
status: "submitted",
|
|
280
|
+
transactionDigest: options.transactionDigest,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
export function submitServiceBountyReceipt(receipt, options) {
|
|
284
|
+
requireReceiptStatus(receipt, ["sponsored"], "submit");
|
|
285
|
+
return withServiceBountyReceiptEvent(receipt, "submitted", options.at, {
|
|
286
|
+
status: "submitted",
|
|
287
|
+
transactionDigest: options.transactionDigest,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
export function submitReputationReceipt(receipt, options) {
|
|
291
|
+
requireReceiptStatus(receipt, ["sponsored"], "submit");
|
|
292
|
+
return withReputationReceiptEvent(receipt, "submitted", options.at, {
|
|
293
|
+
status: "submitted",
|
|
294
|
+
transactionDigest: options.transactionDigest,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
export function submitSubscriptionReceipt(receipt, options) {
|
|
298
|
+
requireReceiptStatus(receipt, ["sponsored"], "submit");
|
|
299
|
+
return withSubscriptionReceiptEvent(receipt, "submitted", options.at, {
|
|
300
|
+
status: "submitted",
|
|
301
|
+
transactionDigest: options.transactionDigest,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
export function completeEscrow(receipt, options) {
|
|
305
|
+
requireReceiptStatus(receipt, ["submitted"], "complete");
|
|
306
|
+
requireEscrowOpen(receipt, "complete");
|
|
307
|
+
return withReceiptEvent(receipt, "completed", options.at, {
|
|
308
|
+
status: "completed",
|
|
309
|
+
evidenceHash: options.evidenceHash,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
export function completePayPerCallReceipt(receipt, options) {
|
|
313
|
+
requireReceiptStatus(receipt, ["submitted"], "complete");
|
|
314
|
+
return withPayPerCallReceiptEvent(receipt, "completed", options.at, {
|
|
315
|
+
status: "completed",
|
|
316
|
+
resultHash: options.resultHash,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
export function failPayPerCallReceipt(receipt, options) {
|
|
320
|
+
requireReceiptStatus(receipt, ["attempted", "approved", "sponsored", "submitted"], "fail");
|
|
321
|
+
return withPayPerCallReceiptEvent(receipt, "failed", options.at, {
|
|
322
|
+
status: "failed",
|
|
323
|
+
failureReason: options.reason,
|
|
324
|
+
}, options.reason);
|
|
325
|
+
}
|
|
326
|
+
export function grantDataLicenseAccess(receipt, options) {
|
|
327
|
+
requireReceiptStatus(receipt, ["submitted"], "grant access");
|
|
328
|
+
requireNonEmpty(options.accessProofHash, "accessProofHash");
|
|
329
|
+
return withDataLicenseReceiptEvent(receipt, "access_granted", options.at, {
|
|
330
|
+
status: "completed",
|
|
331
|
+
accessProofHash: options.accessProofHash,
|
|
332
|
+
...(options.expiresAt ? { expiresAt: options.expiresAt } : {}),
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
export function failDataLicenseReceipt(receipt, options) {
|
|
336
|
+
requireReceiptStatus(receipt, ["attempted", "approved", "sponsored", "submitted"], "fail");
|
|
337
|
+
return withDataLicenseReceiptEvent(receipt, "failed", options.at, {
|
|
338
|
+
status: "failed",
|
|
339
|
+
failureReason: options.reason,
|
|
340
|
+
}, options.reason);
|
|
341
|
+
}
|
|
342
|
+
export function completeServiceBountyReceipt(receipt, options) {
|
|
343
|
+
requireReceiptStatus(receipt, ["submitted"], "complete");
|
|
344
|
+
requireNonEmpty(options.completionProofHash, "completionProofHash");
|
|
345
|
+
return withServiceBountyReceiptEvent(receipt, "completed", options.at, {
|
|
346
|
+
status: "completed",
|
|
347
|
+
completionProofHash: options.completionProofHash,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
export function releaseServiceBountyReceipt(receipt, options) {
|
|
351
|
+
requireReceiptStatus(receipt, ["completed"], "release");
|
|
352
|
+
requireNonEmpty(options.releaseProofHash, "releaseProofHash");
|
|
353
|
+
return withServiceBountyReceiptEvent(receipt, "released", options.at, {
|
|
354
|
+
status: "released",
|
|
355
|
+
releaseProofHash: options.releaseProofHash,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
export function failServiceBountyReceipt(receipt, options) {
|
|
359
|
+
requireReceiptStatus(receipt, ["attempted", "approved", "sponsored", "submitted", "completed"], "fail");
|
|
360
|
+
return withServiceBountyReceiptEvent(receipt, "failed", options.at, {
|
|
361
|
+
status: "failed",
|
|
362
|
+
failureReason: options.reason,
|
|
363
|
+
}, options.reason);
|
|
364
|
+
}
|
|
365
|
+
export function completeReputationReceipt(receipt, options) {
|
|
366
|
+
requireReceiptStatus(receipt, ["submitted"], "complete");
|
|
367
|
+
requireScore(options.score);
|
|
368
|
+
requireNonEmpty(options.evidenceHash, "evidenceHash");
|
|
369
|
+
requireNonEmpty(options.attestationHash, "attestationHash");
|
|
370
|
+
return withReputationReceiptEvent(receipt, "completed", options.at, {
|
|
371
|
+
status: "completed",
|
|
372
|
+
score: options.score,
|
|
373
|
+
evidenceHash: options.evidenceHash,
|
|
374
|
+
attestationHash: options.attestationHash,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
export function failReputationReceipt(receipt, options) {
|
|
378
|
+
requireReceiptStatus(receipt, ["attempted", "approved", "sponsored", "submitted"], "fail");
|
|
379
|
+
return withReputationReceiptEvent(receipt, "failed", options.at, {
|
|
380
|
+
status: "failed",
|
|
381
|
+
failureReason: options.reason,
|
|
382
|
+
}, options.reason);
|
|
383
|
+
}
|
|
384
|
+
export function activateSubscriptionReceipt(receipt, options) {
|
|
385
|
+
requireReceiptStatus(receipt, ["submitted"], "activate");
|
|
386
|
+
requireSafeHashReference(options.activationProofHash, "activationProofHash");
|
|
387
|
+
return withSubscriptionReceiptEvent(receipt, "activated", options.at, {
|
|
388
|
+
status: "active",
|
|
389
|
+
activationProofHash: options.activationProofHash,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
export function renewSubscriptionReceipt(receipt, options) {
|
|
393
|
+
requireReceiptStatus(receipt, ["active", "renewed"], "renew");
|
|
394
|
+
requireNonEmpty(options.periodEnd, "periodEnd");
|
|
395
|
+
requireSafeHashReference(options.renewalProofHash, "renewalProofHash");
|
|
396
|
+
if (options.sponsorshipId !== undefined)
|
|
397
|
+
requireNonEmpty(options.sponsorshipId, "sponsorshipId");
|
|
398
|
+
if (options.transactionDigest !== undefined)
|
|
399
|
+
requireNonEmpty(options.transactionDigest, "transactionDigest");
|
|
400
|
+
requirePeriodAfter(receipt.periodEnd, options.periodEnd, "periodEnd");
|
|
401
|
+
return withSubscriptionReceiptEvent(receipt, "renewed", options.at, {
|
|
402
|
+
status: "renewed",
|
|
403
|
+
periodEnd: options.periodEnd,
|
|
404
|
+
renewalCount: receipt.renewalCount + 1,
|
|
405
|
+
renewalProofHash: options.renewalProofHash,
|
|
406
|
+
...(options.sponsorshipId ? { renewalSponsorshipId: options.sponsorshipId } : {}),
|
|
407
|
+
...(options.transactionDigest ? { renewalTransactionDigest: options.transactionDigest } : {}),
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
export function cancelSubscriptionReceipt(receipt, options) {
|
|
411
|
+
requireReceiptStatus(receipt, ["active", "renewed"], "cancel");
|
|
412
|
+
requireNonEmpty(options.reason, "reason");
|
|
413
|
+
return withSubscriptionReceiptEvent(receipt, "canceled", options.at, {
|
|
414
|
+
status: "canceled",
|
|
415
|
+
cancellationReason: options.reason,
|
|
416
|
+
}, options.reason);
|
|
417
|
+
}
|
|
418
|
+
export function failSubscriptionReceipt(receipt, options) {
|
|
419
|
+
requireReceiptStatus(receipt, ["attempted", "approved", "sponsored", "submitted", "active", "renewed"], "fail");
|
|
420
|
+
return withSubscriptionReceiptEvent(receipt, "failed", options.at, {
|
|
421
|
+
status: "failed",
|
|
422
|
+
failureReason: options.reason,
|
|
423
|
+
}, options.reason);
|
|
424
|
+
}
|
|
425
|
+
export function revokeDataLicenseAccess(receipt, options) {
|
|
426
|
+
requireReceiptStatus(receipt, ["completed"], "revoke access");
|
|
427
|
+
return withDataLicenseReceiptEvent(receipt, "access_revoked", options.at, {
|
|
428
|
+
status: "revoked",
|
|
429
|
+
revocationReason: options.reason,
|
|
430
|
+
}, options.reason);
|
|
431
|
+
}
|
|
432
|
+
export function releaseEscrow(receipt, options) {
|
|
433
|
+
requireVerifier(receipt, options.verifierId);
|
|
434
|
+
requireReceiptStatus(receipt, ["completed"], "release");
|
|
435
|
+
requireEscrowOpen(receipt, "release");
|
|
436
|
+
return withReceiptEvent(receipt, "released", options.at, {
|
|
437
|
+
status: "released",
|
|
438
|
+
escrow: { ...receipt.escrow, status: "released" },
|
|
439
|
+
releaseProofHash: options.releaseProofHash,
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
export function refundEscrow(receipt, options) {
|
|
443
|
+
requireReceiptStatus(receipt, ["attempted", "approved", "sponsored", "submitted", "completed"], "refund");
|
|
444
|
+
requireEscrowOpen(receipt, "refund");
|
|
445
|
+
return withReceiptEvent(receipt, "refunded", options.at, {
|
|
446
|
+
status: "refunded",
|
|
447
|
+
escrow: { ...receipt.escrow, status: "refunded" },
|
|
448
|
+
refundReason: options.reason,
|
|
449
|
+
}, options.reason);
|
|
450
|
+
}
|
|
451
|
+
export function expireEscrow(receipt, options) {
|
|
452
|
+
requireReceiptStatus(receipt, ["attempted", "approved", "sponsored", "submitted", "completed"], "expire");
|
|
453
|
+
requireEscrowOpen(receipt, "expire");
|
|
454
|
+
return withReceiptEvent(receipt, "expired", options.at, {
|
|
455
|
+
status: "refunded",
|
|
456
|
+
escrow: { ...receipt.escrow, status: "expired" },
|
|
457
|
+
refundReason: options.reason,
|
|
458
|
+
}, options.reason);
|
|
459
|
+
}
|
|
460
|
+
export function linkExternalPaymentState(receipt, state) {
|
|
461
|
+
return {
|
|
462
|
+
...receipt,
|
|
463
|
+
externalPayment: state,
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
export function linkIotaReceiptState(receipt, state) {
|
|
467
|
+
return {
|
|
468
|
+
...receipt,
|
|
469
|
+
iotaReceipt: state,
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
export * from "./x402Receipt.js";
|
|
473
|
+
function requireVerifier(receipt, verifierId) {
|
|
474
|
+
if (receipt.escrow.verifierId !== verifierId) {
|
|
475
|
+
throw new ReceiptTransitionError("UNAUTHORIZED_VERIFIER", "Only the configured verifier can release escrow.");
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
function requireEscrowOpen(receipt, action) {
|
|
479
|
+
if (receipt.escrow.status !== "open") {
|
|
480
|
+
throw new ReceiptTransitionError("INVALID_TRANSITION", `Cannot ${action} escrow from ${receipt.escrow.status}.`);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
function requireReceiptStatus(receipt, allowed, action) {
|
|
484
|
+
if (!allowed.includes(receipt.status)) {
|
|
485
|
+
throw new ReceiptTransitionError("INVALID_TRANSITION", `Cannot ${action} receipt from ${receipt.status}.`);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function requireNonEmpty(value, field) {
|
|
489
|
+
if (value.trim() === "") {
|
|
490
|
+
throw new ReceiptInputError("FIELD_REQUIRED", `${field} is required.`);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
function requireSafeHashReference(value, field) {
|
|
494
|
+
requireNonEmpty(value, field);
|
|
495
|
+
if (!/^sha256:[A-Za-z0-9._:-]+$/.test(value)
|
|
496
|
+
|| /(private prompt|review payload|bearer|access-token|signer_ref|payment credential|privateKey|mnemonic|seed)/i.test(value)) {
|
|
497
|
+
throw new ReceiptInputError("FIELD_REQUIRED", `${field} must be a safe sha256 reference.`);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
function requireMatchingField(left, right, leftField, rightField) {
|
|
501
|
+
if (left !== right) {
|
|
502
|
+
throw new ReceiptInputError("FIELD_REQUIRED", `${leftField} must match ${rightField}.`);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
function requirePeriodAfter(start, end, field) {
|
|
506
|
+
const startTime = Date.parse(start);
|
|
507
|
+
const endTime = Date.parse(end);
|
|
508
|
+
if (!Number.isFinite(startTime) || !Number.isFinite(endTime) || endTime <= startTime) {
|
|
509
|
+
throw new ReceiptInputError("FIELD_REQUIRED", `${field} must be after the current period end.`);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
function requireScore(score) {
|
|
513
|
+
if (!Number.isInteger(score) || score < 1 || score > 5) {
|
|
514
|
+
throw new ReceiptInputError("FIELD_REQUIRED", "score must be an integer between 1 and 5.");
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
function withReceiptEvent(receipt, eventType, at, patch, reason) {
|
|
518
|
+
const timestamp = at.toISOString();
|
|
519
|
+
return {
|
|
520
|
+
...receipt,
|
|
521
|
+
...patch,
|
|
522
|
+
updatedAt: timestamp,
|
|
523
|
+
events: [
|
|
524
|
+
...receipt.events,
|
|
525
|
+
{
|
|
526
|
+
type: eventType,
|
|
527
|
+
at: timestamp,
|
|
528
|
+
...(reason ? { reason } : {}),
|
|
529
|
+
},
|
|
530
|
+
],
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
function withPayPerCallReceiptEvent(receipt, eventType, at, patch, reason) {
|
|
534
|
+
const timestamp = at.toISOString();
|
|
535
|
+
return {
|
|
536
|
+
...receipt,
|
|
537
|
+
...patch,
|
|
538
|
+
updatedAt: timestamp,
|
|
539
|
+
events: [
|
|
540
|
+
...receipt.events,
|
|
541
|
+
{
|
|
542
|
+
type: eventType,
|
|
543
|
+
at: timestamp,
|
|
544
|
+
...(reason ? { reason } : {}),
|
|
545
|
+
},
|
|
546
|
+
],
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function withDataLicenseReceiptEvent(receipt, eventType, at, patch, reason) {
|
|
550
|
+
const timestamp = at.toISOString();
|
|
551
|
+
return {
|
|
552
|
+
...receipt,
|
|
553
|
+
...patch,
|
|
554
|
+
updatedAt: timestamp,
|
|
555
|
+
events: [
|
|
556
|
+
...receipt.events,
|
|
557
|
+
{
|
|
558
|
+
type: eventType,
|
|
559
|
+
at: timestamp,
|
|
560
|
+
...(reason ? { reason } : {}),
|
|
561
|
+
},
|
|
562
|
+
],
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
function withServiceBountyReceiptEvent(receipt, eventType, at, patch, reason) {
|
|
566
|
+
const timestamp = at.toISOString();
|
|
567
|
+
return {
|
|
568
|
+
...receipt,
|
|
569
|
+
...patch,
|
|
570
|
+
updatedAt: timestamp,
|
|
571
|
+
events: [
|
|
572
|
+
...receipt.events,
|
|
573
|
+
{
|
|
574
|
+
type: eventType,
|
|
575
|
+
at: timestamp,
|
|
576
|
+
...(reason ? { reason } : {}),
|
|
577
|
+
},
|
|
578
|
+
],
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
function withReputationReceiptEvent(receipt, eventType, at, patch, reason) {
|
|
582
|
+
const timestamp = at.toISOString();
|
|
583
|
+
return {
|
|
584
|
+
...receipt,
|
|
585
|
+
...patch,
|
|
586
|
+
updatedAt: timestamp,
|
|
587
|
+
events: [
|
|
588
|
+
...receipt.events,
|
|
589
|
+
{
|
|
590
|
+
type: eventType,
|
|
591
|
+
at: timestamp,
|
|
592
|
+
...(reason ? { reason } : {}),
|
|
593
|
+
},
|
|
594
|
+
],
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
function withSubscriptionReceiptEvent(receipt, eventType, at, patch, reason) {
|
|
598
|
+
const timestamp = at.toISOString();
|
|
599
|
+
return {
|
|
600
|
+
...receipt,
|
|
601
|
+
...patch,
|
|
602
|
+
updatedAt: timestamp,
|
|
603
|
+
events: [
|
|
604
|
+
...receipt.events,
|
|
605
|
+
{
|
|
606
|
+
type: eventType,
|
|
607
|
+
at: timestamp,
|
|
608
|
+
...(reason ? { reason } : {}),
|
|
609
|
+
},
|
|
610
|
+
],
|
|
611
|
+
};
|
|
612
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { LinkedReceiptState } from "./index.js";
|
|
2
|
+
export interface X402VerifyEvidence {
|
|
3
|
+
readonly isValid: boolean;
|
|
4
|
+
readonly invalidReason?: string;
|
|
5
|
+
readonly invalidMessage?: string;
|
|
6
|
+
readonly payer?: string;
|
|
7
|
+
readonly extensions?: Record<string, unknown>;
|
|
8
|
+
readonly extra?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export interface X402SettleEvidence {
|
|
11
|
+
readonly success: boolean;
|
|
12
|
+
readonly errorReason?: string;
|
|
13
|
+
readonly errorMessage?: string;
|
|
14
|
+
readonly payer?: string;
|
|
15
|
+
readonly transaction: string;
|
|
16
|
+
readonly network: string;
|
|
17
|
+
readonly amount?: string;
|
|
18
|
+
readonly extensions?: Record<string, unknown>;
|
|
19
|
+
readonly extra?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateX402ExternalPaymentReceiptStateInput {
|
|
22
|
+
readonly paymentId: string;
|
|
23
|
+
readonly verify: X402VerifyEvidence;
|
|
24
|
+
readonly settle?: X402SettleEvidence;
|
|
25
|
+
}
|
|
26
|
+
export interface X402ExternalPaymentReceiptState {
|
|
27
|
+
readonly linkedState: LinkedReceiptState;
|
|
28
|
+
readonly metadata: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
export declare function createX402ExternalPaymentReceiptState(input: CreateX402ExternalPaymentReceiptStateInput): X402ExternalPaymentReceiptState;
|
|
31
|
+
export declare function redactX402PaymentMetadata(value: unknown): unknown;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export function createX402ExternalPaymentReceiptState(input) {
|
|
2
|
+
const settlementStatus = settlementStatusFor(input.verify, input.settle);
|
|
3
|
+
const metadata = {
|
|
4
|
+
x402PaymentId: input.paymentId,
|
|
5
|
+
x402VerifyStatus: input.verify.isValid ? "valid" : "invalid",
|
|
6
|
+
x402SettlementStatus: settlementStatus,
|
|
7
|
+
};
|
|
8
|
+
if (input.verify.invalidReason)
|
|
9
|
+
metadata.x402VerifyInvalidReason = input.verify.invalidReason;
|
|
10
|
+
if (input.settle?.errorReason)
|
|
11
|
+
metadata.x402SettleErrorReason = input.settle.errorReason;
|
|
12
|
+
if (input.settle?.network)
|
|
13
|
+
metadata.x402Network = input.settle.network;
|
|
14
|
+
if (input.settle?.transaction)
|
|
15
|
+
metadata.x402Transaction = input.settle.transaction;
|
|
16
|
+
if (input.settle?.amount)
|
|
17
|
+
metadata.x402Amount = input.settle.amount;
|
|
18
|
+
return {
|
|
19
|
+
linkedState: {
|
|
20
|
+
status: settlementStatus === "succeeded" ? "succeeded" : settlementStatus === "failed" ? "failed" : "pending",
|
|
21
|
+
referenceId: `x402:${input.paymentId}`,
|
|
22
|
+
},
|
|
23
|
+
metadata,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function redactX402PaymentMetadata(value) {
|
|
27
|
+
if (Array.isArray(value))
|
|
28
|
+
return value.map((item) => redactX402PaymentMetadata(item));
|
|
29
|
+
if (!isRecord(value))
|
|
30
|
+
return value;
|
|
31
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [
|
|
32
|
+
key,
|
|
33
|
+
isSensitiveX402MetadataKey(key) ? "[REDACTED]" : redactX402PaymentMetadata(child),
|
|
34
|
+
]));
|
|
35
|
+
}
|
|
36
|
+
function settlementStatusFor(verify, settle) {
|
|
37
|
+
if (!verify.isValid)
|
|
38
|
+
return "failed";
|
|
39
|
+
if (!settle)
|
|
40
|
+
return "pending";
|
|
41
|
+
return settle.success ? "succeeded" : "failed";
|
|
42
|
+
}
|
|
43
|
+
function isSensitiveX402MetadataKey(key) {
|
|
44
|
+
return /^(payer.*|paymentPayload|payload|paymentCredential|.*signature.*|.*authorization.*|.*credential.*)$/i.test(key);
|
|
45
|
+
}
|
|
46
|
+
function isRecord(value) {
|
|
47
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
48
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vallum/receipts",
|
|
3
|
+
"version": "0.0.0-prerelease",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"description": "Receipt and escrow state machine for Vallum.",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/**/*.js",
|
|
17
|
+
"dist/**/*.d.ts",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.build.json"
|
|
24
|
+
},
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public",
|
|
30
|
+
"tag": "next"
|
|
31
|
+
}
|
|
32
|
+
}
|