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

    Class SealedRequest

    A sealed request that combines a Request with sender information and state continuations for secure communication.

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

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

    // Create a sealed request
    const request = SealedRequest.new("getBalance", requestId, sender)
    .withParameter("account", "alice")
    .withState("session-state-data")
    .withNote("Balance check");

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

    Implements

    Index

    Methods

    • Creates a new sealed request with the given function, ID, and sender.

      Parameters

      • func: string | number | Function

        The function to call (string name or Function object)

      • id: ARID

        The request ID

      • sender: XIDDocument

        The sender's XID document

      Returns SealedRequest

    • Creates a new sealed request with an expression body.

      Parameters

      • body: Expression

        The expression body

      • id: ARID

        The request ID

      • sender: XIDDocument

        The sender's XID document

      Returns SealedRequest

    • Adds a parameter to the request.

      Parameters

      • parameter: ParameterID
      • value: EnvelopeEncodableValue

      Returns SealedRequest

    • Adds an optional parameter to the request.

      Parameters

      • parameter: ParameterID
      • value: EnvelopeEncodableValue

      Returns SealedRequest

    • Returns the function of the request.

      Returns Function

    • Returns the expression envelope of the request.

      Returns Envelope$1

    • Returns the object for a parameter.

      Parameters

      • param: ParameterID

      Returns Envelope$1 | undefined

    • Returns all objects for a parameter.

      Parameters

      • param: ParameterID

      Returns Envelope$1[]

    • Extracts an object for a parameter as a specific type.

      Type Parameters

      • T

      Parameters

      • param: ParameterID

      Returns T

    • Extracts an optional object for a parameter.

      Type Parameters

      • T

      Parameters

      • param: ParameterID

      Returns T | undefined

    • Extracts all objects for a parameter as a specific type.

      Type Parameters

      • T

      Parameters

      • param: ParameterID

      Returns T[]

    • Returns the date of the request.

      Returns Date | undefined

    • Converts the sealed request to a Request.

      Returns Request

    • Converts the sealed request to an Expression.

      Returns Expression

    • 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 request 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 request as an envelope

    • Parses a sealed request 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

      • recipient: PrivateKeys

        The recipient's private keys for decryption

      Returns SealedRequest

      The parsed sealed request

    • Returns a string representation of the sealed request.

      Returns string