Blockchain Commons GSTP TypeScript Library - v1.0.0-alpha.16
    Preparing search index...

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

    import { Continuation } from '@bcts/gstp';

    // Create a continuation with state
    const continuation = new Continuation("session state data")
    .withValidId(requestId)
    .withValidUntil(new Date(Date.now() + 60000)); // Valid for 60 seconds

    // Convert to envelope (optionally encrypted)
    const envelope = continuation.toEnvelope(recipientPublicKey);
    Index

    Constructors

    • Creates a new Continuation with the given state.

      The state can be any value that implements EnvelopeEncodable.

      Parameters

      • state: EnvelopeEncodableValue

        The state to embed in the continuation

      • OptionalvalidId: ARID

        Optional ID for validation

      • OptionalvalidUntil: Date

        Optional expiration date

      Returns Continuation

    Methods

    • Creates a new continuation with a specific valid ID.

      Parameters

      • validId: ARID

        The ID to use for validation

      Returns Continuation

      A new Continuation instance with the valid ID set

    • Creates a new continuation with an optional valid ID.

      Parameters

      • validId: ARID | undefined

        The ID to use for validation, or undefined

      Returns Continuation

      A new Continuation instance with the valid ID set

    • Creates a new continuation with a specific valid until date.

      Parameters

      • validUntil: Date

        The date until which the continuation is valid

      Returns Continuation

      A new Continuation instance with the valid until date set

    • Creates a new continuation with an optional valid until date.

      Parameters

      • validUntil: Date | undefined

        The date until which the continuation is valid, or undefined

      Returns Continuation

      A new Continuation instance with the valid until date set

    • Creates a new continuation with a validity duration from now.

      Parameters

      • durationMs: number

        The duration in milliseconds for which the continuation is valid

      Returns Continuation

      A new Continuation instance with the valid until date set

    • Returns the state envelope of the continuation.

      Returns Envelope$1

    • Returns the valid ID of the continuation, if set.

      Returns ARID | undefined

    • Returns the valid until date of the continuation, if set.

      Returns Date | undefined

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

      Parameters

      • Optionalnow: Date

        The time to check against, or undefined to skip time validation

      Returns boolean

      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.

      Parameters

      • Optionalid: ARID

        The ID to check against, or undefined to skip ID validation

      Returns boolean

      true if the continuation has the expected ID

    • Checks if the continuation is valid (both date and ID).

      Parameters

      • Optionalnow: Date

        The time to check against, or undefined to skip time validation

      • Optionalid: ARID

        The ID to check against, or undefined to skip ID validation

      Returns boolean

      true if the continuation is valid

    • Converts the continuation to an envelope.

      If a recipient is provided, the envelope is encrypted to that recipient.

      Parameters

      • Optionalrecipient: Encrypter

        Optional recipient to encrypt the envelope to

      Returns Envelope$1

      The continuation as an envelope

    • Parses a continuation from an envelope.

      Parameters

      • encryptedEnvelope: Envelope$1

        The envelope to parse

      • OptionalexpectedId: ARID

        Optional ID to validate against

      • Optionalnow: Date

        Optional time to validate against

      • Optionalrecipient: PrivateKeys

        Optional private keys to decrypt with

      Returns Continuation

      The parsed continuation

      GstpError if validation fails or parsing fails

    • Checks equality with another continuation.

      Two continuations are equal if they have the same state, ID, and valid_until.

      Parameters

      Returns boolean

      true if the continuations are equal

    • Returns a string representation of the continuation.

      Returns string