@percayso-community/cayso-contracts 0.27.0 → 0.29.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.
@@ -326,6 +326,21 @@
326
326
  * credential minted to place a quote must not thereby move cents to somebody without
327
327
  * a match, nor the reverse. It is served at `ROUTES.citizenTransfer`.
328
328
  *
329
+ * `'change-handle'` is a Citizen's Handle change, charged by Cayso (CAY-0091). It is
330
+ * not a second use of `'make-citizen-transfer'`, which pays another Citizen, nor of
331
+ * `'settle-marketplace-order'`, which presents Store Platform's signed order: a Handle
332
+ * change charges the Citizen for a Community service on the authority of a change
333
+ * reference Percayso ID minted. A credential minted for any other operation must not
334
+ * authorise a Handle change, and the reverse. It is served at `ROUTES.handleChange`,
335
+ * and it charges for the change reference named by
336
+ * {@link AssertionClaims.handleChangeReference} and no other.
337
+ *
338
+ * `'read-handle-change-receipt'` asks whether a change reference was charged
339
+ * (CAY-0091), as `'read-marketplace-receipt'` asks of a checkout key. It is its own
340
+ * operation because it is a read beside the money-grade charge it reports on: a
341
+ * credential minted to ask what happened must not thereby be able to make something
342
+ * happen. It is served at `ROUTES.handleChangeReceipt`.
343
+ *
329
344
  * `'place-quote'`, `'withdraw-quote'` and `'request-buy-back'` are the citizen
330
345
  * market's three acts (CAY-0080, Open decision Q). They are three operations
331
346
  * because they are three acts: a credential minted to withdraw a quote must not
@@ -370,7 +385,7 @@
370
385
  * Contribution Store's assertion, which no person presents and which therefore has
371
386
  * no operation here. It is classified before it is served.
372
387
  */
373
- export type ContractOperation = 'read-own-wallet' | 'read-purchase-result' | 'authorise-purchase' | 'cancel-purchase' | 'provision-citizenship' | 'read-own-citizenship' | 'provision-organisation' | 'claim-founder-wallet' | 'make-commercial-payment' | 'make-citizen-transfer' | 'place-quote' | 'withdraw-quote' | 'request-buy-back' | 'read-citizen-market' | 'read-marketplace-receipt' | 'settle-marketplace-order' | 'settle-marketplace-refund' | 'present-standing-authorisation';
388
+ export type ContractOperation = 'read-own-wallet' | 'read-purchase-result' | 'authorise-purchase' | 'cancel-purchase' | 'provision-citizenship' | 'read-own-citizenship' | 'provision-organisation' | 'claim-founder-wallet' | 'make-commercial-payment' | 'make-citizen-transfer' | 'change-handle' | 'read-handle-change-receipt' | 'place-quote' | 'withdraw-quote' | 'request-buy-back' | 'read-citizen-market' | 'read-marketplace-receipt' | 'settle-marketplace-order' | 'settle-marketplace-refund' | 'present-standing-authorisation';
374
389
  /**
375
390
  * An operation key belonging to a deployment's OWN surfaces rather than to this
376
391
  * contract — operator work, above all. Deliberately not enumerated: this package
@@ -839,6 +854,42 @@ export interface AssertionClaims {
839
854
  * of work.
840
855
  */
841
856
  readonly founderClaimReference?: string;
857
+ /**
858
+ * The change reference: the single-use, opaque value Percayso ID issued when it
859
+ * reserved the Citizen's proposed Handle (CAY-0091). OPTIONAL on the wire, and read by
860
+ * `'change-handle'` and `'read-handle-change-receipt'` and by no other operation.
861
+ *
862
+ * ## It travels with its operations, in both directions
863
+ *
864
+ * As {@link founderClaimReference} does. A credential whose `scope` carries
865
+ * `'change-handle'` or `'read-handle-change-receipt'` must carry this claim, and a
866
+ * credential that carries this claim must be scoped to one of them. A verifier refuses
867
+ * either half missing as a malformed credential, before any gate reads it: a Handle
868
+ * change with no reference charges for nothing, and a reference carried to any other
869
+ * operation is half of a Handle change put in front of a route with no business
870
+ * reading it.
871
+ *
872
+ * ## It is carried here and never in a request
873
+ *
874
+ * The reference fixes the new Handle BEFORE the charge, so a receipt cannot be spent
875
+ * on a different name. A reference named in a body would be the caller's claim about
876
+ * which Handle change is theirs (CAY-0021); inside the signed assertion it is Percayso
877
+ * ID's statement. Cayso charges at most once per reference, keys the charge by it, and
878
+ * names it in the signed receipt.
879
+ *
880
+ * ## What it is not
881
+ *
882
+ * It is NOT the Handle. Cayso never learns the Handle: the reference is opaque, and
883
+ * Cayso compares it and never parses it. It is not derived from a Percayso identity,
884
+ * and it carries no `sub`, no name and no email. This contract asks for a non-empty
885
+ * string and nothing more.
886
+ *
887
+ * ## It is as trustworthy as the verifier, and no more
888
+ *
889
+ * As with every claim: declaring it makes the promise structural, and a real
890
+ * signature check is what makes it trustworthy.
891
+ */
892
+ readonly handleChangeReference?: string;
842
893
  /**
843
894
  * The Organisation **Wallet IDs** this identity holds the mandate for
844
895
  * (CAY-0024, CAY-0059 §7). Each entry is a wallet id — the opaque identifier
package/dist/assurance.js CHANGED
@@ -343,6 +343,33 @@ export const ASSURANCE_POLICY = {
343
343
  'anything but the development bypass. An unverified holder must never be able to send, ' +
344
344
  'because sending is how value reaches somebody else.',
345
345
  },
346
+ // A Citizen paying Cayso to change their Handle (CAY-0091). Money-grade, at the
347
+ // Citizen transfer's bar: value leaves the holder, and the payment is what lets
348
+ // Percayso ID change a public name, so an unverified holder must not be able to
349
+ // make it. An allowlist, so a future method is admissible only when somebody
350
+ // decides it here.
351
+ 'change-handle': {
352
+ operation: 'change-handle',
353
+ assurance: 'required',
354
+ decisions: {
355
+ // Asserts nothing; permanently refused wherever "identity-verified" is meant.
356
+ 'dev-bypass': 'refused',
357
+ document: 'accepted',
358
+ 'document-and-biometric': 'accepted',
359
+ },
360
+ rationale: "A Handle change charges the Citizen's own Citizen Wallet, so it is money-grade: anything " +
361
+ 'but the development bypass. The receipt it answers with lets Percayso ID change a ' +
362
+ 'Handle, which an unverified holder must never be able to buy.',
363
+ },
364
+ // Asking whether a change reference was charged (CAY-0091). A read: nothing moves and
365
+ // nothing is reserved, so it applies no bar, as the marketplace receipt read applies
366
+ // none. A credential scoped to it cannot charge anything.
367
+ 'read-handle-change-receipt': {
368
+ operation: 'read-handle-change-receipt',
369
+ assurance: 'not-required',
370
+ rationale: 'Asking whether a change reference was charged moves nothing and reserves nothing. It ' +
371
+ 'answers a receipt Cayso already signed, or that there was no charge, and nothing more.',
372
+ },
346
373
  // The citizen market's three acts (CAY-0080 §7, Open decision Q). All three are
347
374
  // money-grade and all three are allowlists, at the purchase path's bar: the acting
348
375
  // party is a Citizen, and a bar no issuer can yet clear would shut the market on
@@ -524,6 +551,8 @@ export const OPERATION_FOR_ROUTE = {
524
551
  purchaseCancel: 'cancel-purchase',
525
552
  commercialPayment: 'make-commercial-payment',
526
553
  citizenTransfer: 'make-citizen-transfer',
554
+ handleChange: 'change-handle',
555
+ handleChangeReceipt: 'read-handle-change-receipt',
527
556
  citizenMarket: 'read-citizen-market',
528
557
  placeQuote: 'place-quote',
529
558
  withdrawQuote: 'withdraw-quote',
package/dist/client.d.ts CHANGED
@@ -72,6 +72,7 @@ import type { CitizenshipFounderClaimed, CitizenshipView } from './citizenship.j
72
72
  import type { StandingAuthorisationAcknowledged, StandingAuthorisationRequest } from './cloud-settlement.js';
73
73
  import type { CitizenTransferMade, CitizenTransferRequest } from './citizen-transfer.js';
74
74
  import type { CommercialPaymentMade, CommercialPaymentRequest } from './commercial-payment.js';
75
+ import type { HandleChangeCharged, HandleChangeReceiptReadResponse } from './handle-change.js';
75
76
  import type { MarketplaceOrderRequest, MarketplaceOrderSettled } from './marketplace-settlement.js';
76
77
  import type { OrganisationView } from './organisation.js';
77
78
  import type { PurchaseAuthorised, PurchaseCancelled, PurchaseRequest, PurchaseResult, PurchaseTerminal } from './purchase.js';
@@ -225,6 +226,24 @@ export interface CaysoClient {
225
226
  * refusal means nothing moved.
226
227
  */
