Skip to content

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 ​

bash
npm install @xo-cash/utils

Usage ​

typescript
import { parseTemplate, scriptToScriptHash, generateTemplateIdentifier } from '@xo-cash/utils';

Scripts ​

CommandDescription
npm run buildCompile TypeScript to dist/
npm run generate-schemaGenerate xo-template.schema.json from the Zod schema
npm run testRun tests with coverage
npm run styleLint with ESLint (read-only)
npm run syntaxType-check without emitting (tsc --noEmit)
npm run formatAuto-fix formatting and linting
npm run docsGenerate TypeDoc API docs to public/
npm run spellcheckSpell-check source and test files
npm audit --audit-level=moderatePerforms 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:

bash
npm run generate-schema

This 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.

License ​

MIT

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).

ts
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 ​

ts
new AsyncPushIterator<T>(): AsyncPushIterator<T>;

Defined in: index.d.mts:871

Returns ​

AsyncPushIterator<T>

Accessors ​

closed ​

Get Signature ​
ts
get closed(): boolean;

Defined in: source/sse-session/async-push-iterator.ts:47

Flag indicating if the iterator is closed.

Returns ​

boolean

Methods ​

[asyncIterator]() ​

ts
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() ​

ts
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() ​

ts
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 ​
ParameterTypeDescription
errorErrorThe error to throw from the stream.
Returns ​

void

push() ​

ts
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 ​
ParameterTypeDescription
valueTThe 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 ​

ts
new CashAssemblyBlockCommentUnclosedError(commentStartIndex, cashAssemblyText): CashAssemblyBlockCommentUnclosedError;

Defined in: index.d.mts:2857

Parameters ​
ParameterType
commentStartIndexnumber
cashAssemblyTextstring
Returns ​

CashAssemblyBlockCommentUnclosedError

Overrides ​
ts
Error.constructor

Properties ​

PropertyModifierTypeDescriptionDefined in
commentStartIndexreadonlynumberIndex of the first slash of the block comment opener.source/cash-assembly/errors.ts:78
unclosedTextreadonlystringText 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 ​

ts
new CashAssemblyCompilationFailedError(message?): CashAssemblyCompilationFailedError;

Defined in: index.d.mts:2825

Parameters ​
ParameterType
message?string
Returns ​

CashAssemblyCompilationFailedError

Overrides ​
ts
Error.constructor

CashAssemblyEvaluationUnclosedError ​

Defined in: source/cash-assembly/errors.ts:100

Error thrown when a $() evaluation never finds its matching closer.

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new CashAssemblyEvaluationUnclosedError(
   evaluationStartIndex, 
   remainingOpenEvaluations, 
   cashAssemblyText): CashAssemblyEvaluationUnclosedError;

Defined in: index.d.mts:2875

Parameters ​
ParameterType
evaluationStartIndexnumber
remainingOpenEvaluationsnumber
cashAssemblyTextstring
Returns ​

CashAssemblyEvaluationUnclosedError

Overrides ​
ts
Error.constructor

Properties ​

PropertyModifierTypeDescriptionDefined in
evaluationStartIndexreadonlynumberIndex of the $ that opened the evaluation.source/cash-assembly/errors.ts:104
remainingOpenEvaluationsreadonlynumberHow many $() remain open at the end of the string, including nested evaluations.source/cash-assembly/errors.ts:109
unclosedTextreadonlystringText 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 ​

ts
new CashAssemblyIdentifierCollisionError(identifier, resolutionTypes): CashAssemblyIdentifierCollisionError;

Defined in: index.d.mts:2919

Parameters ​
ParameterType
identifierstring
resolutionTypesIdentifierResolutionType[]
Returns ​

CashAssemblyIdentifierCollisionError

Overrides ​
ts
Error.constructor

Properties ​

PropertyModifierTypeDescriptionDefined in
identifierreadonlystringIdentifier that more than one resolution type would match.source/cash-assembly/errors.ts:190
resolutionTypesreadonlyIdentifierResolutionType[]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 ​

ts
new CashAssemblyNumberNotSafeIntegerError(identifier, value): CashAssemblyNumberNotSafeIntegerError;

Defined in: index.d.mts:2899

