@bcts/envelope 1.0.0-alpha.8 → 1.0.0-alpha.9

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/src/base/leaf.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Cbor, CborMap } from "@bcts/dcbor";
1
+ import type { Cbor } from "@bcts/dcbor";
2
2
  import { isNumber, isNaN, asArray, asMap, asText } from "@bcts/dcbor";
3
3
  import { Envelope } from "./envelope";
4
4
 
@@ -8,85 +8,6 @@ import { Envelope } from "./envelope";
8
8
  /// This module extends the Envelope class with convenience methods for
9
9
  /// working with leaf values, including type checking and extraction.
10
10
 
11
- declare module "./envelope" {
12
- interface Envelope {
13
- /// Checks if this envelope contains false.
14
- ///
15
- /// @returns `true` if the envelope's subject is false, `false` otherwise
16
- isFalse(): boolean;
17
-
18
- /// Checks if this envelope contains true.
19
- ///
20
- /// @returns `true` if the envelope's subject is true, `false` otherwise
21
- isTrue(): boolean;
22
-
23
- /// Checks if this envelope contains a boolean value.
24
- ///
25
- /// @returns `true` if the envelope's subject is a boolean, `false`
26
- /// otherwise
27
- isBool(): boolean;
28
-
29
- /// Checks if this envelope is a leaf node that contains a number.
30
- ///
31
- /// @returns `true` if the envelope is a leaf containing a number, `false`
32
- /// otherwise
33
- isNumber(): boolean;
34
-
35
- /// Checks if the subject of this envelope is a number.
36
- ///
37
- /// @returns `true` if the subject is a number, `false` otherwise
38
- isSubjectNumber(): boolean;
39
-
40
- /// Checks if this envelope is a leaf node that contains NaN.
41
- ///
42
- /// @returns `true` if the envelope is a leaf containing NaN, `false`
43
- /// otherwise
44
- isNaN(): boolean;
45
-
46
- /// Checks if the subject of this envelope is NaN.
47
- ///
48
- /// @returns `true` if the subject is NaN, `false` otherwise
49
- isSubjectNaN(): boolean;
50
-
51
- /// Checks if this envelope contains null.
52
- ///
53
- /// @returns `true` if the envelope's subject is null, `false` otherwise
54
- isNull(): boolean;
55
-
56
- /// Attempts to extract the leaf CBOR as a byte string.
57
- ///
58
- /// @returns The byte string value
59
- /// @throws {EnvelopeError} If the envelope is not a leaf or not a byte
60
- /// string
61
- tryByteString(): Uint8Array;
62
-
63
- /// Returns the leaf CBOR as a byte string if possible.
64
- ///
65
- /// @returns The byte string value or undefined
66
- asByteString(): Uint8Array | undefined;
67
-
68
- /// Returns the leaf CBOR as an array if possible.
69
- ///
70
- /// @returns The array value or undefined
71
- asArray(): readonly Cbor[] | undefined;
72
-
73
- /// Returns the leaf CBOR as a map if possible.
74
- ///
75
- /// @returns The map value or undefined
76
- asMap(): CborMap | undefined;
77
-
78
- /// Returns the leaf CBOR as text if possible.
79
- ///
80
- /// @returns The text value or undefined
81
- asText(): string | undefined;
82
-
83
- /// Returns the leaf CBOR value if this envelope is a leaf.
84
- ///
85
- /// @returns The CBOR value or undefined
86
- asLeaf(): Cbor | undefined;
87
- }
88
- }
89
-
90
11
  // Note: Static methods Envelope.false() and Envelope.true() are implemented below
91
12
  // but cannot be declared in TypeScript module augmentation due to reserved keywords.
92
13
 
@@ -19,136 +19,6 @@ import { EnvelopeError } from "./error";
19
19
  /// These methods enable traversal and inspection of envelope hierarchies,
20
20
  /// allowing for flexible manipulation and access to envelope data structures.
21
21
 
