cascrow-sdk 0.2.0 → 0.7.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/CHANGELOG.md +32 -0
- package/README.md +44 -14
- package/dist/client.d.ts +349 -43
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +687 -65
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +226 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/v3.d.ts +128 -0
- package/dist/v3.d.ts.map +1 -0
- package/dist/v3.js +105 -0
- package/dist/v3.js.map +1 -0
- package/package.json +8 -4
package/dist/v3.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MilestoneEscrowV3, remote half: what cascrow prepares and reads for a party.
|
|
3
|
+
*
|
|
4
|
+
* Nothing in this SDK signs, holds a key or talks to a chain — cascrow never
|
|
5
|
+
* signs, sends or relays a transaction for a party (rule I9), and the SDK's main
|
|
6
|
+
* entry stays free of any keystore or file access. Signing happens in the
|
|
7
|
+
* separate `cascrow-signer` package (pinned below), which checks every prepared
|
|
8
|
+
* transaction against its own pinned chain and contract before it signs.
|
|
9
|
+
*/
|
|
10
|
+
// What every cascrow client says about MilestoneEscrowV3 — a JSON copy of
|
|
11
|
+
// V3_CLIENT_TEXT in src/lib/v3-client-text.ts (this package cannot import the
|
|
12
|
+
// app). v3-client-text-parity.test.ts holds the copy equal to the owner.
|
|
13
|
+
// BEGIN v3-client-text
|
|
14
|
+
export const V3_CLIENT_TEXT = {
|
|
15
|
+
"signerPin": "cascrow-signer@0.1.0",
|
|
16
|
+
"remoteTools": [
|
|
17
|
+
"cascrow_v3_offer",
|
|
18
|
+
"cascrow_v3_acceptance_get",
|
|
19
|
+
"cascrow_v3_acceptance_submit",
|
|
20
|
+
"cascrow_v3_prepare",
|
|
21
|
+
"cascrow_v3_report_tx",
|
|
22
|
+
"cascrow_v3_attestation",
|
|
23
|
+
"cascrow_v3_claims"
|
|
24
|
+
],
|
|
25
|
+
"codeHints": {
|
|
26
|
+
"V3_DISABLED": "MilestoneEscrowV3 is switched off for NEW money right now (offers, acceptances, funding). An escrow that already exists is never locked: object, release, refund, claim and withdraw keep working (cascrow_v3_prepare, or npx cascrow-signer@0.1.0 without cascrow at all).",
|
|
27
|
+
"RATE_UNAVAILABLE": "cascrow could not get a consistent XRP/USD rate from its two sources, so no offer can be priced. Nothing was created; retry in a minute.",
|
|
28
|
+
"V3_NOT_OFFERED": "The payer has not offered MilestoneEscrowV3 terms for this milestone yet — only the payer can (cascrow_v3_offer). The payer has been notified.",
|
|
29
|
+
"OFFER_EXISTS": "An open offer already exists for this milestone and stays valid until it expires. Wait for the payee's acceptance or for the offer to lapse; sending the same inputs again returns the same offer.",
|
|
30
|
+
"V3_OFFER_OPEN": "An open MilestoneEscrowV3 offer, or a signed acceptance that is not funded yet, is bound to this milestone or wallet, so it cannot change now. Wait until the payer funds the escrow from their own machine (npx cascrow-signer@0.1.0 fund --milestone <milestoneId>) or the offer or acceptance lapses.",
|
|
31
|
+
"ATTESTATION_PENDING": "The AI panel has not finished on this claim. Its result is a non-binding recommendation — as payer you can object NOW, before the objection deadline, without waiting for it.",
|
|
32
|
+
"CLAIM_PROOF_UNKNOWN": "This claim's proofHash matches no evidence submitted to cascrow, so there is no AI recommendation for it. As payer, judge the delivery yourself and object before the objection deadline if it is not what was agreed.",
|
|
33
|
+
"V3_ESCROW": "This milestone is held in a MilestoneEscrowV3 escrow: only its payer, payee or arbiter moves that money, on chain, with their own key. Get the unsigned transaction with cascrow_v3_prepare, or sign locally with npx cascrow-signer@0.1.0.",
|
|
34
|
+
"V2_ESCROW_PRESENT": "This milestone or its contract still carries data of the retired v2 (RLUSD) escrow, so it cannot become a MilestoneEscrowV3 escrow. Nothing was changed; contact support.",
|
|
35
|
+
"INVALID_SIGNATURE": "The acceptance signature does not verify for your linked wallet over these exact terms (EIP-712, low-s, from an ordinary account). Sign the terms returned by cascrow_v3_acceptance_get again — npx cascrow-signer@0.1.0 accept does it and checks them first.",
|
|
36
|
+
"V3_INDEX_STALE": "cascrow's index of the chain is behind. Read the escrow from the chain directly (npx cascrow-signer@0.1.0 claims, or getEscrow / ClaimSubmitted); every deadline, above all an objection window, runs on chain regardless.",
|
|
37
|
+
"ACCEPTANCE_LAPSED": "The acceptance expired without funding, so the milestone is closed — this is not a failure of either party. A new attempt is a new milestone.",
|
|
38
|
+
"NOT_COMPLETABLE_WITHOUT_ESCROW": "The work was approved, but this milestone carries an amount without a MilestoneEscrowV3 escrow, and the previous escrow system has been removed — nothing can complete or pay it, so it was left as it was and NO money moved. cascrow has opened a case for it; contact support@cascrow.com with the contract ID. Do not resubmit: your evidence is recorded.",
|
|
39
|
+
"RELEASE_HOLD_REMOVED": "releaseHoldHours was removed with the previous escrow system; send the contract without it. A MilestoneEscrowV3 escrow's review period is agreed in the payer's offer (cascrow_v3_offer), and a $0 verification contract has no payout to delay.",
|
|
40
|
+
"AMOUNT_VIA_MILESTONES": "This draft has milestones, and their amounts are the contract's amount — it cannot be set on the contract. Nothing was changed. To change an amount, delete the draft and create the contract again; before joining, the invited builder can propose other amounts in a counter-proposal, which the requester can accept.",
|
|
41
|
+
"DEADLINE_VIA_MILESTONES": "This draft has milestones, and their deadlines are the ones enforced — a contract-level deadline changes nothing, so it is refused. Nothing was changed. To change a deadline, delete the draft and create the contract again; before joining, the invited builder can propose other deadlines in a counter-proposal, which the requester can accept.",
|
|
42
|
+
"MIXED_AMOUNTS": "A contract is either verification-only (every milestone $0) or escrowed (every milestone above $0), never both. Nothing was created or changed. Set every milestone to $0, or give every milestone an amount and fund each one through a MilestoneEscrowV3 offer (cascrow_v3_offer) once the builder has joined."
|
|
43
|
+
},
|
|
44
|
+
"joined": {
|
|
45
|
+
"active": "Joined as Builder. This is a $0 verification contract, so it is active now — submit proof for a milestone (cascrow_submit_proof). No money is held or moved.",
|
|
46
|
+
"awaitingOffer": "Joined as Builder. The milestones carry an amount, so nothing is funded yet: wait for the payer's MilestoneEscrowV3 offer, then accept it with your own wallet key — npx cascrow-signer@0.1.0 accept --milestone <milestoneId>, or on the contract page. cascrow never signs for you. Submit proof once the payer has funded the milestone.",
|
|
47
|
+
"unknown": "Joined as Builder. The server did not say whether the contract is active — check it with cascrow_get_contract before submitting proof."
|
|
48
|
+
},
|
|
49
|
+
"payeeHints": {
|
|
50
|
+
"CLAIM_PROOF_UNKNOWN": "This manifest is not a sealed submission of this milestone, so cascrow will not confirm it and nothing was signed. As payee, claim with the manifestHash the evidence door returned (the upload's answer, or cascrow_get_proof_status): npx cascrow-signer@0.1.0 submit-claim --milestone <milestoneId> --proof-hash <manifestHash>."
|
|
51
|
+
},
|
|
52
|
+
"fundRemoved": "cascrow_fund_milestone was removed (and with it fundMilestone in cascrow-sdk and `cascrow fund`). A $0 verification contract is active by itself once the builder has joined — there is nothing to fund. A milestone with an amount is a MilestoneEscrowV3 escrow in native XRP: the payer offers terms (cascrow_v3_offer), the builder accepts with their own key, and the payer funds it with one transaction from their own machine — npx cascrow-signer@0.1.0 fund --milestone <milestoneId>. cascrow never signs or sends for you.",
|
|
53
|
+
"recommendation": "🧭 AI RECOMMENDATION {verdict} for this MilestoneEscrowV3 submission ({confidence}% confidence on this file) — this verdict moves NO money. The submission is YES only when every file in it has a definite AI yes; only then is it claim-ready. As payee: claim on chain with the submission's manifestHash (npx cascrow-signer@0.1.0 submit-claim --milestone <milestoneId> --proof-hash <manifestHash>). As payer: release, or object before the objection deadline.",
|
|
54
|
+
"reportTxOnlyHash": "cascrow_v3_report_tx takes a transaction HASH (0x + 64 hex characters) and nothing else. cascrow never accepts a signed transaction — broadcast it yourself to the chain's public RPC."
|
|
55
|
+
};
|
|
56
|
+
// END v3-client-text
|
|
57
|
+
/** The version of the local signer this SDK's docs and hints point to. */
|
|
58
|
+
export const CASCROW_SIGNER_PIN = V3_CLIENT_TEXT.signerPin;
|
|
59
|
+
/**
|
|
60
|
+
* What a V3 refusal code means for the caller, or null for a code that is not a V3
|
|
61
|
+
* one. Role-aware (post-review H9): `CLAIM_PROOF_UNKNOWN` without `objectionDeadline`
|
|
62
|
+
* in the body comes from `prepare?action=submitClaim` and reaches the PAYEE; with it,
|
|
63
|
+
* the claim is live and the remedy is the payer's objection.
|
|
64
|
+
*/
|
|
65
|
+
export function v3HintFor(code, body) {
|
|
66
|
+
if (!code)
|
|
67
|
+
return null;
|
|
68
|
+
const b = body && typeof body === "object" ? body : null;
|
|
69
|
+
const liveClaim = !!b && typeof b.objectionDeadline === "string";
|
|
70
|
+
const payee = V3_CLIENT_TEXT.payeeHints[code];
|
|
71
|
+
if (payee && b && !liveClaim)
|
|
72
|
+
return payee;
|
|
73
|
+
return V3_CLIENT_TEXT.codeHints[code] ?? null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The sentence for a `joinContract` answer: `activated: true` — a $0 contract, active
|
|
77
|
+
* now; `false` — a money contract waiting for the payer's MilestoneEscrowV3 offer, which
|
|
78
|
+
* the builder accepts with their own key; anything else — the server did not say.
|
|
79
|
+
*/
|
|
80
|
+
export function joinedLine(body) {
|
|
81
|
+
const activated = body && typeof body === "object" ? body.activated : undefined;
|
|
82
|
+
if (activated === true)
|
|
83
|
+
return V3_CLIENT_TEXT.joined.active;
|
|
84
|
+
if (activated === false)
|
|
85
|
+
return V3_CLIENT_TEXT.joined.awaitingOffer;
|
|
86
|
+
return V3_CLIENT_TEXT.joined.unknown;
|
|
87
|
+
}
|
|
88
|
+
/** The fields of a V3 refusal body its recipient acts on, as one line, or "" (post-review G5). */
|
|
89
|
+
export function v3RefusalDetail(body) {
|
|
90
|
+
if (!body || typeof body !== "object")
|
|
91
|
+
return "";
|
|
92
|
+
const b = body;
|
|
93
|
+
const out = [];
|
|
94
|
+
if (typeof b.remedy === "string" && b.remedy)
|
|
95
|
+
out.push(b.remedy);
|
|
96
|
+
if (Array.isArray(b.allowed))
|
|
97
|
+
out.push(`Allowed now: ${b.allowed.length ? b.allowed.map(String).join(", ") : "nothing"}.`);
|
|
98
|
+
if (typeof b.objectionDeadline === "string" && b.objectionDeadline)
|
|
99
|
+
out.push(`Objection deadline: ${b.objectionDeadline}.`);
|
|
100
|
+
if (typeof b.offerExpiresAt === "string" && b.offerExpiresAt)
|
|
101
|
+
out.push(`Open offer expires: ${b.offerExpiresAt}.`);
|
|
102
|
+
return out.join(" ");
|
|
103
|
+
}
|
|
104
|
+
export const TX_HASH_RE = /^0x[0-9a-fA-F]{64}$/;
|
|
105
|
+
//# sourceMappingURL=v3.js.map
|
package/dist/v3.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v3.js","sourceRoot":"","sources":["../src/v3.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,0EAA0E;AAC1E,8EAA8E;AAC9E,yEAAyE;AACzE,uBAAuB;AACvB,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,WAAW,EAAE,sBAAsB;IACnC,aAAa,EAAE;QACb,kBAAkB;QAClB,2BAA2B;QAC3B,8BAA8B;QAC9B,oBAAoB;QACpB,sBAAsB;QACtB,wBAAwB;QACxB,mBAAmB;KACpB;IACD,WAAW,EAAE;QACX,aAAa,EAAE,6QAA6Q;QAC5R,kBAAkB,EAAE,0IAA0I;QAC9J,gBAAgB,EAAE,gJAAgJ;QAClK,cAAc,EAAE,oMAAoM;QACpN,eAAe,EAAE,0SAA0S;QAC3T,qBAAqB,EAAE,+KAA+K;QACtM,qBAAqB,EAAE,wNAAwN;QAC/O,WAAW,EAAE,6OAA6O;QAC1P,mBAAmB,EAAE,2KAA2K;QAChM,mBAAmB,EAAE,gQAAgQ;QACrR,gBAAgB,EAAE,4NAA4N;QAC9O,mBAAmB,EAAE,+IAA+I;QACpK,gCAAgC,EAAE,gWAAgW;QAClY,sBAAsB,EAAE,kPAAkP;QAC1Q,uBAAuB,EAAE,2TA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cascrow-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "TypeScript client for the Cascrow API — AI-
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "TypeScript client for the Cascrow API — trust infrastructure for the agent economy: AI verification, on-chain reputation, and non-custodial milestone escrow (MilestoneEscrowV3, native XRP)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
|
-
"LICENSE"
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"CHANGELOG.md"
|
|
17
18
|
],
|
|
18
19
|
"sideEffects": false,
|
|
19
20
|
"engines": {
|
|
@@ -38,7 +39,10 @@
|
|
|
38
39
|
"milestone",
|
|
39
40
|
"agent",
|
|
40
41
|
"agentic",
|
|
41
|
-
"sdk"
|
|
42
|
+
"sdk",
|
|
43
|
+
"reputation",
|
|
44
|
+
"trust",
|
|
45
|
+
"agent-economy"
|
|
42
46
|
],
|
|
43
47
|
"author": "Cascrow <dev@cascrow.com>",
|
|
44
48
|
"license": "MIT",
|