Parameters ​
ParameterType
identifierstring
valuenumber
Returns ​

CashAssemblyNumberNotSafeIntegerError

Overrides ​
ts
Error.constructor

CashAssemblyPrimitiveMethodMissingError ​

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 ​

ts
new CashAssemblyPrimitiveMethodMissingError(
   identifier, 
   methodName, 
   type): CashAssemblyPrimitiveMethodMissingError;

Defined in: index.d.mts:2887

Parameters ​
ParameterType
identifierstring
methodNamestring
typestring
Returns ​

CashAssemblyPrimitiveMethodMissingError

Overrides ​
ts
Error.constructor

CashAssemblyPrimitiveVariableMissingError ​

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 ​

ts
new CashAssemblyPrimitiveVariableMissingError(identifier, variableName): CashAssemblyPrimitiveVariableMissingError;

Defined in: index.d.mts:2905

Parameters ​
ParameterType
identifierstring
variableNamestring
Returns ​

CashAssemblyPrimitiveVariableMissingError

Overrides ​
ts
Error.constructor

CashAssemblyQuotedLiteralUnclosedError ​

Defined in: source/cash-assembly/errors.ts:38

Error thrown when a quoted string inside $() never closes.

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new CashAssemblyQuotedLiteralUnclosedError(
   openingQuoteIndex, 
   quoteCharacter, 
   cashAssemblyText): CashAssemblyQuotedLiteralUnclosedError;

Defined in: index.d.mts:2843

Parameters ​
ParameterType
openingQuoteIndexnumber
quoteCharacterstring
cashAssemblyTextstring
Returns ​

CashAssemblyQuotedLiteralUnclosedError

Overrides ​
ts
Error.constructor

Properties ​

PropertyModifierTypeDescriptionDefined in
openingQuoteIndexreadonlynumberIndex of the opening quote that never found a closer.source/cash-assembly/errors.ts:42
quoteCharacterreadonlystringQuote character that opened the literal.source/cash-assembly/errors.ts:47
unclosedTextreadonlystringText 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 ​

ts
new CashAssemblyRequiredVariableMissingError(variableNames?): CashAssemblyRequiredVariableMissingError;

Defined in: index.d.mts:2819

Parameters ​
ParameterType
variableNames?string[]
Returns ​

CashAssemblyRequiredVariableMissingError

Overrides ​
ts
Error.constructor

Properties ​

PropertyModifierTypeDescriptionDefined in
variableNamesreadonlystring[]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 ​

ts
new CashAssemblyUnsupportedValueTypeError(identifier, returnedType): CashAssemblyUnsupportedValueTypeError;

Defined in: index.d.mts:2893

Parameters ​
ParameterType
identifierstring
returnedTypestring
Returns ​

CashAssemblyUnsupportedValueTypeError

Overrides ​
ts
Error.constructor

CashAssemblyVariableTypeMismatchError ​

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 ​

ts
new CashAssemblyVariableTypeMismatchError(
   variableKey, 
   expectedType, 
   actualType): CashAssemblyVariableTypeMismatchError;

Defined in: index.d.mts:2881

Parameters ​
ParameterType
variableKeystring
expectedTypestring
actualTypestring
Returns ​

CashAssemblyVariableTypeMismatchError

Overrides ​
ts
Error.constructor

CashAssemblyVmNumberDecodeError ​

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 ​

ts
new CashAssemblyVmNumberDecodeError(reason): CashAssemblyVmNumberDecodeError;

Defined in: index.d.mts:2925

Parameters ​
ParameterType
reasonstring
Returns ​

CashAssemblyVmNumberDecodeError

Overrides ​
ts
Error.constructor

EventEmitter ​

Defined in: source/event-emitter.ts:37

A simple event emitter implementation.

Extended by ​

Type Parameters ​

Type ParameterDescription
T extends EventMapThe event map type.

Constructors ​

Constructor ​

ts
new EventEmitter<T>(): EventEmitter<T>;
Returns ​

EventEmitter<T>

Methods ​

emit() ​

