@xo-cash/utils 0.0.2-development.15418787895 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -41,133 +41,6 @@ declare const extendedJsonReviver: (_propertyKey: string, value: unknown) => unk
41
41
  */
42
42
  declare const scriptToScriptHash: (script: Uint8Array) => string;
43
43
  //#endregion
44
- //#region source/sse-session/types.d.ts
45
- /**
46
- * Represents a Server-Sent Event.
47
- */
48
- interface SSEvent {
49
- /**
50
- * Event data.
51
- */
52
- data: string;
53
- /**
54
- * Event type.
55
- * This value is optionally sent by the server. Traditional EventSource allows listeners for specific event types.
56
- * The SSE Session collapses all event types into "message" event.
57
- */
58
- event?: string;
59
- /**
60
- * Event ID.
61
- * This value is optionally sent by the server as a "checkpoint" the client can use to resume from using the Last-Event-ID header.
62
- */
63
- id?: string;
64
- /**
65
- * Reconnection time in milliseconds.
66
- * This value is optionally sent by the server to indicate the server's preferred time before reconnecting
67
- */
68
- retry?: number;
69
- }
70
- //#endregion
71
- //#region source/sse-session/sse-event-parser.d.ts
72
- /**
73
- * Optional encoders used when decoding incoming SSE bytes and re-encoding
74
- * any buffered remainder between chunks.
75
- */
76
- interface SSEEventParserOptions {
77
- /** Decodes raw stream bytes into text. Defaults to a new `TextDecoder`. */
78
- textDecoder: TextDecoder;
79
- }
80
- /**
81
- * Incrementally parses Server-Sent Events (SSE) from streamed byte chunks.
82
- *
83
- * SSE payloads are line-oriented: each event is a sequence of `field: value`
84
- * lines terminated by a blank line. This parser accepts arbitrary chunk
85
- * boundaries from a live HTTP response body and emits only complete events.
86
- *
87
- * Typical usage is one parser instance per connection, calling {@link parseEvents}
88
- * for each chunk received from the stream:
89
- *
90
- * ```ts
91
- * const parser = new SSEEventParser();
92
- *
93
- * for await (const chunk of response.body) {
94
- * for (const event of parser.parseEvents(chunk)) {
95
- * // handle event.data, event.event, event.id, event.retry
96
- * }
97
- * }
98
- * ```
99
- *
100
- * Supported fields follow the SSE spec: `data`, `event`, `id`, and `retry`.
101
- * Multiple `data:` lines in one event are joined with `\n`. An event is only
102
- * emitted once a blank line is seen and at least one `data` field was collected.
103
- */
104
- declare class SSEEventParser {
105
- #private;
106
- /**
107
- * Creates a parser for one SSE stream.
108
- *
109
- * Inject custom encoders in tests or when a non-default character encoding
110
- * is required; production callers can rely on the defaults.
111
- *
112
- * @param options - Optional text encoders for decode/encode of stream bytes.
113
- */
114
- constructor(options?: Partial<SSEEventParserOptions>);
115
- /**
116
- * Clears any buffered bytes from a partial line or incomplete event.
117
- *
118
- * Call when abandoning a transport so the next connection does not prepend
119
- * stale bytes to incoming chunks.
120
- */
121
- reset(): void;
122
- /**
123
- * Parses all complete SSE events contained in a newly received chunk.
124
- *
125
- * The chunk is appended to any bytes buffered from earlier calls. Complete
126
- * events (blank-line delimited blocks with at least one `data` field) are
127
- * returned immediately; any trailing partial line or in-progress event stays
128
- * in the internal buffer until a later chunk completes it.
129
- *
130
- * @param chunk - Newly received SSE stream bytes.
131
- * @returns Zero or more complete parsed SSE events from this chunk.
132
- */
133
- parseEvents(chunk: Uint8Array): SSEvent[];
134
- /**
135
- * Appends a new chunk to the buffered bytes and splits the combined payload
136
- * into lines.
137
- *
138
- * Accepts `\r\n`, `\r`, and `\n` line endings so events parse correctly
139
- * regardless of server or platform conventions.
140
- */
141
- private getBufferedLines;
142
- /**
143
- * Parses one SSE field line into an in-progress event.
144
- *
145
- * Lines without a colon are ignored. A single optional space after the colon
146
- * is stripped from the field value, per the SSE spec.
147
- */
148
- private parseLine;
149
- /**
150
- * Applies a numeric `retry:` field to an in-progress event.
151
- *
152
- * Non-numeric values are ignored rather than failing the parse.
153
- */
154
- private parseRetry;
155
- /**
156
- * Constructs a completed SSE event from accumulated fields.
157
- *
158
- * Trims a trailing newline from multi-line `data` values so callers receive
159
- * the payload without an extra line break at the end.
160
- */
161
- private completeEvent;
162
- /**
163
- * Preserves incomplete trailing lines for the next received chunk.
164
- *
165
- * Only lines that were fully processed (through a completed event boundary)
166
- * are discarded; the remainder is re-encoded into {@link messageBuffer}.
167
- */
168
- private storeRemainingLines;
169
- }
170
- //#endregion
171
44
  //#region source/template/errors.d.ts
172
45
  /**
173
46
  * Formats the Zod validation failures into a single string with one line each: "- <field>: <message>" and top level failures
@@ -1471,5 +1344,5 @@ declare const xoTemplateSchema: z.ZodObject<{
1471
1344
  */
1472
1345
  declare const serializeTemplate: (template: XOTemplate) => string;
1473
1346
  //#endregion
1474
- export { SSEEventParser, SSEEventParserOptions, TemplateInvalidError, TemplateJsonMalformedError, TemplateSerializationFailedError, VIEW_PROPERTIES_DESCRIPTION_MAX_LENGTH, VIEW_PROPERTIES_ICON_MAX_LENGTH, VIEW_PROPERTIES_NAME_MAX_LENGTH, bchVmVersionSchema, buildErrorDescription, extendedJsonReplacer, extendedJsonReviver, generateTemplateIdentifier, parseTemplate, satoshisSchema, scriptToScriptHash, serializeTemplate, uint8ArraySchema, xoTemplateActionIntentSchema, xoTemplateActionRequirementsSchema, xoTemplateActionRoleRequirementsSchema, xoTemplateActionRoleSchema, xoTemplateActionSchema, xoTemplateAssetAmountsSchema, xoTemplateConstantSchema, xoTemplateDataSchema, xoTemplateDefaultsSchema, xoTemplateIconSchema, xoTemplateImportDefaultValueSchema, xoTemplateInputSchema, xoTemplateIntentSchema, xoTemplateLockingScriptIntentSchema, xoTemplateLockingScriptRoleSchema, xoTemplateLockingScriptSchema, xoTemplateLockingTypeSchema, xoTemplateNftCapabilitySchema, xoTemplateNonFungibleTokenDetailsSchema, xoTemplateOutputIntentSchema, xoTemplateOutputSchema, xoTemplatePrimitiveTypeSchema, xoTemplateResourceSchema, xoTemplateRoleSlotSchema, xoTemplateRoleSlotsRequirementsSchema, xoTemplateSchema, xoTemplateStateSchema, xoTemplateTokenSchema, xoTemplateTransactionInputSchema, xoTemplateTransactionOutputSchema, xoTemplateTransactionRoleDataSchema, xoTemplateTransactionSchema, xoTemplateVariableSchema, xoTemplateViewPropertiesSchema };
1347
+ export { TemplateInvalidError, TemplateJsonMalformedError, TemplateSerializationFailedError, VIEW_PROPERTIES_DESCRIPTION_MAX_LENGTH, VIEW_PROPERTIES_ICON_MAX_LENGTH, VIEW_PROPERTIES_NAME_MAX_LENGTH, bchVmVersionSchema, buildErrorDescription, extendedJsonReplacer, extendedJsonReviver, generateTemplateIdentifier, parseTemplate, satoshisSchema, scriptToScriptHash, serializeTemplate, uint8ArraySchema, xoTemplateActionIntentSchema, xoTemplateActionRequirementsSchema, xoTemplateActionRoleRequirementsSchema, xoTemplateActionRoleSchema, xoTemplateActionSchema, xoTemplateAssetAmountsSchema, xoTemplateConstantSchema, xoTemplateDataSchema, xoTemplateDefaultsSchema, xoTemplateIconSchema, xoTemplateImportDefaultValueSchema, xoTemplateInputSchema, xoTemplateIntentSchema, xoTemplateLockingScriptIntentSchema, xoTemplateLockingScriptRoleSchema, xoTemplateLockingScriptSchema, xoTemplateLockingTypeSchema, xoTemplateNftCapabilitySchema, xoTemplateNonFungibleTokenDetailsSchema, xoTemplateOutputIntentSchema, xoTemplateOutputSchema, xoTemplatePrimitiveTypeSchema, xoTemplateResourceSchema, xoTemplateRoleSlotSchema, xoTemplateRoleSlotsRequirementsSchema, xoTemplateSchema, xoTemplateStateSchema, xoTemplateTokenSchema, xoTemplateTransactionInputSchema, xoTemplateTransactionOutputSchema, xoTemplateTransactionRoleDataSchema, xoTemplateTransactionSchema, xoTemplateVariableSchema, xoTemplateViewPropertiesSchema };
1475
1348
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../source/extended-json.ts","../source/script.ts","../source/sse-session/types.ts","../source/sse-session/sse-event-parser.ts","../source/template/errors.ts","../source/template/identifier.ts","../source/template/parser.ts","../source/template/schemas.ts","../source/template/serialization.ts"],"mappings":";;;;;;;;;;AA8BA;;;;;AAqBA;;;;;;;;cArBa,oBAAA,GAAwB,YAAA,UAAsB,KAAA;;;;;;;;AE3B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iBxB,oBAAA,EAAoB,CAAA,CAAA,SAAA;;;;;;;;;;;;;cAoBpB,wBAAA,EAAwB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;cAaxB,gBAAA,EAAgB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;APx0B7B;;;;cQlBa,iBAAA,GAAqB,QAAA,EAAU,UAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../source/extended-json.ts","../source/script.ts","../source/template/errors.ts","../source/template/identifier.ts","../source/template/parser.ts","../source/template/schemas.ts","../source/template/serialization.ts"],"mappings":";;;;;;;;;;AA8BA;;;;;AAqBA;;;;;;;;cArBa,oBAAA,GAAwB,YAAA,UAAsB,KAAA;;;;;;;;AEnB3D;;cFwCa,mBAAA,GAAuB,YAAA,UAAsB,KAAA;;;;;;;;cC5C7C,kBAAA,GAAsB,MAAA,EAAQ,UAAA;;;;;;;ADuB3C;;;cEnBa,qBAAA,GAAyB,MAAA,EAAQ,SAAA;;AFwC9C;;cEda,oBAAA,SAA6B,KAAA;cAC1B,OAAA;AAAA;;;;cAUH,0BAAA,SAAmC,KAAA;cAChC,MAAA;AAAA;;;;cASH,gCAAA,SAAyC,KAAA;cACtC,MAAA;AAAA;;;;;;;AF7BhB;;;;cGlBa,0BAAA,GAA8B,QAAA,EAAU,UAAA;;;;;;;AHkBrD;;;;;AAqBA;;cInCa,aAAA,GAAiB,aAAA,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,kCAAA,EAAkC,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;cAgBlC,wBAAA,EAAwB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+BxB,wBAAA,EAAwB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;cAiBxB,oBAAA,EAAoB,CAAA,CAAA,SAAA;;;;;;;;;;;;;cAoBpB,wBAAA,EAAwB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;cAaxB,gBAAA,EAAgB,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ALx0B7B;;;;cMlBa,iBAAA,GAAqB,QAAA,EAAU,UAAA"}
package/dist/index.mjs CHANGED
@@ -63,191 +63,6 @@ const scriptToScriptHash = (script) => {
63
63
  return binToHex(sha256.hash(script).reverse());
64
64
  };
65
65
 
