@paydlux/agent 0.1.0 → 0.1.2
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/README.md +10 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +1 -1
- package/dist/desk.js +1 -1
- package/dist/gateway.d.ts +3 -3
- package/dist/gateway.js +5 -5
- package/dist/vault.d.ts +3 -1
- package/dist/vault.js +6 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -46,13 +46,21 @@ npx tsx stellar/demo.ts # 12 checks, live testnet
|
|
|
46
46
|
npx tsx stellar/story.ts --public # one unguessable link; approve from your phone
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
No wallet, no faucet, no config.
|
|
50
|
-
|
|
49
|
+
No wallet, no faucet, no config.
|
|
50
|
+
|
|
51
|
+
Use it as a package instead of cloning:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install @paydlux/agent
|
|
55
|
+
```
|
|
51
56
|
|
|
52
57
|
```ts
|
|
53
58
|
import { StellarVault, Gateway, PaydluxAgent } from "@paydlux/agent";
|
|
54
59
|
```
|
|
55
60
|
|
|
61
|
+
`npm run build` produces `dist/`. The package depends only on
|
|
62
|
+
`@stellar/stellar-sdk` — no transitive `toml`, so `npm audit` is clean.
|
|
63
|
+
|
|
56
64
|
`story.ts --public` matters for demos: the portal has no login, so the printed
|
|
57
65
|
link carries a 22-character key and every request without it gets a 403.
|
|
58
66
|
|
package/dist/agent.d.ts
CHANGED
package/dist/agent.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
//
|
|
6
6
|
// The agent holds one key of two. It can ask, and it can execute a mandate a
|
|
7
7
|
// human already signed. It cannot move money on its own — the ledger refuses.
|
|
8
|
-
import { Horizon, Keypair, Transaction } from "stellar-sdk";
|
|
8
|
+
import { Horizon, Keypair, Transaction } from "@stellar/stellar-sdk";
|
|
9
9
|
import { passphrase } from "./vault.js";
|
|
10
10
|
const PAY_HEADER = "x-payment";
|
|
11
11
|
export class PaydluxAgent {
|
package/dist/desk.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// - the approval is a real ledger signature, not a database flag
|
|
12
12
|
import { createServer } from "node:http";
|
|
13
13
|
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
14
|
-
import { Keypair } from "stellar-sdk";
|
|
14
|
+
import { Keypair } from "@stellar/stellar-sdk";
|
|
15
15
|
import { portalPage } from "./portal.js";
|
|
16
16
|
/** A portal link is a capability: whoever holds it can approve. So it is long,
|
|
17
17
|
* random, and compared without leaking timing. */
|
package/dist/gateway.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type IncomingMessage, type ServerResponse } from "node:http";
|
|
2
|
-
import { Transaction } from "stellar-sdk";
|
|
2
|
+
import { Transaction } from "@stellar/stellar-sdk";
|
|
3
3
|
import { StellarVault, StellarTxError, type Amount, type Mandate, type Network } from "./vault.ts";
|
|
4
4
|
import { ApprovalDesk, type DeskStore } from "./desk.ts";
|
|
5
5
|
export declare const PAY_HEADER = "x-payment";
|
|
@@ -58,7 +58,7 @@ export declare class Gateway {
|
|
|
58
58
|
payTo: string;
|
|
59
59
|
token: {
|
|
60
60
|
code: string;
|
|
61
|
-
issuer: string;
|
|
61
|
+
issuer: string | undefined;
|
|
62
62
|
};
|
|
63
63
|
vault: string;
|
|
64
64
|
mode: "approval" | "preauth";
|
|
@@ -72,7 +72,7 @@ export declare class Gateway {
|
|
|
72
72
|
*/
|
|
73
73
|
verify(uri: string, proof: PaymentProof): Promise<{
|
|
74
74
|
route: Route;
|
|
75
|
-
tx: Transaction
|
|
75
|
+
tx: Transaction;
|
|
76
76
|
hash: string;
|
|
77
77
|
}>;
|
|
78
78
|
handler(getContent: (uri: string) => string): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
package/dist/gateway.js
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Either way the agent's key alone can never move money: threshold is 2.
|
|
15
15
|
import { createServer } from "node:http";
|
|
16
|
-
import { Keypair, StrKey, Transaction } from "stellar-sdk";
|
|
17
|
-
import { StellarTxError, passphrase } from "./vault.js";
|
|
16
|
+
import { Keypair, StrKey, Transaction } from "@stellar/stellar-sdk";
|
|
17
|
+
import { StellarTxError, hex, passphrase } from "./vault.js";
|
|
18
18
|
import { ApprovalDesk } from "./desk.js";
|
|
19
19
|
export const PAY_HEADER = "x-payment";
|
|
20
20
|
export class Gateway {
|
|
@@ -123,7 +123,7 @@ export class Gateway {
|
|
|
123
123
|
|| op.asset?.getIssuer?.() !== this.cfg.vault.token.getIssuer()) {
|
|
124
124
|
throw new Error("envelope pays in a different token");
|
|
125
125
|
}
|
|
126
|
-
const hash = tx.hash()
|
|
126
|
+
const hash = hex(tx.hash());
|
|
127
127
|
if (hash !== proof.mandateHash)
|
|
128
128
|
throw new Error("envelope hash does not match the declared mandate");
|
|
129
129
|
// The vault stores the mandate as a strkey "T…" signer (base32 of the hash),
|
|
@@ -131,7 +131,7 @@ export class Gateway {
|
|
|
131
131
|
const live = await this.cfg.vault.signerSummary();
|
|
132
132
|
const registered = live.signers
|
|
133
133
|
.filter((s) => s.type === "preauth-mandate")
|
|
134
|
-
.map((s) => StrKey.decodePreAuthTx(s.key)
|
|
134
|
+
.map((s) => hex(StrKey.decodePreAuthTx(s.key)));
|
|
135
135
|
if (!registered.includes(hash)) {
|
|
136
136
|
throw new Error("mandate is not registered on the vault (expired or revoked)");
|
|
137
137
|
}
|
|
@@ -212,7 +212,7 @@ export class Gateway {
|
|
|
212
212
|
const agentSig = tx.signatures?.[0];
|
|
213
213
|
if (!agentSig)
|
|
214
214
|
throw new Error("envelope carries no agent signature");
|
|
215
|
-
const envHash = tx.hash()
|
|
215
|
+
const envHash = hex(tx.hash());
|
|
216
216
|
if (this.settled.has(envHash))
|
|
217
217
|
throw new Error("mandate already redeemed");
|
|
218
218
|
const applied = await this.cfg.vault.txExists(envHash);
|
package/dist/vault.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Asset, Horizon, Keypair, Networks } from "stellar-sdk";
|
|
1
|
+
import { Asset, Horizon, Keypair, Networks } from "@stellar/stellar-sdk";
|
|
2
2
|
export type Network = "testnet" | "public";
|
|
3
|
+
/** stellar-sdk v17 hands back Uint8Array where v13 gave Buffer. One helper, one shape. */
|
|
4
|
+
export declare function hex(b: Uint8Array | string): string;
|
|
3
5
|
/**
|
|
4
6
|
* Circle's own USDC issuer on Stellar. Not a wrapped token, not a bridge:
|
|
5
7
|
* native, and Circle is the issuer. Anyone can put "USDC" on a token name —
|
package/dist/vault.js
CHANGED
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
// amount, the payee, the window, or run it twice — the ledger says no.
|
|
15
15
|
//
|
|
16
16
|
// Verified on testnet by stellar/probe-envelope.ts before this file existed.
|
|
17
|
-
import { Account, Asset, Horizon, Keypair, Memo, Networks, Operation, StrKey, Transaction, TransactionBuilder, } from "stellar-sdk";
|
|
17
|
+
import { Account, Asset, Horizon, Keypair, Memo, Networks, Operation, StrKey, Transaction, TransactionBuilder, } from "@stellar/stellar-sdk";
|
|
18
|
+
/** stellar-sdk v17 hands back Uint8Array where v13 gave Buffer. One helper, one shape. */
|
|
19
|
+
export function hex(b) {
|
|
20
|
+
return typeof b === "string" ? b : Buffer.from(b).toString("hex");
|
|
21
|
+
}
|
|
18
22
|
/**
|
|
19
23
|
* Circle's own USDC issuer on Stellar. Not a wrapped token, not a bridge:
|
|
20
24
|
* native, and Circle is the issuer. Anyone can put "USDC" on a token name —
|
|
@@ -181,7 +185,7 @@ export class StellarVault {
|
|
|
181
185
|
if (spec.memo)
|
|
182
186
|
eb.addMemo(Memo.text(spec.memo));
|
|
183
187
|
const envelope = eb.build();
|
|
184
|
-
const hash = envelope.hash()
|
|
188
|
+
const hash = hex(envelope.hash());
|
|
185
189
|
// register the hash as a weight-1 signer. Two signatures now exist that
|
|
186
190
|
// reach threshold 2: (agent + this hash) and (principal + approver).
|
|
187
191
|
// setOptions needs med threshold 2, so registering a mandate always takes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paydlux/agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Payments for AI agents that a human approves. Spending mandates enforced on the Stellar ledger: 2-of-2 vault, pre-authorised transaction envelopes, HTTP 402, USDC.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"stellar-sdk": "^
|
|
57
|
+
"@stellar/stellar-sdk": "^17.4.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/node": "^26.6.6",
|