@toon-protocol/client-mcp 0.18.0 → 0.20.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/README.md +5 -7
- package/dist/app/index.html +69 -69
- package/dist/{chunk-VA7XC4FD.js → chunk-3DDN4CJQ.js} +17 -1
- package/dist/{chunk-VA7XC4FD.js.map → chunk-3DDN4CJQ.js.map} +1 -1
- package/dist/{chunk-FXPDLGDN.js → chunk-5SFBB4PJ.js} +168 -38
- package/dist/chunk-5SFBB4PJ.js.map +1 -0
- package/dist/{chunk-LR7W2ISE.js → chunk-HMD5EVQI.js} +11 -2
- package/dist/{chunk-LR7W2ISE.js.map → chunk-HMD5EVQI.js.map} +1 -1
- package/dist/{chunk-LSPAGZXL.js → chunk-HSSJFB3I.js} +1426 -213
- package/dist/chunk-HSSJFB3I.js.map +1 -0
- package/dist/{chunk-56TTQYS7.js → chunk-KYQUVXEY.js} +2 -2
- package/dist/{chunk-XQUUFAIM.js → chunk-LN2OF264.js} +4 -2
- package/dist/{chunk-CTDRHEDX.js → chunk-SLMGETW7.js} +2 -2
- package/dist/{chunk-CTDRHEDX.js.map → chunk-SLMGETW7.js.map} +1 -1
- package/dist/{chunk-32QD72IL.js → chunk-T3WCTWRP.js} +2 -2
- package/dist/daemon.js +7 -7
- package/dist/{ed25519-U4PTEOFD.js → ed25519-VBPL32VX.js} +2 -2
- package/dist/{hmac-CMZORX4Y.js → hmac-GNBDA4UC.js} +3 -3
- package/dist/index.d.ts +11 -8
- package/dist/index.js +8 -8
- package/dist/mcp.js +7 -7
- package/dist/{node-WPA2UDEH-72L4MKGB.js → node-WPA2UDEH-SRYDHHAV.js} +3 -3
- package/dist/{node-WPA2UDEH-72L4MKGB.js.map → node-WPA2UDEH-SRYDHHAV.js.map} +1 -1
- package/dist/{sha512-4LOCATJH.js → sha512-D7TTPT7I.js} +3 -3
- package/package.json +6 -6
- package/dist/chunk-FXPDLGDN.js.map +0 -1
- package/dist/chunk-LSPAGZXL.js.map +0 -1
- /package/dist/{chunk-56TTQYS7.js.map → chunk-KYQUVXEY.js.map} +0 -0
- /package/dist/{chunk-XQUUFAIM.js.map → chunk-LN2OF264.js.map} +0 -0
- /package/dist/{chunk-32QD72IL.js.map → chunk-T3WCTWRP.js.map} +0 -0
- /package/dist/{ed25519-U4PTEOFD.js.map → ed25519-VBPL32VX.js.map} +0 -0
- /package/dist/{hmac-CMZORX4Y.js.map → hmac-GNBDA4UC.js.map} +0 -0
- /package/dist/{sha512-4LOCATJH.js.map → sha512-D7TTPT7I.js.map} +0 -0
|
@@ -37,6 +37,9 @@ function aoutput(out, instance) {
|
|
|
37
37
|
throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
function u32(arr) {
|
|
41
|
+
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
42
|
+
}
|
|
40
43
|
function clean(...arrays) {
|
|
41
44
|
for (let i = 0; i < arrays.length; i++) {
|
|
42
45
|
arrays[i].fill(0);
|
|
@@ -51,6 +54,17 @@ function rotr(word, shift) {
|
|
|
51
54
|
function rotl(word, shift) {
|
|
52
55
|
return word << shift | word >>> 32 - shift >>> 0;
|
|
53
56
|
}
|
|
57
|
+
var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
58
|
+
function byteSwap(word) {
|
|
59
|
+
return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
60
|
+
}
|
|
61
|
+
function byteSwap32(arr) {
|
|
62
|
+
for (let i = 0; i < arr.length; i++) {
|
|
63
|
+
arr[i] = byteSwap(arr[i]);
|
|
64
|
+
}
|
|
65
|
+
return arr;
|
|
66
|
+
}
|
|
67
|
+
var swap32IfBE = isLE ? (u) => u : byteSwap32;
|
|
54
68
|
var hasHexBuiltin = /* @__PURE__ */ (() => (
|
|
55
69
|
// @ts-ignore
|
|
56
70
|
typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
|
|
@@ -162,10 +176,12 @@ export {
|
|
|
162
176
|
ahash,
|
|
163
177
|
aexists,
|
|
164
178
|
aoutput,
|
|
179
|
+
u32,
|
|
165
180
|
clean,
|
|
166
181
|
createView,
|
|
167
182
|
rotr,
|
|
168
183
|
rotl,
|
|
184
|
+
swap32IfBE,
|
|
169
185
|
bytesToHex,
|
|
170
186
|
hexToBytes,
|
|
171
187
|
utf8ToBytes,
|
|
@@ -182,4 +198,4 @@ export {
|
|
|
182
198
|
@noble/hashes/esm/utils.js:
|
|
183
199
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
184
200
|
*/
|
|
185
|
-
//# sourceMappingURL=chunk-
|
|
201
|
+
//# sourceMappingURL=chunk-3DDN4CJQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/src/cryptoNode.ts","../../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/src/utils.ts"],"sourcesContent":["/**\n * Internal webcrypto alias.\n * We prefer WebCrypto aka globalThis.crypto, which exists in node.js 16+.\n * Falls back to Node.js built-in crypto for Node.js <=v14.\n * See utils.ts for details.\n * @module\n */\n// @ts-ignore\nimport * as nc from 'node:crypto';\nexport const crypto: any =\n nc && typeof nc === 'object' && 'webcrypto' in nc\n ? (nc.webcrypto as any)\n : nc && typeof nc === 'object' && 'randomBytes' in nc\n ? nc\n : undefined;\n","/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\n\n/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */\nexport function isBytes(a: unknown): a is Uint8Array {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n\n/** Asserts something is positive integer. */\nexport function anumber(n: number): void {\n if (!Number.isSafeInteger(n) || n < 0) throw new Error('positive integer expected, got ' + n);\n}\n\n/** Asserts something is Uint8Array. */\nexport function abytes(b: Uint8Array | undefined, ...lengths: number[]): void {\n if (!isBytes(b)) throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n\n/** Asserts something is hash */\nexport function ahash(h: IHash): void {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.createHasher');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\n\n/** Asserts a hash instance has not been destroyed / finished */\nexport function aexists(instance: any, checkFinished = true): void {\n if (instance.destroyed) throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');\n}\n\n/** Asserts output is properly-sized byte array */\nexport function aoutput(out: any, instance: any): void {\n abytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n\n/** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */\n// prettier-ignore\nexport type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |\n Uint16Array | Int16Array | Uint32Array | Int32Array;\n\n/** Cast u8 / u16 / u32 to u8. */\nexport function u8(arr: TypedArray): Uint8Array {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n\n/** Cast u8 / u16 / u32 to u32. */\nexport function u32(arr: TypedArray): Uint32Array {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n\n/** Zeroize a byte array. Warning: JS provides no guarantees. */\nexport function clean(...arrays: TypedArray[]): void {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n\n/** Create DataView of an array for easy byte-level manipulation. */\nexport function createView(arr: TypedArray): DataView {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n\n/** The rotate right (circular right shift) operation for uint32 */\nexport function rotr(word: number, shift: number): number {\n return (word << (32 - shift)) | (word >>> shift);\n}\n\n/** The rotate left (circular left shift) operation for uint32 */\nexport function rotl(word: number, shift: number): number {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n\n/** Is current platform little-endian? Most are. Big-Endian platform: IBM */\nexport const isLE: boolean = /* @__PURE__ */ (() =>\n new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n\n/** The byte swap operation for uint32 */\nexport function byteSwap(word: number): number {\n return (\n ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff)\n );\n}\n/** Conditionally byte swap if on a big-endian platform */\nexport const swap8IfBE: (n: number) => number = isLE\n ? (n: number) => n\n : (n: number) => byteSwap(n);\n\n/** @deprecated */\nexport const byteSwapIfBE: typeof swap8IfBE = swap8IfBE;\n/** In place byte swap for Uint32Array */\nexport function byteSwap32(arr: Uint32Array): Uint32Array {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n return arr;\n}\n\nexport const swap32IfBE: (u: Uint32Array) => Uint32Array = isLE\n ? (u: Uint32Array) => u\n : byteSwap32;\n\n// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex\nconst hasHexBuiltin: boolean = /* @__PURE__ */ (() =>\n // @ts-ignore\n typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();\n\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n\n/**\n * Convert byte array to hex string. Uses built-in function, when available.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n abytes(bytes);\n // @ts-ignore\n if (hasHexBuiltin) return bytes.toHex();\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const;\nfunction asciiToBase16(ch: number): number | undefined {\n if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n\n/**\n * Convert hex string to byte array. Uses built-in function, when available.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n // @ts-ignore\n if (hasHexBuiltin) return Uint8Array.fromHex(hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n\n/**\n * There is no setImmediate in browser and setTimeout is slow.\n * Call of async fn will return Promise, which will be fullfiled only on\n * next scheduler queue processing step and this is exactly what we need.\n */\nexport const nextTick = async (): Promise<void> => {};\n\n/** Returns control to thread each 'tick' ms to avoid blocking. */\nexport async function asyncLoop(\n iters: number,\n tick: number,\n cb: (i: number) => void\n): Promise<void> {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick) continue;\n await nextTick();\n ts += diff;\n }\n}\n\n// Global symbols, but ts doesn't see them: https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\ndeclare const TextDecoder: any;\n\n/**\n * Converts string to bytes using UTF8 encoding.\n * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\n/**\n * Converts bytes to string using UTF8 encoding.\n * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'\n */\nexport function bytesToUtf8(bytes: Uint8Array): string {\n return new TextDecoder().decode(bytes);\n}\n\n/** Accepted input of hash functions. Strings are converted to byte arrays. */\nexport type Input = string | Uint8Array;\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data: Input): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/** KDFs can accept string or Uint8Array for user convenience. */\nexport type KDFInput = string | Uint8Array;\n/**\n * Helper for KDFs: consumes uint8array or string.\n * When string is passed, does utf8 decoding, using TextDecoder.\n */\nexport function kdfInputToBytes(data: KDFInput): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/** Copies several Uint8Arrays into one. */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n\ntype EmptyObj = {};\nexport function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(\n defaults: T1,\n opts?: T2\n): T1 & T2 {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged as T1 & T2;\n}\n\n/** Hash interface. */\nexport type IHash = {\n (data: Uint8Array): Uint8Array;\n blockLen: number;\n outputLen: number;\n create: any;\n};\n\n/** For runtime check if class implements interface */\nexport abstract class Hash<T extends Hash<T>> {\n abstract blockLen: number; // Bytes per block\n abstract outputLen: number; // Bytes in output\n abstract update(buf: Input): this;\n // Writes digest into buf\n abstract digestInto(buf: Uint8Array): void;\n abstract digest(): Uint8Array;\n /**\n * Resets internal state. Makes Hash instance unusable.\n * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed\n * by user, they will need to manually call `destroy()` when zeroing is necessary.\n */\n abstract destroy(): void;\n /**\n * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()`\n * when no options are passed.\n * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal\n * buffers are overwritten => causes buffer overwrite which is used for digest in some cases.\n * There are no guarantees for clean-up because it's impossible in JS.\n */\n abstract _cloneInto(to?: T): T;\n // Safe version that clones internal state\n abstract clone(): T;\n}\n\n/**\n * XOF: streaming API to read digest in chunks.\n * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.\n * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot\n * destroy state, next call can require more bytes.\n */\nexport type HashXOF<T extends Hash<T>> = Hash<T> & {\n xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream\n xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf\n};\n\n/** Hash function */\nexport type CHash = ReturnType<typeof createHasher>;\n/** Hash function with output */\nexport type CHashO = ReturnType<typeof createOptHasher>;\n/** XOF with output */\nexport type CHashXO = ReturnType<typeof createXOFer>;\n\n/** Wraps hash function, creating an interface on top of it */\nexport function createHasher<T extends Hash<T>>(\n hashCons: () => Hash<T>\n): {\n (msg: Input): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(): Hash<T>;\n} {\n const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\nexport function createOptHasher<H extends Hash<H>, T extends Object>(\n hashCons: (opts?: T) => Hash<H>\n): {\n (msg: Input, opts?: T): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(opts?: T): Hash<H>;\n} {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts?: T) => hashCons(opts);\n return hashC;\n}\n\nexport function createXOFer<H extends HashXOF<H>, T extends Object>(\n hashCons: (opts?: T) => HashXOF<H>\n): {\n (msg: Input, opts?: T): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(opts?: T): HashXOF<H>;\n} {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts?: T) => hashCons(opts);\n return hashC;\n}\nexport const wrapConstructor: typeof createHasher = createHasher;\nexport const wrapConstructorWithOpts: typeof createOptHasher = createOptHasher;\nexport const wrapXOFConstructorWithOpts: typeof createXOFer = createXOFer;\n\n/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */\nexport function randomBytes(bytesLength = 32): Uint8Array {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return Uint8Array.from(crypto.randomBytes(bytesLength));\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n"],"mappings":";;;AAQA,YAAY,QAAQ;AACb,IAAM,SACX,MAAM,OAAO,OAAO,YAAY,eAAe,KACvC,eACJ,MAAM,OAAO,OAAO,YAAY,iBAAiB,KAC/C,KACA;;;ACCF,SAAU,QAAQ,GAAU;AAChC,SAAO,aAAa,cAAe,YAAY,OAAO,CAAC,KAAK,EAAE,YAAY,SAAS;AACrF;AAGM,SAAU,QAAQ,GAAS;AAC/B,MAAI,CAAC,OAAO,cAAc,CAAC,KAAK,IAAI;AAAG,UAAM,IAAI,MAAM,oCAAoC,CAAC;AAC9F;AAGM,SAAU,OAAO,MAA8B,SAAiB;AACpE,MAAI,CAAC,QAAQ,CAAC;AAAG,UAAM,IAAI,MAAM,qBAAqB;AACtD,MAAI,QAAQ,SAAS,KAAK,CAAC,QAAQ,SAAS,EAAE,MAAM;AAClD,UAAM,IAAI,MAAM,mCAAmC,UAAU,kBAAkB,EAAE,MAAM;AAC3F;AAGM,SAAU,MAAM,GAAQ;AAC5B,MAAI,OAAO,MAAM,cAAc,OAAO,EAAE,WAAW;AACjD,UAAM,IAAI,MAAM,8CAA8C;AAChE,UAAQ,EAAE,SAAS;AACnB,UAAQ,EAAE,QAAQ;AACpB;AAGM,SAAU,QAAQ,UAAe,gBAAgB,MAAI;AACzD,MAAI,SAAS;AAAW,UAAM,IAAI,MAAM,kCAAkC;AAC1E,MAAI,iBAAiB,SAAS;AAAU,UAAM,IAAI,MAAM,uCAAuC;AACjG;AAGM,SAAU,QAAQ,KAAU,UAAa;AAC7C,SAAO,GAAG;AACV,QAAM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,GAAG;AAC9B,WAAS,IAAI,GAAG,MAAM,GAAG,IAAI,OAAO,QAAQ,KAAK;AAC/C,UAAM,IAAI,OAAO,CAAC;AAClB,QAAI,IAAI,GAAG,GAAG;AACd,WAAO,EAAE;EACX;AACA,SAAO;AACT;AAGM,SAAU,UACd,UACA,MAAS;AAET,MAAI,SAAS,UAAa,CAAA,EAAG,SAAS,KAAK,IAAI,MAAM;AACnD,UAAM,IAAI,MAAM,uCAAuC;AACzD,QAAM,SAAS,OAAO,OAAO,UAAU,IAAI;AAC3C,SAAO;AACT;AAWM,IAAgB,OAAhB,MAAoB;;AA4CpB,SAAU,aACd,UAAuB;AAOvB,QAAM,QAAQ,CAAC,QAA2B,SAAQ,EAAG,OAAO,QAAQ,GAAG,CAAC,EAAE,OAAM;AAChF,QAAM,MAAM,SAAQ;AACpB,QAAM,YAAY,IAAI;AACtB,QAAM,WAAW,IAAI;AACrB,QAAM,SAAS,MAAM,SAAQ;AAC7B,SAAO;AACT;AAsCM,SAAU,YAAY,cAAc,IAAE;AAC1C,MAAI,UAAU,OAAO,OAAO,oBAAoB,YAAY;AAC1D,WAAO,OAAO,gBAAgB,IAAI,WAAW,WAAW,CAAC;EAC3D;AAEA,MAAI,UAAU,OAAO,OAAO,gBAAgB,YAAY;AACtD,WAAO,WAAW,KAAK,OAAO,YAAY,WAAW,CAAC;EACxD;AACA,QAAM,IAAI,MAAM,wCAAwC;AAC1D;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/src/cryptoNode.ts","../../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/src/utils.ts"],"sourcesContent":["/**\n * Internal webcrypto alias.\n * We prefer WebCrypto aka globalThis.crypto, which exists in node.js 16+.\n * Falls back to Node.js built-in crypto for Node.js <=v14.\n * See utils.ts for details.\n * @module\n */\n// @ts-ignore\nimport * as nc from 'node:crypto';\nexport const crypto: any =\n nc && typeof nc === 'object' && 'webcrypto' in nc\n ? (nc.webcrypto as any)\n : nc && typeof nc === 'object' && 'randomBytes' in nc\n ? nc\n : undefined;\n","/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\n\n/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */\nexport function isBytes(a: unknown): a is Uint8Array {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n\n/** Asserts something is positive integer. */\nexport function anumber(n: number): void {\n if (!Number.isSafeInteger(n) || n < 0) throw new Error('positive integer expected, got ' + n);\n}\n\n/** Asserts something is Uint8Array. */\nexport function abytes(b: Uint8Array | undefined, ...lengths: number[]): void {\n if (!isBytes(b)) throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n\n/** Asserts something is hash */\nexport function ahash(h: IHash): void {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.createHasher');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\n\n/** Asserts a hash instance has not been destroyed / finished */\nexport function aexists(instance: any, checkFinished = true): void {\n if (instance.destroyed) throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');\n}\n\n/** Asserts output is properly-sized byte array */\nexport function aoutput(out: any, instance: any): void {\n abytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n\n/** Generic type encompassing 8/16/32-byte arrays - but not 64-byte. */\n// prettier-ignore\nexport type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |\n Uint16Array | Int16Array | Uint32Array | Int32Array;\n\n/** Cast u8 / u16 / u32 to u8. */\nexport function u8(arr: TypedArray): Uint8Array {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n\n/** Cast u8 / u16 / u32 to u32. */\nexport function u32(arr: TypedArray): Uint32Array {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n\n/** Zeroize a byte array. Warning: JS provides no guarantees. */\nexport function clean(...arrays: TypedArray[]): void {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n\n/** Create DataView of an array for easy byte-level manipulation. */\nexport function createView(arr: TypedArray): DataView {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n\n/** The rotate right (circular right shift) operation for uint32 */\nexport function rotr(word: number, shift: number): number {\n return (word << (32 - shift)) | (word >>> shift);\n}\n\n/** The rotate left (circular left shift) operation for uint32 */\nexport function rotl(word: number, shift: number): number {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n\n/** Is current platform little-endian? Most are. Big-Endian platform: IBM */\nexport const isLE: boolean = /* @__PURE__ */ (() =>\n new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n\n/** The byte swap operation for uint32 */\nexport function byteSwap(word: number): number {\n return (\n ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff)\n );\n}\n/** Conditionally byte swap if on a big-endian platform */\nexport const swap8IfBE: (n: number) => number = isLE\n ? (n: number) => n\n : (n: number) => byteSwap(n);\n\n/** @deprecated */\nexport const byteSwapIfBE: typeof swap8IfBE = swap8IfBE;\n/** In place byte swap for Uint32Array */\nexport function byteSwap32(arr: Uint32Array): Uint32Array {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n return arr;\n}\n\nexport const swap32IfBE: (u: Uint32Array) => Uint32Array = isLE\n ? (u: Uint32Array) => u\n : byteSwap32;\n\n// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex\nconst hasHexBuiltin: boolean = /* @__PURE__ */ (() =>\n // @ts-ignore\n typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();\n\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n\n/**\n * Convert byte array to hex string. Uses built-in function, when available.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n abytes(bytes);\n // @ts-ignore\n if (hasHexBuiltin) return bytes.toHex();\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const;\nfunction asciiToBase16(ch: number): number | undefined {\n if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n\n/**\n * Convert hex string to byte array. Uses built-in function, when available.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n // @ts-ignore\n if (hasHexBuiltin) return Uint8Array.fromHex(hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n\n/**\n * There is no setImmediate in browser and setTimeout is slow.\n * Call of async fn will return Promise, which will be fullfiled only on\n * next scheduler queue processing step and this is exactly what we need.\n */\nexport const nextTick = async (): Promise<void> => {};\n\n/** Returns control to thread each 'tick' ms to avoid blocking. */\nexport async function asyncLoop(\n iters: number,\n tick: number,\n cb: (i: number) => void\n): Promise<void> {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick) continue;\n await nextTick();\n ts += diff;\n }\n}\n\n// Global symbols, but ts doesn't see them: https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\ndeclare const TextDecoder: any;\n\n/**\n * Converts string to bytes using UTF8 encoding.\n * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\n/**\n * Converts bytes to string using UTF8 encoding.\n * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'\n */\nexport function bytesToUtf8(bytes: Uint8Array): string {\n return new TextDecoder().decode(bytes);\n}\n\n/** Accepted input of hash functions. Strings are converted to byte arrays. */\nexport type Input = string | Uint8Array;\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data: Input): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/** KDFs can accept string or Uint8Array for user convenience. */\nexport type KDFInput = string | Uint8Array;\n/**\n * Helper for KDFs: consumes uint8array or string.\n * When string is passed, does utf8 decoding, using TextDecoder.\n */\nexport function kdfInputToBytes(data: KDFInput): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/** Copies several Uint8Arrays into one. */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n\ntype EmptyObj = {};\nexport function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(\n defaults: T1,\n opts?: T2\n): T1 & T2 {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged as T1 & T2;\n}\n\n/** Hash interface. */\nexport type IHash = {\n (data: Uint8Array): Uint8Array;\n blockLen: number;\n outputLen: number;\n create: any;\n};\n\n/** For runtime check if class implements interface */\nexport abstract class Hash<T extends Hash<T>> {\n abstract blockLen: number; // Bytes per block\n abstract outputLen: number; // Bytes in output\n abstract update(buf: Input): this;\n // Writes digest into buf\n abstract digestInto(buf: Uint8Array): void;\n abstract digest(): Uint8Array;\n /**\n * Resets internal state. Makes Hash instance unusable.\n * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed\n * by user, they will need to manually call `destroy()` when zeroing is necessary.\n */\n abstract destroy(): void;\n /**\n * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()`\n * when no options are passed.\n * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal\n * buffers are overwritten => causes buffer overwrite which is used for digest in some cases.\n * There are no guarantees for clean-up because it's impossible in JS.\n */\n abstract _cloneInto(to?: T): T;\n // Safe version that clones internal state\n abstract clone(): T;\n}\n\n/**\n * XOF: streaming API to read digest in chunks.\n * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.\n * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot\n * destroy state, next call can require more bytes.\n */\nexport type HashXOF<T extends Hash<T>> = Hash<T> & {\n xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream\n xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf\n};\n\n/** Hash function */\nexport type CHash = ReturnType<typeof createHasher>;\n/** Hash function with output */\nexport type CHashO = ReturnType<typeof createOptHasher>;\n/** XOF with output */\nexport type CHashXO = ReturnType<typeof createXOFer>;\n\n/** Wraps hash function, creating an interface on top of it */\nexport function createHasher<T extends Hash<T>>(\n hashCons: () => Hash<T>\n): {\n (msg: Input): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(): Hash<T>;\n} {\n const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\nexport function createOptHasher<H extends Hash<H>, T extends Object>(\n hashCons: (opts?: T) => Hash<H>\n): {\n (msg: Input, opts?: T): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(opts?: T): Hash<H>;\n} {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts?: T) => hashCons(opts);\n return hashC;\n}\n\nexport function createXOFer<H extends HashXOF<H>, T extends Object>(\n hashCons: (opts?: T) => HashXOF<H>\n): {\n (msg: Input, opts?: T): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(opts?: T): HashXOF<H>;\n} {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts?: T) => hashCons(opts);\n return hashC;\n}\nexport const wrapConstructor: typeof createHasher = createHasher;\nexport const wrapConstructorWithOpts: typeof createOptHasher = createOptHasher;\nexport const wrapXOFConstructorWithOpts: typeof createXOFer = createXOFer;\n\n/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */\nexport function randomBytes(bytesLength = 32): Uint8Array {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return Uint8Array.from(crypto.randomBytes(bytesLength));\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n"],"mappings":";;;AAQA,YAAY,QAAQ;AACb,IAAM,SACX,MAAM,OAAO,OAAO,YAAY,eAAe,KACvC,eACJ,MAAM,OAAO,OAAO,YAAY,iBAAiB,KAC/C,KACA;;;ACCF,SAAU,QAAQ,GAAU;AAChC,SAAO,aAAa,cAAe,YAAY,OAAO,CAAC,KAAK,EAAE,YAAY,SAAS;AACrF;AAGM,SAAU,QAAQ,GAAS;AAC/B,MAAI,CAAC,OAAO,cAAc,CAAC,KAAK,IAAI;AAAG,UAAM,IAAI,MAAM,oCAAoC,CAAC;AAC9F;AAGM,SAAU,OAAO,MAA8B,SAAiB;AACpE,MAAI,CAAC,QAAQ,CAAC;AAAG,UAAM,IAAI,MAAM,qBAAqB;AACtD,MAAI,QAAQ,SAAS,KAAK,CAAC,QAAQ,SAAS,EAAE,MAAM;AAClD,UAAM,IAAI,MAAM,mCAAmC,UAAU,kBAAkB,EAAE,MAAM;AAC3F;AAGM,SAAU,MAAM,GAAQ;AAC5B,MAAI,OAAO,MAAM,cAAc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,aACd,UAAuB;AAOvB,QAAM,QAAQ,CAAC,QAA2B,SAAQ,EAAG,OAAO,QAAQ,GAAG,CAAC,EAAE,OAAM;AAChF,QAAM,MAAM,SAAQ;AACpB,QAAM,YAAY,IAAI;AACtB,QAAM,WAAW,IAAI;AACrB,QAAM,SAAS,MAAM,SAAQ;AAC7B,SAAO;AACT;AAsCM,SAAU,YAAY,cAAc,IAAE;AAC1C,MAAI,UAAU,OAAO,OAAO,oBAAoB,YAAY;AAC1D,WAAO,OAAO,gBAAgB,IAAI,WAAW,WAAW,CAAC;EAC3D;AAEA,MAAI,UAAU,OAAO,OAAO,gBAAgB,YAAY;AACtD,WAAO,WAAW,KAAK,OAAO,YAAY,WAAW,CAAC;EACxD;AACA,QAAM,IAAI,MAAM,wCAAwC;AAC1D;","names":[]}
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
AdaptiveDeltaController,
|
|
4
4
|
DEFAULT_KEYSTORE_PASSWORD,
|
|
5
5
|
ILP_PEER_INFO_KIND,
|
|
6
|
+
InMemoryPreimageRetentionStore,
|
|
6
7
|
InMemoryReceivedClaimStore,
|
|
7
8
|
JsonFileReceivedClaimStore,
|
|
8
9
|
JsonFileSwapControllerStateStore,
|
|
@@ -15,14 +16,14 @@ import {
|
|
|
15
16
|
extractArweaveTxId,
|
|
16
17
|
fundWallet,
|
|
17
18
|
generateKeystore,
|
|
18
|
-
|
|
19
|
+
ingestAndReveal,
|
|
19
20
|
isEventExpired,
|
|
20
21
|
loadMinaSignerClient,
|
|
21
22
|
mintExecutionCondition,
|
|
22
23
|
parseIlpPeerInfo,
|
|
23
24
|
readConfigFile,
|
|
24
25
|
streamSwap
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-HSSJFB3I.js";
|
|
26
27
|
|
|
27
28
|
// src/daemon/first-run.ts
|
|
28
29
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
@@ -363,7 +364,7 @@ import { readFile, stat } from "fs/promises";
|
|
|
363
364
|
import { join as join3, resolve, sep } from "path";
|
|
364
365
|
import { generateSecretKey } from "nostr-tools/pure";
|
|
365
366
|
|
|
366
|
-
// ../../node_modules/.pnpm/@toon-protocol+core@
|
|
367
|
+
// ../../node_modules/.pnpm/@toon-protocol+core@3.0.0_typescript@5.9.3/node_modules/@toon-protocol/core/dist/nip34/index.js
|
|
367
368
|
var REPOSITORY_ANNOUNCEMENT_KIND = 30617;
|
|
368
369
|
var STATUS_OPEN_KIND = 1630;
|
|
369
370
|
var STATUS_APPLIED_KIND = 1631;
|
|
@@ -835,7 +836,7 @@ async function fetchRemoteState(options) {
|
|
|
835
836
|
};
|
|
836
837
|
}
|
|
837
838
|
|
|
838
|
-
// ../rig/dist/chunk-
|
|
839
|
+
// ../rig/dist/chunk-PG5PUKDR.js
|
|
839
840
|
import { execFile, spawn } from "child_process";
|
|
840
841
|
import { promisify } from "util";
|
|
841
842
|
import { execFile as execFile2, spawn as spawn2 } from "child_process";
|
|
@@ -1033,6 +1034,42 @@ var GitRepoReader = class {
|
|
|
1033
1034
|
}
|
|
1034
1035
|
return objects;
|
|
1035
1036
|
}
|
|
1037
|
+
/**
|
|
1038
|
+
* List every blob (file) reachable from a ref's root tree, recursively,
|
|
1039
|
+
* with the path it is served at (#368: the ar.io site manifest join key).
|
|
1040
|
+
* Uses `git ls-tree -r -z` — NUL-terminated records so binary/spaced paths
|
|
1041
|
+
* survive verbatim, and no path quoting to undo. Submodule (`commit`)
|
|
1042
|
+
* gitlink entries and directories are excluded; only real file blobs remain.
|
|
1043
|
+
*/
|
|
1044
|
+
async listBlobs(rev) {
|
|
1045
|
+
assertRevision(rev, "ref");
|
|
1046
|
+
const { stdout } = await this.git(["ls-tree", "-r", "-z", rev, "--"]);
|
|
1047
|
+
const blobs = [];
|
|
1048
|
+
for (const record of stdout.split("\0")) {
|
|
1049
|
+
if (!record) continue;
|
|
1050
|
+
const tab = record.indexOf(" ");
|
|
1051
|
+
if (tab === -1) {
|
|
1052
|
+
throw new GitError(
|
|
1053
|
+
`unexpected ls-tree record: ${JSON.stringify(record)}`,
|
|
1054
|
+
void 0,
|
|
1055
|
+
""
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
const meta = record.slice(0, tab);
|
|
1059
|
+
const path = record.slice(tab + 1);
|
|
1060
|
+
const [, type, sha] = meta.split(" ");
|
|
1061
|
+
if (type !== "blob") continue;
|
|
1062
|
+
if (!sha || !FULL_SHA_RE.test(sha)) {
|
|
1063
|
+
throw new GitError(
|
|
1064
|
+
`unexpected ls-tree object id: ${JSON.stringify(record)}`,
|
|
1065
|
+
void 0,
|
|
1066
|
+
""
|
|
1067
|
+
);
|
|
1068
|
+
}
|
|
1069
|
+
blobs.push({ path, sha });
|
|
1070
|
+
}
|
|
1071
|
+
return blobs;
|
|
1072
|
+
}
|
|
1036
1073
|
/** Run git feeding `input` on stdin; resolves collected stdout bytes. */
|
|
1037
1074
|
runWithStdin(args, input) {
|
|
1038
1075
|
return new Promise((resolve2, reject) => {
|
|
@@ -1432,7 +1469,10 @@ async function executePush(options) {
|
|
|
1432
1469
|
sha: object.sha,
|
|
1433
1470
|
type: object.type,
|
|
1434
1471
|
body,
|
|
1435
|
-
repoId: plan.repoId
|
|
1472
|
+
repoId: plan.repoId,
|
|
1473
|
+
// #368: the path the blob was reached by drives its Content-Type; a
|
|
1474
|
+
// non-blob object (no path) uploads as octet-stream.
|
|
1475
|
+
...object.path ? { path: object.path } : {}
|
|
1436
1476
|
});
|
|
1437
1477
|
merged.set(object.sha, receipt.txId);
|
|
1438
1478
|
totalFeePaid += receipt.feePaid;
|
|
@@ -2059,7 +2099,9 @@ var ClientRunner = class {
|
|
|
2059
2099
|
)
|
|
2060
2100
|
);
|
|
2061
2101
|
}
|
|
2062
|
-
this.log(
|
|
2102
|
+
this.log(
|
|
2103
|
+
`[runner] resumed apex channel ${saved.channelId} (deposit re-read)`
|
|
2104
|
+
);
|
|
2063
2105
|
return saved.channelId;
|
|
2064
2106
|
}
|
|
2065
2107
|
if (opts.resumeOnly) return void 0;
|
|
@@ -2407,7 +2449,10 @@ var ClientRunner = class {
|
|
|
2407
2449
|
`Arweave upload leg failed (store ${this.config.storeDestination}): ${upload.error ?? "blob upload rejected"}`
|
|
2408
2450
|
);
|
|
2409
2451
|
}
|
|
2410
|
-
const { url, fallbacks } = arweaveUrls(
|
|
2452
|
+
const { url, fallbacks } = arweaveUrls(
|
|
2453
|
+
upload.txId,
|
|
2454
|
+
this.config.arweaveGateways
|
|
2455
|
+
);
|
|
2411
2456
|
const kind = req.kind ?? 1063;
|
|
2412
2457
|
const signed = await apex.client.signEvent({
|
|
2413
2458
|
kind,
|
|
@@ -2450,7 +2495,9 @@ var ClientRunner = class {
|
|
|
2450
2495
|
return new Uint8Array(buf);
|
|
2451
2496
|
} catch (err) {
|
|
2452
2497
|
const detail = err instanceof Error ? err.message : String(err);
|
|
2453
|
-
throw new InvalidPayloadError(
|
|
2498
|
+
throw new InvalidPayloadError(
|
|
2499
|
+
`failed to read filePath ${resolved}: ${detail}`
|
|
2500
|
+
);
|
|
2454
2501
|
}
|
|
2455
2502
|
}
|
|
2456
2503
|
/** Validate + assemble a signable event template (with replaceable merge). */
|
|
@@ -2504,7 +2551,12 @@ var ClientRunner = class {
|
|
|
2504
2551
|
];
|
|
2505
2552
|
}
|
|
2506
2553
|
return [
|
|
2507
|
-
[
|
|
2554
|
+
[
|
|
2555
|
+
"imeta",
|
|
2556
|
+
`url ${url}`,
|
|
2557
|
+
`m ${mime}`,
|
|
2558
|
+
...fallbacks.map((f) => `fallback ${f}`)
|
|
2559
|
+
],
|
|
2508
2560
|
...extra
|
|
2509
2561
|
];
|
|
2510
2562
|
}
|
|
@@ -2596,7 +2648,10 @@ var ClientRunner = class {
|
|
|
2596
2648
|
}
|
|
2597
2649
|
/** Close a channel to begin the settlement grace period (withdraw, step 1). */
|
|
2598
2650
|
async closeChannel(req) {
|
|
2599
|
-
return this.withTrackingApex(
|
|
2651
|
+
return this.withTrackingApex(
|
|
2652
|
+
req.channelId,
|
|
2653
|
+
(client) => client.closeChannel(req.channelId)
|
|
2654
|
+
);
|
|
2600
2655
|
}
|
|
2601
2656
|
/**
|
|
2602
2657
|
* Settle a closed channel to release collateral (withdraw, step 2). The client
|
|
@@ -2604,7 +2659,10 @@ var ClientRunner = class {
|
|
|
2604
2659
|
* called early; `mapError` maps that to HTTP 425.
|
|
2605
2660
|
*/
|
|
2606
2661
|
async settleChannel(req) {
|
|
2607
|
-
return this.withTrackingApex(
|
|
2662
|
+
return this.withTrackingApex(
|
|
2663
|
+
req.channelId,
|
|
2664
|
+
(client) => client.settleChannel(req.channelId)
|
|
2665
|
+
);
|
|
2608
2666
|
}
|
|
2609
2667
|
/** Run `fn` against the apex client that tracks `channelId`, else throw. */
|
|
2610
2668
|
async withTrackingApex(channelId, fn) {
|
|
@@ -2695,7 +2753,8 @@ var ClientRunner = class {
|
|
|
2695
2753
|
}
|
|
2696
2754
|
};
|
|
2697
2755
|
const senderSecretKey = generateSecretKey();
|
|
2698
|
-
const
|
|
2756
|
+
const preimages = new InMemoryPreimageRetentionStore();
|
|
2757
|
+
const swapClient = req.senderConditions ? this.withSenderConditions(apex.client, preimages) : apex.client;
|
|
2699
2758
|
const result = await streamSwap({
|
|
2700
2759
|
client: swapClient,
|
|
2701
2760
|
swapPubkey: req.swapPubkey,
|
|
@@ -2714,15 +2773,24 @@ var ClientRunner = class {
|
|
|
2714
2773
|
const firstReject = result.rejections[0];
|
|
2715
2774
|
const expectedChain = req.pair.to.chain;
|
|
2716
2775
|
const minaSignerClient = expectedChain.startsWith("mina") ? await loadMinaSignerClient() : void 0;
|
|
2717
|
-
const
|
|
2776
|
+
const reveal = () => ({ decision: "revealed" });
|
|
2777
|
+
const ingest = await ingestAndReveal({
|
|
2718
2778
|
claims: result.claims,
|
|
2719
2779
|
expectedChain,
|
|
2720
2780
|
chainRecipient: req.chainRecipient,
|
|
2721
2781
|
...req.swapSignerAddress ? { expectedSignerAddress: req.swapSignerAddress } : {},
|
|
2782
|
+
// v2 EIP-712 receive-side verify (#365): EVM claims are domain-separated
|
|
2783
|
+
// over `(chainId, verifyingContract)`, so the receive path needs the same
|
|
2784
|
+
// `tokenNetworks` (chain key → RollingSwapChannel address) map the settle
|
|
2785
|
+
// path already threads, or an EVM claim is rejected MISSING_CHAIN_CONFIG.
|
|
2786
|
+
...this.config.toonClientConfig.tokenNetworks ? { tokenNetworks: this.config.toonClientConfig.tokenNetworks } : {},
|
|
2722
2787
|
store: this.receivedClaimStore,
|
|
2723
|
-
...minaSignerClient ? { minaSignerClient } : {}
|
|
2788
|
+
...minaSignerClient ? { minaSignerClient } : {},
|
|
2789
|
+
preimages,
|
|
2790
|
+
reveal
|
|
2724
2791
|
});
|
|
2725
|
-
|
|
2792
|
+
preimages.clear();
|
|
2793
|
+
const verifiedSet = new Set(ingest.revealed.map((v) => v.claim));
|
|
2726
2794
|
const rejectionByClaim = new Map(
|
|
2727
2795
|
ingest.rejected.map((r) => [r.claim, r])
|
|
2728
2796
|
);
|
|
@@ -2776,12 +2844,13 @@ var ClientRunner = class {
|
|
|
2776
2844
|
`${ingest.rejected.length} received claim(s) FAILED verification and were NOT counted as value received (first: ${firstRejected.code} \u2014 ${firstRejected.message}). See per-claim verificationError.`
|
|
2777
2845
|
);
|
|
2778
2846
|
}
|
|
2779
|
-
const hadIngestibleClaims = ingest.
|
|
2847
|
+
const hadIngestibleClaims = ingest.revealed.length + ingest.rejected.length > 0;
|
|
2780
2848
|
return {
|
|
2781
|
-
// A swap only counts as accepted when it yielded a VERIFIED
|
|
2782
|
-
// legacy no-metadata claim, whose path is unchanged).
|
|
2783
|
-
// whose claims all failed verification are a failed
|
|
2784
|
-
|
|
2849
|
+
// A swap only counts as accepted when it yielded a VERIFIED+REVEALED
|
|
2850
|
+
// claim (or a legacy no-metadata claim, whose path is unchanged).
|
|
2851
|
+
// FULFILLed packets whose claims all failed verification are a failed
|
|
2852
|
+
// swap, loudly.
|
|
2853
|
+
accepted: ingest.revealed.length + ingest.legacy.length > 0,
|
|
2785
2854
|
packetsAccepted: result.claims.length,
|
|
2786
2855
|
claims,
|
|
2787
2856
|
cumulativeSource: result.cumulativeSource.toString(),
|
|
@@ -2803,9 +2872,9 @@ var ClientRunner = class {
|
|
|
2803
2872
|
...firstReject ? { code: firstReject.code, message: firstReject.message } : {},
|
|
2804
2873
|
...warnings.length > 0 ? { warning: warnings.join("\n") } : {},
|
|
2805
2874
|
...hadIngestibleClaims ? {
|
|
2806
|
-
claimsVerified: ingest.
|
|
2875
|
+
claimsVerified: ingest.revealed.length,
|
|
2807
2876
|
claimsRejected: ingest.rejected.length,
|
|
2808
|
-
valueReceived: ingest.
|
|
2877
|
+
valueReceived: ingest.valueRevealed.toString()
|
|
2809
2878
|
} : {}
|
|
2810
2879
|
};
|
|
2811
2880
|
}
|
|
@@ -2854,6 +2923,14 @@ var ClientRunner = class {
|
|
|
2854
2923
|
const builds = buildSwapSettlements({
|
|
2855
2924
|
entries: pending,
|
|
2856
2925
|
...this.config.toonClientConfig.tokenNetworks ? { tokenNetworks: this.config.toonClientConfig.tokenNetworks } : {},
|
|
2926
|
+
// Re-verify the stored watermark's signature at settle time
|
|
2927
|
+
// (defense-in-depth over the store file). The published v2 sdk
|
|
2928
|
+
// (`@toon-protocol/sdk@^3`) verifies EVM claims against the SAME v2
|
|
2929
|
+
// EIP-712 domain-separated digest the receive-side used (#365), so a
|
|
2930
|
+
// valid v2 signature verifies correctly here — `buildSwapSettlements`
|
|
2931
|
+
// threads `chainId` + `verifyingContract` (from `tokenNetworks`) into the
|
|
2932
|
+
// sdk signer config so the EIP-712 domain is reconstructed.
|
|
2933
|
+
verifySignatures: true,
|
|
2857
2934
|
...minaSignerClient ? { minaSignerClient } : {}
|
|
2858
2935
|
});
|
|
2859
2936
|
for (const [i, build] of builds.entries()) {
|
|
@@ -2883,16 +2960,56 @@ var ClientRunner = class {
|
|
|
2883
2960
|
results.push(base);
|
|
2884
2961
|
continue;
|
|
2885
2962
|
}
|
|
2886
|
-
if (bundle.chainKind
|
|
2963
|
+
if (bundle.chainKind === "solana") {
|
|
2887
2964
|
results.push({
|
|
2888
2965
|
...base,
|
|
2889
2966
|
error: {
|
|
2890
2967
|
code: "SUBMISSION_UNSUPPORTED",
|
|
2891
|
-
message:
|
|
2968
|
+
message: "Solana settlement submission is not wired yet (bundle carries a serialized Message; follow-up under toon-meta#145)."
|
|
2892
2969
|
}
|
|
2893
2970
|
});
|
|
2894
2971
|
continue;
|
|
2895
2972
|
}
|
|
2973
|
+
if (bundle.chainKind === "mina") {
|
|
2974
|
+
if (!this.identityClient.settleSwapBundle) {
|
|
2975
|
+
results.push({
|
|
2976
|
+
...base,
|
|
2977
|
+
error: {
|
|
2978
|
+
code: "SUBMISSION_UNAVAILABLE",
|
|
2979
|
+
message: "The active client does not implement settleSwapBundle."
|
|
2980
|
+
}
|
|
2981
|
+
});
|
|
2982
|
+
continue;
|
|
2983
|
+
}
|
|
2984
|
+
try {
|
|
2985
|
+
const submitted = await this.identityClient.settleSwapBundle(bundle);
|
|
2986
|
+
const latest = this.receivedClaimStore.load(entry.chain, entry.channelId) ?? entry;
|
|
2987
|
+
this.receivedClaimStore.save({
|
|
2988
|
+
...latest,
|
|
2989
|
+
settledAt: Date.now(),
|
|
2990
|
+
settledNonce: BigInt(bundle.nonce),
|
|
2991
|
+
settleTxHash: submitted.txHash
|
|
2992
|
+
});
|
|
2993
|
+
this.log(
|
|
2994
|
+
`[runner] swap settle: submitted ${bundle.chain}/${bundle.channelId} nonce ${bundle.nonce} cumulative ${bundle.cumulativeAmount} \u2192 ${submitted.txHash}`
|
|
2995
|
+
);
|
|
2996
|
+
results.push({
|
|
2997
|
+
...base,
|
|
2998
|
+
submitted: true,
|
|
2999
|
+
txHash: submitted.txHash,
|
|
3000
|
+
...submitted.status ? { txStatus: submitted.status } : {}
|
|
3001
|
+
});
|
|
3002
|
+
} catch (err) {
|
|
3003
|
+
results.push({
|
|
3004
|
+
...base,
|
|
3005
|
+
error: {
|
|
3006
|
+
code: "SUBMISSION_FAILED",
|
|
3007
|
+
message: err instanceof Error ? err.message : String(err)
|
|
3008
|
+
}
|
|
3009
|
+
});
|
|
3010
|
+
}
|
|
3011
|
+
continue;
|
|
3012
|
+
}
|
|
2896
3013
|
const rpcUrl = this.config.toonClientConfig.chainRpcUrls?.[bundle.chain];
|
|
2897
3014
|
if (!rpcUrl) {
|
|
2898
3015
|
results.push({
|
|
@@ -2948,20 +3065,30 @@ var ClientRunner = class {
|
|
|
2948
3065
|
* Wrap an apex client so each `sendSwapPacket` call carries a freshly
|
|
2949
3066
|
* minted sender-chosen execution condition (one preimage per packet, spec
|
|
2950
3067
|
* R1 — reuse would let an observer of packet *i* fulfill packet *i+1*).
|
|
2951
|
-
* `streamSwap` calls `sendSwapPacket` once per packet,
|
|
2952
|
-
*
|
|
2953
|
-
*
|
|
3068
|
+
* `streamSwap` calls `sendSwapPacket` once per packet, in strictly
|
|
3069
|
+
* increasing `packetIndex` order, so minting here yields exactly one
|
|
3070
|
+
* condition per packet and the local counter tracks `packetIndex`. The
|
|
3071
|
+
* transports verify each FULFILL's preimage against the condition and fail
|
|
3072
|
+
* the packet on mismatch.
|
|
2954
3073
|
*
|
|
2955
|
-
*
|
|
2956
|
-
*
|
|
2957
|
-
*
|
|
2958
|
-
*
|
|
2959
|
-
*
|
|
3074
|
+
* Preimage retention (toon-client#360, spec §3.2 leg-B reveal): every minted
|
|
3075
|
+
* `P_i` is retained in `preimages`, keyed by `packetIndex` — the identifier
|
|
3076
|
+
* shared with `AccumulatedClaim.packetIndex` — so the receive-side reveal
|
|
3077
|
+
* step (`ingestAndReveal`) can correlate and consume the preimage for the
|
|
3078
|
+
* claim it commits. Retention is session-scoped (one store per `swap()`
|
|
3079
|
+
* call); a fresh stream mints fresh preimages.
|
|
2960
3080
|
*/
|
|
2961
|
-
withSenderConditions(client) {
|
|
3081
|
+
withSenderConditions(client, preimages) {
|
|
2962
3082
|
const wrapped = Object.create(client);
|
|
3083
|
+
let packetIndex = 0;
|
|
2963
3084
|
wrapped.sendSwapPacket = (params) => {
|
|
2964
|
-
const { condition } = mintExecutionCondition();
|
|
3085
|
+
const { preimage, condition } = mintExecutionCondition();
|
|
3086
|
+
preimages.retain({
|
|
3087
|
+
packetIndex: packetIndex++,
|
|
3088
|
+
preimage,
|
|
3089
|
+
condition,
|
|
3090
|
+
retainedAt: Date.now()
|
|
3091
|
+
});
|
|
2965
3092
|
return client.sendSwapPacket({
|
|
2966
3093
|
...params,
|
|
2967
3094
|
executionCondition: condition
|
|
@@ -3439,8 +3566,10 @@ function matchesFilter(event, filter) {
|
|
|
3439
3566
|
if (filter.ids && !filter.ids.includes(event.id)) return false;
|
|
3440
3567
|
if (filter.kinds && !filter.kinds.includes(event.kind)) return false;
|
|
3441
3568
|
if (filter.authors && !filter.authors.includes(event.pubkey)) return false;
|
|
3442
|
-
if (filter.since !== void 0 && event.created_at < filter.since)
|
|
3443
|
-
|
|
3569
|
+
if (filter.since !== void 0 && event.created_at < filter.since)
|
|
3570
|
+
return false;
|
|
3571
|
+
if (filter.until !== void 0 && event.created_at > filter.until)
|
|
3572
|
+
return false;
|
|
3444
3573
|
for (const [key2, values] of Object.entries(filter)) {
|
|
3445
3574
|
if (!key2.startsWith("#") || !Array.isArray(values)) continue;
|
|
3446
3575
|
const letter = key2.slice(1);
|
|
@@ -3453,7 +3582,8 @@ function matchesFilter(event, filter) {
|
|
|
3453
3582
|
}
|
|
3454
3583
|
function normalizeTags(raw) {
|
|
3455
3584
|
if (raw === void 0) return [];
|
|
3456
|
-
if (!Array.isArray(raw))
|
|
3585
|
+
if (!Array.isArray(raw))
|
|
3586
|
+
throw new InvalidPayloadError("tags must be an array.");
|
|
3457
3587
|
return raw.map((tag, i) => {
|
|
3458
3588
|
if (!Array.isArray(tag) || !tag.every((x) => typeof x === "string")) {
|
|
3459
3589
|
throw new InvalidPayloadError(`tags[${i}] must be an array of strings.`);
|
|
@@ -3932,4 +4062,4 @@ export {
|
|
|
3932
4062
|
PublishRejectedError,
|
|
3933
4063
|
registerRoutes
|
|
3934
4064
|
};
|
|
3935
|
-
//# sourceMappingURL=chunk-
|
|
4065
|
+
//# sourceMappingURL=chunk-5SFBB4PJ.js.map
|