Documentation / @xo-cash/utils
@xo-cash/utils
Utility functions for XO
- Template parsing, serialization, validation and schema generation
- Script identifier generation
- Template identifier generation
- Extended JSON
⚠️ This project is in early development phase. Use it only if you understand what you are doing and accept the risks. Do not use funds you are not willing to lose. Minor version bumps may introduce breaking changes
Installation
npm install @xo-cash/utilsUsage
import { parseTemplate, scriptToScriptHash, generateTemplateIdentifier } from '@xo-cash/utils';Scripts
| Command | Description |
|---|---|
npm run build | Compile TypeScript to dist/ |
npm run generate-schema | Generate xo-template.schema.json from the Zod schema |
npm run test | Run tests with coverage |
npm run style | Lint with ESLint (read-only) |
npm run syntax | Type-check without emitting (tsc --noEmit) |
npm run format | Auto-fix formatting and linting |
npm run docs | Generate TypeDoc API docs to public/ |
npm run spellcheck | Spell-check source and test files |
npm audit --audit-level=moderate | Performs npm audit |
Templates
Parsing
parseTemplate accepts any string OR XOTemplate object and returns a validated XOTemplate object. It rejects unknown properties, missing required fields, and incorrect value types. Native bigint is accepted in satoshi fields; string encoding is also accepted for values sourced from JSON where bigint is unavailable.
How validation works
Validation uses a Zod schema defined in source/template/schemas.ts. The schema mirrors the XOTemplate TypeScript type and rejects unknown keys at every level. When validation fails, a TemplateInvalidError is thrown with a message that lists every failing field and the reason it failed, so all problems are visible in one pass.
JSON Schema export
A JSON Schema representation of the template can be generated by running:
npm run generate-schemaThis writes source/template/xo-template.schema.json, which can be consumed by other tools. However, it's recommended to use functions provided by this library for XO template development thanks to the extended JSON support.
Links
License
AsyncPushIterator
Defined in: source/sse-session/async-push-iterator.ts:24
An async iterable queue that bridges push-based producers and pull-based consumers.
Composes an internal ReadableStream instead of extending it, so producers call push while consumers use standard async iteration (for await...of).
const messages = new AsyncPushIterator<SSEvent>();
// Producer (elsewhere)
messages.push(event);
// Consumer
for await (const event of messages) {
handle(event);
}Symbol.asyncIterator returns stream.values({ preventCancel: true }) so breaking out of for await...of does not cancel the underlying stream. That matters for long-lived sessions where the producer keeps pushing after a consumer stops reading early (for example, test helpers that only collect a fixed count).
Type Parameters
| Type Parameter |
|---|
T |
Constructors
Constructor
new AsyncPushIterator<T>(): AsyncPushIterator<T>;Defined in: index.d.mts:871
Returns
Accessors
closed
Get Signature
get closed(): boolean;Defined in: source/sse-session/async-push-iterator.ts:47
Flag indicating if the iterator is closed.
Returns
boolean
Methods
[asyncIterator]()
asyncIterator: AsyncIterableIterator<T>;Defined in: source/event-emitter.ts:83
Returns an async iterator over the composed stream.
Uses preventCancel: true so early break from for await...of does not close the stream and block later pushes.
Because values are discarded after being read, only a single consumer is supported. Additional consumers will receive a stream lock error. Unread values will be preserved until close is called.
Returns
AsyncIterableIterator<T>
close()
close(): void;Defined in: source/sse-session/async-push-iterator.ts:83
Ends the stream.
Marks the iterator closed so future push calls are ignored. Buffered values are still yielded before iteration completes.
Returns
void
error()
error(error): void;Defined in: source/sse-session/async-push-iterator.ts:70
Causes any future interactions with the associated stream to error with error. Calling this will also clear the pending values immediately, so iterators that were listening will not receive them.
Parameters
| Parameter | Type | Description |
|---|---|---|
error | Error | The error to throw from the stream. |
Returns
void
push()
push(value): void;Defined in: source/sse-session/async-push-iterator.ts:58
Enqueues a value for the consumer.
After close, pushes are silently dropped.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | T | The next value to yield from the iterator. |
Returns
void
CashAssemblyBlockCommentUnclosedError
Defined in: source/cash-assembly/errors.ts:74
Error thrown when a block comment inside $() never closes.
Extends
Error
Constructors
Constructor
new CashAssemblyBlockCommentUnclosedError(commentStartIndex, cashAssemblyText): CashAssemblyBlockCommentUnclosedError;Defined in: index.d.mts:2857
Parameters
| Parameter | Type |
|---|---|
commentStartIndex | number |
cashAssemblyText | string |
Returns
CashAssemblyBlockCommentUnclosedError
Overrides
Error.constructorProperties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
commentStartIndex | readonly | number | Index of the first slash of the block comment opener. | source/cash-assembly/errors.ts:78 |
unclosedText | readonly | string | Text from the block comment opener through the end of the scanned string. | source/cash-assembly/errors.ts:83 |
CashAssemblyCompilationFailedError
Defined in: source/cash-assembly/errors.ts:28
Error thrown when cash assembly compilation fails.
Extends
Error
Constructors
Constructor
new CashAssemblyCompilationFailedError(message?): CashAssemblyCompilationFailedError;Defined in: index.d.mts:2825
Parameters
| Parameter | Type |
|---|---|
message? | string |
Returns
CashAssemblyCompilationFailedError
Overrides
Error.constructorCashAssemblyEvaluationUnclosedError
Defined in: source/cash-assembly/errors.ts:100
Error thrown when a $() evaluation never finds its matching closer.
Extends
Error
Constructors
Constructor
new CashAssemblyEvaluationUnclosedError(
evaluationStartIndex,
remainingOpenEvaluations,
cashAssemblyText): CashAssemblyEvaluationUnclosedError;Defined in: index.d.mts:2875
Parameters
| Parameter | Type |
|---|---|
evaluationStartIndex | number |
remainingOpenEvaluations | number |
cashAssemblyText | string |
Returns
CashAssemblyEvaluationUnclosedError
Overrides
Error.constructorProperties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
evaluationStartIndex | readonly | number | Index of the $ that opened the evaluation. | source/cash-assembly/errors.ts:104 |
remainingOpenEvaluations | readonly | number | How many $() remain open at the end of the string, including nested evaluations. | source/cash-assembly/errors.ts:109 |
unclosedText | readonly | string | Text from the opening $ through the end of the scanned string. | source/cash-assembly/errors.ts:114 |
CashAssemblyIdentifierCollisionError
Defined in: source/cash-assembly/errors.ts:186
Error thrown when one identifier would resolve as more than one IdentifierResolutionType.
Extends
Error
Constructors
Constructor
new CashAssemblyIdentifierCollisionError(identifier, resolutionTypes): CashAssemblyIdentifierCollisionError;Defined in: index.d.mts:2919
Parameters
| Parameter | Type |
|---|---|
identifier | string |
resolutionTypes | IdentifierResolutionType[] |
Returns
CashAssemblyIdentifierCollisionError
Overrides
Error.constructorProperties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
identifier | readonly | string | Identifier that more than one resolution type would match. | source/cash-assembly/errors.ts:190 |
resolutionTypes | readonly | IdentifierResolutionType[] | The list of resolution types that the identifier matches. | source/cash-assembly/errors.ts:195 |
CashAssemblyNumberNotSafeIntegerError
Defined in: source/cash-assembly/errors.ts:166
Error thrown when a number cannot be safely encoded as a CashAssembly VM number.
Extends
Error
Constructors
Constructor
new CashAssemblyNumberNotSafeIntegerError(identifier, value): CashAssemblyNumberNotSafeIntegerError;Defined in: index.d.mts:2899
Parameters
| Parameter | Type |
|---|---|
identifier | string |
value | number |
Returns
CashAssemblyNumberNotSafeIntegerError
Overrides
Error.constructorCashAssemblyPrimitiveMethodMissingError
Defined in: source/cash-assembly/errors.ts:146
Error thrown when a method resolvable primitive type does not expose the requested method.
Extends
Error
Constructors
Constructor
new CashAssemblyPrimitiveMethodMissingError(
identifier,
methodName,
type): CashAssemblyPrimitiveMethodMissingError;Defined in: index.d.mts:2887
Parameters
| Parameter | Type |
|---|---|
identifier | string |
methodName | string |
type | string |
Returns
CashAssemblyPrimitiveMethodMissingError
Overrides
Error.constructorCashAssemblyPrimitiveVariableMissingError
Defined in: source/cash-assembly/errors.ts:176
Error thrown when a method resolvable primitive is selected but its value is missing from the variables map.
Extends
Error
Constructors
Constructor
new CashAssemblyPrimitiveVariableMissingError(identifier, variableName): CashAssemblyPrimitiveVariableMissingError;Defined in: index.d.mts:2905
Parameters
| Parameter | Type |
|---|---|
identifier | string |
variableName | string |
Returns
CashAssemblyPrimitiveVariableMissingError
Overrides
Error.constructorCashAssemblyQuotedLiteralUnclosedError
Defined in: source/cash-assembly/errors.ts:38
Error thrown when a quoted string inside $() never closes.
Extends
Error
Constructors
Constructor
new CashAssemblyQuotedLiteralUnclosedError(
openingQuoteIndex,
quoteCharacter,
cashAssemblyText): CashAssemblyQuotedLiteralUnclosedError;Defined in: index.d.mts:2843
Parameters
| Parameter | Type |
|---|---|
openingQuoteIndex | number |
quoteCharacter | string |
cashAssemblyText | string |
Returns
CashAssemblyQuotedLiteralUnclosedError
Overrides
Error.constructorProperties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
openingQuoteIndex | readonly | number | Index of the opening quote that never found a closer. | source/cash-assembly/errors.ts:42 |
quoteCharacter | readonly | string | Quote character that opened the literal. | source/cash-assembly/errors.ts:47 |
unclosedText | readonly | string | Text from the opening quote through the end of the scanned string. | source/cash-assembly/errors.ts:52 |
CashAssemblyRequiredVariableMissingError
Defined in: source/cash-assembly/errors.ts:7
Error thrown when a required variable is missing.
Extends
Error
Constructors
Constructor
new CashAssemblyRequiredVariableMissingError(variableNames?): CashAssemblyRequiredVariableMissingError;Defined in: index.d.mts:2819
Parameters
| Parameter | Type |
|---|---|
variableNames? | string[] |
Returns
CashAssemblyRequiredVariableMissingError
Overrides
Error.constructorProperties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
variableNames | readonly | string[] | Variable names that were required but absent from the variables map. | source/cash-assembly/errors.ts:11 |
CashAssemblyUnsupportedValueTypeError
Defined in: source/cash-assembly/errors.ts:156
Error thrown when a value cannot be resolved as bytes.
Extends
Error
Constructors
Constructor
new CashAssemblyUnsupportedValueTypeError(identifier, returnedType): CashAssemblyUnsupportedValueTypeError;Defined in: index.d.mts:2893
Parameters
| Parameter | Type |
|---|---|
identifier | string |
returnedType | string |
Returns
CashAssemblyUnsupportedValueTypeError
Overrides
Error.constructorCashAssemblyVariableTypeMismatchError
Defined in: source/cash-assembly/errors.ts:136
Error thrown when a variable's runtime type does not match the type required for compilation.
Extends
Error
Constructors
Constructor
new CashAssemblyVariableTypeMismatchError(
variableKey,
expectedType,
actualType): CashAssemblyVariableTypeMismatchError;Defined in: index.d.mts:2881
Parameters
| Parameter | Type |
|---|---|
variableKey | string |
expectedType | string |
actualType | string |
Returns
CashAssemblyVariableTypeMismatchError
Overrides
Error.constructorCashAssemblyVmNumberDecodeError
Defined in: source/cash-assembly/errors.ts:210
Error thrown when compiled evaluation bytes cannot be decoded as a VM number.
Extends
Error
Constructors
Constructor
new CashAssemblyVmNumberDecodeError(reason): CashAssemblyVmNumberDecodeError;Defined in: index.d.mts:2925
Parameters
| Parameter | Type |
|---|---|
reason | string |
Returns
CashAssemblyVmNumberDecodeError
Overrides
Error.constructorEventEmitter
Defined in: source/event-emitter.ts:37
A simple event emitter implementation.
Extended by
Type Parameters
| Type Parameter | Description |
|---|---|
T extends EventMap | The event map type. |
Constructors
Constructor
new EventEmitter<T>(): EventEmitter<T>;Returns
EventEmitter<T>
Methods
emit()
emit<K>(type, payload): boolean;Defined in: source/event-emitter.ts:155
Emit an event.
Type Parameters
| Type Parameter |
|---|
K extends string | number | symbol |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | K | The event type. |
payload | T[K] | The event payload. |
Returns
boolean
True if there are listeners for the event, false otherwise.
Remarks
The caller is responsible for ensuring the payload suits the intended mutability requirements. By default, the payload will be mutable, so listeners may mutate the payload, effecting both the original object and the other listeners. To prevent this, the caller can use the Object.freeze or deepFreeze function to freeze the payload. This will need to be defined in the EventMap using the built-in Readonly type or the provided DeeplyReadonly type.
off()
off<K>(type, listener?): void;Defined in: source/event-emitter.ts:119
Remove a listener for an event.
Type Parameters
| Type Parameter |
|---|
K extends string | number | symbol |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | K | The event type. |
listener? | Listener<T[K]> | The listener function. |
Returns
void
on()
on<K>(
type,
listener,
debounceMilliseconds?): OffCallback;Defined in: source/event-emitter.ts:51
Add a listener for an event.
Type Parameters
| Type Parameter |
|---|
K extends string | number | symbol |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | K | The event type. |
listener | Listener<T[K]> | The listener function. |
debounceMilliseconds? | number | The debounce time in milliseconds. |
Returns
An off callback that can be called to stop listening for events.
once()
once<K>(
type,
listener,
debounceMilliseconds?): OffCallback;Defined in: source/event-emitter.ts:83
Add a one-time listener for an event.
Type Parameters
| Type Parameter |
|---|
K extends string | number | symbol |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | K | The event type. |
listener | Listener<T[K]> | The listener function. |
debounceMilliseconds? | number | The debounce time in milliseconds. |
Returns
An off callback that can be called to stop listening for events.
removeAllListeners()
removeAllListeners(): void;Defined in: source/event-emitter.ts:176
Remove all listeners.
Returns
void
waitFor()
waitFor<K>(
type,
predicate,
timeoutMs?): Promise<T[K]>;Defined in: source/event-emitter.ts:191
Wait for an event to be emitted that matches the provided predicate function's criteria.
Type Parameters
| Type Parameter |
|---|
K extends string | number | symbol |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | K | The event type. |
predicate | (payload) => boolean | Predicate function to filter for whether the event payload matches the criteria. |
timeoutMs? | number | The timeout in milliseconds. |
Returns
Promise<T[K]>
The event payload.
ExponentialBackoff
Defined in: source/exponential-backoff/exponential-backoff.ts:86
Exponential backoff is a technique used to retry a function after a delay.
The delay increases exponentially with each attempt, up to a maximum delay.
The jitter is a random amount of time subtracted from the delay to prevent thundering herd problems.
The growth rate is the factor by which the delay increases with each attempt.
Constructors
Constructor
new ExponentialBackoff(options?): ExponentialBackoff;Defined in: index.d.mts:220
Creates a new exponential-backoff instance.
Unspecified options use the defaults listed below.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | Partial<ExponentialBackoffOptions> | Exponential-backoff configuration overrides. |
Returns
Throws
An ExponentialBackoffNumberNotFiniteError if a provided option is not a finite number
Throws
An ExponentialBackoffNumberOutOfBoundsError if a provided option is out of bounds
Throws
An ExponentialBackoffNumberTooSmallError if a provided option is too small
Throws
An ExponentialBackoffNonIntegerError if a provided option is not an integer
Methods
run()
run<T>(taskFn, options?): Promise<T>;Defined in: source/exponential-backoff/exponential-backoff.ts:237
Run the function with exponential backoff
If the function fails but we have not hit the max attempts, the error will be passed to the onError callback and the function will be retried with an exponential delay
If every attempt fails, an ExponentialBackoffMaxRetriesHitError will be thrown with all errors from the task function.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
taskFn | (callbackParameters) => Promise<T> | The function to run |
options? | ExponentialBackoffRunOptions | Options that control this run |
Returns
Promise<T>
The result of the function
Throws
An ExponentialBackoffMaxRetriesHitError with all the errors that were thrown by the task function
Throws
An ExponentialBackoffStoppedRetriesError if the abort signal is activated
from()
static from(config?): ExponentialBackoff;Defined in: source/exponential-backoff/exponential-backoff.ts:131
Create a new ExponentialBackoff instance
Parameters
| Parameter | Type | Description |
|---|---|---|
config? | Partial<ExponentialBackoffOptions> | The configuration for the exponential backoff |
Returns
The ExponentialBackoff instance
Throws
An ExponentialBackoffNumberNotFiniteError if a provided option is not a finite number
Throws
An ExponentialBackoffNumberOutOfBoundsError if a provided option is out of bounds
Throws
An ExponentialBackoffNumberTooSmallError if a provided option is too small
Throws
An ExponentialBackoffNonIntegerError if a provided option is not an integer
run()
static run<T>(taskFn, options?): Promise<T>;Defined in: source/exponential-backoff/exponential-backoff.ts:148
Run the function with exponential backoff
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
taskFn | (callbackParameters) => Promise<T> | The function to run |
options? | Partial<ExponentialBackoffStaticRunOptions> | Backoff configuration and options for this run |
Returns
Promise<T>
The result of the function
Throws
An ExponentialBackoffMaxRetriesHitError with all the errors that were thrown by the task function
Throws
An ExponentialBackoffStoppedRetriesError if the abort signal is activated
validateOptions()
static validateOptions(options): void;Defined in: source/exponential-backoff/exponential-backoff.ts:169
Validate the options for the exponential backoff
Parameters
| Parameter | Type | Description |
|---|---|---|
options | ExponentialBackoffOptions | The options to validate |
Returns
void
Throws
ExponentialBackoffNumberNotFiniteError if a provided option is not a finite number
Throws
ExponentialBackoffNonIntegerError if a provided option is not an integer
Throws
ExponentialBackoffNumberOutOfBoundsError if a provided option is out of bounds
Throws
ExponentialBackoffNumberTooSmallError if a provided option is too small
ExponentialBackoffExternallyAbortable
Defined in: source/exponential-backoff/exponential-backoff-externally-aborted.ts:24
An exponential backoff that can be stopped by calling .abort() or by passing an abortSignal to the constructor.
Remarks
One instance can run many tasks. Aborting it stops retries for every run.
Constructors
Constructor
new ExponentialBackoffExternallyAbortable(options?): ExponentialBackoffExternallyAbortable;Defined in: index.d.mts:295
Parameters
| Parameter | Type |
|---|---|
options? | Partial<ExponentialBackoffExternallyAbortableOptions> |
Returns
ExponentialBackoffExternallyAbortable
Methods
abort()
abort(reason): void;Defined in: source/exponential-backoff/exponential-backoff-externally-aborted.ts:93
Stops retries for all current and future runs.
Parameters
| Parameter | Type | Description |
|---|---|---|
reason | unknown | The reason for stopping retries |
Returns
void
run()
run<T>(taskFn, options?): Promise<T>;Defined in: source/exponential-backoff/exponential-backoff-externally-aborted.ts:73
Run the function with exponential backoff
If the function fails but we have not hit the max attempts, the error will be passed to the onError callback and the function will be retried with an exponential delay
If every attempt fails, an ExponentialBackoffMaxRetriesHitError will be thrown with all errors from the task function.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
taskFn | (callbackParameters) => Promise<T> | The function to run |
options? | Partial<ExponentialBackoffRunOptions> | Options that control this run |
Returns
Promise<T>
The result of the function
Throws
An ExponentialBackoffMaxRetriesHitError with all the errors that were thrown by the task function
Throws
An ExponentialBackoffStoppedRetriesError if the abort signal is activated
Throws
An ExternallyAbortedExponentialBackoffExternalSignalAbortedError if the abort signal that was provided during construction is activated
Throws
An ExternallyAbortedExponentialBackoffInternalSignalAbortedError if ExponentialBackoffExternallyAbortable.abort is called on this class
ExponentialBackoffMaxRetriesHitError
Defined in: source/exponential-backoff/errors.ts:6
Error thrown when the maximum number of retries is hit in an exponential backoff
Extends
Error
Constructors
Constructor
new ExponentialBackoffMaxRetriesHitError(errors): ExponentialBackoffMaxRetriesHitError;Defined in: index.d.mts:90
Parameters
| Parameter | Type |
|---|---|
errors | Error[] |
Returns
ExponentialBackoffMaxRetriesHitError
Overrides
Error.constructorExponentialBackoffNonIntegerError
Defined in: source/exponential-backoff/errors.ts:59
Error thrown when an exponential backoff option is not an integer
Extends
Error
Constructors
Constructor
new ExponentialBackoffNonIntegerError(option, value): ExponentialBackoffNonIntegerError;Defined in: index.d.mts:120
Parameters
| Parameter | Type |
|---|---|
option | string |
value | number |
Returns
ExponentialBackoffNonIntegerError
Overrides
Error.constructorExponentialBackoffNumberNotFiniteError
Defined in: source/exponential-backoff/errors.ts:49
Error thrown when an exponential backoff option is an invalid infinite integer
Extends
Error
Constructors
Constructor
new ExponentialBackoffNumberNotFiniteError(option, value): ExponentialBackoffNumberNotFiniteError;Defined in: index.d.mts:114
Parameters
| Parameter | Type |
|---|---|
option | string |
value | number |
Returns
ExponentialBackoffNumberNotFiniteError
Overrides
Error.constructorExponentialBackoffNumberOutOfBoundsError
Defined in: source/exponential-backoff/errors.ts:39
Error thrown when an exponential backoff option is out of bounds
Extends
Error
Constructors
Constructor
new ExponentialBackoffNumberOutOfBoundsError(
option,
value,
min,
max): ExponentialBackoffNumberOutOfBoundsError;Defined in: index.d.mts:108
Parameters
| Parameter | Type |
|---|---|
option | string |
value | number |
min | number |
max | number |
Returns
ExponentialBackoffNumberOutOfBoundsError
Overrides
Error.constructorExponentialBackoffNumberTooSmallError
Defined in: source/exponential-backoff/errors.ts:29
Error thrown when an exponential backoff option is too small
Extends
Error
Constructors
Constructor
new ExponentialBackoffNumberTooSmallError(
option,
value,
min): ExponentialBackoffNumberTooSmallError;Defined in: index.d.mts:102
Parameters
| Parameter | Type |
|---|---|
option | string |
value | number |
min | number |
Returns
ExponentialBackoffNumberTooSmallError
Overrides
Error.constructorExponentialBackoffStoppedRetriesError
Defined in: source/exponential-backoff/errors.ts:16
Error thrown when the exponential backoff retries are stopped
Extends
Error
Constructors
Constructor
new ExponentialBackoffStoppedRetriesError(reason): ExponentialBackoffStoppedRetriesError;Defined in: index.d.mts:96
Parameters
| Parameter | Type |
|---|---|
reason | unknown |
Returns
ExponentialBackoffStoppedRetriesError
Overrides
Error.constructorExternallyAbortedExponentialBackoffExternalSignalAbortedError
Defined in: source/exponential-backoff/errors.ts:70
Error thrown when an externally aborted exponential backoff is aborted due to the external abort signal that was passed in to the constructor being aborted by an upstream consumer
Extends
Error
Constructors
Constructor
new ExternallyAbortedExponentialBackoffExternalSignalAbortedError(reason): ExternallyAbortedExponentialBackoffExternalSignalAbortedError;Defined in: index.d.mts:127
Parameters
| Parameter | Type |
|---|---|
reason | unknown |
Returns
ExternallyAbortedExponentialBackoffExternalSignalAbortedError
Overrides
Error.constructorExternallyAbortedExponentialBackoffInternalSignalAbortedError
Defined in: source/exponential-backoff/errors.ts:84
Error thrown when an externally aborted exponential backoff is aborted due to the internal abort signal being aborted using the .abort() method
Extends
Error
Constructors
Constructor
new ExternallyAbortedExponentialBackoffInternalSignalAbortedError(reason): ExternallyAbortedExponentialBackoffInternalSignalAbortedError;Defined in: index.d.mts:134
Parameters
| Parameter | Type |
|---|---|
reason | unknown |
Returns
ExternallyAbortedExponentialBackoffInternalSignalAbortedError
Overrides
Error.constructorInvitationInvalidError
Defined in: source/invitation/errors.ts:6
Thrown when a value does not satisfy the XOInvitation schema.
Extends
Error
Constructors
Constructor
new InvitationInvalidError(details): InvitationInvalidError;Defined in: index.d.mts:376
Parameters
| Parameter | Type |
|---|---|
details | string |
Returns
Overrides
Error.constructorInvitationJsonMalformedError
Defined in: source/invitation/errors.ts:17
Thrown when invitation share JSON cannot be parsed.
Extends
Error
Constructors
Constructor
new InvitationJsonMalformedError(reason): InvitationJsonMalformedError;Defined in: index.d.mts:386
Parameters
| Parameter | Type |
|---|---|
reason | string |
Returns
Overrides
Error.constructorProperties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
reason | readonly | string | Parser failure forwarded from JSON parsing. | source/invitation/errors.ts:21 |
InvitationSerializationFailedError
Defined in: source/invitation/errors.ts:34
Thrown when invitation serialization fails.
Extends
Error
Constructors
Constructor
new InvitationSerializationFailedError(reason): InvitationSerializationFailedError;Defined in: index.d.mts:396
Parameters
| Parameter | Type |
|---|---|
reason | string |
Returns
InvitationSerializationFailedError
Overrides
Error.constructorProperties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
reason | readonly | string | Serializer failure forwarded from the serialization path. | source/invitation/errors.ts:38 |
SSEEventParser
Defined in: source/sse-session/sse-event-parser.ts:38
Incrementally parses Server-Sent Events (SSE) from streamed byte chunks.
SSE payloads are line-oriented: each event is a sequence of field: value lines terminated by a blank line. This parser accepts arbitrary chunk boundaries from a live HTTP response body and emits only complete events.
Typical usage is one parser instance per connection, calling parseEvents for each chunk received from the stream:
const parser = new SSEEventParser();
for await (const chunk of response.body) {
for (const event of parser.parseEvents(chunk)) {
// handle event.data, event.event, event.id, event.retry
}
}Supported fields follow the SSE spec: data, event, id, and retry. Multiple data: lines in one event are joined with \n. An event is only emitted once a blank line is seen and at least one data field was collected.
Constructors
Constructor
new SSEEventParser(options?): SSEEventParser;Defined in: index.d.mts:1292
Creates a parser for one SSE stream.
Inject custom encoders in tests or when a non-default character encoding is required; production callers can rely on the defaults.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | Partial<SSEEventParserOptions> | Optional text encoders for decode/encode of stream bytes. |
Returns
Methods
parseEvents()
parseEvents(chunk): SSEvent[];Defined in: source/sse-session/sse-event-parser.ts:81
Parses all complete SSE events contained in a newly received chunk.
The chunk is appended to any bytes buffered from earlier calls. Complete events (blank-line delimited blocks with at least one data field) are returned immediately; any trailing partial line or in-progress event stays in the internal buffer until a later chunk completes it.
Parameters
| Parameter | Type | Description |
|---|---|---|
chunk | Uint8Array | Newly received SSE stream bytes. |
Returns
SSEvent[]
Zero or more complete parsed SSE events from this chunk.
reset()
reset(): void;Defined in: source/sse-session/sse-event-parser.ts:62
Clears any buffered bytes from a partial line or incomplete event.
Call when abandoning a transport so the next connection does not prepend stale bytes to incoming chunks.
Returns
void
SSESession
Defined in: source/sse-session/sse-session.ts:56
A fetch-based Server-Sent Events (SSE) client with reconnect and optional browser tab visibility handling.
Each session maintains one HTTP streaming connection at a time. Incoming bytes are parsed into SSEvent objects and delivered through two surfaces:
- Events —
"connected","message","disconnected","error", and"closed"on the session itself (extends EventEmitter). - Messages — messages, an async iterable for
for await...ofconsumers.
Typical usage:
const session = await SSESession.create("/events");
session.on("message", (event) => console.log(event.data));
for await (const event of session.messages) {
handle(event);
}Lifecycle
- connect opens (or reopens) the transport. It resolves once the HTTP stream is established; reading continues in the background.
- disconnect stops the in-flight fetch without ending the session. Used internally for tab visibility. The messages iterator stays open so an existing consumer resumes when the tab becomes visible again.
- close aborts the transport, closes messages, and emits
"closed".
Automatic reconnect is controlled by SSESessionOptions.persistent (server closed the stream) and SSESessionOptions.attemptReconnect (transport error).
Connection supersession
Each connect will create a new controller if one does not exist. Otherwise, it will return immediately.
Extends
Constructors
Constructor
new SSESession(url, options?): SSESession;Defined in: index.d.mts:1210
Parameters
| Parameter | Type |
|---|---|
url | string |
options? | Partial<SSESessionCallbacks & SSERequestInit & SSERequestFunction & SSESessionRetryInterface & SSELifecycleOptions & SSEParser & SSESessionEventCallbacks> |
Returns
Overrides
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
messages | public | AsyncPushIterator<SSEvent> | Asynchronous stream of parsed SSE events for the active connection. Stays open across disconnect and automatic reconnects so an existing for await consumer keeps receiving events after visibility resumes. Closes when: - the server ends the stream and SSESessionOptions.persistent is false, - close is called, or - a transport error occurs with SSESessionOptions.attemptReconnect disabled. A later connect replaces this with a new iterator when the previous one was closed. Consumers should read from session.messages rather than caching a reference across terminal disconnects. | source/sse-session/sse-session.ts:325 |
options | public | SSESessionOptions | Per-instance configuration. Defaults live on the instance field (not a shared static) so each session gets its own SSEEventParser and ExponentialBackoff. | source/sse-session/sse-session.ts:268 |
plugins | readonly | Map<unknown, unknown> | Registered plugins for the session. This can be used to prevent duplicate plugins from being added to the session. The value for a plugin is arbitrary, for example a function that removes the plugin. | source/sse-session/sse-session.ts:300 |
Accessors
active
Get Signature
get active(): boolean;Defined in: source/sse-session/sse-session.ts:359
Returns true if the session is active by checking if the controller is not null.
Returns
boolean
Methods
close()
close(): void;Defined in: source/sse-session/sse-session.ts:488
Terminates the session and disables attached visibility handling until the same instance is manually connected again.
Closes messages and emits "closed".
Returns
void
connect()
connect(): Promise<void>;Defined in: source/sse-session/sse-session.ts:374
Connects or reconnects to the SSE endpoint.
Resolves once the HTTP stream is established and "connected" has been emitted. Body reading continues asynchronously in the background via the internal #readStream method.
Returns
Promise<void>
Throws
When the fetch retry policy exhausts attempts or the connection is superseded before the reader is handed off (in the latter case the promise resolves without throwing).
disconnect()
disconnect(context?): void;Defined in: source/sse-session/sse-session.ts:460
Disconnects only the currently active transport.
beforeDisconnect is emitted on every invocation, even when no transport is currently active. This allows observers to react to an explicit disconnect operation.
Parameters
| Parameter | Type | Description |
|---|---|---|
context? | SSESessionOperationContext | Context describing the operation initiator. |
Returns
void
Emits
beforeDisconnect with the supplied operation context.
Emits
disconnected with reason "disconnect" when an active transport is actually disconnected.
emit()
emit<K>(type, payload): boolean;Defined in: source/event-emitter.ts:155
Emit an event.
Type Parameters
| Type Parameter |
|---|
K extends keyof SSESessionEventMap |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | K | The event type. |
payload | SSESessionEventMap[K] | The event payload. |
Returns
boolean
True if there are listeners for the event, false otherwise.
Remarks
The caller is responsible for ensuring the payload suits the intended mutability requirements. By default, the payload will be mutable, so listeners may mutate the payload, effecting both the original object and the other listeners. To prevent this, the caller can use the Object.freeze or deepFreeze function to freeze the payload. This will need to be defined in the EventMap using the built-in Readonly type or the provided DeeplyReadonly type.
Inherited from
off()
off<K>(type, listener?): void;Defined in: source/event-emitter.ts:119
Remove a listener for an event.
Type Parameters
| Type Parameter |
|---|
K extends keyof SSESessionEventMap |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | K | The event type. |
listener? | Listener<SSESessionEventMap[K]> | The listener function. |
Returns
void
Inherited from
on()
on<K>(
type,
listener,
debounceMilliseconds?): OffCallback;Defined in: source/event-emitter.ts:51
Add a listener for an event.
Type Parameters
| Type Parameter |
|---|
K extends keyof SSESessionEventMap |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | K | The event type. |
listener | Listener<SSESessionEventMap[K]> | The listener function. |
debounceMilliseconds? | number | The debounce time in milliseconds. |
Returns
An off callback that can be called to stop listening for events.
Inherited from
once()
once<K>(
type,
listener,
debounceMilliseconds?): OffCallback;Defined in: source/event-emitter.ts:83
Add a one-time listener for an event.
Type Parameters
| Type Parameter |
|---|
K extends keyof SSESessionEventMap |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | K | The event type. |
listener | Listener<SSESessionEventMap[K]> | The listener function. |
debounceMilliseconds? | number | The debounce time in milliseconds. |
Returns
An off callback that can be called to stop listening for events.
Inherited from
removeAllListeners()
removeAllListeners(): void;Defined in: source/event-emitter.ts:176
Remove all listeners.
Returns
void
Inherited from
EventEmitter.removeAllListeners
waitFor()
waitFor<K>(
type,
predicate,
timeoutMs?): Promise<SSESessionEventMap[K]>;Defined in: source/event-emitter.ts:191
Wait for an event to be emitted that matches the provided predicate function's criteria.
Type Parameters
| Type Parameter |
|---|
K extends keyof SSESessionEventMap |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | K | The event type. |
predicate | (payload) => boolean | Predicate function to filter for whether the event payload matches the criteria. |
timeoutMs? | number | The timeout in milliseconds. |
Returns
Promise<SSESessionEventMap[K]>
The event payload.
Inherited from
addBrowserVisibilityHandler()
static addBrowserVisibilityHandler(session): object;Defined in: source/sse-session/sse-session.ts:174
Pauses and resumes a session based on browser tab visibility.
Uses the Page Visibility API (document.visibilitychange):
- hidden — disconnect stops the active fetch. messages stays open;
"disconnected"fires but"closed"does not. - visible — connect re-establishes the stream if needed.
This controller will not re-connect if the session was disconnected by something else.
No-op in non-browser environments where document is undefined.
Parameters
| Parameter | Type | Description |
|---|---|---|
session | SSESession | The session to manage. |
Returns
object
| Name | Type | Defined in |
|---|---|---|
removeListener? | OffCallback | source/sse-session/sse-session.ts:174 |
session | SSESession | source/sse-session/sse-session.ts:174 |
addLastEventIdReconnect()
static addLastEventIdReconnect(session): object;Defined in: source/sse-session/sse-session.ts:97
Enables SSE resume semantics by sending Last-Event-ID on reconnect.
Listens for incoming "message" events and remembers the most recent SSEvent.id. On every subsequent connect or reconnect, the session's onRequest hook is wrapped so that header is attached when an id is known, allowing the server to replay only events the client has not yet received.
The existing onRequest callback is preserved and runs after the header is applied, so auth or other header mutations continue to work.
Since this relies on listening to the "message" event, this should ideally be called before "connect is called so no messages (and no ids) are missed.
const session = new SSESession(url);
SSESession.addLastEventIdReconnect(session);
await session.connect();
// Reconnects send Last-Event-ID once an event with an id is received.Parameters
| Parameter | Type | Description |
|---|---|---|
session | SSESession | The session to instrument. |
Returns
object
The same session, for chaining.
| Name | Type | Defined in |
|---|---|---|
removeListener? | OffCallback | source/sse-session/sse-session.ts:97 |
session | SSESession | source/sse-session/sse-session.ts:97 |
create()
static create(url, options?): Promise<SSESession>;Defined in: source/sse-session/sse-session.ts:65
Creates a session and waits until the first connection is established.
Parameters
| Parameter | Type | Description |
|---|---|---|
url | string | The SSE endpoint URL. |
options? | Partial<SSESessionCallbacks & SSERequestInit & SSERequestFunction & SSESessionRetryInterface & SSELifecycleOptions & SSEParser & SSESessionEventCallbacks> | Configuration merged with instance defaults. |
Returns
Promise<SSESession>
A connected session.
Throws
When the initial connection cannot be established.
TemplateInvalidError
Defined in: source/template/errors.ts:6
Thrown when the provided template does not satisfy the XOTemplate schema.
Extends
Error
Constructors
Constructor
new TemplateInvalidError(details): TemplateInvalidError;Defined in: index.d.mts:1319
Parameters
| Parameter | Type |
|---|---|
details | string |
Returns
Overrides
Error.constructorTemplateJsonMalformedError
Defined in: source/template/errors.ts:17
Thrown when a string passed to deserializeTemplate cannot be parsed as JSON.
Extends
Error
Constructors
Constructor
new TemplateJsonMalformedError(reason): TemplateJsonMalformedError;Defined in: index.d.mts:1325
Parameters
| Parameter | Type |
|---|---|
reason | string |
Returns
Overrides
Error.constructorTemplateSerializationFailedError
Defined in: source/template/errors.ts:27
Thrown when serializeTemplate fails to produce a JSON string from the template.
Extends
Error
Constructors
Constructor
new TemplateSerializationFailedError(reason): TemplateSerializationFailedError;Defined in: index.d.mts:1331
Parameters
| Parameter | Type |
|---|---|
reason | string |
Returns
TemplateSerializationFailedError
Overrides
Error.constructorWaitForTimeoutError
Defined in: source/errors.ts:36
Error thrown when a waitFor timeout is reached
Extends
Error
Constructors
Constructor
new WaitForTimeoutError(type): WaitForTimeoutError;Defined in: index.d.mts:19
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
Overrides
Error.constructorSSEEventParserOptions
Defined in: source/sse-session/sse-event-parser.ts:8
Optional encoders used when decoding incoming SSE bytes and re-encoding any buffered remainder between chunks.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
textDecoder | TextDecoder | Decodes raw stream bytes into text. Defaults to a new TextDecoder. | source/sse-session/sse-event-parser.ts:11 |
SSEParser
Defined in: source/sse-session/types.ts:78
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
eventParser | object | Incremental SSE frame parser for the response body. SSEEventParser.reset is called by the session when abandoning a transport so partial frames do not carry over to the next connection. | source/sse-session/types.ts:86 |
eventParser.parseEvents | SSEvent[] | - | source/sse-session/types.ts:87 |
eventParser.reset | void | - | source/sse-session/types.ts:88 |
SSEvent
Defined in: source/sse-session/types.ts:174
Represents a Server-Sent Event.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
data | string | Event data. | source/sse-session/types.ts:179 |
event? | string | Event type. This value is optionally sent by the server. Traditional EventSource allows listeners for specific event types. The SSE Session collapses all event types into "message" event. | source/sse-session/types.ts:186 |
id? | string | Event ID. This value is optionally sent by the server as a "checkpoint" the client can use to resume from using the Last-Event-ID header. | source/sse-session/types.ts:192 |
retry? | number | Reconnection time in milliseconds. This value is optionally sent by the server to indicate the server's preferred time before reconnecting | source/sse-session/types.ts:198 |
CompileCashAssemblyStringParameters
type CompileCashAssemblyStringParameters = CompileCashAssemblyContext & object;Defined in: source/cash-assembly/types.ts:48
Parameters for compiling CashAssembly text.
Type Declaration
| Name | Type | Description | Defined in |
|---|---|---|---|
cashAssemblyText | string | Text to compile, which may contain $(). When this text contains $(), each CashAssembly evaluation is compiled and replaced with its decoded payload. Surrounding text is kept. When this text contains no $(), the entire string is compiled as CashAssembly so push opcodes remain. | source/cash-assembly/types.ts:58 |
evaluationDecodeMode? | CompiledCashAssemblyDecodeMode | The mode to decode compiled bytecode into a string. | source/cash-assembly/types.ts:63 |
CompiledCashAssemblyDecodeMode
type CompiledCashAssemblyDecodeMode = "utf8" | "hex" | "boolean" | "bigint" | "uint8array";Defined in: source/cash-assembly/types.ts:6
Supported decode modes for compiled CashAssembly evaluation bytes.
EventMap
type EventMap = Record<string, unknown>;Defined in: source/event-emitter.ts:6
ExponentialBackoffCallbackParameters
type ExponentialBackoffCallbackParameters = object;Defined in: source/exponential-backoff/exponential-backoff.ts:52
The parameters for the task function
Param
stopRetries
The function to call to stop the retries
ExponentialBackoffExternallyAbortableOptions
type ExponentialBackoffExternallyAbortableOptions = Partial<ExponentialBackoffOptions> & object;Defined in: source/exponential-backoff/exponential-backoff-externally-aborted.ts:14
Options for the ExponentialBackoffExternallyAbortable class
Type Declaration
| Name | Type | Defined in |
|---|---|---|
abortSignal | AbortSignal | source/exponential-backoff/exponential-backoff-externally-aborted.ts:15 |
ExponentialBackoffOptions
type ExponentialBackoffOptions = object;Defined in: source/exponential-backoff/exponential-backoff.ts:11
Properties
baseDelay
baseDelay: number;Defined in: source/exponential-backoff/exponential-backoff.ts:26
The base delay between attempts in milliseconds
growthRate
growthRate: number;Defined in: source/exponential-backoff/exponential-backoff.ts:31
The growth rate of the delay
jitter
jitter: number;Defined in: source/exponential-backoff/exponential-backoff.ts:36
The jitter of the delay as a percentage of growthRate. The jitter is subtracted from the delay.
maxAttempts
maxAttempts: number;Defined in: source/exponential-backoff/exponential-backoff.ts:21
The maximum number of attempts. Passing 0 will result in infinite attempts.
maxDelay
maxDelay: number;Defined in: source/exponential-backoff/exponential-backoff.ts:16
The maximum delay between attempts in milliseconds
ExponentialBackoffRunOptions
type ExponentialBackoffRunOptions = object;Defined in: source/exponential-backoff/exponential-backoff.ts:59
Options that control a single exponential-backoff run.
Properties
onError?
optional onError?: (error) => void;Defined in: source/exponential-backoff/exponential-backoff.ts:64
Called after each failed task attempt.
Parameters
| Parameter | Type |
|---|---|
error | Error |
Returns
void
signal?
optional signal?: AbortSignal;Defined in: source/exponential-backoff/exponential-backoff.ts:69
Stops pending delays and prevents future attempts when aborted.
ExponentialBackoffStaticRunOptions
type ExponentialBackoffStaticRunOptions = Partial<ExponentialBackoffOptions> & ExponentialBackoffRunOptions;Defined in: source/exponential-backoff/exponential-backoff.ts:75
Options accepted by the static exponential-backoff run helper.
ExponentialBackoffStopRetriesFunction
type ExponentialBackoffStopRetriesFunction = (reason) => void;Defined in: source/exponential-backoff/exponential-backoff.ts:45
The function to call to stop the retries. This mimics the AbortSignal.abort function by taking in a reason for stopping
Parameters
| Parameter | Type | Description |
|---|---|---|
reason | unknown | The reason for stopping the retries. |
Returns
void
OffCallback
type OffCallback = () => void;Defined in: source/event-emitter.ts:31
Callback returned by on and once for removing a listener.
Returns
void
SSELifecycleOptions
type SSELifecycleOptions = object;Defined in: source/sse-session/types.ts:92
Properties
attemptReconnect
attemptReconnect: boolean;Defined in: source/sse-session/types.ts:99
When true, SSESession calls SSESession.connect again after a transport error (not an intentional disconnect).
Default
truepersistent
persistent: boolean;Defined in: source/sse-session/types.ts:106
When true, SSESession calls SSESession.connect again after the server closes the stream normally (done).
Default
falseSSERequestFunction
type SSERequestFunction = object;Defined in: source/sse-session/types.ts:29
The fetch function to use.
NOTE: This is compatible with Browser/Node's native "fetch" function. We use this in place of "typeof fetch" so that we can accept non-standard URLs ("url" is a "string" here). For example, a LibP2P adapter might not use a standardized URL format (and might only include "path"). This would cause a type error as native fetch expects type "URL".
SSERequestInit
type SSERequestInit = object;Defined in: source/sse-session/types.ts:3
Properties
body?
optional body?: string | FormData;Defined in: source/sse-session/types.ts:18
Request body for POST-based SSE endpoints.
headers?
optional headers?: Record<string, string>;Defined in: source/sse-session/types.ts:13
Request headers sent on every connect and reconnect.
method
method: "GET" | "POST";Defined in: source/sse-session/types.ts:8
The HTTP method to use.
SSESessionCallbacks
type SSESessionCallbacks = object;Defined in: source/sse-session/types.ts:36
Lifecycle hooks invoked by SSESession during connect, read, and teardown.
Properties
onRequest
onRequest: (request) => Promise<RequestInit>;Defined in: source/sse-session/types.ts:42
Called before each fetch so callers can attach auth headers, cookies, or a Last-Event-ID for resume semantics.
Parameters
| Parameter | Type |
|---|---|
request | RequestInit |
Returns
Promise<RequestInit>
SSESessionDisconnectContext
type SSESessionDisconnectContext =
| SSESessionDisconnectInternalContext
| SSESessionDisconnectRemoteContext
| SSESessionDisconnectErrorContext;Defined in: source/sse-session/types.ts:141
Discriminated context for the reason the session was disconnected.
SSESessionDisconnectErrorContext
type SSESessionDisconnectErrorContext = object;Defined in: source/sse-session/types.ts:133
Discriminated context for the reason the session was disconnected due to an error.
SSESessionDisconnectInternalContext
type SSESessionDisconnectInternalContext = object & SSESessionOperationContext;Defined in: source/sse-session/types.ts:119
Discriminated context for the reason the session was disconnected internally.
Type Declaration
| Name | Type | Defined in |
|---|---|---|
reason | "disconnect" | source/sse-session/types.ts:120 |
SSESessionDisconnectRemoteContext
type SSESessionDisconnectRemoteContext = object;Defined in: source/sse-session/types.ts:126
Discriminated context for the reason the session was disconnected remotely.
SSESessionEventCallbacks
type SSESessionEventCallbacks = object;Defined in: source/sse-session/types.ts:45
Properties
onConnected
onConnected: () => void;Defined in: source/sse-session/types.ts:50
Called after the HTTP stream is established and before body reading begins.
Returns
void
onDisconnected
onDisconnected: () => void;Defined in: source/sse-session/types.ts:57
Called when the active transport ends — including SSESession.disconnect, server stream completion, and errors. Not paired with SSESessionEventCallbacks.onConnected when the initial connect never succeeds.
Returns
void
onError
onError: (error) => void;Defined in: source/sse-session/types.ts:63
Called on fetch or read failures. Not invoked for intentional SSESession.disconnect disconnects.
Parameters
| Parameter | Type |
|---|---|
error | Error |
Returns
void
SSESessionEventMap
type SSESessionEventMap = object;Defined in: source/sse-session/types.ts:152
Events emitted by SSESession.
"connected"— HTTP stream established."message"— A complete SSE event was parsed."disconnected"— The active transport ended (including SSESession.disconnect)."error"— An unexpected fetch or read failure."closed"— SSESession.close was called.
SSESessionOperationContext
type SSESessionOperationContext = object;Defined in: source/sse-session/types.ts:112
Context from the source that triggered the event.
SSESessionOptions
type SSESessionOptions = SSESessionCallbacks & SSERequestInit & SSERequestFunction & SSESessionRetryInterface & SSELifecycleOptions & SSEParser;Defined in: source/sse-session/types.ts:164
Configuration for SSESession.
SSESessionRetryInterface
type SSESessionRetryInterface = object;Defined in: source/sse-session/types.ts:66
Properties
retry
retry: object;Defined in: source/sse-session/types.ts:73
Retry policy used while establishing the HTTP connection in SSESession.connect. Defaults to ExponentialBackoff with unlimited attempts.
| Name | Type | Defined in |
|---|---|---|
run() | (fn, options?) => Promise<T> | source/sse-session/types.ts:74 |
bchVmVersionSchema
const bchVmVersionSchema: z.ZodEnum<{
BCH_2020_05: "BCH_2020_05";
BCH_2021_05: "BCH_2021_05";
BCH_2022_05: "BCH_2022_05";
BCH_2023_05: "BCH_2023_05";
BCH_2024_05: "BCH_2024_05";
BCH_2025_05: "BCH_2025_05";
BCH_2026_05: "BCH_2026_05";
}>;Defined in: source/template/schemas.ts:22
Validation schema for a BCH VM version identifier. Defines the set of known BCH VM versions that XO templates declare support for.
Uses BchVmVersions from @xo-cash/types so template validation stays aligned with the BchVmVersion type.
{
"supported": [ "BCH_2025_05" ] ← each value
}buildErrorDescription
const buildErrorDescription: (issues) => string;Defined in: source/errors.ts:10
Formats the Zod validation failures into a single string with one line each: "- <field>: <message>" and top level failures with no field path show as "(root)" for better readability.
Parameters
| Parameter | Type | Description |
|---|---|---|
issues | $ZodIssue[] | The Zod validation failures to format. |
Returns
string
A human readable error string for better debugging.
collectVariablesUsingParseScript
const collectVariablesUsingParseScript: (evaluation, templateScripts?) => string[];Defined in: source/cash-assembly/collect-evaluations.ts:211
Collects WalletData names from the parseScript tree using the visitor pattern.
parseScript returns a tree of Script, Push, Evaluation, and Identifier nodes. Nested Push and Evaluation nodes are entered immediately. A template script id is queued whether it appears inside a Push or next to opcodes. Queued script sources are visited after the current tree finishes, in the order they were first seen. A visited id is skipped on later encounters. Opcodes and literals are ignored. Unrelated scripts in the map are not visited. An Identifier inside a nested Push is collected from that inner Push, for example <$(<someKey.public_key> OP_HASH160)> collects someKey.public_key.
Parameters
| Parameter | Type | Description |
|---|---|---|
evaluation | string | CashAssembly evaluation or script id text to scan. |
templateScripts? | CashAssemblyTemplateScripts | Optional template scripts map used to visit nested script ids. |
Returns
string[]
- WalletData names from reachable Pushes. Script ids are omitted when
templateScriptsis provided.
Throws
CashAssemblyCompilationFailedError - When parseScript rejects the starting text or a visited script source.
compileCashAssemblyString
const compileCashAssemblyString: (parameters) => string;Defined in: source/cash-assembly/evaluations.ts:383
Compiles CashAssembly text. WalletData names come from parseScript. $() evaluations in text are found by scanning the string and matching parentheses.
When cashAssemblyText contains $(), each non empty evaluation is compiled and replaced in place. Empty $() is copied through. Surrounding text is kept. Evaluation drops push opcodes and keeps the stack payload.
When cashAssemblyText contains no $() at all, the entire string is compiled as CashAssembly. Push opcodes from <...> remain. Pass a template script id such as scriptA or concatenated ids such as scriptA scriptB.
Required WalletData names come from collectVariablesUsingParseScript.
Parameters
| Parameter | Type | Description |
|---|---|---|
parameters | CompileCashAssemblyStringParameters | Parameters for compiling the CashAssembly string. |
Returns
string
- Compiled text with evaluations replaced, or decoded bytecode when the whole string is compiled as CashAssembly.
Throws
CashAssemblyRequiredVariableMissingError - When a required variable is not present in the variables map.
Throws
CashAssemblyPrimitiveMethodMissingError - When a supported primitive hint has an unknown method.
Throws
CashAssemblyPrimitiveVariableMissingError - When a supported primitive method is missing its runtime value.
Throws
CashAssemblyUnsupportedValueTypeError - When a primitive method return type cannot be embedded as bytes.
Throws
CashAssemblyNumberNotSafeIntegerError - When a number variable is not a safe integer.
Throws
CashAssemblyVmNumberDecodeError - When evaluationDecodeMode is bigint and compiled bytes are not a VM number.
Throws
CashAssemblyIdentifierCollisionError - When one identifier matches two resolution types.
Throws
CashAssemblyCompilationFailedError - When Libauth compilation fails.
Throws
CashAssemblyEvaluationUnclosedError - When an evaluation never closes.
Throws
CashAssemblyQuotedLiteralUnclosedError - When a quoted literal never closes.
Throws
CashAssemblyBlockCommentUnclosedError - When a block comment never closes.
deepFreeze
const deepFreeze: <T>(value) => DeeplyReadonly<T>;Defined in: source/misc.ts:8
Recursively freezes an object by iterating over all properties and freezing them.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
value | T |
Returns
DeeplyReadonly<T>
The frozen object.
deserializeInvitation
const deserializeInvitation: (serializedInvitation) => XOInvitation;Defined in: source/invitation/serialization.ts:34
Deserializes a shared invitation JSON string into an invitation.
Every field is checked against its declared type, so the returned invitation can be trusted to match XOInvitation.
Parameters
| Parameter | Type | Description |
|---|---|---|
serializedInvitation | string | JSON produced by serializeInvitation. |
Returns
Parsed invitation whose fields match their declared types.
Throws
When the string is not valid JSON.
Throws
When the parsed value does not match the XOInvitation type.
extendedJsonReplacer
const extendedJsonReplacer: (_propertyKey, value) => unknown;Defined in: source/extended-json.ts:31
The JSON replacer that encodes bigint and Uint8Array values in Extended JSON format, compatible with the format expected by extendedJsonReviver.
- BigInts are encoded as
<bigint: 123n>. - Uint8Arrays are encoded as
<uint8array: abcd>. All other values pass through unchanged and if any incompatible type is encountered, an error is thrown.
Note: To use this function, pass it as the second argument to JSON.stringify when serializing data.
Note to developers: Libauth's stringify is the replacer. It also serializes functions and symbols, which we do not support. Passing it would let templates include those values, but revival would then fail. This module provides a dedicated replacer and reviver so serialization and deserialization stay aligned.
Parameters
| Parameter | Type | Description |
|---|---|---|
_propertyKey | string | The property key being serialized, required by the JSON.stringify replacer but not used here. |
value | unknown | The value to encode or pass through unchanged. |
Returns
unknown
The encoded string
extendedJsonReviver
const extendedJsonReviver: (_propertyKey, value) => unknown;Defined in: source/extended-json.ts:52
The JSON reviver that reconstructs bigint and Uint8Array values encoded by extendedJsonReplacer.
Note: To use this function, pass it as the second argument to JSON.parse when deserializing data.
Parameters
| Parameter | Type | Description |
|---|---|---|
_propertyKey | string | The property key being deserialized, required by the JSON.parse reviver but not used here. |
value | unknown | The value to reconstruct or pass through unchanged. |
Returns
unknown
The reconstructed value
extractCashAssemblyEvaluations
const extractCashAssemblyEvaluations: (cashAssemblyText) => string[];Defined in: source/cash-assembly/scan-evaluations.ts:235
This function returns each $() that starts in this string. Empty $() is omitted.
Parameters
| Parameter | Type | Description |
|---|---|---|
cashAssemblyText | string | Text that may contain $(). |
Returns
string[]
- Complete non empty evaluation strings in left to right order.
Throws
CashAssemblyEvaluationUnclosedError - When an evaluation never closes.
Throws
CashAssemblyQuotedLiteralUnclosedError - When a quoted literal never closes.
Throws
CashAssemblyBlockCommentUnclosedError - When a block comment never closes.
fromExtendedJson
const fromExtendedJson: (serializedObject) => unknown;Defined in: source/extended-json.ts:94
Deserializes a string to an object using the extendedJsonReviver.
Parameters
| Parameter | Type | Description |
|---|---|---|
serializedObject | string | The string to deserialize. |
Returns
unknown
The object reconstructed from the string.
generateTemplateIdentifier
const generateTemplateIdentifier: (template) => string;Defined in: source/template/identifier.ts:13
Generates a deterministic template identifier by hashing the template.
Note: This expects a template that has been validated by parseTemplate.
Parameters
| Parameter | Type | Description |
|---|---|---|
template | XOTemplate | The template to generate an identifier for. |
Returns
string
The sha256 hex identifier for the template.
isCashAssemblyExpression
const isCashAssemblyExpression: (expression) => boolean;Defined in: source/cash-assembly/scan-evaluations.ts:256
This function returns true when the value is exactly one CashAssembly $(). Text with characters outside $(), empty $(), or a failed scan returns false.
Parameters
| Parameter | Type | Description |
|---|---|---|
expression | unknown | Value to test. |
Returns
boolean
- True when the value is a string that is one complete evaluation and nothing else.
isWithinBounds
const isWithinBounds: (value, min, max) => boolean;Defined in: source/misc.ts:33
Validate the value is within the bounds, returning true if it is within the bounds, false otherwise
Parameters
| Parameter | Type | Description |
|---|---|---|
value | number | The value to validate |
min | number | The minimum value |
max | number | The maximum value |
Returns
boolean
True if the value is within the bounds, false otherwise
normalizeError
const normalizeError: (error) => Error;Defined in: source/misc.ts:46
Converts a non-error to an error
Parameters
| Parameter | Type | Description |
|---|---|---|
error | unknown | The error to convert |
Returns
Error
The error
outputTokenSchema
const outputTokenSchema: z.ZodObject<{
amount: z.ZodBigInt;
category: z.ZodInstanceOf<Uint8Array<ArrayBuffer>>;
nft: z.ZodExactOptional<z.ZodObject<{
capability: z.ZodEnum<{
MINTING: "minting";
MUTABLE: "mutable";
NONE: "none";
}>;
commitment: z.ZodInstanceOf<Uint8Array<ArrayBuffer>>;
}, z.core.$strict>>;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:62
Validation schema for a cashtoken.
parseInvitation
const parseInvitation: (invitationValue) => XOInvitation;Defined in: source/invitation/parser.ts:19
Validates an untyped value against the XOInvitation schema and returns it as a typed invitation.
The schema parser returns a rebuilt copy whose keys follow the schema order. Commit signatures cover the JSON text of each commit's data, and that text depends on key order, so a rebuilt copy no longer matches its signatures. Only the value that was received keeps the order it was signed with.
The received value itself is returned, not a copy, so the key order its commit signatures were made over is kept.
Parameters
| Parameter | Type | Description |
|---|---|---|
invitationValue | unknown | Value to validate, such as the output of Extended JSON parsing. |
Returns
- The validated invitation, as the same object that was passed in.
Throws
InvitationInvalidError - When any field is missing, has the wrong type, or is not part of the invitation type.
parseTemplate
const parseTemplate: (inputTemplate) => XOTemplate;Defined in: source/template/parser.ts:18
Accepts a template value and returns a validated XOTemplate object. The input may be either an Extended JSON string or a pre-parsed object. Both are validated against the XOTemplate schema.
Parameters
| Parameter | Type | Description |
|---|---|---|
inputTemplate | string | XOTemplate | The value to validate. May be an Extended JSON string or a pre-parsed object. |
Returns
The validated template object
Throws
If a pre-parsed object input cannot be serialized to JSON for normalization.
Throws
If the string input is not valid JSON.
Throws
If the value does not conform to the XOTemplate schema.
satoshisSchema
const satoshisSchema: z.ZodBigInt;Defined in: source/template/schemas.ts:79
Validation schema for the Satoshis type i.e. bigint.
scriptToScriptHash
const scriptToScriptHash: (script) => string;Defined in: source/script.ts:8
Converts a script to a scriptHash.
Parameters
| Parameter | Type | Description |
|---|---|---|
script | Uint8Array | The script to convert. |
Returns
string
The scriptHash as a reversed hex string.
serializeInvitation
const serializeInvitation: (invitation) => string;Defined in: source/invitation/serialization.ts:13
Serializes an invitation for sharing. Encodes bigint and Uint8Array fields using Extended JSON.
Parameters
| Parameter | Type | Description |
|---|---|---|
invitation | XOInvitation | Shared invitation to export. |
Returns
string
JSON string that deserializeInvitation can restore.
Throws
When JSON serialization fails.
serializeTemplate
const serializeTemplate: (template) => string;Defined in: source/template/serialization.ts:13
Serializes an XOTemplate to a JSON string. Encodes bigint and Uint8Array fields in Extended JSON format so they can be reconstructed by deserializeTemplate.
Parameters
| Parameter | Type | Description |
|---|---|---|
template | XOTemplate | The template to serialize. |
Returns
string
A JSON string representation of the template.
Throws
If the template cannot be serialized to JSON.
toExtendedJson
const toExtendedJson: (object) => string;Defined in: source/extended-json.ts:84
Serializes an object to a string using the extendedJsonReplacer.
Parameters
| Parameter | Type | Description |
|---|---|---|
object | unknown | The object to serialize. |
Returns
string
The string representation of the object in Extended JSON format.
uint8ArraySchema
const uint8ArraySchema: z.ZodInstanceOf<Uint8Array<ArrayBuffer>>;Defined in: source/template/schemas.ts:74
Validation schema for byte array fields i.e. Uint8Array instance.
VIEW_PROPERTIES_DESCRIPTION_MAX_LENGTH
const VIEW_PROPERTIES_DESCRIPTION_MAX_LENGTH: 5000 = 5000;Defined in: source/template/schemas.ts:89
Maximum character length for description fields on view properties.
VIEW_PROPERTIES_ICON_MAX_LENGTH
const VIEW_PROPERTIES_ICON_MAX_LENGTH: 1000 = 1000;Defined in: source/template/schemas.ts:92
Maximum character length for icon fields on view properties.
VIEW_PROPERTIES_NAME_MAX_LENGTH
const VIEW_PROPERTIES_NAME_MAX_LENGTH: 1000 = 1000;Defined in: source/template/schemas.ts:86
Maximum character length for name fields on view properties.
xoInvitationActionReferenceSchema
const xoInvitationActionReferenceSchema: z.ZodObject<{
actionIdentifier: z.ZodString;
templateIdentifier: z.ZodString;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:29
Validation schema for the template action a commit is resolved against when it differs from the invitation root.
xoInvitationCommitDataSchema
const xoInvitationCommitDataSchema: z.ZodObject<{
inputs: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
inputIdentifier: z.ZodExactOptional<z.ZodString>;
mergesWith: z.ZodExactOptional<z.ZodObject<{
commitIdentifier: z.ZodString;
itemIndex: z.ZodNumber;
}, z.core.$strict>>;
outpointIndex: z.ZodExactOptional<z.ZodNumber>;
outpointTransactionHash: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<ArrayBuffer>>>;
resolutions: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
resolutionIdentifier: z.ZodString;
roleIdentifier: z.ZodExactOptional<...>;
value: z.ZodInstanceOf<...>;
}, z.core.$strict>>>;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
sequenceNumber: z.ZodExactOptional<z.ZodNumber>;
token: z.ZodExactOptional<z.ZodObject<{
amount: z.ZodBigInt;
category: z.ZodInstanceOf<Uint8Array<...>>;
nft: z.ZodExactOptional<z.ZodObject<..., ...>>;
}, z.core.$strict>>;
transactionIndex: z.ZodExactOptional<z.ZodNumber>;
unlockingBytecode: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<ArrayBuffer>>>;
valueSatoshis: z.ZodExactOptional<z.ZodBigInt>;
}, z.core.$strict>>>;
outputs: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
lockingBytecode: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<ArrayBuffer>>>;
mergesWith: z.ZodExactOptional<z.ZodObject<{
commitIdentifier: z.ZodString;
itemIndex: z.ZodNumber;
}, z.core.$strict>>;
outputIdentifier: z.ZodExactOptional<z.ZodString>;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
secretIdentifier: z.ZodExactOptional<z.ZodString>;
token: z.ZodExactOptional<z.ZodObject<{
amount: z.ZodExactOptional<z.ZodBigInt>;
category: z.ZodExactOptional<z.ZodInstanceOf<...>>;
nft: z.ZodExactOptional<z.ZodObject<..., ...>>;
}, z.core.$strict>>;
transactionIndex: z.ZodExactOptional<z.ZodNumber>;
valueSatoshis: z.ZodExactOptional<z.ZodBigInt>;
}, z.core.$strict>>>;
resolutions: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
resolutionIdentifier: z.ZodString;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
value: z.ZodInstanceOf<Uint8Array<ArrayBuffer>>;
}, z.core.$strict>>>;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
transactionLocktime: z.ZodExactOptional<z.ZodNumber>;
transactionVersion: z.ZodExactOptional<z.ZodNumber>;
variables: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
mergesWith: z.ZodExactOptional<z.ZodObject<{
commitIdentifier: z.ZodString;
itemIndex: z.ZodNumber;
}, z.core.$strict>>;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
value: z.ZodUnion<readonly [z.ZodBigInt, z.ZodBoolean, z.ZodNumber, z.ZodString]>;
variableIdentifier: z.ZodString;
}, z.core.$strict>>>;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:143
Validation schema for the data a commit supplies.
xoInvitationCommitSchema
const xoInvitationCommitSchema: z.ZodObject<{
actionReference: z.ZodExactOptional<z.ZodObject<{
actionIdentifier: z.ZodString;
templateIdentifier: z.ZodString;
}, z.core.$strict>>;
commitIdentifier: z.ZodString;
createdAtTimestamp: z.ZodNumber;
data: z.ZodObject<{
inputs: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
inputIdentifier: z.ZodExactOptional<z.ZodString>;
mergesWith: z.ZodExactOptional<z.ZodObject<{
commitIdentifier: ...;
itemIndex: ...;
}, z.core.$strict>>;
outpointIndex: z.ZodExactOptional<z.ZodNumber>;
outpointTransactionHash: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<...>>>;
resolutions: z.ZodExactOptional<z.ZodArray<z.ZodObject<..., ...>>>;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
sequenceNumber: z.ZodExactOptional<z.ZodNumber>;
token: z.ZodExactOptional<z.ZodObject<{
amount: ...;
category: ...;
nft: ...;
}, z.core.$strict>>;
transactionIndex: z.ZodExactOptional<z.ZodNumber>;
unlockingBytecode: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<...>>>;
valueSatoshis: z.ZodExactOptional<z.ZodBigInt>;
}, z.core.$strict>>>;
outputs: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
lockingBytecode: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<...>>>;
mergesWith: z.ZodExactOptional<z.ZodObject<{
commitIdentifier: ...;
itemIndex: ...;
}, z.core.$strict>>;
outputIdentifier: z.ZodExactOptional<z.ZodString>;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
secretIdentifier: z.ZodExactOptional<z.ZodString>;
token: z.ZodExactOptional<z.ZodObject<{
amount: ...;
category: ...;
nft: ...;
}, z.core.$strict>>;
transactionIndex: z.ZodExactOptional<z.ZodNumber>;
valueSatoshis: z.ZodExactOptional<z.ZodBigInt>;
}, z.core.$strict>>>;
resolutions: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
resolutionIdentifier: z.ZodString;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
value: z.ZodInstanceOf<Uint8Array<ArrayBuffer>>;
}, z.core.$strict>>>;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
transactionLocktime: z.ZodExactOptional<z.ZodNumber>;
transactionVersion: z.ZodExactOptional<z.ZodNumber>;
variables: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
mergesWith: z.ZodExactOptional<z.ZodObject<{
commitIdentifier: ...;
itemIndex: ...;
}, z.core.$strict>>;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
value: z.ZodUnion<readonly [..., ..., ..., ...]>;
variableIdentifier: z.ZodString;
}, z.core.$strict>>>;
}, z.core.$strict>;
entityIdentifier: z.ZodString;
expiresAtTimestamp: z.ZodNumber;
memo: z.ZodExactOptional<z.ZodString>;
previousCommitIdentifier: z.ZodPrefault<z.ZodOptional<z.ZodString>>;
signature: z.ZodString;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:158
Validation schema for one signed commit in an invitation.
xoInvitationCreatedResultSchema
const xoInvitationCreatedResultSchema: z.ZodObject<{
createdAtTimestamp: z.ZodNumber;
createdByEntityIdentifier: z.ZodString;
createdBySignature: z.ZodString;
value: z.ZodUnion<readonly [z.ZodBigInt, z.ZodBoolean, z.ZodNumber, z.ZodString]>;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:204
Validation schema for a data result created on an invitation.
xoInvitationInputSchema
const xoInvitationInputSchema: z.ZodObject<{
inputIdentifier: z.ZodExactOptional<z.ZodString>;
mergesWith: z.ZodExactOptional<z.ZodObject<{
commitIdentifier: z.ZodString;
itemIndex: z.ZodNumber;
}, z.core.$strict>>;
outpointIndex: z.ZodExactOptional<z.ZodNumber>;
outpointTransactionHash: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<ArrayBuffer>>>;
resolutions: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
resolutionIdentifier: z.ZodString;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
value: z.ZodInstanceOf<Uint8Array<ArrayBuffer>>;
}, z.core.$strict>>>;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
sequenceNumber: z.ZodExactOptional<z.ZodNumber>;
token: z.ZodExactOptional<z.ZodObject<{
amount: z.ZodBigInt;
category: z.ZodInstanceOf<Uint8Array<ArrayBuffer>>;
nft: z.ZodExactOptional<z.ZodObject<{
capability: z.ZodEnum<{
MINTING: "minting";
MUTABLE: "mutable";
NONE: "none";
}>;
commitment: z.ZodInstanceOf<Uint8Array<ArrayBuffer>>;
}, z.core.$strict>>;
}, z.core.$strict>>;
transactionIndex: z.ZodExactOptional<z.ZodNumber>;
unlockingBytecode: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<ArrayBuffer>>>;
valueSatoshis: z.ZodExactOptional<z.ZodBigInt>;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:108
Validation schema for a transaction input supplied by a commit.
xoInvitationMergesWithReferenceSchema
const xoInvitationMergesWithReferenceSchema: z.ZodObject<{
commitIdentifier: z.ZodString;
itemIndex: z.ZodNumber;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:19
Validation schema for a reference to an input or output in an earlier commit that a later item extends.
{
"inputs|outputs": [
{
"mergesWith": { "commitIdentifier": "...", "itemIndex": 0 } ← this schema
}
]
}xoInvitationOutputSchema
const xoInvitationOutputSchema: z.ZodObject<{
lockingBytecode: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<ArrayBuffer>>>;
mergesWith: z.ZodExactOptional<z.ZodObject<{
commitIdentifier: z.ZodString;
itemIndex: z.ZodNumber;
}, z.core.$strict>>;
outputIdentifier: z.ZodExactOptional<z.ZodString>;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
secretIdentifier: z.ZodExactOptional<z.ZodString>;
token: z.ZodExactOptional<z.ZodObject<{
amount: z.ZodExactOptional<z.ZodBigInt>;
category: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<ArrayBuffer>>>;
nft: z.ZodExactOptional<z.ZodObject<{
capability: z.ZodExactOptional<z.ZodEnum<{
MINTING: ...;
MUTABLE: ...;
NONE: ...;
}>>;
commitment: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<...>>>;
}, z.core.$strict>>;
}, z.core.$strict>>;
transactionIndex: z.ZodExactOptional<z.ZodNumber>;
valueSatoshis: z.ZodExactOptional<z.ZodBigInt>;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:127
Validation schema for a transaction output supplied by a commit.
xoInvitationResolutionSchema
const xoInvitationResolutionSchema: z.ZodObject<{
resolutionIdentifier: z.ZodString;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
value: z.ZodInstanceOf<Uint8Array<ArrayBuffer>>;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:97
Validation schema for a value one participant resolved from its own template key, such as a public key or a signature.
xoInvitationResultSchema
const xoInvitationResultSchema: z.ZodObject<{
data: z.ZodExactOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
createdAtTimestamp: z.ZodNumber;
createdByEntityIdentifier: z.ZodString;
createdBySignature: z.ZodString;
value: z.ZodUnion<readonly [z.ZodBigInt, z.ZodBoolean, z.ZodNumber, z.ZodString]>;
}, z.core.$strict>>>;
transactions: z.ZodExactOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
broadcastedAtTimestamp: z.ZodNumber;
broadcastedByEntityIdentifier: z.ZodString;
broadcastedBySignature: z.ZodString;
createdAtTimestamp: z.ZodNumber;
createdByEntityIdentifier: z.ZodString;
createdBySignature: z.ZodString;
transactionHash: z.ZodString;
}, z.core.$strict>, z.ZodObject<{
createdAtTimestamp: z.ZodNumber;
createdByEntityIdentifier: z.ZodString;
createdBySignature: z.ZodString;
transactionHash: z.ZodString;
}, z.core.$strict>]>>>;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:216
Validation schema for the results created on an invitation.
xoInvitationSchema
const xoInvitationSchema: z.ZodType<XOInvitation>;Defined in: source/invitation/schemas.ts:232
Validation schema for an invitation.
xoInvitationTokenSchema
const xoInvitationTokenSchema: z.ZodObject<{
amount: z.ZodExactOptional<z.ZodBigInt>;
category: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<ArrayBuffer>>>;
nft: z.ZodExactOptional<z.ZodObject<{
capability: z.ZodExactOptional<z.ZodEnum<{
MINTING: "minting";
MUTABLE: "mutable";
NONE: "none";
}>>;
commitment: z.ZodExactOptional<z.ZodInstanceOf<Uint8Array<ArrayBuffer>>>;
}, z.core.$strict>>;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:80
Validation schema for a cashtoken supplied by a commit output. Every field is optional because a later commit may supply the fields an earlier commit left unset.
xoInvitationTransactionBroadcastedResultSchema
const xoInvitationTransactionBroadcastedResultSchema: z.ZodObject<{
broadcastedAtTimestamp: z.ZodNumber;
broadcastedByEntityIdentifier: z.ZodString;
broadcastedBySignature: z.ZodString;
createdAtTimestamp: z.ZodNumber;
createdByEntityIdentifier: z.ZodString;
createdBySignature: z.ZodString;
transactionHash: z.ZodString;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:193
Validation schema for a transaction result that has been created and broadcast.
xoInvitationTransactionCreatedResultSchema
const xoInvitationTransactionCreatedResultSchema: z.ZodObject<{
createdAtTimestamp: z.ZodNumber;
createdByEntityIdentifier: z.ZodString;
createdBySignature: z.ZodString;
transactionHash: z.ZodString;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:181
Validation schema for a transaction result that has been created but not broadcast.
xoInvitationVariableSchema
const xoInvitationVariableSchema: z.ZodObject<{
mergesWith: z.ZodExactOptional<z.ZodObject<{
commitIdentifier: z.ZodString;
itemIndex: z.ZodNumber;
}, z.core.$strict>>;
roleIdentifier: z.ZodExactOptional<z.ZodString>;
value: z.ZodUnion<readonly [z.ZodBigInt, z.ZodBoolean, z.ZodNumber, z.ZodString]>;
variableIdentifier: z.ZodString;
}, z.core.$strict>;Defined in: source/invitation/schemas.ts:50
Validation schema for a variable supplied by a commit.
xoInvitationVariableValueSchema
const xoInvitationVariableValueSchema: z.ZodUnion<readonly [z.ZodBigInt, z.ZodBoolean, z.ZodNumber, z.ZodString]>;Defined in: source/invitation/schemas.ts:43
Validation schema for a variable value. Matches every value type an invitation variable can hold.
xoTemplateActionIntentSchema
const xoTemplateActionIntentSchema: z.ZodObject<{
action: z.ZodString;
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:163
Validation schema for an action intent. Extends the base intent structure with an action identifier. Used in locking script action lists and in the template's start array.
{
"start": [
{ "action": "..." } ← this schema
],
"lockingScripts": {
"[id]": {
"actions": [
{ "action": "..." } ← this schema
],
"roles": {
"[roleId]": {
"actions": [
{ "action": "..." } ← this schema
]
}
}
}
}
}xoTemplateActionRequirementsSchema
const xoTemplateActionRequirementsSchema: z.ZodObject<{
participants: z.ZodOptional<z.ZodArray<z.ZodObject<{
role: z.ZodString;
slots: z.ZodObject<{
max: z.ZodOptional<z.ZodNumber>;
min: z.ZodNumber;
}, z.core.$strict>;
}, z.core.$strict>>>;
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:323
Validation schema for the requirements of an action.
{
"actions": {
"[id]": {
"requirements": { "variables": [], "participants": [], "secrets": [] } ← this schema
}
}
}xoTemplateActionRoleRequirementsSchema
const xoTemplateActionRoleRequirementsSchema: z.ZodObject<{
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:247
Validation schema for the capability requirements declared on a role within an action. Describes what data, secrets, or state the role is responsible for providing when participating in an action.
{
"actions": {
"[id]": {
"roles": {
"[roleId]": {
"requirements": { "variables": [], "secrets": [] } ← this schema
}
}
}
}
}xoTemplateActionRoleSchema
const xoTemplateActionRoleSchema: z.ZodObject<{
description: z.ZodOptional<z.ZodString>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
icon: z.ZodOptional<z.ZodOptional<z.ZodString>>;
name: z.ZodOptional<z.ZodString>;
requirements: z.ZodOptional<z.ZodObject<{
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:270
Validation schema for a role-specific definition within an action. All view properties are optional.
{
"actions": {
"[id]": {
"roles": {
"[roleId]": { } ← this schema
}
}
}
}xoTemplateActionSchema
const xoTemplateActionSchema: z.ZodObject<{
conditions: z.ZodOptional<z.ZodArray<z.ZodString>>;
data: z.ZodOptional<z.ZodString>;
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
name: z.ZodString;
requirements: z.ZodOptional<z.ZodObject<{
participants: z.ZodOptional<z.ZodArray<z.ZodObject<{
role: z.ZodString;
slots: z.ZodObject<{
max: ...;
min: ...;
}, z.core.$strict>;
}, z.core.$strict>>>;
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
description: z.ZodOptional<z.ZodString>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
icon: z.ZodOptional<z.ZodOptional<z.ZodString>>;
name: z.ZodOptional<z.ZodString>;
requirements: z.ZodOptional<z.ZodObject<{
secrets: z.ZodOptional<z.ZodArray<...>>;
variables: z.ZodOptional<z.ZodArray<...>>;
}, z.core.$strict>>;
}, z.core.$strict>>>;
transaction: z.ZodOptional<z.ZodString>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:342
Validation schema for an action definition.
{
"actions": {
"[id]": { } ← this schema
}
}xoTemplateAssetAmountsSchema
const xoTemplateAssetAmountsSchema: z.ZodObject<{
fungibleTokens: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodLiteral<true>]>>;
nonfungibleTokens: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodString, z.ZodLiteral<true>]>>;
satoshis: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodLiteral<true>]>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:424
Validation schema for the asset amounts configuration. Used by omitChangeAmounts on inputs and by balance on locking scripts, outputs, and their roles.
xoTemplateConstantSchema
const xoTemplateConstantSchema: z.ZodObject<{
description: z.ZodString;
hint: z.ZodOptional<z.ZodUnknown>;
icon: z.ZodOptional<z.ZodString>;
name: z.ZodString;
type: z.ZodEnum<{
BIGINT: "bigint";
BOOLEAN: "boolean";
BYTES: "bytes";
EXTENDED_PUBLIC_KEY: "extended_public_key";
FUNGIBLE_TOKEN_AMOUNT: "token_amount";
INTEGER: "integer";
LOCKING_SCRIPT: "locking_script";
NFT_COMMITMENT: "nft_commitment";
NON_FUNGIBLE_TOKEN_CAPABILITY: "token_capability";
NON_FUNGIBLE_TOKEN_COMMITMENT: "token_commitment";
PRIVATE_KEY: "private_key";
PUBLIC_KEY: "public_key";
SATOSHIS: "satoshis";
SCHNORR_SIGNATURE: "signature";
STRING: "string";
TEMPLATE_IDENTIFIER: "template_identifier";
TIMESTAMP: "timestamp";
TOKEN_CATEGORY: "token_category";
TRANSACTION_HASH: "transaction_hash";
}>;
value: z.ZodUnknown;
}, z.core.$strict>;Defined in: source/template/schemas.ts:738
Validation schema for a constant value definition.
{
"constants": {
"[id]": { } ← this schema
}
}xoTemplateDataSchema
const xoTemplateDataSchema: z.ZodObject<{
hint: z.ZodOptional<z.ZodUnknown>;
type: z.ZodEnum<{
BIGINT: "bigint";
BOOLEAN: "boolean";
BYTES: "bytes";
EXTENDED_PUBLIC_KEY: "extended_public_key";
FUNGIBLE_TOKEN_AMOUNT: "token_amount";
INTEGER: "integer";
LOCKING_SCRIPT: "locking_script";
NFT_COMMITMENT: "nft_commitment";
NON_FUNGIBLE_TOKEN_CAPABILITY: "token_capability";
NON_FUNGIBLE_TOKEN_COMMITMENT: "token_commitment";
PRIVATE_KEY: "private_key";
PUBLIC_KEY: "public_key";
SATOSHIS: "satoshis";
SCHNORR_SIGNATURE: "signature";
STRING: "string";
TEMPLATE_IDENTIFIER: "template_identifier";
TIMESTAMP: "timestamp";
TOKEN_CATEGORY: "token_category";
TRANSACTION_HASH: "transaction_hash";
}>;
value: z.ZodUnknown;
}, z.core.$strict>;Defined in: source/template/schemas.ts:757
Validation schema for a data field definition.
{
"data": {
"[id]": { } ← this schema
}
}xoTemplateDefaultsSchema
const xoTemplateDefaultsSchema: z.ZodObject<{
address: z.ZodOptional<z.ZodObject<{
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
lockingScript: z.ZodString;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>;
change: z.ZodOptional<z.ZodObject<{
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
output: z.ZodString;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>;
receive: z.ZodOptional<z.ZodObject<{
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
output: z.ZodString;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:863
Validation schema for the defaults block of a template.
{
"defaults": { } ← this schema
}xoTemplateIconSchema
const xoTemplateIconSchema: z.ZodObject<{
hash: z.ZodString;
name: z.ZodString;
}, z.core.$strict>;Defined in: source/template/schemas.ts:843
Validation schema for an icon reference.
{
"icons": [
{ "name": "...", "hash": "..." } ← this schema
]
}xoTemplateImportDefaultValueSchema
const xoTemplateImportDefaultValueSchema: z.ZodObject<{
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
description: z.ZodOptional<z.ZodString>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
icon: z.ZodOptional<z.ZodOptional<z.ZodString>>;
name: z.ZodOptional<z.ZodString>;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:779
Validation schema for an import default value intent. Extends the base intent with optional view properties that the engine evaluates at runtime to produce human-readable output.
{
"variables": {
"[id]": {
"importDefaultValue": { } ← this schema
}
}
}xoTemplateInputSchema
const xoTemplateInputSchema: z.ZodObject<{
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
name: z.ZodString;
omitChangeAmounts: z.ZodOptional<z.ZodObject<{
fungibleTokens: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodLiteral<true>]>>;
nonfungibleTokens: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodString, z.ZodLiteral<true>]>>;
satoshis: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodLiteral<true>]>>;
}, z.core.$strict>>;
sequenceNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
token: z.ZodOptional<z.ZodNullable<z.ZodObject<{
amount: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodNull]>>;
category: z.ZodOptional<z.ZodString>;
nft: z.ZodOptional<z.ZodNullable<z.ZodObject<{
capability: z.ZodOptional<...>;
commitment: z.ZodOptional<...>;
}, z.core.$strict>>>;
}, z.core.$strict>>>;
unlockingScript: z.ZodOptional<z.ZodString>;
valueSatoshis: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString]>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:578
Validation schema for an input definition in the template. Extends view properties with optional satoshi value, token configuration, and other transaction level fields.
{
"inputs": {
"[id]": { } ← this schema
}
}xoTemplateIntentSchema
const xoTemplateIntentSchema: z.ZodObject<{
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:123
Validation schema for the base intent structure. Describes the common data parameters shared by all intent types regardless of what they target.
An optional templateIdentifier allows the intent to reference a target defined in a different template, enabling cross-template interaction.
Extended by: xoTemplateActionIntentSchema, xoTemplateOutputIntentSchema, xoTemplateLockingScriptIntentSchema.
xoTemplateLockingScriptIntentSchema
const xoTemplateLockingScriptIntentSchema: z.ZodObject<{
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
lockingScript: z.ZodString;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:193
Validation schema for a locking script intent. Extends the base intent structure with a locking script identifier.
Todo
The location of this schema in the template JSON is not yet determined.
xoTemplateLockingScriptRoleSchema
const xoTemplateLockingScriptRoleSchema: z.ZodObject<{
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
action: z.ZodString;
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>>;
balance: z.ZodOptional<z.ZodObject<{
fungibleTokens: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodLiteral<...>]>>>;
nonfungibleTokens: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<...>, z.ZodLiteral<...>, z.ZodString, z.ZodLiteral<...>]>>>;
satoshis: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodLiteral<...>]>>>;
}, z.core.$strict>>;
description: z.ZodOptional<z.ZodString>;
icon: z.ZodOptional<z.ZodOptional<z.ZodString>>;
name: z.ZodOptional<z.ZodString>;
privacy: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
relevant: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
selectable: z.ZodOptional<z.ZodBoolean>;
state: z.ZodOptional<z.ZodObject<{
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:511
Validation schema for a role definition for a locking script.
{
"lockingScripts": {
"[id]": {
"roles": {
"[roleId]": { } ← this schema
}
}
}
}xoTemplateLockingScriptSchema
const xoTemplateLockingScriptSchema: z.ZodObject<{
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
action: z.ZodString;
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>>;
balance: z.ZodOptional<z.ZodObject<{
fungibleTokens: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodLiteral<...>]>>>;
nonfungibleTokens: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<...>, z.ZodLiteral<...>, z.ZodString, z.ZodLiteral<...>]>>>;
satoshis: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodLiteral<...>]>>>;
}, z.core.$strict>>;
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
lockingBytecode: z.ZodString;
lockingType: z.ZodOptional<z.ZodEnum<{
P2PKH: "p2pkh";
P2S: "p2s";
P2SH: "p2sh";
}>>;
name: z.ZodString;
privacy: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
action: z.ZodString;
constants: z.ZodOptional<...>;
generate: z.ZodOptional<...>;
role: z.ZodOptional<...>;
secrets: z.ZodOptional<...>;
templateIdentifier: z.ZodOptional<...>;
variables: z.ZodOptional<...>;
}, z.core.$strict>>>;
balance: z.ZodOptional<z.ZodObject<{
fungibleTokens: z.ZodOptional<z.ZodOptional<...>>;
nonfungibleTokens: z.ZodOptional<z.ZodOptional<...>>;
satoshis: z.ZodOptional<z.ZodOptional<...>>;
}, z.core.$strict>>;
description: z.ZodOptional<z.ZodString>;
icon: z.ZodOptional<z.ZodOptional<z.ZodString>>;
name: z.ZodOptional<z.ZodString>;
privacy: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
relevant: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
selectable: z.ZodOptional<z.ZodBoolean>;
state: z.ZodOptional<z.ZodObject<{
secrets: z.ZodOptional<z.ZodArray<...>>;
variables: z.ZodOptional<z.ZodArray<...>>;
}, z.core.$strict>>;
}, z.core.$strict>>>;
selectable: z.ZodOptional<z.ZodBoolean>;
state: z.ZodOptional<z.ZodObject<{
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
unlockingBytecode: z.ZodOptional<z.ZodString>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:541
Validation schema for a locking script definition.
{
"lockingScripts": {
"[id]": { } ← this schema
}
}xoTemplateLockingTypeSchema
const xoTemplateLockingTypeSchema: z.ZodEnum<{
P2PKH: "p2pkh";
P2S: "p2s";
P2SH: "p2sh";
}>;Defined in: source/template/schemas.ts:59
Validation schema for a BCH locking script type. Defines the standard locking script types supported on BCH.
{
"lockingScripts": {
"[id]": {
"lockingType": "p2pkh" ← this schema
}
}
}xoTemplateNftCapabilitySchema
const xoTemplateNftCapabilitySchema: z.ZodEnum<{
MINTING: "minting";
MUTABLE: "mutable";
NONE: "none";
}>;Defined in: source/template/schemas.ts:43
Validation schema for the capability of a non-fungible token. Defines the three capability types supported on BCH: minting tokens can create new NFTs, mutable tokens can update their commitment, and none tokens cannot be changed after creation.
{
"inputs|outputs": {
"[id]": {
"token": {
"nft": {
"capability": "minting" ← this schema
}
}
}
}
}xoTemplateNonFungibleTokenDetailsSchema
const xoTemplateNonFungibleTokenDetailsSchema: z.ZodObject<{
capability: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
MINTING: "minting";
MUTABLE: "mutable";
NONE: "none";
}>, z.ZodString]>>;
commitment: z.ZodOptional<z.ZodString>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:383
Validation schema for the non-fungible token configuration within a token field.
{
"inputs|outputs": {
"[id]": {
"token": {
"nft": { } ← this schema
}
}
}
}xoTemplateOutputIntentSchema
const xoTemplateOutputIntentSchema: z.ZodObject<{
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
output: z.ZodString;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:181
Validation schema for an output intent. Extends the base intent structure with an output identifier. Used in the template's defaults block.
{
"defaults": {
"change": { "output": "..." } ← this schema
}
}xoTemplateOutputSchema
const xoTemplateOutputSchema: z.ZodObject<{
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
action: z.ZodString;
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>>;
balance: z.ZodOptional<z.ZodObject<{
fungibleTokens: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodLiteral<...>]>>>;
nonfungibleTokens: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<...>, z.ZodLiteral<...>, z.ZodString, z.ZodLiteral<...>]>>>;
satoshis: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodLiteral<...>]>>>;
}, z.core.$strict>>;
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
lockingScript: z.ZodString;
name: z.ZodString;
privacy: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
action: z.ZodString;
constants: z.ZodOptional<...>;
generate: z.ZodOptional<...>;
role: z.ZodOptional<...>;
secrets: z.ZodOptional<...>;
templateIdentifier: z.ZodOptional<...>;
variables: z.ZodOptional<...>;
}, z.core.$strict>>>;
balance: z.ZodOptional<z.ZodObject<{
fungibleTokens: z.ZodOptional<z.ZodOptional<...>>;
nonfungibleTokens: z.ZodOptional<z.ZodOptional<...>>;
satoshis: z.ZodOptional<z.ZodOptional<...>>;
}, z.core.$strict>>;
description: z.ZodOptional<z.ZodString>;
icon: z.ZodOptional<z.ZodOptional<z.ZodString>>;
name: z.ZodOptional<z.ZodString>;
privacy: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
relevant: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
selectable: z.ZodOptional<z.ZodBoolean>;
state: z.ZodOptional<z.ZodObject<{
secrets: z.ZodOptional<z.ZodArray<...>>;
variables: z.ZodOptional<z.ZodArray<...>>;
}, z.core.$strict>>;
}, z.core.$strict>>>;
selectable: z.ZodOptional<z.ZodBoolean>;
state: z.ZodOptional<z.ZodObject<{
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
token: z.ZodOptional<z.ZodNullable<z.ZodObject<{
amount: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodNull]>>;
category: z.ZodOptional<z.ZodString>;
nft: z.ZodOptional<z.ZodNullable<z.ZodObject<{
capability: z.ZodOptional<...>;
commitment: z.ZodOptional<...>;
}, z.core.$strict>>>;
}, z.core.$strict>>>;
valueSatoshis: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString]>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:612
Validation schema for an output definition. Extends the locking script schema so that every output inherits the same locking script fields and adds output-specific fields.
{
"outputs": {
"[id]": { } ← this schema
}
}xoTemplatePrimitiveTypeSchema
const xoTemplatePrimitiveTypeSchema: z.ZodEnum<{
BIGINT: "bigint";
BOOLEAN: "boolean";
BYTES: "bytes";
EXTENDED_PUBLIC_KEY: "extended_public_key";
FUNGIBLE_TOKEN_AMOUNT: "token_amount";
INTEGER: "integer";
LOCKING_SCRIPT: "locking_script";
NFT_COMMITMENT: "nft_commitment";
NON_FUNGIBLE_TOKEN_CAPABILITY: "token_capability";
NON_FUNGIBLE_TOKEN_COMMITMENT: "token_commitment";
PRIVATE_KEY: "private_key";
PUBLIC_KEY: "public_key";
SATOSHIS: "satoshis";
SCHNORR_SIGNATURE: "signature";
STRING: "string";
TEMPLATE_IDENTIFIER: "template_identifier";
TIMESTAMP: "timestamp";
TOKEN_CATEGORY: "token_category";
TRANSACTION_HASH: "transaction_hash";
}>;Defined in: source/template/schemas.ts:65
Validation schema for a primitive type identifier. Accepts values from XOTemplatePrimitiveTypes for the hint field on constants, variables, and data.
xoTemplateResourceSchema
const xoTemplateResourceSchema: z.ZodObject<{
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
name: z.ZodString;
url: z.ZodString;
}, z.core.$strict>;Defined in: source/template/schemas.ts:826
Validation schema for a resource reference attached to a template element. Extends view properties with a URL pointing to external documentation or tooling.
{
"resources": [
{ "name": "...", "description": "...", "url": "..." } ← this schema
]
}xoTemplateRoleSlotSchema
const xoTemplateRoleSlotSchema: z.ZodObject<{
role: z.ZodString;
slots: z.ZodObject<{
max: z.ZodOptional<z.ZodNumber>;
min: z.ZodNumber;
}, z.core.$strict>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:303
Validation schema for a role participation requirement in an action's requirements block.
{
"actions": {
"[id]": {
"requirements": {
"participants": [
{ "role": "...", "slots": { } } ← this schema
]
}
}
}
}xoTemplateRoleSlotsRequirementsSchema
const xoTemplateRoleSlotsRequirementsSchema: z.ZodObject<{
max: z.ZodOptional<z.ZodNumber>;
min: z.ZodNumber;
}, z.core.$strict>;Defined in: source/template/schemas.ts:222
Validation schema for the slot count configuration on a role requirement. Declares how many participants of a given role are needed. min sets the lower bound and max sets the upper bound. When max is absent, there is no upper limit.
{
"actions": {
"[id]": {
"requirements": {
"participants": [
{ "slots": { "min": 1, "max": 1 } } ← this schema
]
}
}
}
}xoTemplateSchema
const xoTemplateSchema: z.ZodObject<{
$schema: z.ZodString;
actions: z.ZodRecord<z.ZodString, z.ZodObject<{
conditions: z.ZodOptional<z.ZodArray<z.ZodString>>;
data: z.ZodOptional<z.ZodString>;
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
name: z.ZodString;
requirements: z.ZodOptional<z.ZodObject<{
participants: z.ZodOptional<z.ZodArray<z.ZodObject<..., ...>>>;
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
description: z.ZodOptional<z.ZodString>;
generate: z.ZodOptional<z.ZodArray<...>>;
icon: z.ZodOptional<z.ZodOptional<...>>;
name: z.ZodOptional<z.ZodString>;
requirements: z.ZodOptional<z.ZodObject<..., ...>>;
}, z.core.$strict>>>;
transaction: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>;
constants: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
description: z.ZodString;
hint: z.ZodOptional<z.ZodUnknown>;
icon: z.ZodOptional<z.ZodString>;
name: z.ZodString;
type: z.ZodEnum<{
BIGINT: "bigint";
BOOLEAN: "boolean";
BYTES: "bytes";
EXTENDED_PUBLIC_KEY: "extended_public_key";
FUNGIBLE_TOKEN_AMOUNT: "token_amount";
INTEGER: "integer";
LOCKING_SCRIPT: "locking_script";
NFT_COMMITMENT: "nft_commitment";
NON_FUNGIBLE_TOKEN_CAPABILITY: "token_capability";
NON_FUNGIBLE_TOKEN_COMMITMENT: "token_commitment";
PRIVATE_KEY: "private_key";
PUBLIC_KEY: "public_key";
SATOSHIS: "satoshis";
SCHNORR_SIGNATURE: "signature";
STRING: "string";
TEMPLATE_IDENTIFIER: "template_identifier";
TIMESTAMP: "timestamp";
TOKEN_CATEGORY: "token_category";
TRANSACTION_HASH: "transaction_hash";
}>;
value: z.ZodUnknown;
}, z.core.$strict>>>;
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
hint: z.ZodOptional<z.ZodUnknown>;
type: z.ZodEnum<{
BIGINT: "bigint";
BOOLEAN: "boolean";
BYTES: "bytes";
EXTENDED_PUBLIC_KEY: "extended_public_key";
FUNGIBLE_TOKEN_AMOUNT: "token_amount";
INTEGER: "integer";
LOCKING_SCRIPT: "locking_script";
NFT_COMMITMENT: "nft_commitment";
NON_FUNGIBLE_TOKEN_CAPABILITY: "token_capability";
NON_FUNGIBLE_TOKEN_COMMITMENT: "token_commitment";
PRIVATE_KEY: "private_key";
PUBLIC_KEY: "public_key";
SATOSHIS: "satoshis";
SCHNORR_SIGNATURE: "signature";
STRING: "string";
TEMPLATE_IDENTIFIER: "template_identifier";
TIMESTAMP: "timestamp";
TOKEN_CATEGORY: "token_category";
TRANSACTION_HASH: "transaction_hash";
}>;
value: z.ZodUnknown;
}, z.core.$strict>>>;
defaults: z.ZodOptional<z.ZodObject<{
address: z.ZodOptional<z.ZodObject<{
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<..., ...>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
lockingScript: z.ZodString;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<..., ...>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<..., ...>>>;
}, z.core.$strict>>;
change: z.ZodOptional<z.ZodObject<{
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<..., ...>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
output: z.ZodString;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<..., ...>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<..., ...>>>;
}, z.core.$strict>>;
receive: z.ZodOptional<z.ZodObject<{
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<..., ...>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
output: z.ZodString;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<..., ...>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<..., ...>>>;
}, z.core.$strict>>;
}, z.core.$strict>>;
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
hash: z.ZodString;
name: z.ZodString;
}, z.core.$strict>>>;
inputs: z.ZodRecord<z.ZodString, z.ZodObject<{
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
name: z.ZodString;
omitChangeAmounts: z.ZodOptional<z.ZodObject<{
fungibleTokens: z.ZodOptional<z.ZodUnion<readonly ...>>;
nonfungibleTokens: z.ZodOptional<z.ZodUnion<readonly ...>>;
satoshis: z.ZodOptional<z.ZodUnion<readonly ...>>;
}, z.core.$strict>>;
sequenceNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
token: z.ZodOptional<z.ZodNullable<z.ZodObject<{
amount: z.ZodOptional<z.ZodUnion<...>>;
category: z.ZodOptional<z.ZodString>;
nft: z.ZodOptional<z.ZodNullable<...>>;
}, z.core.$strict>>>;
unlockingScript: z.ZodOptional<z.ZodString>;
valueSatoshis: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString]>>;
}, z.core.$strict>>;
lockingScripts: z.ZodRecord<z.ZodString, z.ZodObject<{
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
action: z.ZodString;
constants: z.ZodOptional<z.ZodArray<...>>;
generate: z.ZodOptional<z.ZodArray<...>>;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<...>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<...>>;
}, z.core.$strict>>>;
balance: z.ZodOptional<z.ZodObject<{
fungibleTokens: z.ZodOptional<z.ZodOptional<z.ZodUnion<...>>>;
nonfungibleTokens: z.ZodOptional<z.ZodOptional<z.ZodUnion<...>>>;
satoshis: z.ZodOptional<z.ZodOptional<z.ZodUnion<...>>>;
}, z.core.$strict>>;
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
lockingBytecode: z.ZodString;
lockingType: z.ZodOptional<z.ZodEnum<{
P2PKH: "p2pkh";
P2S: "p2s";
P2SH: "p2sh";
}>>;
name: z.ZodString;
privacy: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
actions: z.ZodOptional<z.ZodArray<...>>;
balance: z.ZodOptional<z.ZodObject<..., ...>>;
description: z.ZodOptional<z.ZodString>;
icon: z.ZodOptional<z.ZodOptional<...>>;
name: z.ZodOptional<z.ZodString>;
privacy: z.ZodOptional<z.ZodUnion<...>>;
relevant: z.ZodOptional<z.ZodUnion<...>>;
selectable: z.ZodOptional<z.ZodBoolean>;
state: z.ZodOptional<z.ZodObject<..., ...>>;
}, z.core.$strict>>>;
selectable: z.ZodOptional<z.ZodBoolean>;
state: z.ZodOptional<z.ZodObject<{
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
unlockingBytecode: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>;
name: z.ZodString;
outputs: z.ZodRecord<z.ZodString, z.ZodObject<{
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
action: z.ZodString;
constants: z.ZodOptional<z.ZodArray<...>>;
generate: z.ZodOptional<z.ZodArray<...>>;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<...>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<...>>;
}, z.core.$strict>>>;
balance: z.ZodOptional<z.ZodObject<{
fungibleTokens: z.ZodOptional<z.ZodOptional<z.ZodUnion<...>>>;
nonfungibleTokens: z.ZodOptional<z.ZodOptional<z.ZodUnion<...>>>;
satoshis: z.ZodOptional<z.ZodOptional<z.ZodUnion<...>>>;
}, z.core.$strict>>;
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
lockingScript: z.ZodString;
name: z.ZodString;
privacy: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
actions: z.ZodOptional<z.ZodArray<...>>;
balance: z.ZodOptional<z.ZodObject<..., ...>>;
description: z.ZodOptional<z.ZodString>;
icon: z.ZodOptional<z.ZodOptional<...>>;
name: z.ZodOptional<z.ZodString>;
privacy: z.ZodOptional<z.ZodUnion<...>>;
relevant: z.ZodOptional<z.ZodUnion<...>>;
selectable: z.ZodOptional<z.ZodBoolean>;
state: z.ZodOptional<z.ZodObject<..., ...>>;
}, z.core.$strict>>>;
selectable: z.ZodOptional<z.ZodBoolean>;
state: z.ZodOptional<z.ZodObject<{
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
token: z.ZodOptional<z.ZodNullable<z.ZodObject<{
amount: z.ZodOptional<z.ZodUnion<...>>;
category: z.ZodOptional<z.ZodString>;
nft: z.ZodOptional<z.ZodNullable<...>>;
}, z.core.$strict>>>;
valueSatoshis: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString]>>;
}, z.core.$strict>>;
resources: z.ZodOptional<z.ZodArray<z.ZodObject<{
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
name: z.ZodString;
url: z.ZodString;
}, z.core.$strict>>>;
roles: z.ZodRecord<z.ZodString, z.ZodObject<{
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
name: z.ZodString;
}, z.core.$strict>>;
scenarios: z.ZodOptional<z.ZodUnknown>;
scripts: z.ZodRecord<z.ZodString, z.ZodString>;
start: z.ZodArray<z.ZodObject<{
action: z.ZodString;
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>;
supported: z.ZodArray<z.ZodEnum<{
BCH_2020_05: "BCH_2020_05";
BCH_2021_05: "BCH_2021_05";
BCH_2022_05: "BCH_2022_05";
BCH_2023_05: "BCH_2023_05";
BCH_2024_05: "BCH_2024_05";
BCH_2025_05: "BCH_2025_05";
BCH_2026_05: "BCH_2026_05";
}>>;
transactions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
composable: z.ZodOptional<z.ZodBoolean>;
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
inputs: z.ZodArray<z.ZodObject<{
input: z.ZodString;
inputIndex: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>>;
locktime: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
name: z.ZodString;
outputs: z.ZodArray<z.ZodObject<{
output: z.ZodString;
outputIndex: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>>;
roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
description: z.ZodOptional<...>;
icon: z.ZodOptional<...>;
inputs: z.ZodOptional<...>;
name: z.ZodOptional<...>;
outputs: z.ZodOptional<...>;
}, z.core.$strict>>>;
version: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>>>;
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
description: z.ZodString;
hint: z.ZodOptional<z.ZodUnknown>;
icon: z.ZodOptional<z.ZodString>;
importDefaultValue: z.ZodOptional<z.ZodObject<{
constants: z.ZodOptional<z.ZodArray<...>>;
description: z.ZodOptional<z.ZodString>;
generate: z.ZodOptional<z.ZodArray<...>>;
icon: z.ZodOptional<z.ZodOptional<...>>;
name: z.ZodOptional<z.ZodString>;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<...>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<...>>;
}, z.core.$strict>>;
name: z.ZodString;
type: z.ZodOptional<z.ZodEnum<{
BIGINT: "bigint";
BOOLEAN: "boolean";
BYTES: "bytes";
EXTENDED_PUBLIC_KEY: "extended_public_key";
FUNGIBLE_TOKEN_AMOUNT: "token_amount";
INTEGER: "integer";
LOCKING_SCRIPT: "locking_script";
NFT_COMMITMENT: "nft_commitment";
NON_FUNGIBLE_TOKEN_CAPABILITY: "token_capability";
NON_FUNGIBLE_TOKEN_COMMITMENT: "token_commitment";
PRIVATE_KEY: "private_key";
PUBLIC_KEY: "public_key";
SATOSHIS: "satoshis";
SCHNORR_SIGNATURE: "signature";
STRING: "string";
TEMPLATE_IDENTIFIER: "template_identifier";
TIMESTAMP: "timestamp";
TOKEN_CATEGORY: "token_category";
TRANSACTION_HASH: "transaction_hash";
}>>;
}, z.core.$strict>>>;
version: z.ZodOptional<z.ZodString>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:880
Validation schema for the full XOTemplate type.
xoTemplateStateSchema
const xoTemplateStateSchema: z.ZodObject<{
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
variables: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:489
Validation schema for the state configuration shared by a locking script and its individual roles. Declares which variables and secrets are tracked in the on-chain state for a given participant.
{
"lockingScripts": {
"[id]": {
"state": { "variables": [], "secrets": [] } ← this schema
"roles": {
"[roleId]": {
"state": { "variables": [], "secrets": [] } ← this schema
}
}
}
}
}xoTemplateTokenSchema
const xoTemplateTokenSchema: z.ZodObject<{
amount: z.ZodOptional<z.ZodUnion<readonly [z.ZodBigInt, z.ZodString, z.ZodNull]>>;
category: z.ZodOptional<z.ZodString>;
nft: z.ZodOptional<z.ZodNullable<z.ZodObject<{
capability: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<...>, z.ZodString]>>;
commitment: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:406
Validation schema for the token configuration on inputs and outputs.
{
"inputs|outputs": {
"[id]": {
"token": { } ← this schema
}
}
}xoTemplateTransactionInputSchema
const xoTemplateTransactionInputSchema: z.ZodObject<{
input: z.ZodString;
inputIndex: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:643
Validation schema for a transaction input reference for a transaction definition.
{
"transactions": {
"[id]": {
"inputs": [
{ "input": "..." } ← this schema
]
}
}
}xoTemplateTransactionOutputSchema
const xoTemplateTransactionOutputSchema: z.ZodObject<{
output: z.ZodString;
outputIndex: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:665
Validation schema for a transaction output reference for a transaction definition.
{
"transactions": {
"[id]": {
"outputs": [
{ "output": "..." } ← this schema
]
}
}
}xoTemplateTransactionRoleDataSchema
const xoTemplateTransactionRoleDataSchema: z.ZodObject<{
description: z.ZodOptional<z.ZodString>;
icon: z.ZodOptional<z.ZodOptional<z.ZodString>>;
inputs: z.ZodOptional<z.ZodArray<z.ZodObject<{
input: z.ZodString;
inputIndex: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>>>;
name: z.ZodOptional<z.ZodString>;
outputs: z.ZodOptional<z.ZodArray<z.ZodObject<{
output: z.ZodString;
outputIndex: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:687
Validation schema for role-specific data for a transaction definition.
{
"transactions": {
"[id]": {
"roles": {
"[roleId]": { } ← this schema
}
}
}
}xoTemplateTransactionSchema
const xoTemplateTransactionSchema: z.ZodObject<{
composable: z.ZodOptional<z.ZodBoolean>;
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
inputs: z.ZodArray<z.ZodObject<{
input: z.ZodString;
inputIndex: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>>;
locktime: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
name: z.ZodString;
outputs: z.ZodArray<z.ZodObject<{
output: z.ZodString;
outputIndex: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>>;
roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
description: z.ZodOptional<z.ZodString>;
icon: z.ZodOptional<z.ZodOptional<z.ZodString>>;
inputs: z.ZodOptional<z.ZodArray<z.ZodObject<{
input: z.ZodString;
inputIndex: z.ZodOptional<...>;
}, z.core.$strict>>>;
name: z.ZodOptional<z.ZodString>;
outputs: z.ZodOptional<z.ZodArray<z.ZodObject<{
output: z.ZodString;
outputIndex: z.ZodOptional<...>;
}, z.core.$strict>>>;
}, z.core.$strict>>>;
version: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:706
Validation schema for a transaction template definition.
{
"transactions": {
"[id]": { } ← this schema
}
}xoTemplateVariableSchema
const xoTemplateVariableSchema: z.ZodObject<{
description: z.ZodString;
hint: z.ZodOptional<z.ZodUnknown>;
icon: z.ZodOptional<z.ZodString>;
importDefaultValue: z.ZodOptional<z.ZodObject<{
constants: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
description: z.ZodOptional<z.ZodString>;
generate: z.ZodOptional<z.ZodArray<z.ZodString>>;
icon: z.ZodOptional<z.ZodOptional<z.ZodString>>;
name: z.ZodOptional<z.ZodString>;
role: z.ZodOptional<z.ZodString>;
secrets: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
templateIdentifier: z.ZodOptional<z.ZodString>;
variables: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
}, z.core.$strict>>;
name: z.ZodString;
type: z.ZodOptional<z.ZodEnum<{
BIGINT: "bigint";
BOOLEAN: "boolean";
BYTES: "bytes";
EXTENDED_PUBLIC_KEY: "extended_public_key";
FUNGIBLE_TOKEN_AMOUNT: "token_amount";
INTEGER: "integer";
LOCKING_SCRIPT: "locking_script";
NFT_COMMITMENT: "nft_commitment";
NON_FUNGIBLE_TOKEN_CAPABILITY: "token_capability";
NON_FUNGIBLE_TOKEN_COMMITMENT: "token_commitment";
PRIVATE_KEY: "private_key";
PUBLIC_KEY: "public_key";
SATOSHIS: "satoshis";
SCHNORR_SIGNATURE: "signature";
STRING: "string";
TEMPLATE_IDENTIFIER: "template_identifier";
TIMESTAMP: "timestamp";
TOKEN_CATEGORY: "token_category";
TRANSACTION_HASH: "transaction_hash";
}>>;
}, z.core.$strict>;Defined in: source/template/schemas.ts:795
Validation schema for a variable definition.
{
"variables": {
"[id]": { } ← this schema
}
}xoTemplateViewPropertiesSchema
const xoTemplateViewPropertiesSchema: z.ZodObject<{
description: z.ZodString;
icon: z.ZodOptional<z.ZodString>;
name: z.ZodString;
}, z.core.$strict>;Defined in: source/template/schemas.ts:98
Validation schema for view properties shared across many template elements i.e. name, description, icon. Extended by most other schemas in this file.