227
228
  makeCitizenTransfer(req: CitizenTransferRequest): Promise<CitizenTransferMade>;
229
+ /**
230
+ * Charge the caller's own Citizen Wallet for a Handle change, and receive the signed
231
+ * receipt Percayso ID relies on (CAY-0091) — or, for a change reference already
232
+ * charged, the receipt of that charge, with nothing charged again.
233
+ *
234
+ * There is nothing to send: the change reference is inside the assertion, the wallet
235
+ * is the verified holder's own, and the price is Cayso's. A refusal arrives as a thrown
236
+ * {@link CaysoApiError} whose `code` is a `HandleChangeRefusal` member, one of the
237
+ * gate's codes, or a seam code. A refusal means nothing moved.
238
+ */
239
+ changeHandle(): Promise<HandleChangeCharged>;
240
+ /**
241
+ * Ask whether the change reference inside the assertion was charged for the caller
242
+ * (CAY-0091): its receipt, or `no-charge`. Never "pending". A refusal arrives as a
243
+ * thrown {@link CaysoApiError} whose `code` is a `HandleChangeReceiptReadRefusal`
244
+ * member, one of the gate's codes, or a seam code — and is never "no charge".
245
+ */
246
+ readHandleChangeReceipt(): Promise<HandleChangeReceiptReadResponse>;
228
247
  /**
229
248
  * Read the citizen market as the caller sees it (CAY-0080 §1.4): the published
230
249
  * value and its band, both bounds per quote unit, the best bid and the best ask with
package/dist/client.js CHANGED
@@ -231,6 +231,25 @@ function buildClient(options, internals) {
231
231
  idempotencyKey: req.idempotencyKey,
232
232
  });
233
233
  },
234
+ async changeHandle() {
235
+ return requestJson({
236
+ method: ROUTES.handleChange.method,
237
+ path: ROUTES.handleChange.path,
238
+ // Safe to retry with no key: the charge is keyed by the change reference
239
+ // inside the assertion, so a repeat answers the charge already made, and each
240
+ // attempt mints a fresh assertion, so the single-use `jti` is never presented
241
+ // twice.
242
+ idempotent: true,
243
+ });
244
+ },
245
+ async readHandleChangeReceipt() {
246
+ return requestJson({
247
+ method: ROUTES.handleChangeReceipt.method,
248
+ path: ROUTES.handleChangeReceipt.path,
249
+ // A read: it moves nothing, so a retry is always safe.
250
+ idempotent: true,
251
+ });
252
+ },
234
253
  async getCitizenMarket() {
235
254
  return requestJson({
236
255
  method: ROUTES.citizenMarket.method,
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export const CONTRACT_SCHEMA = {
17
- "contractVersion": "0.27.0",
17
+ "contractVersion": "0.29.0",
18
18
  "packageName": "@percayso-community/cayso-contracts",
19
19
  "capabilities": {
20
20
  "wallet": "cayso.wallet",
@@ -61,6 +61,14 @@ export const CONTRACT_SCHEMA = {
61
61
  "method": "POST",
62
62
  "path": "/api/citizen-transfers"
63
63
  },
64
+ "handleChange": {
65
+ "method": "POST",
66
+ "path": "/api/handle-changes"
67
+ },
68
+ "handleChangeReceipt": {
69
+ "method": "GET",
70
+ "path": "/api/handle-changes/receipt"
71
+ },
64
72
  "citizenMarket": {
65
73
  "method": "GET",
66
74
  "path": "/api/citizen-market"
@@ -234,6 +242,13 @@ export const CONTRACT_SCHEMA = {
234
242
  "readonly": true,
235
243
  "optional": true
236
244
  },
245
+ "handleChangeReference": {
246
+ "type": {
247
+ "scalar": "string"
248
+ },
249
+ "readonly": true,
250
+ "optional": true
251
+ },
237
252
  "mandateFor": {
238
253
  "type": {
239
254
  "array": {
@@ -661,6 +676,15 @@ export const CONTRACT_SCHEMA = {
661
676
  {
662
677
  "literal": "citizen_transfer_store_not_configured"
663
678
  },
679
+ {
680
+ "literal": "handle_change_store_not_configured"
681
+ },
682
+ {
683
+ "literal": "handle_change_price_not_configured"
684
+ },
685
+ {
686
+ "literal": "handle_change_payee_not_configured"
687
+ },
664
688
  {
665
689
  "literal": "citizen_market_not_configured"
666
690
  },
@@ -706,6 +730,12 @@ export const CONTRACT_SCHEMA = {
706
730
  {
707
731
  "ref": "CitizenTransferRefusal"
708
732
  },
733
+ {
734
+ "ref": "HandleChangeRefusal"
735
+ },
736
+ {
737
+ "ref": "HandleChangeReceiptReadRefusal"
738
+ },
709
739
  {
710
740
  "ref": "QuotePlacementRefusal"
711
741
  },
@@ -1499,6 +1529,12 @@ export const CONTRACT_SCHEMA = {
1499
1529
  {
1500
1530
  "literal": "make-citizen-transfer"
1501
1531
  },
1532
+ {
1533
+ "literal": "change-handle"
1534
+ },
1535
+ {
1536
+ "literal": "read-handle-change-receipt"
1537
+ },
1502
1538
  {
1503
1539
  "literal": "place-quote"
1504
1540
  },
@@ -1744,6 +1780,255 @@ export const CONTRACT_SCHEMA = {
1744
1780
  ]
1745
1781
  }
1746
1782
  },
1783
+ "HandleChangeCharged": {
1784
+ "kind": "object",
1785
+ "properties": {
1786
+ "outcome": {
1787
+ "type": {
1788
+ "literal": "charged"
1789
+ },
1790
+ "readonly": true,
1791
+ "optional": false
1792
+ },
1793
+ "receipt": {
1794
+ "type": {
1795
+ "ref": "HandleChangeReceipt"
1796
+ },
1797
+ "readonly": true,
1798
+ "optional": false
1799
+ }
1800
+ }
1801
+ },
1802
+ "HandleChangeNoCharge": {
1803
+ "kind": "object",
1804
+ "properties": {
1805
+ "outcome": {
1806
+ "type": {
1807
+ "literal": "no-charge"
1808
+ },
1809
+ "readonly": true,
1810
+ "optional": false
1811
+ }
1812
+ }
1813
+ },
1814
+ "HandleChangeReceipt": {
1815
+ "kind": "object",
1816
+ "properties": {
1817
+ "statement": {
1818
+ "type": {
1819
+ "ref": "HandleChangeReceiptStatement"
1820
+ },
1821
+ "readonly": true,
1822
+ "optional": false
1823
+ },
1824
+ "signature": {
1825
+ "type": {
1826
+ "scalar": "string"
1827
+ },
1828
+ "readonly": true,
1829
+ "optional": false
1830
+ }
1831
+ }
1832
+ },
1833
+ "HandleChangeReceiptFound": {
1834
+ "kind": "object",
1835
+ "properties": {
1836
+ "outcome": {
1837
+ "type": {
1838
+ "literal": "receipt"
1839
+ },
1840
+ "readonly": true,
1841
+ "optional": false
1842
+ },
1843
+ "receipt": {
1844
+ "type": {
1845
+ "ref": "HandleChangeReceipt"
1846
+ },
1847
+ "readonly": true,
1848
+ "optional": false
1849
+ }
1850
+ }
1851
+ },
1852
+ "HandleChangeReceiptReadRefusal": {
1853
+ "kind": "alias",
1854
+ "of": {
1855
+ "union": [
1856
+ {
1857
+ "literal": "payer_has_no_citizen_wallet"
1858
+ },
1859
+ {
1860
+ "literal": "handle_change_reference_charged_to_another_wallet"
1861
+ }
1862
+ ]
1863
+ }
1864
+ },
1865
+ "HandleChangeReceiptReadRefused": {
1866
+ "kind": "object",
1867
+ "properties": {
1868
+ "outcome": {
1869
+ "type": {
1870
+ "literal": "refused"
1871
+ },
1872
+ "readonly": true,
1873
+ "optional": false
1874
+ },
1875
+ "error": {
1876
+ "type": {
1877
+ "ref": "HandleChangeReceiptReadRefusal"
1878
+ },
1879
+ "readonly": true,
1880
+ "optional": false
1881
+ }
1882
+ }
1883
+ },
1884
+ "HandleChangeReceiptReadResponse": {
1885
+ "kind": "alias",
1886
+ "of": {
1887
+ "union": [
1888
+ {
1889
+ "ref": "HandleChangeReceiptFound"
1890
+ },
1891
+ {
1892
+ "ref": "HandleChangeNoCharge"
1893
+ },
1894
+ {
1895
+ "ref": "HandleChangeReceiptReadRefused"
1896
+ }
1897
+ ]
1898
+ }
1899
+ },
1900
+ "HandleChangeReceiptStatement": {
1901
+ "kind": "object",
1902
+ "properties": {
1903
+ "reason": {
1904
+ "type": {
1905
+ "literal": "handle-change"
1906
+ },
1907
+ "readonly": true,
1908
+ "optional": false
1909
+ },
1910
+ "movementKind": {
1911
+ "type": {
1912
+ "literal": "charge"
1913
+ },
1914
+ "readonly": true,
1915
+ "optional": false
1916
+ },
1917
+ "movementId": {
1918
+ "type": {
1919
+ "scalar": "string"
1920
+ },
1921
+ "readonly": true,
1922
+ "optional": false
1923
+ },
1924
+ "handleChangeReference": {
1925
+ "type": {
1926
+ "scalar": "string"
1927
+ },
1928
+ "readonly": true,
1929
+ "optional": false
1930
+ },
1931
+ "assertionIssuer": {
1932
+ "type": {
1933
+ "scalar": "string"
1934
+ },
1935
+ "readonly": true,
1936
+ "optional": false
1937
+ },
1938
+ "assertionId": {
1939
+ "type": {
1940
+ "scalar": "string"
1941
+ },
1942
+ "readonly": true,
1943
+ "optional": false
1944
+ },
1945
+ "payerWalletId": {
1946
+ "type": {
1947
+ "scalar": "string"
1948
+ },
1949
+ "readonly": true,
1950
+ "optional": false
1951
+ },
1952
+ "payeeLeg": {
1953
+ "type": {
1954
+ "ref": "MarketplaceReceiptLeg"
1955
+ },
1956
+ "readonly": true,
1957
+ "optional": false
1958
+ },
1959
+ "writtenAt": {
1960
+ "type": {
1961
+ "ref": "Millis"
1962
+ },
1963
+ "readonly": true,
1964
+ "optional": false
1965
+ },
1966
+ "keyId": {
1967
+ "type": {
1968
+ "ref": "MarketplaceReceiptKeyId"
1969
+ },
1970
+ "readonly": true,
1971
+ "optional": false
1972
+ }
1973
+ }
1974
+ },
1975
+ "HandleChangeRefusal": {
1976
+ "kind": "alias",
1977
+ "of": {
1978
+ "union": [
1979
+ {
1980
+ "literal": "assurance_not_money_grade"
1981
+ },
1982
+ {
1983
+ "literal": "payer_has_no_citizen_wallet"
1984
+ },
1985
+ {
1986
+ "literal": "cents_insufficient"
1987
+ },
1988
+ {
1989
+ "literal": "cents_frozen"
1990
+ },
1991
+ {
1992
+ "literal": "handle_change_reference_charged_to_another_wallet"
1993
+ },
1994
+ {
1995
+ "literal": "carve_contended"
1996
+ }
1997
+ ]
1998
+ }
1999
+ },
2000
+ "HandleChangeRefused": {
2001
+ "kind": "object",
2002
+ "properties": {
2003
+ "outcome": {
2004
+ "type": {
2005
+ "literal": "refused"
2006
+ },
2007
+ "readonly": true,
2008
+ "optional": false
2009
+ },
2010
+ "error": {
2011
+ "type": {
2012
+ "ref": "HandleChangeRefusal"
2013
+ },
2014
+ "readonly": true,
2015
+ "optional": false
2016
+ }
2017
+ }
2018
+ },
2019
+ "HandleChangeResponse": {
2020
+ "kind": "alias",
2021
+ "of": {
2022
+ "union": [
2023
+ {
2024
+ "ref": "HandleChangeCharged"
2025
+ },
2026
+ {
2027
+ "ref": "HandleChangeRefused"
2028
+ }
2029
+ ]
2030
+ }
2031
+ },
1747
2032
  "HolderType": {
1748
2033
  "kind": "alias",
1749
2034
  "of": {
@@ -1998,6 +2283,9 @@ export const CONTRACT_SCHEMA = {
1998
2283
  {
1999
2284
  "literal": "allocation_policy_version_not_configured"
2000
2285
  },
2286
+ {
2287
+ "literal": "allocation_share_out_of_range"
2288
+ },
2001
2289
  {
2002
2290
  "literal": "payee_wallet_not_found"
2003
2291
  },
@@ -2007,6 +2295,9 @@ export const CONTRACT_SCHEMA = {
2007
2295
  {
2008
2296
  "literal": "payee_wallet_has_no_live_binding"
2009
2297
  },
2298
+ {
2299
+ "literal": "payee_wallet_is_the_buyers"
2300
+ },
2010
2301
  {
2011
2302
  "literal": "unrestricted_cents_insufficient"
2012
2303
  },
@@ -4217,6 +4508,9 @@ export const CONTRACT_SCHEMA = {
4217
4508
  },
4218
4509
  {
4219
4510
  "literal": "quoted_sale_compensation"
4511
+ },
4512
+ {
4513
+ "literal": "marketplace_settlement"
4220
4514
  }
4221
4515
  ]
4222
4516
  }
package/dist/errors.d.ts CHANGED
@@ -45,6 +45,7 @@ import type { FounderClaimRefusal } from './citizenship.js';
45
45
  import type { BuyBackRefusal, QuotePlacementRefusal, QuoteWithdrawalRefusal } from './citizen-market.js';
46
46
  import type { SettlementAssertionRefusal, StandingAuthorisationRefusal } from './cloud-settlement.js';
47
47
  import type { CitizenTransferRefusal } from './citizen-transfer.js';
48
+ import type { HandleChangeReceiptReadRefusal, HandleChangeRefusal } from './handle-change.js';
48
49
  import type { CommercialPaymentRefusal } from './commercial-payment.js';
49
50
  import type { MarketplaceReceiptReadRefusal } from './marketplace-receipt.js';
50
51
  import type { MarketplaceOrderRefusal, MarketplaceRefundRefusal } from './marketplace-settlement.js';
@@ -126,6 +127,21 @@ export type CaysoApiErrorCode =
126
127
  * transfer's refusal union.
127
128
  */
