@payai/x402-evm 2.4.1 → 2.4.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.
Files changed (143) hide show
  1. package/dist/cjs/batch-settlement/client/file-storage.d.ts +47 -0
  2. package/dist/cjs/batch-settlement/client/file-storage.js +116 -0
  3. package/dist/cjs/batch-settlement/client/file-storage.js.map +1 -0
  4. package/dist/cjs/batch-settlement/client/index.d.ts +111 -0
  5. package/dist/cjs/batch-settlement/client/index.js +1565 -0
  6. package/dist/cjs/batch-settlement/client/index.js.map +1 -0
  7. package/dist/cjs/batch-settlement/facilitator/index.d.ts +71 -0
  8. package/dist/cjs/batch-settlement/facilitator/index.js +2032 -0
  9. package/dist/cjs/batch-settlement/facilitator/index.js.map +1 -0
  10. package/dist/cjs/batch-settlement/server/file-storage.d.ts +53 -0
  11. package/dist/cjs/batch-settlement/server/file-storage.js +181 -0
  12. package/dist/cjs/batch-settlement/server/file-storage.js.map +1 -0
  13. package/dist/cjs/batch-settlement/server/index.d.ts +491 -0
  14. package/dist/cjs/batch-settlement/server/index.js +1960 -0
  15. package/dist/cjs/batch-settlement/server/index.js.map +1 -0
  16. package/dist/cjs/batch-settlement/server/redis-storage.d.ts +87 -0
  17. package/dist/cjs/batch-settlement/server/redis-storage.js +181 -0
  18. package/dist/cjs/batch-settlement/server/redis-storage.js.map +1 -0
  19. package/dist/cjs/exact/client/index.d.ts +6 -4
  20. package/dist/cjs/exact/client/index.js +7 -5
  21. package/dist/cjs/exact/client/index.js.map +1 -1
  22. package/dist/cjs/exact/facilitator/index.d.ts +16 -9
  23. package/dist/cjs/exact/facilitator/index.js +35 -7
  24. package/dist/cjs/exact/facilitator/index.js.map +1 -1
  25. package/dist/cjs/exact/server/index.js +40 -1
  26. package/dist/cjs/exact/server/index.js.map +1 -1
  27. package/dist/cjs/exact/v1/client/index.d.ts +2 -1
  28. package/dist/cjs/exact/v1/client/index.js.map +1 -1
  29. package/dist/cjs/exact/v1/facilitator/index.d.ts +11 -5
  30. package/dist/cjs/exact/v1/facilitator/index.js +16 -2
  31. package/dist/cjs/exact/v1/facilitator/index.js.map +1 -1
  32. package/dist/cjs/index.d.ts +113 -7
  33. package/dist/cjs/index.js +1353 -5
  34. package/dist/cjs/index.js.map +1 -1
  35. package/dist/{esm/permit2-CyZxwngN.d.mts → cjs/permit2-DhJRUcgY.d.ts} +1 -13
  36. package/dist/cjs/rpc-DULZzRne.d.ts +13 -0
  37. package/dist/cjs/scheme-CvkPJXBD.d.ts +307 -0
  38. package/dist/{esm/scheme-DCR7hsa3.d.mts → cjs/scheme-DTQFE9xp.d.ts} +2 -2
  39. package/dist/{esm/signer-D912R4mq.d.mts → cjs/signer-tYS6Y46X.d.ts} +3 -0
  40. package/dist/cjs/storage-6W5MO46W.d.ts +50 -0
  41. package/dist/cjs/storage-Bl6aD0Xg.d.ts +81 -0
  42. package/dist/cjs/types-CF8P2-NM.d.ts +180 -0
  43. package/dist/cjs/upto/client/index.d.ts +5 -3
  44. package/dist/cjs/upto/client/index.js +7 -5
  45. package/dist/cjs/upto/client/index.js.map +1 -1
  46. package/dist/cjs/upto/facilitator/index.d.ts +2 -1
  47. package/dist/cjs/upto/facilitator/index.js +2 -1
  48. package/dist/cjs/upto/facilitator/index.js.map +1 -1
  49. package/dist/cjs/upto/server/index.js +40 -1
  50. package/dist/cjs/upto/server/index.js.map +1 -1
  51. package/dist/cjs/v1/index.d.ts +2 -1
  52. package/dist/cjs/v1/index.js.map +1 -1
  53. package/dist/esm/batch-settlement/client/file-storage.d.mts +47 -0
  54. package/dist/esm/batch-settlement/client/file-storage.mjs +63 -0
  55. package/dist/esm/batch-settlement/client/file-storage.mjs.map +1 -0
  56. package/dist/esm/batch-settlement/client/index.d.mts +111 -0
  57. package/dist/esm/batch-settlement/client/index.mjs +59 -0
  58. package/dist/esm/batch-settlement/client/index.mjs.map +1 -0
  59. package/dist/esm/batch-settlement/facilitator/index.d.mts +71 -0
  60. package/dist/esm/batch-settlement/facilitator/index.mjs +1235 -0
  61. package/dist/esm/batch-settlement/facilitator/index.mjs.map +1 -0
  62. package/dist/esm/batch-settlement/server/file-storage.d.mts +53 -0
  63. package/dist/esm/batch-settlement/server/file-storage.mjs +128 -0
  64. package/dist/esm/batch-settlement/server/file-storage.mjs.map +1 -0
  65. package/dist/esm/batch-settlement/server/index.d.mts +491 -0
  66. package/dist/esm/batch-settlement/server/index.mjs +1645 -0
  67. package/dist/esm/batch-settlement/server/index.mjs.map +1 -0
  68. package/dist/esm/batch-settlement/server/redis-storage.d.mts +87 -0
  69. package/dist/esm/batch-settlement/server/redis-storage.mjs +156 -0
  70. package/dist/esm/batch-settlement/server/redis-storage.mjs.map +1 -0
  71. package/dist/esm/chunk-2EUQTNJO.mjs +38 -0
  72. package/dist/esm/chunk-2EUQTNJO.mjs.map +1 -0
  73. package/dist/esm/chunk-53USC5VE.mjs +47 -0
  74. package/dist/esm/chunk-53USC5VE.mjs.map +1 -0
  75. package/dist/esm/{chunk-GJ57SZGI.mjs → chunk-6WQOGWBE.mjs} +7 -5
  76. package/dist/esm/{chunk-GJ57SZGI.mjs.map → chunk-6WQOGWBE.mjs.map} +1 -1
  77. package/dist/esm/{chunk-F3OOHBAW.mjs → chunk-BTYNCDNS.mjs} +42 -2
  78. package/dist/esm/{chunk-F3OOHBAW.mjs.map → chunk-BTYNCDNS.mjs.map} +1 -1
  79. package/dist/esm/{chunk-ERK2ZPOY.mjs → chunk-CSQS7ZON.mjs} +27 -7
  80. package/dist/esm/chunk-CSQS7ZON.mjs.map +1 -0
  81. package/dist/esm/chunk-GD4MKCN7.mjs +57 -0
  82. package/dist/esm/chunk-GD4MKCN7.mjs.map +1 -0
  83. package/dist/esm/chunk-HYABYUBD.mjs +432 -0
  84. package/dist/esm/chunk-HYABYUBD.mjs.map +1 -0
  85. package/dist/esm/chunk-IN5YIT5C.mjs +159 -0
  86. package/dist/esm/chunk-IN5YIT5C.mjs.map +1 -0
  87. package/dist/esm/{chunk-JII456TS.mjs → chunk-JK7SLLF7.mjs} +1 -1
  88. package/dist/esm/chunk-JK7SLLF7.mjs.map +1 -0
  89. package/dist/esm/{chunk-C4ZQMS77.mjs → chunk-MACPBXCT.mjs} +2 -216
  90. package/dist/esm/chunk-MACPBXCT.mjs.map +1 -0
  91. package/dist/esm/chunk-NKYVYGRA.mjs +911 -0
  92. package/dist/esm/chunk-NKYVYGRA.mjs.map +1 -0
  93. package/dist/esm/{chunk-FQJR4RCF.mjs → chunk-R7I3RZFF.mjs} +10 -6
  94. package/dist/esm/{chunk-FQJR4RCF.mjs.map → chunk-R7I3RZFF.mjs.map} +1 -1
  95. package/dist/esm/{chunk-CRT6YNY5.mjs → chunk-RWLVVO3B.mjs} +21 -61
  96. package/dist/esm/chunk-RWLVVO3B.mjs.map +1 -0
  97. package/dist/esm/chunk-TGFAVNUD.mjs +111 -0
  98. package/dist/esm/chunk-TGFAVNUD.mjs.map +1 -0
  99. package/dist/esm/chunk-TW7Z65AO.mjs +34 -0
  100. package/dist/esm/chunk-TW7Z65AO.mjs.map +1 -0
  101. package/dist/esm/chunk-U4HCGTLU.mjs +35 -0
  102. package/dist/esm/chunk-U4HCGTLU.mjs.map +1 -0
  103. package/dist/esm/chunk-VS3RYAYE.mjs +80 -0
  104. package/dist/esm/chunk-VS3RYAYE.mjs.map +1 -0
  105. package/dist/esm/chunk-W6ON4LG2.mjs +39 -0
  106. package/dist/esm/chunk-W6ON4LG2.mjs.map +1 -0
  107. package/dist/esm/{chunk-WKBC5YMI.mjs → chunk-YMQCTKDU.mjs} +23 -55
  108. package/dist/esm/chunk-YMQCTKDU.mjs.map +1 -0
  109. package/dist/esm/exact/client/index.d.mts +6 -4
  110. package/dist/esm/exact/client/index.mjs +10 -5
  111. package/dist/esm/exact/facilitator/index.d.mts +16 -9
  112. package/dist/esm/exact/facilitator/index.mjs +36 -14
  113. package/dist/esm/exact/facilitator/index.mjs.map +1 -1
  114. package/dist/esm/exact/server/index.mjs +1 -1
  115. package/dist/esm/exact/v1/client/index.d.mts +2 -1
  116. package/dist/esm/exact/v1/client/index.mjs +5 -2
  117. package/dist/esm/exact/v1/facilitator/index.d.mts +11 -5
  118. package/dist/esm/exact/v1/facilitator/index.mjs +5 -2
  119. package/dist/esm/index.d.mts +113 -7
  120. package/dist/esm/index.mjs +53 -7
  121. package/dist/esm/index.mjs.map +1 -1
  122. package/dist/esm/permit2-DhJRUcgY.d.mts +729 -0
  123. package/dist/esm/rpc-DULZzRne.d.mts +13 -0
  124. package/dist/esm/scheme-DtbSS4Fk.d.mts +307 -0
  125. package/dist/esm/scheme-gtqAIYPJ.d.mts +47 -0
  126. package/dist/esm/signer-tYS6Y46X.d.mts +170 -0
  127. package/dist/esm/storage-6W5MO46W.d.mts +50 -0
  128. package/dist/esm/storage-sZ1CDS4P.d.mts +81 -0
  129. package/dist/esm/types-CF8P2-NM.d.mts +180 -0
  130. package/dist/esm/upto/client/index.d.mts +5 -3
  131. package/dist/esm/upto/client/index.mjs +9 -4
  132. package/dist/esm/upto/facilitator/index.d.mts +2 -1
  133. package/dist/esm/upto/facilitator/index.mjs +17 -9
  134. package/dist/esm/upto/facilitator/index.mjs.map +1 -1
  135. package/dist/esm/upto/server/index.mjs +1 -1
  136. package/dist/esm/v1/index.d.mts +2 -1
  137. package/dist/esm/v1/index.mjs +5 -2
  138. package/package.json +5 -5
  139. package/dist/esm/chunk-C4ZQMS77.mjs.map +0 -1
  140. package/dist/esm/chunk-CRT6YNY5.mjs.map +0 -1
  141. package/dist/esm/chunk-ERK2ZPOY.mjs.map +0 -1
  142. package/dist/esm/chunk-JII456TS.mjs.map +0 -1
  143. package/dist/esm/chunk-WKBC5YMI.mjs.map +0 -1
