@pay-skill/sdk 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +154 -0
  2. package/dist/auth.d.ts +47 -0
  3. package/dist/auth.d.ts.map +1 -0
  4. package/dist/auth.js +121 -0
  5. package/dist/auth.js.map +1 -0
  6. package/dist/client.d.ts +93 -0
  7. package/dist/client.d.ts.map +1 -0
  8. package/dist/client.js +391 -0
  9. package/dist/client.js.map +1 -0
  10. package/dist/errors.d.ts +24 -0
  11. package/dist/errors.d.ts.map +1 -0
  12. package/dist/errors.js +42 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/index.d.ts +13 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +7 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/models.d.ts +69 -0
  19. package/dist/models.d.ts.map +1 -0
  20. package/dist/models.js +2 -0
  21. package/dist/models.js.map +1 -0
  22. package/dist/ows-signer.d.ts +75 -0
  23. package/dist/ows-signer.d.ts.map +1 -0
  24. package/dist/ows-signer.js +130 -0
  25. package/dist/ows-signer.js.map +1 -0
  26. package/dist/signer.d.ts +46 -0
  27. package/dist/signer.d.ts.map +1 -0
  28. package/dist/signer.js +112 -0
  29. package/dist/signer.js.map +1 -0
  30. package/dist/wallet.d.ts +121 -0
  31. package/dist/wallet.d.ts.map +1 -0
  32. package/dist/wallet.js +328 -0
  33. package/dist/wallet.js.map +1 -0
  34. package/eslint.config.js +22 -0
  35. package/package.json +44 -0
  36. package/src/auth.ts +200 -0
  37. package/src/client.ts +644 -0
  38. package/src/eip3009.ts +79 -0
  39. package/src/errors.ts +48 -0
  40. package/src/index.ts +51 -0
  41. package/src/models.ts +77 -0
  42. package/src/ows-signer.ts +223 -0
  43. package/src/signer.ts +147 -0
  44. package/src/wallet.ts +445 -0
  45. package/tests/test_auth_rejection.ts +154 -0
  46. package/tests/test_crypto.ts +251 -0
  47. package/tests/test_e2e.ts +158 -0
  48. package/tests/test_errors.ts +36 -0
  49. package/tests/test_ows_integration.ts +92 -0
  50. package/tests/test_ows_signer.ts +365 -0
  51. package/tests/test_signer.ts +47 -0
  52. package/tests/test_validation.ts +66 -0
  53. package/tsconfig.json +19 -0