128
129
  | 'citizen_transfer_store_not_configured'
130
+ /**
131
+ * No Handle-change store is wired, so the route is closed (CAY-0091). It describes
132
+ * the deployment and not the payment, so it is not a member of the refusal union.
133
+ */
134
+ | 'handle_change_store_not_configured'
135
+ /**
136
+ * The Handle-change price is not configured on this deployment, so nothing can be
137
+ * charged (CAY-0091). An unset price is a closed door, never a free Handle change.
138
+ */
139
+ | 'handle_change_price_not_configured'
140
+ /**
141
+ * The Organisation Wallet a Handle change is charged to is not configured on this
142
+ * deployment (CAY-0091). There is no default payee, so the route is closed.
143
+ */
144
+ | 'handle_change_payee_not_configured'
129
145
  /**
130
146
  * The citizen market is shut on this deployment: no store is wired, or a figure
131
147
  * the book needs is not set in the canon and so not configured here (CAY-0080,
@@ -171,11 +187,13 @@ export type CaysoApiErrorCode =
171
187
  */
172
188
  | 'marketplace_order_store_not_configured'
173
189
  /**
174
- * The signed order pays a Citizen publisher, and this version serves the
175
- * house-publisher sale only (CAY-0082 §2). Nothing was checked against the payee and
176
- * nothing moved. A seam code rather than a {@link MarketplaceOrderRefusal}, because it
177
- * describes this deployment and not the order; the third-party sale retires it when
178
- * it ships.
190
+ * The signed order pays a Citizen publisher and carries no Community share
191
+ * (`communityShareBasisPoints`): Store Platform signed it before CAY-0090 put the
192
+ * share in the order, so Cayso has no figure to divide the price by. Nothing was
193
+ * checked against the payee and nothing moved. Before the share was a fact every
194
+ * Citizen publisher's order was answered this way; now only one without it is.
195
+ * A seam code rather than a {@link MarketplaceOrderRefusal}, because it describes
196
+ * what the deployments in the path speak and not the order.
179
197
  */
