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

    Class SealedResponse

    A sealed response that combines a Response with sender information and state continuations for secure communication.

    import { SealedResponse, ARID } from '@bcts/gstp';
    import { XIDDocument } from '@bcts/xid';

    // Create sender XID document
    const sender = XIDDocument.new();
    const requestId = ARID.new();

    // Create a successful sealed response
    const response = SealedResponse.newSuccess(requestId, sender)
    .withResult("Operation completed")
    .withState("next-page-state");

    // Convert to sealed envelope
    const envelope = response.toEnvelope(
    new Date(Date.now() + 60000), // Valid for 60 seconds
    senderPrivateKey,
    recipientXIDDocument
    );

    Implements

    Index

    Methods

    • Creates a new successful sealed response.

      Parameters

      • id: ARID

        The request ID this response is for

      • sender: XIDDocument

        The sender's XID document

      Returns SealedResponse

    • Creates a new failure sealed response.

      Parameters

      • id: ARID

        The request ID this response is for

      • sender: XIDDocument

        The sender's XID document

      Returns SealedResponse

    • Creates a new early failure sealed response.

      An early failure takes place before the message has been decrypted, and therefore the ID and sender public key are not known.

      Parameters

      • sender: XIDDocument

        The sender's XID document

      Returns SealedResponse

    • Sets an optional result value for a successful response. If the result is undefined, the value of the response will be the null envelope.

      Parameters

      • result: EnvelopeEncodableValue

      Returns SealedResponse

    • Sets an optional error value for a failure response. If the error is undefined, the value of the response will be the unknown value.

      Parameters

      • error: EnvelopeEncodableValue

      Returns SealedResponse

    • Returns true if this is a successful response.

      Returns boolean

    • Returns the ID of the request this response is for, if known.

      Returns ARID | undefined

    • Returns the ID of the request this response is for.

      Returns ARID

      Error if the ID is not known

    • Returns the result envelope if this is a successful response.

      Returns Envelope$1

      Error if this is a failure response

    • Extracts the result as a specific type.

      Type Parameters

      • T

      Parameters

      • decoder: (cbor: unknown) => T

      Returns T

    • Returns the error envelope if this is a failure response.

      Returns Envelope$1

      Error if this is a successful response

    • Extracts the error as a specific type.

      Type Parameters

      • T

      Parameters

      • decoder: (cbor: unknown) => T

      Returns T

    • Creates an envelope that can be decrypted by zero or one recipient.

      Parameters

      • OptionalvalidUntil: Date

        Optional expiration date for the continuation

      • Optionalsigner: Signer

        Optional signer for the envelope

      • Optionalrecipient: XIDDocument

        Optional recipient XID document for encryption

      Returns Envelope$1

      The sealed response as an envelope

    • Creates an envelope that can be decrypted by zero or more recipients.

      Parameters

      • OptionalvalidUntil: Date

        Optional expiration date for the continuation

      • Optionalsigner: Signer

        Optional signer for the envelope

      • Optionalrecipients: XIDDocument[]

        Array of recipient XID documents for encryption

      Returns Envelope$1

      The sealed response as an envelope

    • Parses a sealed response from an encrypted envelope.

      Parameters

      • encryptedEnvelope: Envelope$1

        The encrypted envelope to parse

      • expectedId: ARID | undefined

        Optional expected request ID for validation

      • now: Date | undefined

        Optional current time for continuation validation

      • recipientPrivateKey: PrivateKeys

        The recipient's private keys for decryption

      Returns SealedResponse

      The parsed sealed response

    • Returns a string representation of the sealed response.

      Returns string