@@ -0,0 +1,75 @@
1
+ /**
2
+ * OWS (Open Wallet Standard) signer adapter.
3
+ *
4
+ * Wraps the @open-wallet-standard/core FFI module to implement the Pay
5
+ * Signer interface. OWS handles encrypted key storage + policy-gated signing;
6
+ * this adapter translates between Pay's (domain, types, value) EIP-712
7
+ * calling convention and OWS's JSON string convention.
8
+ *
9
+ * Priority: Pay's own CLI signer is #1, OWS is #2. OWS only activates when
10
+ * OWS_WALLET_ID is set AND @open-wallet-standard/core is installed. If the
11
+ * env var is set but the package is missing, creation fails loud with
12
+ * install instructions.
13
+ *
14
+ * Usage:
15
+ * const signer = await OwsSigner.create({ walletId: "pay-my-agent" });
16
+ * const wallet = new Wallet({ signer });
17
+ */
18
+ import type { Signer } from "./signer.js";
19
+ /** EIP-712 domain fields. */
20
+ export interface TypedDataDomain {
21
+ name?: string;
22
+ version?: string;
23
+ chainId?: number | bigint;
24
+ verifyingContract?: string;
25
+ }
26
+ /** EIP-712 type definitions. */
27
+ export interface TypedDataTypes {
28
+ [typeName: string]: Array<{
29
+ name: string;
30
+ type: string;
31
+ }>;
32
+ }
33
+ /** Options for {@link OwsSigner.create}. */
34
+ export interface OwsSignerOptions {
35
+ /** OWS wallet name or UUID (e.g. "pay-my-agent"). */
36
+ walletId: string;
37
+ /** Chain name - only used for logging, not passed to OWS. Default: "base". */
38
+ chain?: string;
39
+ /** OWS API key token (passed as passphrase to OWS signing calls). */
40
+ owsApiKey?: string;
41
+ /** @internal Inject OWS module for testing - bypasses dynamic import. */
42
+ _owsModule?: unknown;
43
+ }
44
+ /**
45
+ * Signer backed by the Open Wallet Standard.
46
+ *
47
+ * - Keys live in OWS's encrypted vault (~/.ows/wallets/), never in env vars.
48
+ * - Signing calls go through OWS FFI, which evaluates policy rules before signing.
49
+ * - Use the static {@link create} factory - the constructor is private because
50
+ * address resolution requires a synchronous FFI call that must happen before
51
+ * sign() can work.
52
+ */
53
+ export declare class OwsSigner implements Signer {
54
+ #private;
55
+ private constructor();
56
+ /**
57
+ * Create an OwsSigner by resolving the wallet address from OWS.
58
+ *
59
+ * Lazily imports @open-wallet-standard/core so the module is only required
60
+ * when OWS is actually used (keeps it an optional peer dependency).
61
+ */
62
+ static create(options: OwsSignerOptions): Promise<OwsSigner>;
63
+ get address(): string;
64
+ sign(_hash: Uint8Array): Uint8Array;
65
+ /**
66
+ * Sign EIP-712 typed data via OWS FFI.
67
+ *
68
+ * This is the primary signing method for OWS. Pay's auth module should
69
+ * call this instead of sign() when an OwsSigner is detected.
70
+ */
71
+ signTypedData(domain: TypedDataDomain, types: TypedDataTypes, value: Record<string, unknown>): Promise<string>;
72
+ /** Prevent wallet ID / key leakage in serialization. */
73
+ toJSON(): Record<string, string>;
74
+ }
75
+ //# sourceMappingURL=ows-signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ows-signer.d.ts","sourceRoot":"","sources":["../src/ows-signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAwB1C,6BAA6B;AAC7B,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,gCAAgC;AAChC,MAAM,WAAW,cAAc;IAC7B,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC3D;AAED,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,qBAAa,SAAU,YAAW,MAAM;;IAMtC,OAAO;IAYP;;;;;OAKG;WACU,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAqClE,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;IAQnC;;;;;OAKG;IACG,aAAa,CACjB,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC;IAuDlB,wDAAwD;IACxD,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAOjC"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * OWS (Open Wallet Standard) signer adapter.
3
+ *
4
+ * Wraps the @open-wallet-standard/core FFI module to implement the Pay
5
+ * Signer interface. OWS handles encrypted key storage + policy-gated signing;
6
+ * this adapter translates between Pay's (domain, types, value) EIP-712
7
+ * calling convention and OWS's JSON string convention.
8
+ *
9
+ * Priority: Pay's own CLI signer is #1, OWS is #2. OWS only activates when
10
+ * OWS_WALLET_ID is set AND @open-wallet-standard/core is installed. If the
11
+ * env var is set but the package is missing, creation fails loud with
12
+ * install instructions.
13
+ *
14
+ * Usage:
15
+ * const signer = await OwsSigner.create({ walletId: "pay-my-agent" });
16
+ * const wallet = new Wallet({ signer });
17
+ */
18
+ /**
19
+ * Signer backed by the Open Wallet Standard.
20
+ *
21
+ * - Keys live in OWS's encrypted vault (~/.ows/wallets/), never in env vars.
22
+ * - Signing calls go through OWS FFI, which evaluates policy rules before signing.
23
+ * - Use the static {@link create} factory - the constructor is private because
24
+ * address resolution requires a synchronous FFI call that must happen before
25
+ * sign() can work.
26
+ */
27
+ export class OwsSigner {
28
+ #walletId;
29
+ #address;
30
+ #owsApiKey;
31
+ #ows;
32
+ constructor(walletId, address, owsModule, owsApiKey) {
33
+ this.#walletId = walletId;
34
+ this.#address = address;
35
+ this.#ows = owsModule;
36
+ this.#owsApiKey = owsApiKey;
37
+ }
38
+ /**
39
+ * Create an OwsSigner by resolving the wallet address from OWS.
40
+ *
41
+ * Lazily imports @open-wallet-standard/core so the module is only required
42
+ * when OWS is actually used (keeps it an optional peer dependency).
43
+ */
44
+ static async create(options) {
45
+ let owsModule;
46
+ if (options._owsModule) {
47
+ owsModule = options._owsModule;
48
+ }
49
+ else {
50
+ try {
51
+ // Dynamic string prevents TypeScript from statically resolving this
52
+ // optional peer dependency at compile time.
53
+ const moduleName = "@open-wallet-standard/core";
54
+ owsModule = (await import(moduleName));
55
+ }
56
+ catch {
57
+ throw new Error("OWS_WALLET_ID is set but @open-wallet-standard/core is not installed. " +
58
+ "Install it with: npm install @open-wallet-standard/core");
59
+ }
60
+ }
61
+ const walletInfo = owsModule.getWallet(options.walletId);
62
+ const evmAccount = walletInfo.accounts.find((a) => a.chainId === "evm" || a.chainId.startsWith("eip155:"));
63
+ if (!evmAccount) {
64
+ throw new Error(`No EVM account found in OWS wallet '${options.walletId}'. ` +
65
+ `Available chains: ${walletInfo.accounts.map((a) => a.chainId).join(", ") || "none"}.`);
66
+ }
67
+ return new OwsSigner(options.walletId, evmAccount.address, owsModule, options.owsApiKey);
68
+ }
69
+ get address() {
70
+ return this.#address;
71
+ }
72
+ sign(_hash) {
73
+ throw new Error("OwsSigner does not support raw hash signing. " +
74
+ "OWS only supports EIP-712 typed data signing. " +
75
+ "Use CliSigner or RawKeySigner for operations that require sign().");
76
+ }
77
+ /**
78
+ * Sign EIP-712 typed data via OWS FFI.
79
+ *
80
+ * This is the primary signing method for OWS. Pay's auth module should
81
+ * call this instead of sign() when an OwsSigner is detected.
82
+ */
83
+ async signTypedData(domain, types, value) {
84
+ // 1. Derive primaryType: first key in types that is NOT "EIP712Domain".
85
+ const primaryType = Object.keys(types).filter((k) => k !== "EIP712Domain")[0] ?? "Request";
86
+ // 2. Build EIP712Domain type array dynamically from domain object fields.
87
+ const eip712DomainType = [];
88
+ if (domain.name !== undefined)
89
+ eip712DomainType.push({ name: "name", type: "string" });
90
+ if (domain.version !== undefined)
91
+ eip712DomainType.push({ name: "version", type: "string" });
92
+ if (domain.chainId !== undefined)
93
+ eip712DomainType.push({ name: "chainId", type: "uint256" });
94
+ if (domain.verifyingContract !== undefined)
95
+ eip712DomainType.push({
96
+ name: "verifyingContract",
97
+ type: "address",
98
+ });
99
+ // 3. Assemble full EIP-712 typed data structure.
100
+ const fullTypedData = {
101
+ types: { EIP712Domain: eip712DomainType, ...types },
102
+ primaryType,
103
+ domain,
104
+ message: value,
105
+ };
106
+ // 4. Serialize - handle BigInt values.
107
+ const json = JSON.stringify(fullTypedData, (_key, v) => typeof v === "bigint" ? v.toString() : v);
108
+ // 5. Call OWS FFI. Chain is always "evm" for EVM signing.
109
+ const result = this.#ows.signTypedData(this.#walletId, "evm", json, this.#owsApiKey);
110
+ // 6. Concatenate r+s+v into 65-byte Ethereum signature.
111
+ const sig = result.signature.startsWith("0x")
112
+ ? result.signature.slice(2)
113
+ : result.signature;
114
+ // If OWS already returns r+s+v (130 hex chars), use as-is.
115
+ if (sig.length === 130) {
116
+ return `0x${sig}`;
117
+ }
118
+ // Otherwise it's r+s (128 hex chars), append v.
119
+ const v = (result.recoveryId ?? 0) + 27;
120
+ return `0x${sig}${v.toString(16).padStart(2, "0")}`;
121
+ }
122
+ /** Prevent wallet ID / key leakage in serialization. */
123
+ toJSON() {
124
+ return { address: this.#address, walletId: this.#walletId };
125
+ }
126
+ [Symbol.for("nodejs.util.inspect.custom")]() {
127
+ return `OwsSigner { address: '${this.#address}', wallet: '${this.#walletId}' }`;
128
+ }
129
+ }
130
+ //# sourceMappingURL=ows-signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ows-signer.js","sourceRoot":"","sources":["../src/ows-signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAmDH;;;;;;;;GAQG;AACH,MAAM,OAAO,SAAS;IACX,SAAS,CAAS;IAClB,QAAQ,CAAS;IACjB,UAAU,CAAqB;IAC/B,IAAI,CAAY;IAEzB,YACE,QAAgB,EAChB,OAAe,EACf,SAAoB,EACpB,SAAkB;QAElB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAyB;QAC3C,IAAI,SAAoB,CAAC;QACzB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,SAAS,GAAG,OAAO,CAAC,UAAuB,CAAC;QAC9C,CAAC;aAAM,CAAC;YACN,IAAI,CAAC;gBACH,oEAAoE;gBACpE,4CAA4C;gBAC5C,MAAM,UAAU,GAAG,4BAA4B,CAAC;gBAChD,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAyB,CAAC;YACjE,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,IAAI,KAAK,CACb,wEAAwE;oBACtE,yDAAyD,CAC5D,CAAC;YACJ,CAAC;QACH,CAAC;QAED,MAAM,UAAU,GAAG,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACzD,MAAM,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CACzC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,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AU,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;QACxC,OAAO,KAAK,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IACtD,CAAC;IAED,wDAAwD;IACxD,MAAM;QACJ,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;IAC9D,CAAC;IAED,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACxC,OAAO,yBAAyB,IAAI,CAAC,QAAQ,eAAe,IAAI,CAAC,SAAS,KAAK,CAAC;IAClF,CAAC;CACF"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Signer interface and implementations.
3
+ *
4
+ * Three modes:
5
+ * 1. CLI signer (default): subprocess call to `pay sign`
6
+ * 2. Raw key: from PAYSKILL_KEY environment variable (dev/testing only)
7
+ * 3. Custom: user provides a sign(hash) -> signature callback
8
+ */
9
+ /** Abstract signer interface. */
10
+ export interface Signer {
11
+ /** Sign a 32-byte hash. Returns 65-byte signature (r || s || v). */
12
+ sign(hash: Uint8Array): Uint8Array;
13
+ /** The signer's Ethereum address (0x-prefixed, checksummed). */
14
+ readonly address: string;
15
+ }
16
+ /** Signs via the `pay sign` CLI subprocess. */
17
+ export declare class CliSigner implements Signer {
18
+ private readonly command;
19
+ readonly address: string;
20
+ constructor(command?: string, address?: string);
21
+ sign(hash: Uint8Array): Uint8Array;
22
+ }
23
+ /** Signs with a raw private key using viem. Dev/testing only. */
24
+ export declare class RawKeySigner implements Signer {
25
+ private readonly _key;
26
+ readonly address: string;
27
+ constructor(key?: string);
28
+ sign(hash: Uint8Array): Uint8Array;
29
+ /** Async sign — preferred over sync sign(). */
30
+ signAsync(hash: Uint8Array): Promise<Uint8Array>;
31
+ }
32
+ /** Delegates signing to a user-provided callback. */
33
+ export declare class CallbackSigner implements Signer {
34
+ private readonly callback;
35
+ readonly address: string;
36
+ constructor(callback: (hash: Uint8Array) => Uint8Array, address?: string);
37
+ sign(hash: Uint8Array): Uint8Array;
38
+ }
39
+ /** Factory for creating signers. */
40
+ export declare function createSigner(mode?: "cli" | "raw" | "custom", options?: {
41
+ command?: string;
42
+ key?: string;
43
+ address?: string;
44
+ callback?: (hash: Uint8Array) => Uint8Array;
45
+ }): Signer;
46
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,iCAAiC;AACjC,MAAM,WAAW,MAAM;IACrB,oEAAoE;IACpE,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IACnC,gEAAgE;IAChE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,+CAA+C;AAC/C,qBAAa,SAAU,YAAW,MAAM;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,SAAQ,EAAE,OAAO,SAAK;IAgBzC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU;CASnC;AAED,iEAAiE;AACjE,qBAAa,YAAa,YAAW,MAAM;IACzC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAM;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,GAAG,CAAC,EAAE,MAAM;IAYxB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU;IAelC,+CAA+C;IACzC,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAMvD;AAED,qDAAqD;AACrD,qBAAa,cAAe,YAAW,MAAM;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmC;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAGvB,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,EAC1C,OAAO,SAAK;IAMd,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU;CAGnC;AAED,oCAAoC;AACpC,wBAAgB,YAAY,CAC1B,IAAI,GAAE,KAAK,GAAG,KAAK,GAAG,QAAgB,EACtC,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,CAAC;CACxC,GACL,MAAM,CAcR"}
package/dist/signer.js ADDED
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Signer interface and implementations.
3
+ *
4
+ * Three modes:
5
+ * 1. CLI signer (default): subprocess call to `pay sign`
6
+ * 2. Raw key: from PAYSKILL_KEY environment variable (dev/testing only)
7
+ * 3. Custom: user provides a sign(hash) -> signature callback
8
+ */
9
+ import { execFileSync } from "node:child_process";
10
+ import { privateKeyToAccount, sign as viemSign, serializeSignature, } from "viem/accounts";
11
+ /** Signs via the `pay sign` CLI subprocess. */
12
+ export class CliSigner {
13
+ command;
14
+ address;
15
+ constructor(command = "pay", address = "") {
16
+ this.command = command;
17
+ if (address) {
18
+ this.address = address;
19
+ }
20
+ else {
21
+ try {
22
+ this.address = execFileSync(this.command, ["address"], {
23
+ encoding: "utf-8",
24
+ timeout: 10_000,
25
+ }).trim();
26
+ }
27
+ catch {
28
+ this.address = "";
29
+ }
30
+ }
31
+ }
32
+ sign(hash) {
33
+ const hexHash = Buffer.from(hash).toString("hex");
34
+ const result = execFileSync(this.command, ["sign"], {
35
+ input: hexHash,
36
+ encoding: "utf-8",
37
+ timeout: 30_000,
38
+ });
39
+ return Buffer.from(result.trim(), "hex");
40
+ }
41
+ }
42
+ /** Signs with a raw private key using viem. Dev/testing only. */
43
+ export class RawKeySigner {
44
+ _key;
45
+ address;
46
+ constructor(key) {
47
+ const rawKey = key ?? process.env.PAYSKILL_KEY ?? "";
48
+ if (!rawKey) {
49
+ throw new Error("No key provided and PAYSKILL_KEY not set");
50
+ }
51
+ this._key = rawKey.startsWith("0x")
52
+ ? rawKey
53
+ : `0x${rawKey}`;
54
+ const account = privateKeyToAccount(this._key);
55
+ this.address = account.address;
56
+ }
57
+ sign(hash) {
58
+ // viem's sign() does raw ECDSA signing (no EIP-191 prefix)
59
+ const hashHex = ("0x" + Buffer.from(hash).toString("hex"));
60
+ // sign() is async but Signer interface is sync — we use the sync internal
61
+ // For the sync interface, we need a workaround. Since RawKeySigner is
62
+ // dev/testing only, we'll do a sync computation via signSync.
63
+ // viem doesn't expose sync sign, but we can construct manually.
64
+ // Use the async path via signAsync helper pattern.
65
+ throw new Error("RawKeySigner.sign() is synchronous but viem signing is async. " +
66
+ "Use RawKeySigner.signAsync() or use buildAuthHeaders() directly with the private key.");
67
+ }
68
+ /** Async sign — preferred over sync sign(). */
69
+ async signAsync(hash) {
70
+ const hashHex = ("0x" + Buffer.from(hash).toString("hex"));
71
+ const raw = await viemSign({ hash: hashHex, privateKey: this._key });
72
+ const sigHex = serializeSignature(raw);
73
+ return hexToBytes(sigHex);
74
+ }
75
+ }
76
+ /** Delegates signing to a user-provided callback. */
77
+ export class CallbackSigner {
78
+ callback;
79
+ address;
80
+ constructor(callback, address = "") {
81
+ this.callback = callback;
82
+ this.address = address;
83
+ }
84
+ sign(hash) {
85
+ return this.callback(hash);
86
+ }
87
+ }
88
+ /** Factory for creating signers. */
89
+ export function createSigner(mode = "cli", options = {}) {
90
+ switch (mode) {
91
+ case "cli":
92
+ return new CliSigner(options.command, options.address);
93
+ case "raw":
94
+ return new RawKeySigner(options.key);
95
+ case "custom":
96
+ if (!options.callback) {
97
+ throw new Error("custom signer requires a callback");
98
+ }
99
+ return new CallbackSigner(options.callback, options.address);
100
+ default:
101
+ throw new Error(`Unknown signer mode: ${mode}`);
102
+ }
103
+ }
104
+ function hexToBytes(hex) {
105
+ const clean = hex.startsWith("0x") ? hex.slice(2) : hex;
106
+ const bytes = new Uint8Array(clean.length / 2);
107
+ for (let i = 0; i < bytes.length; i++) {
108
+ bytes[i] = parseInt(clean.slice(i * 2, i * 2 + 2), 16);
109
+ }
110
+ return bytes;
111
+ }
112
+ //# sourceMappingURL=signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EACL,mBAAmB,EACnB,IAAI,IAAI,QAAQ,EAChB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAUvB,+CAA+C;AAC/C,MAAM,OAAO,SAAS;IACH,OAAO,CAAS;IACxB,OAAO,CAAS;IAEzB,YAAY,OAAO,GAAG,KAAK,EAAE,OAAO,GAAG,EAAE;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC;gBACH,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE;oBACrD,QAAQ,EAAE,OAAO;oBACjB,OAAO,EAAE,MAAM;iBAChB,CAAC,CAAC,IAAI,EAAE,CAAC;YACZ,CAAC;YAAC,MAAM,CAAC;gBACP,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,CAAC,IAAgB;QACnB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,EAA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,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACxD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,KAAK,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Wallet — high-level write client for agents.
3
+ * Wraps PayClient with private key signing and balance tracking.
4
+ *
5
+ * This is the primary entry point for the playground and agent integrations.
6
+ * The PayClient is lower-level (HTTP only); Wallet adds signing + state.
7
+ */
8
+ export interface WalletOptions {
9
+ privateKey: string;
10
+ chain: string;
11
+ apiUrl: string;
12
+ routerAddress: string;
13
+ /** Numeric chain ID for EIP-712 domain. If omitted, parsed from `chain`. */
14
+ chainId?: number;
15
+ }
16
+ export interface FundLinkOptions {
17
+ messages?: unknown[];
18
+ agentName?: string;
19
+ }
20
+ export interface PermitResult {
21
+ nonce: string;
22
+ deadline: number;
23
+ v: number;
24
+ r: string;
25
+ s: string;
26
+ }
27
+ export declare class Wallet {
28
+ readonly address: string;
29
+ private readonly _privateKey;
30
+ private readonly _apiUrl;
31
+ private readonly _chain;
32
+ private readonly _chainId;
33
+ private readonly _routerAddress;
34
+ private readonly _account;
35
+ /** URL path prefix extracted from apiUrl (e.g., "/api/v1"). */
36
+ private readonly _basePath;
37
+ /** Cached contracts response. */
38
+ private _contractsCache;
39
+ constructor(options: WalletOptions);
40
+ private get _authConfig();
41
+ /** Build authenticated fetch headers for an API request. */
42
+ private _authFetch;
43
+ /** Get USDC balance in human-readable units (e.g., 142.50). */
44
+ balance(): Promise<number>;
45
+ /**
46
+ * Sign an EIP-2612 permit for a given spender and amount.
47
+ * Uses the server's /permit/prepare endpoint to get the nonce and hash,
48
+ * then signs the hash locally.
49
+ * @param flow — "direct" or "tab" (used to look up the spender contract address)
50
+ * @param amount — micro-USDC amount
51
+ */
52
+ signPermit(flow: string, amount: number): Promise<PermitResult>;
53
+ /** Send a direct payment. Auto-signs permit if not provided. */
54
+ payDirect(to: string, amount: number, memo: string, options?: {
55
+ permit?: PermitResult;
56
+ }): Promise<{
57
+ tx_hash: string;
58
+ status: string;
59
+ }>;
60
+ /** Create a one-time fund link via the server. Returns the dashboard URL. */
61
+ createFundLink(options?: FundLinkOptions): Promise<string>;
62
+ /** Create a one-time withdraw link via the server. Returns the dashboard URL. */
63
+ createWithdrawLink(options?: FundLinkOptions): Promise<string>;
64
+ /** Register a webhook for this wallet. */
65
+ registerWebhook(url: string, events: string[], secret?: string): Promise<{
66
+ id: string;
67
+ }>;
68
+ /** Open a tab with a provider (positional or object form). */
69
+ openTab(providerOrOpts: string | {
70
+ to: string;
71
+ limit: number;
72
+ perUnit: number;
73
+ permit?: PermitResult;
74
+ }, amount?: number, maxChargePerCall?: number, options?: {
75
+ permit?: PermitResult;
76
+ }): Promise<{
77
+ id: string;
78
+ tab_id: string;
79
+ }>;
80
+ /** Charge a tab (provider-side). */
81
+ chargeTab(tabId: string, amountOrOpts: number | {
82
+ amount: number;
83
+ cumulative: number;
84
+ callCount: number;
85
+ providerSig: string;
86
+ }): Promise<{
87
+ status: string;
88
+ }>;
89
+ /** Close a tab. */
90
+ closeTab(tabId: string, options?: {
91
+ finalAmount?: number;
92
+ providerSig?: string;
93
+ }): Promise<{
94
+ status: string;
95
+ }>;
96
+ /** Fetch contract addresses from the API (public, no auth). */
97
+ getContracts(): Promise<{
98
+ router: string;
99
+ tab: string;
100
+ direct: string;
101
+ fee: string;
102
+ usdc: string;
103
+ chainId: number;
104
+ }>;
105
+ /** Sign a tab charge (provider-side EIP-712 signature). */
106
+ signTabCharge(contractAddr: string, tabId: string, cumulativeUnits: bigint | number, callCount: number): Promise<string>;
107
+ /** Sign a raw hash with the wallet's private key. */
108
+ private _signHash;
109
+ }
110
+ /** PrivateKeySigner — for manual EIP-712 signing in the playground. */
111
+ export declare class PrivateKeySigner {
112
+ private readonly _account;
113
+ readonly address: string;
114
+ constructor(privateKey: string);
115
+ /** Sign EIP-712 typed data. Returns hex signature. */
116
+ signTypedData(domain: Record<string, unknown>, types: Record<string, Array<{
117
+ name: string;
118
+ type: string;
119
+ }>>, message: Record<string, unknown>): Promise<string>;
120
+ }
121
+ //# sourceMappingURL=wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../src/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAQD,qBAAa,MAAM;IACjB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAM;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,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