UNPKG

originstamp-client-fetch

Version:
173 lines (138 loc) 8.28 kB
/* tslint:disable */ /* eslint-disable */ /** * OriginStamp Timestamping * OriginStamp Timestamping leverages decentralized blockchain technology to create anonymous, tamper-proof timestamps for digital content. This service enables users to timestamp files, emails, or plain text, and store the resulting hashes on the blockchain. Users can also retrieve and verify timestamps that have been committed. The trusted timestamping mechanism ensures that a hash fingerprint can be generated and used as proof that specific data existed at a given point in time. * * The version of the OpenAPI document: 1.0.0 * Contact: support@originstamp.com * * 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 { ErrorMessage, ProofRequest, TimestampData, TimestampRequest, TimestampResponse, } from '../models/index'; import { ErrorMessageFromJSON, ErrorMessageToJSON, ProofRequestFromJSON, ProofRequestToJSON, TimestampDataFromJSON, TimestampDataToJSON, TimestampRequestFromJSON, TimestampRequestToJSON, TimestampResponseFromJSON, TimestampResponseToJSON, } from '../models/index'; export interface CreateTimestampRequest { timestampRequest?: TimestampRequest; } export interface GetProofRequest { proofRequest?: ProofRequest; } export interface GetTreeStatusRequest { treeId: string; } /** * */ export class TimestampApi extends runtime.BaseAPI { /** * Submits a new hash to be timestamped. If the hash has not been submitted previously, a new timestamp will be created and and the associated tree returned. If the hash has already been submitted and a timestamp exists, the request will not create a new entry but will return the previously associated timestamp information with a `202 Accepted` response. * Submission */ async createTimestampRaw(requestParameters: CreateTimestampRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<TimestampResponse>> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key"); // API_Key_Authorization authentication } let urlPath = `/v1/timestamp`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: TimestampRequestToJSON(requestParameters['timestampRequest']), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => TimestampResponseFromJSON(jsonValue)); } /** * Submits a new hash to be timestamped. If the hash has not been submitted previously, a new timestamp will be created and and the associated tree returned. If the hash has already been submitted and a timestamp exists, the request will not create a new entry but will return the previously associated timestamp information with a `202 Accepted` response. * Submission */ async createTimestamp(requestParameters: CreateTimestampRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TimestampResponse> { const response = await this.createTimestampRaw(requestParameters, initOverrides); return await response.value(); } /** * Initiates a proof request for a previously submitted hash. This request does not return the proof immediately. If the transaction associated with the hash has been verified, the proof will be generated and delivered asynchronously via a pre-registered webhook. If the transaction has not yet been verified, the request will respond with `425 Too Early`. You should not poll this endpoint for results. Instead, you must ensure that a webhook listener is available to receive the final proof. * Proof */ async getProofRaw(requestParameters: GetProofRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> { const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key"); // API_Key_Authorization authentication } let urlPath = `/v1/proof`; const response = await this.request({ path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: ProofRequestToJSON(requestParameters['proofRequest']), }, initOverrides); return new runtime.VoidApiResponse(response); } /** * Initiates a proof request for a previously submitted hash. This request does not return the proof immediately. If the transaction associated with the hash has been verified, the proof will be generated and delivered asynchronously via a pre-registered webhook. If the transaction has not yet been verified, the request will respond with `425 Too Early`. You should not poll this endpoint for results. Instead, you must ensure that a webhook listener is available to receive the final proof. * Proof */ async getProof(requestParameters: GetProofRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> { await this.getProofRaw(requestParameters, initOverrides); } /** * Retrieves the submit status of the root node for the given tree. This endpoint allows clients to track the overall verification progress of all SHA-256 hashes aggregated under the same tree, instead of querying individual hash status. Trees represent batches of hashes that are bundled together before being submitted to a blockchain. The returned information includes the current submission status and timestamp details, if available. * Status Tree */ async getTreeStatusRaw(requestParameters: GetTreeStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<TimestampData>> { if (requestParameters['treeId'] == null) { throw new runtime.RequiredError( 'treeId', 'Required parameter "treeId" was null or undefined when calling getTreeStatus().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key"); // API_Key_Authorization authentication } let urlPath = `/v1/tree/{treeId}`; urlPath = urlPath.replace(`{${"treeId"}}`, encodeURIComponent(String(requestParameters['treeId']))); const response = await this.request({ path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => TimestampDataFromJSON(jsonValue)); } /** * Retrieves the submit status of the root node for the given tree. This endpoint allows clients to track the overall verification progress of all SHA-256 hashes aggregated under the same tree, instead of querying individual hash status. Trees represent batches of hashes that are bundled together before being submitted to a blockchain. The returned information includes the current submission status and timestamp details, if available. * Status Tree */ async getTreeStatus(requestParameters: GetTreeStatusRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TimestampData> { const response = await this.getTreeStatusRaw(requestParameters, initOverrides); return await response.value(); } }