@otskit/client 0.5.0 → 0.6.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/README.md CHANGED
@@ -12,6 +12,8 @@
12
12
  [![npm downloads](https://img.shields.io/npm/dt/@otskit/client.svg)](https://www.npmjs.com/package/@otskit/client)
13
13
  [![TypeScript](https://img.shields.io/badge/TypeScript-6-blue.svg)](https://www.typescriptlang.org/)
14
14
  [![Node ≥20](https://img.shields.io/badge/node-%3E%3D20-brightgreen)](https://nodejs.org)
15
+ [![Coverage](https://codecov.io/gh/OTSkit/OTSkit-client/branch/main/graph/badge.svg)](https://codecov.io/gh/OTSkit/OTSkit-client)
16
+ [![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=OTSkit_OTSkit-client&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=OTSkit_OTSkit-client)
15
17
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
16
18
 
17
19
  `@otskit/client` is the official client SDK for submitting, upgrading, and verifying [OpenTimestamps](https://opentimestamps.org) proofs. It sits on top of [@otskit/core](https://github.com/OTSkit/OTSkit-core) — the low-level protocol engine — and wraps it in a high-level API with production-ready resilience patterns built in.
@@ -33,14 +35,14 @@
33
35
  ### Developer Experience
34
36
  - **TypeScript-first** — Strict types throughout; full IntelliSense for every option and error
35
37
  - **Node.js 20+** — Requires Node.js; uses native `crypto`, `dns`, and `net` APIs not available in browsers or edge runtimes
36
- - **Tree-shakeable** — Dual ESM/CJS build, zero runtime dependencies
38
+ - **Tree-shakeable** — Dual ESM/CJS build; `@otskit/core` is the only runtime dependency, no third-party packages
37
39
  - **`AbortController` support** — Cancel any in-flight operation at any level
38
40
  - **Observable** — Drop-in `Logger` interface compatible with `console`, `pino`, `winston`, etc.
39
41
  - **Built-in SHA-256 helpers** — `hashFile()` and `hashBuffer()` so you don't need to wire up `crypto` yourself
40
42
 
41
43
  ---
42
44
 
43
- > **Note on confirmation times:** After `stamp()`, the proof is `pending` — registered with calendar servers but not yet anchored to Bitcoin. Confirmations typically arrive within **10–60 minutes**, but can take **several hours** during periods of high network congestion. Call `upgrade()` periodically to check; an `UpgradeError` simply means the blockchain hasn't confirmed yet, not that anything went wrong.
45
+ > **Note on confirmation times:** After `stamp()`, the proof is `pending` — registered with calendar servers but not yet anchored to Bitcoin. Confirmations typically arrive within **~60 minutes**, but can take **several hours** during network congestion. Call `upgrade()` periodically to check; a pending proof is not a failed proof — an `UpgradeError` simply means the blockchain hasn't confirmed yet.
44
46
 
45
47
  ---
46
48
 
@@ -50,7 +52,7 @@
50
52
  npm install @otskit/client
51
53
  ```
52
54
 
53
- `@otskit/core` is a peer dependency bundled as a `file:` reference in monorepo setups; no separate install is needed.
55
+ `@otskit/core` is a regular dependency and installs automatically; no separate install is needed.
54
56
 
55
57
  ---
56
58
 
@@ -68,7 +70,7 @@ const hash = await hashFile('contract.pdf')
68
70
  // 2. Submit to calendars → get a pending .ots proof
69
71
  const pendingProof = await client.stamp(hash)
70
72
  writeFileSync('contract.pdf.ots', pendingProof)
71
- console.log('Proof saved — Bitcoin confirmation usually arrives in 10–60 minutes.')
73
+ console.log('Proof saved — Bitcoin confirmation usually arrives in ~60 minutes.')
72
74
 
73
75
  // 3. Later: query calendars for a Bitcoin confirmation
74
76
  const upgradedProof = await client.upgrade(pendingProof)
@@ -558,7 +560,7 @@ This repository uses [Conventional Commits](https://www.conventionalcommits.org)
558
560
  - TypeScript strict mode
559
561
  - ESLint + Prettier (run `npm run format` before pushing)
560
562
  - Fail-closed: all external input is validated at the boundary
561
- - No runtime dependencies
563
+ - No third-party runtime dependencies (`@otskit/core` is the only dependency)
562
564
 
563
565
  ---
564
566
 
@@ -571,4 +573,4 @@ This repository uses [Conventional Commits](https://www.conventionalcommits.org)
571
573
 
572
574
  ## License
573
575
 
574
- MIT
576
+ MIT © OTSkit contributors — see [LICENSE](LICENSE).
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Type definitions for the OpenTimestamps Client SDK
3
+ */
4
+ /** Logger interface for observability. */
5
+ interface Logger {
6
+ debug(message: string, ...args: unknown[]): void;
7
+ info(message: string, ...args: unknown[]): void;
8
+ warn(message: string, ...args: unknown[]): void;
9
+ error(message: string, ...args: unknown[]): void;
10
+ }
11
+
12
+ /** SHA-256 via the platform Web Crypto — identical in Node 20+ and browsers. */
13
+ declare function hashBytes(data: Uint8Array): Promise<Uint8Array>;
14
+ /** Hash a user-selected File/Blob without a Node stream. */
15
+ declare function hashBlob(blob: Blob): Promise<Uint8Array>;
16
+
17
+ declare function bytesToHex(bytes: Uint8Array): string;
18
+
19
+ /** Calendars confirmed to accept browser-origin CORS requests (verified 2026-07-28). */
20
+ declare const BROWSER_CALENDARS: readonly ["https://a.pool.opentimestamps.org", "https://b.pool.opentimestamps.org", "https://a.pool.eternitywall.com"];
21
+ interface BrowserClientOptions {
22
+ minimumSuccessfulSubmissions?: number;
23
+ logger?: Logger;
24
+ }
25
+ /** Browser-only OpenTimestamps client: stamp a hash, get back a pending .ots (Uint8Array). */
26
+ declare class OpenTimestampsBrowserClient {
27
+ private readonly calendars;
28
+ private readonly minSubs;
29
+ private readonly layer;
30
+ private readonly logger?;
31
+ constructor(options?: BrowserClientOptions);
32
+ /** hash: 32-byte Uint8Array or 64-char hex. Returns the pending .ots as Uint8Array. */
33
+ stamp(hash: Uint8Array | string): Promise<Uint8Array>;
34
+ }
35
+
36
+ export { BROWSER_CALENDARS, type BrowserClientOptions, OpenTimestampsBrowserClient, bytesToHex, hashBlob, hashBytes };