ts
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 ​
ParameterTypeDescription
typeKThe event type.
payloadT[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() ​

ts
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 ​
ParameterTypeDescription
typeKThe event type.
listener?Listener<T[K]>The listener function.
Returns ​

void

on() ​

ts
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 ​
ParameterTypeDescription
typeKThe event type.
listenerListener<T[K]>The listener function.
debounceMilliseconds?numberThe debounce time in milliseconds.
Returns ​

OffCallback

An off callback that can be called to stop listening for events.

once() ​

ts
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 ​
ParameterTypeDescription
typeKThe event type.
listenerListener<T[K]>The listener function.
debounceMilliseconds?numberThe debounce time in milliseconds.
Returns ​

OffCallback

An off callback that can be called to stop listening for events.

removeAllListeners() ​

ts
removeAllListeners(): void;

Defined in: source/event-emitter.ts:176

Remove all listeners.

Returns ​

void

waitFor() ​

ts
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 ​
ParameterTypeDescription
typeKThe event type.
predicate(payload) => booleanPredicate function to filter for whether the event payload matches the criteria.
timeoutMs?numberThe 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 ​

ts
new ExponentialBackoff(options?): ExponentialBackoff;

Defined in: index.d.mts:220

Creates a new exponential-backoff instance.

Unspecified options use the defaults listed below.

Parameters ​
ParameterTypeDescription
options?Partial<ExponentialBackoffOptions>Exponential-backoff configuration overrides.
Returns ​

ExponentialBackoff

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() ​

ts
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 ​
ParameterTypeDescription
taskFn(callbackParameters) => Promise<T>The function to run
options?ExponentialBackoffRunOptionsOptions 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() ​

ts
static from(config?): ExponentialBackoff;

Defined in: source/exponential-backoff/exponential-backoff.ts:131

Create a new ExponentialBackoff instance

Parameters ​
ParameterTypeDescription
config?Partial<ExponentialBackoffOptions>The configuration for the exponential backoff
Returns ​

ExponentialBackoff

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() ​

ts
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 ​
ParameterTypeDescription
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() ​

ts
static validateOptions(options): void;

Defined in: source/exponential-backoff/exponential-backoff.ts:169

Validate the options for the exponential backoff

Parameters ​
ParameterTypeDescription
optionsExponentialBackoffOptionsThe 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 ​

ts
new ExponentialBackoffExternallyAbortable(options?): ExponentialBackoffExternallyAbortable;

Defined in: index.d.mts:295

Parameters ​
ParameterType
options?Partial<ExponentialBackoffExternallyAbortableOptions>
Returns ​

ExponentialBackoffExternallyAbortable

Methods ​

abort() ​

ts
abort(reason): void;

Defined in: source/exponential-backoff/exponential-backoff-externally-aborted.ts:93

Stops retries for all current and future runs.

Parameters ​
ParameterTypeDescription
reasonunknownThe reason for stopping retries
Returns ​

void

run() ​

ts
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 ​
ParameterTypeDescription
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 ​

ts
new ExponentialBackoffMaxRetriesHitError(errors): ExponentialBackoffMaxRetriesHitError;

Defined in: index.d.mts:90

Parameters ​
ParameterType
errorsError[]
Returns ​

ExponentialBackoffMaxRetriesHitError

Overrides ​
ts
Error.constructor

ExponentialBackoffNonIntegerError ​

Defined in: source/exponential-backoff/errors.ts:59

Error thrown when an exponential backoff option is not an integer

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new ExponentialBackoffNonIntegerError(option, value): ExponentialBackoffNonIntegerError;

Defined in: index.d.mts:120

Parameters ​
ParameterType
optionstring
valuenumber
Returns ​

ExponentialBackoffNonIntegerError

Overrides ​
ts
Error.constructor

ExponentialBackoffNumberNotFiniteError ​

Defined in: source/exponential-backoff/errors.ts:49

Error thrown when an exponential backoff option is an invalid infinite integer

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new ExponentialBackoffNumberNotFiniteError(option, value): ExponentialBackoffNumberNotFiniteError;

Defined in: index.d.mts:114

Parameters ​
ParameterType
optionstring
valuenumber
Returns ​

ExponentialBackoffNumberNotFiniteError

Overrides ​
ts
Error.constructor

ExponentialBackoffNumberOutOfBoundsError ​

Defined in: source/exponential-backoff/errors.ts:39

Error thrown when an exponential backoff option is out of bounds

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new ExponentialBackoffNumberOutOfBoundsError(
   option, 
   value, 
   min, 
   max): ExponentialBackoffNumberOutOfBoundsError;

Defined in: index.d.mts:108

Parameters ​
ParameterType
optionstring
valuenumber
minnumber
maxnumber
Returns ​

ExponentialBackoffNumberOutOfBoundsError

Overrides ​
ts
Error.constructor

ExponentialBackoffNumberTooSmallError ​

Defined in: source/exponential-backoff/errors.ts:29

Error thrown when an exponential backoff option is too small

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new ExponentialBackoffNumberTooSmallError(
   option, 
   value, 
   min): ExponentialBackoffNumberTooSmallError;

Defined in: index.d.mts:102

Parameters ​
ParameterType
optionstring
valuenumber
minnumber
Returns ​

ExponentialBackoffNumberTooSmallError

Overrides ​
ts
Error.constructor

ExponentialBackoffStoppedRetriesError ​

Defined in: source/exponential-backoff/errors.ts:16

Error thrown when the exponential backoff retries are stopped

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new ExponentialBackoffStoppedRetriesError(reason): ExponentialBackoffStoppedRetriesError;

Defined in: index.d.mts:96

Parameters ​
ParameterType
reasonunknown
Returns ​

ExponentialBackoffStoppedRetriesError

Overrides ​
ts
Error.constructor

ExternallyAbortedExponentialBackoffExternalSignalAbortedError ​

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 ​

ts
new ExternallyAbortedExponentialBackoffExternalSignalAbortedError(reason): ExternallyAbortedExponentialBackoffExternalSignalAbortedError;

Defined in: index.d.mts:127

Parameters ​
ParameterType
reasonunknown
Returns ​

ExternallyAbortedExponentialBackoffExternalSignalAbortedError

Overrides ​
ts
Error.constructor

ExternallyAbortedExponentialBackoffInternalSignalAbortedError ​

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 ​

ts
new ExternallyAbortedExponentialBackoffInternalSignalAbortedError(reason): ExternallyAbortedExponentialBackoffInternalSignalAbortedError;

Defined in: index.d.mts:134

Parameters ​
ParameterType
reasonunknown
Returns ​

ExternallyAbortedExponentialBackoffInternalSignalAbortedError

Overrides ​
ts
Error.constructor

InvitationInvalidError ​

Defined in: source/invitation/errors.ts:6

Thrown when a value does not satisfy the XOInvitation schema.

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new InvitationInvalidError(details): InvitationInvalidError;

Defined in: index.d.mts:376

Parameters ​
ParameterType
detailsstring
Returns ​

InvitationInvalidError

Overrides ​
ts
Error.constructor

InvitationJsonMalformedError ​

Defined in: source/invitation/errors.ts:17

Thrown when invitation share JSON cannot be parsed.

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new InvitationJsonMalformedError(reason): InvitationJsonMalformedError;

Defined in: index.d.mts:386

Parameters ​
ParameterType
reasonstring
Returns ​

InvitationJsonMalformedError

Overrides ​
ts
Error.constructor

Properties ​

PropertyModifierTypeDescriptionDefined in
reasonreadonlystringParser 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 ​

ts
new InvitationSerializationFailedError(reason): InvitationSerializationFailedError;

Defined in: index.d.mts:396

Parameters ​
ParameterType
reasonstring
Returns ​

InvitationSerializationFailedError

Overrides ​
ts
Error.constructor

Properties ​

PropertyModifierTypeDescriptionDefined in
reasonreadonlystringSerializer 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:

ts
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 ​

ts
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 ​
ParameterTypeDescription
options?Partial<SSEEventParserOptions>Optional text encoders for decode/encode of stream bytes.
Returns ​

SSEEventParser

Methods ​

parseEvents() ​

ts
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 ​
ParameterTypeDescription
chunkUint8ArrayNewly received SSE stream bytes.
Returns ​

SSEvent[]

Zero or more complete parsed SSE events from this chunk.

reset() ​

ts
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...of consumers.

Typical usage:

ts
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 ​

ts
new SSESession(url, options?): SSESession;

Defined in: index.d.mts:1210

Parameters ​
ParameterType
urlstring
options?Partial<SSESessionCallbacks & SSERequestInit & SSERequestFunction & SSESessionRetryInterface & SSELifecycleOptions & SSEParser & SSESessionEventCallbacks>
Returns ​

SSESession

Overrides ​

EventEmitter.constructor

Properties ​

PropertyModifierTypeDescriptionDefined in
messagespublicAsyncPushIterator<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
optionspublicSSESessionOptionsPer-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
pluginsreadonlyMap<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 ​
ts
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() ​

ts
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() ​

ts
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() ​

ts
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 ​
ParameterTypeDescription
context?SSESessionOperationContextContext 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() ​

ts
emit<K>(type, payload): boolean;

Defined in: source/event-emitter.ts:155

Emit an event.

Type Parameters ​
Type Parameter
K extends keyof SSESessionEventMap
Parameters ​
ParameterTypeDescription
typeKThe event type.
payloadSSESessionEventMap[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 ​

EventEmitter.emit

off() ​

ts
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 ​
ParameterTypeDescription
typeKThe event type.
listener?Listener<SSESessionEventMap[K]>The listener function.
Returns ​

void

Inherited from ​

EventEmitter.off

on() ​

ts
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 ​
ParameterTypeDescription
typeKThe event type.
listenerListener<SSESessionEventMap[K]>The listener function.
debounceMilliseconds?numberThe debounce time in milliseconds.
Returns ​

OffCallback

An off callback that can be called to stop listening for events.

Inherited from ​

EventEmitter.on

once() ​

ts
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 ​
ParameterTypeDescription
typeKThe event type.
listenerListener<SSESessionEventMap[K]>The listener function.
debounceMilliseconds?numberThe debounce time in milliseconds.
Returns ​

OffCallback

An off callback that can be called to stop listening for events.

Inherited from ​

EventEmitter.once

removeAllListeners() ​

ts
removeAllListeners(): void;

Defined in: source/event-emitter.ts:176

Remove all listeners.

Returns ​

void

Inherited from ​

EventEmitter.removeAllListeners

waitFor() ​

ts
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 ​
ParameterTypeDescription
typeKThe event type.
predicate(payload) => booleanPredicate function to filter for whether the event payload matches the criteria.
timeoutMs?numberThe timeout in milliseconds.
Returns ​

Promise<SSESessionEventMap[K]>

The event payload.

Inherited from ​

EventEmitter.waitFor

addBrowserVisibilityHandler() ​

ts
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 ​
ParameterTypeDescription
sessionSSESessionThe session to manage.
Returns ​

object

NameTypeDefined in
removeListener?OffCallbacksource/sse-session/sse-session.ts:174
sessionSSESessionsource/sse-session/sse-session.ts:174

addLastEventIdReconnect() ​

ts
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.

ts
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 ​
ParameterTypeDescription
sessionSSESessionThe session to instrument.
Returns ​

object

The same session, for chaining.

NameTypeDefined in
removeListener?OffCallbacksource/sse-session/sse-session.ts:97
sessionSSESessionsource/sse-session/sse-session.ts:97

create() ​

ts
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 ​
ParameterTypeDescription
urlstringThe 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 ​

ts
new TemplateInvalidError(details): TemplateInvalidError;

Defined in: index.d.mts:1319

Parameters ​
ParameterType
detailsstring
Returns ​

TemplateInvalidError

Overrides ​
ts
Error.constructor

TemplateJsonMalformedError ​

Defined in: source/template/errors.ts:17

Thrown when a string passed to deserializeTemplate cannot be parsed as JSON.

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new TemplateJsonMalformedError(reason): TemplateJsonMalformedError;

Defined in: index.d.mts:1325

Parameters ​
ParameterType
reasonstring
Returns ​

TemplateJsonMalformedError

Overrides ​
ts
Error.constructor

TemplateSerializationFailedError ​

Defined in: source/template/errors.ts:27

Thrown when serializeTemplate fails to produce a JSON string from the template.

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new TemplateSerializationFailedError(reason): TemplateSerializationFailedError;

Defined in: index.d.mts:1331

Parameters ​
ParameterType
reasonstring
Returns ​

TemplateSerializationFailedError

Overrides ​
ts
Error.constructor

WaitForTimeoutError ​

Defined in: source/errors.ts:36

Error thrown when a waitFor timeout is reached

Extends ​

  • Error

Constructors ​

Constructor ​

ts
new WaitForTimeoutError(type): WaitForTimeoutError;

Defined in: index.d.mts:19

Parameters ​
ParameterType
typestring
Returns ​

WaitForTimeoutError

Overrides ​
ts
Error.constructor

SSEEventParserOptions ​

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 ​

PropertyTypeDescriptionDefined in
textDecoderTextDecoderDecodes 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 ​

PropertyTypeDescriptionDefined in
eventParserobjectIncremental 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.parseEventsSSEvent[]-source/sse-session/types.ts:87
eventParser.resetvoid-source/sse-session/types.ts:88

SSEvent ​

Defined in: source/sse-session/types.ts:174

Represents a Server-Sent Event.

Properties ​

PropertyTypeDescriptionDefined in
datastringEvent data.source/sse-session/types.ts:179
event?stringEvent 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?stringEvent 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?numberReconnection time in milliseconds. This value is optionally sent by the server to indicate the server's preferred time before reconnectingsource/sse-session/types.ts:198

CompileCashAssemblyStringParameters ​

ts
type CompileCashAssemblyStringParameters = CompileCashAssemblyContext & object;

Defined in: source/cash-assembly/types.ts:48

Parameters for compiling CashAssembly text.

Type Declaration ​

NameTypeDescriptionDefined in
cashAssemblyTextstringText 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?CompiledCashAssemblyDecodeModeThe mode to decode compiled bytecode into a string.source/cash-assembly/types.ts:63

CompiledCashAssemblyDecodeMode ​

ts
type CompiledCashAssemblyDecodeMode = "utf8" | "hex" | "boolean" | "bigint" | "uint8array";

Defined in: source/cash-assembly/types.ts:6

Supported decode modes for compiled CashAssembly evaluation bytes.


EventMap ​

ts
type EventMap = Record<string, unknown>;

Defined in: source/event-emitter.ts:6


ExponentialBackoffCallbackParameters ​

ts
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 ​

ts
type ExponentialBackoffExternallyAbortableOptions = Partial<ExponentialBackoffOptions> & object;

Defined in: source/exponential-backoff/exponential-backoff-externally-aborted.ts:14

Options for the ExponentialBackoffExternallyAbortable class

Type Declaration ​

NameTypeDefined in
abortSignalAbortSignalsource/exponential-backoff/exponential-backoff-externally-aborted.ts:15

ExponentialBackoffOptions ​

ts
type ExponentialBackoffOptions = object;

Defined in: source/exponential-backoff/exponential-backoff.ts:11

Properties ​

baseDelay ​

ts
baseDelay: number;

Defined in: source/exponential-backoff/exponential-backoff.ts:26

The base delay between attempts in milliseconds

growthRate ​

ts
growthRate: number;

Defined in: source/exponential-backoff/exponential-backoff.ts:31

The growth rate of the delay

jitter ​

ts
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 ​

ts
maxAttempts: number;

Defined in: source/exponential-backoff/exponential-backoff.ts:21

The maximum number of attempts. Passing 0 will result in infinite attempts.

maxDelay ​

ts
maxDelay: number;

Defined in: source/exponential-backoff/exponential-backoff.ts:16

The maximum delay between attempts in milliseconds


ExponentialBackoffRunOptions ​

ts
type ExponentialBackoffRunOptions = object;

Defined in: source/exponential-backoff/exponential-backoff.ts:59

Options that control a single exponential-backoff run.

Properties ​

onError? ​

ts
optional onError?: (error) => void;

Defined in: source/exponential-backoff/exponential-backoff.ts:64

Called after each failed task attempt.

Parameters ​
ParameterType
errorError
Returns ​

void

signal? ​

ts
optional signal?: AbortSignal;

Defined in: source/exponential-backoff/exponential-backoff.ts:69

Stops pending delays and prevents future attempts when aborted.


ExponentialBackoffStaticRunOptions ​

ts
type ExponentialBackoffStaticRunOptions = Partial<ExponentialBackoffOptions> & ExponentialBackoffRunOptions;

Defined in: source/exponential-backoff/exponential-backoff.ts:75

Options accepted by the static exponential-backoff run helper.


ExponentialBackoffStopRetriesFunction ​

ts
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 ​

ParameterTypeDescription
reasonunknownThe reason for stopping the retries.

Returns ​

void


OffCallback ​

ts
type OffCallback = () => void;

Defined in: source/event-emitter.ts:31

Callback returned by on and once for removing a listener.

Returns ​

void


SSELifecycleOptions ​

ts
type SSELifecycleOptions = object;

Defined in: source/sse-session/types.ts:92

Properties ​

attemptReconnect ​

ts
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 ​
ts
true

persistent ​

ts
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 ​
ts
false

SSERequestFunction ​

ts
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 ​

ts
type SSERequestInit = object;

Defined in: source/sse-session/types.ts:3

Properties ​

body? ​

ts
optional body?: string | FormData;

Defined in: source/sse-session/types.ts:18

Request body for POST-based SSE endpoints.

headers? ​

ts
optional headers?: Record<string, string>;

Defined in: source/sse-session/types.ts:13

Request headers sent on every connect and reconnect.

method ​

ts
method: "GET" | "POST";

Defined in: source/sse-session/types.ts:8

The HTTP method to use.


SSESessionCallbacks ​

ts
type SSESessionCallbacks = object;

Defined in: source/sse-session/types.ts:36

Lifecycle hooks invoked by SSESession during connect, read, and teardown.

Properties ​

onRequest ​

ts
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 ​
ParameterType
requestRequestInit
Returns ​

Promise<RequestInit>


SSESessionDisconnectContext ​

ts
type SSESessionDisconnectContext = 
  | SSESessionDisconnectInternalContext
  | SSESessionDisconnectRemoteContext
  | SSESessionDisconnectErrorContext;

Defined in: source/sse-session/types.ts:141

Discriminated context for the reason the session was disconnected.


SSESessionDisconnectErrorContext ​

ts
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 ​

ts
type SSESessionDisconnectInternalContext = object & SSESessionOperationContext;

Defined in: source/sse-session/types.ts:119

Discriminated context for the reason the session was disconnected internally.

Type Declaration ​

NameTypeDefined in
reason"disconnect"source/sse-session/types.ts:120

SSESessionDisconnectRemoteContext ​

ts
type SSESessionDisconnectRemoteContext = object;

Defined in: source/sse-session/types.ts:126

Discriminated context for the reason the session was disconnected remotely.


SSESessionEventCallbacks ​

ts
type SSESessionEventCallbacks = object;

Defined in: source/sse-session/types.ts:45

Properties ​

onConnected ​

ts
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 ​

ts
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 ​

ts
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 ​
ParameterType
errorError
Returns ​

void


SSESessionEventMap ​

ts
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 ​

ts
type SSESessionOperationContext = object;

Defined in: source/sse-session/types.ts:112

Context from the source that triggered the event.


SSESessionOptions ​

ts
type SSESessionOptions = SSESessionCallbacks & SSERequestInit & SSERequestFunction & SSESessionRetryInterface & SSELifecycleOptions & SSEParser;

Defined in: source/sse-session/types.ts:164

Configuration for SSESession.


SSESessionRetryInterface ​

ts
type SSESessionRetryInterface = object;

Defined in: source/sse-session/types.ts:66

Properties ​

retry ​

ts
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.

NameTypeDefined in
run()(fn, options?) => Promise<T>source/sse-session/types.ts:74

bchVmVersionSchema ​

ts
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 ​

ts
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 ​

ParameterTypeDescription
issues$ZodIssue[]The Zod validation failures to format.

Returns ​

string

A human readable error string for better debugging.


collectVariablesUsingParseScript ​

ts
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 ​

ParameterTypeDescription
evaluationstringCashAssembly evaluation or script id text to scan.
templateScripts?CashAssemblyTemplateScriptsOptional template scripts map used to visit nested script ids.

Returns ​

string[]

  • WalletData names from reachable Pushes. Script ids are omitted when templateScripts is provided.

Throws ​

CashAssemblyCompilationFailedError - When parseScript rejects the starting text or a visited script source.


compileCashAssemblyString ​

ts
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 ​

ParameterTypeDescription
parametersCompileCashAssemblyStringParametersParameters 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 ​

ts
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 ​

ParameterType
valueT

Returns ​

DeeplyReadonly<T>

The frozen object.


deserializeInvitation ​

ts
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 ​

ParameterTypeDescription
serializedInvitationstringJSON produced by serializeInvitation.

Returns ​

XOInvitation

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 ​

ts
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 ​

ParameterTypeDescription
_propertyKeystringThe property key being serialized, required by the JSON.stringify replacer but not used here.
valueunknownThe value to encode or pass through unchanged.

Returns ​

unknown

The encoded string


extendedJsonReviver ​

ts
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 ​

ParameterTypeDescription
_propertyKeystringThe property key being deserialized, required by the JSON.parse reviver but not used here.
valueunknownThe value to reconstruct or pass through unchanged.

Returns ​

unknown

The reconstructed value


extractCashAssemblyEvaluations ​

ts
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 ​

ParameterTypeDescription
cashAssemblyTextstringText 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 ​

ts
const fromExtendedJson: (serializedObject) => unknown;

Defined in: source/extended-json.ts:94

Deserializes a string to an object using the extendedJsonReviver.

Parameters ​

ParameterTypeDescription
serializedObjectstringThe string to deserialize.

Returns ​

unknown

The object reconstructed from the string.


generateTemplateIdentifier ​

ts
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 ​

ParameterTypeDescription
templateXOTemplateThe template to generate an identifier for.

Returns ​

string

The sha256 hex identifier for the template.


isCashAssemblyExpression ​

ts
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 ​

ParameterTypeDescription
expressionunknownValue to test.

Returns ​

boolean

  • True when the value is a string that is one complete evaluation and nothing else.

isWithinBounds ​

ts
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 ​

ParameterTypeDescription
valuenumberThe value to validate
minnumberThe minimum value
maxnumberThe maximum value

Returns ​

boolean

True if the value is within the bounds, false otherwise


normalizeError ​

ts
const normalizeError: (error) => Error;

Defined in: source/misc.ts:46

Converts a non-error to an error

Parameters ​

ParameterTypeDescription
errorunknownThe error to convert

Returns ​

Error

The error


outputTokenSchema ​

ts
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 ​

ts
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 ​

ParameterTypeDescription
invitationValueunknownValue to validate, such as the output of Extended JSON parsing.

Returns ​

XOInvitation

  • 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 ​

ts
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 ​

ParameterTypeDescription
inputTemplatestring | XOTemplateThe value to validate. May be an Extended JSON string or a pre-parsed object.

Returns ​

XOTemplate

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 ​

ts
const satoshisSchema: z.ZodBigInt;

Defined in: source/template/schemas.ts:79

Validation schema for the Satoshis type i.e. bigint.


scriptToScriptHash ​

ts
const scriptToScriptHash: (script) => string;

Defined in: source/script.ts:8

Converts a script to a scriptHash.

Parameters ​

ParameterTypeDescription
scriptUint8ArrayThe script to convert.

Returns ​

string

The scriptHash as a reversed hex string.


serializeInvitation ​

ts
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 ​

ParameterTypeDescription
invitationXOInvitationShared invitation to export.

Returns ​

string

JSON string that deserializeInvitation can restore.

Throws ​

When JSON serialization fails.


serializeTemplate ​

ts
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 ​

ParameterTypeDescription
templateXOTemplateThe template to serialize.

Returns ​

string

A JSON string representation of the template.

Throws ​

If the template cannot be serialized to JSON.


toExtendedJson ​

ts
const toExtendedJson: (object) => string;

Defined in: source/extended-json.ts:84

Serializes an object to a string using the extendedJsonReplacer.

Parameters ​

ParameterTypeDescription
objectunknownThe object to serialize.

Returns ​

string

The string representation of the object in Extended JSON format.


uint8ArraySchema ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
const xoInvitationSchema: z.ZodType<XOInvitation>;

Defined in: source/invitation/schemas.ts:232

Validation schema for an invitation.


xoInvitationTokenSchema ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
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.