22
- declare module "./envelope" {
23
- interface Envelope {
24
- /// Returns true if the envelope has at least one assertion.
25
- ///
26
- /// @returns `true` if there are assertions, `false` otherwise
27
- hasAssertions(): boolean;
28
-
29
- /// Returns the envelope as an assertion if it is one.
30
- ///
31
- /// @returns The assertion envelope or undefined
32
- asAssertion(): Envelope | undefined;
33
-
34
- /// Returns the envelope as an assertion or throws an error.
35
- ///
36
- /// @returns The assertion envelope
37
- /// @throws {EnvelopeError} If the envelope is not an assertion
38
- tryAssertion(): Envelope;
39
-
40
- /// Returns the predicate of this assertion envelope.
41
- ///
42
- /// @returns The predicate envelope or undefined
43
- asPredicate(): Envelope | undefined;
44
-
45
- /// Returns the predicate of this assertion envelope or throws an error.
46
- ///
47
- /// @returns The predicate envelope
48
- /// @throws {EnvelopeError} If the envelope is not an assertion
49
- tryPredicate(): Envelope;
50
-
51
- /// Returns the object of this assertion envelope.
52
- ///
53
- /// @returns The object envelope or undefined
54
- asObject(): Envelope | undefined;
55
-
56
- /// Returns the object of this assertion envelope or throws an error.
57
- ///
58
- /// @returns The object envelope
59
- /// @throws {EnvelopeError} If the envelope is not an assertion
60
- tryObject(): Envelope;
61
-
62
- /// Checks if this envelope is case Assertion.
63
- ///
64
- /// @returns `true` if this is an assertion envelope
65
- isAssertion(): boolean;
66
-
67
- /// Checks if this envelope is case Elided.
68
- ///
69
- /// @returns `true` if this is an elided envelope
70
- isElided(): boolean;
71
-
72
- /// Checks if this envelope is case Leaf.
73
- ///
74
- /// @returns `true` if this is a leaf envelope
75
- isLeaf(): boolean;
76
-
77
- /// Checks if this envelope is case Node.
78
- ///
79
- /// @returns `true` if this is a node envelope
80
- isNode(): boolean;
81
-
82
- /// Checks if this envelope is case Wrapped.
83
- ///
84
- /// @returns `true` if this is a wrapped envelope
85
- isWrapped(): boolean;
86
-
87
- /// Checks if this envelope is internal (has child elements).
88
- ///
89
- /// Internal elements include node, wrapped, and assertion.
90
- ///
91
- /// @returns `true` if this envelope has children
92
- isInternal(): boolean;
93
-
94
- /// Checks if this envelope is obscured (elided, encrypted, or compressed).
95
- ///
96
- /// @returns `true` if this envelope is obscured
97
- isObscured(): boolean;
98
-
99
- /// Returns all assertions with the given predicate.
100
- ///
101
- /// Match is performed by comparing digests.
102
- ///
103
- /// @param predicate - The predicate to search for
104
- /// @returns An array of matching assertion envelopes
105
- assertionsWithPredicate(predicate: EnvelopeEncodableValue): Envelope[];
106
-
107
- /// Returns the assertion with the given predicate.
108
- ///
109
- /// @param predicate - The predicate to search for
110
- /// @returns The matching assertion envelope
111
- /// @throws {EnvelopeError} If no assertion or multiple assertions match
112
- assertionWithPredicate(predicate: EnvelopeEncodableValue): Envelope;
113
-
114
- /// Returns the assertion with the given predicate, or undefined if not
115
- /// found.
116
- ///
117
- /// @param predicate - The predicate to search for
118
- /// @returns The matching assertion envelope or undefined
119
- /// @throws {EnvelopeError} If multiple assertions match
120
- optionalAssertionWithPredicate(predicate: EnvelopeEncodableValue): Envelope | undefined;
121
-
122
- /// Returns the object of the assertion with the given predicate.
123
- ///
124
- /// @param predicate - The predicate to search for
125
- /// @returns The object envelope
126
- /// @throws {EnvelopeError} If no assertion or multiple assertions match
127
- objectForPredicate(predicate: EnvelopeEncodableValue): Envelope;
128
-
129
- /// Returns the object of the assertion with the given predicate, or
130
- /// undefined if not found.
131
- ///
132
- /// @param predicate - The predicate to search for
133
- /// @returns The object envelope or undefined
134
- /// @throws {EnvelopeError} If multiple assertions match
135
- optionalObjectForPredicate(predicate: EnvelopeEncodableValue): Envelope | undefined;
136
-
137
- /// Returns the objects of all assertions with the matching predicate.
138
- ///
139
- /// @param predicate - The predicate to search for
140
- /// @returns An array of object envelopes
141
- objectsForPredicate(predicate: EnvelopeEncodableValue): Envelope[];
142
-
143
- /// Returns the number of structural elements in the envelope.
144
- ///
145
- /// This includes the envelope itself and all nested elements.
146
- ///
147
- /// @returns The total element count
148
- elementsCount(): number;
149
- }
150
- }
151
-
152
22
  /// Implementation of hasAssertions()
