@axorum/client 0.0.0-stage → 1.0.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 (79) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +530 -2
  3. package/dist/agent-uri.d.ts +30 -0
  4. package/dist/agent-uri.d.ts.map +1 -0
  5. package/dist/agent-uri.js +218 -0
  6. package/dist/agent-uri.js.map +1 -0
  7. package/dist/authorize.d.ts +671 -0
  8. package/dist/authorize.d.ts.map +1 -0
  9. package/dist/authorize.js +947 -0
  10. package/dist/authorize.js.map +1 -0
  11. package/dist/capabilities.d.ts +30 -0
  12. package/dist/capabilities.d.ts.map +1 -0
  13. package/dist/capabilities.js +40 -0
  14. package/dist/capabilities.js.map +1 -0
  15. package/dist/chart.d.ts +74 -0
  16. package/dist/chart.d.ts.map +1 -0
  17. package/dist/chart.js +107 -0
  18. package/dist/chart.js.map +1 -0
  19. package/dist/client.d.ts +644 -0
  20. package/dist/client.d.ts.map +1 -0
  21. package/dist/client.js +1302 -0
  22. package/dist/client.js.map +1 -0
  23. package/dist/errors.d.ts +646 -0
  24. package/dist/errors.d.ts.map +1 -0
  25. package/dist/errors.js +928 -0
  26. package/dist/errors.js.map +1 -0
  27. package/dist/failover.d.ts +197 -0
  28. package/dist/failover.d.ts.map +1 -0
  29. package/dist/failover.js +289 -0
  30. package/dist/failover.js.map +1 -0
  31. package/dist/freshness.d.ts +65 -0
  32. package/dist/freshness.d.ts.map +1 -0
  33. package/dist/freshness.js +148 -0
  34. package/dist/freshness.js.map +1 -0
  35. package/dist/generated/agent-plane.d.ts +1863 -0
  36. package/dist/generated/agent-plane.d.ts.map +1 -0
  37. package/dist/generated/agent-plane.js +19 -0
  38. package/dist/generated/agent-plane.js.map +1 -0
  39. package/dist/idempotency.d.ts +160 -0
  40. package/dist/idempotency.d.ts.map +1 -0
  41. package/dist/idempotency.js +208 -0
  42. package/dist/idempotency.js.map +1 -0
  43. package/dist/index.d.ts +89 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +87 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/intent.d.ts +163 -0
  48. package/dist/intent.d.ts.map +1 -0
  49. package/dist/intent.js +82 -0
  50. package/dist/intent.js.map +1 -0
  51. package/dist/json.d.ts +49 -0
  52. package/dist/json.d.ts.map +1 -0
  53. package/dist/json.js +259 -0
  54. package/dist/json.js.map +1 -0
  55. package/dist/key.d.ts +64 -0
  56. package/dist/key.d.ts.map +1 -0
  57. package/dist/key.js +71 -0
  58. package/dist/key.js.map +1 -0
  59. package/dist/payment.d.ts +172 -0
  60. package/dist/payment.d.ts.map +1 -0
  61. package/dist/payment.js +178 -0
  62. package/dist/payment.js.map +1 -0
  63. package/dist/refusal.d.ts +121 -0
  64. package/dist/refusal.d.ts.map +1 -0
  65. package/dist/refusal.js +176 -0
  66. package/dist/refusal.js.map +1 -0
  67. package/dist/retry.d.ts +215 -0
  68. package/dist/retry.d.ts.map +1 -0
  69. package/dist/retry.js +297 -0
  70. package/dist/retry.js.map +1 -0
  71. package/dist/typeid.d.ts +64 -0
  72. package/dist/typeid.d.ts.map +1 -0
  73. package/dist/typeid.js +119 -0
  74. package/dist/typeid.js.map +1 -0
  75. package/dist/types.d.ts +245 -0
  76. package/dist/types.d.ts.map +1 -0
  77. package/dist/types.js +14 -0
  78. package/dist/types.js.map +1 -0
  79. package/package.json +58 -3
package/dist/key.js ADDED
@@ -0,0 +1,71 @@
1
+ /**
2
+ * A caller-chosen payment key, and the transaction id it stands for.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import { uuidV5 } from "./chart.js";
7
+ import { InvalidPaymentError } from "./errors.js";
8
+ import { TRANSACTION_PREFIX, encodeSuffix } from "./typeid.js";
9
+ /** The longest key accepted, in bytes. */
10
+ export const MAX_PAYMENT_KEY_BYTES = 255;
11
+ /**
12
+ * The namespace keyed transaction ids are UUID v5s under. Fixed forever: the Rust SDK
13
+ * derives the same id from the same key, and `spec/fixtures/authorize-key-v1.json` pins
14
+ * both.
15
+ */
16
+ export const AUTHORIZE_NAMESPACE = "107dbcd8-d7e9-4ddd-8e42-34da893200e4";
17
+ /**
18
+ * Why `key` is not an acceptable payment key, or `undefined`. Pure; the same rules
19
+ * as the Rust SDK's `PaymentKey::new`.
20
+ *
21
+ * One to {@link MAX_PAYMENT_KEY_BYTES} bytes of visible ASCII (`!` through `~`): no
22
+ * space, no control character, nothing a copy through a log or a shell could silently
23
+ * change.
24
+ */
25
+ export function paymentKeyProblem(key) {
26
+ if (key.length === 0) {
27
+ return "the payment key is empty; use the identifier your own records keep for this payment, such as an order number";
28
+ }
29
+ const bytes = new TextEncoder().encode(key).length;
30
+ if (bytes > MAX_PAYMENT_KEY_BYTES) {
31
+ return `the payment key is ${bytes} bytes, over the ${MAX_PAYMENT_KEY_BYTES}-byte limit; use a shorter identifier`;
32
+ }
33
+ if (!/^[\x21-\x7e]+$/.test(key)) {
34
+ return "the payment key holds a space, a control character or non-ASCII; use visible ASCII only";
35
+ }
36
+ return undefined;
37
+ }
38
+ /**
39
+ * Validates a payment key and the time it was first issued. Pure; the same rules as the
40
+ * Rust SDK's `PaymentKey::new`.
41
+ *
42
+ * ```ts
43
+ * import { paymentKey } from "@axorum/client";
44
+ *
45
+ * // `order.approvedAtMs` is stored with the order, so a restart passes the same value.
46
+ * const key = paymentKey("order-8812", order.approvedAtMs);
47
+ * ```
48
+ *
49
+ * @throws {InvalidPaymentError} If the key is empty, over
50
+ * {@link MAX_PAYMENT_KEY_BYTES} bytes or not visible ASCII, or `issuedAtMs` is not a
51
+ * finite number.
52
+ */
53
+ export function paymentKey(key, issuedAtMs) {
54
+ const problem = paymentKeyProblem(key);
55
+ if (problem !== undefined) {
56
+ throw new InvalidPaymentError(problem);
57
+ }
58
+ if (!Number.isFinite(issuedAtMs)) {
59
+ throw new InvalidPaymentError(`the payment key's issue time is ${issuedAtMs}; pass the milliseconds since the Unix epoch your records keep for it`);
60
+ }
61
+ return Object.freeze({ key, issuedAtMs });
62
+ }
63
+ /**
64
+ * The transaction id `agentUri` paying under `key` stands for:
65
+ * `UUIDv5(AUTHORIZE_NAMESPACE, agentUri || 0x1F || key)` as a `txn_` TypeID. Async only
66
+ * because it hashes with WebCrypto. The key must already be valid.
67
+ */
68
+ export async function keyedTransaction(agentUri, key) {
69
+ return `${TRANSACTION_PREFIX}_${encodeSuffix(await uuidV5(AUTHORIZE_NAMESPACE, `${agentUri}\u001f${key}`))}`;
70
+ }
71
+ //# sourceMappingURL=key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key.js","sourceRoot":"","sources":["../src/key.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE/D,0CAA0C;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAEzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,sCAAsC,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,8GAA8G,CAAC;IACxH,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,IAAI,KAAK,GAAG,qBAAqB,EAAE,CAAC;QAClC,OAAO,sBAAsB,KAAK,oBAAoB,qBAAqB,uCAAuC,CAAC;IACrH,CAAC;IACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,OAAO,yFAAyF,CAAC;IACnG,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAsBD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,UAAkB;IACxD,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,mBAAmB,CAC3B,mCAAmC,UAAU,uEAAuE,CACrH,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,QAAgB,EAAE,GAAW;IAClE,OAAO,GAAG,kBAAkB,IAAI,YAAY,CAAC,MAAM,MAAM,CAAC,mBAAmB,EAAE,GAAG,QAAQ,SAAS,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;AAC/G,CAAC"}
@@ -0,0 +1,172 @@
1
+ /**
2
+ * What a one-call `authorize` pays, and the pure plan that turns it into an intent.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import { IdempotencyKey } from "./idempotency.js";
7
+ import type { IntentDraft } from "./intent.js";
8
+ import { type PaymentKey } from "./key.js";
9
+ import type { Amount } from "./types.js";
10
+ /** The longest payee accepted, in UTF-8 bytes. */
11
+ export declare const MAX_PAYEE_BYTES = 256;
12
+ /** What you describe when you create a {@link Payment}. */
13
+ export interface PaymentInit {
14
+ /** How much, in integer minor units. Must be positive. */
15
+ amount: Amount;
16
+ /**
17
+ * Who is paid, as your policy's approved-counterparty registry names them: a merchant
18
+ * host such as `api.openai.com`, or an id you imported.
19
+ */
20
+ payee: string;
21
+ /**
22
+ * A UUID v7 transaction id you already hold (`txn_…`), to re-drive a payment after a
23
+ * crash; its mint time is the one the id carries. Leave it out and a fresh UUID v7 id
24
+ * is minted, once, now. An id of any other version carries no mint time: rebuild it
25
+ * with {@link resumePayment} and the time you persisted, or a keyed payment with
26
+ * {@link keyedPayment}.
27
+ */
28
+ transaction?: string;
29
+ /**
30
+ * The agent's stated reason. Defaults to `purchase of <minor> <currency> from <payee>`.
31
+ *
32
+ * It is not part of what the transaction id commits to: a re-drive that rewords it
33
+ * replays the original answer, which carries the **original** justification's hash.
34
+ * `justificationMatches` tells the two apart.
35
+ */
36
+ justification?: string;
37
+ /** Lowercase-hex SHA-256 digests of evidence the payment references. */
38
+ evidence?: readonly string[];
39
+ }
40
+ /**
41
+ * Where a payment's idempotency key came from.
42
+ *
43
+ * - `minted`: {@link payment} minted it in this process, so it was never sent before.
44
+ * - `supplied`: a UUID v7 id you passed to {@link payment}, stamped with the time it
45
+ * carries.
46
+ * - `keyed`: derived from your {@link PaymentKey} ({@link keyedPayment}).
47
+ * - `resumed`: read back from your records ({@link resumePayment}).
48
+ *
49
+ * Every key but a `minted` one may have been sent before, so `authorize` sends it only
50
+ * while the service's idempotency window still covers it.
51
+ */
52
+ export type PaymentOrigin = "minted" | "supplied" | "keyed" | "resumed";
53
+ /**
54
+ * A validated payment with its transaction id already minted.
55
+ *
56
+ * Minting at creation, before any I/O, is what makes a re-drive safe: hand the **same**
57
+ * `Payment` to `authorize` again after an indeterminate failure and a payment that did
58
+ * commit replays its answer instead of paying twice. A process that may restart persists
59
+ * {@link Payment.idempotencyKey} (the id and its mint time) and rebuilds the payment
60
+ * with {@link resumePayment}. Build one with {@link payment}.
61
+ */
62
+ export interface Payment {
63
+ readonly amount: Amount;
64
+ readonly payee: string;
65
+ /** The transaction id: the idempotency key of every send. */
66
+ readonly transaction: string;
67
+ /**
68
+ * The transaction id and when it was first minted. Every send carries the mint time
69
+ * as `minted_at_ms`; persist both to resume the payment after a restart.
70
+ */
71
+ readonly idempotencyKey: IdempotencyKey;
72
+ readonly justification: string;
73
+ readonly evidence: readonly string[];
74
+ /** Where {@link Payment.idempotencyKey} came from. */
75
+ readonly origin: PaymentOrigin;
76
+ /**
77
+ * The agent URI the transaction id was derived for, when it came from a payment
78
+ * key ({@link keyedPayment}); `undefined` otherwise.
79
+ */
80
+ readonly keyedFor: string | undefined;
81
+ }
82
+ /**
83
+ * Validates a payment and mints its transaction id.
84
+ *
85
+ * ```ts
86
+ * import { payment } from "@axorum/client";
87
+ *
88
+ * const lunch = payment({ amount: { minor: 1_250n, currency: "USD" }, payee: "api.openai.com" });
89
+ * console.log(lunch.transaction); // txn_…, minted once, now
90
+ * ```
91
+ *
92
+ * @throws {InvalidPaymentError} If the amount is not positive, the payee is empty, too
93
+ * long, or carries a control character or surrounding whitespace, or `transaction` is
94
+ * not a UUID v7 id.
95
+ */
96
+ export declare function payment(init: PaymentInit): Payment;
97
+ /**
98
+ * Rebuilds a payment from the idempotency key you persisted for it, so a process that
99
+ * restarted re-drives the **same** transaction: if an earlier send committed, its answer
100
+ * comes back as a replay. The key keeps its original mint time.
101
+ *
102
+ * ```ts
103
+ * import { IdempotencyKey, payment, resumePayment } from "@axorum/client";
104
+ *
105
+ * const lunch = payment({ amount: { minor: 1_250n, currency: "USD" }, payee: "api.openai.com" });
106
+ * const { transaction, mintedAtMs } = lunch.idempotencyKey; // persist both
107
+ * // … after a restart:
108
+ * const again = resumePayment(new IdempotencyKey(transaction, mintedAtMs), {
109
+ * amount: { minor: 1_250n, currency: "USD" },
110
+ * payee: "api.openai.com",
111
+ * });
112
+ * ```
113
+ *
114
+ * `authorize` sends a resumed payment only while the service's idempotency window
115
+ * still covers its key; otherwise it fails with `stale_key`, and nothing is sent.
116
+ *
117
+ * @throws {InvalidPaymentError} If the payment itself is invalid.
118
+ */
119
+ export declare function resumePayment(key: IdempotencyKey, init: Omit<PaymentInit, "transaction">): Payment;
120
+ /**
121
+ * Validates a payment whose transaction id comes from **your** key (an order number, a
122
+ * job id) rather than a fresh mint, so a process that lost the id can re-drive the
123
+ * payment from its own records.
124
+ *
125
+ * The id is `UUIDv5(AUTHORIZE_NAMESPACE, agent.uri || 0x1F || key)`, the same as the
126
+ * Rust SDK's `Payment::with_key`: the same agent and key always name the same
127
+ * transaction. A re-drive replays; a **different** payment under the same key is
128
+ * refused with `transaction_reused`. The key's issue time becomes the payment's mint
129
+ * time, so it must be the time persisted with the key.
130
+ *
131
+ * `authorize` sends a keyed payment only for the agent it was keyed for. Otherwise it
132
+ * fails with `keyed_for_another_agent`, and nothing is sent; so does one whose key the
133
+ * service's idempotency window no longer covers (`stale_key`).
134
+ *
135
+ * ```ts
136
+ * import { keyedPayment, paymentKey } from "@axorum/client";
137
+ *
138
+ * const order = await keyedPayment(buyer, paymentKey("order-8812", approvedAtMs), {
139
+ * amount: { minor: 1_250n, currency: "USD" },
140
+ * payee: "api.openai.com",
141
+ * });
142
+ * ```
143
+ *
144
+ * @throws {InvalidPaymentError} If the payment itself is invalid (the key was checked
145
+ * by {@link paymentKey}).
146
+ */
147
+ export declare function keyedPayment(agent: {
148
+ readonly uri: string;
149
+ }, key: PaymentKey, init: Omit<PaymentInit, "transaction">): Promise<Payment>;
150
+ /**
151
+ * Why `payee` is not acceptable, or `undefined` if it is. Pure.
152
+ *
153
+ * The same rules as the Rust SDK's `Payee::new`.
154
+ */
155
+ export declare function payeeProblem(payee: string): string | undefined;
156
+ /**
157
+ * The intent a payment proposes, less the policy pin. Pure apart from hashing the
158
+ * default chart's account ids.
159
+ *
160
+ * `purchase(amount, payee)` with the payee bound as text, debiting the default chart's
161
+ * spend account and crediting its payable account in the amount's currency.
162
+ */
163
+ export declare function planPayment(agent: string, attestation: string, pay: Payment): Promise<IntentDraft & {
164
+ transaction: string;
165
+ minted_at_ms: bigint;
166
+ }>;
167
+ /**
168
+ * Mints a transaction id from a UUID v7: time-ordered, so ids sort by when their payment
169
+ * was created.
170
+ */
171
+ export declare function newPaymentId(): string;
172
+ //# sourceMappingURL=payment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../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AgB,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAalD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,OAAO,CAElG;AAiDD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAC/B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,GACrC,OAAO,CAAC,OAAO,CAAC,CAIlB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAe9D;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,OAAO,GACX,OAAO,CAAC,WAAW,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,CAiBtE;AAED;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAErC"}
@@ -0,0 +1,178 @@
1
+ /**
2
+ * What a one-call `authorize` pays, and the pure plan that turns it into an intent.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import { DEFAULT_CHART_V1, defaultChartLegs } from "./chart.js";
7
+ import { InvalidPaymentError } from "./errors.js";
8
+ import { IdempotencyKey, mintedAtWire } from "./idempotency.js";
9
+ import { keyedTransaction } from "./key.js";
10
+ import { newTransactionId, v7MintedAtMs } from "./typeid.js";
11
+ /** The longest payee accepted, in UTF-8 bytes. */
12
+ export const MAX_PAYEE_BYTES = 256;
13
+ /**
14
+ * Validates a payment and mints its transaction id.
15
+ *
16
+ * ```ts
17
+ * import { payment } from "@axorum/client";
18
+ *
19
+ * const lunch = payment({ amount: { minor: 1_250n, currency: "USD" }, payee: "api.openai.com" });
20
+ * console.log(lunch.transaction); // txn_…, minted once, now
21
+ * ```
22
+ *
23
+ * @throws {InvalidPaymentError} If the amount is not positive, the payee is empty, too
24
+ * long, or carries a control character or surrounding whitespace, or `transaction` is
25
+ * not a UUID v7 id.
26
+ */
27
+ export function payment(init) {
28
+ const valid = validated(init);
29
+ if (init.transaction === undefined) {
30
+ return build(valid, IdempotencyKey.mint(newPaymentId(), Date.now()), "minted", undefined);
31
+ }
32
+ const mintedAtMs = v7MintedAtMs(init.transaction);
33
+ if (mintedAtMs === undefined) {
34
+ throw new InvalidPaymentError(`transaction id ${init.transaction} is not a UUID v7, so it carries no mint time; rebuild a keyed ` +
35
+ "payment with keyedPayment, or pass the id with the mint time you persisted to resumePayment");
36
+ }
37
+ return build(valid, new IdempotencyKey(init.transaction, mintedAtMs), "supplied", undefined);
38
+ }
39
+ /**
40
+ * Rebuilds a payment from the idempotency key you persisted for it, so a process that
41
+ * restarted re-drives the **same** transaction: if an earlier send committed, its answer
42
+ * comes back as a replay. The key keeps its original mint time.
43
+ *
44
+ * ```ts
45
+ * import { IdempotencyKey, payment, resumePayment } from "@axorum/client";
46
+ *
47
+ * const lunch = payment({ amount: { minor: 1_250n, currency: "USD" }, payee: "api.openai.com" });
48
+ * const { transaction, mintedAtMs } = lunch.idempotencyKey; // persist both
49
+ * // … after a restart:
50
+ * const again = resumePayment(new IdempotencyKey(transaction, mintedAtMs), {
51
+ * amount: { minor: 1_250n, currency: "USD" },
52
+ * payee: "api.openai.com",
53
+ * });
54
+ * ```
55
+ *
56
+ * `authorize` sends a resumed payment only while the service's idempotency window
57
+ * still covers its key; otherwise it fails with `stale_key`, and nothing is sent.
58
+ *
59
+ * @throws {InvalidPaymentError} If the payment itself is invalid.
60
+ */
61
+ export function resumePayment(key, init) {
62
+ return build(validated(init), new IdempotencyKey(key.transaction, key.mintedAtMs), "resumed", undefined);
63
+ }
64
+ /** A frozen payment from `valid` under `key`. Pure. */
65
+ function build(valid, key, origin, keyedFor) {
66
+ return Object.freeze({
67
+ amount: Object.freeze({ ...valid.amount }),
68
+ payee: valid.payee,
69
+ transaction: key.transaction,
70
+ idempotencyKey: key,
71
+ justification: valid.justification,
72
+ evidence: Object.freeze([...valid.evidence]),
73
+ origin,
74
+ keyedFor,
75
+ });
76
+ }
77
+ /** `init` checked, with the default justification. Pure. */
78
+ function validated(init) {
79
+ if (init.amount.minor <= 0n) {
80
+ throw new InvalidPaymentError(`the amount is ${init.amount.minor} ${init.amount.currency}; a payment moves a positive amount`);
81
+ }
82
+ const problem = payeeProblem(init.payee);
83
+ if (problem !== undefined) {
84
+ throw new InvalidPaymentError(problem);
85
+ }
86
+ return {
87
+ amount: init.amount,
88
+ payee: init.payee,
89
+ justification: init.justification ?? `purchase of ${init.amount.minor} ${init.amount.currency} from ${init.payee}`,
90
+ evidence: init.evidence ?? [],
91
+ };
92
+ }
93
+ /**
94
+ * Validates a payment whose transaction id comes from **your** key (an order number, a
95
+ * job id) rather than a fresh mint, so a process that lost the id can re-drive the
96
+ * payment from its own records.
97
+ *
98
+ * The id is `UUIDv5(AUTHORIZE_NAMESPACE, agent.uri || 0x1F || key)`, the same as the
99
+ * Rust SDK's `Payment::with_key`: the same agent and key always name the same
100
+ * transaction. A re-drive replays; a **different** payment under the same key is
101
+ * refused with `transaction_reused`. The key's issue time becomes the payment's mint
102
+ * time, so it must be the time persisted with the key.
103
+ *
104
+ * `authorize` sends a keyed payment only for the agent it was keyed for. Otherwise it
105
+ * fails with `keyed_for_another_agent`, and nothing is sent; so does one whose key the
106
+ * service's idempotency window no longer covers (`stale_key`).
107
+ *
108
+ * ```ts
109
+ * import { keyedPayment, paymentKey } from "@axorum/client";
110
+ *
111
+ * const order = await keyedPayment(buyer, paymentKey("order-8812", approvedAtMs), {
112
+ * amount: { minor: 1_250n, currency: "USD" },
113
+ * payee: "api.openai.com",
114
+ * });
115
+ * ```
116
+ *
117
+ * @throws {InvalidPaymentError} If the payment itself is invalid (the key was checked
118
+ * by {@link paymentKey}).
119
+ */
120
+ export async function keyedPayment(agent, key, init) {
121
+ const valid = validated(init);
122
+ const transaction = await keyedTransaction(agent.uri, key.key);
123
+ return build(valid, new IdempotencyKey(transaction, key.issuedAtMs), "keyed", agent.uri);
124
+ }
125
+ /**
126
+ * Why `payee` is not acceptable, or `undefined` if it is. Pure.
127
+ *
128
+ * The same rules as the Rust SDK's `Payee::new`.
129
+ */
130
+ export function payeeProblem(payee) {
131
+ if (payee.length === 0) {
132
+ return "the payee is empty; name who is being paid, as your policy's approved-counterparty registry names them";
133
+ }
134
+ const bytes = new TextEncoder().encode(payee).length;
135
+ if (bytes > MAX_PAYEE_BYTES) {
136
+ return `the payee is ${bytes} bytes, over the ${MAX_PAYEE_BYTES}-byte limit; use a stable short identifier such as the merchant's host`;
137
+ }
138
+ if (/\p{Cc}/u.test(payee)) {
139
+ return "the payee contains a control character; pass the identifier alone";
140
+ }
141
+ if (payee.trim() !== payee) {
142
+ return "the payee starts or ends with whitespace, so it would never match a registry entry; trim it";
143
+ }
144
+ return undefined;
145
+ }
146
+ /**
147
+ * The intent a payment proposes, less the policy pin. Pure apart from hashing the
148
+ * default chart's account ids.
149
+ *
150
+ * `purchase(amount, payee)` with the payee bound as text, debiting the default chart's
151
+ * spend account and crediting its payable account in the amount's currency.
152
+ */
153
+ export async function planPayment(agent, attestation, pay) {
154
+ return {
155
+ agent,
156
+ attestation,
157
+ transaction: pay.transaction,
158
+ minted_at_ms: mintedAtWire(pay.idempotencyKey),
159
+ action: {
160
+ action: DEFAULT_CHART_V1.action,
161
+ bindings: {
162
+ [DEFAULT_CHART_V1.amountParam]: { Amount: pay.amount },
163
+ [DEFAULT_CHART_V1.payeeParam]: { Text: pay.payee },
164
+ },
165
+ },
166
+ entries: await defaultChartLegs(pay.amount),
167
+ evidence: [...pay.evidence],
168
+ justification: pay.justification,
169
+ };
170
+ }
171
+ /**
172
+ * Mints a transaction id from a UUID v7: time-ordered, so ids sort by when their payment
173
+ * was created.
174
+ */
175
+ export function newPaymentId() {
176
+ return newTransactionId();
177
+ }
178
+ //# sourceMappingURL=payment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment.js","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAmB,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG7D,kDAAkD;AAClD,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAC;AA2EnC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,OAAO,CAAC,IAAiB;IACvC,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC5F,CAAC;IACD,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,mBAAmB,CAC3B,kBAAkB,IAAI,CAAC,WAAW,iEAAiE;YACjG,6FAA6F,CAChG,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC,KAAK,EAAE,IAAI,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,UAAU,EAAE,S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OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,KAAa,EACb,WAAmB,EACnB,GAAY;IAEZ,OAAO;QACL,KAAK;QACL,WAAW;QACX,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,cAAc,CAAC;QAC9C,MAAM,EAAE;YACN,MAAM,EAAE,gBAAgB,CAAC,MAAM;YAC/B,QAAQ,EAAE;gBACR,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE;gBACtD,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE;aACnD;SACF;QACD,OAAO,EAAE,MAAM,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC;QAC3C,QAAQ,EAAE,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC3B,aAAa,EAAE,GAAG,CAAC,aAAa;KACjC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,gBAAgB,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Reading why an intent was refused (contract 5.0.0).
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import type { AgentOutcome, Condition, Figure, Refusal } from "./types.js";
7
+ /**
8
+ * The refusal codes this version of the contract documents.
9
+ *
10
+ * - `forbidden_by_rule`: a forbid rule in the judging policy won and no permit overrode
11
+ * it. `rule` names it.
12
+ * - `not_delegated`: a permit matched and its conditions held, but no delegation to the
13
+ * acting agent covers it. `rule` names the highest-priority such permit.
14
+ * - `denied_by_default`: no rule permitted the action for this actor, so the policy's
15
+ * default deny applied. No `rule`.
16
+ * - `reason_archived`: the refused record has been archived, so a replay cannot carry
17
+ * the reason. No `rule`.
18
+ *
19
+ * An **open vocabulary**: a newer service may send a code this client has never heard
20
+ * of. Test with {@link isKnownRefusalCode}, and fall back to `explanation`.
21
+ */
22
+ export declare const REFUSAL_CODES: readonly ["forbidden_by_rule", "not_delegated", "denied_by_default", "reason_archived"];
23
+ /** A refusal code this version of the contract documents. See {@link REFUSAL_CODES}. */
24
+ export type KnownRefusalCode = (typeof REFUSAL_CODES)[number];
25
+ /** Whether `code` is one this version of the contract documents. */
26
+ export declare function isKnownRefusalCode(code: string): code is KnownRefusalCode;
27
+ /**
28
+ * What a guard literal tested, named by `Condition.kind` (contract 5.0.0). An open
29
+ * vocabulary, like {@link REFUSAL_CODES}.
30
+ */
31
+ export declare const CONDITION_KINDS: readonly ["register_cap", "counterparty_limit", "mandate_cap", "counterparty_list", "chart_of_accounts", "posting_period", "posted_balance", "time_window", "actor", "param"];
32
+ /** A condition kind this version of the contract documents. See {@link CONDITION_KINDS}. */
33
+ export type KnownConditionKind = (typeof CONDITION_KINDS)[number];
34
+ /** Whether `kind` is one this version of the contract documents. */
35
+ export declare function isKnownConditionKind(kind: string): kind is KnownConditionKind;
36
+ /**
37
+ * What a figure read, named by `Figure.source`: `register` carries `register`, `window`
38
+ * and `scope`; `mandate` carries `mandate` and `quantity`. An open vocabulary.
39
+ */
40
+ export declare const FIGURE_SOURCES: readonly ["register", "mandate"];
41
+ /** The comparisons `Figure.op` can name, as the policy wrote them. An open vocabulary. */
42
+ export declare const COMPARISON_OPS: readonly ["eq", "ne", "lt", "le", "gt", "ge", "in"];
43
+ /** The windows `Figure.window.kind` can name. An open vocabulary. */
44
+ export declare const WINDOW_KINDS: readonly ["rolling", "calendar", "unbounded"];
45
+ /** The partitions `Figure.scope` can name. An open vocabulary. */
46
+ export declare const REGISTER_SCOPES: readonly ["per_party", "per_role", "per_counterparty", "per_rail", "global"];
47
+ /** The mandate quantities `Figure.quantity` can name. An open vocabulary. */
48
+ export declare const MANDATE_QUANTITIES: readonly ["spent", "ceiling", "remaining", "projected"];
49
+ /** The modalities `SetAside.modality` can name. An open vocabulary. */
50
+ export declare const MODALITIES: readonly ["permitted", "obligated", "forbidden"];
51
+ /**
52
+ * The figure a condition compared, or `undefined` when the literal compared no figure
53
+ * (a list membership, an actor test) or the index is out of range.
54
+ *
55
+ * Every amount on a figure is a `bigint` in minor units of `currency`: exact at any
56
+ * magnitude, including above 2^64. `exponent` is the deployment's declared scale.
57
+ *
58
+ * ```ts
59
+ * const refusal = refusalOf(outcome);
60
+ * for (const condition of refusal?.conditions ?? []) {
61
+ * const figure = figureOf(refusal!, condition);
62
+ * if (figure?.headroom !== undefined && figure.headroom > 0n) {
63
+ * retryWith(figure.headroom); // the largest amount that clears this condition
64
+ * }
65
+ * }
66
+ * ```
67
+ */
68
+ export declare function figureOf(refusal: Refusal, condition: Condition): Figure | undefined;
69
+ /**
70
+ * The substrate laws a `substrate_rejected` error body can name in `law` (contract
71
+ * 5.0.0). Present only on a genuine law violation, never on malformed input. An open
72
+ * vocabulary, like {@link REFUSAL_CODES}.
73
+ */
74
+ export declare const SUBSTRATE_LAWS: readonly ["conservative", "authorization_conservation", "revenue_cost_matching", "usage_balance_conservation", "period_close_roll_forward"];
75
+ /** A substrate law this version of the contract documents. See {@link SUBSTRATE_LAWS}. */
76
+ export type KnownSubstrateLaw = (typeof SUBSTRATE_LAWS)[number];
77
+ /** Whether `law` is one this version of the contract documents. */
78
+ export declare function isKnownSubstrateLaw(law: string): law is KnownSubstrateLaw;
79
+ /**
80
+ * What the caller must change, named by `cause` on a `substrate_rejected` error body
81
+ * (contract 5.0.0). Present only when the refusal broke no law but the intent was
82
+ * malformed in a way the caller can fix; a body carries `law` or `cause`, never both.
83
+ * An open vocabulary, like {@link REFUSAL_CODES}.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * if (error.body.cause === "unknown_account") {
88
+ * // provision the account, or post to one that exists
89
+ * }
90
+ * ```
91
+ */
92
+ export declare const SUBSTRATE_CAUSES: readonly ["unknown_account", "account_revoked", "currency_mismatch", "non_positive_amount", "entry_count", "amount_overflow", "unknown_mandate", "mandate_revoked", "unknown_usage", "usage_not_owned", "unknown_deferral", "unknown_counterparty", "counterparty_mandate_unresolved", "undeclared_action", "missing_param", "unexpected_param", "param_type_mismatch", "period_closed", "undeclared_currency"];
93
+ /** A cause this version of the contract documents. See {@link SUBSTRATE_CAUSES}. */
94
+ export type KnownSubstrateCause = (typeof SUBSTRATE_CAUSES)[number];
95
+ /** Whether `cause` is one this version of the contract documents. */
96
+ export declare function isKnownSubstrateCause(cause: string): cause is KnownSubstrateCause;
97
+ /**
98
+ * Why `outcome` was refused, or `undefined` if it posted.
99
+ *
100
+ * Branch on `code`; for policy-specific reasons, branch on `rule.name`, which you
101
+ * declared. Show `explanation` to a human: it names the rule and says what to do next.
102
+ *
103
+ * `undefined` on a refused outcome means the service predates contract 5.0.0 and sent
104
+ * no reason; `posted: false` is still the refusal.
105
+ *
106
+ * The refusal is **not signed**. The receipt signs the provenance (whose `winning` is
107
+ * the rule id) and the policy hash; the refusal is derived from those, so a verifier
108
+ * recomputes it from signed facts rather than trusting these bytes.
109
+ *
110
+ * ```ts
111
+ * const outcome = await axorum.submitPinned(draft);
112
+ * const refusal = refusalOf(outcome);
113
+ * if (refusal?.code === "forbidden_by_rule" && refusal.rule?.name === "no_unapproved_vendors") {
114
+ * await askForVendorApproval();
115
+ * } else if (refusal) {
116
+ * console.log(refusal.explanation);
117
+ * }
118
+ * ```
119
+ */
120
+ export declare function refusalOf(outcome: AgentOutcome): Refusal | undefined;
121
+ //# sourceMappingURL=refusal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE3E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,yFAKhB,CAAC;AAEX,wFAAwF;AACxF,MAAM,M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