@otskit/client 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -44,6 +44,8 @@ __export(index_exports, {
44
44
  UpgradeError: () => UpgradeError,
45
45
  UrlWhitelist: () => UrlWhitelist,
46
46
  ValidationError: () => ValidationError,
47
+ hashBuffer: () => hashBuffer,
48
+ hashFile: () => hashFile,
47
49
  verifyAgainstBlockheader: () => verifyAgainstBlockheader,
48
50
  verifyTimestampAttestation: () => verifyTimestampAttestation
49
51
  });
@@ -2418,6 +2420,19 @@ var OpenTimestampsClient = class {
2418
2420
  this.networkLayer.resetAllCircuits();
2419
2421
  }
2420
2422
  };
2423
+
2424
+ // src/utils/hash.ts
2425
+ var import_crypto = require("crypto");
2426
+ var import_fs = require("fs");
2427
+ function hashBuffer(data) {
2428
+ return (0, import_crypto.createHash)("sha256").update(data).digest();
2429
+ }
2430
+ function hashFile(path) {
2431
+ return new Promise((resolve, reject) => {
2432
+ const hash = (0, import_crypto.createHash)("sha256");
2433
+ (0, import_fs.createReadStream)(path).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve(hash.digest())).on("error", reject);
2434
+ });
2435
+ }
2421
2436
  // Annotate the CommonJS export names for ESM import in node:
