@avow-finance/spec 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +119 -2
  3. package/dist/agent-connect.d.ts +82 -0
  4. package/dist/agent-connect.d.ts.map +1 -0
  5. package/dist/agent-connect.js +91 -0
  6. package/dist/agent-connect.js.map +1 -0
  7. package/dist/agent-session.d.ts +791 -0
  8. package/dist/agent-session.d.ts.map +1 -0
  9. package/dist/agent-session.js +176 -0
  10. package/dist/agent-session.js.map +1 -0
  11. package/dist/ap2.d.ts +79 -0
  12. package/dist/ap2.d.ts.map +1 -0
  13. package/dist/ap2.js +151 -0
  14. package/dist/ap2.js.map +1 -0
  15. package/dist/api-request.d.ts +144 -0
  16. package/dist/api-request.d.ts.map +1 -0
  17. package/dist/api-request.js +246 -0
  18. package/dist/api-request.js.map +1 -0
  19. package/dist/api.d.ts +288 -0
  20. package/dist/api.d.ts.map +1 -0
  21. package/dist/api.js +332 -0
  22. package/dist/api.js.map +1 -0
  23. package/dist/canonical.d.ts +22 -0
  24. package/dist/canonical.d.ts.map +1 -0
  25. package/dist/canonical.js +66 -0
  26. package/dist/canonical.js.map +1 -0
  27. package/dist/commitment-card.d.ts +78 -0
  28. package/dist/commitment-card.d.ts.map +1 -0
  29. package/dist/commitment-card.js +224 -0
  30. package/dist/commitment-card.js.map +1 -0
  31. package/dist/commitment.d.ts +185 -0
  32. package/dist/commitment.d.ts.map +1 -0
  33. package/dist/commitment.js +148 -0
  34. package/dist/commitment.js.map +1 -0
  35. package/dist/compute-offers.d.ts +128 -0
  36. package/dist/compute-offers.d.ts.map +1 -0
  37. package/dist/compute-offers.js +111 -0
  38. package/dist/compute-offers.js.map +1 -0
  39. package/dist/contest.d.ts +88 -0
  40. package/dist/contest.d.ts.map +1 -0
  41. package/dist/contest.js +131 -0
  42. package/dist/contest.js.map +1 -0
  43. package/dist/demo.d.ts +69 -0
  44. package/dist/demo.d.ts.map +1 -0
  45. package/dist/demo.js +152 -0
  46. package/dist/demo.js.map +1 -0
  47. package/dist/dependencies.d.ts +308 -0
  48. package/dist/dependencies.d.ts.map +1 -0
  49. package/dist/dependencies.js +133 -0
  50. package/dist/dependencies.js.map +1 -0
  51. package/dist/eip712.d.ts +1569 -0
  52. package/dist/eip712.d.ts.map +1 -0
  53. package/dist/eip712.js +550 -0
  54. package/dist/eip712.js.map +1 -0
  55. package/dist/elided-terms.d.ts +37 -0
  56. package/dist/elided-terms.d.ts.map +1 -0
  57. package/dist/elided-terms.js +48 -0
  58. package/dist/elided-terms.js.map +1 -0
  59. package/dist/erc8183.d.ts +78 -0
  60. package/dist/erc8183.d.ts.map +1 -0
  61. package/dist/erc8183.js +88 -0
  62. package/dist/erc8183.js.map +1 -0
  63. package/dist/facts.d.ts +70 -0
  64. package/dist/facts.d.ts.map +1 -0
  65. package/dist/facts.js +33 -0
  66. package/dist/facts.js.map +1 -0
  67. package/dist/gpu-reservation.d.ts +79 -0
  68. package/dist/gpu-reservation.d.ts.map +1 -0
  69. package/dist/gpu-reservation.js +135 -0
  70. package/dist/gpu-reservation.js.map +1 -0
  71. package/dist/index.d.ts +49 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +49 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/job-session.d.ts +981 -0
  76. package/dist/job-session.d.ts.map +1 -0
  77. package/dist/job-session.js +170 -0
  78. package/dist/job-session.js.map +1 -0
  79. package/dist/job-verification.d.ts +244 -0
  80. package/dist/job-verification.d.ts.map +1 -0
  81. package/dist/job-verification.js +89 -0
  82. package/dist/job-verification.js.map +1 -0
  83. package/dist/job-wording.d.ts +48 -0
  84. package/dist/job-wording.d.ts.map +1 -0
  85. package/dist/job-wording.js +134 -0
  86. package/dist/job-wording.js.map +1 -0
  87. package/dist/job.d.ts +117 -0
  88. package/dist/job.d.ts.map +1 -0
  89. package/dist/job.js +166 -0
  90. package/dist/job.js.map +1 -0
  91. package/dist/json-fields.d.ts +13 -0
  92. package/dist/json-fields.d.ts.map +1 -0
  93. package/dist/json-fields.js +30 -0
  94. package/dist/json-fields.js.map +1 -0
  95. package/dist/keychain.d.ts +51 -0
  96. package/dist/keychain.d.ts.map +1 -0
  97. package/dist/keychain.js +133 -0
  98. package/dist/keychain.js.map +1 -0
  99. package/dist/mailbox.d.ts +1650 -0
  100. package/dist/mailbox.d.ts.map +1 -0
  101. package/dist/mailbox.js +87 -0
  102. package/dist/mailbox.js.map +1 -0
  103. package/dist/mandate.d.ts +53 -0
  104. package/dist/mandate.d.ts.map +1 -0
  105. package/dist/mandate.js +97 -0
  106. package/dist/mandate.js.map +1 -0
  107. package/dist/networks.d.ts +18 -0
  108. package/dist/networks.d.ts.map +1 -0
  109. package/dist/networks.js +24 -0
  110. package/dist/networks.js.map +1 -0
  111. package/dist/profiles.d.ts +31 -0
  112. package/dist/profiles.d.ts.map +1 -0
  113. package/dist/profiles.js +33 -0
  114. package/dist/profiles.js.map +1 -0
  115. package/dist/rail.d.ts +48 -0
  116. package/dist/rail.d.ts.map +1 -0
  117. package/dist/rail.js +28 -0
  118. package/dist/rail.js.map +1 -0
  119. package/dist/reasons.d.ts +173 -0
  120. package/dist/reasons.d.ts.map +1 -0
  121. package/dist/reasons.js +174 -0
  122. package/dist/reasons.js.map +1 -0
  123. package/dist/reference-link.d.ts +23 -0
  124. package/dist/reference-link.d.ts.map +1 -0
  125. package/dist/reference-link.js +56 -0
  126. package/dist/reference-link.js.map +1 -0
  127. package/dist/references.d.ts +125 -0
  128. package/dist/references.d.ts.map +1 -0
  129. package/dist/references.js +108 -0
  130. package/dist/references.js.map +1 -0
  131. package/dist/replay.d.ts +30 -0
  132. package/dist/replay.d.ts.map +1 -0
  133. package/dist/replay.js +27 -0
  134. package/dist/replay.js.map +1 -0
  135. package/dist/sandbox-registration.d.ts +200 -0
  136. package/dist/sandbox-registration.d.ts.map +1 -0
  137. package/dist/sandbox-registration.js +172 -0
  138. package/dist/sandbox-registration.js.map +1 -0
  139. package/dist/sandbox.d.ts +3478 -0
  140. package/dist/sandbox.d.ts.map +1 -0
  141. package/dist/sandbox.js +316 -0
  142. package/dist/sandbox.js.map +1 -0
  143. package/dist/session-fields.d.ts +203 -0
  144. package/dist/session-fields.d.ts.map +1 -0
  145. package/dist/session-fields.js +43 -0
  146. package/dist/session-fields.js.map +1 -0
  147. package/dist/supplier-adapter.d.ts +65 -0
  148. package/dist/supplier-adapter.d.ts.map +1 -0
  149. package/dist/supplier-adapter.js +91 -0
  150. package/dist/supplier-adapter.js.map +1 -0
  151. package/dist/terms-v1.d.ts +74 -0
  152. package/dist/terms-v1.d.ts.map +1 -0
  153. package/dist/terms-v1.js +156 -0
  154. package/dist/terms-v1.js.map +1 -0
  155. package/dist/terms.d.ts +341 -0
  156. package/dist/terms.d.ts.map +1 -0
  157. package/dist/terms.js +715 -0
  158. package/dist/terms.js.map +1 -0
  159. package/dist/test-customer.d.ts +1525 -0
  160. package/dist/test-customer.d.ts.map +1 -0
  161. package/dist/test-customer.js +260 -0
  162. package/dist/test-customer.js.map +1 -0
  163. package/dist/types.d.ts +272 -0
  164. package/dist/types.d.ts.map +1 -0
  165. package/dist/types.js +32 -0
  166. package/dist/types.js.map +1 -0
  167. package/dist/version.d.ts +51 -0
  168. package/dist/version.d.ts.map +1 -0
  169. package/dist/version.js +66 -0
  170. package/dist/version.js.map +1 -0
  171. package/dist/wire.d.ts +2698 -0
  172. package/dist/wire.d.ts.map +1 -0
  173. package/dist/wire.js +678 -0
  174. package/dist/wire.js.map +1 -0
  175. package/package.json +37 -3
  176. package/vectors/api-request-v1.json +53 -0
  177. package/vectors/contest-statement-v1.json +42 -0
  178. package/vectors/terms-v2.json +398 -0
  179. package/vectors/terms-v3.json +2103 -0
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Reason codes for every decision Avow makes and every refusal a verifier returns. Each code is
3
+ * a stable string a machine can act on, with a sentence for a person.
4
+ */
5
+ export declare const REASON_CODES: {
6
+ readonly approved: 'Every check passed';
7
+ readonly 'business.unverified': 'The business has no current KYB attestation';
8
+ readonly 'business.test_data': 'The KYB attestation is test data, which only testnet accepts';
9
+ readonly 'administrator.no_authority': "The administrator's authority to bind the business isn't recorded";
10
+ readonly 'agent.revoked': "The agent's key is revoked";
11
+ readonly 'agent.key_mismatch': "The request didn't come from the mandate's agent key";
12
+ readonly 'mandate.invalid': 'The mandate names neither suppliers nor categories, or its caps conflict';
13
+ readonly 'mandate.ap2_mismatch': 'An AP2 intent mandate says something the Avow mandate it travels with does not';
14
+ readonly 'mandate.signature_invalid': "The mandate's signature doesn't match the business's administrator, so it was changed or forged";
15
+ readonly 'mandate.missing': "The supported acceptance path needs the buyer's signed mandate, and none was given";
16
+ readonly 'mandate.expired': 'The mandate has expired';
17
+ readonly 'mandate.revoked': 'The mandate is revoked';
18
+ readonly 'mandate.action_not_permitted': "The mandate doesn't permit this action";
19
+ readonly 'mandate.supplier_not_allowed': "The supplier isn't on the mandate's list";
20
+ readonly 'mandate.category_not_allowed': "The category isn't on the mandate's list";
21
+ readonly 'terms.category_mismatch': "These terms' template has a mandate category of its own, and the request names another";
22
+ readonly 'mandate.currency_not_allowed': "The terms' currency isn't the mandate's";
23
+ readonly 'mandate.token_not_allowed': "The lock's token isn't one the mandate allows";
24
+ readonly 'mandate.over_payment_limit': "The amount is above the mandate's payment limit for the token";
25
+ readonly 'mandate.over_commitment_cap': 'The amount is above the cap per commitment';
26
+ readonly 'mandate.over_open_reserves_cap': "The amount would take open reserves above the mandate's cap";
27
+ readonly 'mandate.ends_before_window': 'The mandate expires before the booking window ends';
28
+ readonly 'approval.human_required': 'The mandate asks the administrator to approve this reserve';
29
+ readonly 'approval.human_invalid': "The administrator's approval is forged, expired, used already, or names another amount or supplier";
30
+ readonly 'terms.invalid': "The terms don't parse, or hold a field the terms hash doesn't cover";
31
+ readonly 'terms.reserve_mismatch': "The reserve doesn't equal the largest charge in the terms";
32
+ readonly 'terms.deadlines_out_of_order': "The terms' deadlines are out of order";
33
+ readonly 'terms.contest_window_short': 'The contest window is shorter than this profile allows';
34
+ readonly 'terms.hash_mismatch': "The terms and salt don't produce the signed terms hash";
35
+ readonly 'terms.currency_mismatch': "The terms' currency isn't the one the lock's token stands for";
36
+ readonly 'terms.incomplete': 'The terms leave out a field or section this check needs, such as the arbiter and the day-90 share';
37
+ readonly 'terms.dispute_invalid': "The terms' arbiter is missing or zero, or the day-90 share is outside 0 to 10,000 basis points";
38
+ readonly 'terms.version_unknown': "The terms' version isn't one this code reads";
39
+ readonly 'terms.template_unknown': "The terms name a template this code doesn't know, so it can't read their subject";
40
+ readonly 'terms.template_invalid': 'The terms break a rule of their template';
41
+ readonly 'terms.backing_unsupported': "The terms' backing is a kind or side a lock can't enforce, and this release takes only the buyer's reserve";
42
+ readonly 'terms.charges_invalid': "The terms' charges repeat a kind, come out of order, have no amount or name a kind a lock can't hold";
43
+ readonly 'message.schema_unknown': "The message's schema version or type isn't one this code reads";
44
+ readonly 'message.invalid': "The message doesn't parse as its schema version, or its fields don't fit together";
45
+ readonly 'message.validity_too_long': 'The message stays valid longer than this reader allows';
46
+ readonly 'message.wrong_chain': 'The message was signed for another chain';
47
+ readonly 'message.wrong_contract': 'The message was signed for another lock';
48
+ readonly 'message.expired': 'The message has expired';
49
+ readonly 'message.replayed': 'The message has been used before';
50
+ readonly 'message.signature_invalid': "The signature doesn't match the message";
51
+ readonly 'message.signer_unknown': "The signature doesn't come from one of Avow's published keys, so the message was changed or signed by someone else";
52
+ readonly 'request.unsigned': "The request to Avow's API carries no signature, or its Authorization header doesn't parse";
53
+ readonly 'request.invalid': "The request's audience, method, path or body isn't in the form a signed request takes";
54
+ readonly 'request.signer_unknown': "The key that signed the request isn't one Avow knows for this business, supplier or commitment";
55
+ readonly 'request.id_reused': 'The request id was used before for a request with other content, so nothing was done';
56
+ readonly 'request.in_progress': 'Avow is still answering the same signed request, so send the same bytes again shortly';
57
+ readonly 'service.unavailable': "Avow couldn't read the records or the chain this request depends on, so it did nothing, and the same request can be sent again";
58
+ readonly 'sponsorship.refused': "Avow's relay pays only for a reserve the agent's own key signs for its business account, which approves the reserve token to the business's lock and reserves on it";
59
+ readonly 'sponsorship.over_cap': "The transaction asks for more gas, or could cost more in fees, than Avow's relay pays for a transaction of its kind";
60
+ readonly 'sponsorship.rate_limited': "The signing key has asked Avow's relay to pay more times in the last minute than the relay allows";
61
+ readonly 'sponsorship.simulation_failed': "The transaction fails when it runs on the latest block, so Avow's relay won't pay for it";
62
+ readonly 'sponsorship.altered': "Avow's relay handed back another transaction than the one the key signed, so nothing was sent";
63
+ readonly 'sponsorship.budget_spent': "Paying for the transaction would take one of Avow's relay budgets past the gas it allows in 24 hours";
64
+ readonly 'business.unknown': 'Avow has no record of this business';
65
+ readonly 'supplier.unknown': 'Avow has no profile for this supplier';
66
+ readonly 'order.supplier_mismatch': "The order was offered to another supplier, so only that supplier's signing key can quote it or report its delivery";
67
+ readonly 'order.limit_reached': 'The supplier already holds as many open orders as the test customer allows, or the customer has reached its own total or daily limit';
68
+ readonly 'order.unknown': 'The test customer has no order with that id';
69
+ readonly 'order.out_of_step': "The order isn't at the step this request is for, such as a second quote or a delivery before acceptance";
70
+ readonly 'order.terms_changed': "The quote's terms differ from the offer's beyond the compute bookings they add";
71
+ readonly 'order.commitment_mismatch': "The quote's terms agreement names another commitment id than the one the order's offer names";
72
+ readonly 'agreement.parties_mismatch': "The terms agreement names another buyer, mandate or supplier than the agent's business, its mandate and the supplier it deals with";
73
+ readonly 'commitment.unknown': 'Avow has no record of this commitment';
74
+ readonly 'commitment.cancel_on_lock': "Free cancellation hasn't ended, so the business cancels on the lock and gets the whole reserve back";
75
+ readonly 'commitment.cancel_closed': 'The no-show charge can already be reported, so a cancellation no longer changes the charge';
76
+ readonly 'commitment.ended': "The commitment's charge deadline has passed, so it can no longer be cancelled, started or reported on";
77
+ readonly 'authorization.payee_mismatch': "The payee isn't the supplier's own payout address";
78
+ readonly 'authorization.terms_mismatch': "The authorization's amount or deadlines differ from the terms";
79
+ readonly 'authorization.commitment_mismatch': 'The authorization is for another commitment than the one the supplier agreed to';
80
+ readonly 'authorization.mandate_mismatch': "The mandate given isn't the one the authorization or the supplier's agreement names, or names another business, account or agent key";
81
+ readonly 'authorization.buyer_mismatch': 'The authorization names another buyer than the one the supplier agreed with';
82
+ readonly 'authorization.accept_by_passed': 'The acceptance deadline has passed, so the reserve can no longer be accepted';
83
+ readonly 'authorization.token_not_accepted': "The reserve's token isn't one the supplier accepts for the terms' currency";
84
+ readonly 'approval.commitment_mismatch': "Avow's approval is for another commitment than the one the supplier agreed to";
85
+ readonly 'approval.parties_mismatch': "Avow's approval names another supplier account, signing key or payout address than the supplier's own";
86
+ readonly 'approval.terms_mismatch': "Avow's approval differs from the supplier's terms in its side, token, amount, deadlines, contest window or terms hash";
87
+ readonly 'approval.charges_mismatch': "Avow's approval carries other charges than the supplier's terms set";
88
+ readonly 'approval.dispute_mismatch': "Avow's approval names another arbiter or day-90 share than the supplier's terms";
89
+ readonly 'approval.mandate_mismatch': "Avow's approval names another mandate, other caps or another funding key than the buyer's mandate and Avow's authorization";
90
+ readonly 'consent.not_releasable': "The commitment isn't in a state a supplier's consent can release, or it has a ruling";
91
+ readonly 'consent.count_passed': 'The commitment already has more reports than the consent names, so the lock would never take it';
92
+ readonly 'consent.count_out_of_range': 'The consent names a report count no commitment can reach';
93
+ readonly 'report.not_reportable': 'The lock holds the commitment as something other than accepted, and only an accepted commitment takes a report';
94
+ readonly 'report.open': 'A report on the commitment is still open, and the lock takes one report at a time';
95
+ readonly 'report.limit_reached': 'The commitment already has two reports, the most a lock takes';
96
+ readonly 'report.kind_not_allowed': "The commitment's terms carry no charge of this kind";
97
+ readonly 'report.amount_invalid': 'The amount is zero or more than the terms let this kind of charge take';
98
+ readonly 'report.too_early': "The terms don't let this kind of charge be reported yet";
99
+ readonly 'contest.not_contestable': 'The lock holds no pending charge and no standing report on the commitment for a contest to pause, or the commitment has ended';
100
+ readonly 'contest.already_contested': 'The business has already contested a charge on this commitment, and the contest stays on record, so a later report pauses at once';
101
+ readonly 'contest.window_closed': "The charge's contest window has closed by the chain's clock, or closes before a contest sent now could land";
102
+ readonly 'contest.reason_not_for_charge': "The reason doesn't answer the kind of charge the supplier reported, and wrong_charge and other answer any kind";
103
+ readonly 'contest.statement_invalid': "The statement's text is blank, holds a control character, a Unicode noncharacter or broken Unicode, or is longer than a statement may be";
104
+ readonly 'contest.not_on_chain': "The transaction named holds no contest of this commitment from the business's lock, failed, or isn't on the chain yet";
105
+ readonly 'contest.statement_mismatch': "The statement's reason or hash differs from what the lock recorded for the contest";
106
+ readonly 'chain.reserve_missing': 'No reserve for this commitment is on-chain';
107
+ readonly 'keychain.over_daily_limit': "The agent's key would move more than its daily limit, which the business account's keychain holds";
108
+ readonly 'chain.reserve_mismatch': 'The on-chain reserve differs from the authorization, or the lock enforces other values than the terms map to';
109
+ readonly 'chain.reserve_accepted': 'The reserve has already been accepted';
110
+ readonly 'chain.acceptance_reverted': 'The lock reverted the acceptance, so the reserve stays unaccepted';
111
+ readonly 'chain.lock_unknown': "The lock isn't running the code Avow's factory deploys";
112
+ readonly 'chain.agent_key_inactive': "The agent's key isn't on the chain, is revoked, or expires before the commitment's release date";
113
+ readonly 'chain.mandate_mismatch': "The agent key's authorization on-chain carries a different mandate";
114
+ readonly 'chain.approval_mismatch': 'The lock holds this reserve under another approval than the one given, or stores other terms than it names';
115
+ readonly 'chain.lock_timing_unexpected': "The lock's dispute timing or token isn't what the supplier's profile accepts";
116
+ readonly 'chain.supplier_mismatch': "The commitment on the lock names another supplier account or signing key than this supplier's";
117
+ readonly 'reference.commitment_mismatch': "The lock holds no commitment for this reference, holds it under another terms hash, or the reference names a side the terms' backing doesn't secure";
118
+ readonly 'reference.unreadable': "A read of the commitment the reference names failed, timed out or couldn't be pinned to one block, so nothing was decided";
119
+ readonly 'payment.not_found': 'No transfer is at that chain, transaction and log index';
120
+ readonly 'payment.failed': 'The transaction that holds the payment failed';
121
+ readonly 'payment.not_final': "The payment's block isn't finalized yet";
122
+ readonly 'payment.not_memo_transfer': "The log at that index isn't a TransferWithMemo event, and only that event counts as a payment";
123
+ readonly 'payment.token_not_accepted': "The payment's token isn't one this reader accepts payments in";
124
+ readonly 'payment.token_mismatch': "A contract other than the reference's token emitted the transfer";
125
+ readonly 'payment.sender_mismatch': 'The transfer came from another sender than the reference names';
126
+ readonly 'payment.recipient_mismatch': 'The transfer went to another recipient than the reference names';
127
+ readonly 'payment.amount_mismatch': 'The transfer moved another amount than the reference names';
128
+ readonly 'payment.memo_mismatch': "The transfer's memo differs from the reference's";
129
+ readonly 'payment.attributed_twice': "The payment's value is attributed more than once in this set, and this release lets it count once";
130
+ readonly 'dependency.lock_unknown': 'The booking relied on sits in a lock that no supported factory on a supported chain created';
131
+ readonly 'dependency.not_owned': "The lock holding the booking relied on belongs to another account than this booking's supplier";
132
+ readonly 'dependency.not_found': 'The lock holds no commitment with the id and side the dependency names';
133
+ readonly 'dependency.self_supplied': 'The booking relied on was supplied by the seller itself, so it shows no one else accepted it';
134
+ readonly 'dependency.not_accepted': "The booking relied on is reserved, and its supplier hasn't accepted it";
135
+ readonly 'dependency.charge_pending': 'The booking relied on has a report filed, a charge pending or a charge paused for a dispute';
136
+ readonly 'dependency.cancellable': "The booking relied on was still inside its free cancellation at the block read, so the seller's business could still cancel it at no charge";
137
+ readonly 'dependency.ended': 'The booking relied on has been released, charged or resolved';
138
+ readonly 'dependency.terms_mismatch': 'The lock holds the booking relied on under another terms hash than the dependency names';
139
+ readonly 'dependency.disclosure_invalid': "The section shown of the booking relied on is missing, isn't the one the dependency names, or doesn't hash to its terms hash";
140
+ readonly 'dependency.does_not_fit': 'This booking asks for more GPUs, another GPU or region, or a window outside the booking it relies on';
141
+ readonly 'dependency.unreadable': "A read of the booking relied on failed, timed out or couldn't be pinned to one block, so nothing was decided";
142
+ readonly 'dependency.stale': "The latest finalized block the node gave was older than the check's limit by the caller's clock, so nothing was decided";
143
+ readonly 'dependency.required': 'These terms name no booking they rely on, and their template commits only on a booking it relies on, such as the compute a job runs on';
144
+ readonly 'dependency.elided': 'The terms carry the dependencies section only as its digest, and this step needs its entries in clear';
145
+ readonly 'dependency.unrecorded': 'Avow holds no record of the booking relied on, so it has nothing to check the section shown against';
146
+ readonly 'service.compute_off': 'The compute switch in service.ts is off, so the tool layer books no compute and a quote names no booking';
147
+ readonly 'service.over_budget': "The offer's rate per GPU-hour is over the compute budget in service.ts, so the tool layer didn't book it";
148
+ readonly 'service.unknown_offer': 'No offer in the latest listing has that id, so nothing was booked';
149
+ readonly 'service.unknown_booking': 'No compute booking this session made has that id';
150
+ readonly 'service.quantity_unavailable': "The offer doesn't take that many GPUs in one booking, so nothing was booked";
151
+ readonly 'supplier.declined': 'The supplier declined to sign the agreement, such as for a booking over its most or past its limit of open bookings, so nothing was reserved';
152
+ readonly 'supplier.not_accepted': "The supplier didn't accept the reserve by its acceptance deadline, so it goes back to the business then";
153
+ readonly 'service.check_failed': "checkBeforeWork in service.ts threw, took too long or gave a verdict that doesn't read, so nothing was accepted and no work started";
154
+ readonly 'service.cancel_late': 'Free cancellation has ended, so the session cancels nothing and the booking stands under its terms';
155
+ readonly 'service.cancel_declined': 'The developer declined the cancellation, so the booking stands';
156
+ readonly 'chain.cancel_reverted': 'The lock reverted the cancellation, so the booking stands';
157
+ readonly 'chain.report_reverted': 'The lock reverted the report, so no charge was filed';
158
+ readonly 'service.booking_required': 'service.ts books compute for every quote while its compute switch is on, so a quote has to name a booking';
159
+ readonly 'sandbox.closed': 'Sandbox registration and its faucet are switched off for now, so nothing was registered or paid';
160
+ readonly 'sandbox.limit_reached': 'Registering would take one of the sandbox limits past what it allows, so send it again once `retryAt` has passed';
161
+ readonly 'sandbox.budget_spent': 'The faucet has sent everything its total budget allows, so it registers no more businesses until Avow raises it';
162
+ readonly 'sandbox.pool_empty': "The faucet's pool of test dollars can't pay another business yet, so nothing was registered";
163
+ readonly 'sandbox.faucet_fees_low': "The faucet's own fees are too low to send a payout, so nothing was registered. They usually refill on their own within a few minutes, so register again then";
164
+ readonly 'sandbox.taken': 'The account, lock or signing key already belongs to another business or supplier Avow records';
165
+ readonly 'sandbox.session_taken': 'Another sandbox business already posts to this session, so start a session of your own';
166
+ readonly 'sandbox.session_expired': 'This session took events for a week after its first and has ended, so start a new session';
167
+ readonly 'sandbox.session_full': 'This session holds as many events as a session can, so start a new session';
168
+ readonly 'sandbox.event_too_large': 'The event is larger than a session keeps, so nothing was posted';
169
+ readonly 'sandbox.session_rate': 'Your business is posting events faster than the sandbox allows, so send it again once `retryAt` has passed';
170
+ };
171
+ export type ReasonCode = keyof typeof REASON_CODES;
172
+ export declare function describeReason(code: ReasonCode): string;
173
+ //# sourceMappingURL=reasons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reasons.d.ts","sourceRoot":"","sources":["../src/reasons.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,YAAY;aACvB,QAAQ,EAAE,oBAAoB;aAC9B,qBAAqB,EAAE,6CAA6C;aACpE,oBAAoB,EAAE,8DAA8D;aACpF,4BAA4B,EAAE,mEAAmE;aACjG,eAAe,EAAE,4BAA4B;aAC7C,oBAAoB,EAAE,sDAAsD;aAC5E,iBAAiB,EAAE,0EAA0E;aAC7F,sBAAsB,EACpB,gFAAgF;aAClF,2BAA2B,EACzB,iGAAiG;aACnG,iBAAiB,EACf,oFAAoF;aACtF,iBAAiB,EAAE,yBAAyB;aAC5C,iBAAiB,EAAE,wBAAwB;aAC3C,8BAA8B,EAAE,wCAAwC;aACxE,8BAA8B,EAAE,0CAA0C;aAC1E,8BAA8B,EAAE,0CAA0C;aAC1E,yBAAyB,EACvB,wFAAwF;aAC1F,8BAA8B,EAAE,yCAAyC;aACzE,2BAA2B,EAAE,+CAA+C;aAC5E,4BAA4B,EAAE,+DAA+D;aAC7F,6BAA6B,EAAE,4CAA4C;aAC3E,gCAAgC,EAAE,6DAA6D;aAC/F,4BA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AAsB,EACpB,qIAAqI;aACvI,qBAAqB,EACnB,oGAAoG;aACtG,yBAAyB,EAAE,gEAAgE;aAC3F,uBAAuB,EAAE,2DAA2D;aACpF,uBAAuB,EAAE,sDAAsD;aAC/E,0BAA0B,EACxB,2GAA2G;aAC7G,gBAAgB,EACd,iGAAiG;aACnG,uBAAuB,EACrB,kHAAkH;aACpH,sBAAsB,EACpB,iHAAiH;aACnH,oBAAoB,EAClB,6FAA6F;aAC/F,yBAAyB,EACvB,8JAA8J;aAChK,eAAe,EACb,+FAA+F;aACjG,uBAAuB,EACrB,wFAAwF;aAC1F,yBAAyB,EACvB,2FAA2F;aAC7F,sBAAsB,EACpB,4EAA4E;aAC9E,yBAAyB,EAAE,iEAAiE;aAC5F,sBAAsB,EACpB,4GAA4G;CACtG,CAAA;AAEV,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,YAAY,CAAA;AAElD,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAEvD"}
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Reason codes for every decision Avow makes and every refusal a verifier returns. Each code is
3
+ * a stable string a machine can act on, with a sentence for a person.
4
+ */
5
+ export const REASON_CODES = {
6
+ approved: 'Every check passed',
7
+ 'business.unverified': 'The business has no current KYB attestation',
8
+ 'business.test_data': 'The KYB attestation is test data, which only testnet accepts',
9
+ 'administrator.no_authority': "The administrator's authority to bind the business isn't recorded",
10
+ 'agent.revoked': "The agent's key is revoked",
11
+ 'agent.key_mismatch': "The request didn't come from the mandate's agent key",
12
+ 'mandate.invalid': 'The mandate names neither suppliers nor categories, or its caps conflict',
13
+ 'mandate.ap2_mismatch': 'An AP2 intent mandate says something the Avow mandate it travels with does not',
14
+ 'mandate.signature_invalid': "The mandate's signature doesn't match the business's administrator, so it was changed or forged",
15
+ 'mandate.missing': "The supported acceptance path needs the buyer's signed mandate, and none was given",
16
+ 'mandate.expired': 'The mandate has expired',
17
+ 'mandate.revoked': 'The mandate is revoked',
18
+ 'mandate.action_not_permitted': "The mandate doesn't permit this action",
19
+ 'mandate.supplier_not_allowed': "The supplier isn't on the mandate's list",
20
+ 'mandate.category_not_allowed': "The category isn't on the mandate's list",
21
+ 'terms.category_mismatch': "These terms' template has a mandate category of its own, and the request names another",
22
+ 'mandate.currency_not_allowed': "The terms' currency isn't the mandate's",
23
+ 'mandate.token_not_allowed': "The lock's token isn't one the mandate allows",
24
+ 'mandate.over_payment_limit': "The amount is above the mandate's payment limit for the token",
25
+ 'mandate.over_commitment_cap': 'The amount is above the cap per commitment',
26
+ 'mandate.over_open_reserves_cap': "The amount would take open reserves above the mandate's cap",
27
+ 'mandate.ends_before_window': 'The mandate expires before the booking window ends',
28
+ 'approval.human_required': 'The mandate asks the administrator to approve this reserve',
29
+ 'approval.human_invalid': "The administrator's approval is forged, expired, used already, or names another amount or supplier",
30
+ 'terms.invalid': "The terms don't parse, or hold a field the terms hash doesn't cover",
31
+ 'terms.reserve_mismatch': "The reserve doesn't equal the largest charge in the terms",
32
+ 'terms.deadlines_out_of_order': "The terms' deadlines are out of order",
33
+ 'terms.contest_window_short': 'The contest window is shorter than this profile allows',
34
+ 'terms.hash_mismatch': "The terms and salt don't produce the signed terms hash",
35
+ 'terms.currency_mismatch': "The terms' currency isn't the one the lock's token stands for",
36
+ 'terms.incomplete': 'The terms leave out a field or section this check needs, such as the arbiter and the day-90 share',
37
+ 'terms.dispute_invalid': "The terms' arbiter is missing or zero, or the day-90 share is outside 0 to 10,000 basis points",
38
+ 'terms.version_unknown': "The terms' version isn't one this code reads",
39
+ 'terms.template_unknown': "The terms name a template this code doesn't know, so it can't read their subject",
40
+ 'terms.template_invalid': 'The terms break a rule of their template',
41
+ 'terms.backing_unsupported': "The terms' backing is a kind or side a lock can't enforce, and this release takes only the buyer's reserve",
42
+ 'terms.charges_invalid': "The terms' charges repeat a kind, come out of order, have no amount or name a kind a lock can't hold",
43
+ 'message.schema_unknown': "The message's schema version or type isn't one this code reads",
44
+ 'message.invalid': "The message doesn't parse as its schema version, or its fields don't fit together",
45
+ 'message.validity_too_long': 'The message stays valid longer than this reader allows',
46
+ 'message.wrong_chain': 'The message was signed for another chain',
47
+ 'message.wrong_contract': 'The message was signed for another lock',
48
+ 'message.expired': 'The message has expired',
49
+ 'message.replayed': 'The message has been used before',
50
+ 'message.signature_invalid': "The signature doesn't match the message",
51
+ 'message.signer_unknown': "The signature doesn't come from one of Avow's published keys, so the message was changed or signed by someone else",
52
+ 'request.unsigned': "The request to Avow's API carries no signature, or its Authorization header doesn't parse",
53
+ 'request.invalid': "The request's audience, method, path or body isn't in the form a signed request takes",
54
+ 'request.signer_unknown': "The key that signed the request isn't one Avow knows for this business, supplier or commitment",
55
+ 'request.id_reused': 'The request id was used before for a request with other content, so nothing was done',
56
+ 'request.in_progress': 'Avow is still answering the same signed request, so send the same bytes again shortly',
57
+ 'service.unavailable': "Avow couldn't read the records or the chain this request depends on, so it did nothing, and the same request can be sent again",
58
+ 'sponsorship.refused': "Avow's relay pays only for a reserve the agent's own key signs for its business account, which approves the reserve token to the business's lock and reserves on it",
59
+ 'sponsorship.over_cap': "The transaction asks for more gas, or could cost more in fees, than Avow's relay pays for a transaction of its kind",
60
+ 'sponsorship.rate_limited': "The signing key has asked Avow's relay to pay more times in the last minute than the relay allows",
61
+ 'sponsorship.simulation_failed': "The transaction fails when it runs on the latest block, so Avow's relay won't pay for it",
62
+ 'sponsorship.altered': "Avow's relay handed back another transaction than the one the key signed, so nothing was sent",
63
+ 'sponsorship.budget_spent': "Paying for the transaction would take one of Avow's relay budgets past the gas it allows in 24 hours",
64
+ 'business.unknown': 'Avow has no record of this business',
65
+ 'supplier.unknown': 'Avow has no profile for this supplier',
66
+ 'order.supplier_mismatch': "The order was offered to another supplier, so only that supplier's signing key can quote it or report its delivery",
67
+ 'order.limit_reached': 'The supplier already holds as many open orders as the test customer allows, or the customer has reached its own total or daily limit',
68
+ 'order.unknown': 'The test customer has no order with that id',
69
+ 'order.out_of_step': "The order isn't at the step this request is for, such as a second quote or a delivery before acceptance",
70
+ 'order.terms_changed': "The quote's terms differ from the offer's beyond the compute bookings they add",
71
+ 'order.commitment_mismatch': "The quote's terms agreement names another commitment id than the one the order's offer names",
72
+ 'agreement.parties_mismatch': "The terms agreement names another buyer, mandate or supplier than the agent's business, its mandate and the supplier it deals with",
73
+ 'commitment.unknown': 'Avow has no record of this commitment',
74
+ 'commitment.cancel_on_lock': "Free cancellation hasn't ended, so the business cancels on the lock and gets the whole reserve back",
75
+ 'commitment.cancel_closed': 'The no-show charge can already be reported, so a cancellation no longer changes the charge',
76
+ 'commitment.ended': "The commitment's charge deadline has passed, so it can no longer be cancelled, started or reported on",
77
+ 'authorization.payee_mismatch': "The payee isn't the supplier's own payout address",
78
+ 'authorization.terms_mismatch': "The authorization's amount or deadlines differ from the terms",
79
+ 'authorization.commitment_mismatch': 'The authorization is for another commitment than the one the supplier agreed to',
80
+ 'authorization.mandate_mismatch': "The mandate given isn't the one the authorization or the supplier's agreement names, or names another business, account or agent key",
81
+ 'authorization.buyer_mismatch': 'The authorization names another buyer than the one the supplier agreed with',
82
+ 'authorization.accept_by_passed': 'The acceptance deadline has passed, so the reserve can no longer be accepted',
83
+ 'authorization.token_not_accepted': "The reserve's token isn't one the supplier accepts for the terms' currency",
84
+ 'approval.commitment_mismatch': "Avow's approval is for another commitment than the one the supplier agreed to",
85
+ 'approval.parties_mismatch': "Avow's approval names another supplier account, signing key or payout address than the supplier's own",
86
+ 'approval.terms_mismatch': "Avow's approval differs from the supplier's terms in its side, token, amount, deadlines, contest window or terms hash",
87
+ 'approval.charges_mismatch': "Avow's approval carries other charges than the supplier's terms set",
88
+ 'approval.dispute_mismatch': "Avow's approval names another arbiter or day-90 share than the supplier's terms",
89
+ 'approval.mandate_mismatch': "Avow's approval names another mandate, other caps or another funding key than the buyer's mandate and Avow's authorization",
90
+ 'consent.not_releasable': "The commitment isn't in a state a supplier's consent can release, or it has a ruling",
91
+ 'consent.count_passed': 'The commitment already has more reports than the consent names, so the lock would never take it',
92
+ 'consent.count_out_of_range': 'The consent names a report count no commitment can reach',
93
+ 'report.not_reportable': 'The lock holds the commitment as something other than accepted, and only an accepted commitment takes a report',
94
+ 'report.open': 'A report on the commitment is still open, and the lock takes one report at a time',
95
+ 'report.limit_reached': 'The commitment already has two reports, the most a lock takes',
96
+ 'report.kind_not_allowed': "The commitment's terms carry no charge of this kind",
97
+ 'report.amount_invalid': 'The amount is zero or more than the terms let this kind of charge take',
98
+ 'report.too_early': "The terms don't let this kind of charge be reported yet",
99
+ 'contest.not_contestable': 'The lock holds no pending charge and no standing report on the commitment for a contest to pause, or the commitment has ended',
100
+ 'contest.already_contested': 'The business has already contested a charge on this commitment, and the contest stays on record, so a later report pauses at once',
101
+ 'contest.window_closed': "The charge's contest window has closed by the chain's clock, or closes before a contest sent now could land",
102
+ 'contest.reason_not_for_charge': "The reason doesn't answer the kind of charge the supplier reported, and wrong_charge and other answer any kind",
103
+ 'contest.statement_invalid': "The statement's text is blank, holds a control character, a Unicode noncharacter or broken Unicode, or is longer than a statement may be",
104
+ 'contest.not_on_chain': "The transaction named holds no contest of this commitment from the business's lock, failed, or isn't on the chain yet",
105
+ 'contest.statement_mismatch': "The statement's reason or hash differs from what the lock recorded for the contest",
106
+ 'chain.reserve_missing': 'No reserve for this commitment is on-chain',
107
+ 'keychain.over_daily_limit': "The agent's key would move more than its daily limit, which the business account's keychain holds",
108
+ 'chain.reserve_mismatch': 'The on-chain reserve differs from the authorization, or the lock enforces other values than the terms map to',
109
+ 'chain.reserve_accepted': 'The reserve has already been accepted',
110
+ 'chain.acceptance_reverted': 'The lock reverted the acceptance, so the reserve stays unaccepted',
111
+ 'chain.lock_unknown': "The lock isn't running the code Avow's factory deploys",
112
+ 'chain.agent_key_inactive': "The agent's key isn't on the chain, is revoked, or expires before the commitment's release date",
113
+ 'chain.mandate_mismatch': "The agent key's authorization on-chain carries a different mandate",
114
+ 'chain.approval_mismatch': 'The lock holds this reserve under another approval than the one given, or stores other terms than it names',
115
+ 'chain.lock_timing_unexpected': "The lock's dispute timing or token isn't what the supplier's profile accepts",
116
+ 'chain.supplier_mismatch': "The commitment on the lock names another supplier account or signing key than this supplier's",
117
+ 'reference.commitment_mismatch': "The lock holds no commitment for this reference, holds it under another terms hash, or the reference names a side the terms' backing doesn't secure",
118
+ 'reference.unreadable': "A read of the commitment the reference names failed, timed out or couldn't be pinned to one block, so nothing was decided",
119
+ 'payment.not_found': 'No transfer is at that chain, transaction and log index',
120
+ 'payment.failed': 'The transaction that holds the payment failed',
121
+ 'payment.not_final': "The payment's block isn't finalized yet",
122
+ 'payment.not_memo_transfer': "The log at that index isn't a TransferWithMemo event, and only that event counts as a payment",
123
+ 'payment.token_not_accepted': "The payment's token isn't one this reader accepts payments in",
124
+ 'payment.token_mismatch': "A contract other than the reference's token emitted the transfer",
125
+ 'payment.sender_mismatch': 'The transfer came from another sender than the reference names',
126
+ 'payment.recipient_mismatch': 'The transfer went to another recipient than the reference names',
127
+ 'payment.amount_mismatch': 'The transfer moved another amount than the reference names',
128
+ 'payment.memo_mismatch': "The transfer's memo differs from the reference's",
129
+ 'payment.attributed_twice': "The payment's value is attributed more than once in this set, and this release lets it count once",
130
+ 'dependency.lock_unknown': 'The booking relied on sits in a lock that no supported factory on a supported chain created',
131
+ 'dependency.not_owned': "The lock holding the booking relied on belongs to another account than this booking's supplier",
132
+ 'dependency.not_found': 'The lock holds no commitment with the id and side the dependency names',
133
+ 'dependency.self_supplied': 'The booking relied on was supplied by the seller itself, so it shows no one else accepted it',
134
+ 'dependency.not_accepted': "The booking relied on is reserved, and its supplier hasn't accepted it",
135
+ 'dependency.charge_pending': 'The booking relied on has a report filed, a charge pending or a charge paused for a dispute',
136
+ 'dependency.cancellable': "The booking relied on was still inside its free cancellation at the block read, so the seller's business could still cancel it at no charge",
137
+ 'dependency.ended': 'The booking relied on has been released, charged or resolved',
138
+ 'dependency.terms_mismatch': 'The lock holds the booking relied on under another terms hash than the dependency names',
139
+ 'dependency.disclosure_invalid': "The section shown of the booking relied on is missing, isn't the one the dependency names, or doesn't hash to its terms hash",
140
+ 'dependency.does_not_fit': 'This booking asks for more GPUs, another GPU or region, or a window outside the booking it relies on',
141
+ 'dependency.unreadable': "A read of the booking relied on failed, timed out or couldn't be pinned to one block, so nothing was decided",
142
+ 'dependency.stale': "The latest finalized block the node gave was older than the check's limit by the caller's clock, so nothing was decided",
143
+ 'dependency.required': 'These terms name no booking they rely on, and their template commits only on a booking it relies on, such as the compute a job runs on',
144
+ 'dependency.elided': 'The terms carry the dependencies section only as its digest, and this step needs its entries in clear',
145
+ 'dependency.unrecorded': 'Avow holds no record of the booking relied on, so it has nothing to check the section shown against',
146
+ 'service.compute_off': 'The compute switch in service.ts is off, so the tool layer books no compute and a quote names no booking',
147
+ 'service.over_budget': "The offer's rate per GPU-hour is over the compute budget in service.ts, so the tool layer didn't book it",
148
+ 'service.unknown_offer': 'No offer in the latest listing has that id, so nothing was booked',
149
+ 'service.unknown_booking': 'No compute booking this session made has that id',
150
+ 'service.quantity_unavailable': "The offer doesn't take that many GPUs in one booking, so nothing was booked",
151
+ 'supplier.declined': 'The supplier declined to sign the agreement, such as for a booking over its most or past its limit of open bookings, so nothing was reserved',
152
+ 'supplier.not_accepted': "The supplier didn't accept the reserve by its acceptance deadline, so it goes back to the business then",
153
+ 'service.check_failed': "checkBeforeWork in service.ts threw, took too long or gave a verdict that doesn't read, so nothing was accepted and no work started",
154
+ 'service.cancel_late': 'Free cancellation has ended, so the session cancels nothing and the booking stands under its terms',
155
+ 'service.cancel_declined': 'The developer declined the cancellation, so the booking stands',
156
+ 'chain.cancel_reverted': 'The lock reverted the cancellation, so the booking stands',
157
+ 'chain.report_reverted': 'The lock reverted the report, so no charge was filed',
158
+ 'service.booking_required': 'service.ts books compute for every quote while its compute switch is on, so a quote has to name a booking',
159
+ 'sandbox.closed': 'Sandbox registration and its faucet are switched off for now, so nothing was registered or paid',
160
+ 'sandbox.limit_reached': 'Registering would take one of the sandbox limits past what it allows, so send it again once `retryAt` has passed',
161
+ 'sandbox.budget_spent': 'The faucet has sent everything its total budget allows, so it registers no more businesses until Avow raises it',
162
+ 'sandbox.pool_empty': "The faucet's pool of test dollars can't pay another business yet, so nothing was registered",
163
+ 'sandbox.faucet_fees_low': "The faucet's own fees are too low to send a payout, so nothing was registered. They usually refill on their own within a few minutes, so register again then",
164
+ 'sandbox.taken': 'The account, lock or signing key already belongs to another business or supplier Avow records',
165
+ 'sandbox.session_taken': 'Another sandbox business already posts to this session, so start a session of your own',
166
+ 'sandbox.session_expired': 'This session took events for a week after its first and has ended, so start a new session',
167
+ 'sandbox.session_full': 'This session holds as many events as a session can, so start a new session',
168
+ 'sandbox.event_too_large': 'The event is larger than a session keeps, so nothing was posted',
169
+ 'sandbox.session_rate': 'Your business is posting events faster than the sandbox allows, so send it again once `retryAt` has passed',
170
+ };
171
+ export function describeReason(code) {
172
+ return REASON_CODES[code];
173
+ }
174
+ //# sourceMappingURL=reasons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reasons.js","sourceRoot":"","sources":["../src/reasons.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,oBAAoB;IAC9B,qBAAqB,EAAE,6CAA6C;IACpE,oBAAoB,EAAE,8DAA8D;IACpF,4BAA4B,EAAE,mEAAmE;IACjG,eAAe,EAAE,4BAA4B;IAC7C,oBAAoB,EAAE,sDAAsD;IAC5E,iBAAiB,EAAE,0EAA0E;IAC7F,sBAAsB,EACpB,gFAAgF;IAClF,2BAA2B,EACzB,iGAAiG;IACnG,iBAAiB,EACf,oFAAoF;IACtF,iBAAiB,EAAE,yBAAyB;IAC5C,iBAAiB,EAAE,wBAAwB;IAC3C,8BAA8B,EAAE,wCAAwC;IACxE,8BAA8B,EAAE,0CAA0C;IAC1E,8BAA8B,EAAE,0CAA0C;IAC1E,yBAAyB,EACvB,wFAAwF;IAC1F,8BAA8B,EAAE,yCAAyC;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AC5F,yBAAyB,EAAE,kDAAkD;IAC7E,8BAA8B,EAC5B,6EAA6E;IAC/E,mBAAmB,EACjB,8IAA8I;IAChJ,uBAAuB,EACrB,yGAAyG;IAC3G,sBAAsB,EACpB,qIAAqI;IACvI,qBAAqB,EACnB,oGAAoG;IACtG,yBAAyB,EAAE,gEAAgE;IAC3F,uBAAuB,EAAE,2DAA2D;IACpF,uBAAuB,EAAE,sDAAsD;IAC/E,0BAA0B,EACxB,2GAA2G;IAC7G,gBAAgB,EACd,iGAAiG;IACnG,uBAAuB,EACrB,kHAAkH;IACpH,sBAAsB,EACpB,iHAAiH;IACnH,oBAAoB,EAClB,6FAA6F;IAC/F,yBAAyB,EACvB,8JAA8J;IAChK,eAAe,EACb,+FAA+F;IACjG,uBAAuB,EACrB,wFAAwF;IAC1F,yBAAyB,EACvB,2FAA2F;IAC7F,sBAAsB,EACpB,4EAA4E;IAC9E,yBAAyB,EAAE,iEAAiE;IAC5F,sBAAsB,EACpB,4GAA4G;CACtG,CAAA;AAIV,MAAM,UAAU,cAAc,CAAC,IAAgB;IAC7C,OAAO,YAAY,CAAC,IAAI,CAAC,CAAA;AAC3B,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { type CommitmentReference } from './references.js';
2
+ import { type Parsed } from './wire.js';
3
+ /**
4
+ * A value as one URL-safe token for a link: its canonical JSON in UTF-8, in base64url without
5
+ * padding. Canonical JSON has one encoding for each value, so a value has one token.
6
+ */
7
+ export declare function encodeLinkToken(value: unknown): string;
8
+ /**
9
+ * The JSON a token from `encodeLinkToken` carries, or null when the token is empty, longer than
10
+ * `max`, or isn't base64url holding UTF-8 JSON.
11
+ */
12
+ export declare function decodeLinkToken(token: string, max: number): {
13
+ json: unknown;
14
+ } | null;
15
+ /**
16
+ * A commitment reference as one URL-safe token, for a link such as `#verify=<token>`: the
17
+ * reference's canonical JSON in base64url, without padding. It names where the backing sits and
18
+ * the terms hash, which anyone can check against the lock, so the token carries nothing private.
19
+ */
20
+ export declare function encodeCommitmentReference(reference: CommitmentReference): string;
21
+ /** Reads the commitment reference a token from `encodeCommitmentReference` carries. */
22
+ export declare function decodeCommitmentReference(token: string): Parsed<CommitmentReference>;
23
+ //# sourceMappingURL=reference-link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference-link.d.ts","sourceRoot":"","sources":["../src/reference-link.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,mBAAmB,EAA2B,MAAM,iBAAiB,CAAA;AACnF,OAAO,EAAE,KAAK,MAAM,EAAU,MAAM,WAAW,CAAA;AAO/C;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAMtD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAUpF;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,mBAAmB,GAAG,MAAM,CAIhF;AAED,uFAAuF;AACvF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAOpF"}
@@ -0,0 +1,56 @@
1
+ import { canonicalJson } from './canonical.js';
2
+ import { commitmentReferenceJson } from './references.js';
3
+ import { toWire } from './wire.js';
4
+ /** The longest token `decodeCommitmentReference` reads, well above any reference's. */
5
+ const MAX_TOKEN = 1024;
6
+ const TOKEN = /^[A-Za-z0-9_-]+$/;
7
+ /**
8
+ * A value as one URL-safe token for a link: its canonical JSON in UTF-8, in base64url without
9
+ * padding. Canonical JSON has one encoding for each value, so a value has one token.
10
+ */
11
+ export function encodeLinkToken(value) {
12
+ const bytes = new TextEncoder().encode(canonicalJson(toWire(value)));
13
+ return btoa(String.fromCharCode(...bytes))
14
+ .replace(/\+/g, '-')
15
+ .replace(/\//g, '_')
16
+ .replace(/=+$/, '');
17
+ }
18
+ /**
19
+ * The JSON a token from `encodeLinkToken` carries, or null when the token is empty, longer than
20
+ * `max`, or isn't base64url holding UTF-8 JSON.
21
+ */
22
+ export function decodeLinkToken(token, max) {
23
+ if (token.length === 0 || token.length > max || !TOKEN.test(token))
24
+ return null;
25
+ try {
26
+ const base64 = token.replace(/-/g, '+').replace(/_/g, '/');
27
+ const binary = atob(base64.padEnd(Math.ceil(base64.length / 4) * 4, '='));
28
+ const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
29
+ return { json: JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes)) };
30
+ }
31
+ catch {
32
+ return null;
33
+ }
34
+ }
35
+ /**
36
+ * A commitment reference as one URL-safe token, for a link such as `#verify=<token>`: the
37
+ * reference's canonical JSON in base64url, without padding. It names where the backing sits and
38
+ * the terms hash, which anyone can check against the lock, so the token carries nothing private.
39
+ */
40
+ export function encodeCommitmentReference(reference) {
41
+ const parsed = commitmentReferenceJson.safeParse(toWire(reference));
42
+ if (!parsed.success)
43
+ throw new RangeError("That isn't a commitment reference");
44
+ return encodeLinkToken(parsed.data);
45
+ }
46
+ /** Reads the commitment reference a token from `encodeCommitmentReference` carries. */
47
+ export function decodeCommitmentReference(token) {
48
+ const decoded = decodeLinkToken(token, MAX_TOKEN);
49
+ if (!decoded)
50
+ return { ok: false, reason: 'message.invalid' };
51
+ const parsed = commitmentReferenceJson.safeParse(decoded.json);
52
+ return parsed.success
53
+ ? { ok: true, value: parsed.data }
54
+ : { ok: false, reason: 'message.invalid' };
55
+ }
56
+ //# sourceMappingURL=reference-link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference-link.js","sourceRoot":"","sources":["../src/reference-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAA4B,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AACnF,OAAO,EAAe,MAAM,EAAE,MAAM,WAAW,CAAA;AAE/C,uFAAuF;AACvF,M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AM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAA;IACtF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,SAA8B;IACtE,MAAM,MAAM,GAAG,uBAAuB,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;IACnE,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,UAAU,CAAC,mCAAmC,CAAC,CAAA;IAC9E,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AACrC,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,yBAAyB,CAAC,KAAa;IACrD,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IACjD,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC7D,MAAM,MAAM,GAAG,uBAAuB,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9D,OAAO,MAAM,CAAC,OAAO;QACnB,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE;QAClC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAA;AAC9C,CAAC"}
@@ -0,0 +1,125 @@
1
+ import { type Address, type Hex } from 'viem';
2
+ import { z } from 'zod';
3
+ import type { ReasonCode } from './reasons.js';
4
+ import type { Side } from './types.js';
5
+ /**
6
+ * A commitment named by where its backing sits and the terms it was made under. A reader checks it
7
+ * against the lock, which holds the terms hash for the commitment id and side.
8
+ */
9
+ export interface CommitmentReference {
10
+ kind: 'commitment';
11
+ chainId: number;
12
+ lock: Address;
13
+ commitmentId: Hex;
14
+ side: Side;
15
+ termsHash: Hex;
16
+ }
17
+ /** A commitment reference's JSON form, with hex in lower case. */
18
+ export declare const commitmentReferenceJson: z.ZodObject<{
19
+ kind: z.ZodLiteral<"commitment">;
20
+ chainId: z.ZodNumber;
21
+ lock: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
22
+ commitmentId: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
23
+ side: z.ZodEnum<{
24
+ buyer: "buyer";
25
+ supplier: "supplier";
26
+ }>;
27
+ termsHash: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
28
+ }, z.core.$strict>;
29
+ /**
30
+ * A settled token transfer. The chain, transaction hash and log index identify it, and the token,
31
+ * sender, recipient, amount and memo are what the reference says the transfer shows. A reader
32
+ * checks each of them against the token's own `TransferWithMemo` event at that log index, in a
33
+ * successful and finalized transaction. A payment is evidence that money moved. It never backs a
34
+ * commitment.
35
+ */
36
+ export interface PaymentReference {
37
+ kind: 'payment';
38
+ chainId: number;
39
+ transactionHash: Hex;
40
+ /** The log's index in its block, as the receipt numbers it. */
41
+ logIndex: number;
42
+ /** The token contract that emitted the event. */
43
+ token: Address;
44
+ from: Address;
45
+ to: Address;
46
+ /** In the token's base units. */
47
+ amount: bigint;
48
+ /** The event's 32-byte memo. */
49
+ memo: Hex;
50
+ }
51
+ /** A typed reference. A new kind of reference is a new variant here. */
52
+ export type Reference = CommitmentReference | PaymentReference;
53
+ /**
54
+ * A payment's canonical id: its chain, transaction hash and log index. Records that cite the same
55
+ * transfer share it, whatever else they say about the transfer.
56
+ */
57
+ export declare function paymentId(p: Pick<PaymentReference, 'chainId' | 'transactionHash' | 'logIndex'>): string;
58
+ /** The label a reference's hash starts from. */
59
+ export declare const REFERENCE_LABEL = "avow:reference:v1";
60
+ /**
61
+ * A reference's hash: keccak256 of the ABI encoding of the string `avow:reference:v1` and the
62
+ * reference's canonical JSON, with every address and hash in lower case. It names a reference in
63
+ * 32 bytes.
64
+ */
65
+ export declare function referenceHash(r: Reference): Hex;
66
+ /**
67
+ * What a chain reader found at one log index of one transaction. `event` is the log decoded as a
68
+ * TIP-20 `TransferWithMemo` event, or null when the log there is any other event. Nothing read
69
+ * from calldata counts.
70
+ */
71
+ export interface ObservedTransfer {
72
+ chainId: number;
73
+ transactionHash: Hex;
74
+ logIndex: number;
75
+ /** Whether the transaction succeeded. */
76
+ succeeded: boolean;
77
+ /** Whether the transaction's block is finalized. */
78
+ finalized: boolean;
79
+ /** The contract that emitted the log. */
80
+ emitter: Address;
81
+ event: {
82
+ from: Address;
83
+ to: Address;
84
+ amount: bigint;
85
+ memo: Hex;
86
+ } | null;
87
+ }
88
+ /** A token a reader accepts payments in, on one chain. */
89
+ export interface PaymentToken {
90
+ chainId: number;
91
+ token: Address;
92
+ }
93
+ /** Whether the reference names a token the reader accepts, on the reference's own chain. */
94
+ export declare function acceptsPaymentToken(ref: Pick<PaymentReference, 'chainId' | 'token'>, accepted: readonly PaymentToken[]): boolean;
95
+ /**
96
+ * Checks a payment reference against what a chain reader found. The reference names its own token,
97
+ * so the reader says which tokens it accepts, and any contract can emit an event shaped like a
98
+ * token's. It passes only when the token is one the reader accepts, the transaction succeeded and
99
+ * is finalized, and the log at the reference's index is that token's own `TransferWithMemo` event
100
+ * with exactly the sender, recipient, amount and memo the reference states. A plain transfer with
101
+ * no memo doesn't count. Returns the first problem, or null.
102
+ */
103
+ export declare function checkPaymentReference(ref: PaymentReference, seen: ObservedTransfer | null, accepted: readonly PaymentToken[]): ReasonCode | null;
104
+ /**
105
+ * A record's use of a payment toward an obligation. Evidence cites the payment, and any number of
106
+ * records can. Value counts the payment's amount toward the obligation, and this release lets a
107
+ * payment's value count once.
108
+ */
109
+ export interface Attribution {
110
+ payment: PaymentReference;
111
+ obligation: CommitmentReference;
112
+ use: 'evidence' | 'value';
113
+ }
114
+ /**
115
+ * Checks a set of attributions against the rule that a payment's value counts at most once. Citing
116
+ * a payment as evidence any number of times passes. A second attribution of the same payment's
117
+ * value refuses, whichever obligation it names, since this release allows exclusive attribution
118
+ * only and no partial allocations. No attribution backs a commitment.
119
+ *
120
+ * This proves uniqueness only within the set it's given. It can't see an attribution another
121
+ * service or a later request makes. Before any version lets a payment's value be allocated, Avow
122
+ * needs a persistent registry that records each attribution atomically.
123
+ */
124
+ export declare function checkAttributions(attributions: readonly Attribution[]): ReasonCode | null;
125
+ //# sourceMappingURL=references.d.ts.map