@percayso-community/cayso-contracts 0.23.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.
- package/LICENSE +201 -0
- package/README.md +114 -0
- package/dist/assertion.d.ts +867 -0
- package/dist/assertion.js +63 -0
- package/dist/assurance.d.ts +353 -0
- package/dist/assurance.js +551 -0
- package/dist/citizen-market.d.ts +468 -0
- package/dist/citizen-market.js +16 -0
- package/dist/citizenship.d.ts +215 -0
- package/dist/citizenship.js +26 -0
- package/dist/client.d.ts +288 -0
- package/dist/client.js +370 -0
- package/dist/commercial-payment.d.ts +243 -0
- package/dist/commercial-payment.js +16 -0
- package/dist/contract-schema.generated.d.ts +14 -0
- package/dist/contract-schema.generated.js +3107 -0
- package/dist/errors.d.ts +171 -0
- package/dist/errors.js +28 -0
- package/dist/index.d.ts +621 -0
- package/dist/index.js +624 -0
- package/dist/marketplace-receipt.d.ts +306 -0
- package/dist/marketplace-receipt.js +116 -0
- package/dist/marketplace-settlement.d.ts +298 -0
- package/dist/marketplace-settlement.js +16 -0
- package/dist/money.d.ts +84 -0
- package/dist/money.js +34 -0
- package/dist/organisation.d.ts +60 -0
- package/dist/organisation.js +16 -0
- package/dist/purchase.d.ts +531 -0
- package/dist/purchase.js +107 -0
- package/dist/restriction.d.ts +262 -0
- package/dist/restriction.js +316 -0
- package/dist/routes.d.ts +155 -0
- package/dist/routes.js +128 -0
- package/dist/schema-types.d.ts +101 -0
- package/dist/schema-types.js +16 -0
- package/dist/schema.d.ts +24 -0
- package/dist/schema.js +16 -0
- package/dist/wallet.d.ts +92 -0
- package/dist/wallet.js +59 -0
- package/package.json +41 -0
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The refusal envelope, and the closed set of codes that may travel in it
|
|
3
|
+
* (CAY-0058 §5).
|
|
4
|
+
*
|
|
5
|
+
* Every refusal this service answers a Piper-facing request with is the same
|
|
6
|
+
* shape: a JSON object carrying one machine-readable `error` and nothing else. A
|
|
7
|
+
* consumer renders a refusal by switching on that code, which is only safe if the
|
|
8
|
+
* code set is closed and published — a union that lived privately inside `apps/api`
|
|
9
|
+
* would make every consumer either pattern-match on prose or keep a retyped copy
|
|
10
|
+
* that goes stale the first time a refusal is added.
|
|
11
|
+
*
|
|
12
|
+
* ## Why the envelope is published rather than described
|
|
13
|
+
*
|
|
14
|
+
* The rest of this package publishes the shapes of things that SUCCEED. The
|
|
15
|
+
* refusal is the other half of the same contract, and it is the half a consumer is
|
|
16
|
+
* most likely to get wrong: a wallet page that treats an unrecognised refusal as an
|
|
17
|
+
* outage, or as a success with missing fields, misleads the person reading it. So
|
|
18
|
+
* the envelope is a type here, the codes are a closed union here, and a consumer
|
|
19
|
+
* exhausting {@link CaysoApiErrorCode} is told by its own compiler when this
|
|
20
|
+
* surface grows a refusal it has not thought about.
|
|
21
|
+
*
|
|
22
|
+
* ## The codes of the internal verifier are NOT a separate vocabulary
|
|
23
|
+
*
|
|
24
|
+
* The gate that checks a credential has its own refusal codes inside
|
|
25
|
+
* `@cayso/identity`, and most of them appear here under the same spelling because
|
|
26
|
+
* they already crossed this boundary. That is a mapping and not an identity: the
|
|
27
|
+
* service holds a total map from its internal codes onto this union, so a code
|
|
28
|
+
* added privately cannot reach the wire without a decision being taken about what
|
|
29
|
+
* it is called in public. The throttle is the case that proves the map is doing
|
|
30
|
+
* work — see {@link REQUEST_RATE_LIMITED}.
|
|
31
|
+
*
|
|
32
|
+
* ## Some of these codes travel in a richer body
|
|
33
|
+
*
|
|
34
|
+
* A purchase refusal and a cancellation refusal carry a discriminant beside the
|
|
35
|
+
* code (`{ "outcome": "refused", "error": … }`) because a caller polling a purchase
|
|
36
|
+
* needs to tell a refusal from a result at the top level. Their reasons are still
|
|
37
|
+
* part of this union — it is the set of codes that cross the boundary, not the set
|
|
38
|
+
* that happen to arrive in the bare envelope — and they are included BY REFERENCE
|
|
39
|
+
* to the unions that own them, so neither can grow a member this union does not
|
|
40
|
+
* carry. The founder claim's refusals are included the same way, and so are the
|
|
41
|
+
* commercial payment's, the citizen market's, the marketplace status read's and the
|
|
42
|
+
* two marketplace settlements'.
|
|
43
|
+
*/
|
|
44
|
+
import type { FounderClaimRefusal } from './citizenship.js';
|
|
45
|
+
import type { BuyBackRefusal, QuotePlacementRefusal, QuoteWithdrawalRefusal } from './citizen-market.js';
|
|
46
|
+
import type { CommercialPaymentRefusal } from './commercial-payment.js';
|
|
47
|
+
import type { MarketplaceReceiptReadRefusal } from './marketplace-receipt.js';
|
|
48
|
+
import type { MarketplaceOrderRefusal, MarketplaceRefundRefusal } from './marketplace-settlement.js';
|
|
49
|
+
import type { PurchaseCancelRefusalReason, PurchaseFailureReason } from './purchase.js';
|
|
50
|
+
/**
|
|
51
|
+
* The single public code for a request refused by a request-rate limit, published
|
|
52
|
+
* as a value so a consumer compares a refusal against the contract's own string
|
|
53
|
+
* rather than a retyped copy of it (the reason `NOT_PROVISIONED` is a value too).
|
|
54
|
+
*
|
|
55
|
+
* It is `request_rate_limited` rather than anything naming a credential, and that
|
|
56
|
+
* is deliberate (CAY-0058 §5): the two limits that can produce it refuse at
|
|
57
|
+
* different moments — one of them before any credential has been read, and so on a
|
|
58
|
+
* request that carries none at all — and a code that named a credential would be a
|
|
59
|
+
* lie on half the refusals and a hint about the shape of the other half on the
|
|
60
|
+
* rest. One code, one body, one status, from both origins.
|
|
61
|
+
*/
|
|
62
|
+
export declare const REQUEST_RATE_LIMITED: "request_rate_limited";
|
|
63
|
+
/**
|
|
64
|
+
* Every code that may cross this HTTP boundary in a refusal.
|
|
65
|
+
*
|
|
66
|
+
* Grouped below by what a consumer does about each: the gate's refusals mean
|
|
67
|
+
* *present a different credential*, the unconfigured-seam refusals mean *this
|
|
68
|
+
* deployment is not finished, try later*, and the operation refusals mean *this
|
|
69
|
+
* particular request cannot be served as asked*.
|
|
70
|
+
*/
|
|
71
|
+
export type CaysoApiErrorCode =
|
|
72
|
+
/** No credential was presented, or the header carrying it was not readable. */
|
|
73
|
+
'unauthenticated'
|
|
74
|
+
/** The credential did not parse, or its shape was not the declared envelope. */
|
|
75
|
+
| 'assertion_invalid'
|
|
76
|
+
/** The credential is past `exp`, or outside the skew allowed around it. */
|
|
77
|
+
| 'assertion_expired'
|
|
78
|
+
/** The credential names an issuer this deployment does not trust. */
|
|
79
|
+
| 'assertion_issuer_refused'
|
|
80
|
+
/** The credential names a key its issuer does not publish. */
|
|
81
|
+
| 'assertion_key_refused'
|
|
82
|
+
/** The credential is signed with an algorithm this gate does not accept. */
|
|
83
|
+
| 'assertion_algorithm_refused'
|
|
84
|
+
/** The subject is not in the namespace this deployment serves. */
|
|
85
|
+
| 'assertion_subject_refused'
|
|
86
|
+
/** This exact credential has been presented before. It is single-use. */
|
|
87
|
+
| 'assertion_replayed'
|
|
88
|
+
/** The credential is valid and does not carry the scope this operation needs. */
|
|
89
|
+
| 'assertion_scope_refused'
|
|
90
|
+
/** The request was refused by a request-rate limit. See {@link REQUEST_RATE_LIMITED}. */
|
|
91
|
+
| 'request_rate_limited'
|
|
92
|
+
/** No verifier is configured, so no credential can be checked at all. */
|
|
93
|
+
| 'verifier_not_configured'
|
|
94
|
+
/** A verifier exists and has been told about no issuer, so it trusts nobody. */
|
|
95
|
+
| 'issuer_registry_not_configured' | 'wallet_store_not_configured' | 'balance_reader_not_configured' | 'citizenship_store_not_configured'
|
|
96
|
+
/** No founder claim store is wired, so no founder wallet can be claimed. */
|
|
97
|
+
| 'founder_claim_store_not_configured' | 'sign_up_grant_not_configured'
|
|
98
|
+
/**
|
|
99
|
+
* No per-band grant-envelope schedule is configured, so a grant cannot be priced
|
|
100
|
+
* against the envelope its band allows. Distinct from
|
|
101
|
+
* `sign_up_grant_not_configured` on purpose: "nobody set the grant" and "no
|
|
102
|
+
* schedule to price the grant against" are different facts for an operator to
|
|
103
|
+
* read — the same distinction `allowance_ceiling_published_value_unavailable`
|
|
104
|
+
* draws for the Signatory threshold.
|
|
105
|
+
*/
|
|
106
|
+
| 'sign_up_grant_envelope_policy_not_configured'
|
|
107
|
+
/**
|
|
108
|
+
* The configured grant exceeds the total reward envelope the band in force
|
|
109
|
+
* allows. A policy refusal rather than a caller's mistake: the envelope tapers,
|
|
110
|
+
* so a figure approved for a lower band over-grants once a quickening has passed.
|
|
111
|
+
* It is the quickening being visible instead of silent.
|
|
112
|
+
*/
|
|
113
|
+
| 'sign_up_grant_exceeds_tier_envelope' | 'purchase_store_not_configured' | 'purchase_result_reader_not_configured' | 'purchase_cancel_store_not_configured' | 'published_value_not_configured' | 'gateway_not_configured' | 'schema_version_reader_not_configured'
|
|
114
|
+
/**
|
|
115
|
+
* No commercial payment store is wired, or this deployment has not been told
|
|
116
|
+
* which wallet is the Treasury. Both close the route: a payment the service
|
|
117
|
+
* could not hold to "the Treasury takes no part" is not one it may make
|
|
118
|
+
* (CAY-0079 §3).
|
|
119
|
+
*/
|
|
120
|
+
| 'commercial_payment_store_not_configured'
|
|
121
|
+
/**
|
|
122
|
+
* The citizen market is shut on this deployment: no store is wired, or a figure
|
|
123
|
+
* the book needs is not set in the canon and so not configured here (CAY-0080,
|
|
124
|
+
* *Figures*). An unset figure is a closed door and never "no limit", and it is
|
|
125
|
+
* not a member of the market's refusal unions, because it describes the
|
|
126
|
+
* deployment and not the quote.
|
|
127
|
+
*/
|
|
128
|
+
| 'citizen_market_not_configured'
|
|
129
|
+
/**
|
|
130
|
+
* The Treasury's buy-back is shut on this deployment: no buy-back store is wired,
|
|
131
|
+
* or one of the buy-back's own figures — the limit per holder, the
|
|
132
|
+
* recent-acquisition window — is not set in the canon and so not configured here
|
|
133
|
+
* (CAY-0080, *Figures*). The book may still be open. An unset limit is never "no
|
|
134
|
+
* limit".
|
|
135
|
+
*/
|
|
136
|
+
| 'buy_back_not_configured'
|
|
137
|
+
/**
|
|
138
|
+
* No sterling observation has ever been recorded, so there is no eligible sterling
|
|
139
|
+
* to measure the request against. It says nothing about the request, which may be
|
|
140
|
+
* retried unchanged once somebody observes. The purchase path answers it when there
|
|
141
|
+
* is no backing ceiling to measure against, and the buy-back when there is no
|
|
142
|
+
* eligible sterling to reserve from (CAY-0080).
|
|
143
|
+
*/
|
|
144
|
+
| 'sterling_not_observed'
|
|
145
|
+
/**
|
|
146
|
+
* This deployment holds no key it may sign a marketplace receipt with, so it
|
|
147
|
+
* cannot write a marketplace sale or refund: Store Platform grants nothing on a
|
|
148
|
+
* receipt it cannot verify, and a sale with no receipt is cents moved for nothing
|
|
149
|
+
* the buyer can use (CAY-0083 §1). Published before the marketplace checkout that
|
|
150
|
+
* answers it is served, so a consumer exhausting this union renders it from the
|
|
151
|
+
* start.
|
|
152
|
+
*/
|
|
153
|
+
| 'receipt_signing_not_configured'
|
|
154
|
+
/** The request body or parameters did not satisfy the declared schema. */
|
|
155
|
+
| 'invalid_request'
|
|
156
|
+
/** There is no such purchase under this caller's wallet. */
|
|
157
|
+
| 'not_found'
|
|
158
|
+
/** Something failed on the way and the refusal discloses nothing further. */
|
|
159
|
+
| 'internal_error' | PurchaseFailureReason | PurchaseCancelRefusalReason | FounderClaimRefusal | CommercialPaymentRefusal | QuotePlacementRefusal | QuoteWithdrawalRefusal | BuyBackRefusal | MarketplaceReceiptReadRefusal | MarketplaceOrderRefusal | MarketplaceRefundRefusal;
|
|
160
|
+
/**
|
|
161
|
+
* The body of every refusal on this surface: one code, and nothing beside it.
|
|
162
|
+
*
|
|
163
|
+
* Nothing else is in this shape on purpose. A refusal that carried a message would
|
|
164
|
+
* invite a consumer to render prose it does not control and cannot translate; a
|
|
165
|
+
* refusal that carried counts, windows or a moment to try again would describe the
|
|
166
|
+
* control that produced it to whoever was probing it. The code is the whole of the
|
|
167
|
+
* contract, and the service answers exactly this object.
|
|
168
|
+
*/
|
|
169
|
+
export interface CaysoErrorResponse {
|
|
170
|
+
readonly error: CaysoApiErrorCode;
|
|
171
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
/**
|
|
17
|
+
* The single public code for a request refused by a request-rate limit, published
|
|
18
|
+
* as a value so a consumer compares a refusal against the contract's own string
|
|
19
|
+
* rather than a retyped copy of it (the reason `NOT_PROVISIONED` is a value too).
|
|
20
|
+
*
|
|
21
|
+
* It is `request_rate_limited` rather than anything naming a credential, and that
|
|
22
|
+
* is deliberate (CAY-0058 §5): the two limits that can produce it refuse at
|
|
23
|
+
* different moments — one of them before any credential has been read, and so on a
|
|
24
|
+
* request that carries none at all — and a code that named a credential would be a
|
|
25
|
+
* lie on half the refusals and a hint about the shape of the other half on the
|
|
26
|
+
* rest. One code, one body, one status, from both origins.
|
|
27
|
+
*/
|
|
28
|
+
export const REQUEST_RATE_LIMITED = 'request_rate_limited';
|