180
198
  | 'third_party_marketplace_sale_not_served'
181
199
  /** The request body or parameters did not satisfy the declared schema. */
@@ -183,7 +201,7 @@ export type CaysoApiErrorCode =
183
201
  /** There is no such purchase under this caller's wallet. */
184
202
  | 'not_found'
185
203
  /** Something failed on the way and the refusal discloses nothing further. */
186
- | 'internal_error' | PurchaseFailureReason | PurchaseCancelRefusalReason | FounderClaimRefusal | CommercialPaymentRefusal | CitizenTransferRefusal | QuotePlacementRefusal | QuoteWithdrawalRefusal | BuyBackRefusal | MarketplaceReceiptReadRefusal | MarketplaceOrderRefusal | MarketplaceRefundRefusal | StandingAuthorisationRefusal | SettlementAssertionRefusal;
204
+ | 'internal_error' | PurchaseFailureReason | PurchaseCancelRefusalReason | FounderClaimRefusal | CommercialPaymentRefusal | CitizenTransferRefusal | HandleChangeRefusal | HandleChangeReceiptReadRefusal | QuotePlacementRefusal | QuoteWithdrawalRefusal | BuyBackRefusal | MarketplaceReceiptReadRefusal | MarketplaceOrderRefusal | MarketplaceRefundRefusal | StandingAuthorisationRefusal | SettlementAssertionRefusal;
187
205
  /**
188
206
  * The body of every refusal on this surface: one code, and nothing beside it.
189
207
  *
@@ -0,0 +1,189 @@
1
+ /**
2
+ * `handle-change` — a Citizen's Handle change, charged by Cayso, and the signed receipt
3
+ * Percayso ID relies on before it changes the Handle record (CAY-0091).
4
+ *
5
+ * Every Handle change after approval is charged in Cayso (Percayso ID's onboarding PRD
6
+ * §7.2). Cayso holds the price and makes the charge; Percayso ID changes the Handle only
7
+ * once Cayso has answered with a receipt. Served at `ROUTES.handleChange`, under the
8
+ * operation `'change-handle'`, and read back at `ROUTES.handleChangeReceipt`, under
9
+ * `'read-handle-change-receipt'`.
10
+ *
11
+ * ## Who calls it
12
+ *
13
+ * Percayso ID, over its back channel, as it presents a founder claim. The Citizen
14
+ * confirms on Percayso ID's own pages; Percayso ID mints a `change-handle` assertion for
15
+ * that interactive session — never from the background source (CAY-0070) — and presents
16
+ * it here. The assertion's `sub` is the Citizen ID.
17
+ *
18
+ * ## One `charge` for a Community service, or nothing
19
+ *
20
+ * The charge is one `charge` movement from the Citizen's own Citizen Wallet to the
21
+ * Organisation Wallet of the organisation that operates Percayso ID, named in Cayso's
22
+ * configuration — never a Citizen Wallet (CAY-0084). A Handle change is a Community
23
+ * service (CAY-0076, as extended by CAY-0091), and a `charge` may draw restricted lots
24
+ * like any charge, so restricted and unrestricted cents are drawn together. There is no
25
+ * sterling leg and so no lifecycle: the answer is a {@link HandleChangeCharged} carrying
26
+ * the signed receipt, or a {@link HandleChangeRefused} meaning nothing moved.
27
+ *
28
+ * ## Nothing in the request names anything
29
+ *
30
+ * There is no request body. The paying wallet is the verified subject's own Citizen
31
+ * Wallet, resolved inside the service (CAY-0021). The price is Cayso's configuration.
32
+ * The change reference — the single-use reference Percayso ID issued when it reserved
33
+ * the proposed Handle — is carried INSIDE the signed assertion, as
34
+ * `handleChangeReference`, because a reference named in a body would be the caller's
35
+ * claim about which Handle change is theirs. Cayso never learns the Handle.
36
+ *
37
+ * ## At most one charge per change reference
38
+ *
39
+ * The change reference is the charge's key. The first presentation charges; a later
40
+ * presentation of the same reference for the same Citizen, under a fresh assertion,
41
+ * charges nothing and answers the receipt of the charge already made — so Percayso ID,
42
+ * having had no response, retries with the same reference and is answered idempotently.
43
+ * A reference already charged to another wallet is refused. The same assertion
44
+ * presented twice never reaches this far: its `jti` is single-use, and the replay is
45
+ * refused at the gate.
46
+ *
47
+ * ## The receipt is a statement Cayso signs
48
+ *
49
+ * {@link HandleChangeReceipt} is a {@link HandleChangeReceiptStatement} and an `ES256`
50
+ * signature over {@link encodeHandleChangeReceiptStatement} of it, made with Cayso's
51
+ * receipt key (CAY-0083 §1, as amended by CAY-0091) and published in the same key set
52
+ * as a marketplace receipt's. It is BOUND to the charge: it names the change reference
53
+ * and the issuer and `jti` of the assertion the charge was made under, which Percayso ID
54
+ * minted and alone can tie to a Citizen. It names a wallet id and never a Percayso
55
+ * identity (CAY-0006, CAY-0054): there is no `sub` and no Handle.
56
+ *
57
+ * ## Was this reference charged? A receipt or "no charge", never "pending"
58
+ *
59
+ * {@link HandleChangeReceiptReadResponse} answers the read Percayso ID makes before it
60
+ * releases a held Handle: the receipt of the charge the reference landed, or
61
+ * `no-charge` — nothing was charged under this reference for this Citizen. There is no
62
+ * `pending`: a movement is written or it is not (CAY-0023). A read writes no row and
63
+ * moves nothing.
64
+ *
65
+ * ## The bytes that are signed, and why they cannot be a marketplace receipt
66
+ *
67
+ * {@link encodeHandleChangeReceiptStatement} is the one encoding, called by the signer
68
+ * and by every verifier: the statement's fields in the order the interface declares
69
+ * them, as UTF-8 JSON with no whitespace, refusing any field it does not name. Its first
70
+ * field is `"reason":"handle-change"`, and no marketplace receipt has a `reason` field —
71
+ * that encoder refuses one — so the one key signing both cannot make either read as the
72
+ * other.
73
+ *
74
+ * ## What is not here
75
+ *
76
+ * No figure: the price is a canon figure, configured, and the receipt carries the cents
77
+ * that moved. No key material and no verifier: which keys Percayso ID trusts is Percayso
78
+ * ID's configuration, empty by default.
79
+ */
80
+ import type { MarketplaceReceiptKeyId, MarketplaceReceiptLeg } from './marketplace-receipt.js';
81
+ import type { Millis } from './wallet.js';
82
+ /**
83
+ * What Cayso signs about one Handle-change charge. Every field is signed, including
84
+ * `keyId`, so which key signed is part of what is signed.
85
+ */
86
+ export interface HandleChangeReceiptStatement {
87
+ /** The reason for the charge. Always the literal, and always first in the encoding. */
88
+ readonly reason: 'handle-change';
89
+ /** The act: one `charge`, from the payer to the payee. */
90
+ readonly movementKind: 'charge';
91
+ /** The movement that carried the cents. */
92
+ readonly movementId: string;
93
+ /** The change reference charged for, exactly as Percayso ID minted it into the assertion. */
94
+ readonly handleChangeReference: string;
95
+ /** The issuer of the assertion the charge was made under. */
96
+ readonly assertionIssuer: string;
97
+ /** The `jti` of the assertion the charge was made under. */
98
+ readonly assertionId: string;
99
+ /** The paying wallet: the Citizen's own Citizen Wallet. */
100
+ readonly payerWalletId: string;
101
+ /** The whole price, to the configured Organisation Wallet, as the cents that moved. */
102
+ readonly payeeLeg: MarketplaceReceiptLeg;
103
+ /** When the movement was written. */
104
+ readonly writtenAt: Millis;
105
+ /** The receipt key the signature was made with. */
106
+ readonly keyId: MarketplaceReceiptKeyId;
107
+ }
108
+ /** A receipt: the statement, and Cayso's signature over its encoding. */
109
+ export interface HandleChangeReceipt {
110
+ readonly statement: HandleChangeReceiptStatement;
111
+ /**
112
+ * `ES256` over {@link encodeHandleChangeReceiptStatement}`(statement)`: `r || s`, 64
113
+ * bytes, as unpadded base64url.
114
+ */
115
+ readonly signature: string;
116
+ }
117
+ /** The Handle change was charged, by this request or by an earlier one for the same reference. */
118
+ export interface HandleChangeCharged {
119
+ readonly outcome: 'charged';
120
+ readonly receipt: HandleChangeReceipt;
121
+ }
122
+ /** The charge was refused, with one member of the closed union. Nothing was written. */
123
+ export interface HandleChangeRefused {
124
+ readonly outcome: 'refused';
125
+ readonly error: HandleChangeRefusal;
126
+ }
127
+ /** The ONE declared answer to a Handle change, discriminated by `outcome`. */
128
+ export type HandleChangeResponse = HandleChangeCharged | HandleChangeRefused;
129
+ /**
130
+ * Why a Handle change was refused: CAY-0091's set, closed. Every member means the same
131
+ * thing about money: nothing moved.
132
+ */
133
+ export type HandleChangeRefusal =
134
+ /**
135
+ * The verification method is outside the money-grade assurance profile
136
+ * (`ASSURANCE_POLICY['change-handle']`). `dev-bypass` is never inside it.
137
+ */
138
+ 'assurance_not_money_grade'
139
+ /** The verified subject resolves to no Citizen Wallet. A Handle change never provisions one. */
140
+ | 'payer_has_no_citizen_wallet'
141
+ /** The payer's cents, restricted and unrestricted together, are short of the price. */
142
+ | 'cents_insufficient'
143
+ /** A holding the charge would draw is frozen. */
144
+ | 'cents_frozen'
145
+ /** The change reference has already been charged, to another wallet. */
146
+ | 'handle_change_reference_charged_to_another_wallet'
147
+ /** Too many concurrent draws on the paying wallet. Nothing moved; retry with the same reference. */
148
+ | 'carve_contended';
149
+ /** The reference was charged for this Citizen: the receipt of that charge. */
150
+ export interface HandleChangeReceiptFound {
151
+ readonly outcome: 'receipt';
152
+ readonly receipt: HandleChangeReceipt;
153
+ }
154
+ /**
155
+ * Nothing was charged under this reference for this Citizen. Never "pending": there is
156
+ * no pending charge.
157
+ */
158
+ export interface HandleChangeNoCharge {
159
+ readonly outcome: 'no-charge';
160
+ }
161
+ /**
162
+ * Why the read could not be answered. Closed, and a refusal is never a statement about
163
+ * the reference: a caller must not read one as "no charge".
164
+ */
165
+ export type HandleChangeReceiptReadRefusal =
166
+ /**
167
+ * No wallet is bound to the verified subject now, so there is no paying wallet to ask
168
+ * about, and whether the reference was charged is not known.
169
+ */
170
+ 'payer_has_no_citizen_wallet'
171
+ /** The reference was charged, to another wallet. */
172
+ | 'handle_change_reference_charged_to_another_wallet';
173
+ /** The read was refused, with one reason. Nothing was written. */
174
+ export interface HandleChangeReceiptReadRefused {
175
+ readonly outcome: 'refused';
176
+ readonly error: HandleChangeReceiptReadRefusal;
177
+ }
178
+ /** The ONE declared answer to the read: a receipt, "no charge", or a refusal. Never "pending". */
179
+ export type HandleChangeReceiptReadResponse = HandleChangeReceiptFound | HandleChangeNoCharge | HandleChangeReceiptReadRefused;
180
+ /**
181
+ * The exact bytes a Handle-change receipt's signature is computed over.
182
+ *
183
+ * Builds a fresh object from the statement's named fields, in a fixed order, so the
184
+ * encoding depends on nothing but their values. THROWS a `TypeError` for anything that
185
+ * is not exactly a {@link HandleChangeReceiptStatement}: a wrong literal, a missing or
186
+ * extra field, a string field that is not a string, or cents or a time that is not a
187
+ * safe whole number no less than zero.
188
+ */
189
+ export declare function encodeHandleChangeReceiptStatement(statement: HandleChangeReceiptStatement): Uint8Array<ArrayBuffer>;
@@ -0,0 +1,96 @@
1
+ /*
2
+ * Copyright 2026 Percayso Community
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ // --- The encoding ------------------------------------------------------------
17
+ /** The statement's own fields, in the order they are encoded. */
18
+ const FIELDS = [
19
+ 'reason',
20
+ 'movementKind',
21
+ 'movementId',
22
+ 'handleChangeReference',
23
+ 'assertionIssuer',
24
+ 'assertionId',
25
+ 'payerWalletId',
26
+ 'payeeLeg',
27
+ 'writtenAt',
28
+ 'keyId',
29
+ ];
30
+ /** Every string field, each of which must be a string when it arrives. */
31
+ const STRING_FIELDS = [
32
+ 'movementId',
33
+ 'handleChangeReference',
34
+ 'assertionIssuer',
35
+ 'assertionId',
36
+ 'payerWalletId',
37
+ 'keyId',
38
+ ];
39
+ /** The fields of a leg, in the order they are encoded. */
40
+ const LEG_FIELDS = ['walletId', 'cents'];
41
+ /**
42
+ * The exact bytes a Handle-change receipt's signature is computed over.
43
+ *
44
+ * Builds a fresh object from the statement's named fields, in a fixed order, so the
45
+ * encoding depends on nothing but their values. THROWS a `TypeError` for anything that
46
+ * is not exactly a {@link HandleChangeReceiptStatement}: a wrong literal, a missing or
47
+ * extra field, a string field that is not a string, or cents or a time that is not a
48
+ * safe whole number no less than zero.
49
+ */
50
+ export function encodeHandleChangeReceiptStatement(statement) {
51
+ const value = statement;
52
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
53
+ throw new TypeError('a Handle-change receipt statement is an object');
54
+ }
55
+ requireExactly(value, FIELDS, 'a Handle-change receipt carries exactly its own fields');
56
+ if (value['reason'] !== 'handle-change' || value['movementKind'] !== 'charge') {
57
+ throw new TypeError('a Handle-change receipt is for a Handle change made by a charge');
58
+ }
59
+ for (const field of STRING_FIELDS) {
60
+ if (typeof value[field] !== 'string') {
61
+ throw new TypeError('every identifier of a Handle-change receipt is a string');
62
+ }
63
+ }
64
+ requireWholeNumber(value['writtenAt'], 'a Handle-change receipt is written at whole milliseconds');
65
+ const canonical = {};
66
+ for (const field of FIELDS) {
67
+ canonical[field] = field === 'payeeLeg' ? canonicalLeg(value[field]) : value[field];
68
+ }
69
+ return new TextEncoder().encode(JSON.stringify(canonical));
70
+ }
71
+ /** A leg rebuilt in its fixed order, or a refusal. */
72
+ function canonicalLeg(leg) {
73
+ if (typeof leg !== 'object' || leg === null || Array.isArray(leg)) {
74
+ throw new TypeError('a Handle-change receipt leg is an object');
75
+ }
76
+ const value = leg;
77
+ requireExactly(value, LEG_FIELDS, 'a Handle-change receipt leg carries a wallet id and cents only');
78
+ if (typeof value['walletId'] !== 'string') {
79
+ throw new TypeError('a Handle-change receipt leg names its wallet by id');
80
+ }
81
+ requireWholeNumber(value['cents'], 'a Handle-change receipt leg carries whole cents');
82
+ return { walletId: value['walletId'], cents: value['cents'] };
83
+ }
84
+ /** Refuse an object whose own keys are not exactly `fields`. */
85
+ function requireExactly(value, fields, category) {
86
+ const keys = Object.keys(value);
87
+ if (keys.length !== fields.length || !fields.every((field) => Object.hasOwn(value, field))) {
88
+ throw new TypeError(category);
89
+ }
90
+ }
91
+ /** Refuse anything that is not a safe whole number no less than zero. */
92
+ function requireWholeNumber(value, category) {
93
+ if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) {
94
+ throw new TypeError(category);
95
+ }
96
+ }
package/dist/index.d.ts CHANGED
@@ -76,6 +76,36 @@
76
76
  * this money surface gains that Piper's own contracts lack, since theirs share
