Utility class for generating data for testing.

Constructors

Methods

  • Generates a dummy authorization property for a DWN message that only conforms to schema validation.

    Returns AuthorizationModel

  • Generates a dummy authorization property for a DWN message that only conforms to schema validation.

    Returns GeneralJws

  • Parameters

    • Optional input: GenerateEventsGetInput

    Returns Promise<GenerateEventsGetOutput>

  • Parameters

    • input: GenerateEventsQueryInput

    Returns Promise<GenerateEventsQueryOutput>

  • Generates a EventsSubscribe message for testing.

    Parameters

    • Optional input: GenerateEventsSubscribeInput

    Returns Promise<GenerateEventsSubscribeOutput>

  • Generates a valid RecordsWrite that modifies the given an existing write. Any mutable property is not specified will be automatically mutated. e.g. if published is not specified, it will be toggled from the state of the given existing write.

    Parameters

    • input: GenerateFromRecordsWriteInput

    Returns Promise<GenerateFromRecordsWriteOut>

  • Parameters

    • input: GenerateMessagesGetInput

    Returns Promise<GenerateMessagesGetOutput>

  • Generates a encrypted RecordsWrite message for testing.

    Parameters

    • input: {
          author: Persona;
          encryptSymmetricKeyWithProtocolContextDerivedKey: boolean;
          encryptSymmetricKeyWithProtocolPathDerivedKey: boolean;
          plaintextBytes: Uint8Array;
          protocolContextDerivedPublicJwk?: PublicJwk;
          protocolContextDerivingRootKeyId?: string;
          protocolDefinition: ProtocolDefinition;
          protocolParentContextId?: string;
          protocolPath: string;
          recipient?: string;
      }
      • author: Persona
      • encryptSymmetricKeyWithProtocolContextDerivedKey: boolean

        Set to true to attach the symmetric key encrypted by the protocol context derived public key

      • encryptSymmetricKeyWithProtocolPathDerivedKey: boolean

        Set to true to attach the symmetric key encrypted by the protocol path derived public key

      • plaintextBytes: Uint8Array
      • Optional protocolContextDerivedPublicJwk?: PublicJwk
      • Optional protocolContextDerivingRootKeyId?: string
      • protocolDefinition: ProtocolDefinition

        Protocol definition used to generate the RecordsWrite. Must be the RECIPIENT's protocol definition if encryptSymmetricKeyWithProtocolPathDerivedKey is true, because the recipient's public keys will be needed to encrypt the symmetric key.

      • Optional protocolParentContextId?: string
      • protocolPath: string
      • Optional recipient?: string

    Returns Promise<{
        dataStream: Readable;
        encryptedDataBytes: Uint8Array;
        encryptionInput: EncryptionInput;
        message: RecordsWriteMessage;
        recordsWrite: RecordsWrite;
    }>

  • Generates a ProtocolsConfigure message for testing. Optional parameters are generated if not given. Implementation currently uses ProtocolsConfigure.create().

    Parameters

    • Optional input: GenerateProtocolsConfigureInput

    Returns Promise<GenerateProtocolsConfigureOutput>

  • Generates a ProtocolsQuery message for testing.

    Parameters

    • Optional input: GenerateProtocolsQueryInput

    Returns Promise<GenerateProtocolsQueryOutput>

  • Generates a RecordsDelete for testing.

    Parameters

    • Optional input: GenerateRecordsDeleteInput

    Returns Promise<GenerateRecordsDeleteOutput>

  • Generates a RecordsQuery message for testing.

    Parameters

    • Optional input: GenerateRecordsQueryInput

    Returns Promise<GenerateRecordsQueryOutput>

  • Generates a RecordsSubscribe message for testing.

    Parameters

    • Optional input: GenerateRecordsSubscribeInput

    Returns Promise<GenerateRecordsSubscribeOutput>

  • Generates a RecordsWrite message for testing. Implementation currently uses RecordsWrite.create().

    Parameters

    • Optional input: GenerateRecordsWriteInput

    Returns Promise<GenerateRecordsWriteOutput>

  • Generates a random within a range (inclusive).

    Parameters

    • min: number

      lowest potential value.

    • max: number

      greatest potential value.

    Returns number

  • Generates a random timestamp. Optionally allows you to set specific non-randomized values for the timestamp.

    Parameters

    • Optional options: {
          day?: number;
          hour?: number;
          microsecond?: number;
          millisecond?: number;
          minute?: number;
          month?: number;
          second?: number;
          year?: number;
      }
      • Optional day?: number
      • Optional hour?: number
      • Optional microsecond?: number
      • Optional millisecond?: number
      • Optional minute?: number
      • Optional month?: number
      • Optional second?: number
      • Optional year?: number

    Returns string

    random UTC ISO-8601 timestamp