@passes/reqs / Exports / SignedRequestTopic
Class: SignedRequestTopic<TRequestBody, TResultBody>
Wraps a RequestTopic to implement result signing and verification.
Implements
Type parameters
| Name |
|---|
TRequestBody |
TResultBody |
Hierarchy
↳
SignedRequestTopic
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new SignedRequestTopic<TRequestBody, TResultBody>(params): SignedRequestTopic<TRequestBody, TResultBody>
Type parameters
| Name |
|---|
TRequestBody |
TResultBody |
Parameters
| Name | Type |
|---|---|
params | SignedRequestTopicParams<TRequestBody, TResultBody> |
Returns
SignedRequestTopic<TRequestBody, TResultBody>
Overrides
Defined in
Properties
abi
• abi: PassesABI
Inherited from
Defined in
id
• id: string
Inherited from
Defined in
requestBodyCodec
• requestBodyCodec: Codec<any>
Inherited from
Defined in
resultBodyCodec
• resultBodyCodec: Codec<any>
Inherited from
Defined in
signResult
• signResult: (body: TResultBody) => Promise<SignedBodyWrapperHeader>
Type declaration
▸ (body): Promise<SignedBodyWrapperHeader>
Parameters
| Name | Type |
|---|---|
body | TResultBody |
Returns
Promise<SignedBodyWrapperHeader>
Defined in
verifyResult
• verifyResult: (signed: SignedBodyWrapper<TResultBody>) => Promise<boolean>
Type declaration
▸ (signed): Promise<boolean>
Parameters
| Name | Type |
|---|---|
signed | SignedBodyWrapper<TResultBody> |
Returns
Promise<boolean>
Defined in
Errors
▪ Static Errors: Object
Type declaration
| Name | Type |
|---|---|
ABI_NOT_AVAILABLE | typeof RequestTopicABINotAvailable |
CANNOT_SIGN | typeof SignedRequestTopicCannotSign |
CANNOT_VERIFY | typeof SignedRequestTopicCannotVerify |
INCORRECT_TOPIC | typeof RequestTopicIncorrectTopicError |
INVALID_SIGNATURE | typeof SignedRequestTopicInvalidSignature |
Overrides
Defined in
Methods
decodeRequest
▸ decodeRequest(bytes): Promise<any>
Decodes an envelope-v0x00 request into a structured request body.
Parameters
| Name | Type |
|---|---|
bytes | Uint8Array |
Returns
Promise<any>
Inherited from
Defined in
decodeResult
▸ decodeResult(bytes): Promise<SignedRequestResult<TResultBody>>
Returns the signed result's body if the result signature is valid. Throws if the signature is invalid.
Parameters
| Name | Type |
|---|---|
bytes | Uint8Array |
Returns
Promise<SignedRequestResult<TResultBody>>
Throws
- Throws an INVALID_SIGNATURE error if the signature does not represent match the body and public key
Throws
- Throws a CANNOT_VERIFY error if no verifyResult implementation was provided at construction
Overrides
Defined in
encodeRequest
▸ encodeRequest(body): Promise<Uint8Array>
Encodes a structured request body into an envelope-v0x00 request.
Parameters
| Name | Type |
|---|---|
body | any |
Returns
Promise<Uint8Array>
Inherited from
Defined in
encodeResult
▸ encodeResult(result): Promise<Uint8Array>
Encodes a structured result body into a signed result.
Parameters
| Name | Type |
|---|---|
result | SignedRequestResult<TResultBody> |
Returns
Promise<Uint8Array>
Throws
- Throws a CANNOT_SIGN error if no signResult implementation was provided at construction
Overrides
Defined in
resolveABI
▸ resolveABI(): PassesABI
A helper for resolving the PassesABI. If the instance has no abi property, it returns document.passes if it's available.
Returns
Throws
- document.passes must be available if
abiis not passed.
Inherited from
Defined in
sendRequest
▸ sendRequest(reqBody): Promise<RequestResult<TResultBody>>
Sends a request.
Parameters
| Name | Type |
|---|---|
reqBody | TRequestBody |
Returns
Promise<RequestResult<TResultBody>>
Overrides
Defined in
toString
▸ toString(): string
Returns a string representation of the request topic.
Returns
string
Inherited from
Defined in
withABI
▸ withABI(abi): RequestTopic<any, any>
Returns a new RequestTopic instance with the same id and codecs, but with a new ABI.
Parameters
| Name | Type |
|---|---|
abi | PassesABI |
Returns
RequestTopic<any, any>