77
77
  * one global version bumped across all twenty-two together (CAY-0026).
78
78
  *
79
+ * `0.28.0` → `0.29.0` publishes and SERVES the Handle change (CAY-0091):
80
+ * `ROUTES.handleChange`, `POST /api/handle-changes`, mapped to the new operation
81
+ * `'change-handle'`, money-grade in `ASSURANCE_POLICY`; `ROUTES.handleChangeReceipt`,
82
+ * `GET /api/handle-changes/receipt`, mapped to the new read-scope operation
83
+ * `'read-handle-change-receipt'`; the assertion claim `handleChangeReference`, which
84
+ * travels with those two operations in both directions; the client methods
85
+ * `changeHandle` and `readHandleChangeReceipt`; the signed {@link HandleChangeReceipt}
86
+ * and its one encoding, {@link encodeHandleChangeReceiptStatement}; and
87
+ * `CaysoApiErrorCode` gains {@link HandleChangeRefusal} and
88
+ * {@link HandleChangeReceiptReadRefusal} by reference and the seam codes
89
+ * `handle_change_store_not_configured`, `handle_change_price_not_configured` and
90
+ * `handle_change_payee_not_configured`. BREAKING in the package's sense because closed
91
+ * tables grew. Additive on the wire: no route a `0.28.0` consumer calls changed or
92
+ * answers anything new, and a credential a `0.28.0` issuer mints carries neither the new
93
+ * scope keys nor the new claim (CAY-0086).
94
+ *
95
+ * `0.27.0` → `0.28.0` SERVES a Citizen publisher's marketplace sale (CAY-0090):
96
+ * `POST /api/marketplace/orders` settles a signed order whose payee is a
97
+ * `citizen_publisher` as one `marketplace_settlement`, answering the
98
+ * `MarketplaceSettlementReceiptStatement` `0.24.0` already published. The share is
99
+ * read from a new signed-order fact, `communityShareBasisPoints`, which Store Platform
100
+ * signs beside `allocationPolicyVersion`. {@link MarketplaceOrderRefusal} gains
101
+ * `allocation_share_out_of_range` and `payee_wallet_is_the_buyers`, and
102
+ * `allocation_policy_version_not_configured` is retired (kept, never answered). The
103
+ * operator `MovementKind` gains `marketplace_settlement`. BREAKING in the package's
104
+ * sense because closed tables grew. On the wire, every order a `0.27.0` consumer could
105
+ * present — one Store Platform signed without the new fact — is answered exactly as
106
+ * before, a Citizen publisher's with `third_party_marketplace_sale_not_served`; only an
107
+ * order carrying the new fact can reach a new code (CAY-0086).
108
+ *
79
109
  * `0.26.0` → `0.27.0` publishes and SERVES the Citizen transfer (CAY-0088):