66
- //#endregion
67
- //#region source/sse-session/constants.ts
68
- /**
69
- * Regex that splits decoded SSE text into lines.
70
- *
71
- * The SSE wire format is line-oriented (`field: value` per line). Servers may
72
- * send `\r\n` (HTTP default), `\n` (Unix), or `\r` (legacy Mac). Matching all
73
- * three keeps parsing correct regardless of platform or server implementation.
74
- */
75
- const SSE_LINE_ENDINGS = /\r\n|\r|\n/;
76
- /**
77
- * Regex that matches the single optional leading space in an SSE field value.
78
- *
79
- * Per the SSE spec, `field: value` may include one space immediately after the
80
- * colon; that space is not part of the value. Used with `.replace()` to strip
81
- * it when parsing lines such as `data: hello` → `hello`.
82
- */
83
- const SSE_FIELD_VALUE_REGEX = /^ /;
84
- /**
85
- * Regex that matches a trailing newline at the end of a string.
86
- *
87
- * Multiple `data:` lines in one event are joined with `\n`. When the event is
88
- * completed, this removes any stray trailing newline so callers receive the
89
- * payload without an extra line break at the end.
90
- */
91
- const SSE_TRAILING_NEWLINE_REGEX = /\n$/;
92
- /**
93
- * The newline character used when normalizing SSE text internally.
94
- *
95
- * Used to join consecutive `data:` lines into one payload and to reassemble
96
- * buffered partial lines between streamed chunks before the next parse call.
97
- */
98
- const NEW_LINE = "\n";
99
-
100
- //#endregion
101
- //#region source/sse-session/sse-event-parser.ts
102
- /**
103
- * Incrementally parses Server-Sent Events (SSE) from streamed byte chunks.
104
- *
105
- * SSE payloads are line-oriented: each event is a sequence of `field: value`
106
- * lines terminated by a blank line. This parser accepts arbitrary chunk
107
- * boundaries from a live HTTP response body and emits only complete events.
108
- *
109
- * Typical usage is one parser instance per connection, calling {@link parseEvents}
110
- * for each chunk received from the stream:
111
- *
112
- * ```ts
113
- * const parser = new SSEEventParser();
114
- *
115
- * for await (const chunk of response.body) {
116
- * for (const event of parser.parseEvents(chunk)) {
117
- * // handle event.data, event.event, event.id, event.retry
118
- * }
119
- * }
120
- * ```
121
- *
122
- * Supported fields follow the SSE spec: `data`, `event`, `id`, and `retry`.
123
- * Multiple `data:` lines in one event are joined with `\n`. An event is only
124
- * emitted once a blank line is seen and at least one `data` field was collected.
125
- */
126
- var SSEEventParser = class {
127
- #textDecoder;
128
- /** Bytes from a partial line or incomplete event, carried over to the next chunk. */
129
- #messageBuffer = "";
130
- /**
131
- * Creates a parser for one SSE stream.
132
- *
133
- * Inject custom encoders in tests or when a non-default character encoding
134
- * is required; production callers can rely on the defaults.
135
- *
136
- * @param options - Optional text encoders for decode/encode of stream bytes.
137
- */
138
- constructor(options = {}) {
139
- this.#textDecoder = options.textDecoder ?? new TextDecoder();
140
- }
141
- /**
142
- * Clears any buffered bytes from a partial line or incomplete event.
143
- *
144
- * Call when abandoning a transport so the next connection does not prepend
145
- * stale bytes to incoming chunks.
146
- */
147
- reset() {
148
- this.#messageBuffer = "";
149
- this.#textDecoder.decode();
150
- }
151
- /**
152
- * Parses all complete SSE events contained in a newly received chunk.
153
- *
154
- * The chunk is appended to any bytes buffered from earlier calls. Complete
155
- * events (blank-line delimited blocks with at least one `data` field) are
156
- * returned immediately; any trailing partial line or in-progress event stays
157
- * in the internal buffer until a later chunk completes it.
158
- *
159
- * @param chunk - Newly received SSE stream bytes.
160
- * @returns Zero or more complete parsed SSE events from this chunk.
161
- */
162
- parseEvents(chunk) {
163
- const lines = this.getBufferedLines(chunk);
164
- const eventLines = lines.slice(0, -1);
165
- const events = [];
166
- let event = {};
167
- let processedLineCount = 0;
168
- for (const [index, line] of eventLines.entries()) {
169
- if (line === "") {
170
- if (event.data !== void 0) {
171
- events.push(this.completeEvent(event));
172
- event = {};
173
- processedLineCount = index + 1;
174
- }
175
- continue;
176
- }
177
- this.parseLine(line, event);
178
- }
179
- this.storeRemainingLines(lines, processedLineCount);
180
- return events;
181
- }
182
- /**
183
- * Appends a new chunk to the buffered bytes and splits the combined payload
184
- * into lines.
185
- *
186
- * Accepts `\r\n`, `\r`, and `\n` line endings so events parse correctly
187
- * regardless of server or platform conventions.
188
- */
189
- getBufferedLines(chunk) {
190
- this.#messageBuffer += this.#textDecoder.decode(chunk, { stream: true });
191
- return this.#messageBuffer.split(SSE_LINE_ENDINGS);
192
- }
193
- /**
194
- * Parses one SSE field line into an in-progress event.
195
- *
196
- * Lines without a colon are ignored. A single optional space after the colon
197
- * is stripped from the field value, per the SSE spec.
198
- */
199
- parseLine(line, event) {
200
- const colonIndex = line.indexOf(":");
201
- if (colonIndex === -1) return;
202
- const field = line.slice(0, colonIndex);
203
- const value = line.slice(colonIndex + 1).replace(SSE_FIELD_VALUE_REGEX, "");
204
- switch (field) {
205
- case "data":
206
- event.data = event.data ? `${event.data}${NEW_LINE}${value}` : value;
207
- return;
208
- case "event":
209
- event.event = value;
210
- return;
211
- case "id":
212
- event.id = value;
213
- return;
214
- case "retry":
215
- this.parseRetry(value, event);
216
- return;
217
- }
218
- }
219
- /**
220
- * Applies a numeric `retry:` field to an in-progress event.
221
- *
222
- * Non-numeric values are ignored rather than failing the parse.
223
- */
224
- parseRetry(value, event) {
225
- const retry = parseInt(value, 10);
226
- if (!isNaN(retry)) event.retry = retry;
227
- }
228
- /**
229
- * Constructs a completed SSE event from accumulated fields.
230
- *
231
- * Trims a trailing newline from multi-line `data` values so callers receive
232
- * the payload without an extra line break at the end.
233
- */
234
- completeEvent(event) {
235
- return {
236
- ...event,
237
- data: event.data?.replace(SSE_TRAILING_NEWLINE_REGEX, "")
238
- };
239
- }
240
- /**
241
- * Preserves incomplete trailing lines for the next received chunk.
242
- *
243
- * Only lines that were fully processed (through a completed event boundary)
244
- * are discarded; the remainder is re-encoded into {@link messageBuffer}.
245
- */
246
- storeRemainingLines(lines, processedLineCount) {
247
- this.#messageBuffer = lines.slice(processedLineCount).join(NEW_LINE);
248
- }
249
- };
250
-
251
66
  //#endregion
252
67
  //#region source/template/errors.ts
