/* tslint:disable */ /* eslint-disable */ /** * barkd REST API * A simple REST API for barkd, a wallet daemon for integrating bitcoin payments into your app over HTTP. Supports self-custodial Lightning, Ark, and on-chain out of the box. barkd is a long-running daemon best suited for always-on or high-connectivity environments like nodes, servers, desktops, and point-of-sale terminals. All endpoints return JSON. Amounts are denominated in satoshis. * * The version of the OpenAPI document: 0.6.2 * Contact: hello@second.tech * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import type { BadRequestError, InternalServerError, MessageVerification, SignMessageRequest, SignedMessage, VerifyMessageRequest, } from '../models/index'; import { BadRequestErrorFromJSON, BadRequestErrorToJSON, InternalServerErrorFromJSON, InternalServerErrorToJSON, MessageVerificationFromJSON, MessageVerificationToJSON, SignMessageRequestFromJSON, SignMessageRequestToJSON, SignedMessageFromJSON, SignedMessageToJSON, VerifyMessageRequestFromJSON, VerifyMessageRequestToJSON, } from '../models/index'; export interface SignMessageOperationRequest { signMessageRequest: SignMessageRequest; } export interface VerifyMessageOperationRequest { verifyMessageRequest: VerifyMessageRequest; } /** * */ export class MessageApi extends runtime.BaseAPI { /** * Creates request options for signMessage without sending the request */ async signMessageRequestOpts(requestParameters: SignMessageOperationRequest): Promise { if (requestParameters['signMessageRequest'] == null) { throw new runtime.RequiredError( 'signMessageRequest', 'Required parameter "signMessageRequest" was null or undefined when calling signMessage().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v1/message/sign`; return { path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: SignMessageRequestToJSON(requestParameters['signMessageRequest']), }; } /** * Signs an arbitrary message with a BIP-340 Schnorr signature over a prefixed hash (`SHA256(\"bark/message\" || message)`) of the UTF-8 message bytes. The message is signed with the key of the given Ark address, which must be one of the wallet\'s own addresses; addresses that do not belong to the wallet are rejected. The resulting signature can be checked with the `/message/verify` endpoint. * Sign a message */ async signMessageRaw(requestParameters: SignMessageOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.signMessageRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => SignedMessageFromJSON(jsonValue)); } /** * Signs an arbitrary message with a BIP-340 Schnorr signature over a prefixed hash (`SHA256(\"bark/message\" || message)`) of the UTF-8 message bytes. The message is signed with the key of the given Ark address, which must be one of the wallet\'s own addresses; addresses that do not belong to the wallet are rejected. The resulting signature can be checked with the `/message/verify` endpoint. * Sign a message */ async signMessage(requestParameters: SignMessageOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.signMessageRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for verifyMessage without sending the request */ async verifyMessageRequestOpts(requestParameters: VerifyMessageOperationRequest): Promise { if (requestParameters['verifyMessageRequest'] == null) { throw new runtime.RequiredError( 'verifyMessageRequest', 'Required parameter "verifyMessageRequest" was null or undefined when calling verifyMessage().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } let urlPath = `/api/v1/message/verify`; return { path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: VerifyMessageRequestToJSON(requestParameters['verifyMessageRequest']), }; } /** * Verifies a BIP-340 Schnorr signature over a prefixed hash (`SHA256(\"bark/message\" || message)`) of the UTF-8 message bytes, as created by the `/message/sign` endpoint. The signature is checked against a public key (`pubkey`) or against the user public key of an Ark address (`address`); exactly one of the two must be set. Verification is stateless and works for signatures made by any wallet, not just this one. * Verify a signed message */ async verifyMessageRaw(requestParameters: VerifyMessageOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.verifyMessageRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => MessageVerificationFromJSON(jsonValue)); } /** * Verifies a BIP-340 Schnorr signature over a prefixed hash (`SHA256(\"bark/message\" || message)`) of the UTF-8 message bytes, as created by the `/message/sign` endpoint. The signature is checked against a public key (`pubkey`) or against the user public key of an Ark address (`address`); exactly one of the two must be set. Verification is stateless and works for signatures made by any wallet, not just this one. * Verify a signed message */ async verifyMessage(requestParameters: VerifyMessageOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.verifyMessageRaw(requestParameters, initOverrides); return await response.value(); } }