80
110
  * `ROUTES.citizenTransfer`, `POST /api/citizen-transfers`, mapped to the new
81
111
  * operation `'make-citizen-transfer'`, money-grade in `ASSURANCE_POLICY`; the client
@@ -522,7 +552,7 @@
522
552
  * have needed a breaking bump on their own. Under semver below `1.0.0` the minor
523
553
  * is where a breaking change goes, so the minor moves and the patch does not.
524
554
  */
525
- export declare const CONTRACT_VERSION: "0.27.0";
555
+ export declare const CONTRACT_VERSION: "0.29.0";
526
556
  /** The package's own name, so a consumer can name what it depends on. */
527
557
  export declare const packageName = "@percayso-community/cayso-contracts";
528
558
  /**
@@ -656,6 +686,11 @@ export { REQUEST_RATE_LIMITED } from './errors.js';
656
686
  * one of the four.
657
687
  */
658
688
  export { MARKETPLACE_RECEIPT_SIGNATURE_ALGORITHM, encodeMarketplaceReceiptStatement, } from './marketplace-receipt.js';
689
+ /**
690
+ * The one encoding of a Handle-change receipt statement, called by the signer and by
691
+ * Percayso ID's verifier (CAY-0091).
692
+ */
693
+ export { encodeHandleChangeReceiptStatement } from './handle-change.js';
659
694
  export type { PositiveCents } from './money.js';
660
695
  export type { CaysoApiErrorCode, CaysoErrorResponse } from './errors.js';
661
696
  export type { HolderType, Millis, Cents, WalletRecord, Balance, Allowance, WalletView, CaysoWallet, } from './wallet.js';