2422
2437
  0 && (module.exports = {
2423
2438
  CalendarClient,
@@ -2444,6 +2459,8 @@ var OpenTimestampsClient = class {
2444
2459
  UpgradeError,
2445
2460
  UrlWhitelist,
2446
2461
  ValidationError,
2462
+ hashBuffer,
2463
+ hashFile,
2447
2464
  verifyAgainstBlockheader,
2448
2465
  verifyTimestampAttestation
2449
2466
  });
package/dist/index.d.cts CHANGED
@@ -358,4 +358,7 @@ declare class EsploraClient {
358
358
  */
359
359
  declare function verifyTimestampAttestation(digest: Uint8Array, attestation: Attestation, explorer: EsploraClient, signal?: AbortSignal): Promise<number>;
360
360
 
361
- export { type BackoffStrategy, CalendarClient, CalendarResponseTooLargeError, CircuitBreakerError, type CircuitBreakerOptions, CircuitState, type ClientOptions, CommitmentNotFoundError, DEFAULT_AGGREGATORS, DEFAULT_CALENDARS, DEFAULT_CALENDAR_WHITELIST, DEFAULT_RESILIENCE, EsploraClient, type EsploraClientOptions, EsploraResponseError, type JitterType, type Logger, MAX_CALENDAR_RESPONSE_SIZE, MAX_ESPLORA_RESPONSE_SIZE, NetworkError, OpenTimestampsClient, OpenTimestampsClientError, type OperationOptions, PUBLIC_ESPLORA_URL, type ResilienceOptions, ResilientNetworkLayer, type RetryOptions, StampError, UpgradeError, UrlWhitelist, ValidationError, type VerificationResult, verifyTimestampAttestation };
361
+ declare function hashBuffer(data: Buffer | Uint8Array): Buffer;
362
+ declare function hashFile(path: string): Promise<Buffer>;
363
+
364
+ export { type BackoffStrategy, CalendarClient, CalendarResponseTooLargeError, CircuitBreakerError, type CircuitBreakerOptions, CircuitState, type ClientOptions, CommitmentNotFoundError, DEFAULT_AGGREGATORS, DEFAULT_CALENDARS, DEFAULT_CALENDAR_WHITELIST, DEFAULT_RESILIENCE, EsploraClient, type EsploraClientOptions, EsploraResponseError, type JitterType, type Logger, MAX_CALENDAR_RESPONSE_SIZE, MAX_ESPLORA_RESPONSE_SIZE, NetworkError, OpenTimestampsClient, OpenTimestampsClientError, type OperationOptions, PUBLIC_ESPLORA_URL, type ResilienceOptions, ResilientNetworkLayer, type RetryOptions, StampError, UpgradeError, UrlWhitelist, ValidationError, type VerificationResult, hashBuffer, hashFile, verifyTimestampAttestation };
package/dist/index.d.ts CHANGED
@@ -358,4 +358,7 @@ declare class EsploraClient {
358
358
  */
359
359
  declare function verifyTimestampAttestation(digest: Uint8Array, attestation: Attestation, explorer: EsploraClient, signal?: AbortSignal): Promise<number>;
360
360
 
361
- export { type BackoffStrategy, CalendarClient, CalendarResponseTooLargeError, CircuitBreakerError, type CircuitBreakerOptions, CircuitState, type ClientOptions, CommitmentNotFoundError, DEFAULT_AGGREGATORS, DEFAULT_CALENDARS, DEFAULT_CALENDAR_WHITELIST, DEFAULT_RESILIENCE, EsploraClient, type EsploraClientOptions, EsploraResponseError, type JitterType, type Logger, MAX_CALENDAR_RESPONSE_SIZE, MAX_ESPLORA_RESPONSE_SIZE, NetworkError, OpenTimestampsClient, OpenTimestampsClientError, type OperationOptions, PUBLIC_ESPLORA_URL, type ResilienceOptions, ResilientNetworkLayer, type RetryOptions, StampError, UpgradeError, UrlWhitelist, ValidationError, type VerificationResult, verifyTimestampAttestation };
361
+ declare function hashBuffer(data: Buffer | Uint8Array): Buffer;
362
+ declare function hashFile(path: string): Promise<Buffer>;
363
+
364
+ export { type BackoffStrategy, CalendarClient, CalendarResponseTooLargeError, CircuitBreakerError, type CircuitBreakerOptions, CircuitState, type ClientOptions, CommitmentNotFoundError, DEFAULT_AGGREGATORS, DEFAULT_CALENDARS, DEFAULT_CALENDAR_WHITELIST, DEFAULT_RESILIENCE, EsploraClient, type EsploraClientOptions, EsploraResponseError, type JitterType, type Logger, MAX_CALENDAR_RESPONSE_SIZE, MAX_ESPLORA_RESPONSE_SIZE, NetworkError, OpenTimestampsClient, OpenTimestampsClientError, type OperationOptions, PUBLIC_ESPLORA_URL, type ResilienceOptions, ResilientNetworkLayer, type RetryOptions, StampError, UpgradeError, UrlWhitelist, ValidationError, type VerificationResult, hashBuffer, hashFile, verifyTimestampAttestation };
package/dist/index.js CHANGED
@@ -2367,6 +2367,19 @@ var OpenTimestampsClient = class {
2367
2367
  this.networkLayer.resetAllCircuits();
2368
2368
  }
2369
2369
  };
2370
+
2371
+ // src/utils/hash.ts
2372
+ import { createHash } from "crypto";
2373
+ import { createReadStream } from "fs";
2374
+ function hashBuffer(data) {
2375
+ return createHash("sha256").update(data).digest();
2376
+ }
2377
+ function hashFile(path) {
2378
+ return new Promise((resolve, reject) => {
2379
+ const hash = createHash("sha256");
2380
+ createReadStream(path).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve(hash.digest())).on("error", reject);
2381
+ });
2382
+ }
2370
2383
  export {
2371
2384
  CalendarClient,
2372
2385
  CalendarResponseTooLargeError,
@@ -2392,6 +2405,8 @@ export {
2392
2405
  UpgradeError,
2393
2406
  UrlWhitelist,
2394
2407
  ValidationError,
2408
+ hashBuffer,
2409
+ hashFile,
2395
2410
  verifyAgainstBlockheader,
2396
2411
  verifyTimestampAttestation
2397
2412
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@otskit/client",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "Official client SDK for OpenTimestamps calendars with resilience patterns",
5
5
  "author": "alexalves87",
6
6
  "license": "MIT",