153
23
  Envelope.prototype.hasAssertions = function (this: Envelope): boolean {
154
24
  const c = this.case();
package/src/base/walk.ts CHANGED
@@ -79,32 +79,6 @@ export type Visitor<State> = (
79
79
  state: State,
80
80
  ) => [State, boolean];
81
81
 
82
- declare module "./envelope" {
83
- interface Envelope {
84
- /// Walks the envelope structure, calling the visitor function for each
85
- /// element.
86
- ///
87
- /// This function traverses the entire envelope hierarchy and calls the
88
- /// visitor function on each element. The traversal can be performed in
89
- /// two modes:
90
- ///
91
- /// - Structure-based traversal (`hideNodes = false`): Visits every element
92
- /// including node containers
93
- /// - Tree-based traversal (`hideNodes = true`): Skips node elements and
94
- /// focuses on semantic content
95
- ///
96
- /// The visitor function can optionally return a context value that is
97
- /// passed to child elements, enabling state to be accumulated or passed
98
- /// down during traversal.
99
- ///
100
- /// @param hideNodes - If true, the visitor will not be called for node
101
- /// containers
102
- /// @param state - Initial state passed to the visitor
103
- /// @param visit - The visitor function called for each element
104
- walk<State>(hideNodes: boolean, state: State, visit: Visitor<State>): void;
105
- }
106
- }
107
-
108
82
  /// Implementation of walk()
109
83
  Envelope.prototype.walk = function <State>(
110
84
  this: Envelope,
package/src/base/wrap.ts CHANGED
@@ -6,52 +6,6 @@ import { EnvelopeError } from "./error";
6
6
  /// Wrapping allows treating an envelope (including its assertions) as a single
7
7
  /// unit, making it possible to add assertions about the envelope as a whole.
8
8
 
9
- declare module "./envelope" {
10
- interface Envelope {
11
- /// Returns a new envelope which wraps the current envelope.
12
- ///
13
- /// Wrapping an envelope allows you to treat an envelope (including its
14
- /// assertions) as a single unit, making it possible to add assertions
15
- /// about the envelope as a whole.
16
- ///
17
- /// @returns A new wrapped envelope
18
- ///
19
- /// @example
20
- /// ```typescript
21
- /// // Create an envelope with an assertion
22
- /// const envelope = Envelope.new("Hello.").addAssertion("language", "English");
23
- ///
24
- /// // Wrap it to add an assertion about the envelope as a whole
25
- /// const wrapped = envelope.wrap().addAssertion("authenticated", true);
26
- /// ```
27
- wrap(): Envelope;
28
-
29
- /// Unwraps and returns the inner envelope.
30
- ///
31
- /// This extracts the envelope contained within a wrapped envelope.
32
- ///
33
- /// @returns The unwrapped envelope
34
- /// @throws {EnvelopeError} If this is not a wrapped envelope
35
- ///
36
- /// @example
37
- /// ```typescript
38
- /// // Create an envelope and wrap it
39
- /// const envelope = Envelope.new("Hello.");
40
- /// const wrapped = envelope.wrap();
41
- ///
42
- /// // Unwrap to get the original envelope
43
- /// const unwrapped = wrapped.tryUnwrap();
44
- /// ```
45
- tryUnwrap(): Envelope;
46
-
47
- /// Alias for tryUnwrap() - unwraps and returns the inner envelope.
48
- ///
49
- /// @returns The unwrapped envelope
50
- /// @throws {EnvelopeError} If this is not a wrapped envelope
51
- unwrap(): Envelope;
52
- }
53
- }
54
-
55
9
  /// Implementation of wrap()
56
10
  Envelope.prototype.wrap = function (this: Envelope): Envelope {
57
11
  return Envelope.newWrapped(this);
@@ -128,95 +128,6 @@ export class Attachments {
128
128
  }
129
129
  }
130
130
 
131
- /**
132
- * Support for attachments in envelopes.
133
- */
134
- declare module "../base/envelope" {
135
- interface Envelope {
136
- /**
137
- * Creates a new envelope with an attachment as its subject.
138
- *
139
- * The attachment consists of:
140
- * - The predicate 'attachment'
141
- * - An object that is a wrapped envelope containing:
142
- * - The payload (as the subject)
143
- * - A required 'vendor': String assertion
144
- * - An optional 'conformsTo': String assertion
145
- *
146
- * @param payload - The content of the attachment
147
- * @param vendor - A string identifying the entity (typically reverse domain name)
148
- * @param conformsTo - Optional URI identifying the format of the attachment
149
- * @returns A new attachment envelope
150
- *
151
- * @example
152
- * ```typescript
153
- * const attachment = Envelope.newAttachment(
154
- * "Custom data",
155
- * "com.example",
156
- * "https://example.com/format/v1"
157
- * );
158
- * ```
159
- */
160
- addAttachment(payload: EnvelopeEncodableValue, vendor: string, conformsTo?: string): Envelope;
161
-
162
- /**
163
- * Returns the payload of an attachment envelope.
164
- *
165
- * @returns The payload envelope
166
- * @throws {EnvelopeError} If the envelope is not a valid attachment
167
- */
168
- attachmentPayload(): Envelope;
169
-
170
- /**
171
- * Returns the vendor identifier of an attachment envelope.
172
- *
173
- * @returns The vendor string
174
- * @throws {EnvelopeError} If the envelope is not a valid attachment
175
- */
176
- attachmentVendor(): string;
177
-
178
- /**
179
- * Returns the optional conformsTo URI of an attachment envelope.
180
- *
181
- * @returns The conformsTo string if present, or undefined
182
- * @throws {EnvelopeError} If the envelope is not a valid attachment
183
- */
184
- attachmentConformsTo(): string | undefined;
185
-
186
- /**
187
- * Returns all attachment assertions in this envelope.
188
- *
189
- * @returns Array of attachment envelopes
190
- */
191
- attachments(): Envelope[];
192
-
193
- /**
194
- * Searches for attachments matching the given vendor and conformsTo.
195
- *
196
- * @param vendor - Optional vendor identifier to match
197
- * @param conformsTo - Optional conformsTo URI to match
198
- * @returns Array of matching attachment envelopes
199
- */
200
- attachmentsWithVendorAndConformsTo(vendor?: string, conformsTo?: string): Envelope[];
201
- }
202
-
203
- namespace Envelope {
204
- /**
205
- * Creates a new attachment envelope.
206
- *
207
- * @param payload - The content of the attachment
208
- * @param vendor - A string identifying the entity
209
- * @param conformsTo - Optional URI identifying the format
210
- * @returns A new attachment envelope
211
- */
212
- function newAttachment(
213
- payload: EnvelopeEncodableValue,
214
- vendor: string,
215
- conformsTo?: string,
216
- ): Envelope;
217
- }
218
- }
219
-
220
131
  // Implementation
221
132
 
222
133
  /**
@@ -69,123 +69,6 @@ export class Compressed {
69
69
  }
70
70
  }
71
71
 
72
- declare module "../base/envelope" {
73
- interface Envelope {
74
- /// Returns a compressed version of this envelope.
75
- ///
76
- /// This method compresses the envelope using the DEFLATE algorithm,
77
- /// creating a more space-efficient representation while preserving the
78
- /// envelope's digest and semantic content. The compressed envelope
79
- /// maintains the same digest as the original, ensuring compatibility
80
- /// with the envelope's digest tree structure.
81
- ///
82
- /// When an envelope is compressed, the entire envelope structure (including
83
- /// its subject and assertions) is compressed as a single unit. The
84
- /// compression preserves all the information but reduces the size of
85
- /// the serialized envelope.
86
- ///
87
- /// @returns The compressed envelope
88
- /// @throws {EnvelopeError} If the envelope is already encrypted or elided
89
- ///
90
- /// @example
91
- /// ```typescript
92
- /// // Create an envelope with some content
93
- /// const text = "This is a fairly long text that will benefit from compression.";
94
- /// const envelope = Envelope.new(text);
95
- ///
96
- /// // Compress the envelope
97
- /// const compressed = envelope.compress();
98
- ///
99
- /// // Check that the compressed version has the same digest
100
- /// console.log(envelope.digest().equals(compressed.digest())); // true
101
- ///
102
- /// // Verify that the compressed version takes less space
103
- /// console.log(compressed.cborBytes().length < envelope.cborBytes().length);
104
- /// ```
105
- compress(): Envelope;
106
-
107
- /// Returns the decompressed variant of this envelope.
108
- ///
109
- /// This method reverses the compression process, restoring the envelope to
110
- /// its original decompressed form. The decompressed envelope will have
111
- /// the same digest as the compressed version.
112
- ///
113
- /// @returns The decompressed envelope
114
- /// @throws {EnvelopeError} If the envelope is not compressed, missing digest, or has invalid digest
115
- ///
116
- /// @example
117
- /// ```typescript
118
- /// // Create and compress an envelope
119
- /// const original = Envelope.new("Hello, world!");
120
- /// const compressed = original.compress();
121
- ///
122
- /// // Decompress it
123
- /// const decompressed = compressed.decompress();
124
- ///
125
- /// // The decompressed envelope should match the original
126
- /// console.log(decompressed.asText() === "Hello, world!"); // true
127
- /// console.log(decompressed.digest().equals(original.digest())); // true
128
- /// ```
129
- decompress(): Envelope;
130
-
131
- /// Returns this envelope with its subject compressed.
132
- ///
133
- /// Unlike `compress()` which compresses the entire envelope, this method
134
- /// only compresses the subject of the envelope, leaving the assertions
135
- /// decompressed. This is useful when you want to compress a large
136
- /// subject while keeping the assertions readable and accessible.
137
- ///
138
- /// @returns A new envelope with a compressed subject
139
- ///
140
- /// @example
141
- /// ```typescript
142
- /// // Create an envelope with a large subject and some assertions
143
- /// const lorem = "Lorem ipsum dolor sit amet...";
144
- /// const envelope = Envelope.new(lorem)
145
- /// .addAssertion("note", "This is a metadata note");
146
- ///
147
- /// // Compress just the subject
148
- /// const subjectCompressed = envelope.compressSubject();
149
- ///
150
- /// // The envelope's digest is preserved
151
- /// console.log(envelope.digest().equals(subjectCompressed.digest())); // true
152
- ///
153
- /// // The subject is now compressed
154
- /// console.log(subjectCompressed.subject().isCompressed()); // true
155
- /// ```
156
- compressSubject(): Envelope;
157
-
158
- /// Returns this envelope with its subject decompressed.
159
- ///
160
- /// This method reverses the effect of `compressSubject()`, decompressing
161
- /// the subject of the envelope while leaving the rest of the envelope
162
- /// unchanged.
163
- ///
164
- /// @returns A new envelope with a decompressed subject
165
- ///
166
- /// @example
167
- /// ```typescript
168
- /// // Create an envelope and compress its subject
169
- /// const original = Envelope.new("Hello, world!")
170
- /// .addAssertion("note", "Test note");
171
- /// const compressed = original.compressSubject();
172
- ///
173
- /// // Verify the subject is compressed
174
- /// console.log(compressed.subject().isCompressed()); // true
175
- ///
176
- /// // Decompress the subject
177
- /// const decompressed = compressed.decompressSubject();
178
- ///
179
- /// // Verify the subject is now decompressed
180
- /// console.log(!decompressed.subject().isCompressed()); // true
181
- /// ```
182
- decompressSubject(): Envelope;
183
-
184
- /// Checks if this envelope is compressed
185
- isCompressed(): boolean;
186
- }
187
- }
188
-
189
72
  /// Register compression extension methods on Envelope prototype
190
73
  /// This function is exported and called during module initialization
191
74
  /// to ensure Envelope is fully defined before attaching methods.
@@ -172,88 +172,6 @@ export class EncryptedMessage {
172
172
  }
173
173
  }
174
174
 
175
- declare module "../base/envelope" {
176
- interface Envelope {
177
- /// Returns a new envelope with its subject encrypted.
178
- ///
179
- /// Encrypts only the subject of the envelope, leaving assertions
180
- /// unencrypted. To encrypt an entire envelope including its assertions,
181
- /// it must first be wrapped using the `wrap()` method, or you
182
- /// can use the `encrypt()` convenience method.
183
- ///
184
- /// The encryption uses IETF ChaCha20-Poly1305 and preserves the envelope's
185
- /// digest, allowing for features like selective disclosure and
186
- /// signature verification to work even on encrypted envelopes.
187
- ///
188
- /// @param key - The SymmetricKey to use for encryption
189
- /// @returns A new envelope with its subject encrypted
190
- /// @throws {EnvelopeError} If the envelope is already encrypted or elided
191
- ///
192
- /// @example
193
- /// ```typescript
194
- /// const envelope = Envelope.new("Secret data");
195
- /// const key = SymmetricKey.generate();
196
- /// const encrypted = envelope.encryptSubject(key);
197
- /// console.log(encrypted.subject().isEncrypted()); // true
198
- /// ```
199
- encryptSubject(key: SymmetricKey): Envelope;
200
-
201
- /// Returns a new envelope with its subject decrypted.
202
- ///
203
- /// Decrypts the subject of an envelope that was previously encrypted using
204
- /// `encryptSubject()`. The symmetric key used must be the same one
205
- /// used for encryption.
206
- ///
207
- /// @param key - The SymmetricKey to use for decryption
208
- /// @returns A new envelope with its subject decrypted
209
- /// @throws {EnvelopeError} If the envelope's subject is not encrypted, key is incorrect, or digest mismatch
210
- ///
211
- /// @example
212
- /// ```typescript
213
- /// const decrypted = encrypted.decryptSubject(key);
214
- /// console.log(decrypted.asText()); // "Secret data"
215
- /// ```
216
- decryptSubject(key: SymmetricKey): Envelope;
217
-
218
- /// Convenience method to encrypt an entire envelope including its assertions.
219
- ///
220
- /// This method wraps the envelope and then encrypts its subject, which has
221
- /// the effect of encrypting the entire original envelope including all
222
- /// its assertions.
223
- ///
224
- /// @param key - The SymmetricKey to use for encryption
225
- /// @returns A new envelope with the entire original envelope encrypted
226
- ///
227
- /// @example
228
- /// ```typescript
229
- /// const envelope = Envelope.new("Alice").addAssertion("knows", "Bob");
230
- /// const key = SymmetricKey.generate();
231
- /// const encrypted = envelope.encrypt(key);
232
- /// ```
233
- encrypt(key: SymmetricKey): Envelope;
234
-
235
- /// Convenience method to decrypt an entire envelope that was encrypted
236
- /// using the `encrypt()` method.
237
- ///
238
- /// This method decrypts the subject and then unwraps the resulting
239
- /// envelope, returning the original envelope with all its assertions.
240
- ///
241
- /// @param key - The SymmetricKey to use for decryption
242
- /// @returns The original decrypted envelope
243
- /// @throws {EnvelopeError} If envelope is not encrypted, key is incorrect, digest mismatch, or cannot unwrap
244
- ///
245
- /// @example
246
- /// ```typescript
247
- /// const decrypted = encrypted.decrypt(key);
248
- /// console.log(envelope.digest().equals(decrypted.digest())); // true
249
- /// ```
250
- decrypt(key: SymmetricKey): Envelope;
251
-
252
- /// Checks if this envelope is encrypted
253
- isEncrypted(): boolean;
254
- }
255
- }
256
-
257
175
  /// Register encryption extension methods on Envelope prototype
258
176
  /// This function is exported and called during module initialization
259
177
  /// to ensure Envelope is fully defined before attaching methods.
@@ -47,55 +47,6 @@ import { type Digest } from "../base/digest";
47
47
  /// }
48
48
  /// ```
49
49
 
50
- declare module "../base/envelope" {
51
- interface Envelope {
52
- /// Creates a proof that this envelope includes every element in the target set.
53
- ///
54
- /// An inclusion proof is a specially constructed envelope that:
55
- /// - Has the same digest as the original envelope (or an elided version of it)
56
- /// - Contains the minimal structure needed to prove the existence of target elements
57
- /// - Keeps all other content elided to preserve privacy
58
- ///
59
- /// @param target - The set of digests representing elements that the proof must include
60
- /// @returns A proof envelope if all targets can be proven to exist, undefined otherwise
61
- proofContainsSet(target: Set<Digest>): Envelope | undefined;
62
-
63
- /// Creates a proof that this envelope includes the single target element.
64
- ///
65
- /// This is a convenience method that wraps `proofContainsSet()` for the
66
- /// common case of proving the existence of just one element.
67
- ///
68
- /// @param target - The element that the proof must demonstrate exists in this envelope
69
- /// @returns A proof envelope if the target can be proven to exist, undefined otherwise
70
- proofContainsTarget(target: Envelope): Envelope | undefined;
71
-
72
- /// Verifies whether this envelope contains all elements in the target set
73
- /// using the given inclusion proof.
74
- ///
75
- /// This method is used by a verifier to check if a proof demonstrates the
76
- /// existence of all target elements within this envelope. The verification
77
- /// succeeds only if:
78
- /// 1. The proof's digest matches this envelope's digest
79
- /// 2. The proof contains all the target elements
80
- ///
81
- /// @param target - The set of digests representing elements that need to be proven to exist
82
- /// @param proof - The inclusion proof envelope to verify
83
- /// @returns true if all target elements are proven to exist in this envelope by the proof
84
- confirmContainsSet(target: Set<Digest>, proof: Envelope): boolean;
85
-
86
- /// Verifies whether this envelope contains the single target element using
87
- /// the given inclusion proof.
88
- ///
89
- /// This is a convenience method that wraps `confirmContainsSet()` for the
90
- /// common case of verifying just one element.
91
- ///
92
- /// @param target - The element that needs to be proven to exist in this envelope
93
- /// @param proof - The inclusion proof envelope to verify
94
- /// @returns true if the target element is proven to exist in this envelope by the proof
95
- confirmContainsTarget(target: Envelope, proof: Envelope): boolean;
96
- }
97
- }
98
-
99
50
  /// Implementation of proof methods on Envelope prototype
100
51
  // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
101
52
  if (Envelope?.prototype) {