@@ -663,6 +698,7 @@ export type { SignUpGrantTerms, SignUpGrant, CitizenshipNotProvisioned, Citizens
663
698
  export type { OrganisationView } from './organisation.js';
664
699
  export type { CommercialPaymentAuthority, CommercialPaymentRequest, CommercialPayment, CommercialPaymentMade, CommercialPaymentRefused, CommercialPaymentResponse, CommercialPaymentRefusal, } from './commercial-payment.js';
665
700
  export type { CitizenTransferRequest, CitizenTransfer, CitizenTransferMade, CitizenTransferRefused, CitizenTransferResponse, CitizenTransferRefusal, } from './citizen-transfer.js';
701
+ export type { HandleChangeReceiptStatement, HandleChangeReceipt, HandleChangeCharged, HandleChangeRefused, HandleChangeResponse, HandleChangeRefusal, HandleChangeReceiptFound, HandleChangeNoCharge, HandleChangeReceiptReadRefusal, HandleChangeReceiptReadRefused, HandleChangeReceiptReadResponse, } from './handle-change.js';
666
702
  export type { QuoteSide, QuoteRequest, Quote, QuotePlaced, QuoteRefused, QuoteResponse, QuoteEntryRefusal, QuotePlacementRefusal, QuoteWithdrawalRequest, QuoteWithdrawal, QuoteWithdrawn, QuoteWithdrawalRefused, QuoteWithdrawalResponse, QuoteWithdrawalRefusal, BuyBackRequest, BuyBack, BuyBackMade, BuyBackRefused, BuyBackResponse, BuyBackRefusal, BookLevel, QuoteStatus, QuoteWithdrawalReason, OwnQuote, OwnQuoteNotWithdrawn, OwnQuoteWithdrawn, CitizenMarketView, CitizenMarketViewed, CitizenMarketViewRefusal, CitizenMarketViewRefused, CitizenMarketResponse, } from './citizen-market.js';
667
703
  export type { MarketplaceReceiptSignatureAlgorithm, MarketplaceReceiptKeyId, MarketplaceSaleKind, MarketplaceReceiptLeg, MarketplaceSettlementReceiptStatement, HousePublisherChargeReceiptStatement, ThirdPartyRefundReceiptStatement, HousePublisherRefundReceiptStatement, MarketplaceReceiptStatement, MarketplaceReceipt, MarketplaceReceiptReadRequest, MarketplaceReceiptFound, MarketplaceNoMovement, MarketplaceReceiptReadRefusal, MarketplaceReceiptReadRefused, MarketplaceReceiptReadResponse, } from './marketplace-receipt.js';
668
704
  export type { StoreSignedStatement, MarketplaceOrderRequest, MarketplaceRefundRequest, MarketplaceOrderReceipt, MarketplaceRefundReceipt, MarketplaceOrderSettled, MarketplaceOrderRefused, MarketplaceOrderResponse, MarketplaceOrderRefusal, MarketplaceRefundSettled, MarketplaceRefundRefused, MarketplaceRefundResponse, MarketplaceRefundRefusal, } from './marketplace-settlement.js';
package/dist/index.js CHANGED
@@ -92,6 +92,36 @@
92
92
  * this money surface gains that Piper's own contracts lack, since theirs share
93
93
  * one global version bumped across all twenty-two together (CAY-0026).
94
94
  *
95
+ * `0.28.0` → `0.29.0` publishes and SERVES the Handle change (CAY-0091):
96
+ * `ROUTES.handleChange`, `POST /api/handle-changes`, mapped to the new operation
97
+ * `'change-handle'`, money-grade in `ASSURANCE_POLICY`; `ROUTES.handleChangeReceipt`,
98
+ * `GET /api/handle-changes/receipt`, mapped to the new read-scope operation
99
+ * `'read-handle-change-receipt'`; the assertion claim `handleChangeReference`, which
100
+ * travels with those two operations in both directions; the client methods
101
+ * `changeHandle` and `readHandleChangeReceipt`; the signed {@link HandleChangeReceipt}
102
+ * and its one encoding, {@link encodeHandleChangeReceiptStatement}; and
103
+ * `CaysoApiErrorCode` gains {@link HandleChangeRefusal} and
104
+ * {@link HandleChangeReceiptReadRefusal} by reference and the seam codes
105
+ * `handle_change_store_not_configured`, `handle_change_price_not_configured` and
106
+ * `handle_change_payee_not_configured`. BREAKING in the package's sense because closed
107
+ * tables grew. Additive on the wire: no route a `0.28.0` consumer calls changed or
108
+ * answers anything new, and a credential a `0.28.0` issuer mints carries neither the new
109
+ * scope keys nor the new claim (CAY-0086).
110
+ *
111
+ * `0.27.0` → `0.28.0` SERVES a Citizen publisher's marketplace sale (CAY-0090):
112
+ * `POST /api/marketplace/orders` settles a signed order whose payee is a
113
+ * `citizen_publisher` as one `marketplace_settlement`, answering the
114
+ * `MarketplaceSettlementReceiptStatement` `0.24.0` already published. The share is
115
+ * read from a new signed-order fact, `communityShareBasisPoints`, which Store Platform
116
+ * signs beside `allocationPolicyVersion`. {@link MarketplaceOrderRefusal} gains
117
+ * `allocation_share_out_of_range` and `payee_wallet_is_the_buyers`, and
118
+ * `allocation_policy_version_not_configured` is retired (kept, never answered). The
119
+ * operator `MovementKind` gains `marketplace_settlement`. BREAKING in the package's
120
+ * sense because closed tables grew. On the wire, every order a `0.27.0` consumer could
121
+ * present — one Store Platform signed without the new fact — is answered exactly as
122
+ * before, a Citizen publisher's with `third_party_marketplace_sale_not_served`; only an
123
+ * order carrying the new fact can reach a new code (CAY-0086).
124
+ *
95
125
  * `0.26.0` → `0.27.0` publishes and SERVES the Citizen transfer (CAY-0088):
96
126
  * `ROUTES.citizenTransfer`, `POST /api/citizen-transfers`, mapped to the new
97
127
  * operation `'make-citizen-transfer'`, money-grade in `ASSURANCE_POLICY`; the client
@@ -538,7 +568,7 @@
538
568
  * have needed a breaking bump on their own. Under semver below `1.0.0` the minor
539
569
  * is where a breaking change goes, so the minor moves and the patch does not.
540
570
  */
541
- export const CONTRACT_VERSION = '0.27.0';
571
+ export const CONTRACT_VERSION = '0.29.0';
542
572
  /** The package's own name, so a consumer can name what it depends on. */
543
573
  export const packageName = '@percayso-community/cayso-contracts';
544
574
  /**
@@ -672,3 +702,8 @@ export { REQUEST_RATE_LIMITED } from './errors.js';
672
702
  * one of the four.
673
703
  */
674
704
  export { MARKETPLACE_RECEIPT_SIGNATURE_ALGORITHM, encodeMarketplaceReceiptStatement, } from './marketplace-receipt.js';
705
+ /**
706
+ * The one encoding of a Handle-change receipt statement, called by the signer and by
707
+ * Percayso ID's verifier (CAY-0091).
708
+ */
709
+ export { encodeHandleChangeReceiptStatement } from './handle-change.js';
@@ -12,8 +12,10 @@
12
12
  *
13
13
  * **This is the contract surface only.** Nothing here settles anything. Since
14
14
  * `0.24.0` a route serves `settle-marketplace-order` for a house-publisher sale
15
- * (`ROUTES.marketplaceOrder`); the third-party sale and the refund are not served. The sale table, the registry of Store Platform order
16
- * keys and the ledger stay in this proprietary tree (CAY-0083 §3).
15
+ * (`ROUTES.marketplaceOrder`), and since `0.28.0` for a Citizen publisher's sale too,
16
+ * as one `marketplace_settlement` with a publisher leg and a Community leg (CAY-0090).
17
+ * The refund is not served, for either kind of sale. The sale table, the registry of
18
+ * Store Platform order keys and the ledger stay in this proprietary tree (CAY-0083 §3).
17
19
  *
18
20
  * ## Two operations, because two authorities are checked
19
21
  *
@@ -41,7 +43,9 @@
41
43
  * disagree eventually. What Cayso reads from them, once verified, is CAY-0082's
42
44
  * list — the order digest, the checkout's idempotency key, the price, the paying
43
45
  * wallet, the payee wallet or the house-publisher fact, and the allocation-policy
44
- * version.
46
+ * version — and, since `0.28.0`, the Community's share in basis points, which Store
47
+ * Platform snapshots into the checkout from its allocation policy and signs beside the
48
+ * version (CAY-0090, amending CAY-0082 §3).
45
49
  *
46
50
  * **Nothing about the sale is taken from the caller's word.** The house-publisher
47
51
  * fact, the payee wallet, the price and the idempotency key are all inside the
@@ -198,17 +202,33 @@ export type MarketplaceOrderRefusal =
198
202
  */
199
203
  | 'idempotency_key_reused_for_a_different_order'
200
204
  /**
201
- * The allocation-policy version the order names has no figure configured here, so
202
- * a third-party sale's split cannot be computed. A closed door, never a default
203
- * split. A house-publisher sale has no split and never meets it.
205
+ * RETIRED in `0.28.0`, and never answered since. It was published for a Cayso that
206
+ * would hold each allocation-policy version's figure itself; CAY-0090 put the figure
207
+ * in Store Platform's signed order instead, so no version can be "not configured"
208
+ * here. Kept in the union so a consumer's exhaustive map keeps compiling; a consumer
209
+ * may stop rendering it.
204
210
  */
205
211
  | 'allocation_policy_version_not_configured'
212
+ /**
213
+ * The Community's share the signed order carries (`communityShareBasisPoints`) is not
214
+ * a whole number from 0 to 10000, or, for a Citizen publisher's sale, leaves the
215
+ * publisher leg or the Community leg at zero cents at this price. A leg is a lot that
216
+ * arrives, and a lot of no cents is not one (CAY-0078, CAY-0090), so a share of 0 or
217
+ * 10000, or a price too small to split, is refused rather than settled with one leg.
218
+ */
219
+ | 'allocation_share_out_of_range'
206
220
  /** No wallet has the payee's id. */
207
221
  | 'payee_wallet_not_found'
208
222
  /** The payee's wallet is an Organisation Wallet or the Treasury. A paid sale's publisher is a Citizen (CAY-0082 §8). */
209
223
  | 'payee_wallet_not_a_citizens'
210
224
  /** No Citizen is bound to the payee's wallet now, for example because the binding was erased. */
211
225
  | 'payee_wallet_has_no_live_binding'
226
+ /**
227
+ * The payee's wallet is the buyer's own: a publisher buying their own listing. A
228
+ * movement never runs from a wallet to itself, so nothing is paid and nothing is
229
+ * written (CAY-0090).
230
+ */
231
+ | 'payee_wallet_is_the_buyers'
212
232
  /**
213
233
  * A third-party sale: the buyer's unrestricted cents are short. Restricted cents
214
234
  * are never counted and never drawn for one (CAY-0076), so a wallet holding enough
@@ -85,7 +85,7 @@ export declare const OPERATOR_READ_ROUTES: {
85
85
  * movement list's `kind` filter refuses anything outside it (`400 invalid_kind`), and
86
86
  * every row's `kind` is one of these.
87
87
  */
88
- export type MovementKind = 'issuance' | 'purchase' | 'grant' | 'charge' | 'payout' | 'transfer' | 'burn' | 'forfeit' | 'commercial_payment' | 'quoted_sale' | 'buy_back' | 'quoted_sale_compensation';
88
+ export type MovementKind = 'issuance' | 'purchase' | 'grant' | 'charge' | 'payout' | 'transfer' | 'burn' | 'forfeit' | 'commercial_payment' | 'quoted_sale' | 'buy_back' | 'quoted_sale_compensation' | 'marketplace_settlement';
89
89
  /** Every {@link MovementKind}, in the service's order — for a filter a person picks from. */
90
90
  export declare const MOVEMENT_KINDS: readonly MovementKind[];
91
91
  /**
@@ -96,6 +96,11 @@ export declare const MOVEMENT_KINDS: readonly MovementKind[];
96
96
  * `fromWalletId` is null when the cents came from unissued (an issuance) and
97
97
  * `toWalletId` is null when they went back to it (a burn, a forfeiture). Both are
98
98
  * wallet ids — the operator-facing handle — and never an identity.
99
+ *
100
+ * A `marketplace_settlement` lands in two wallets (CAY-0082 §1): `toWalletId` is the
101
+ * publisher's Citizen Wallet and `cents` the whole price the buyer paid. The Community
102
+ * leg's share of it went to the Treasury inside the same movement, and the row does not
103
+ * itemise it; the signed receipt names both legs (CAY-0090).
99
104
  */
100
105
  export interface OperatorMovementRow {
101
106
  /** The row's own opaque handle: a stable list key, not an identity. */
package/dist/operator.js CHANGED
@@ -45,4 +45,5 @@ export const MOVEMENT_KINDS = [
45
45
  'quoted_sale',
46
46
  'buy_back',
47
47
  'quoted_sale_compensation',
48
+ 'marketplace_settlement',
48
49
  ];
package/dist/routes.d.ts CHANGED
@@ -84,6 +84,16 @@
84
84
  * Wallet, resolved inside `apps/api`, because a sending wallet the caller named would
85
85
  * be the caller's claim about whose cents these are (CAY-0021).
86
86
  *
87
+ * ## Why `handleChange` and `handleChangeReceipt` take nothing but the credential
88
+ *
89
+ * `POST /api/handle-changes` is a Citizen's Handle change, charged by Cayso, and
90
+ * `GET /api/handle-changes/receipt` asks whether a change reference was charged
91
+ * (CAY-0091). Nothing either request could carry is the caller's to say: the paying
92
+ * wallet is the verified subject's own, the price is Cayso's configuration, and the
93
+ * change reference is inside the signed assertion. So there is nothing to send but the
94
+ * credential, as with the founder claim. They are two paths because they are two
95
+ * operations, and one path carries one scope requirement at the gate.
96
+ *
87
97
  * ## Why the citizen market is FOUR PATHS, and none of them names a wallet
88
98
  *
89
99
  * `citizenMarket` reads the book, `placeQuote` places a quote, and `withdrawQuote`
@@ -158,6 +168,14 @@ export declare const ROUTES: {
158
168
  readonly method: "POST";
159
169
  readonly path: "/api/citizen-transfers";
160
170
  };
171
+ readonly handleChange: {
172
+ readonly method: "POST";
173
+ readonly path: "/api/handle-changes";
174
+ };
175
+ readonly handleChangeReceipt: {
176
+ readonly method: "GET";
177
+ readonly path: "/api/handle-changes/receipt";
178
+ };
161
179
  readonly citizenMarket: {
162
180
  readonly method: "GET";
163
181
  readonly path: "/api/citizen-market";
package/dist/routes.js CHANGED
@@ -99,6 +99,16 @@
99
99
  * Wallet, resolved inside `apps/api`, because a sending wallet the caller named would
100
100
  * be the caller's claim about whose cents these are (CAY-0021).
101
101
  *
102
+ * ## Why `handleChange` and `handleChangeReceipt` take nothing but the credential
103
+ *
104
+ * `POST /api/handle-changes` is a Citizen's Handle change, charged by Cayso, and
105
+ * `GET /api/handle-changes/receipt` asks whether a change reference was charged
106
+ * (CAY-0091). Nothing either request could carry is the caller's to say: the paying
107
+ * wallet is the verified subject's own, the price is Cayso's configuration, and the
108
+ * change reference is inside the signed assertion. So there is nothing to send but the
109
+ * credential, as with the founder claim. They are two paths because they are two
110
+ * operations, and one path carries one scope requirement at the gate.
111
+ *
102
112
  * ## Why the citizen market is FOUR PATHS, and none of them names a wallet
103
113
  *
104
114
  * `citizenMarket` reads the book, `placeQuote` places a quote, and `withdrawQuote`
@@ -143,6 +153,8 @@ export const ROUTES = {
143
153
  purchaseCancel: { method: 'POST', path: '/api/purchases/:purchaseId/cancel' },
144
154
  commercialPayment: { method: 'POST', path: '/api/commercial-payments' },
145
155
  citizenTransfer: { method: 'POST', path: '/api/citizen-transfers' },
156
+ handleChange: { method: 'POST', path: '/api/handle-changes' },
157
+ handleChangeReceipt: { method: 'GET', path: '/api/handle-changes/receipt' },
146
158
  citizenMarket: { method: 'GET', path: '/api/citizen-market' },
147
159
  placeQuote: { method: 'POST', path: '/api/quotes' },
148
160
  withdrawQuote: { method: 'POST', path: '/api/quote-withdrawals' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percayso-community/cayso-contracts",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "The versioned capability contract surface through which anything outside this repository reads a wallet. Published; keep it the surface of every consumer outside this tree, Piper and the Percayso Cloud, and nothing internal.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {