@sess.si/sdk 0.1.0-rc.8 → 0.1.0-rc.9

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 (139) hide show
  1. package/CHANGELOG.md +38 -3
  2. package/NOTICE +1 -1
  3. package/README.md +64 -9
  4. package/dist/ask.d.ts +0 -1
  5. package/dist/ask.js +0 -1
  6. package/dist/cli/main.d.ts +0 -1
  7. package/dist/cli/main.js +0 -1
  8. package/dist/cli/verify.d.ts +0 -1
  9. package/dist/cli/verify.js +0 -1
  10. package/dist/client.d.ts +0 -1
  11. package/dist/client.js +0 -1
  12. package/dist/commerce/builders.d.ts +99 -0
  13. package/dist/commerce/builders.js +208 -0
  14. package/dist/commerce/currency.d.ts +4 -0
  15. package/dist/commerce/currency.js +25 -0
  16. package/dist/commerce/items.d.ts +119 -0
  17. package/dist/commerce/items.js +280 -0
  18. package/dist/commerce/lint.d.ts +16 -0
  19. package/dist/commerce/lint.js +56 -0
  20. package/dist/errors.d.ts +0 -1
  21. package/dist/errors.js +5 -1
  22. package/dist/generated/openapi.d.ts +12 -13
  23. package/dist/generated/openapi.js +0 -1
  24. package/dist/index.d.ts +6 -1
  25. package/dist/index.js +3 -1
  26. package/dist/internal/decode.d.ts +0 -1
  27. package/dist/internal/decode.js +9 -2
  28. package/dist/internal/json.d.ts +0 -1
  29. package/dist/internal/json.js +0 -1
  30. package/dist/internal/time.d.ts +0 -1
  31. package/dist/internal/time.js +0 -1
  32. package/dist/internal/version.d.ts +2 -0
  33. package/dist/internal/version.js +2 -0
  34. package/dist/polling.d.ts +0 -1
  35. package/dist/polling.js +0 -1
  36. package/dist/qr/encoder.d.ts +0 -1
  37. package/dist/qr/encoder.js +0 -1
  38. package/dist/qr/index.d.ts +0 -1
  39. package/dist/qr/index.js +0 -1
  40. package/dist/receipts/bundle.d.ts +0 -1
  41. package/dist/receipts/bundle.js +0 -1
  42. package/dist/receipts/index.d.ts +0 -1
  43. package/dist/receipts/index.js +0 -1
  44. package/dist/receipts/json.d.ts +0 -1
  45. package/dist/receipts/json.js +0 -1
  46. package/dist/receipts/key-cache.d.ts +0 -1
  47. package/dist/receipts/key-cache.js +0 -1
  48. package/dist/receipts/renderers.d.ts +0 -1
  49. package/dist/receipts/renderers.js +1 -2
  50. package/dist/receipts/resource.d.ts +0 -1
  51. package/dist/receipts/resource.js +0 -1
  52. package/dist/receipts/verify.d.ts +0 -1
  53. package/dist/receipts/verify.js +0 -1
  54. package/dist/sessions.d.ts +0 -1
  55. package/dist/sessions.js +0 -1
  56. package/dist/transport.d.ts +0 -1
  57. package/dist/transport.js +24 -3
  58. package/dist/types.d.ts +56 -2
  59. package/dist/types.js +0 -1
  60. package/dist/webhook-resource.d.ts +0 -1
  61. package/dist/webhook-resource.js +0 -1
  62. package/dist/webhooks/index.d.ts +0 -1
  63. package/dist/webhooks/index.js +0 -1
  64. package/package.json +3 -3
  65. package/dist/ask.d.ts.map +0 -1
  66. package/dist/ask.js.map +0 -1
  67. package/dist/cli/main.d.ts.map +0 -1
  68. package/dist/cli/main.js.map +0 -1
  69. package/dist/cli/verify.d.ts.map +0 -1
  70. package/dist/cli/verify.js.map +0 -1
  71. package/dist/client.d.ts.map +0 -1
  72. package/dist/client.js.map +0 -1
  73. package/dist/errors.d.ts.map +0 -1
  74. package/dist/errors.js.map +0 -1
  75. package/dist/generated/openapi.d.ts.map +0 -1
  76. package/dist/generated/openapi.js.map +0 -1
  77. package/dist/index.d.ts.map +0 -1
  78. package/dist/index.js.map +0 -1
  79. package/dist/internal/decode.d.ts.map +0 -1
  80. package/dist/internal/decode.js.map +0 -1
  81. package/dist/internal/json.d.ts.map +0 -1
  82. package/dist/internal/json.js.map +0 -1
  83. package/dist/internal/time.d.ts.map +0 -1
  84. package/dist/internal/time.js.map +0 -1
  85. package/dist/polling.d.ts.map +0 -1
  86. package/dist/polling.js.map +0 -1
  87. package/dist/qr/encoder.d.ts.map +0 -1
  88. package/dist/qr/encoder.js.map +0 -1
  89. package/dist/qr/index.d.ts.map +0 -1
  90. package/dist/qr/index.js.map +0 -1
  91. package/dist/receipts/bundle.d.ts.map +0 -1
  92. package/dist/receipts/bundle.js.map +0 -1
  93. package/dist/receipts/index.d.ts.map +0 -1
  94. package/dist/receipts/index.js.map +0 -1
  95. package/dist/receipts/json.d.ts.map +0 -1
  96. package/dist/receipts/json.js.map +0 -1
  97. package/dist/receipts/key-cache.d.ts.map +0 -1
  98. package/dist/receipts/key-cache.js.map +0 -1
  99. package/dist/receipts/renderers.d.ts.map +0 -1
  100. package/dist/receipts/renderers.js.map +0 -1
  101. package/dist/receipts/resource.d.ts.map +0 -1
  102. package/dist/receipts/resource.js.map +0 -1
  103. package/dist/receipts/verify.d.ts.map +0 -1
  104. package/dist/receipts/verify.js.map +0 -1
  105. package/dist/sessions.d.ts.map +0 -1
  106. package/dist/sessions.js.map +0 -1
  107. package/dist/transport.d.ts.map +0 -1
  108. package/dist/transport.js.map +0 -1
  109. package/dist/types.d.ts.map +0 -1
  110. package/dist/types.js.map +0 -1
  111. package/dist/webhook-resource.d.ts.map +0 -1
  112. package/dist/webhook-resource.js.map +0 -1
  113. package/dist/webhooks/index.d.ts.map +0 -1
  114. package/dist/webhooks/index.js.map +0 -1
  115. package/src/ask.ts +0 -683
  116. package/src/cli/main.ts +0 -8
  117. package/src/cli/verify.ts +0 -349
  118. package/src/client.ts +0 -55
  119. package/src/errors.ts +0 -127
  120. package/src/generated/openapi.ts +0 -8586
  121. package/src/index.ts +0 -5
  122. package/src/internal/decode.ts +0 -348
  123. package/src/internal/json.ts +0 -64
  124. package/src/internal/time.ts +0 -85
  125. package/src/polling.ts +0 -173
  126. package/src/qr/encoder.ts +0 -345
  127. package/src/qr/index.ts +0 -203
  128. package/src/receipts/bundle.ts +0 -547
  129. package/src/receipts/index.ts +0 -29
  130. package/src/receipts/json.ts +0 -168
  131. package/src/receipts/key-cache.ts +0 -143
  132. package/src/receipts/renderers.ts +0 -220
  133. package/src/receipts/resource.ts +0 -264
  134. package/src/receipts/verify.ts +0 -554
  135. package/src/sessions.ts +0 -238
  136. package/src/transport.ts +0 -566
  137. package/src/types.ts +0 -219
  138. package/src/webhook-resource.ts +0 -81
  139. package/src/webhooks/index.ts +0 -246