@@ -0,0 +1,47 @@
1
+ import { F as FileChannelStorageOptions } from '../../types-CF8P2-NM.js';
2
+ import { C as ClientChannelStorage, B as BatchSettlementClientContext } from '../../storage-6W5MO46W.js';
3
+ import 'viem';
4
+
5
+ /**
6
+ * Node.js file-backed {@link ClientChannelStorage} for the batched client scheme.
7
+ * Each channel's context is persisted as `{root}/client/{channelId}.json` so that channel
8
+ * records survive process restarts.
9
+ */
10
+ declare class FileClientChannelStorage implements ClientChannelStorage {
11
+ private readonly root;
12
+ /**
13
+ * Creates file-backed client channel storage under the given root directory.
14
+ *
15
+ * @param options - Configuration including the storage root directory.
16
+ */
17
+ constructor(options: FileChannelStorageOptions);
18
+ /**
19
+ * Loads the stored client context for a channel, if present.
20
+ *
21
+ * @param key - Channel storage key (typically a lowercased channelId).
22
+ * @returns Parsed context or `undefined` when the file is missing.
23
+ */
24
+ get(key: string): Promise<BatchSettlementClientContext | undefined>;
25
+ /**
26
+ * Persists the client context for a channel.
27
+ *
28
+ * @param key - Channel storage key.
29
+ * @param context - Context record to write.
30
+ */
31
+ set(key: string, context: BatchSettlementClientContext): Promise<void>;
32
+ /**
33
+ * Removes the persisted context file for a channel, if it exists.
34
+ *
35
+ * @param key - Channel storage key.
36
+ */
37
+ delete(key: string): Promise<void>;
38
+ /**
39
+ * Absolute path to the JSON file for a channel.
40
+ *
41
+ * @param key - Channel storage key.
42
+ * @returns Filesystem path under `{root}/client/...`.
43
+ */
44
+ private filePath;
45
+ }
46
+
47
+ export { FileChannelStorageOptions, FileClientChannelStorage };
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/batch-settlement/client/fileStorage.ts
21
+ var fileStorage_exports = {};
22
+ __export(fileStorage_exports, {
23
+ FileClientChannelStorage: () => FileClientChannelStorage
24
+ });
25
+ module.exports = __toCommonJS(fileStorage_exports);
26
+ var import_promises2 = require("fs/promises");
27
+ var import_node_path2 = require("path");
28
+
29
+ // src/batch-settlement/storage-utils.ts
30
+ var import_promises = require("fs/promises");
31
+ var import_node_path = require("path");
32
+ function isNodeEnoent(err) {
33
+ if (!err || typeof err !== "object" || !("code" in err)) return false;
34
+ return err.code === "ENOENT";
35
+ }
36
+ async function readJsonFile(filePath) {
37
+ try {
38
+ const raw = await (0, import_promises.readFile)(filePath, "utf8");
39
+ return JSON.parse(raw);
40
+ } catch (err) {
41
+ if (isNodeEnoent(err)) return void 0;
42
+ throw err;
43
+ }
44
+ }
45
+ async function writeJsonAtomic(filePath, value) {
46
+ const dir = (0, import_node_path.dirname)(filePath);
47
+ await (0, import_promises.mkdir)(dir, { recursive: true });
48
+ const tmp = (0, import_node_path.join)(dir, `.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`);
49
+ const body = `${JSON.stringify(value, null, 2)}
50
+ `;
51
+ await (0, import_promises.writeFile)(tmp, body, "utf8");
52
+ try {
53
+ await (0, import_promises.rename)(tmp, filePath);
54
+ } catch {
55
+ await (0, import_promises.unlink)(filePath).catch(() => {
56
+ });
57
+ await (0, import_promises.rename)(tmp, filePath);
58
+ }
59
+ }
60
+
61
+ // src/batch-settlement/client/fileStorage.ts
62
+ var FileClientChannelStorage = class {
63
+ /**
64
+ * Creates file-backed client channel storage under the given root directory.
65
+ *
66
+ * @param options - Configuration including the storage root directory.
67
+ */
68
+ constructor(options) {
69
+ this.root = options.directory;
70
+ }
71
+ /**
72
+ * Loads the stored client context for a channel, if present.
73
+ *
74
+ * @param key - Channel storage key (typically a lowercased channelId).
75
+ * @returns Parsed context or `undefined` when the file is missing.
76
+ */
77
+ async get(key) {
78
+ return readJsonFile(this.filePath(key));
79
+ }
80
+ /**
81
+ * Persists the client context for a channel.
82
+ *
83
+ * @param key - Channel storage key.
84
+ * @param context - Context record to write.
85
+ */
86
+ async set(key, context) {
87
+ await writeJsonAtomic(this.filePath(key), context);
88
+ }
89
+ /**
90
+ * Removes the persisted context file for a channel, if it exists.
91
+ *
92
+ * @param key - Channel storage key.
93
+ */
94
+ async delete(key) {
95
+ try {
96
+ await (0, import_promises2.unlink)(this.filePath(key));
97
+ } catch (err) {
98
+ if (isNodeEnoent(err)) return;
99
+ throw err;
100
+ }
101
+ }
102
+ /**
103
+ * Absolute path to the JSON file for a channel.
104
+ *
105
+ * @param key - Channel storage key.
106
+ * @returns Filesystem path under `{root}/client/...`.
107
+ */
108
+ filePath(key) {
109
+ return (0, import_node_path2.join)(this.root, "client", `${key.toLowerCase()}.json`);
110
+ }
111
+ };
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ FileClientChannelStorage
115
+ });
116
+ //# sourceMappingURL=file-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/batch-settlement/client/fileStorage.ts","../../../../src/batch-settlement/storage-utils.ts"],"sourcesContent":["import { unlink } from \"node:fs/promises\";\nimport { join } from \"node:path\";\n\nimport { isNodeEnoent, readJsonFile, writeJsonAtomic } from \"../storage-utils\";\nimport type { FileChannelStorageOptions } from \"../types\";\nimport type { ClientChannelStorage, BatchSettlementClientContext } from \"./storage\";\n\nexport type { FileChannelStorageOptions };\n\n/**\n * Node.js file-backed {@link ClientChannelStorage} for the batched client scheme.\n * Each channel's context is persisted as `{root}/client/{channelId}.json` so that channel\n * records survive process restarts.\n */\nexport class FileClientChannelStorage implements ClientChannelStorage {\n private readonly root: string;\n\n /**\n * Creates file-backed client channel storage under the given root directory.\n *\n * @param options - Configuration including the storage root directory.\n */\n constructor(options: FileChannelStorageOptions) {\n this.root = options.directory;\n }\n\n /**\n * Loads the stored client context for a channel, if present.\n *\n * @param key - Channel storage key (typically a lowercased channelId).\n * @returns Parsed context or `undefined` when the file is missing.\n */\n async get(key: string): Promise<BatchSettlementClientContext | undefined> {\n return readJsonFile<BatchSettlementClientContext>(this.filePath(key));\n }\n\n /**\n * Persists the client context for a channel.\n *\n * @param key - Channel storage key.\n * @param context - Context record to write.\n */\n async set(key: string, context: BatchSettlementClientContext): Promise<void> {\n await writeJsonAtomic(this.filePath(key), context);\n }\n\n /**\n * Removes the persisted context file for a channel, if it exists.\n *\n * @param key - Channel storage key.\n */\n async delete(key: string): Promise<void> {\n try {\n await unlink(this.filePath(key));\n } catch (err: unknown) {\n if (isNodeEnoent(err)) return;\n throw err;\n }\n }\n\n /**\n * Absolute path to the JSON file for a channel.\n *\n * @param key - Channel storage key.\n * @returns Filesystem path under `{root}/client/...`.\n */\n private filePath(key: string): string {\n return join(this.root, \"client\", `${key.toLowerCase()}.json`);\n }\n}\n","import { mkdir, readFile, rename, unlink, writeFile } from \"node:fs/promises\";\nimport { dirname, join } from \"node:path\";\n\n/**\n * Returns true when `err` is a Node.js `ENOENT` filesystem error (file does not exist).\n *\n * @param err - The thrown value to inspect.\n * @returns `true` for `ENOENT`, `false` for any other value or error code.\n */\nexport function isNodeEnoent(err: unknown): boolean {\n if (!err || typeof err !== \"object\" || !(\"code\" in err)) return false;\n return (err as NodeJS.ErrnoException).code === \"ENOENT\";\n}\n\n/**\n * Reads a JSON file and parses it. Returns `undefined` if the file does not exist.\n * Other errors (permission, malformed JSON) are rethrown.\n *\n * @param filePath - Path to the JSON file.\n * @returns Parsed value, or `undefined` for `ENOENT`.\n */\nexport async function readJsonFile<T>(filePath: string): Promise<T | undefined> {\n try {\n const raw = await readFile(filePath, \"utf8\");\n return JSON.parse(raw) as T;\n } catch (err: unknown) {\n if (isNodeEnoent(err)) return undefined;\n throw err;\n }\n}\n\n/**\n * Writes JSON to `filePath` atomically (temp file in the same directory, then rename).\n * Creates parent directories as needed.\n *\n * @param filePath - Destination file path; parent dirs are created if missing.\n * @param value - JSON-serializable value to persist.\n */\nexport async function writeJsonAtomic(filePath: string, value: unknown): Promise<void> {\n const dir = dirname(filePath);\n await mkdir(dir, { recursive: true });\n const tmp = join(dir, `.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`);\n const body = `${JSON.stringify(value, null, 2)}\\n`;\n await writeFile(tmp, body, \"utf8\");\n try {\n await rename(tmp, filePath);\n } catch {\n // On Windows, rename() onto an existing file throws EEXIST; unlink + rename is intentional.\n await unlink(filePath).catch(() => {});\n await rename(tmp, filePath);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,mBAAuB;AACvB,IAAAC,oBAAqB;;;ACDrB,sBAA2D;AAC3D,uBAA8B;AAQvB,SAAS,aAAa,KAAuB;AAClD,MAAI,CAAC,OAAO,OAAO,QAAQ,YAAY,EAAE,UAAU,KAAM,QAAO;AAChE,SAAQ,IAA8B,SAAS;AACjD;AASA,eAAsB,aAAgB,UAA0C;AAC9E,MAAI;AACF,UAAM,MAAM,UAAM,0BAAS,UAAU,MAAM;AAC3C,WAAO,KAAK,MAAM,GAAG;AAAA,EACvB,SAAS,KAAc;AACrB,QAAI,aAAa,GAAG,EAAG,QAAO;AAC9B,UAAM;AAAA,EACR;AACF;AASA,eAAsB,gBAAgB,UAAkB,OAA+B;AACrF,QAAM,UAAM,0BAAQ,QAAQ;AAC5B,YAAM,uBAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AACpC,QAAM,UAAM,uBAAK,KAAK,IAAI,QAAQ,GAAG,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM;AAChG,QAAM,OAAO,GAAG,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;AAAA;AAC9C,YAAM,2BAAU,KAAK,MAAM,MAAM;AACjC,MAAI;AACF,cAAM,wBAAO,KAAK,QAAQ;AAAA,EAC5B,QAAQ;AAEN,cAAM,wBAAO,QAAQ,EAAE,MAAM,MAAM;AAAA,IAAC,CAAC;AACrC,cAAM,wBAAO,KAAK,QAAQ;AAAA,EAC5B;AACF;;;ADrCO,IAAM,2BAAN,MAA+D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpE,YAAY,SAAoC;AAC9C,SAAK,OAAO,QAAQ;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,KAAgE;AACxE,WAAO,aAA2C,KAAK,SAAS,GAAG,CAAC;AAAA,EACtE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,IAAI,KAAa,SAAsD;AAC3E,UAAM,gBAAgB,KAAK,SAAS,GAAG,GAAG,OAAO;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,OAAO,KAA4B;AACvC,QAAI;AACF,gBAAM,yBAAO,KAAK,SAAS,GAAG,CAAC;AAAA,IACjC,SAAS,KAAc;AACrB,UAAI,aAAa,GAAG,EAAG;AACvB,YAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,SAAS,KAAqB;AACpC,eAAO,wBAAK,KAAK,MAAM,UAAU,GAAG,IAAI,YAAY,CAAC,OAAO;AAAA,EAC9D;AACF;","names":["import_promises","import_node_path"]}
@@ -0,0 +1,111 @@
1
+ import { a as BatchSettlementClientDeps } from '../../scheme-CvkPJXBD.js';
2
+ export { b as BatchSettlementDepositPolicy, c as BatchSettlementDepositStrategy, d as BatchSettlementDepositStrategyContext, e as BatchSettlementDepositStrategyResult, B as BatchSettlementEvmScheme, f as BatchSettlementEvmSchemeOptions, R as RefundOptions, j as ResolvedClientOptions, k as buildChannelConfig, g as depositAmountForRequest, l as getChannel, m as hasChannel, i as isBatchSettlementEvmSchemeOptions, p as processPaymentResponse, n as processSettleResponse, o as readChannelBalanceAndTotalClaimed, q as recoverChannel, r as refundChannel, h as resolveClientOptions, u as updateChannelAfterRefund, v as validateDepositPolicy } from '../../scheme-CvkPJXBD.js';
3
+ export { B as BatchSettlementClientContext, C as ClientChannelStorage, I as InMemoryClientChannelStorage } from '../../storage-6W5MO46W.js';
4
+ import { PaymentRequirements, PaymentPayloadResult, SchemeClientHooks, PaymentRequired } from '@payai/x402/types';
5
+ import { C as ClientEvmSigner } from '../../signer-tYS6Y46X.js';
6
+ import { C as ChannelConfig, d as BatchSettlementVoucherFields, t as BatchSettlementChannelStateExtra, u as BatchSettlementVoucherStateExtra } from '../../types-CF8P2-NM.js';
7
+ import { PaymentResponseContext } from '@payai/x402/client';
8
+ import '../../rpc-DULZzRne.js';
9
+ import 'viem';
10
+
11
+ /**
12
+ * Computes the chain-bound channel id from a {@link ChannelConfig} struct.
13
+ *
14
+ * @param config - The immutable channel configuration.
15
+ * @param networkOrChainId - CAIP-2 network identifier or numeric EVM chain id.
16
+ * @returns The `bytes32` channel id as a hex string.
17
+ */
18
+ declare function computeChannelId(config: ChannelConfig, networkOrChainId: string | number): `0x${string}`;
19
+
20
+ /**
21
+ * Creates a deposit payload that bundles an ERC-3009 `receiveWithAuthorization` approval
22
+ * together with a cumulative voucher signature.
23
+ *
24
+ * When the facilitator submits this payload onchain, the contract atomically transfers
25
+ * tokens from the payer into the channel and records the initial voucher.
26
+ *
27
+ * @param signer - Client wallet used to sign the ERC-3009 authorization (`from` = payer).
28
+ * @param x402Version - Protocol version to embed in the payload envelope.
29
+ * @param paymentRequirements - Server-provided payment requirements (asset, network, amount, etc.).
30
+ * @param channelConfig - Immutable channel configuration (payer, receiver, token, …).
31
+ * @param depositAmount - Number of tokens (decimal string) to deposit into the channel.
32
+ * @param maxClaimableAmount - Cumulative ceiling for the accompanying voucher.
33
+ * @param voucherSigner - Optional key that signs the voucher; defaults to `signer` (same as payer).
34
+ * @returns A {@link PaymentPayloadResult} containing the signed deposit + voucher payload.
35
+ */
36
+ declare function createBatchSettlementEIP3009DepositPayload(signer: ClientEvmSigner, x402Version: number, paymentRequirements: PaymentRequirements, channelConfig: ChannelConfig, depositAmount: string, maxClaimableAmount: string, voucherSigner?: ClientEvmSigner): Promise<PaymentPayloadResult>;
37
+
38
+ /**
39
+ * Signs a cumulative voucher using the client's wallet.
40
+ *
41
+ * The voucher authorises the receiver to claim up to `maxClaimableAmount` from the
42
+ * channel identified by `channelId`. The signature covers the EIP-712 `Voucher` struct
43
+ * under the batched domain.
44
+ *
45
+ * @param signer - Client wallet used to produce the EIP-712 signature.
46
+ * @param channelId - Identifier of the payment channel. This is the EIP-712
47
+ * hash of the `ChannelConfig` typed data for the batch settlement domain; see
48
+ * `computeChannelId`.
49
+ * @param maxClaimableAmount - Cumulative ceiling the receiver may claim (decimal string in token units).
50
+ * @param network - CAIP-2 network identifier (e.g. `eip155:84532`).
51
+ * @returns Signed voucher fields ready to be included in a payment payload.
52
+ */
53
+ declare function signVoucher(signer: ClientEvmSigner, channelId: `0x${string}`, maxClaimableAmount: string, network: string): Promise<BatchSettlementVoucherFields>;
54
+
55
+ /**
56
+ * Creates storage-aware client hooks for batch-settlement payment responses.
57
+ *
58
+ * @param deps - Client identity and storage inputs.
59
+ * @returns Scheme hooks for response reconciliation and corrective recovery.
60
+ */
61
+ declare function createBatchSettlementClientHooks(deps: BatchSettlementClientDeps): SchemeClientHooks;
62
+ /**
63
+ * Reconciles batch-settlement client state after a paid request or refund attempt.
64
+ *
65
+ * @param deps - Client identity and storage inputs.
66
+ * @param ctx - Core payment response context.
67
+ * @returns A recovery signal when corrective recovery succeeds.
68
+ */
69
+ declare function handleBatchSettlementPaymentResponse(deps: BatchSettlementClientDeps, ctx: PaymentResponseContext): Promise<void | {
70
+ recovered: true;
71
+ }>;
72
+
73
+ /**
74
+ * Handles a corrective 402 response from the server when the client's
75
+ * cumulative base is out of sync.
76
+ *
77
+ * Validates the server-provided state (chargedCumulativeAmount,
78
+ * signedMaxClaimable, signature) against onchain data and the client's own
79
+ * signing key, then updates the local channel state if everything checks out.
80
+ *
81
+ * @param deps - Signer + storage + identity inputs.
82
+ * @param paymentRequired - The decoded 402 response body.
83
+ * @returns `true` if the channel state was successfully resynced and the request can be retried.
84
+ */
85
+ declare function processCorrectivePaymentRequired(deps: BatchSettlementClientDeps, paymentRequired: PaymentRequired): Promise<boolean>;
86
+ /**
87
+ * Recovers channel state from a corrective 402 that includes a server-provided
88
+ * voucher signature. Verifies the signature matches the client's own signing
89
+ * key before accepting.
90
+ *
91
+ * @param deps - Signer + storage + identity inputs.
92
+ * @param accept - Batch settlement payment requirements from the corrective 402.
93
+ * @param channelState - Server channel snapshot from `accept.extra.channelState`.
94
+ * @param voucherState - Latest signed voucher proof from `accept.extra.voucherState`.
95
+ * @returns `true` when local channel state was updated successfully.
96
+ */
97
+ declare function recoverFromSignature(deps: BatchSettlementClientDeps, accept: PaymentRequirements, channelState: BatchSettlementChannelStateExtra, voucherState: BatchSettlementVoucherStateExtra): Promise<boolean>;
98
+ /**
99
+ * Recovers channel state purely from onchain state when the server has no stored
100
+ * voucher (e.g. after a cooperative refund deleted the channel record). The onchain
101
+ * `totalClaimed` becomes the new baseline — no signature verification is
102
+ * needed because the contract is the source of truth when no outstanding
103
+ * voucher exists.
104
+ *
105
+ * @param deps - Signer + storage + identity inputs.
106
+ * @param accept - Batch settlement payment requirements from the corrective 402.
107
+ * @returns `true` when local channel state was updated from onchain data.
108
+ */
109
+ declare function recoverFromOnChainState(deps: BatchSettlementClientDeps, accept: PaymentRequirements): Promise<boolean>;
110
+
111
+ export { BatchSettlementClientDeps, computeChannelId, createBatchSettlementClientHooks, createBatchSettlementEIP3009DepositPayload, handleBatchSettlementPaymentResponse, processCorrectivePaymentRequired, recoverFromOnChainState, recoverFromSignature, signVoucher };