253
68
  /**
@@ -998,5 +813,5 @@ const parseTemplate = (inputTemplate) => {
998
813
  };
999
814
 
1000
815
  //#endregion
1001
- export { SSEEventParser, TemplateInvalidError, TemplateJsonMalformedError, TemplateSerializationFailedError, VIEW_PROPERTIES_DESCRIPTION_MAX_LENGTH, VIEW_PROPERTIES_ICON_MAX_LENGTH, VIEW_PROPERTIES_NAME_MAX_LENGTH, bchVmVersionSchema, buildErrorDescription, extendedJsonReplacer, extendedJsonReviver, generateTemplateIdentifier, parseTemplate, satoshisSchema, scriptToScriptHash, serializeTemplate, uint8ArraySchema, xoTemplateActionIntentSchema, xoTemplateActionRequirementsSchema, xoTemplateActionRoleRequirementsSchema, xoTemplateActionRoleSchema, xoTemplateActionSchema, xoTemplateAssetAmountsSchema, xoTemplateConstantSchema, xoTemplateDataSchema, xoTemplateDefaultsSchema, xoTemplateIconSchema, xoTemplateImportDefaultValueSchema, xoTemplateInputSchema, xoTemplateIntentSchema, xoTemplateLockingScriptIntentSchema, xoTemplateLockingScriptRoleSchema, xoTemplateLockingScriptSchema, xoTemplateLockingTypeSchema, xoTemplateNftCapabilitySchema, xoTemplateNonFungibleTokenDetailsSchema, xoTemplateOutputIntentSchema, xoTemplateOutputSchema, xoTemplatePrimitiveTypeSchema, xoTemplateResourceSchema, xoTemplateRoleSlotSchema, xoTemplateRoleSlotsRequirementsSchema, xoTemplateSchema, xoTemplateStateSchema, xoTemplateTokenSchema, xoTemplateTransactionInputSchema, xoTemplateTransactionOutputSchema, xoTemplateTransactionRoleDataSchema, xoTemplateTransactionSchema, xoTemplateVariableSchema, xoTemplateViewPropertiesSchema };
816
+ export { TemplateInvalidError, TemplateJsonMalformedError, TemplateSerializationFailedError, VIEW_PROPERTIES_DESCRIPTION_MAX_LENGTH, VIEW_PROPERTIES_ICON_MAX_LENGTH, VIEW_PROPERTIES_NAME_MAX_LENGTH, bchVmVersionSchema, buildErrorDescription, extendedJsonReplacer, extendedJsonReviver, generateTemplateIdentifier, parseTemplate, satoshisSchema, scriptToScriptHash, serializeTemplate, uint8ArraySchema, xoTemplateActionIntentSchema, xoTemplateActionRequirementsSchema, xoTemplateActionRoleRequirementsSchema, xoTemplateActionRoleSchema, xoTemplateActionSchema, xoTemplateAssetAmountsSchema, xoTemplateConstantSchema, xoTemplateDataSchema, xoTemplateDefaultsSchema, xoTemplateIconSchema, xoTemplateImportDefaultValueSchema, xoTemplateInputSchema, xoTemplateIntentSchema, xoTemplateLockingScriptIntentSchema, xoTemplateLockingScriptRoleSchema, xoTemplateLockingScriptSchema, xoTemplateLockingTypeSchema, xoTemplateNftCapabilitySchema, xoTemplateNonFungibleTokenDetailsSchema, xoTemplateOutputIntentSchema, xoTemplateOutputSchema, xoTemplatePrimitiveTypeSchema, xoTemplateResourceSchema, xoTemplateRoleSlotSchema, xoTemplateRoleSlotsRequirementsSchema, xoTemplateSchema, xoTemplateStateSchema, xoTemplateTokenSchema, xoTemplateTransactionInputSchema, xoTemplateTransactionOutputSchema, xoTemplateTransactionRoleDataSchema, xoTemplateTransactionSchema, xoTemplateVariableSchema, xoTemplateViewPropertiesSchema };
1002
817
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["#textDecoder","#messageBuffer"],"sources":["../source/extended-json.ts","../source/script.ts","../source/sse-session/constants.ts","../source/sse-session/sse-event-parser.ts","../source/template/errors.ts","../source/template/serialization.ts","../source/template/identifier.ts","../source/template/schemas.ts","../source/template/parser.ts"],"sourcesContent":["import { binToHex, hexToBin } from '@bitauth/libauth';\n\n/**\n * Matches a bigint encoded in Extended JSON format: `<bigint: 123n>`.\n */\nconst EXTENDED_JSON_BIGINT_PATTERN = /^<bigint: (?<bigint>[+-]?[0-9]+)n>$/u;\n\n/**\n * Matches a Uint8Array encoded in Extended JSON format: `<uint8array: abcd>`.\n */\nconst EXTENDED_JSON_UINT8ARRAY_PATTERN = /^<uint8array: (?<hex>[0-9a-f]*)>$/u;\n\n/**\n * The JSON replacer that encodes `bigint` and `Uint8Array` values in Extended JSON format,\n * compatible with the format expected by `extendedJsonReviver`.\n *\n * - BigInts are encoded as `<bigint: 123n>`.\n * - Uint8Arrays are encoded as `<uint8array: abcd>`.\n * All other values pass through unchanged and if any incompatible type is encountered, an error is thrown.\n *\n * Note: To use this function, pass it as the second argument to `JSON.stringify` when serializing data.\n *\n * Note to developers: Libauth's `stringify` is the replacer. It also serializes functions and symbols,\n * which we do not support. Passing it would let templates include those values, but revival would then fail.\n * This module provides a dedicated replacer and reviver so serialization and deserialization stay aligned.\n *\n * @param _propertyKey The property key being serialized, required by the `JSON.stringify` replacer but not used here.\n * @param value The value to encode or pass through unchanged.\n * @returns The encoded string\n */\nexport const extendedJsonReplacer = (_propertyKey: string, value: unknown): unknown => {\n if (value instanceof Uint8Array) {\n return `<uint8array: ${binToHex(value)}>`;\n }\n\n if (typeof value === 'bigint') {\n return `<bigint: ${value.toString()}n>`;\n }\n\n return value;\n};\n\n/**\n * The JSON reviver that reconstructs `bigint` and `Uint8Array` values encoded by `extendedJsonReplacer`.\n *\n * Note: To use this function, pass it as the second argument to `JSON.parse` when deserializing data.\n *\n * @param _propertyKey The property key being deserialized, required by the `JSON.parse` reviver but not used here.\n * @param value The value to reconstruct or pass through unchanged.\n * @returns The reconstructed value\n */\nexport const extendedJsonReviver = (_propertyKey: string, value: unknown): unknown => {\n // If the value is not a string, return the original value\n if (typeof value !== 'string') {\n return value;\n }\n\n // Match the bigint pattern\n const bigintPatternMatch = value.match(EXTENDED_JSON_BIGINT_PATTERN);\n\n // If the value matches the bigint pattern, return the reconstructed bigint\n if (bigintPatternMatch) {\n return BigInt(bigintPatternMatch.groups!.bigint);\n }\n\n // Match the Uint8Array pattern\n const uint8arrayPatternMatch = value.match(EXTENDED_JSON_UINT8ARRAY_PATTERN);\n\n // If the value matches the Uint8Array pattern, return the reconstructed Uint8Array\n if (uint8arrayPatternMatch) {\n return hexToBin(uint8arrayPatternMatch.groups!.hex);\n }\n\n // If the value does not match either pattern, return the original value\n return value;\n};\n","import { binToHex, sha256 } from '@bitauth/libauth';\n\n/**\n * Converts a script to a scriptHash.\n * @param {Uint8Array} script - The script to convert.\n * @returns {string} The scriptHash as a reversed hex string.\n */\nexport const scriptToScriptHash = (script: Uint8Array): string => {\n // Hash the script.\n const hash = sha256.hash(script);\n\n // Reverse the hash. (Electrum style, reverse switches to little endian representation)\n const reversed = hash.reverse();\n\n // Convert the reversed hash to hex.\n return binToHex(reversed);\n};\n","/**\n * Regex that splits decoded SSE text into lines.\n *\n * The SSE wire format is line-oriented (`field: value` per line). Servers may\n * send `\\r\\n` (HTTP default), `\\n` (Unix), or `\\r` (legacy Mac). Matching all\n * three keeps parsing correct regardless of platform or server implementation.\n */\nexport const SSE_LINE_ENDINGS = /\\r\\n|\\r|\\n/;\n\n/**\n * Regex that matches the single optional leading space in an SSE field value.\n *\n * Per the SSE spec, `field: value` may include one space immediately after the\n * colon; that space is not part of the value. Used with `.replace()` to strip\n * it when parsing lines such as `data: hello` → `hello`.\n */\nexport const SSE_FIELD_VALUE_REGEX = /^ /;\n\n/**\n * Regex that matches a trailing newline at the end of a string.\n *\n * Multiple `data:` lines in one event are joined with `\\n`. When the event is\n * completed, this removes any stray trailing newline so callers receive the\n * payload without an extra line break at the end.\n */\nexport const SSE_TRAILING_NEWLINE_REGEX = /\\n$/;\n\n/**\n * The newline character used when normalizing SSE text internally.\n *\n * Used to join consecutive `data:` lines into one payload and to reassemble\n * buffered partial lines between streamed chunks before the next parse call.\n */\nexport const NEW_LINE = '\\n';\n","import type { SSEvent } from './types.ts';\nimport { NEW_LINE, SSE_FIELD_VALUE_REGEX, SSE_LINE_ENDINGS, SSE_TRAILING_NEWLINE_REGEX } from './constants.ts';\n\n/**\n * Optional encoders used when decoding incoming SSE bytes and re-encoding\n * any buffered remainder between chunks.\n */\nexport interface SSEEventParserOptions {\n\n /** Decodes raw stream bytes into text. Defaults to a new `TextDecoder`. */\n textDecoder: TextDecoder;\n}\n\n/**\n * Incrementally parses Server-Sent Events (SSE) from streamed byte chunks.\n *\n * SSE payloads are line-oriented: each event is a sequence of `field: value`\n * lines terminated by a blank line. This parser accepts arbitrary chunk\n * boundaries from a live HTTP response body and emits only complete events.\n *\n * Typical usage is one parser instance per connection, calling {@link parseEvents}\n * for each chunk received from the stream:\n *\n * ```ts\n * const parser = new SSEEventParser();\n *\n * for await (const chunk of response.body) {\n * for (const event of parser.parseEvents(chunk)) {\n * // handle event.data, event.event, event.id, event.retry\n * }\n * }\n * ```\n *\n * Supported fields follow the SSE spec: `data`, `event`, `id`, and `retry`.\n * Multiple `data:` lines in one event are joined with `\\n`. An event is only\n * emitted once a blank line is seen and at least one `data` field was collected.\n */\nexport class SSEEventParser {\n readonly #textDecoder: TextDecoder;\n\n /** Bytes from a partial line or incomplete event, carried over to the next chunk. */\n #messageBuffer: string = '';\n\n /**\n * Creates a parser for one SSE stream.\n *\n * Inject custom encoders in tests or when a non-default character encoding\n * is required; production callers can rely on the defaults.\n *\n * @param options - Optional text encoders for decode/encode of stream bytes.\n */\n constructor(options: Partial<SSEEventParserOptions> = {}) {\n this.#textDecoder = options.textDecoder ?? new TextDecoder();\n }\n\n /**\n * Clears any buffered bytes from a partial line or incomplete event.\n *\n * Call when abandoning a transport so the next connection does not prepend\n * stale bytes to incoming chunks.\n */\n public reset(): void {\n // Clear the message buffer\n this.#messageBuffer = '';\n\n // Reset the decoder to clear any buffered bytes\n this.#textDecoder.decode();\n }\n\n /**\n * Parses all complete SSE events contained in a newly received chunk.\n *\n * The chunk is appended to any bytes buffered from earlier calls. Complete\n * events (blank-line delimited blocks with at least one `data` field) are\n * returned immediately; any trailing partial line or in-progress event stays\n * in the internal buffer until a later chunk completes it.\n *\n * @param chunk - Newly received SSE stream bytes.\n * @returns Zero or more complete parsed SSE events from this chunk.\n */\n public parseEvents(chunk: Uint8Array): SSEvent[] {\n const lines = this.getBufferedLines(chunk);\n\n const eventLines = lines.slice(0, -1);\n\n const events: SSEvent[] = [];\n let event: Partial<SSEvent> = {};\n let processedLineCount = 0;\n\n for (const [ index, line ] of eventLines.entries()) {\n // A blank line indicates the end of an event. If we have received data, we can complete the event\n if (line === '') {\n if (event.data !== undefined) {\n events.push(this.completeEvent(event));\n event = {};\n processedLineCount = index + 1;\n }\n\n continue;\n }\n\n this.parseLine(line, event);\n }\n\n this.storeRemainingLines(lines, processedLineCount);\n\n return events;\n }\n\n /**\n * Appends a new chunk to the buffered bytes and splits the combined payload\n * into lines.\n *\n * Accepts `\\r\\n`, `\\r`, and `\\n` line endings so events parse correctly\n * regardless of server or platform conventions.\n */\n private getBufferedLines(chunk: Uint8Array): string[] {\n this.#messageBuffer += this.#textDecoder.decode(chunk, { stream: true });\n\n return this.#messageBuffer.split(SSE_LINE_ENDINGS);\n }\n\n /**\n * Parses one SSE field line into an in-progress event.\n *\n * Lines without a colon are ignored. A single optional space after the colon\n * is stripped from the field value, per the SSE spec.\n */\n private parseLine(line: string, event: Partial<SSEvent>): void {\n const colonIndex = line.indexOf(':');\n if (colonIndex === -1) return;\n\n const field = line.slice(0, colonIndex);\n const value = line.slice(colonIndex + 1).replace(SSE_FIELD_VALUE_REGEX, '');\n\n switch (field) {\n case 'data':\n event.data = event.data ? `${event.data}${NEW_LINE}${value}` : value;\n\n return;\n\n case 'event':\n event.event = value;\n\n return;\n\n case 'id':\n event.id = value;\n\n return;\n\n case 'retry':\n this.parseRetry(value, event);\n\n return;\n }\n }\n\n /**\n * Applies a numeric `retry:` field to an in-progress event.\n *\n * Non-numeric values are ignored rather than failing the parse.\n */\n private parseRetry(value: string, event: Partial<SSEvent>): void {\n const retry = parseInt(value, 10);\n\n if (!isNaN(retry)) {\n event.retry = retry;\n }\n }\n\n /**\n * Constructs a completed SSE event from accumulated fields.\n *\n * Trims a trailing newline from multi-line `data` values so callers receive\n * the payload without an extra line break at the end.\n */\n private completeEvent(event: Partial<SSEvent>): SSEvent {\n return {\n ...event,\n data: event.data?.replace(SSE_TRAILING_NEWLINE_REGEX, ''),\n } as SSEvent;\n }\n\n /**\n * Preserves incomplete trailing lines for the next received chunk.\n *\n * Only lines that were fully processed (through a completed event boundary)\n * are discarded; the remainder is re-encoded into {@link messageBuffer}.\n */\n private storeRemainingLines(lines: string[], processedLineCount: number): void {\n this.#messageBuffer = lines.slice(processedLineCount).join(NEW_LINE);\n }\n}\n","/* eslint-disable max-classes-per-file */\n\nimport type { $ZodIssue } from 'zod/v4/core';\n\n/**\n * Formats the Zod validation failures into a single string with one line each: \"- <field>: <message>\" and top level failures\n * with no field path show as \"(root)\" for better readability.\n *\n * @param issues The Zod validation failures to format.\n * @returns A human readable error string for better debugging.\n */\nexport const buildErrorDescription = (issues: $ZodIssue[]): string => {\n // Initialize an empty array to store the formatted lines.\n const lines: string[] = [];\n\n // Iterate over the issues and format them into a string.\n for (const issue of issues) {\n // Get the issue path.\n const issuePath = issue.path.length > 0 ? issue.path.join('.') : '(root)';\n\n // The prefix that Zod adds to messages.\n const messagePrefix = 'Invalid input: ';\n\n // Remove the prefix for better readability.\n const issueMessage = issue.message.startsWith(messagePrefix) ? issue.message.slice(messagePrefix.length) : issue.message;\n\n // Add the formatted line to the array.\n lines.push(`- ${issuePath}: ${issueMessage}`);\n }\n\n // Return the formatted string.\n return `\\n${lines.join('\\n')}`;\n};\n\n/**\n * Thrown when the provided template does not satisfy the XOTemplate schema.\n */\nexport class TemplateInvalidError extends Error {\n constructor(details: string) {\n const message = `Template invalid: ${details}`;\n super(message);\n this.name = 'TemplateInvalidError';\n }\n}\n\n/**\n * Thrown when a string passed to `deserializeTemplate` cannot be parsed as JSON.\n */\nexport class TemplateJsonMalformedError extends Error {\n constructor(reason: string) {\n super(`Template JSON malformed, expected a valid JSON string: ${reason}`);\n this.name = 'TemplateJsonMalformedError';\n }\n}\n\n/**\n * Thrown when `serializeTemplate` fails to produce a JSON string from the template.\n */\nexport class TemplateSerializationFailedError extends Error {\n constructor(reason: string) {\n super(`Template serialization failed: ${reason}`);\n this.name = 'TemplateSerializationFailedError';\n }\n}\n","import type { XOTemplate } from '@xo-cash/types';\nimport { extendedJsonReplacer, extendedJsonReviver } from '../extended-json.ts';\nimport { TemplateJsonMalformedError, TemplateSerializationFailedError } from './errors.ts';\n\n/**\n * Serializes an XOTemplate to a JSON string. Encodes `bigint` and `Uint8Array` fields in\n * Extended JSON format so they can be reconstructed by `deserializeTemplate`.\n *\n * @param template The template to serialize.\n * @returns A JSON string representation of the template.\n * @throws {TemplateSerializationFailedError} If the template cannot be serialized to JSON.\n */\nexport const serializeTemplate = (template: XOTemplate): string => {\n try {\n // Serialize the template to a JSON string.\n return JSON.stringify(template, extendedJsonReplacer);\n } catch (serializationError) {\n const reason = serializationError instanceof Error ? serializationError.message : 'unknown error while serializing template';\n\n throw new TemplateSerializationFailedError(reason);\n }\n};\n\n/**\n * Deserializes a JSON string back into an XOTemplate object. Restores `bigint` and\n * `Uint8Array` fields encoded in Extended JSON format by `serializeTemplate`.\n *\n * @param serializedTemplate - A JSON string of an XOTemplate object.\n * @returns The reconstructed XOTemplate object.\n * @throws {TemplateJsonMalformedError} If the serialized template is not valid JSON.\n */\nexport const deserializeTemplate = (serializedTemplate: string): XOTemplate => {\n try {\n // Parse the serialized template using the extended JSON reviver.\n return JSON.parse(serializedTemplate, extendedJsonReviver);\n } catch (parsingError) {\n const reason = parsingError instanceof Error ? parsingError.message : 'unknown error while deserializing template';\n\n throw new TemplateJsonMalformedError(reason);\n }\n};\n","import { binToHex, sha256, utf8ToBin } from '@bitauth/libauth';\nimport type { XOTemplate } from '@xo-cash/types';\nimport { serializeTemplate } from './serialization.ts';\n\n/**\n * Generates a deterministic template identifier by hashing the template.\n *\n * Note: This expects a template that has been validated by `parseTemplate`.\n *\n * @param template - The template to generate an identifier for.\n * @returns The sha256 hex identifier for the template.\n */\nexport const generateTemplateIdentifier = (template: XOTemplate): string => {\n // Serialize the template.\n const serializedTemplate = serializeTemplate(template);\n\n // Hash the serialized template.\n const hash = sha256.hash(utf8ToBin(serializedTemplate));\n\n // Convert the hash to hex and return it.\n return binToHex(hash);\n};\n","/* eslint-disable @stylistic/newline-per-chained-call */\nimport { BchVmVersions, XOTemplateLockingTypes, XOTemplateNftCapabilities, XOTemplatePrimitiveTypes } from '@xo-cash/types';\nimport { z } from 'zod';\n\n// ============================================================\n// Enums\n// ============================================================\n\n/**\n * Validation schema for a BCH VM version identifier. Defines the set of known BCH VM versions\n * that XO templates declare support for.\n *\n * Uses `BchVmVersions` from `@xo-cash/types` so template validation stays aligned with the\n * `BchVmVersion` type.\n *\n * ```\n * {\n * \"supported\": [ \"BCH_2025_05\" ] ← each value\n * }\n * ```\n */\nexport const bchVmVersionSchema = z.enum(BchVmVersions);\n\n/**\n * Validation schema for the capability of a non-fungible token. Defines the three capability\n * types supported on BCH: minting tokens can create new NFTs, mutable tokens can update their\n * commitment, and none tokens cannot be changed after creation.\n *\n * ```\n * {\n * \"inputs|outputs\": {\n * \"[id]\": {\n * \"token\": {\n * \"nft\": {\n * \"capability\": \"minting\" ← this schema\n * }\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateNftCapabilitySchema = z.enum(XOTemplateNftCapabilities);\n\n/**\n * Validation schema for a BCH locking script type. Defines the standard locking script types\n * supported on BCH.\n *\n * ```\n * {\n * \"lockingScripts\": {\n * \"[id]\": {\n * \"lockingType\": \"p2pkh\" ← this schema\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateLockingTypeSchema = z.enum(XOTemplateLockingTypes);\n\n/**\n * Validation schema for a primitive type identifier. Defines the set of primitive types\n * that can be declared in an XO template. Used by constants, variables, and data fields.\n */\nexport const xoTemplatePrimitiveTypeSchema = z.enum(XOTemplatePrimitiveTypes);\n\n// ============================================================\n// Primitives\n// ============================================================\n\n/**\n * Validation schema for byte array fields i.e. Uint8Array instance.\n */\nexport const uint8ArraySchema = z.instanceof(Uint8Array).describe('A sequence of unsigned 8-bit integers expressed as a Uint8Array.');\n\n/**\n * Validation schema for the Satoshis type i.e. bigint.\n */\nexport const satoshisSchema = z.bigint().describe('A satoshi amount expressed as a bigint.');\n\n// ============================================================\n// Shared\n// ============================================================\n\n/** Maximum character length for name fields on view properties. */\nexport const VIEW_PROPERTIES_NAME_MAX_LENGTH = 1000;\n\n/** Maximum character length for description fields on view properties. */\nexport const VIEW_PROPERTIES_DESCRIPTION_MAX_LENGTH = 5000;\n\n/** Maximum character length for icon fields on view properties. */\nexport const VIEW_PROPERTIES_ICON_MAX_LENGTH = 1000;\n\n/**\n * Validation schema for view properties shared across many template elements i.e. name, description, icon.\n * Extended by most other schemas in this file.\n */\nexport const xoTemplateViewPropertiesSchema = z\n .object({\n name: z.string().max(VIEW_PROPERTIES_NAME_MAX_LENGTH).describe('A short human-readable label for this element.'),\n description: z\n .string()\n .max(VIEW_PROPERTIES_DESCRIPTION_MAX_LENGTH)\n .describe('A human-readable explanation of what this element does and when it is relevant.'),\n icon: z.string().max(VIEW_PROPERTIES_ICON_MAX_LENGTH).optional().describe('An optional icon identifier or URL for this element.'),\n })\n .strict();\n\n// ============================================================\n// Intents\n// ============================================================\n\n/**\n * Validation schema for the base intent structure. Describes the common data parameters shared\n * by all intent types regardless of what they target.\n *\n * An optional templateIdentifier allows the intent to reference a target defined in a different\n * template, enabling cross-template interaction.\n *\n * Extended by: xoTemplateActionIntentSchema, xoTemplateOutputIntentSchema,\n * xoTemplateLockingScriptIntentSchema.\n */\nexport const xoTemplateIntentSchema = z\n .object({\n templateIdentifier: z\n .string()\n .optional()\n .describe('Optional identifier for the template used in this intent. If not provided, uses the current template.'),\n role: z.string().optional().describe('Optional identifier for the role used in this intent.'),\n generate: z.array(z.string()).optional().describe('Identifiers for items to generate when this intent is resolved, e.g. keys or secrets.'),\n variables: z.array(z.record(z.string(), z.unknown())).optional().describe('Variable values to apply when this intent is resolved.'),\n constants: z.array(z.record(z.string(), z.unknown())).optional().describe('Constant values to apply when this intent is resolved.'),\n secrets: z.array(z.record(z.string(), z.unknown())).optional().describe('Secret values to apply when this intent is resolved.'),\n })\n .strict();\n\n/**\n * Validation schema for an action intent. Extends the base intent structure with an action\n * identifier. Used in locking script action lists and in the template's start array.\n *\n * ```\n * {\n * \"start\": [\n * { \"action\": \"...\" } ← this schema\n * ],\n * \"lockingScripts\": {\n * \"[id]\": {\n * \"actions\": [\n * { \"action\": \"...\" } ← this schema\n * ],\n * \"roles\": {\n * \"[roleId]\": {\n * \"actions\": [\n * { \"action\": \"...\" } ← this schema\n * ]\n * }\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateActionIntentSchema = xoTemplateIntentSchema\n .extend({\n action: z.string().describe('The identifier for the intended action.'),\n })\n .strict();\n\n/**\n * Validation schema for an output intent. Extends the base intent structure with an output\n * identifier. Used in the template's defaults block.\n *\n * ```\n * {\n * \"defaults\": {\n * \"change\": { \"output\": \"...\" } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateOutputIntentSchema = xoTemplateIntentSchema\n .extend({\n output: z.string().describe('The identifier for the intended output.'),\n })\n .strict();\n\n/**\n * Validation schema for a locking script intent. Extends the base intent structure with\n * a locking script identifier.\n *\n * @todo The location of this schema in the template JSON is not yet determined.\n */\nexport const xoTemplateLockingScriptIntentSchema = xoTemplateIntentSchema\n .extend({\n lockingScript: z.string().describe('The identifier for the intended locking script.'),\n })\n .strict();\n\n// ============================================================\n// Actions\n// ============================================================\n\n/**\n * Validation schema for the slot count configuration on a role requirement. Declares how many\n * participants of a given role are needed. min sets the lower bound and max sets the upper bound.\n * When max is absent, there is no upper limit.\n *\n * ```\n * {\n * \"actions\": {\n * \"[id]\": {\n * \"requirements\": {\n * \"participants\": [\n * { \"slots\": { \"min\": 1, \"max\": 1 } } ← this schema\n * ]\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateRoleSlotsRequirementsSchema = z\n .object({\n min: z.number().describe('Minimum number of participants required for this role.'),\n max: z.number().optional().describe('Maximum number of participants allowed for this role. Undefined means unlimited.'),\n })\n .strict();\n\n/**\n * Validation schema for the capability requirements declared on a role within an action.\n * Describes what data, secrets, or state the role is responsible for providing when participating in an action.\n *\n * ```\n * {\n * \"actions\": {\n * \"[id]\": {\n * \"roles\": {\n * \"[roleId]\": {\n * \"requirements\": { \"variables\": [], \"secrets\": [] } ← this schema\n * }\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateActionRoleRequirementsSchema = z\n .object({\n variables: z.array(z.string()).optional().describe('List of variable identifiers required for this role.'),\n secrets: z.array(z.string()).optional().describe('List of secret identifiers required for this role.'),\n })\n .strict();\n\n/**\n * Validation schema for a role-specific definition within an action.\n * All view properties are optional.\n *\n * ```\n * {\n * \"actions\": {\n * \"[id]\": {\n * \"roles\": {\n * \"[roleId]\": { } ← this schema\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateActionRoleSchema = xoTemplateViewPropertiesSchema\n .partial()\n .extend({\n generate: z\n .array(z.string())\n .optional()\n .describe('Identifiers for data items that should be generated for this role when participating in the action.'),\n\n // Describes under what conditions this role can proceed with the action. All values listed\n // under requirements must be populated for the action to work. This is a developer and\n // author concern. It is not present on intents because intents are used to populate the\n // action rather than to define it, and their fields are flattened accordingly.\n requirements: xoTemplateActionRoleRequirementsSchema.optional().describe('The requirements for this role within this action.'),\n })\n .strict();\n\n/**\n * Validation schema for a role participation requirement in an action's requirements block.\n *\n * ```\n * {\n * \"actions\": {\n * \"[id]\": {\n * \"requirements\": {\n * \"participants\": [\n * { \"role\": \"...\", \"slots\": { } } ← this schema\n * ]\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateRoleSlotSchema = z\n .object({\n role: z.string().describe('The role identifier that this requirement applies to.'),\n slots: xoTemplateRoleSlotsRequirementsSchema.describe('Slot configuration specifying how many participants of this role are required.'),\n })\n .strict();\n\n/**\n * Validation schema for the requirements of an action.\n *\n * ```\n * {\n * \"actions\": {\n * \"[id]\": {\n * \"requirements\": { \"variables\": [], \"participants\": [], \"secrets\": [] } ← this schema\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateActionRequirementsSchema = z\n .object({\n variables: z.array(z.string()).optional().describe('List of variable identifiers required for this action.'),\n participants: z.array(xoTemplateRoleSlotSchema).optional().describe('The participants required for this action.'),\n secrets: z.array(z.string()).optional().describe('The secrets required for this action.'),\n })\n .strict();\n\n/**\n * Validation schema for an action definition.\n *\n * ```\n * {\n * \"actions\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateActionSchema = xoTemplateViewPropertiesSchema\n .extend({\n roles: z.record(z.string(), xoTemplateActionRoleSchema).optional().describe('Specific context for each role participating in this action.'),\n requirements: xoTemplateActionRequirementsSchema.optional().describe('The requirements for this action.'),\n\n // This is a list of conditions that can influence how the action behaves.\n // This needs more work to be done.\n conditions: z.array(z.string()).optional().describe('Conditions that must be met for this action to be available.'),\n\n // A single transaction produced by the action.\n // In future this might be moved to a results block that can have multiple transactions.\n transaction: z\n .string()\n .optional()\n .describe(\"The identifier of the transaction this action produces, referencing an entry in the template's transactions.\"),\n\n // The data that is produced by the action.\n // In future this might be moved to a results block that can have multiple data fields.\n data: z.string().optional().describe(\"The identifier of the data field this action produces, referencing an entry in the template's data.\"),\n })\n .strict();\n\n// ============================================================\n// Tokens & Amounts\n// ============================================================\n\n/**\n * Validation schema for the non-fungible token configuration within a token field.\n *\n * ```\n * {\n * \"inputs|outputs\": {\n * \"[id]\": {\n * \"token\": {\n * \"nft\": { } ← this schema\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateNonFungibleTokenDetailsSchema = z\n .object({\n capability: z\n .union([ xoTemplateNftCapabilitySchema, z.string() ])\n .optional()\n .describe('The capability of the NFT. May be a known capability value or a CashASM expression resolving to a capability.'),\n commitment: z.string().optional().describe('The commitment data for the NFT, as a string or CashASM expression resolving to a commitment.'),\n })\n .strict();\n\n/**\n * Validation schema for the token configuration on inputs and outputs.\n *\n * ```\n * {\n * \"inputs|outputs\": {\n * \"[id]\": {\n * \"token\": { } ← this schema\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateTokenSchema = z\n .object({\n category: z.string().optional().describe('The category of the token, as a string or CashASM expression resolving to a category.'),\n amount: z\n .union([ z.bigint(), z.string(), z.null() ])\n .optional()\n .describe('The amount of fungible tokens as a bigint, a CashASM expression resolving to a bigint, or null indicating no FT is present.'),\n nft: xoTemplateNonFungibleTokenDetailsSchema\n .nullable()\n .optional()\n .describe('Non-fungible token configuration. Null indicates no NFT is present.'),\n })\n .strict();\n\n/**\n * Validation schema for the asset amounts configuration. Used by omitChangeAmounts on inputs\n * and by balance on locking scripts, outputs, and their roles.\n */\nexport const xoTemplateAssetAmountsSchema = z\n .object({\n\n /**\n * The satoshi amount.\n * - `Satoshis`: A specific bigint amount.\n * - `string`: A CashASM expression that resolves to the amount.\n * - `true`: all, i.e. the entire amount\n */\n satoshis: z\n .union([ satoshisSchema, z.string(), z.literal(true) ])\n .optional()\n .describe('The satoshi amount. Accepts a bigint for a specific value, a CashASM expression, or true for the entire amount.'),\n\n /**\n * The fungible token amount.\n * - `FungibleTokenAmount`: A specific bigint amount.\n * - `string`: A CashASM expression that resolves to the amount.\n * - `true`: all, i.e. the entire amount\n */\n fungibleTokens: z\n .union([ z.bigint(), z.string(), z.literal(true) ])\n .optional()\n .describe('The fungible token amount. Accepts a bigint for a specific value, a CashASM expression, or true for the entire amount.'),\n\n /**\n * Whether a non-fungible token is present (0 for absent, 1 for present),\n * or a CashASM expression that evaluates to 0 or 1.\n * - `true`: resolves to 1 if an NFT is present, or 0 if none is present. Use this when\n * the NFT is optional, to express that the NFT is estimated to be part of the balance\n * if present, or absent from it if not.\n * - `0`: None, i.e. nothing is expected to be included\n * - `1`: present and complete, as value > 1 does not make sense for non-fungible tokens\n * - `string`: A CashASM expression that evaluates to 0 or 1.\n */\n nonfungibleTokens: z\n .union([ z.literal(0), z.literal(1), z.string(), z.literal(true) ])\n .optional()\n .describe('Whether an NFT is present: 0 for absent, 1 for present, a CashASM expression evaluating to 0 or 1, or true to estimate the NFT as part of the balance if present, or absent from it if not.'),\n })\n .strict();\n\n// ============================================================\n// Locking Scripts\n// ============================================================\n\n/**\n * Validation schema for the state configuration shared by a locking script and its individual roles.\n * Declares which variables and secrets are tracked in the on-chain state for a given participant.\n *\n * ```\n * {\n * \"lockingScripts\": {\n * \"[id]\": {\n * \"state\": { \"variables\": [], \"secrets\": [] } ← this schema\n * \"roles\": {\n * \"[roleId]\": {\n * \"state\": { \"variables\": [], \"secrets\": [] } ← this schema\n * }\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateStateSchema = z\n .object({\n variables: z.array(z.string()).optional().describe('List of variable identifiers to track in state.'),\n secrets: z.array(z.string()).optional().describe('List of secret identifiers to track in state.'),\n })\n .strict();\n\n/**\n * Validation schema for a role definition for a locking script.\n *\n * ```\n * {\n * \"lockingScripts\": {\n * \"[id]\": {\n * \"roles\": {\n * \"[roleId]\": { } ← this schema\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateLockingScriptRoleSchema = xoTemplateViewPropertiesSchema\n .partial()\n .extend({\n state: xoTemplateStateSchema.optional().describe('List of items to track as state for this role.'),\n actions: z.array(xoTemplateActionIntentSchema).optional().describe('List of action references available to this role.'),\n balance: xoTemplateAssetAmountsSchema.partial().optional().describe('Estimated ownership in the optional set of asset amounts specified.'),\n selectable: z.boolean().optional().describe('Whether outputs locked to this script should be available for coin selection.'),\n privacy: z\n .union([ z.number(), z.string() ])\n .optional()\n .describe('Privacy level for outputs locked to this script. A numeric level or a CashASM expression that evaluates to a privacy level.'),\n })\n .strict();\n\n/**\n * Validation schema for a locking script definition.\n *\n * ```\n * {\n * \"lockingScripts\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateLockingScriptSchema = xoTemplateViewPropertiesSchema\n .extend({\n lockingType: xoTemplateLockingTypeSchema.optional().describe('The type of locking mechanism. Defaults to p2s if not specified.'),\n lockingBytecode: z.string().describe('The locking script bytecode.'),\n unlockingBytecode: z.string().optional().describe('Optional default unlocking bytecode when used in automatic coin selection.'),\n actions: z.array(xoTemplateActionIntentSchema).optional().describe('The actions available for this locking script.'),\n state: xoTemplateStateSchema.optional().describe('List of items to track as state for all participants.'),\n balance: xoTemplateAssetAmountsSchema.partial().optional().describe('Estimated ownership in the optional set of asset amounts specified.'),\n selectable: z.boolean().optional().describe('Whether outputs locked to this script should be available for coin selection.'),\n // Might be levels or tags\n privacy: z\n .union([ z.number(), z.string() ])\n .optional()\n .describe('Privacy level for outputs locked to this script. A numeric level or a CashASM expression that evaluates to a privacy level.'),\n roles: z\n .record(z.string(), xoTemplateLockingScriptRoleSchema)\n .optional()\n .describe('Specific context for each role participating in this locking script.'),\n })\n .strict();\n\n// ============================================================\n// Inputs\n// ============================================================\n\n/**\n * Validation schema for an input definition in the template. Extends view properties with optional\n * satoshi value, token configuration, and other transaction level fields.\n *\n * ```\n * {\n * \"inputs\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateInputSchema = xoTemplateViewPropertiesSchema\n .extend({\n valueSatoshis: z\n .union([ satoshisSchema, z.string() ])\n .optional()\n .describe('The amount of satoshis for this input as a bigint or a CashASM expression resolving to the amount.'),\n token: xoTemplateTokenSchema.nullable().optional().describe('Token configuration for this input.'),\n sequenceNumber: z\n .union([ z.number(), z.string() ])\n .optional()\n .describe('The sequence number of this input as a specific number or a CashASM expression.'),\n unlockingScript: z.string().optional().describe('Identifier of the unlocking script to use for the UTXO provided for this input.'),\n omitChangeAmounts: xoTemplateAssetAmountsSchema\n .optional()\n .describe('Amount of change that should be omitted from the automatic change handling. WARNING: Setting this can result in loss of funds!'),\n })\n .strict();\n\n// ============================================================\n// Outputs\n// ============================================================\n\n/**\n * Validation schema for an output definition. Extends the locking script schema so that\n * every output inherits the same locking script fields and adds output-specific fields.\n *\n * ```\n * {\n * \"outputs\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateOutputSchema = xoTemplateLockingScriptSchema\n .omit({ lockingType: true, lockingBytecode: true, unlockingBytecode: true })\n .extend({\n lockingScript: z.string().describe('Identifier of the locking script to use for this output.'),\n valueSatoshis: z\n .union([ satoshisSchema, z.string() ])\n .optional()\n .describe('The amount of satoshis for this output as a bigint or a CashASM expression resolving to the amount.'),\n token: xoTemplateTokenSchema.nullable().optional().describe('Token configuration for this output.'),\n })\n .strict();\n\n// ============================================================\n// Transactions\n// ============================================================\n\n/**\n * Validation schema for a transaction input reference for a transaction definition.\n *\n * ```\n * {\n * \"transactions\": {\n * \"[id]\": {\n * \"inputs\": [\n * { \"input\": \"...\" } ← this schema\n * ]\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateTransactionInputSchema = z\n .object({\n input: z.string().describe('The input definition identifier.'),\n inputIndex: z.number().optional().describe('Optional index of this input in the transaction.'),\n })\n .strict();\n\n/**\n * Validation schema for a transaction output reference for a transaction definition.\n *\n * ```\n * {\n * \"transactions\": {\n * \"[id]\": {\n * \"outputs\": [\n * { \"output\": \"...\" } ← this schema\n * ]\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateTransactionOutputSchema = z\n .object({\n output: z.string().describe('The output definition identifier.'),\n outputIndex: z.number().optional().describe('Optional index of this output in the transaction.'),\n })\n .strict();\n\n/**\n * Validation schema for role-specific data for a transaction definition.\n *\n * ```\n * {\n * \"transactions\": {\n * \"[id]\": {\n * \"roles\": {\n * \"[roleId]\": { } ← this schema\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateTransactionRoleDataSchema = xoTemplateViewPropertiesSchema\n .partial()\n .extend({\n inputs: z.array(xoTemplateTransactionInputSchema).optional().describe('The inputs required for this role.'),\n outputs: z.array(xoTemplateTransactionOutputSchema).optional().describe('The outputs required for this role.'),\n })\n .strict();\n\n/**\n * Validation schema for a transaction template definition.\n *\n * ```\n * {\n * \"transactions\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateTransactionSchema = xoTemplateViewPropertiesSchema\n .extend({\n version: z.number().optional().describe('The version of the transaction.'),\n locktime: z\n .union([ z.number(), z.string() ])\n .optional()\n .describe('The locktime for this transaction as a specific number or a CashASM expression.'),\n inputs: z.array(xoTemplateTransactionInputSchema).describe('The inputs for this transaction.'),\n outputs: z.array(xoTemplateTransactionOutputSchema).describe('The outputs for this transaction.'),\n roles: z\n .record(z.string(), xoTemplateTransactionRoleDataSchema)\n .optional()\n .describe('Specific context for each role participating in this transaction.'),\n composable: z.boolean().optional().describe('Whether this transaction can be composed with other transactions.'),\n })\n .strict();\n\n// ============================================================\n// Template Data\n// ============================================================\n\n/**\n * Validation schema for a constant value definition.\n *\n * ```\n * {\n * \"constants\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateConstantSchema = xoTemplateViewPropertiesSchema\n .extend({\n type: xoTemplatePrimitiveTypeSchema.describe('The data type of this constant.'),\n value: z.unknown().describe('The value of this constant.'),\n hint: z.string().optional().describe('An optional hint to help apps and users understand what this constant represents.'),\n })\n .strict();\n\n/**\n * Validation schema for a data field definition.\n *\n * ```\n * {\n * \"data\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateDataSchema = z\n .object({\n type: xoTemplatePrimitiveTypeSchema.describe('The data type of this data field.'),\n value: z.unknown().describe('The value for this data field.'),\n hint: z.string().optional().describe('An optional hint to help apps and users understand this data field.'),\n })\n .strict();\n\n/**\n * Validation schema for an import default value intent. Extends the base intent with optional\n * view properties that the engine evaluates at runtime to produce human-readable output.\n *\n * ```\n * {\n * \"variables\": {\n * \"[id]\": {\n * \"importDefaultValue\": { } ← this schema\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateImportDefaultValueSchema = xoTemplateIntentSchema\n // .shape unwraps the ZodObject to the raw field map { name, description, icon } with each field made optional\n .extend(xoTemplateViewPropertiesSchema.partial().shape)\n .strict();\n\n/**\n * Validation schema for a variable definition.\n *\n * ```\n * {\n * \"variables\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateVariableSchema = xoTemplateViewPropertiesSchema\n .extend({\n type: xoTemplatePrimitiveTypeSchema.optional().describe('The data type of this variable.'),\n hint: z.string().optional().describe('A hint to help users understand what value to provide.'),\n\n // A neutral intent that the engine uses to populate the default value for this variable.\n // View properties (name, description, icon) may contain CashASM expressions that the\n // engine evaluates at runtime to produce human-readable output. The engine overrides\n // whatever values are set here when resolving the variable for a participant.\n importDefaultValue: xoTemplateImportDefaultValueSchema\n .optional()\n .describe('A neutral intent that the engine uses to populate the default value for this variable.'),\n })\n .strict();\n\n// ============================================================\n// Template Resources\n// ============================================================\n\n/**\n * Validation schema for a resource reference attached to a template element. Extends view\n * properties with a URL pointing to external documentation or tooling.\n *\n * ```\n * {\n * \"resources\": [\n * { \"name\": \"...\", \"description\": \"...\", \"url\": \"...\" } ← this schema\n * ]\n * }\n * ```\n */\nexport const xoTemplateResourceSchema = xoTemplateViewPropertiesSchema\n .extend({\n url: z.string().describe('The URL for this resource.'),\n })\n .strict();\n\n/**\n * Validation schema for an icon reference.\n *\n * ```\n * {\n * \"icons\": [\n * { \"name\": \"...\", \"hash\": \"...\" } ← this schema\n * ]\n * }\n * ```\n */\nexport const xoTemplateIconSchema = xoTemplateViewPropertiesSchema\n .pick({ name: true })\n .extend({\n hash: z.string().describe('The identifier of the icon.'),\n })\n .strict();\n\n// ============================================================\n// Defaults\n// ============================================================\n\n/**\n * Validation schema for the defaults block of a template.\n *\n * ```\n * {\n * \"defaults\": { } ← this schema\n * }\n * ```\n */\nexport const xoTemplateDefaultsSchema = z\n .object({\n change: xoTemplateOutputIntentSchema.optional().describe('Instructions for how to construct automated change output.'),\n })\n .strict();\n\n// ============================================================\n// Template\n// ============================================================\n\n/**\n * Validation schema for the full XOTemplate type.\n */\nexport const xoTemplateSchema = xoTemplateViewPropertiesSchema\n .extend({\n $schema: z\n .string()\n .describe('The URI that identifies the JSON Schema used by this template. This enables documentation, autocompletion, and validation in JSON documents.'),\n version: z.string().optional().describe('A string identifying the version of this template.'),\n supported: z.array(bchVmVersionSchema).min(1).describe('The BCH VM versions that this template supports. At least one version is required.'),\n defaults: xoTemplateDefaultsSchema.optional().describe('Optional default settings used in this template.'),\n roles: z.record(z.string(), xoTemplateViewPropertiesSchema).describe('The roles defined in this template.'),\n start: z.array(xoTemplateActionIntentSchema).describe('A list of entry points defining which actions are available at the start.'),\n actions: z.record(z.string(), xoTemplateActionSchema).describe('The actions defined in this template.'),\n data: z.record(z.string(), xoTemplateDataSchema).optional().describe('The data fields defined in this template.'),\n transactions: z.record(z.string(), xoTemplateTransactionSchema).optional().describe('The transaction templates defined in this template.'),\n inputs: z.record(z.string(), xoTemplateInputSchema).describe('The inputs defined in this template.'),\n outputs: z.record(z.string(), xoTemplateOutputSchema).describe('The outputs defined in this template.'),\n lockingScripts: z.record(z.string(), xoTemplateLockingScriptSchema).describe('The locking script templates defined in this template.'),\n scripts: z\n .record(z.string(), z.string())\n .describe('Scripts used in this template. Keys are script identifiers, values are bytecode or CashASM expressions.'),\n constants: z.record(z.string(), xoTemplateConstantSchema).optional().describe('The constants defined in this template.'),\n variables: z\n .record(z.string(), xoTemplateVariableSchema)\n .optional()\n .describe(\"The variables that must be provided for use in the template's scripts.\"),\n resources: z.array(xoTemplateResourceSchema).optional().describe('Resource references providing external documentation or tooling links.'),\n icons: z.array(xoTemplateIconSchema).optional().describe('The icons available for use throughout the template.'),\n scenarios: z.unknown().optional().describe('The scenarios defined in this template.'),\n })\n .strict();\n","import type { XOTemplate } from '@xo-cash/types';\nimport { xoTemplateSchema } from './schemas.ts';\nimport { TemplateInvalidError, buildErrorDescription } from './errors.ts';\nimport { deserializeTemplate, serializeTemplate } from './serialization.ts';\n\n/**\n * Accepts a template value and returns a validated XOTemplate object. The input may be\n * either an Extended JSON string or a pre-parsed object. Both are validated\n * against the XOTemplate schema.\n *\n * @param inputTemplate - The value to validate. May be an Extended JSON string or a pre-parsed object.\n * @returns The validated template object\n * @throws {TemplateSerializationFailedError} If a pre-parsed object input cannot be serialized to JSON for normalization.\n * @throws {TemplateJsonMalformedError} If the string input is not valid JSON.\n * @throws {TemplateInvalidError} If the value does not conform to the XOTemplate schema.\n */\nexport const parseTemplate = (inputTemplate: string | XOTemplate): XOTemplate => {\n // Regardless of whether the inputTemplate is a string, an imported template or an in-memory object, serialize and then\n // deserialize it to ensure the output shape is consistent. For example, optional fields explicitly set to 'undefined' would be passed through\n // and then dropped on the string path, resulting in structurally different results for the same template.\n const serializedTemplate = typeof inputTemplate === 'string' ? inputTemplate : serializeTemplate(inputTemplate);\n const templateObject = deserializeTemplate(serializedTemplate);\n\n // Validate the template against the schema.\n const parseResult = xoTemplateSchema.safeParse(templateObject);\n\n if (parseResult.success) {\n // Return the validated template object\n return parseResult.data as XOTemplate;\n }\n\n // Build a human-readable description of every validation failure\n const errorDescription = buildErrorDescription(parseResult.error.issues);\n\n // Throw a typed error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Y,QAEZ,QAAO,YAAY;AAOvB,OAAM,IAAI,qBAHe,sBAAsB,YAAY,MAAM,OAAO,CAGxB"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../source/extended-json.ts","../source/script.ts","../source/template/errors.ts","../source/template/serialization.ts","../source/template/identifier.ts","../source/template/schemas.ts","../source/template/parser.ts"],"sourcesContent":["import { binToHex, hexToBin } from '@bitauth/libauth';\n\n/**\n * Matches a bigint encoded in Extended JSON format: `<bigint: 123n>`.\n */\nconst EXTENDED_JSON_BIGINT_PATTERN = /^<bigint: (?<bigint>[+-]?[0-9]+)n>$/u;\n\n/**\n * Matches a Uint8Array encoded in Extended JSON format: `<uint8array: abcd>`.\n */\nconst EXTENDED_JSON_UINT8ARRAY_PATTERN = /^<uint8array: (?<hex>[0-9a-f]*)>$/u;\n\n/**\n * The JSON replacer that encodes `bigint` and `Uint8Array` values in Extended JSON format,\n * compatible with the format expected by `extendedJsonReviver`.\n *\n * - BigInts are encoded as `<bigint: 123n>`.\n * - Uint8Arrays are encoded as `<uint8array: abcd>`.\n * All other values pass through unchanged and if any incompatible type is encountered, an error is thrown.\n *\n * Note: To use this function, pass it as the second argument to `JSON.stringify` when serializing data.\n *\n * Note to developers: Libauth's `stringify` is the replacer. It also serializes functions and symbols,\n * which we do not support. Passing it would let templates include those values, but revival would then fail.\n * This module provides a dedicated replacer and reviver so serialization and deserialization stay aligned.\n *\n * @param _propertyKey The property key being serialized, required by the `JSON.stringify` replacer but not used here.\n * @param value The value to encode or pass through unchanged.\n * @returns The encoded string\n */\nexport const extendedJsonReplacer = (_propertyKey: string, value: unknown): unknown => {\n if (value instanceof Uint8Array) {\n return `<uint8array: ${binToHex(value)}>`;\n }\n\n if (typeof value === 'bigint') {\n return `<bigint: ${value.toString()}n>`;\n }\n\n return value;\n};\n\n/**\n * The JSON reviver that reconstructs `bigint` and `Uint8Array` values encoded by `extendedJsonReplacer`.\n *\n * Note: To use this function, pass it as the second argument to `JSON.parse` when deserializing data.\n *\n * @param _propertyKey The property key being deserialized, required by the `JSON.parse` reviver but not used here.\n * @param value The value to reconstruct or pass through unchanged.\n * @returns The reconstructed value\n */\nexport const extendedJsonReviver = (_propertyKey: string, value: unknown): unknown => {\n // If the value is not a string, return the original value\n if (typeof value !== 'string') {\n return value;\n }\n\n // Match the bigint pattern\n const bigintPatternMatch = value.match(EXTENDED_JSON_BIGINT_PATTERN);\n\n // If the value matches the bigint pattern, return the reconstructed bigint\n if (bigintPatternMatch) {\n return BigInt(bigintPatternMatch.groups!.bigint);\n }\n\n // Match the Uint8Array pattern\n const uint8arrayPatternMatch = value.match(EXTENDED_JSON_UINT8ARRAY_PATTERN);\n\n // If the value matches the Uint8Array pattern, return the reconstructed Uint8Array\n if (uint8arrayPatternMatch) {\n return hexToBin(uint8arrayPatternMatch.groups!.hex);\n }\n\n // If the value does not match either pattern, return the original value\n return value;\n};\n","import { binToHex, sha256 } from '@bitauth/libauth';\n\n/**\n * Converts a script to a scriptHash.\n * @param {Uint8Array} script - The script to convert.\n * @returns {string} The scriptHash as a reversed hex string.\n */\nexport const scriptToScriptHash = (script: Uint8Array): string => {\n // Hash the script.\n const hash = sha256.hash(script);\n\n // Reverse the hash. (Electrum style, reverse switches to little endian representation)\n const reversed = hash.reverse();\n\n // Convert the reversed hash to hex.\n return binToHex(reversed);\n};\n","/* eslint-disable max-classes-per-file */\n\nimport type { $ZodIssue } from 'zod/v4/core';\n\n/**\n * Formats the Zod validation failures into a single string with one line each: \"- <field>: <message>\" and top level failures\n * with no field path show as \"(root)\" for better readability.\n *\n * @param issues The Zod validation failures to format.\n * @returns A human readable error string for better debugging.\n */\nexport const buildErrorDescription = (issues: $ZodIssue[]): string => {\n // Initialize an empty array to store the formatted lines.\n const lines: string[] = [];\n\n // Iterate over the issues and format them into a string.\n for (const issue of issues) {\n // Get the issue path.\n const issuePath = issue.path.length > 0 ? issue.path.join('.') : '(root)';\n\n // The prefix that Zod adds to messages.\n const messagePrefix = 'Invalid input: ';\n\n // Remove the prefix for better readability.\n const issueMessage = issue.message.startsWith(messagePrefix) ? issue.message.slice(messagePrefix.length) : issue.message;\n\n // Add the formatted line to the array.\n lines.push(`- ${issuePath}: ${issueMessage}`);\n }\n\n // Return the formatted string.\n return `\\n${lines.join('\\n')}`;\n};\n\n/**\n * Thrown when the provided template does not satisfy the XOTemplate schema.\n */\nexport class TemplateInvalidError extends Error {\n constructor(details: string) {\n const message = `Template invalid: ${details}`;\n super(message);\n this.name = 'TemplateInvalidError';\n }\n}\n\n/**\n * Thrown when a string passed to `deserializeTemplate` cannot be parsed as JSON.\n */\nexport class TemplateJsonMalformedError extends Error {\n constructor(reason: string) {\n super(`Template JSON malformed, expected a valid JSON string: ${reason}`);\n this.name = 'TemplateJsonMalformedError';\n }\n}\n\n/**\n * Thrown when `serializeTemplate` fails to produce a JSON string from the template.\n */\nexport class TemplateSerializationFailedError extends Error {\n constructor(reason: string) {\n super(`Template serialization failed: ${reason}`);\n this.name = 'TemplateSerializationFailedError';\n }\n}\n","import type { XOTemplate } from '@xo-cash/types';\nimport { extendedJsonReplacer, extendedJsonReviver } from '../extended-json.ts';\nimport { TemplateJsonMalformedError, TemplateSerializationFailedError } from './errors.ts';\n\n/**\n * Serializes an XOTemplate to a JSON string. Encodes `bigint` and `Uint8Array` fields in\n * Extended JSON format so they can be reconstructed by `deserializeTemplate`.\n *\n * @param template The template to serialize.\n * @returns A JSON string representation of the template.\n * @throws {TemplateSerializationFailedError} If the template cannot be serialized to JSON.\n */\nexport const serializeTemplate = (template: XOTemplate): string => {\n try {\n // Serialize the template to a JSON string.\n return JSON.stringify(template, extendedJsonReplacer);\n } catch (serializationError) {\n const reason = serializationError instanceof Error ? serializationError.message : 'unknown error while serializing template';\n\n throw new TemplateSerializationFailedError(reason);\n }\n};\n\n/**\n * Deserializes a JSON string back into an XOTemplate object. Restores `bigint` and\n * `Uint8Array` fields encoded in Extended JSON format by `serializeTemplate`.\n *\n * @param serializedTemplate - A JSON string of an XOTemplate object.\n * @returns The reconstructed XOTemplate object.\n * @throws {TemplateJsonMalformedError} If the serialized template is not valid JSON.\n */\nexport const deserializeTemplate = (serializedTemplate: string): XOTemplate => {\n try {\n // Parse the serialized template using the extended JSON reviver.\n return JSON.parse(serializedTemplate, extendedJsonReviver);\n } catch (parsingError) {\n const reason = parsingError instanceof Error ? parsingError.message : 'unknown error while deserializing template';\n\n throw new TemplateJsonMalformedError(reason);\n }\n};\n","import { binToHex, sha256, utf8ToBin } from '@bitauth/libauth';\nimport type { XOTemplate } from '@xo-cash/types';\nimport { serializeTemplate } from './serialization.ts';\n\n/**\n * Generates a deterministic template identifier by hashing the template.\n *\n * Note: This expects a template that has been validated by `parseTemplate`.\n *\n * @param template - The template to generate an identifier for.\n * @returns The sha256 hex identifier for the template.\n */\nexport const generateTemplateIdentifier = (template: XOTemplate): string => {\n // Serialize the template.\n const serializedTemplate = serializeTemplate(template);\n\n // Hash the serialized template.\n const hash = sha256.hash(utf8ToBin(serializedTemplate));\n\n // Convert the hash to hex and return it.\n return binToHex(hash);\n};\n","/* eslint-disable @stylistic/newline-per-chained-call */\nimport { BchVmVersions, XOTemplateLockingTypes, XOTemplateNftCapabilities, XOTemplatePrimitiveTypes } from '@xo-cash/types';\nimport { z } from 'zod';\n\n// ============================================================\n// Enums\n// ============================================================\n\n/**\n * Validation schema for a BCH VM version identifier. Defines the set of known BCH VM versions\n * that XO templates declare support for.\n *\n * Uses `BchVmVersions` from `@xo-cash/types` so template validation stays aligned with the\n * `BchVmVersion` type.\n *\n * ```\n * {\n * \"supported\": [ \"BCH_2025_05\" ] ← each value\n * }\n * ```\n */\nexport const bchVmVersionSchema = z.enum(BchVmVersions);\n\n/**\n * Validation schema for the capability of a non-fungible token. Defines the three capability\n * types supported on BCH: minting tokens can create new NFTs, mutable tokens can update their\n * commitment, and none tokens cannot be changed after creation.\n *\n * ```\n * {\n * \"inputs|outputs\": {\n * \"[id]\": {\n * \"token\": {\n * \"nft\": {\n * \"capability\": \"minting\" ← this schema\n * }\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateNftCapabilitySchema = z.enum(XOTemplateNftCapabilities);\n\n/**\n * Validation schema for a BCH locking script type. Defines the standard locking script types\n * supported on BCH.\n *\n * ```\n * {\n * \"lockingScripts\": {\n * \"[id]\": {\n * \"lockingType\": \"p2pkh\" ← this schema\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateLockingTypeSchema = z.enum(XOTemplateLockingTypes);\n\n/**\n * Validation schema for a primitive type identifier. Defines the set of primitive types\n * that can be declared in an XO template. Used by constants, variables, and data fields.\n */\nexport const xoTemplatePrimitiveTypeSchema = z.enum(XOTemplatePrimitiveTypes);\n\n// ============================================================\n// Primitives\n// ============================================================\n\n/**\n * Validation schema for byte array fields i.e. Uint8Array instance.\n */\nexport const uint8ArraySchema = z.instanceof(Uint8Array).describe('A sequence of unsigned 8-bit integers expressed as a Uint8Array.');\n\n/**\n * Validation schema for the Satoshis type i.e. bigint.\n */\nexport const satoshisSchema = z.bigint().describe('A satoshi amount expressed as a bigint.');\n\n// ============================================================\n// Shared\n// ============================================================\n\n/** Maximum character length for name fields on view properties. */\nexport const VIEW_PROPERTIES_NAME_MAX_LENGTH = 1000;\n\n/** Maximum character length for description fields on view properties. */\nexport const VIEW_PROPERTIES_DESCRIPTION_MAX_LENGTH = 5000;\n\n/** Maximum character length for icon fields on view properties. */\nexport const VIEW_PROPERTIES_ICON_MAX_LENGTH = 1000;\n\n/**\n * Validation schema for view properties shared across many template elements i.e. name, description, icon.\n * Extended by most other schemas in this file.\n */\nexport const xoTemplateViewPropertiesSchema = z\n .object({\n name: z.string().max(VIEW_PROPERTIES_NAME_MAX_LENGTH).describe('A short human-readable label for this element.'),\n description: z\n .string()\n .max(VIEW_PROPERTIES_DESCRIPTION_MAX_LENGTH)\n .describe('A human-readable explanation of what this element does and when it is relevant.'),\n icon: z.string().max(VIEW_PROPERTIES_ICON_MAX_LENGTH).optional().describe('An optional icon identifier or URL for this element.'),\n })\n .strict();\n\n// ============================================================\n// Intents\n// ============================================================\n\n/**\n * Validation schema for the base intent structure. Describes the common data parameters shared\n * by all intent types regardless of what they target.\n *\n * An optional templateIdentifier allows the intent to reference a target defined in a different\n * template, enabling cross-template interaction.\n *\n * Extended by: xoTemplateActionIntentSchema, xoTemplateOutputIntentSchema,\n * xoTemplateLockingScriptIntentSchema.\n */\nexport const xoTemplateIntentSchema = z\n .object({\n templateIdentifier: z\n .string()\n .optional()\n .describe('Optional identifier for the template used in this intent. If not provided, uses the current template.'),\n role: z.string().optional().describe('Optional identifier for the role used in this intent.'),\n generate: z.array(z.string()).optional().describe('Identifiers for items to generate when this intent is resolved, e.g. keys or secrets.'),\n variables: z.array(z.record(z.string(), z.unknown())).optional().describe('Variable values to apply when this intent is resolved.'),\n constants: z.array(z.record(z.string(), z.unknown())).optional().describe('Constant values to apply when this intent is resolved.'),\n secrets: z.array(z.record(z.string(), z.unknown())).optional().describe('Secret values to apply when this intent is resolved.'),\n })\n .strict();\n\n/**\n * Validation schema for an action intent. Extends the base intent structure with an action\n * identifier. Used in locking script action lists and in the template's start array.\n *\n * ```\n * {\n * \"start\": [\n * { \"action\": \"...\" } ← this schema\n * ],\n * \"lockingScripts\": {\n * \"[id]\": {\n * \"actions\": [\n * { \"action\": \"...\" } ← this schema\n * ],\n * \"roles\": {\n * \"[roleId]\": {\n * \"actions\": [\n * { \"action\": \"...\" } ← this schema\n * ]\n * }\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateActionIntentSchema = xoTemplateIntentSchema\n .extend({\n action: z.string().describe('The identifier for the intended action.'),\n })\n .strict();\n\n/**\n * Validation schema for an output intent. Extends the base intent structure with an output\n * identifier. Used in the template's defaults block.\n *\n * ```\n * {\n * \"defaults\": {\n * \"change\": { \"output\": \"...\" } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateOutputIntentSchema = xoTemplateIntentSchema\n .extend({\n output: z.string().describe('The identifier for the intended output.'),\n })\n .strict();\n\n/**\n * Validation schema for a locking script intent. Extends the base intent structure with\n * a locking script identifier.\n *\n * @todo The location of this schema in the template JSON is not yet determined.\n */\nexport const xoTemplateLockingScriptIntentSchema = xoTemplateIntentSchema\n .extend({\n lockingScript: z.string().describe('The identifier for the intended locking script.'),\n })\n .strict();\n\n// ============================================================\n// Actions\n// ============================================================\n\n/**\n * Validation schema for the slot count configuration on a role requirement. Declares how many\n * participants of a given role are needed. min sets the lower bound and max sets the upper bound.\n * When max is absent, there is no upper limit.\n *\n * ```\n * {\n * \"actions\": {\n * \"[id]\": {\n * \"requirements\": {\n * \"participants\": [\n * { \"slots\": { \"min\": 1, \"max\": 1 } } ← this schema\n * ]\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateRoleSlotsRequirementsSchema = z\n .object({\n min: z.number().describe('Minimum number of participants required for this role.'),\n max: z.number().optional().describe('Maximum number of participants allowed for this role. Undefined means unlimited.'),\n })\n .strict();\n\n/**\n * Validation schema for the capability requirements declared on a role within an action.\n * Describes what data, secrets, or state the role is responsible for providing when participating in an action.\n *\n * ```\n * {\n * \"actions\": {\n * \"[id]\": {\n * \"roles\": {\n * \"[roleId]\": {\n * \"requirements\": { \"variables\": [], \"secrets\": [] } ← this schema\n * }\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateActionRoleRequirementsSchema = z\n .object({\n variables: z.array(z.string()).optional().describe('List of variable identifiers required for this role.'),\n secrets: z.array(z.string()).optional().describe('List of secret identifiers required for this role.'),\n })\n .strict();\n\n/**\n * Validation schema for a role-specific definition within an action.\n * All view properties are optional.\n *\n * ```\n * {\n * \"actions\": {\n * \"[id]\": {\n * \"roles\": {\n * \"[roleId]\": { } ← this schema\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateActionRoleSchema = xoTemplateViewPropertiesSchema\n .partial()\n .extend({\n generate: z\n .array(z.string())\n .optional()\n .describe('Identifiers for data items that should be generated for this role when participating in the action.'),\n\n // Describes under what conditions this role can proceed with the action. All values listed\n // under requirements must be populated for the action to work. This is a developer and\n // author concern. It is not present on intents because intents are used to populate the\n // action rather than to define it, and their fields are flattened accordingly.\n requirements: xoTemplateActionRoleRequirementsSchema.optional().describe('The requirements for this role within this action.'),\n })\n .strict();\n\n/**\n * Validation schema for a role participation requirement in an action's requirements block.\n *\n * ```\n * {\n * \"actions\": {\n * \"[id]\": {\n * \"requirements\": {\n * \"participants\": [\n * { \"role\": \"...\", \"slots\": { } } ← this schema\n * ]\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateRoleSlotSchema = z\n .object({\n role: z.string().describe('The role identifier that this requirement applies to.'),\n slots: xoTemplateRoleSlotsRequirementsSchema.describe('Slot configuration specifying how many participants of this role are required.'),\n })\n .strict();\n\n/**\n * Validation schema for the requirements of an action.\n *\n * ```\n * {\n * \"actions\": {\n * \"[id]\": {\n * \"requirements\": { \"variables\": [], \"participants\": [], \"secrets\": [] } ← this schema\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateActionRequirementsSchema = z\n .object({\n variables: z.array(z.string()).optional().describe('List of variable identifiers required for this action.'),\n participants: z.array(xoTemplateRoleSlotSchema).optional().describe('The participants required for this action.'),\n secrets: z.array(z.string()).optional().describe('The secrets required for this action.'),\n })\n .strict();\n\n/**\n * Validation schema for an action definition.\n *\n * ```\n * {\n * \"actions\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateActionSchema = xoTemplateViewPropertiesSchema\n .extend({\n roles: z.record(z.string(), xoTemplateActionRoleSchema).optional().describe('Specific context for each role participating in this action.'),\n requirements: xoTemplateActionRequirementsSchema.optional().describe('The requirements for this action.'),\n\n // This is a list of conditions that can influence how the action behaves.\n // This needs more work to be done.\n conditions: z.array(z.string()).optional().describe('Conditions that must be met for this action to be available.'),\n\n // A single transaction produced by the action.\n // In future this might be moved to a results block that can have multiple transactions.\n transaction: z\n .string()\n .optional()\n .describe(\"The identifier of the transaction this action produces, referencing an entry in the template's transactions.\"),\n\n // The data that is produced by the action.\n // In future this might be moved to a results block that can have multiple data fields.\n data: z.string().optional().describe(\"The identifier of the data field this action produces, referencing an entry in the template's data.\"),\n })\n .strict();\n\n// ============================================================\n// Tokens & Amounts\n// ============================================================\n\n/**\n * Validation schema for the non-fungible token configuration within a token field.\n *\n * ```\n * {\n * \"inputs|outputs\": {\n * \"[id]\": {\n * \"token\": {\n * \"nft\": { } ← this schema\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateNonFungibleTokenDetailsSchema = z\n .object({\n capability: z\n .union([ xoTemplateNftCapabilitySchema, z.string() ])\n .optional()\n .describe('The capability of the NFT. May be a known capability value or a CashASM expression resolving to a capability.'),\n commitment: z.string().optional().describe('The commitment data for the NFT, as a string or CashASM expression resolving to a commitment.'),\n })\n .strict();\n\n/**\n * Validation schema for the token configuration on inputs and outputs.\n *\n * ```\n * {\n * \"inputs|outputs\": {\n * \"[id]\": {\n * \"token\": { } ← this schema\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateTokenSchema = z\n .object({\n category: z.string().optional().describe('The category of the token, as a string or CashASM expression resolving to a category.'),\n amount: z\n .union([ z.bigint(), z.string(), z.null() ])\n .optional()\n .describe('The amount of fungible tokens as a bigint, a CashASM expression resolving to a bigint, or null indicating no FT is present.'),\n nft: xoTemplateNonFungibleTokenDetailsSchema\n .nullable()\n .optional()\n .describe('Non-fungible token configuration. Null indicates no NFT is present.'),\n })\n .strict();\n\n/**\n * Validation schema for the asset amounts configuration. Used by omitChangeAmounts on inputs\n * and by balance on locking scripts, outputs, and their roles.\n */\nexport const xoTemplateAssetAmountsSchema = z\n .object({\n\n /**\n * The satoshi amount.\n * - `Satoshis`: A specific bigint amount.\n * - `string`: A CashASM expression that resolves to the amount.\n * - `true`: all, i.e. the entire amount\n */\n satoshis: z\n .union([ satoshisSchema, z.string(), z.literal(true) ])\n .optional()\n .describe('The satoshi amount. Accepts a bigint for a specific value, a CashASM expression, or true for the entire amount.'),\n\n /**\n * The fungible token amount.\n * - `FungibleTokenAmount`: A specific bigint amount.\n * - `string`: A CashASM expression that resolves to the amount.\n * - `true`: all, i.e. the entire amount\n */\n fungibleTokens: z\n .union([ z.bigint(), z.string(), z.literal(true) ])\n .optional()\n .describe('The fungible token amount. Accepts a bigint for a specific value, a CashASM expression, or true for the entire amount.'),\n\n /**\n * Whether a non-fungible token is present (0 for absent, 1 for present),\n * or a CashASM expression that evaluates to 0 or 1.\n * - `true`: resolves to 1 if an NFT is present, or 0 if none is present. Use this when\n * the NFT is optional, to express that the NFT is estimated to be part of the balance\n * if present, or absent from it if not.\n * - `0`: None, i.e. nothing is expected to be included\n * - `1`: present and complete, as value > 1 does not make sense for non-fungible tokens\n * - `string`: A CashASM expression that evaluates to 0 or 1.\n */\n nonfungibleTokens: z\n .union([ z.literal(0), z.literal(1), z.string(), z.literal(true) ])\n .optional()\n .describe('Whether an NFT is present: 0 for absent, 1 for present, a CashASM expression evaluating to 0 or 1, or true to estimate the NFT as part of the balance if present, or absent from it if not.'),\n })\n .strict();\n\n// ============================================================\n// Locking Scripts\n// ============================================================\n\n/**\n * Validation schema for the state configuration shared by a locking script and its individual roles.\n * Declares which variables and secrets are tracked in the on-chain state for a given participant.\n *\n * ```\n * {\n * \"lockingScripts\": {\n * \"[id]\": {\n * \"state\": { \"variables\": [], \"secrets\": [] } ← this schema\n * \"roles\": {\n * \"[roleId]\": {\n * \"state\": { \"variables\": [], \"secrets\": [] } ← this schema\n * }\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateStateSchema = z\n .object({\n variables: z.array(z.string()).optional().describe('List of variable identifiers to track in state.'),\n secrets: z.array(z.string()).optional().describe('List of secret identifiers to track in state.'),\n })\n .strict();\n\n/**\n * Validation schema for a role definition for a locking script.\n *\n * ```\n * {\n * \"lockingScripts\": {\n * \"[id]\": {\n * \"roles\": {\n * \"[roleId]\": { } ← this schema\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateLockingScriptRoleSchema = xoTemplateViewPropertiesSchema\n .partial()\n .extend({\n state: xoTemplateStateSchema.optional().describe('List of items to track as state for this role.'),\n actions: z.array(xoTemplateActionIntentSchema).optional().describe('List of action references available to this role.'),\n balance: xoTemplateAssetAmountsSchema.partial().optional().describe('Estimated ownership in the optional set of asset amounts specified.'),\n selectable: z.boolean().optional().describe('Whether outputs locked to this script should be available for coin selection.'),\n privacy: z\n .union([ z.number(), z.string() ])\n .optional()\n .describe('Privacy level for outputs locked to this script. A numeric level or a CashASM expression that evaluates to a privacy level.'),\n })\n .strict();\n\n/**\n * Validation schema for a locking script definition.\n *\n * ```\n * {\n * \"lockingScripts\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateLockingScriptSchema = xoTemplateViewPropertiesSchema\n .extend({\n lockingType: xoTemplateLockingTypeSchema.optional().describe('The type of locking mechanism. Defaults to p2s if not specified.'),\n lockingBytecode: z.string().describe('The locking script bytecode.'),\n unlockingBytecode: z.string().optional().describe('Optional default unlocking bytecode when used in automatic coin selection.'),\n actions: z.array(xoTemplateActionIntentSchema).optional().describe('The actions available for this locking script.'),\n state: xoTemplateStateSchema.optional().describe('List of items to track as state for all participants.'),\n balance: xoTemplateAssetAmountsSchema.partial().optional().describe('Estimated ownership in the optional set of asset amounts specified.'),\n selectable: z.boolean().optional().describe('Whether outputs locked to this script should be available for coin selection.'),\n // Might be levels or tags\n privacy: z\n .union([ z.number(), z.string() ])\n .optional()\n .describe('Privacy level for outputs locked to this script. A numeric level or a CashASM expression that evaluates to a privacy level.'),\n roles: z\n .record(z.string(), xoTemplateLockingScriptRoleSchema)\n .optional()\n .describe('Specific context for each role participating in this locking script.'),\n })\n .strict();\n\n// ============================================================\n// Inputs\n// ============================================================\n\n/**\n * Validation schema for an input definition in the template. Extends view properties with optional\n * satoshi value, token configuration, and other transaction level fields.\n *\n * ```\n * {\n * \"inputs\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateInputSchema = xoTemplateViewPropertiesSchema\n .extend({\n valueSatoshis: z\n .union([ satoshisSchema, z.string() ])\n .optional()\n .describe('The amount of satoshis for this input as a bigint or a CashASM expression resolving to the amount.'),\n token: xoTemplateTokenSchema.nullable().optional().describe('Token configuration for this input.'),\n sequenceNumber: z\n .union([ z.number(), z.string() ])\n .optional()\n .describe('The sequence number of this input as a specific number or a CashASM expression.'),\n unlockingScript: z.string().optional().describe('Identifier of the unlocking script to use for the UTXO provided for this input.'),\n omitChangeAmounts: xoTemplateAssetAmountsSchema\n .optional()\n .describe('Amount of change that should be omitted from the automatic change handling. WARNING: Setting this can result in loss of funds!'),\n })\n .strict();\n\n// ============================================================\n// Outputs\n// ============================================================\n\n/**\n * Validation schema for an output definition. Extends the locking script schema so that\n * every output inherits the same locking script fields and adds output-specific fields.\n *\n * ```\n * {\n * \"outputs\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateOutputSchema = xoTemplateLockingScriptSchema\n .omit({ lockingType: true, lockingBytecode: true, unlockingBytecode: true })\n .extend({\n lockingScript: z.string().describe('Identifier of the locking script to use for this output.'),\n valueSatoshis: z\n .union([ satoshisSchema, z.string() ])\n .optional()\n .describe('The amount of satoshis for this output as a bigint or a CashASM expression resolving to the amount.'),\n token: xoTemplateTokenSchema.nullable().optional().describe('Token configuration for this output.'),\n })\n .strict();\n\n// ============================================================\n// Transactions\n// ============================================================\n\n/**\n * Validation schema for a transaction input reference for a transaction definition.\n *\n * ```\n * {\n * \"transactions\": {\n * \"[id]\": {\n * \"inputs\": [\n * { \"input\": \"...\" } ← this schema\n * ]\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateTransactionInputSchema = z\n .object({\n input: z.string().describe('The input definition identifier.'),\n inputIndex: z.number().optional().describe('Optional index of this input in the transaction.'),\n })\n .strict();\n\n/**\n * Validation schema for a transaction output reference for a transaction definition.\n *\n * ```\n * {\n * \"transactions\": {\n * \"[id]\": {\n * \"outputs\": [\n * { \"output\": \"...\" } ← this schema\n * ]\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateTransactionOutputSchema = z\n .object({\n output: z.string().describe('The output definition identifier.'),\n outputIndex: z.number().optional().describe('Optional index of this output in the transaction.'),\n })\n .strict();\n\n/**\n * Validation schema for role-specific data for a transaction definition.\n *\n * ```\n * {\n * \"transactions\": {\n * \"[id]\": {\n * \"roles\": {\n * \"[roleId]\": { } ← this schema\n * }\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateTransactionRoleDataSchema = xoTemplateViewPropertiesSchema\n .partial()\n .extend({\n inputs: z.array(xoTemplateTransactionInputSchema).optional().describe('The inputs required for this role.'),\n outputs: z.array(xoTemplateTransactionOutputSchema).optional().describe('The outputs required for this role.'),\n })\n .strict();\n\n/**\n * Validation schema for a transaction template definition.\n *\n * ```\n * {\n * \"transactions\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateTransactionSchema = xoTemplateViewPropertiesSchema\n .extend({\n version: z.number().optional().describe('The version of the transaction.'),\n locktime: z\n .union([ z.number(), z.string() ])\n .optional()\n .describe('The locktime for this transaction as a specific number or a CashASM expression.'),\n inputs: z.array(xoTemplateTransactionInputSchema).describe('The inputs for this transaction.'),\n outputs: z.array(xoTemplateTransactionOutputSchema).describe('The outputs for this transaction.'),\n roles: z\n .record(z.string(), xoTemplateTransactionRoleDataSchema)\n .optional()\n .describe('Specific context for each role participating in this transaction.'),\n composable: z.boolean().optional().describe('Whether this transaction can be composed with other transactions.'),\n })\n .strict();\n\n// ============================================================\n// Template Data\n// ============================================================\n\n/**\n * Validation schema for a constant value definition.\n *\n * ```\n * {\n * \"constants\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateConstantSchema = xoTemplateViewPropertiesSchema\n .extend({\n type: xoTemplatePrimitiveTypeSchema.describe('The data type of this constant.'),\n value: z.unknown().describe('The value of this constant.'),\n hint: z.string().optional().describe('An optional hint to help apps and users understand what this constant represents.'),\n })\n .strict();\n\n/**\n * Validation schema for a data field definition.\n *\n * ```\n * {\n * \"data\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateDataSchema = z\n .object({\n type: xoTemplatePrimitiveTypeSchema.describe('The data type of this data field.'),\n value: z.unknown().describe('The value for this data field.'),\n hint: z.string().optional().describe('An optional hint to help apps and users understand this data field.'),\n })\n .strict();\n\n/**\n * Validation schema for an import default value intent. Extends the base intent with optional\n * view properties that the engine evaluates at runtime to produce human-readable output.\n *\n * ```\n * {\n * \"variables\": {\n * \"[id]\": {\n * \"importDefaultValue\": { } ← this schema\n * }\n * }\n * }\n * ```\n */\nexport const xoTemplateImportDefaultValueSchema = xoTemplateIntentSchema\n // .shape unwraps the ZodObject to the raw field map { name, description, icon } with each field made optional\n .extend(xoTemplateViewPropertiesSchema.partial().shape)\n .strict();\n\n/**\n * Validation schema for a variable definition.\n *\n * ```\n * {\n * \"variables\": {\n * \"[id]\": { } ← this schema\n * }\n * }\n * ```\n */\nexport const xoTemplateVariableSchema = xoTemplateViewPropertiesSchema\n .extend({\n type: xoTemplatePrimitiveTypeSchema.optional().describe('The data type of this variable.'),\n hint: z.string().optional().describe('A hint to help users understand what value to provide.'),\n\n // A neutral intent that the engine uses to populate the default value for this variable.\n // View properties (name, description, icon) may contain CashASM expressions that the\n // engine evaluates at runtime to produce human-readable output. The engine overrides\n // whatever values are set here when resolving the variable for a participant.\n importDefaultValue: xoTemplateImportDefaultValueSchema\n .optional()\n .describe('A neutral intent that the engine uses to populate the default value for this variable.'),\n })\n .strict();\n\n// ============================================================\n// Template Resources\n// ============================================================\n\n/**\n * Validation schema for a resource reference attached to a template element. Extends view\n * properties with a URL pointing to external documentation or tooling.\n *\n * ```\n * {\n * \"resources\": [\n * { \"name\": \"...\", \"description\": \"...\", \"url\": \"...\" } ← this schema\n * ]\n * }\n * ```\n */\nexport const xoTemplateResourceSchema = xoTemplateViewPropertiesSchema\n .extend({\n url: z.string().describe('The URL for this resource.'),\n })\n .strict();\n\n/**\n * Validation schema for an icon reference.\n *\n * ```\n * {\n * \"icons\": [\n * { \"name\": \"...\", \"hash\": \"...\" } ← this schema\n * ]\n * }\n * ```\n */\nexport const xoTemplateIconSchema = xoTemplateViewPropertiesSchema\n .pick({ name: true })\n .extend({\n hash: z.string().describe('The identifier of the icon.'),\n })\n .strict();\n\n// ============================================================\n// Defaults\n// ============================================================\n\n/**\n * Validation schema for the defaults block of a template.\n *\n * ```\n * {\n * \"defaults\": { } ← this schema\n * }\n * ```\n */\nexport const xoTemplateDefaultsSchema = z\n .object({\n change: xoTemplateOutputIntentSchema.optional().describe('Instructions for how to construct automated change output.'),\n })\n .strict();\n\n// ============================================================\n// Template\n// ============================================================\n\n/**\n * Validation schema for the full XOTemplate type.\n */\nexport const xoTemplateSchema = xoTemplateViewPropertiesSchema\n .extend({\n $schema: z\n .string()\n .describe('The URI that identifies the JSON Schema used by this template. This enables documentation, autocompletion, and validation in JSON documents.'),\n version: z.string().optional().describe('A string identifying the version of this template.'),\n supported: z.array(bchVmVersionSchema).min(1).describe('The BCH VM versions that this template supports. At least one version is required.'),\n defaults: xoTemplateDefaultsSchema.optional().describe('Optional default settings used in this template.'),\n roles: z.record(z.string(), xoTemplateViewPropertiesSchema).describe('The roles defined in this template.'),\n start: z.array(xoTemplateActionIntentSchema).describe('A list of entry points defining which actions are available at the start.'),\n actions: z.record(z.string(), xoTemplateActionSchema).describe('The actions defined in this template.'),\n data: z.record(z.string(), xoTemplateDataSchema).optional().describe('The data fields defined in this template.'),\n transactions: z.record(z.string(), xoTemplateTransactionSchema).optional().describe('The transaction templates defined in this template.'),\n inputs: z.record(z.string(), xoTemplateInputSchema).describe('The inputs defined in this template.'),\n outputs: z.record(z.string(), xoTemplateOutputSchema).describe('The outputs defined in this template.'),\n lockingScripts: z.record(z.string(), xoTemplateLockingScriptSchema).describe('The locking script templates defined in this template.'),\n scripts: z\n .record(z.string(), z.string())\n .describe('Scripts used in this template. Keys are script identifiers, values are bytecode or CashASM expressions.'),\n constants: z.record(z.string(), xoTemplateConstantSchema).optional().describe('The constants defined in this template.'),\n variables: z\n .record(z.string(), xoTemplateVariableSchema)\n .optional()\n .describe(\"The variables that must be provided for use in the template's scripts.\"),\n resources: z.array(xoTemplateResourceSchema).optional().describe('Resource references providing external documentation or tooling links.'),\n icons: z.array(xoTemplateIconSchema).optional().describe('The icons available for use throughout the template.'),\n scenarios: z.unknown().optional().describe('The scenarios defined in this template.'),\n })\n .strict();\n","import type { XOTemplate } from '@xo-cash/types';\nimport { xoTemplateSchema } from './schemas.ts';\nimport { TemplateInvalidError, buildErrorDescription } from './errors.ts';\nimport { deserializeTemplate, serializeTemplate } from './serialization.ts';\n\n/**\n * Accepts a template value and returns a validated XOTemplate object. The input may be\n * either an Extended JSON string or a pre-parsed object. Both are validated\n * against the XOTemplate schema.\n *\n * @param inputTemplate - The value to validate. May be an Extended JSON string or a pre-parsed object.\n * @returns The validated template object\n * @throws {TemplateSerializationFailedError} If a pre-parsed object input cannot be serialized to JSON for normalization.\n * @throws {TemplateJsonMalformedError} If the string input is not valid JSON.\n * @throws {TemplateInvalidError} If the value does not conform to the XOTemplate schema.\n */\nexport const parseTemplate = (inputTemplate: string | XOTemplate): XOTemplate => {\n // Regardless of whether the inputTemplate is a string, an imported template or an in-memory object, serialize and then\n // deserialize it to ensure the output shape is consistent. For example, optional fields explicitly set to 'undefined' would be passed through\n // and then dropped on the string path, resulting in structurally different results for the same template.\n const serializedTemplate = typeof inputTemplate === 'string' ? inputTemplate : serializeTemplate(inputTemplate);\n const templateObject = deserializeTemplate(serializedTemplate);\n\n // Validate the template against the schema.\n const parseResult = xoTemplateSchema.safeParse(templateObject);\n\n if (parseResult.success) {\n // Return the validated template object\n return parseResult.data as XOTemplate;\n }\n\n // Build a human-readable description of every validation failure\n const errorDescription = buildErrorDescription(parseResult.error.issues);\n\n // Throw a typed error with the description\n throw new TemplateInvalidError(errorDescription);\n};\n"],"mappings":";;;;;;;;AAKA,MAAM,+BAA+B;;;;AAKrC,MAAM,mCAAmC;;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AAS,0GAA0G;CACxH,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,yBAAyB,CAAC,UAAU,CAAC,SAAS,0CAA0C;CACxH,WAAW,EACN,OAAO,EAAE,QAAQ,EAAE,yBAAyB,CAC5C,UAAU,CACV,SAAS,yEAAyE;CACvF,WAAW,EAAE,MAAM,yBAAyB,CAAC,UAAU,CAAC,SAAS,yEAAyE;CAC1I,OAAO,EAAE,MAAM,qBAAqB,CAAC,UAAU,CAAC,SAAS,uDAAuD;CAChH,WAAW,EAAE,SAAS,CAAC,UAAU,CAAC,SAAS,0CAA0C;CACxF,CAAC,CACD,QAAQ;;;;;;;;;;;;;;;ACl3Bb,MAAa,iBAAiB,kBAAmD;CAK7E,MAAM,iBAAiB,oBADI,OAAO,kBAAkB,WAAW,gBAAgB,kBAAkB,cAAc,CACjD;CAG9D,MAAM,cAAc,iBAAiB,UAAU,eAAe;AAE9D,KAAI,YAAY,QAEZ,QAAO,YAAY;AAOvB,OAAM,IAAI,qBAHe,sBAAsB,YAAY,MAAM,OAAO,CAGxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xo-cash/utils",
3
- "version": "0.0.2-development.15418787895",
3
+ "version": "0.0.2",
4
4
  "description": "XO Cash utilities",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.mts",