@@ -0,0 +1,119 @@
1
+ import type { ItemsComponent } from '../types.js';
2
+ /**
3
+ * The runtime's items limits (Unicode code points for text): rows 1–100, totals lines ≤ 8, a row
4
+ * name ≤ 80, a detail ≤ 160, a totals label ≤ 40, a caption ≤ 200, a quantity unit ≤ 16, every
5
+ * amount within ±10^15 minor units, a quantity within 0–1,000,000.
6
+ */
7
+ export declare const ITEMS_LIMITS: Readonly<{
8
+ rows: 100;
9
+ totals: 8;
10
+ name: 80;
11
+ detail: 160;
12
+ totalLabel: 40;
13
+ label: 200;
14
+ quantityUnit: 16;
15
+ amount: 1000000000000000;
16
+ quantity: 1000000;
17
+ }>;
18
+ /** An amount in a currency's minor unit (1250 is 12.50 USD, 1250 JPY, 1.250 BHD). */
19
+ export interface Money {
20
+ readonly amount: number;
21
+ readonly currency: string;
22
+ }
23
+ /** A row, totals or payment amount: minor units of the component's currency, or `money()`. */
24
+ export type Amount = number | Money;
25
+ /** A line of the bill. Put quantity and unit price in `detail`, not in `name`. */
26
+ export interface ItemRowInput {
27
+ /** What the line is, shown verbatim; at most 80. Example: `Design retainer, October` */
28
+ readonly name: string;
29
+ /** Optional second line: quantity or unit price; at most 160 with `reference`. Example: `3 × $150.00` */
30
+ readonly detail?: string;
31
+ /** Optional reference (SKU, booking or PO number): shown in the detail line, after it. */
32
+ readonly reference?: string;
33
+ /** Minor units (or `money()`), or null for a line with no amount, such as `Included`. */
34
+ readonly amount: Amount | null;
35
+ /**
36
+ * A quantity the person may change (an integer within `min`, default 0, and `max`, default
37
+ * 1,000,000). The amount stays as stated: a changed quantity comes back as a change request
38
+ * and your agent sends a new revision with new amounts.
39
+ */
40
+ readonly quantity?: {
41
+ readonly value: number;
42
+ readonly unit?: string;
43
+ readonly min?: number;
44
+ readonly max?: number;
45
+ };
46
+ }
47
+ /** A line between the subtotal and the total. Added to the total unless `included`. */
48
+ export interface ItemLineInput {
49
+ /** A word or two; at most 40. Examples: `GST 5%`, `Shipping`, `Early-payment discount` */
50
+ readonly label: string;
51
+ /** Minor units (or `money()`). A discount is negative. */
52
+ readonly amount: Amount;
53
+ readonly role: 'tax' | 'discount' | 'shipping' | 'fee' | 'tip' | 'adjustment' | 'other';
54
+ /** Already inside the row prices (such as VAT): shown, never added. */
55
+ readonly included?: boolean;
56
+ }
57
+ /** A payment already made, such as a deposit: a negative amount, counted once, in the amount due. */
58
+ export interface ItemPaymentInput {
59
+ /** A word or two; at most 40. Example: `Deposit paid` */
60
+ readonly label: string;
61
+ /** Minor units (or `money()`), negative. */
62
+ readonly amount: Amount;
63
+ }
64
+ export interface ItemsInput {
65
+ /** ISO 4217 code with known minor units, such as `CAD`, `JPY` or `BHD`: one per component. */
66
+ readonly currency: string;
67
+ /** 1–100 rows, in order. */
68
+ readonly rows: readonly ItemRowInput[];
69
+ /** Optional caption: what the list is; at most 200. Example: `Invoice 2041` */
70
+ readonly label?: string;
71
+ /** Tax, discount, shipping, fee, tip and other lines, shown between the subtotal and the total. */
72
+ readonly lines?: readonly ItemLineInput[];
73
+ /** Payments already made, shown after the total and followed by the amount due. */
74
+ readonly payments?: readonly ItemPaymentInput[];
75
+ /** The totals lines' labels. Defaults: `Subtotal`, `Total`, `Amount due`. */
76
+ readonly labels?: {
77
+ readonly subtotal?: string;
78
+ readonly total?: string;
79
+ readonly due?: string;
80
+ };
81
+ /** `false` states no totals (a list to choose from); then `lines` and `payments` are not allowed. */
82
+ readonly totals?: boolean;
83
+ /** The person may choose rows: `one` or `many`. Needs `name`. */
84
+ readonly select?: 'one' | 'many';
85
+ /** The answer's name (`^[a-z][a-z0-9_]{0,55}$`), with `select` or a row `quantity`. */
86
+ readonly name?: string;
87
+ }
88
+ /** Default totals labels (proposed copy; see CHANGELOG). */
89
+ export declare const ITEMS_DEFAULT_LABELS: Readonly<{
90
+ subtotal: "Subtotal";
91
+ total: "Total";
92
+ due: "Amount due";
93
+ }>;
94
+ /** Internal: a refused builder input, named by its JSON pointer; nothing was sent. */
95
+ export declare function refuse(field: string, problem: string): never;
96
+ /** Internal: a value over its limit, in Sess's own sentence (`field`, `limit` and `length` set). */
97
+ export declare function tooLong(field: string, limit: number, length: number): never;
98
+ /** Internal: a non-blank, well-formed string of at most `max` code points (never truncated). */
99
+ export declare function text(value: unknown, field: string, max: number): string;
100
+ /** Internal: the JSON pointer token of a key (RFC 6901). */
101
+ export declare const token: (key: string) => string;
102
+ /**
103
+ * An amount in a currency's minor unit, checked: a whole number within ±10^15 and an ISO 4217
104
+ * code Sess accepts. `money(1250, 'USD')` is $12.50; `money(1250, 'JPY')` is ¥1,250;
105
+ * `money(1250, 'BHD')` is 1.250 BHD. It never rounds or converts: `money(12.5, 'USD')` throws.
106
+ */
107
+ export declare function money(amount: number, currency: string): Money;
108
+ /** Internal: `items()` at a pointer (`at` is the component's pointer in the request). */
109
+ export declare function buildItems(input: ItemsInput, at: string): ItemsComponent;
110
+ /**
111
+ * Builds an items component: rows in one currency, and the subtotal, total and amount due computed
112
+ * exactly from them, so Sess's arithmetic check passes. A bill with lines (tax, discount,
113
+ * shipping …) gets `Subtotal`, the lines and `Total`; with none, `Total` only; with payments, the
114
+ * payments and `Amount due` after the total. Amounts are whole minor units (`money()` checks
115
+ * one). Over a limit it throws a `SessError` (`code` `INVALID_SCHEMA`, `outcome` `not_sent`) whose
116
+ * `field` is the value's JSON pointer within the component, such as `/rows/3/name`; nothing is
117
+ * ever truncated. With a row `quantity`, put it in a Surface with a `request_change` action.
118
+ */
119
+ export declare function items(input: ItemsInput): ItemsComponent;
@@ -0,0 +1,280 @@
1
+ // Commerce: money and the items builder. The runtime's `items` component carries amounts as
2
+ // whole numbers in a currency's minor unit and checks the stated subtotal, total and amount due
3
+ // exactly; this builder computes them so a bill it returns passes that check. It never rounds,
4
+ // converts or formats: what you state is what is sent. Limits reject, never truncate, with the
5
+ // pointer and sentences of Sess's 400 INVALID_SCHEMA. Pure: no network, clock or I/O.
6
+ import { SessError, lengthMessage } from '../errors.js';
7
+ import { minorUnits } from './currency.js';
8
+ /**
9
+ * The runtime's items limits (Unicode code points for text): rows 1–100, totals lines ≤ 8, a row
10
+ * name ≤ 80, a detail ≤ 160, a totals label ≤ 40, a caption ≤ 200, a quantity unit ≤ 16, every
11
+ * amount within ±10^15 minor units, a quantity within 0–1,000,000.
12
+ */
13
+ export const ITEMS_LIMITS = Object.freeze({
14
+ rows: 100,
15
+ totals: 8,
16
+ name: 80,
17
+ detail: 160,
18
+ totalLabel: 40,
19
+ label: 200,
20
+ quantityUnit: 16,
21
+ amount: 1_000_000_000_000_000,
22
+ quantity: 1_000_000,
23
+ });
24
+ /** Default totals labels (proposed copy; see CHANGELOG). */
25
+ export const ITEMS_DEFAULT_LABELS = Object.freeze({
26
+ subtotal: 'Subtotal',
27
+ total: 'Total',
28
+ due: 'Amount due',
29
+ });
30
+ const ADDITIVE_ROLES = [
31
+ 'tax',
32
+ 'discount',
33
+ 'shipping',
34
+ 'fee',
35
+ 'tip',
36
+ 'adjustment',
37
+ 'other',
38
+ ];
39
+ const ANSWER_NAME = /^[a-z][a-z0-9_]{0,55}$/;
40
+ const AMOUNT_MAX = BigInt(ITEMS_LIMITS.amount);
41
+ const codePoints = (value) => [...value].length;
42
+ /** Internal: a refused builder input, named by its JSON pointer; nothing was sent. */
43
+ export function refuse(field, problem) {
44
+ // Pointers and problems only: caller values never enter the message.
45
+ const subject = field === '' ? 'The items component' : field;
46
+ throw new SessError('configuration', `${subject} ${problem}.`, {
47
+ code: 'INVALID_SCHEMA',
48
+ outcome: 'not_sent',
49
+ ...(field === '' ? {} : { field }),
50
+ });
51
+ }
52
+ /** Internal: a value over its limit, in Sess's own sentence (`field`, `limit` and `length` set). */
53
+ export function tooLong(field, limit, length) {
54
+ throw new SessError('configuration', lengthMessage(field, limit, length), {
55
+ code: 'INVALID_SCHEMA',
56
+ outcome: 'not_sent',
57
+ field,
58
+ limit,
59
+ length,
60
+ });
61
+ }
62
+ /** Internal: a non-blank, well-formed string of at most `max` code points (never truncated). */
63
+ export function text(value, field, max) {
64
+ if (typeof value !== 'string')
65
+ return refuse(field, 'must be string');
66
+ if (!value.isWellFormed())
67
+ refuse(field, 'must be well-formed Unicode');
68
+ const length = codePoints(value);
69
+ if (length > max)
70
+ tooLong(field, max, length);
71
+ if (!/\S/.test(value))
72
+ refuse(field, 'must not be blank');
73
+ return value;
74
+ }
75
+ /** Internal: the JSON pointer token of a key (RFC 6901). */
76
+ export const token = (key) => key.replace(/~/g, '~0').replace(/\//g, '~1');
77
+ function checkCurrency(currency, field) {
78
+ if (typeof currency !== 'string' || minorUnits(currency) === undefined)
79
+ refuse(field, 'is not an ISO 4217 currency code with known minor units; use one such as USD, EUR or JPY');
80
+ return currency;
81
+ }
82
+ function wholeAmount(amount, field) {
83
+ if (typeof amount !== 'number' || !Number.isInteger(amount))
84
+ return refuse(field, 'must be integer');
85
+ if (amount > ITEMS_LIMITS.amount)
86
+ refuse(field, `must be <= ${ITEMS_LIMITS.amount}`);
87
+ if (amount < -ITEMS_LIMITS.amount)
88
+ refuse(field, `must be >= ${-ITEMS_LIMITS.amount}`);
89
+ return amount === 0 ? 0 : amount; // -0 is sent as 0
90
+ }
91
+ /**
92
+ * An amount in a currency's minor unit, checked: a whole number within ±10^15 and an ISO 4217
93
+ * code Sess accepts. `money(1250, 'USD')` is $12.50; `money(1250, 'JPY')` is ¥1,250;
94
+ * `money(1250, 'BHD')` is 1.250 BHD. It never rounds or converts: `money(12.5, 'USD')` throws.
95
+ */
96
+ export function money(amount, currency) {
97
+ if (typeof currency !== 'string' || minorUnits(currency) === undefined)
98
+ throw new SessError('configuration', 'money(): the currency is not an ISO 4217 code with known minor units; use one such as USD, EUR or JPY.', { code: 'INVALID_SCHEMA', outcome: 'not_sent' });
99
+ if (typeof amount !== 'number' || !Number.isSafeInteger(amount) || Math.abs(amount) > ITEMS_LIMITS.amount)
100
+ throw new SessError('configuration', `money(): the amount must be a whole number of the currency's smallest unit (cents for USD, yen for JPY, fils for BHD), within ±${ITEMS_LIMITS.amount}: 1250 for 12.50 USD. Sess never rounds.`, { code: 'INVALID_SCHEMA', outcome: 'not_sent' });
101
+ return Object.freeze({ amount: amount === 0 ? 0 : amount, currency });
102
+ }
103
+ /** A stated amount in the component's currency: a number, or `money()` in the same currency. */
104
+ function amountOf(value, currency, field) {
105
+ if (value !== null && typeof value === 'object') {
106
+ const m = value;
107
+ if (m.currency !== currency)
108
+ refuse(field, 'is in another currency; an items component has one currency, so send it as its own items component');
109
+ return wholeAmount(m.amount, field);
110
+ }
111
+ return wholeAmount(value, field);
112
+ }
113
+ function quantityOf(raw, field) {
114
+ if (raw === null || typeof raw !== 'object')
115
+ return refuse(field, 'must be object');
116
+ const whole = (v, at) => {
117
+ if (typeof v !== 'number' || !Number.isInteger(v))
118
+ return refuse(at, 'must be integer');
119
+ if (v < 0)
120
+ refuse(at, 'must be >= 0');
121
+ if (v > ITEMS_LIMITS.quantity)
122
+ refuse(at, `must be <= ${ITEMS_LIMITS.quantity}`);
123
+ return v;
124
+ };
125
+ const value = whole(raw.value, `${field}/value`);
126
+ const min = raw.min === undefined ? undefined : whole(raw.min, `${field}/min`);
127
+ const max = raw.max === undefined ? undefined : whole(raw.max, `${field}/max`);
128
+ if ((min ?? 0) > (max ?? ITEMS_LIMITS.quantity))
129
+ refuse(`${field}/min`, 'is more than max');
130
+ if (value < (min ?? 0) || value > (max ?? ITEMS_LIMITS.quantity))
131
+ refuse(`${field}/value`, 'is not within min and max');
132
+ const unit = raw.unit === undefined ? undefined : text(raw.unit, `${field}/unit`, ITEMS_LIMITS.quantityUnit);
133
+ return {
134
+ value,
135
+ ...(unit === undefined ? {} : { unit }),
136
+ ...(min === undefined ? {} : { min }),
137
+ ...(max === undefined ? {} : { max }),
138
+ };
139
+ }
140
+ /** The exact sum of minor-unit amounts (BigInt, so no order of 100 amounts loses a unit). */
141
+ function sum(field, amounts) {
142
+ const total = amounts.reduce((s, a) => s + BigInt(a), 0n);
143
+ if (total > AMOUNT_MAX)
144
+ refuse(field, `must be <= ${ITEMS_LIMITS.amount}`);
145
+ if (total < -AMOUNT_MAX)
146
+ refuse(field, `must be >= ${-ITEMS_LIMITS.amount}`);
147
+ return Number(total);
148
+ }
149
+ /** Internal: `items()` at a pointer (`at` is the component's pointer in the request). */
150
+ export function buildItems(input, at) {
151
+ if (input === null || typeof input !== 'object')
152
+ return refuse(at, 'must be object');
153
+ const currency = checkCurrency(input.currency, `${at}/currency`);
154
+ const label = input.label === undefined ? undefined : text(input.label, `${at}/label`, ITEMS_LIMITS.label);
155
+ const sourceRows = input.rows;
156
+ if (!Array.isArray(sourceRows) || sourceRows.length < 1)
157
+ return refuse(`${at}/rows`, 'needs at least one row');
158
+ if (sourceRows.length > ITEMS_LIMITS.rows)
159
+ tooLong(`${at}/rows`, ITEMS_LIMITS.rows, sourceRows.length);
160
+ const rows = sourceRows.map((r, i) => {
161
+ const p = `${at}/rows/${i}`;
162
+ if (r === null || typeof r !== 'object')
163
+ return refuse(p, 'must be object');
164
+ const name = text(r.name, `${p}/name`, ITEMS_LIMITS.name);
165
+ // A reference goes in the detail line under the plain name, after any detail, so it reads as one.
166
+ const detail = r.detail === undefined ? undefined : text(r.detail, `${p}/detail`, ITEMS_LIMITS.detail);
167
+ const reference = r.reference === undefined ? undefined : text(r.reference, `${p}/detail`, ITEMS_LIMITS.detail);
168
+ const joined = reference === undefined
169
+ ? detail
170
+ : text(detail === undefined ? reference : `${detail} · ${reference}`, `${p}/detail`, ITEMS_LIMITS.detail);
171
+ const quantity = r.quantity === undefined ? undefined : quantityOf(r.quantity, `${p}/quantity`);
172
+ const amount = r.amount === null ? null : amountOf(r.amount, currency, `${p}/amount`);
173
+ return {
174
+ name,
175
+ ...(joined === undefined ? {} : { detail: joined }),
176
+ ...(quantity === undefined ? {} : { quantity }),
177
+ amount,
178
+ };
179
+ });
180
+ const editable = rows.some((r) => r.quantity !== undefined);
181
+ const select = input.select;
182
+ if (select !== undefined && select !== 'one' && select !== 'many')
183
+ refuse(`${at}/select`, 'must be one or many');
184
+ const answered = select !== undefined || editable;
185
+ if (input.name !== undefined && !answered)
186
+ refuse(`${at}/name`, 'applies only with select or editable; remove it');
187
+ if (answered && input.name === undefined)
188
+ refuse(at, 'has select or editable but no name; add a name for the answer');
189
+ if (input.name !== undefined && (typeof input.name !== 'string' || !ANSWER_NAME.test(input.name)))
190
+ refuse(`${at}/name`, `must match pattern "${ANSWER_NAME.source}"`);
191
+ // Totals: the subtotal is the rows; the total adds every line not already included; payments are
192
+ // counted once, in the amount due. Computed exactly, as Sess checks them.
193
+ const lines = input.lines ?? [];
194
+ const payments = input.payments ?? [];
195
+ if (!Array.isArray(lines))
196
+ refuse(`${at}/lines`, 'must be array');
197
+ if (!Array.isArray(payments))
198
+ refuse(`${at}/payments`, 'must be array');
199
+ const totals = [];
200
+ if (input.totals === false) {
201
+ if (lines.length || payments.length)
202
+ refuse(`${at}/totals`, 'is false, so a bill without totals has no lines or payments; remove them');
203
+ }
204
+ else {
205
+ const labels = input.labels ?? {};
206
+ const labelOf = (key, index) => labels[key] === undefined
207
+ ? ITEMS_DEFAULT_LABELS[key]
208
+ : text(labels[key], `${at}/totals/${index}/label`, ITEMS_LIMITS.totalLabel);
209
+ const count = (lines.length ? 1 : 0) + lines.length + 1 + (payments.length ? payments.length + 1 : 0);
210
+ if (count > ITEMS_LIMITS.totals)
211
+ tooLong(`${at}/totals`, ITEMS_LIMITS.totals, count);
212
+ const subtotal = sum(`${at}/rows`, rows.map((r) => r.amount ?? 0));
213
+ if (lines.length)
214
+ totals.push({ label: labelOf('subtotal', 0), amount: subtotal, role: 'subtotal' });
215
+ for (const line of lines) {
216
+ const p = `${at}/totals/${totals.length}`;
217
+ if (line === null || typeof line !== 'object')
218
+ refuse(p, 'must be object');
219
+ const lineLabel = text(line.label, `${p}/label`, ITEMS_LIMITS.totalLabel);
220
+ if (!ADDITIVE_ROLES.includes(line.role))
221
+ refuse(`${p}/role`, `must be one of ${ADDITIVE_ROLES.join(', ')}`);
222
+ const amount = amountOf(line.amount, currency, `${p}/amount`);
223
+ if (line.role === 'discount' && amount > 0)
224
+ refuse(`${p}/amount`, 'is a discount, so it is negative; state it with a minus sign');
225
+ if (line.included !== undefined && typeof line.included !== 'boolean')
226
+ refuse(`${p}/included`, 'must be boolean');
227
+ totals.push({
228
+ label: lineLabel,
229
+ amount,
230
+ role: line.role,
231
+ ...(line.included === undefined ? {} : { included: line.included }),
232
+ });
233
+ }
234
+ const added = totals.filter((t) => t.role !== 'subtotal' && t.included !== true).map((t) => t.amount);
235
+ const total = sum(`${at}/totals`, [subtotal, ...added]);
236
+ totals.push({ label: labelOf('total', totals.length), amount: total, role: 'total' });
237
+ if (payments.length) {
238
+ const paid = [];
239
+ for (const payment of payments) {
240
+ const p = `${at}/totals/${totals.length}`;
241
+ if (payment === null || typeof payment !== 'object')
242
+ refuse(p, 'must be object');
243
+ const paymentLabel = text(payment.label, `${p}/label`, ITEMS_LIMITS.totalLabel);
244
+ const amount = amountOf(payment.amount, currency, `${p}/amount`);
245
+ if (amount > 0)
246
+ refuse(`${p}/amount`, 'is a payment, so it is negative; state it with a minus sign');
247
+ paid.push(amount);
248
+ totals.push({ label: paymentLabel, amount, role: 'paid' });
249
+ }
250
+ totals.push({
251
+ label: labelOf('due', totals.length),
252
+ amount: sum(`${at}/totals`, [total, ...paid]),
253
+ role: 'due',
254
+ });
255
+ }
256
+ }
257
+ // Canonical member order, as Sess stores the component.
258
+ return {
259
+ type: 'items',
260
+ ...(label === undefined ? {} : { label }),
261
+ currency,
262
+ ...(select === undefined ? {} : { select }),
263
+ ...(editable ? { editable: ['quantity'] } : {}),
264
+ ...(input.name === undefined ? {} : { name: input.name }),
265
+ rows,
266
+ ...(totals.length ? { totals } : {}),
267
+ };
268
+ }
269
+ /**
270
+ * Builds an items component: rows in one currency, and the subtotal, total and amount due computed
271
+ * exactly from them, so Sess's arithmetic check passes. A bill with lines (tax, discount,
272
+ * shipping …) gets `Subtotal`, the lines and `Total`; with none, `Total` only; with payments, the
273
+ * payments and `Amount due` after the total. Amounts are whole minor units (`money()` checks
274
+ * one). Over a limit it throws a `SessError` (`code` `INVALID_SCHEMA`, `outcome` `not_sent`) whose
275
+ * `field` is the value's JSON pointer within the component, such as `/rows/3/name`; nothing is
276
+ * ever truncated. With a row `quantity`, put it in a Surface with a `request_change` action.
277
+ */
278
+ export function items(input) {
279
+ return buildItems(input, '');
280
+ }
@@ -0,0 +1,16 @@
1
+ /** One pipe table found in a text. */
2
+ export interface TextLintFinding {
3
+ readonly rule: 'pipe-table';
4
+ /** The 1-based line where the table starts. */
5
+ readonly line: number;
6
+ /** What to send instead: `items` for amounts, `record` for other rows. */
7
+ readonly use: 'items' | 'record';
8
+ readonly message: string;
9
+ }
10
+ /**
11
+ * Finds Markdown pipe tables in a text: a header row with pipes followed by a delimiter row
12
+ * (`|---|---|`), or two or more consecutive rows drawn between pipes (`| a | b |`). Each finding
13
+ * says where the table starts and what to send instead: an items component for prices, or a
14
+ * record for other rows. Returns an empty list for ordinary text.
15
+ */
16
+ export declare function lintText(text: string): TextLintFinding[];
@@ -0,0 +1,56 @@
1
+ // Commerce: a text lint for Markdown pipe tables. Sess shows text exactly as written (plain text,
2
+ // never markup), so a table drawn with pipes reaches the person as a wall of `|` and `---`. Prices
3
+ // belong in an items component; other rows of facts in a record. Pure: no I/O.
4
+ // A GFM delimiter row: `| --- | :---: |`, `---|---`, `| --- |`.
5
+ const DELIMITER = /^\s*\|?\s*:?-+:?\s*(?:\|\s*:?-+:?\s*)*\|?\s*$/;
6
+ // Amount-like content: a currency symbol, an ISO-style code beside a number, a two- or three-place
7
+ // decimal, or a price word in the header.
8
+ const MONEY = /[$€£¥₹₩₽₺₪₫฿]|\b[A-Z]{3}\s?-?\d|\d\s?[A-Z]{3}\b|\d[.,]\d{2,3}\b/;
9
+ const PRICE_WORDS = /\b(?:price|amount|total|subtotal|cost|tax|vat|fee|qty|quantity)\b/i;
10
+ /** The cells of a line split on unescaped pipes, or null when it has no pipe. */
11
+ function cells(line) {
12
+ const parts = line.split(/(?<!\\)\|/);
13
+ return parts.length > 1 ? parts : null;
14
+ }
15
+ const bordered = (line) => /^\s*\|.*\|\s*$/.test(line) && (cells(line)?.length ?? 0) >= 3;
16
+ /**
17
+ * Finds Markdown pipe tables in a text: a header row with pipes followed by a delimiter row
18
+ * (`|---|---|`), or two or more consecutive rows drawn between pipes (`| a | b |`). Each finding
19
+ * says where the table starts and what to send instead: an items component for prices, or a
20
+ * record for other rows. Returns an empty list for ordinary text.
21
+ */
22
+ export function lintText(text) {
23
+ if (typeof text !== 'string')
24
+ return [];
25
+ const lines = text.split(/\r\n|\r|\n/);
26
+ const findings = [];
27
+ let i = 0;
28
+ while (i < lines.length) {
29
+ const line = lines[i];
30
+ const next = lines[i + 1];
31
+ const headed = cells(line) !== null &&
32
+ next !== undefined &&
33
+ next.includes('-') &&
34
+ DELIMITER.test(next) &&
35
+ next.includes('|');
36
+ const drawn = bordered(line) && next !== undefined && bordered(next);
37
+ if (!headed && !drawn) {
38
+ i += 1;
39
+ continue;
40
+ }
41
+ let end = i + (headed ? 2 : 1);
42
+ while (end < lines.length && cells(lines[end]) !== null && /\S/.test(lines[end]))
43
+ end += 1;
44
+ const use = lines.slice(i, end).some((l) => MONEY.test(l) || PRICE_WORDS.test(l)) ? 'items' : 'record';
45
+ findings.push({
46
+ rule: 'pipe-table',
47
+ line: i + 1,
48
+ use,
49
+ message: use === 'items'
50
+ ? `Line ${i + 1} starts a Markdown table. Sess shows text as written, so the person would see the pipes. For prices, send an items component instead.`
51
+ : `Line ${i + 1} starts a Markdown table. Sess shows text as written, so the person would see the pipes. For rows of facts, send a record component instead.`,
52
+ });
53
+ i = end;
54
+ }
55
+ return findings;
56
+ }
package/dist/errors.d.ts CHANGED
@@ -55,4 +55,3 @@ export declare class SessError extends Error {
55
55
  export declare function lengthMessage(field: string, limit: number, length: number): string;
56
56
  /** Internal: keep private creation capabilities out of inspection and serialization. */
57
57
  export declare function attachRecovery(error: SessError, value: CreateSessionResponse): void;
58
- //# sourceMappingURL=errors.d.ts.map
package/dist/errors.js CHANGED
@@ -64,10 +64,14 @@ export function lengthMessage(field, limit, length) {
64
64
  // `sess.ask()` question) has its own.
65
65
  if (field === '/interaction/title' || field === '/question')
66
66
  return `The title can be at most ${limit} characters. Keep it to a short heading, about 40.`;
67
+ // Commerce: an items component's rows and totals lines are counted, never truncated.
68
+ if (/\/rows$/.test(field))
69
+ return `${field} has ${length} rows; the limit is ${limit}. Send at most ${limit}, in more than one items component if you need more.`;
70
+ if (/\/totals$/.test(field))
71
+ return `${field} has ${length} totals lines; the limit is ${limit}. Send at most ${limit}.`;
67
72
  return `${field} is ${length} characters; the limit is ${limit}. Shorten it to at most ${limit} characters.`;
68
73
  }
69
74
  /** Internal: keep private creation capabilities out of inspection and serialization. */
70
75
  export function attachRecovery(error, value) {
71
76
  recovery.set(error, Object.freeze({ ...value }));
72
77
  }
73
- //# sourceMappingURL=errors.js.map
@@ -829,7 +829,7 @@ export interface paths {
829
829
  };
830
830
  get?: never;
831
831
  put?: never;
832
- /** @description P2-13 V3 / P2-11, step 1 of "Keep your receipt" (DOCS/spec/keep-v1.md). The human link is the capability; never log it. Sent by the receipt card’s same-origin script after the person taps Keep: Sec-Fetch-Site same-origin (or, without Fetch Metadata, an Origin equal to the page’s origin), application/json, at most 65536 bytes, at most 128 grants. Each round is authorized only by its own receipt-scoped Keep grant: the Session, a receipt list or another round’s grant never authorize it. Reads one Session snapshot (its Event sequence cutoff) and, when some authorized receipt in custody has no holder yet, records one fresh challenge (5 minutes) bound to exactly that batch. Headers as every /s/* response (no-store, no-referrer, noindex, no CORS). */
832
+ /** @description P2-13 V3 / P2-11, step 1 of "Keep your receipt" (the Sess keep-v1 specification). The human link is the capability; never log it. Sent by the receipt card’s same-origin script after the person taps Keep: Sec-Fetch-Site same-origin (or, without Fetch Metadata, an Origin equal to the page’s origin), application/json, at most 65536 bytes, at most 128 grants. Each round is authorized only by its own receipt-scoped Keep grant: the Session, a receipt list or another round’s grant never authorize it. Reads one Session snapshot (its Event sequence cutoff) and, when some authorized receipt in custody has no holder yet, records one fresh challenge (5 minutes) bound to exactly that batch. Headers as every /s/* response (no-store, no-referrer, noindex, no CORS). */
833
833
  post: operations['createKeepChallenge'];
834
834
  delete?: never;
835
835
  options?: never;
@@ -846,7 +846,7 @@ export interface paths {
846
846
  };
847
847
  get?: never;
848
848
  put?: never;
849
- /** @description P2-13 V3 / P2-11, step 2: the kept-conversation file (DOCS/spec/keep-v1.md), the one bounded, versioned file the person saves — every authorized accepted round of the Session through the snapshot cutoff with its unchanged receipt and bundle (or content unavailable once purged), preservation status (the witness state at snapshot time, with the evidence attached by then), holder status and an inventory. Same request checks as the challenge. With `enrollment`, first enrolls one fresh holder key per receipt of the challenge’s exact batch (or only its final receipt: the disclosed fallback): every proof is checked, then all enrollments and the challenge’s consumption commit atomically; the same request again is an idempotent replay, a different one is refused, a receipt keeps its first holder and a key holds one receipt. Without `enrollment` (key generation or storage failed, or nothing to enrol) the file is exported with every round marked unenrolled: export never depends on enrollment. The file holds no private key, grant secret or Sess link. Content-Disposition: attachment. */
849
+ /** @description P2-13 V3 / P2-11, step 2: the kept-conversation file (the Sess keep-v1 specification), the one bounded, versioned file the person saves — every authorized accepted round of the Session through the snapshot cutoff with its unchanged receipt and bundle (or content unavailable once purged), preservation status (the witness state at snapshot time, with the evidence attached by then), holder status and an inventory. Same request checks as the challenge. With `enrollment`, first enrolls one fresh holder key per receipt of the challenge’s exact batch (or only its final receipt: the disclosed fallback): every proof is checked, then all enrollments and the challenge’s consumption commit atomically; the same request again is an idempotent replay, a different one is refused, a receipt keeps its first holder and a key holds one receipt. Without `enrollment` (key generation or storage failed, or nothing to enrol) the file is exported with every round marked unenrolled: export never depends on enrollment. The file holds no private key, grant secret or Sess link. Content-Disposition: attachment. */
850
850
  post: operations['keepConversation'];
851
851
  delete?: never;
852
852
  options?: never;
@@ -863,7 +863,7 @@ export interface paths {
863
863
  };
864
864
  get?: never;
865
865
  put?: never;
866
- /** @description P2-15 PR-B, Save to Sess from a human page on another origin than /personal (DOCS/spec/personal-copies-v1.md §7). The Sess link is the capability; never log it. Sent by the receipt card’s same-origin script once the Save sheet on the personal origin is signed in and has sent its destination binding: Sec-Fetch-Site same-origin (or an Origin equal to the page’s), application/json, at most 65536 bytes, rate limited per link. Records one pending claim bound to the rounds the presented Keep grants authorize now, exactly as Keep reads them (restricted or deleted rounds never included; no client-chosen IDs), their cutoff, a fresh 256-bit transfer secret (stored as its hash), the purpose, the personal origin, the source verifier’s challenge and the destination binding. The claim expires in 5 minutes. Nothing is saved until the sheet redeems it. Headers as every /s/* response. */
866
+ /** @description P2-15 PR-B, Save to Sess from a human page on another origin than /personal (the Sess personal-copies-v1 specification §7). The Sess link is the capability; never log it. Sent by the receipt card’s same-origin script once the Save sheet on the personal origin is signed in and has sent its destination binding: Sec-Fetch-Site same-origin (or an Origin equal to the page’s), application/json, at most 65536 bytes, rate limited per link. Records one pending claim bound to the rounds the presented Keep grants authorize now, exactly as Keep reads them (restricted or deleted rounds never included; no client-chosen IDs), their cutoff, a fresh 256-bit transfer secret (stored as its hash), the purpose, the personal origin, the source verifier’s challenge and the destination binding. The claim expires in 5 minutes. Nothing is saved until the sheet redeems it. Headers as every /s/* response. */
867
867
  post: operations['createSaveClaim'];
868
868
  delete?: never;
869
869
  options?: never;
@@ -931,7 +931,7 @@ export interface paths {
931
931
  };
932
932
  get?: never;
933
933
  put?: never;
934
- /** @description P2-12: the payment provider’s signed asynchronous events (provider-to-Sess only; DOCS/spec/billing-provider-v1.md). The signature header is verified over the exact raw body (at most 256 KiB, timestamp within 300 s) before the body is parsed. Each event id is processed once (a duplicate is acknowledged without effect); older subscription states never replace newer ones; unknown event types are acknowledged and ignored. Not configured → 404. */
934
+ /** @description P2-12: the payment provider’s signed asynchronous events (provider-to-Sess only; the Sess billing-provider-v1 specification). The signature header is verified over the exact raw body (at most 256 KiB, timestamp within 300 s) before the body is parsed. Each event id is processed once (a duplicate is acknowledged without effect); older subscription states never replace newer ones; unknown event types are acknowledged and ignored. Not configured → 404. */
935
935
  post: operations['receiveBillingProviderEvent'];
936
936
  delete?: never;
937
937
  options?: never;
@@ -1032,7 +1032,7 @@ export interface paths {
1032
1032
  path?: never;
1033
1033
  cookie?: never;
1034
1034
  };
1035
- /** @description The deliberate export of one accepted response as a bundle-v1 disclosure (DOCS/spec/bundle-v1.md): its stored receipt exactly as issued, the complete normalized Surface of the revision it was accepted on, the accepted data, and the current public receipt keys. Never a private key, owner credential or Sess link. Anyone holding the bundle can verify it (POST /v1/receipts/verify, or offline with trusted keys); share it only with whom you mean to show the decision. Read-only. Cache-Control: no-store, no-transform; Referrer-Policy: no-referrer. */
1035
+ /** @description The deliberate export of one accepted response as a bundle-v1 disclosure (the Sess bundle-v1 specification): its stored receipt exactly as issued, the complete normalized Surface of the revision it was accepted on, the accepted data, and the current public receipt keys. Never a private key, owner credential or Sess link. Anyone holding the bundle can verify it (POST /v1/receipts/verify, or offline with trusted keys); share it only with whom you mean to show the decision. Read-only. Cache-Control: no-store, no-transform; Referrer-Policy: no-referrer. */
1036
1036
  get: operations['exportDecisionBundle'];
1037
1037
  put?: never;
1038
1038
  post?: never;
@@ -1068,7 +1068,7 @@ export interface paths {
1068
1068
  };
1069
1069
  get?: never;
1070
1070
  put?: never;
1071
- /** @description Public, no credential. Verifies an archival envelope (DOCS/spec/archival-core-v1.md §3) with the successor archival verifier against this server's own configuration only: its published receipt keys, its receipt issuer as the expected context issuer, its published witness key set (/.well-known/sess-witness-keys.json) and, when configured, its TUF-verified witness trusted root. Nothing in the request is trusted. It reports the independent dimensions of archival-core-v1 §5 (signature, contents, context, witness, key_trust, live_expiry) with the same statuses and reasons as @sess.si/sdk/archival, and their presentation. The body is the envelope only: contents is therefore unverifiable: content_unavailable (verify a bundle-v1 at /v1/receipts/verify for content), and context is at most incomplete (application_context_unchecked). Without a witness trusted root, attached evidence is indeterminate: witness_trust_unavailable. It looks nothing up and stores nothing. A malformed or oversized envelope is a 200 result. The bundle route is unchanged. Body: application/json, at most 2097152 bytes (413 above); 65,536 bytes envelope bound (reason oversized). The same per-client and total rate limits as /v1/receipts/verify, shared with it (429 RATE_LIMITED with Retry-After), and the same absolute 2-second deadline from the request's arrival (503 SERVICE_UNAVAILABLE with Connection: close). Cache-Control: no-store, no-transform; Referrer-Policy: no-referrer; CORS only for the product site origins. Never put an envelope or receipt in a URL. */
1071
+ /** @description Public, no credential. Verifies an archival envelope (the Sess archival-core-v1 specification §3) with the successor archival verifier against this server's own configuration only: its published receipt keys, its receipt issuer as the expected context issuer, its published witness key set (/.well-known/sess-witness-keys.json) and, when configured, its TUF-verified witness trusted root. Nothing in the request is trusted. It reports the independent dimensions of archival-core-v1 §5 (signature, contents, context, witness, key_trust, live_expiry) with the same statuses and reasons as @sess.si/sdk/archival, and their presentation. The body is the envelope only: contents is therefore unverifiable: content_unavailable (verify a bundle-v1 at /v1/receipts/verify for content), and context is at most incomplete (application_context_unchecked). Without a witness trusted root, attached evidence is indeterminate: witness_trust_unavailable. It looks nothing up and stores nothing. A malformed or oversized envelope is a 200 result. The bundle route is unchanged. Body: application/json, at most 2097152 bytes (413 above); 65,536 bytes envelope bound (reason oversized). The same per-client and total rate limits as /v1/receipts/verify, shared with it (429 RATE_LIMITED with Retry-After), and the same absolute 2-second deadline from the request's arrival (503 SERVICE_UNAVAILABLE with Connection: close). Cache-Control: no-store, no-transform; Referrer-Policy: no-referrer; CORS only for the product site origins. Never put an envelope or receipt in a URL. */
1072
1072
  post: operations['verifyArchivalEnvelope'];
1073
1073
  delete?: never;
1074
1074
  options?: never;
@@ -1288,7 +1288,7 @@ export interface paths {
1288
1288
  path?: never;
1289
1289
  cookie?: never;
1290
1290
  };
1291
- /** @description P2-13 V5: the status of one custody record of the owner workspace (from the credential only), never its content: available, restricted (with its reason code and since when) or deleted (with its reason code and deletion time). A restricted or deleted record is excluded from the list, the export, its bundle and every other receipt-scoped fetch; a restricted one stays verifiable for preservation integrity. Restriction, holds and deletion are decided by the operator through the recorded procedure (DOCS/spec/custody-restriction-deletion-v1.md); holds are not shown here. A deletion does not recall exported copies or files people already kept, and the public witness commitment (an aggregate batch root) remains. Another workspace’s record, or an unknown event ID, is 404. Cache-Control: no-store, no-transform. */
1291
+ /** @description P2-13 V5: the status of one custody record of the owner workspace (from the credential only), never its content: available, restricted (with its reason code and since when) or deleted (with its reason code and deletion time). A restricted or deleted record is excluded from the list, the export, its bundle and every other receipt-scoped fetch; a restricted one stays verifiable for preservation integrity. Restriction, holds and deletion are decided by the operator through the recorded procedure (the Sess custody-restriction-deletion-v1 specification); holds are not shown here. A deletion does not recall exported copies or files people already kept, and the public witness commitment (an aggregate batch root) remains. Another workspace’s record, or an unknown event ID, is 404. Cache-Control: no-store, no-transform. */
1292
1292
  get: operations['getEvidenceRecordStatus'];
1293
1293
  put?: never;
1294
1294
  post?: never;
@@ -1322,7 +1322,7 @@ export interface paths {
1322
1322
  path?: never;
1323
1323
  cookie?: never;
1324
1324
  };
1325
- /** @description Decision 0009 Amendment 13: the renderer identities Sess signs receipts under (the values of a receipt’s surface.renderer_version), as one JWS signed with the receipt keys, in the RFC 7515 flattened JSON serialization {protected, payload, signature} (joined with dots they are its compact form). Protected header {alg EdDSA, kid, typ sess-renderer-identities+jwt}; payload the RFC 8785 canonical JSON {sess_renderer_identities: 1, iss: the receipt issuer, seq: the list edition (an integer, higher in every later published edition), iat: when this copy was signed (NumericDate), identities: [{renderer_version, since: the UTC date it was added}]}; the signature covers seq and iat. Order authentic lists by seq, with containment as the cross-check; an older list still proves the identities it contains. Verify it with GET /.well-known/sess-receipt-keys.json (the key its kid names) and the expected issuer; a receipt verifies when its renderer_version is on a list whose signature verifies. The list only grows: an identity is never removed, reordered or reused, so every receipt issued keeps verifying (sess-html-form-1 is always on it). DOCS/spec/receipt-v1.md §10. No credential. 503 SERVICE_UNAVAILABLE while the receipt keys are not configured. Cache-Control: no-store, no-transform. */
1325
+ /** @description Decision 0009 Amendment 13: the renderer identities Sess signs receipts under (the values of a receipt’s surface.renderer_version), as one JWS signed with the receipt keys, in the RFC 7515 flattened JSON serialization {protected, payload, signature} (joined with dots they are its compact form). Protected header {alg EdDSA, kid, typ sess-renderer-identities+jwt}; payload the RFC 8785 canonical JSON {sess_renderer_identities: 1, iss: the receipt issuer, seq: the list edition (an integer, higher in every later published edition), iat: when this copy was signed (NumericDate), identities: [{renderer_version, since: the UTC date it was added}]}; the signature covers seq and iat. Order authentic lists by seq, with containment as the cross-check; an older list still proves the identities it contains. Verify it with GET /.well-known/sess-receipt-keys.json (the key its kid names) and the expected issuer; a receipt verifies when its renderer_version is on a list whose signature verifies. The list only grows: an identity is never removed, reordered or reused, so every receipt issued keeps verifying (sess-html-form-1 is always on it). the Sess receipt-v1 specification §10. No credential. 503 SERVICE_UNAVAILABLE while the receipt keys are not configured. Cache-Control: no-store, no-transform. */
1326
1326
  get: operations['rendererIdentities'];
1327
1327
  put?: never;
1328
1328
  post?: never;
@@ -1339,7 +1339,7 @@ export interface paths {
1339
1339
  path?: never;
1340
1340
  cookie?: never;
1341
1341
  };
1342
- /** @description The issuer’s published witness key set (DOCS/spec/witness-evidence-v1.md §5.1): the public ECDSA P-256 keys that sign witness checkpoints, each with its validity window. The current key has valid_to null; a rotated-out key is kept with its closed window, so evidence it signed stays verifiable. Read with parseWitnessKeySet and pass as the witnessKeys anchor of verifyWitnessEvidence, beside an independently distributed trusted root. Public keys only. No credential. Empty keys when no witness key is configured; 503 SERVICE_UNAVAILABLE when a configured key set is unusable (it is never trimmed or served empty). Cache-Control: no-store, no-transform. */
1342
+ /** @description The issuer’s published witness key set (the Sess witness-evidence-v1 specification §5.1): the public ECDSA P-256 keys that sign witness checkpoints, each with its validity window. The current key has valid_to null; a rotated-out key is kept with its closed window, so evidence it signed stays verifiable. Read with parseWitnessKeySet and pass as the witnessKeys anchor of verifyWitnessEvidence, beside an independently distributed trusted root. Public keys only. No credential. Empty keys when no witness key is configured; 503 SERVICE_UNAVAILABLE when a configured key set is unusable (it is never trimmed or served empty). Cache-Control: no-store, no-transform. */
1343
1343
  get: operations['witnessKeys'];
1344
1344
  put?: never;
1345
1345
  post?: never;
@@ -2074,12 +2074,12 @@ export interface components {
2074
2074
  x: string;
2075
2075
  y: string;
2076
2076
  };
2077
- /** @description base64url of the 64-byte ECDSA P-256 SHA-256 signature (IEEE P1363) over the holder proof message (DOCS/spec/keep-v1.md §3). */
2077
+ /** @description base64url of the 64-byte ECDSA P-256 SHA-256 signature (IEEE P1363) over the holder proof message (the Sess keep-v1 specification §3). */
2078
2078
  proof: string;
2079
2079
  }[];
2080
2080
  };
2081
2081
  };
2082
- /** @description The kept conversation (DOCS/spec/keep-v1.md): every authorized accepted round of the Session through the snapshot cutoff, each with its unchanged receipt-v1, its bundle-v1 while the content is retained (else unavailable, never reconstructed), its preservation status and holder status, plus an inventory. No private key, grant secret or Sess link. Each extracted bundle verifies with the unchanged bundle-v1 verifier. */
2082
+ /** @description The kept conversation (the Sess keep-v1 specification): every authorized accepted round of the Session through the snapshot cutoff, each with its unchanged receipt-v1, its bundle-v1 while the content is retained (else unavailable, never reconstructed), its preservation status and holder status, plus an inventory. No private key, grant secret or Sess link. Each extracted bundle verifies with the unchanged bundle-v1 verifier. */
2083
2083
  KeptConversation: {
2084
2084
  /** @constant */
2085
2085
  type: 'sess.kept-conversation';
@@ -2159,7 +2159,7 @@ export interface components {
2159
2159
  status: 'preserved';
2160
2160
  /** @description The witness state at snapshot time (the custody witness job: `pending` until a witness attaches, then e.g. `witnessed`); the envelope carries the evidence attached by then. */
2161
2161
  witness: string;
2162
- /** @description The archival envelope (DOCS/spec/archival-core-v1.md). */
2162
+ /** @description The archival envelope (the Sess archival-core-v1 specification). */
2163
2163
  archival_envelope: {
2164
2164
  [key: string]: unknown;
2165
2165
  };
@@ -8358,4 +8358,3 @@ export interface operations {
8358
8358
  };
8359
8359
  };
8360
8360
  }
8361
- //# sourceMappingURL=openapi.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=openapi.js.map
package/dist/index.d.ts CHANGED
@@ -3,4 +3,9 @@ export { SessError } from './errors.js';
3
3
  export type { SessErrorKind, SessErrorDetails, WriteOutcome } from './errors.js';
4
4
  export type { AskAnswer, AskAnswerOptions, AskField, AskHandle, AskInput, AskOptions } from './ask.js';
5
5
  export * from './types.js';
6
- //# sourceMappingURL=index.d.ts.map
6
+ export { ITEMS_DEFAULT_LABELS, ITEMS_LIMITS, items, money } from './commerce/items.js';
7
+ export type { Amount, ItemLineInput, ItemPaymentInput, ItemRowInput, ItemsInput, Money, } from './commerce/items.js';
8
+ export { COMMERCE_DEFAULTS, invoice, purchaseOrder, quote, receipt, refund } from './commerce/builders.js';
9
+ export type { BillInput, RefundInput } from './commerce/builders.js';
10
+ export { lintText } from './commerce/lint.js';
11
+ export type { TextLintFinding } from './commerce/lint.js';