Creates a new Continuation with the given state.
The state can be any value that implements EnvelopeEncodable.
The state to embed in the continuation
OptionalvalidId: ARIDOptional ID for validation
OptionalvalidUntil: DateOptional expiration date
Creates a new continuation with a specific valid ID.
The ID to use for validation
A new Continuation instance with the valid ID set
Creates a new continuation with an optional valid ID.
The ID to use for validation, or undefined
A new Continuation instance with the valid ID set
Creates a new continuation with a specific valid until date.
The date until which the continuation is valid
A new Continuation instance with the valid until date set
Creates a new continuation with an optional valid until date.
The date until which the continuation is valid, or undefined
A new Continuation instance with the valid until date set
Creates a new continuation with a validity duration from now.
The duration in milliseconds for which the continuation is valid
A new Continuation instance with the valid until date set
Returns the state envelope of the continuation.
Returns the valid ID of the continuation, if set.
Returns the valid until date of the continuation, if set.
Checks if the continuation is valid at the given time.
If no valid_until is set, always returns true. If no time is provided, always returns true.
Optionalnow: DateThe time to check against, or undefined to skip time validation
true if the continuation is valid at the given time
Checks if the continuation has the expected ID.
If no valid_id is set, always returns true. If no ID is provided for checking, always returns true.
Optionalid: ARIDThe ID to check against, or undefined to skip ID validation
true if the continuation has the expected ID
Checks if the continuation is valid (both date and ID).
Optionalnow: DateThe time to check against, or undefined to skip time validation
Optionalid: ARIDThe ID to check against, or undefined to skip ID validation
true if the continuation is valid
Converts the continuation to an envelope.
If a recipient is provided, the envelope is encrypted to that recipient.
Optionalrecipient: EncrypterOptional recipient to encrypt the envelope to
The continuation as an envelope
StatictryParses a continuation from an envelope.
The envelope to parse
OptionalexpectedId: ARIDOptional ID to validate against
Optionalnow: DateOptional time to validate against
Optionalrecipient: PrivateKeysOptional private keys to decrypt with
The parsed continuation
Checks equality with another continuation.
Two continuations are equal if they have the same state, ID, and valid_until.
The continuation to compare with
true if the continuations are equal
Returns a string representation of the continuation.
Represents an encrypted state continuation.
Continuations provide a way to maintain state across message exchanges without requiring local storage. The state is encrypted and embedded directly in the message envelope.
Example