@uvrn/sdk 1.0.1 → 1.0.3

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
@@ -2,6 +2,8 @@
2
2
 
3
3
  TypeScript SDK for the [UVRN Delta Engine](https://github.com/UVRN-org/uvrn-packages) — programmatic access to deterministic verification and consensus computation.
4
4
 
5
+ **Disclaimer:** UVRN is in Alpha testing. The engine measures whether your sources agree with each other — not whether they’re correct. Final trust of output rests with the user. Use at your own risk. Have fun.
6
+
5
7
  ## Overview
6
8
 
7
9
  The Delta Engine SDK provides a developer-friendly interface to interact with the Delta Engine in multiple execution modes:
@@ -107,7 +109,7 @@ Spawns the Delta Engine CLI as a child process:
107
109
  ```typescript
108
110
  const client = new DeltaEngineClient({
109
111
  mode: 'cli',
110
- cliPath: '/usr/local/bin/delta-engine', // or './node_modules/.bin/delta-engine'
112
+ cliPath: '/usr/local/bin/uvrn', // or './node_modules/.bin/uvrn'
111
113
  timeout: 30000
112
114
  });
113
115
  ```
@@ -311,6 +313,8 @@ See the [examples directory](./examples/) for complete working examples:
311
313
 
312
314
  ## Links
313
315
 
316
+ **Open source:** Source code and issues: [GitHub (uvrn-packages)](https://github.com/UVRN-org/uvrn-packages). Project landing: [UVRN](https://github.com/UVRN-org/uvrn).
317
+
314
318
  - [Repository](https://github.com/UVRN-org/uvrn-packages) — monorepo (this package: `uvrn-sdk`)
315
319
  - [SDK Guide](./docs/SDK_GUIDE.md) — comprehensive usage guide
316
320
  - [@uvrn/core](https://www.npmjs.com/package/@uvrn/core) — Delta Engine core (used in local mode)
@@ -0,0 +1,192 @@
1
+ /**
2
+ * Bundle Builder - Fluent API for constructing Delta Bundles
3
+ */
4
+ import type { DeltaBundle, DataSpec, MetricPoint } from '@uvrn/core';
5
+ import type { BundleBuilderOptions, ValidationResult } from './types/sdk';
6
+ /**
7
+ * Fluent API for building Delta Bundles
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const bundle = new BundleBuilder()
12
+ * .setBundleId('my-bundle')
13
+ * .setClaim('Q1 revenue matches projections')
14
+ * .addDataSpec({
15
+ * id: 'forecast',
16
+ * label: 'Q1 Forecast',
17
+ * sourceKind: 'report',
18
+ * originDocIds: ['doc-1'],
19
+ * metrics: [{ key: 'revenue', value: 1000000 }]
20
+ * })
21
+ * .addDataSpec({
22
+ * id: 'actual',
23
+ * label: 'Q1 Actual',
24
+ * sourceKind: 'report',
25
+ * originDocIds: ['doc-2'],
26
+ * metrics: [{ key: 'revenue', value: 1020000 }]
27
+ * })
28
+ * .setThreshold(0.05)
29
+ * .build();
30
+ * ```
31
+ */
32
+ export declare class BundleBuilder {
33
+ private bundleId;
34
+ private claim;
35
+ private dataSpecs;
36
+ private thresholdPct;
37
+ private maxRounds?;
38
+ /**
39
+ * Creates a new BundleBuilder
40
+ *
41
+ * @param options - Optional initial configuration
42
+ */
43
+ constructor(options?: BundleBuilderOptions);
44
+ /**
45
+ * Generates a unique bundle ID
46
+ * @internal
47
+ */
48
+ private generateBundleId;
49
+ /**
50
+ * Sets the bundle ID
51
+ *
52
+ * @param bundleId - Unique identifier for this bundle
53
+ * @returns this builder instance for chaining
54
+ */
55
+ setBundleId(bundleId: string): this;
56
+ /**
57
+ * Sets the claim statement
58
+ *
59
+ * @param claim - The claim this bundle will verify
60
+ * @returns this builder instance for chaining
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * builder.setClaim('Revenue projections are within 10% of actuals');
65
+ * ```
66
+ */
67
+ setClaim(claim: string): this;
68
+ /**
69
+ * Adds a DataSpec to the bundle
70
+ *
71
+ * @param spec - Complete DataSpec object
72
+ * @returns this builder instance for chaining
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * builder.addDataSpec({
77
+ * id: 'source-1',
78
+ * label: 'Forecast Data',
79
+ * sourceKind: 'report',
80
+ * originDocIds: ['doc-123'],
81
+ * metrics: [
82
+ * { key: 'revenue', value: 1000000, unit: 'USD' }
83
+ * ]
84
+ * });
85
+ * ```
86
+ */
87
+ addDataSpec(spec: DataSpec): this;
88
+ /**
89
+ * Creates and adds a DataSpec with a fluent interface
90
+ *
91
+ * @param id - Unique identifier
92
+ * @param label - Human-readable label
93
+ * @param sourceKind - Type of data source
94
+ * @param originDocIds - Source document IDs
95
+ * @param metrics - Metric data points
96
+ * @returns this builder instance for chaining
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * builder.addDataSpecQuick(
101
+ * 'source-1',
102
+ * 'Forecast',
103
+ * 'report',
104
+ * ['doc-123'],
105
+ * [{ key: 'revenue', value: 1000000 }]
106
+ * );
107
+ * ```
108
+ */
109
+ addDataSpecQuick(id: string, label: string, sourceKind: 'report' | 'metric' | 'chart' | 'meta', originDocIds: string[], metrics: MetricPoint[]): this;
110
+ /**
111
+ * Sets the threshold percentage for delta comparison
112
+ *
113
+ * @param threshold - Threshold as a decimal (0.0 to 1.0)
114
+ * @returns this builder instance for chaining
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * builder.setThreshold(0.10); // 10% threshold
119
+ * ```
120
+ */
121
+ setThreshold(threshold: number): this;
122
+ /**
123
+ * Sets the threshold percentage using a percentage value
124
+ *
125
+ * @param percent - Threshold as percentage (0 to 100)
126
+ * @returns this builder instance for chaining
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * builder.setThresholdPercent(10); // 10% threshold
131
+ * ```
132
+ */
133
+ setThresholdPercent(percent: number): this;
134
+ /**
135
+ * Sets the maximum number of rounds
136
+ *
137
+ * @param rounds - Maximum rounds (defaults to 5 if not set)
138
+ * @returns this builder instance for chaining
139
+ */
140
+ setMaxRounds(rounds: number): this;
141
+ /**
142
+ * Validates the current bundle configuration without building
143
+ *
144
+ * @returns ValidationResult indicating if the bundle is valid
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const result = builder.validate();
149
+ * if (!result.valid) {
150
+ * console.error('Bundle configuration is invalid:', result.errors);
151
+ * }
152
+ * ```
153
+ */
154
+ validate(): ValidationResult;
155
+ /**
156
+ * Converts current configuration to a DeltaBundle object (without validation)
157
+ * @internal
158
+ */
159
+ private toBundle;
160
+ /**
161
+ * Builds and returns the final DeltaBundle
162
+ *
163
+ * @throws {ValidationError} if the bundle configuration is invalid
164
+ * @returns Complete, validated DeltaBundle
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * try {
169
+ * const bundle = builder.build();
170
+ * // Use bundle...
171
+ * } catch (error) {
172
+ * if (error instanceof ValidationError) {
173
+ * console.error('Invalid bundle:', error.errors);
174
+ * }
175
+ * }
176
+ * ```
177
+ */
178
+ build(): DeltaBundle;
179
+ /**
180
+ * Resets the builder to initial state (keeps bundleId)
181
+ *
182
+ * @returns this builder instance for chaining
183
+ */
184
+ reset(): this;
185
+ /**
186
+ * Creates a new builder instance with a fresh bundle ID
187
+ *
188
+ * @returns new BundleBuilder instance
189
+ */
190
+ static create(options?: BundleBuilderOptions): BundleBuilder;
191
+ }
192
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK1E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,SAAS,CAAC,CAAS;IAE3B;;;;OAIG;gBACS,OAAO,CAAC,EAAE,oBAAoB;IAO1C;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKnC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAKjC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,gBAAgB,CACd,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,EAClD,YAAY,EAAE,MAAM,EAAE,EACtB,OAAO,EAAE,WAAW,EAAE,GACrB,IAAI;IAUP;;;;;;;;;;OAUG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKrC;;;;;;;;;;OAUG;IACH,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK1C;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKlC;;;;;;;;;;;;OAYG;IACH,QAAQ,IAAI,gBAAgB;IAK5B;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAehB;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,IAAI,WAAW;IAcpB;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAQb;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,aAAa;CAG7D"}
@@ -0,0 +1,264 @@
1
+ "use strict";
2
+ /**
3
+ * Bundle Builder - Fluent API for constructing Delta Bundles
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.BundleBuilder = void 0;
7
+ const validators_1 = require("./validators");
8
+ const errors_1 = require("./errors");
9
+ const crypto_1 = require("crypto");
10
+ /**
11
+ * Fluent API for building Delta Bundles
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const bundle = new BundleBuilder()
16
+ * .setBundleId('my-bundle')
17
+ * .setClaim('Q1 revenue matches projections')
18
+ * .addDataSpec({
19
+ * id: 'forecast',
20
+ * label: 'Q1 Forecast',
21
+ * sourceKind: 'report',
22
+ * originDocIds: ['doc-1'],
23
+ * metrics: [{ key: 'revenue', value: 1000000 }]
24
+ * })
25
+ * .addDataSpec({
26
+ * id: 'actual',
27
+ * label: 'Q1 Actual',
28
+ * sourceKind: 'report',
29
+ * originDocIds: ['doc-2'],
30
+ * metrics: [{ key: 'revenue', value: 1020000 }]
31
+ * })
32
+ * .setThreshold(0.05)
33
+ * .build();
34
+ * ```
35
+ */
36
+ class BundleBuilder {
37
+ bundleId;
38
+ claim = '';
39
+ dataSpecs = [];
40
+ thresholdPct = 0.05; // Default 5%
41
+ maxRounds;
42
+ /**
43
+ * Creates a new BundleBuilder
44
+ *
45
+ * @param options - Optional initial configuration
46
+ */
47
+ constructor(options) {
48
+ this.bundleId = options?.bundleId || this.generateBundleId();
49
+ if (options?.claim)
50
+ this.claim = options.claim;
51
+ if (options?.thresholdPct !== undefined)
52
+ this.thresholdPct = options.thresholdPct;
53
+ if (options?.maxRounds !== undefined)
54
+ this.maxRounds = options.maxRounds;
55
+ }
56
+ /**
57
+ * Generates a unique bundle ID
58
+ * @internal
59
+ */
60
+ generateBundleId() {
61
+ const timestamp = Date.now();
62
+ const random = (0, crypto_1.randomBytes)(4).toString('hex');
63
+ return `bundle-${timestamp}-${random}`;
64
+ }
65
+ /**
66
+ * Sets the bundle ID
67
+ *
68
+ * @param bundleId - Unique identifier for this bundle
69
+ * @returns this builder instance for chaining
70
+ */
71
+ setBundleId(bundleId) {
72
+ this.bundleId = bundleId;
73
+ return this;
74
+ }
75
+ /**
76
+ * Sets the claim statement
77
+ *
78
+ * @param claim - The claim this bundle will verify
79
+ * @returns this builder instance for chaining
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * builder.setClaim('Revenue projections are within 10% of actuals');
84
+ * ```
85
+ */
86
+ setClaim(claim) {
87
+ this.claim = claim;
88
+ return this;
89
+ }
90
+ /**
91
+ * Adds a DataSpec to the bundle
92
+ *
93
+ * @param spec - Complete DataSpec object
94
+ * @returns this builder instance for chaining
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * builder.addDataSpec({
99
+ * id: 'source-1',
100
+ * label: 'Forecast Data',
101
+ * sourceKind: 'report',
102
+ * originDocIds: ['doc-123'],
103
+ * metrics: [
104
+ * { key: 'revenue', value: 1000000, unit: 'USD' }
105
+ * ]
106
+ * });
107
+ * ```
108
+ */
109
+ addDataSpec(spec) {
110
+ this.dataSpecs.push(spec);
111
+ return this;
112
+ }
113
+ /**
114
+ * Creates and adds a DataSpec with a fluent interface
115
+ *
116
+ * @param id - Unique identifier
117
+ * @param label - Human-readable label
118
+ * @param sourceKind - Type of data source
119
+ * @param originDocIds - Source document IDs
120
+ * @param metrics - Metric data points
121
+ * @returns this builder instance for chaining
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * builder.addDataSpecQuick(
126
+ * 'source-1',
127
+ * 'Forecast',
128
+ * 'report',
129
+ * ['doc-123'],
130
+ * [{ key: 'revenue', value: 1000000 }]
131
+ * );
132
+ * ```
133
+ */
134
+ addDataSpecQuick(id, label, sourceKind, originDocIds, metrics) {
135
+ return this.addDataSpec({
136
+ id,
137
+ label,
138
+ sourceKind,
139
+ originDocIds,
140
+ metrics
141
+ });
142
+ }
143
+ /**
144
+ * Sets the threshold percentage for delta comparison
145
+ *
146
+ * @param threshold - Threshold as a decimal (0.0 to 1.0)
147
+ * @returns this builder instance for chaining
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * builder.setThreshold(0.10); // 10% threshold
152
+ * ```
153
+ */
154
+ setThreshold(threshold) {
155
+ this.thresholdPct = threshold;
156
+ return this;
157
+ }
158
+ /**
159
+ * Sets the threshold percentage using a percentage value
160
+ *
161
+ * @param percent - Threshold as percentage (0 to 100)
162
+ * @returns this builder instance for chaining
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * builder.setThresholdPercent(10); // 10% threshold
167
+ * ```
168
+ */
169
+ setThresholdPercent(percent) {
170
+ this.thresholdPct = percent / 100;
171
+ return this;
172
+ }
173
+ /**
174
+ * Sets the maximum number of rounds
175
+ *
176
+ * @param rounds - Maximum rounds (defaults to 5 if not set)
177
+ * @returns this builder instance for chaining
178
+ */
179
+ setMaxRounds(rounds) {
180
+ this.maxRounds = rounds;
181
+ return this;
182
+ }
183
+ /**
184
+ * Validates the current bundle configuration without building
185
+ *
186
+ * @returns ValidationResult indicating if the bundle is valid
187
+ *
188
+ * @example
189
+ * ```typescript
190
+ * const result = builder.validate();
191
+ * if (!result.valid) {
192
+ * console.error('Bundle configuration is invalid:', result.errors);
193
+ * }
194
+ * ```
195
+ */
196
+ validate() {
197
+ const bundle = this.toBundle();
198
+ return (0, validators_1.validateBundle)(bundle);
199
+ }
200
+ /**
201
+ * Converts current configuration to a DeltaBundle object (without validation)
202
+ * @internal
203
+ */
204
+ toBundle() {
205
+ const bundle = {
206
+ bundleId: this.bundleId,
207
+ claim: this.claim,
208
+ dataSpecs: this.dataSpecs,
209
+ thresholdPct: this.thresholdPct
210
+ };
211
+ if (this.maxRounds !== undefined) {
212
+ bundle.maxRounds = this.maxRounds;
213
+ }
214
+ return bundle;
215
+ }
216
+ /**
217
+ * Builds and returns the final DeltaBundle
218
+ *
219
+ * @throws {ValidationError} if the bundle configuration is invalid
220
+ * @returns Complete, validated DeltaBundle
221
+ *
222
+ * @example
223
+ * ```typescript
224
+ * try {
225
+ * const bundle = builder.build();
226
+ * // Use bundle...
227
+ * } catch (error) {
228
+ * if (error instanceof ValidationError) {
229
+ * console.error('Invalid bundle:', error.errors);
230
+ * }
231
+ * }
232
+ * ```
233
+ */
234
+ build() {
235
+ const bundle = this.toBundle();
236
+ const validation = (0, validators_1.validateBundle)(bundle);
237
+ if (!validation.valid) {
238
+ throw new errors_1.ValidationError('Invalid bundle configuration', validation.errors || []);
239
+ }
240
+ return bundle;
241
+ }
242
+ /**
243
+ * Resets the builder to initial state (keeps bundleId)
244
+ *
245
+ * @returns this builder instance for chaining
246
+ */
247
+ reset() {
248
+ this.claim = '';
249
+ this.dataSpecs = [];
250
+ this.thresholdPct = 0.05;
251
+ this.maxRounds = undefined;
252
+ return this;
253
+ }
254
+ /**
255
+ * Creates a new builder instance with a fresh bundle ID
256
+ *
257
+ * @returns new BundleBuilder instance
258
+ */
259
+ static create(options) {
260
+ return new BundleBuilder(options);
261
+ }
262
+ }
263
+ exports.BundleBuilder = BundleBuilder;
264
+ //# sourceMappingURL=builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Delta Engine SDK Client
3
+ *
4
+ * Main client class for interacting with Delta Engine in multiple modes:
5
+ * - CLI: Spawns CLI process
6
+ * - HTTP: Makes API requests
7
+ * - Local: Direct function calls
8
+ */
9
+ import type { DeltaBundle, DeltaReceipt } from '@uvrn/core';
10
+ import type { ClientOptions, ValidationResult, VerificationResult } from './types/sdk';
11
+ /**
12
+ * Client for interacting with Delta Engine
13
+ *
14
+ * Supports three execution modes:
15
+ * - **CLI**: Spawns the CLI executable
16
+ * - **HTTP**: Makes requests to REST API
17
+ * - **Local**: Direct import of core engine
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // CLI mode
22
+ * const client = new DeltaEngineClient({
23
+ * mode: 'cli',
24
+ * cliPath: '/usr/local/bin/uvrn'
25
+ * });
26
+ *
27
+ * // HTTP mode
28
+ * const client = new DeltaEngineClient({
29
+ * mode: 'http',
30
+ * apiUrl: 'http://localhost:3000',
31
+ * timeout: 30000
32
+ * });
33
+ *
34
+ * // Local mode
35
+ * const client = new DeltaEngineClient({
36
+ * mode: 'local'
37
+ * });
38
+ * ```
39
+ */
40
+ export declare class DeltaEngineClient {
41
+ private readonly options;
42
+ /**
43
+ * Creates a new DeltaEngineClient
44
+ *
45
+ * @param options - Client configuration
46
+ * @throws {ConfigurationError} if configuration is invalid
47
+ */
48
+ constructor(options: ClientOptions);
49
+ /**
50
+ * Validates client options
51
+ * @internal
52
+ */
53
+ private validateOptions;
54
+ /**
55
+ * Executes a bundle and returns a receipt
56
+ *
57
+ * @param bundle - The DeltaBundle to execute
58
+ * @returns Promise resolving to DeltaReceipt
59
+ * @throws {ValidationError} if bundle is invalid
60
+ * @throws {ExecutionError} if execution fails
61
+ * @throws {NetworkError} if HTTP request fails (HTTP mode only)
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * const bundle = {
66
+ * bundleId: 'test-1',
67
+ * claim: 'Revenue matches forecast',
68
+ * dataSpecs: [...],
69
+ * thresholdPct: 0.05
70
+ * };
71
+ *
72
+ * const receipt = await client.runEngine(bundle);
73
+ * console.log('Outcome:', receipt.outcome);
74
+ * ```
75
+ */
76
+ runEngine(bundle: DeltaBundle): Promise<DeltaReceipt>;
77
+ /**
78
+ * Executes bundle via CLI mode
79
+ * @internal
80
+ */
81
+ private runEngineCLI;
82
+ /**
83
+ * Spawns CLI process and captures output
84
+ * @internal
85
+ */
86
+ private spawnCLI;
87
+ /**
88
+ * Executes bundle via HTTP API mode
89
+ * @internal
90
+ */
91
+ private runEngineHTTP;
92
+ /**
93
+ * Fetch with retry logic
94
+ * @internal
95
+ */
96
+ private fetchWithRetry;
97
+ /**
98
+ * Executes bundle via local mode (direct import)
99
+ * @internal
100
+ */
101
+ private runEngineLocal;
102
+ /**
103
+ * Validates a bundle without executing it
104
+ *
105
+ * @param bundle - The bundle to validate
106
+ * @returns ValidationResult with detailed errors
107
+ *
108
+ * @example
109
+ * ```typescript
110
+ * const result = await client.validateBundle(bundle);
111
+ * if (!result.valid) {
112
+ * console.error('Validation errors:', result.errors);
113
+ * }
114
+ * ```
115
+ */
116
+ validateBundle(bundle: DeltaBundle): Promise<ValidationResult>;
117
+ /**
118
+ * Verifies a receipt's integrity and determinism
119
+ *
120
+ * Checks:
121
+ * 1. Receipt hash integrity
122
+ * 2. Deterministic replay (if original bundle available)
123
+ *
124
+ * @param receipt - The receipt to verify
125
+ * @returns VerificationResult with detailed information
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * const result = await client.verifyReceipt(receipt);
130
+ * if (!result.verified) {
131
+ * console.error('Receipt verification failed!');
132
+ * }
133
+ * if (!result.deterministic) {
134
+ * console.warn('Non-deterministic execution detected!');
135
+ * }
136
+ * ```
137
+ */
138
+ verifyReceipt(receipt: DeltaReceipt): Promise<VerificationResult>;
139
+ }
140
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAevF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;IAElD;;;;;OAKG;gBACS,OAAO,EAAE,aAAa;IAclC;;;OAGG;IACH,OAAO,CAAC,eAAe;IAkBvB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IAoB3D;;;OAGG;YACW,YAAY;IAoC1B;;;OAGG;IACH,OAAO,CAAC,QAAQ;IA+BhB;;;OAGG;YACW,aAAa;IAwC3B;;;OAGG;YACW,cAAc;IAuB5B;;;OAGG;YACW,cAAc;IAwB5B;;;;;;;;;;;;;OAaG;IACG,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIpE;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAkCxE"}