@bcts/known-values 1.0.0-alpha.10
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/LICENSE +48 -0
- package/README.md +11 -0
- package/dist/index.cjs +1017 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +664 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +664 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.iife.js +1019 -0
- package/dist/index.iife.js.map +1 -0
- package/dist/index.mjs +912 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +74 -0
- package/src/index.ts +116 -0
- package/src/known-value.ts +425 -0
- package/src/known-values-registry.ts +317 -0
- package/src/known-values-store.ts +327 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,912 @@
|
|
|
1
|
+
import { MajorType, cbor, cborData, decodeCbor } from "@bcts/dcbor";
|
|
2
|
+
import { KNOWN_VALUE } from "@bcts/components";
|
|
3
|
+
|
|
4
|
+
//#region src/known-value.ts
|
|
5
|
+
/**
|
|
6
|
+
* A value in a namespace of unsigned integers that represents a stand-alone
|
|
7
|
+
* ontological concept.
|
|
8
|
+
*
|
|
9
|
+
* Known Values provide a compact, deterministic way to represent commonly used
|
|
10
|
+
* ontological concepts such as relationships between entities, classes of
|
|
11
|
+
* entities, properties, or enumerated values. They are particularly useful as
|
|
12
|
+
* predicates in Gordian Envelope assertions, offering a more compact and
|
|
13
|
+
* deterministic alternative to URIs. However, known values are not exclusive
|
|
14
|
+
* to Gordian Envelopes and can be used in any context where a compact, unique
|
|
15
|
+
* identifier for a concept is needed.
|
|
16
|
+
*
|
|
17
|
+
* A Known Value is represented as a 64-bit unsigned integer with an optional
|
|
18
|
+
* human-readable name. This approach ensures:
|
|
19
|
+
*
|
|
20
|
+
* - **Compact binary representation** - Each Known Value requires only 1-9
|
|
21
|
+
* bytes depending on value range
|
|
22
|
+
* - **Deterministic encoding** - Every concept has exactly one valid binary
|
|
23
|
+
* representation
|
|
24
|
+
* - **Enhanced security** - Eliminates URI manipulation vulnerabilities
|
|
25
|
+
* - **Standardized semantics** - Values are registered in a central registry
|
|
26
|
+
*
|
|
27
|
+
* While Known Values are most commonly used as predicates in assertions, they
|
|
28
|
+
* can appear in any position in an Envelope (subject, predicate, or object).
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* import { KnownValue } from '@bcts/known-values';
|
|
33
|
+
*
|
|
34
|
+
* // Create a Known Value with a numeric value
|
|
35
|
+
* const knownValue = new KnownValue(42);
|
|
36
|
+
* console.log(knownValue.value()); // 42
|
|
37
|
+
*
|
|
38
|
+
* // Create a Known Value with a name
|
|
39
|
+
* const namedValue = new KnownValue(1, 'isA');
|
|
40
|
+
* console.log(namedValue.value()); // 1
|
|
41
|
+
* console.log(namedValue.name()); // "isA"
|
|
42
|
+
*
|
|
43
|
+
* // CBOR encoding
|
|
44
|
+
* const cbor = namedValue.taggedCbor();
|
|
45
|
+
* const bytes = namedValue.toCborData();
|
|
46
|
+
*
|
|
47
|
+
* // CBOR decoding
|
|
48
|
+
* const decoded = KnownValue.fromTaggedCbor(cbor);
|
|
49
|
+
* const decodedFromBytes = KnownValue.fromCborData(bytes);
|
|
50
|
+
*
|
|
51
|
+
* // Use a pre-defined Known Value from the registry
|
|
52
|
+
* import { IS_A } from '@bcts/known-values';
|
|
53
|
+
* console.log(IS_A.value()); // 1
|
|
54
|
+
* console.log(IS_A.name()); // "isA"
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @specification
|
|
58
|
+
*
|
|
59
|
+
* Known Values are defined in
|
|
60
|
+
* [BCR-2023-002](https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2023-002-known-value.md)
|
|
61
|
+
* and implemented as an Envelope extension in
|
|
62
|
+
* [BCR-2023-003](https://github.com/BlockchainCommons/Research/blob/master/papers/bcr-2023-003-envelope-known-value.md).
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* The numeric value for the CBOR tag used for Known Values.
|
|
66
|
+
* This is Tag 40000 as defined in the Blockchain Commons registry.
|
|
67
|
+
*/
|
|
68
|
+
const TAG_KNOWN_VALUE = KNOWN_VALUE.value;
|
|
69
|
+
/**
|
|
70
|
+
* The CBOR tag used for Known Values.
|
|
71
|
+
* This is Tag 40000 as defined in the Blockchain Commons registry.
|
|
72
|
+
*/
|
|
73
|
+
const KNOWN_VALUE_TAG = KNOWN_VALUE;
|
|
74
|
+
var KnownValue = class KnownValue {
|
|
75
|
+
_value;
|
|
76
|
+
_assignedName;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new KnownValue with the given numeric value and optional name.
|
|
79
|
+
*
|
|
80
|
+
* @param value - The numeric value (number or bigint). Numbers are converted to bigint internally.
|
|
81
|
+
* @param assignedName - Optional human-readable name for the value
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const knownValue = new KnownValue(42);
|
|
86
|
+
* console.log(knownValue.value()); // 42
|
|
87
|
+
*
|
|
88
|
+
* const namedValue = new KnownValue(1, 'isA');
|
|
89
|
+
* console.log(namedValue.name()); // "isA"
|
|
90
|
+
*
|
|
91
|
+
* // Using bigint for large values
|
|
92
|
+
* const largeValue = new KnownValue(9007199254740993n);
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
constructor(value, assignedName) {
|
|
96
|
+
this._value = typeof value === "bigint" ? value : BigInt(value);
|
|
97
|
+
this._assignedName = assignedName;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns the numeric value of the KnownValue.
|
|
101
|
+
*
|
|
102
|
+
* This is the raw unsigned integer that identifies the concept.
|
|
103
|
+
* Returns a number for backward compatibility. For values > MAX_SAFE_INTEGER,
|
|
104
|
+
* use `valueBigInt()`.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* import { IS_A, NOTE } from '@bcts/known-values';
|
|
109
|
+
* console.log(IS_A.value()); // 1
|
|
110
|
+
* console.log(NOTE.value()); // 4
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
value() {
|
|
114
|
+
if (this._value > BigInt(Number.MAX_SAFE_INTEGER)) throw new RangeError(`KnownValue ${this._value} exceeds MAX_SAFE_INTEGER. Use valueBigInt() instead.`);
|
|
115
|
+
return Number(this._value);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Returns the numeric value of the KnownValue as a bigint.
|
|
119
|
+
*
|
|
120
|
+
* Use this for values that may exceed Number.MAX_SAFE_INTEGER (2^53-1).
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```typescript
|
|
124
|
+
* const largeValue = new KnownValue(9007199254740993n);
|
|
125
|
+
* console.log(largeValue.valueBigInt()); // 9007199254740993n
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
valueBigInt() {
|
|
129
|
+
return this._value;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Returns the assigned name of the KnownValue, if one exists.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const namedValue = new KnownValue(1, 'isA');
|
|
137
|
+
* console.log(namedValue.assignedName()); // "isA"
|
|
138
|
+
*
|
|
139
|
+
* const unnamedValue = new KnownValue(42);
|
|
140
|
+
* console.log(unnamedValue.assignedName()); // undefined
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
assignedName() {
|
|
144
|
+
return this._assignedName;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Returns a human-readable name for the KnownValue.
|
|
148
|
+
*
|
|
149
|
+
* If the KnownValue has an assigned name, that name is returned.
|
|
150
|
+
* Otherwise, the string representation of the numeric value is returned.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const namedValue = new KnownValue(1, 'isA');
|
|
155
|
+
* console.log(namedValue.name()); // "isA"
|
|
156
|
+
*
|
|
157
|
+
* const unnamedValue = new KnownValue(42);
|
|
158
|
+
* console.log(unnamedValue.name()); // "42"
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
name() {
|
|
162
|
+
return this._assignedName ?? this._value.toString();
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Compares this KnownValue with another for equality.
|
|
166
|
+
* Equality is based solely on the numeric value, ignoring the name.
|
|
167
|
+
*
|
|
168
|
+
* @param other - The KnownValue to compare with
|
|
169
|
+
* @returns true if the values are equal
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* const kv1 = new KnownValue(1, 'isA');
|
|
174
|
+
* const kv2 = new KnownValue(1, 'different');
|
|
175
|
+
* console.log(kv1.equals(kv2)); // true (same value, different name)
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
equals(other) {
|
|
179
|
+
return this._value === other._value;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Hash code based on the numeric value.
|
|
183
|
+
* Useful for using KnownValue in hash-based collections.
|
|
184
|
+
*/
|
|
185
|
+
hashCode() {
|
|
186
|
+
return Number(this._value & BigInt(4294967295));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* String representation of the KnownValue.
|
|
190
|
+
*
|
|
191
|
+
* If a name is assigned, the name is displayed. Otherwise, the numeric value
|
|
192
|
+
* is displayed.
|
|
193
|
+
*/
|
|
194
|
+
toString() {
|
|
195
|
+
return this.name();
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Returns the CBOR tags associated with KnownValue.
|
|
199
|
+
*
|
|
200
|
+
* The primary tag is TAG_KNOWN_VALUE (201).
|
|
201
|
+
*
|
|
202
|
+
* @returns Array containing the KnownValue tag
|
|
203
|
+
*/
|
|
204
|
+
cborTags() {
|
|
205
|
+
return [KNOWN_VALUE_TAG];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Returns the untagged CBOR encoding of this KnownValue.
|
|
209
|
+
*
|
|
210
|
+
* The untagged representation is simply the unsigned integer value.
|
|
211
|
+
*
|
|
212
|
+
* @returns CBOR representation of the value (unsigned integer)
|
|
213
|
+
*/
|
|
214
|
+
untaggedCbor() {
|
|
215
|
+
return cbor(this._value);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Returns the tagged CBOR encoding of this KnownValue.
|
|
219
|
+
*
|
|
220
|
+
* This wraps the unsigned integer value with tag 201.
|
|
221
|
+
*
|
|
222
|
+
* @returns Tagged CBOR representation
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```typescript
|
|
226
|
+
* const kv = new KnownValue(1, 'isA');
|
|
227
|
+
* const tagged = kv.taggedCbor();
|
|
228
|
+
* console.log(tagged.toHex()); // "d8c901" (tag 201, value 1)
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
taggedCbor() {
|
|
232
|
+
return cbor({
|
|
233
|
+
tag: TAG_KNOWN_VALUE,
|
|
234
|
+
value: this._value
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Returns the tagged CBOR encoding as binary data.
|
|
239
|
+
*
|
|
240
|
+
* @returns Binary CBOR representation
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* const kv = new KnownValue(1, 'isA');
|
|
245
|
+
* const bytes = kv.toCborData();
|
|
246
|
+
* // bytes is Uint8Array containing the CBOR encoding
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
toCborData() {
|
|
250
|
+
return cborData(this.taggedCbor());
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Alias for `toCborData()` to match the dcbor interface.
|
|
254
|
+
*/
|
|
255
|
+
taggedCborData() {
|
|
256
|
+
return this.toCborData();
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Creates a KnownValue from untagged CBOR (an unsigned integer).
|
|
260
|
+
* Instance method for interface compliance.
|
|
261
|
+
*
|
|
262
|
+
* @param cborValue - The CBOR value (must be an unsigned integer)
|
|
263
|
+
* @returns A new KnownValue
|
|
264
|
+
* @throws {Error} If the CBOR is not an unsigned integer
|
|
265
|
+
*/
|
|
266
|
+
fromUntaggedCbor(cborValue) {
|
|
267
|
+
return KnownValue.fromUntaggedCbor(cborValue);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Creates a KnownValue from tagged CBOR (tag 201).
|
|
271
|
+
* Instance method for interface compliance.
|
|
272
|
+
*
|
|
273
|
+
* @param cborValue - The tagged CBOR value
|
|
274
|
+
* @returns A new KnownValue
|
|
275
|
+
* @throws {Error} If the CBOR is not properly tagged or contains invalid data
|
|
276
|
+
*/
|
|
277
|
+
fromTaggedCbor(cborValue) {
|
|
278
|
+
return KnownValue.fromTaggedCbor(cborValue);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Creates a KnownValue from untagged CBOR (an unsigned integer).
|
|
282
|
+
*
|
|
283
|
+
* @param cborValue - The CBOR value (must be an unsigned integer)
|
|
284
|
+
* @returns A new KnownValue
|
|
285
|
+
* @throws {Error} If the CBOR is not an unsigned integer
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```typescript
|
|
289
|
+
* const cborValue = cbor(42);
|
|
290
|
+
* const kv = KnownValue.fromUntaggedCbor(cborValue);
|
|
291
|
+
* console.log(kv.value()); // 42
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
static fromUntaggedCbor(cborValue) {
|
|
295
|
+
if (cborValue.type !== MajorType.Unsigned) throw new Error(`Expected unsigned integer for KnownValue, got major type ${cborValue.type}`);
|
|
296
|
+
const numValue = cborValue.value;
|
|
297
|
+
return new KnownValue(typeof numValue === "bigint" ? numValue : BigInt(numValue));
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Creates a KnownValue from tagged CBOR (tag 201).
|
|
301
|
+
*
|
|
302
|
+
* @param cborValue - The tagged CBOR value
|
|
303
|
+
* @returns A new KnownValue
|
|
304
|
+
* @throws {Error} If the CBOR is not properly tagged or contains invalid data
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```typescript
|
|
308
|
+
* const kv = KnownValue.fromTaggedCbor(taggedCborValue);
|
|
309
|
+
* ```
|
|
310
|
+
*/
|
|
311
|
+
static fromTaggedCbor(cborValue) {
|
|
312
|
+
if (cborValue.type !== MajorType.Tagged) throw new Error(`Expected tagged CBOR for KnownValue, got major type ${cborValue.type}`);
|
|
313
|
+
const tag = cborValue.tag;
|
|
314
|
+
if (tag !== BigInt(TAG_KNOWN_VALUE) && tag !== TAG_KNOWN_VALUE) throw new Error(`Expected tag ${TAG_KNOWN_VALUE} for KnownValue, got ${tag}`);
|
|
315
|
+
return KnownValue.fromUntaggedCbor(cborValue.value);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Creates a KnownValue from binary CBOR data.
|
|
319
|
+
*
|
|
320
|
+
* @param data - Binary CBOR data (must be a tagged KnownValue)
|
|
321
|
+
* @returns A new KnownValue
|
|
322
|
+
* @throws {Error} If the data cannot be decoded or is not a valid KnownValue
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* const bytes = new Uint8Array([0xd8, 0xc9, 0x01]); // tag 201, value 1
|
|
327
|
+
* const kv = KnownValue.fromCborData(bytes);
|
|
328
|
+
* console.log(kv.value()); // 1
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
static fromCborData(data) {
|
|
332
|
+
const cborValue = decodeCbor(data);
|
|
333
|
+
return KnownValue.fromTaggedCbor(cborValue);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Creates a KnownValue from a CBOR value, automatically detecting
|
|
337
|
+
* whether it's tagged or untagged.
|
|
338
|
+
*
|
|
339
|
+
* @param cborValue - The CBOR value (tagged or untagged)
|
|
340
|
+
* @returns A new KnownValue
|
|
341
|
+
* @throws {Error} If the CBOR cannot be converted to a KnownValue
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* // Works with both tagged and untagged
|
|
346
|
+
* const kv1 = KnownValue.fromCbor(cbor(42));
|
|
347
|
+
* const kv2 = KnownValue.fromCbor(taggedCborValue);
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
static fromCbor(cborValue) {
|
|
351
|
+
if (cborValue.type === MajorType.Tagged) return KnownValue.fromTaggedCbor(cborValue);
|
|
352
|
+
return KnownValue.fromUntaggedCbor(cborValue);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/known-values-store.ts
|
|
358
|
+
/**
|
|
359
|
+
* A store that maps between Known Values and their assigned names.
|
|
360
|
+
*
|
|
361
|
+
* The `KnownValuesStore` provides a bidirectional mapping between:
|
|
362
|
+
* - Numeric values (bigint) and their corresponding KnownValue instances
|
|
363
|
+
* - String names and their corresponding KnownValue instances
|
|
364
|
+
*
|
|
365
|
+
* This enables efficient lookup in both directions, making it possible to:
|
|
366
|
+
* - Find the name for a given numeric value
|
|
367
|
+
* - Find the numeric value for a given name
|
|
368
|
+
* - Retrieve complete KnownValue instances by either name or value
|
|
369
|
+
*
|
|
370
|
+
* The store is typically populated with predefined Known Values from the
|
|
371
|
+
* registry, but can also be extended with custom values.
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
* ```typescript
|
|
375
|
+
* import { KnownValuesStore, IS_A, NOTE, SIGNED } from '@bcts/known-values';
|
|
376
|
+
*
|
|
377
|
+
* // Create a store with predefined Known Values
|
|
378
|
+
* const store = new KnownValuesStore([IS_A, NOTE, SIGNED]);
|
|
379
|
+
*
|
|
380
|
+
* // Look up a Known Value by name
|
|
381
|
+
* const isA = store.knownValueNamed('isA');
|
|
382
|
+
* console.log(isA?.value()); // 1
|
|
383
|
+
*
|
|
384
|
+
* // Look up a name for a raw value
|
|
385
|
+
* const name = store.name(new KnownValue(3));
|
|
386
|
+
* console.log(name); // "signed"
|
|
387
|
+
*
|
|
388
|
+
* // Insert a custom Known Value
|
|
389
|
+
* const customStore = store.clone();
|
|
390
|
+
* customStore.insert(new KnownValue(100, 'customValue'));
|
|
391
|
+
* console.log(customStore.knownValueNamed('customValue')?.value()); // 100
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
var KnownValuesStore = class KnownValuesStore {
|
|
395
|
+
knownValuesByRawValue;
|
|
396
|
+
knownValuesByAssignedName;
|
|
397
|
+
/**
|
|
398
|
+
* Creates a new KnownValuesStore with the provided Known Values.
|
|
399
|
+
*
|
|
400
|
+
* This constructor takes an iterable of KnownValue instances and
|
|
401
|
+
* populates the store with them, creating mappings from both raw
|
|
402
|
+
* values and names to the corresponding KnownValue instances.
|
|
403
|
+
*
|
|
404
|
+
* @param knownValues - Iterable of KnownValue instances to populate the store
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* import { KnownValuesStore, IS_A, NOTE, SIGNED } from '@bcts/known-values';
|
|
409
|
+
*
|
|
410
|
+
* // Create a store with predefined Known Values
|
|
411
|
+
* const store = new KnownValuesStore([IS_A, NOTE, SIGNED]);
|
|
412
|
+
*
|
|
413
|
+
* // Look up Known Values
|
|
414
|
+
* console.log(store.knownValueNamed('isA')?.value()); // 1
|
|
415
|
+
* console.log(store.knownValueNamed('note')?.value()); // 4
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
constructor(knownValues = []) {
|
|
419
|
+
this.knownValuesByRawValue = /* @__PURE__ */ new Map();
|
|
420
|
+
this.knownValuesByAssignedName = /* @__PURE__ */ new Map();
|
|
421
|
+
for (const knownValue of knownValues) this._insert(knownValue);
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Inserts a KnownValue into the store.
|
|
425
|
+
*
|
|
426
|
+
* If the KnownValue has an assigned name, it will be indexed by both its
|
|
427
|
+
* raw value and its name. If a KnownValue with the same raw value or name
|
|
428
|
+
* already exists in the store, it will be replaced.
|
|
429
|
+
*
|
|
430
|
+
* @param knownValue - The KnownValue to insert
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```typescript
|
|
434
|
+
* import { KnownValuesStore, KnownValue } from '@bcts/known-values';
|
|
435
|
+
*
|
|
436
|
+
* const store = new KnownValuesStore();
|
|
437
|
+
* store.insert(new KnownValue(100, 'customValue'));
|
|
438
|
+
* console.log(store.knownValueNamed('customValue')?.value()); // 100
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
441
|
+
insert(knownValue) {
|
|
442
|
+
this._insert(knownValue);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Returns the assigned name for a KnownValue, if present in the store.
|
|
446
|
+
*
|
|
447
|
+
* @param knownValue - The KnownValue to look up
|
|
448
|
+
* @returns The assigned name, or undefined if not found
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* ```typescript
|
|
452
|
+
* import { KnownValuesStore, IS_A } from '@bcts/known-values';
|
|
453
|
+
*
|
|
454
|
+
* const store = new KnownValuesStore([IS_A]);
|
|
455
|
+
* console.log(store.assignedName(IS_A)); // "isA"
|
|
456
|
+
* console.log(store.assignedName(new KnownValue(999))); // undefined
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
assignedName(knownValue) {
|
|
460
|
+
return this.knownValuesByRawValue.get(knownValue.valueBigInt())?.assignedName();
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Returns a human-readable name for a KnownValue.
|
|
464
|
+
*
|
|
465
|
+
* If the KnownValue has an assigned name in the store, that name is
|
|
466
|
+
* returned. Otherwise, the KnownValue's default name (which may be its
|
|
467
|
+
* numeric value as a string) is returned.
|
|
468
|
+
*
|
|
469
|
+
* @param knownValue - The KnownValue to get the name for
|
|
470
|
+
* @returns The name (assigned or numeric)
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* ```typescript
|
|
474
|
+
* import { KnownValuesStore, IS_A } from '@bcts/known-values';
|
|
475
|
+
*
|
|
476
|
+
* const store = new KnownValuesStore([IS_A]);
|
|
477
|
+
* console.log(store.name(IS_A)); // "isA"
|
|
478
|
+
* console.log(store.name(new KnownValue(999))); // "999"
|
|
479
|
+
* ```
|
|
480
|
+
*/
|
|
481
|
+
name(knownValue) {
|
|
482
|
+
return this.assignedName(knownValue) ?? knownValue.name();
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Looks up a KnownValue by its assigned name.
|
|
486
|
+
*
|
|
487
|
+
* Returns the KnownValue if found, or undefined if no KnownValue
|
|
488
|
+
* with the given name exists in the store.
|
|
489
|
+
*
|
|
490
|
+
* @param assignedName - The name to look up
|
|
491
|
+
* @returns The KnownValue, or undefined if not found
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```typescript
|
|
495
|
+
* import { KnownValuesStore, IS_A } from '@bcts/known-values';
|
|
496
|
+
*
|
|
497
|
+
* const store = new KnownValuesStore([IS_A]);
|
|
498
|
+
*
|
|
499
|
+
* const isA = store.knownValueNamed('isA');
|
|
500
|
+
* console.log(isA?.value()); // 1
|
|
501
|
+
*
|
|
502
|
+
* console.log(store.knownValueNamed('nonexistent')); // undefined
|
|
503
|
+
* ```
|
|
504
|
+
*/
|
|
505
|
+
knownValueNamed(assignedName) {
|
|
506
|
+
return this.knownValuesByAssignedName.get(assignedName);
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Looks up a KnownValue by its raw numeric value.
|
|
510
|
+
*
|
|
511
|
+
* @param rawValue - The numeric value to look up (number or bigint)
|
|
512
|
+
* @returns The KnownValue, or undefined if not found
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* ```typescript
|
|
516
|
+
* import { KnownValuesStore, IS_A } from '@bcts/known-values';
|
|
517
|
+
*
|
|
518
|
+
* const store = new KnownValuesStore([IS_A]);
|
|
519
|
+
* const isA = store.knownValueForValue(1);
|
|
520
|
+
* console.log(isA?.name()); // "isA"
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
523
|
+
knownValueForValue(rawValue) {
|
|
524
|
+
const key = typeof rawValue === "bigint" ? rawValue : BigInt(rawValue);
|
|
525
|
+
return this.knownValuesByRawValue.get(key);
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Retrieves a KnownValue for a raw value, using a store if provided.
|
|
529
|
+
*
|
|
530
|
+
* This static method allows looking up a KnownValue by its raw numeric
|
|
531
|
+
* value:
|
|
532
|
+
* - If a store is provided and contains a mapping for the raw value, that
|
|
533
|
+
* KnownValue is returned
|
|
534
|
+
* - Otherwise, a new KnownValue with no assigned name is created and
|
|
535
|
+
* returned
|
|
536
|
+
*
|
|
537
|
+
* @param rawValue - The numeric value to look up (number or bigint)
|
|
538
|
+
* @param knownValues - Optional store to search in
|
|
539
|
+
* @returns The KnownValue from the store or a new unnamed KnownValue
|
|
540
|
+
*
|
|
541
|
+
* @example
|
|
542
|
+
* ```typescript
|
|
543
|
+
* import { KnownValuesStore, IS_A } from '@bcts/known-values';
|
|
544
|
+
*
|
|
545
|
+
* const store = new KnownValuesStore([IS_A]);
|
|
546
|
+
*
|
|
547
|
+
* // Known value from store
|
|
548
|
+
* const isA = KnownValuesStore.knownValueForRawValue(1, store);
|
|
549
|
+
* console.log(isA.name()); // "isA"
|
|
550
|
+
*
|
|
551
|
+
* // Unknown value creates a new KnownValue
|
|
552
|
+
* const unknown = KnownValuesStore.knownValueForRawValue(999, store);
|
|
553
|
+
* console.log(unknown.name()); // "999"
|
|
554
|
+
*
|
|
555
|
+
* // No store provided also creates a new KnownValue
|
|
556
|
+
* const unknown2 = KnownValuesStore.knownValueForRawValue(1, undefined);
|
|
557
|
+
* console.log(unknown2.name()); // "1"
|
|
558
|
+
* ```
|
|
559
|
+
*/
|
|
560
|
+
static knownValueForRawValue(rawValue, knownValues) {
|
|
561
|
+
if (knownValues !== void 0) {
|
|
562
|
+
const value = knownValues.knownValueForValue(rawValue);
|
|
563
|
+
if (value !== void 0) return value;
|
|
564
|
+
}
|
|
565
|
+
return new KnownValue(rawValue);
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Attempts to find a KnownValue by its name, using a store if provided.
|
|
569
|
+
*
|
|
570
|
+
* This static method allows looking up a KnownValue by its name:
|
|
571
|
+
* - If a store is provided and contains a mapping for the name, that
|
|
572
|
+
* KnownValue is returned
|
|
573
|
+
* - Otherwise, undefined is returned
|
|
574
|
+
*
|
|
575
|
+
* @param name - The name to look up
|
|
576
|
+
* @param knownValues - Optional store to search in
|
|
577
|
+
* @returns The KnownValue if found, or undefined
|
|
578
|
+
*
|
|
579
|
+
* @example
|
|
580
|
+
* ```typescript
|
|
581
|
+
* import { KnownValuesStore, IS_A } from '@bcts/known-values';
|
|
582
|
+
*
|
|
583
|
+
* const store = new KnownValuesStore([IS_A]);
|
|
584
|
+
*
|
|
585
|
+
* // Known value from store
|
|
586
|
+
* const isA = KnownValuesStore.knownValueForName('isA', store);
|
|
587
|
+
* console.log(isA?.value()); // 1
|
|
588
|
+
*
|
|
589
|
+
* // Unknown name returns undefined
|
|
590
|
+
* console.log(KnownValuesStore.knownValueForName('unknown', store)); // undefined
|
|
591
|
+
*
|
|
592
|
+
* // No store provided also returns undefined
|
|
593
|
+
* console.log(KnownValuesStore.knownValueForName('isA', undefined)); // undefined
|
|
594
|
+
* ```
|
|
595
|
+
*/
|
|
596
|
+
static knownValueForName(name, knownValues) {
|
|
597
|
+
return knownValues?.knownValueNamed(name);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Returns a human-readable name for a KnownValue, using a store if provided.
|
|
601
|
+
*
|
|
602
|
+
* This static method allows getting a name for a KnownValue:
|
|
603
|
+
* - If a store is provided and contains a mapping for the KnownValue, its
|
|
604
|
+
* assigned name is returned
|
|
605
|
+
* - Otherwise, the KnownValue's default name (which may be its numeric
|
|
606
|
+
* value as a string) is returned
|
|
607
|
+
*
|
|
608
|
+
* @param knownValue - The KnownValue to get the name for
|
|
609
|
+
* @param knownValues - Optional store to use for lookup
|
|
610
|
+
* @returns The name (assigned or numeric)
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
* ```typescript
|
|
614
|
+
* import { KnownValuesStore, IS_A } from '@bcts/known-values';
|
|
615
|
+
*
|
|
616
|
+
* const store = new KnownValuesStore([IS_A]);
|
|
617
|
+
*
|
|
618
|
+
* // Known value from store
|
|
619
|
+
* let name = KnownValuesStore.nameForKnownValue(IS_A, store);
|
|
620
|
+
* console.log(name); // "isA"
|
|
621
|
+
*
|
|
622
|
+
* // Unknown value in store uses KnownValue's name method
|
|
623
|
+
* name = KnownValuesStore.nameForKnownValue(new KnownValue(999), store);
|
|
624
|
+
* console.log(name); // "999"
|
|
625
|
+
*
|
|
626
|
+
* // No store provided also uses KnownValue's name method
|
|
627
|
+
* name = KnownValuesStore.nameForKnownValue(IS_A, undefined);
|
|
628
|
+
* console.log(name); // "isA"
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
631
|
+
static nameForKnownValue(knownValue, knownValues) {
|
|
632
|
+
if (knownValues !== void 0) {
|
|
633
|
+
const assignedName = knownValues.assignedName(knownValue);
|
|
634
|
+
if (assignedName !== void 0 && assignedName !== "") return assignedName;
|
|
635
|
+
}
|
|
636
|
+
return knownValue.name();
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Creates a shallow clone of this store.
|
|
640
|
+
*
|
|
641
|
+
* @returns A new KnownValuesStore with the same entries
|
|
642
|
+
*/
|
|
643
|
+
clone() {
|
|
644
|
+
const cloned = new KnownValuesStore();
|
|
645
|
+
cloned.knownValuesByRawValue = new Map(this.knownValuesByRawValue);
|
|
646
|
+
cloned.knownValuesByAssignedName = new Map(this.knownValuesByAssignedName);
|
|
647
|
+
return cloned;
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Internal helper method to insert a KnownValue into the store's maps.
|
|
651
|
+
*/
|
|
652
|
+
_insert(knownValue) {
|
|
653
|
+
this.knownValuesByRawValue.set(knownValue.valueBigInt(), knownValue);
|
|
654
|
+
const assignedName = knownValue.assignedName();
|
|
655
|
+
if (assignedName !== void 0 && assignedName !== "") this.knownValuesByAssignedName.set(assignedName, knownValue);
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/known-values-registry.ts
|
|
661
|
+
const UNIT = new KnownValue(0, "");
|
|
662
|
+
const IS_A = new KnownValue(1, "isA");
|
|
663
|
+
const ID = new KnownValue(2, "id");
|
|
664
|
+
const SIGNED = new KnownValue(3, "signed");
|
|
665
|
+
const NOTE = new KnownValue(4, "note");
|
|
666
|
+
const HAS_RECIPIENT = new KnownValue(5, "hasRecipient");
|
|
667
|
+
const SSKR_SHARE = new KnownValue(6, "sskrShare");
|
|
668
|
+
const CONTROLLER = new KnownValue(7, "controller");
|
|
669
|
+
const KEY = new KnownValue(8, "key");
|
|
670
|
+
const DEREFERENCE_VIA = new KnownValue(9, "dereferenceVia");
|
|
671
|
+
const ENTITY = new KnownValue(10, "entity");
|
|
672
|
+
const NAME = new KnownValue(11, "name");
|
|
673
|
+
const LANGUAGE = new KnownValue(12, "language");
|
|
674
|
+
const ISSUER = new KnownValue(13, "issuer");
|
|
675
|
+
const HOLDER = new KnownValue(14, "holder");
|
|
676
|
+
const SALT = new KnownValue(15, "salt");
|
|
677
|
+
const DATE = new KnownValue(16, "date");
|
|
678
|
+
const UNKNOWN_VALUE = new KnownValue(17, "Unknown");
|
|
679
|
+
const VERSION_VALUE = new KnownValue(18, "version");
|
|
680
|
+
const HAS_SECRET = new KnownValue(19, "hasSecret");
|
|
681
|
+
const DIFF_EDITS = new KnownValue(20, "edits");
|
|
682
|
+
const VALID_FROM = new KnownValue(21, "validFrom");
|
|
683
|
+
const VALID_UNTIL = new KnownValue(22, "validUntil");
|
|
684
|
+
const POSITION = new KnownValue(23, "position");
|
|
685
|
+
const NICKNAME = new KnownValue(24, "nickname");
|
|
686
|
+
const ATTACHMENT = new KnownValue(50, "attachment");
|
|
687
|
+
const VENDOR = new KnownValue(51, "vendor");
|
|
688
|
+
const CONFORMS_TO = new KnownValue(52, "conformsTo");
|
|
689
|
+
const ALLOW = new KnownValue(60, "allow");
|
|
690
|
+
const DENY = new KnownValue(61, "deny");
|
|
691
|
+
const ENDPOINT = new KnownValue(62, "endpoint");
|
|
692
|
+
const DELEGATE = new KnownValue(63, "delegate");
|
|
693
|
+
const PROVENANCE = new KnownValue(64, "provenance");
|
|
694
|
+
const PRIVATE_KEY = new KnownValue(65, "privateKey");
|
|
695
|
+
const SERVICE = new KnownValue(66, "service");
|
|
696
|
+
const CAPABILITY = new KnownValue(67, "capability");
|
|
697
|
+
const PROVENANCE_GENERATOR = new KnownValue(68, "provenanceGenerator");
|
|
698
|
+
const PRIVILEGE_ALL = new KnownValue(70, "All");
|
|
699
|
+
const PRIVILEGE_AUTH = new KnownValue(71, "Auth");
|
|
700
|
+
const PRIVILEGE_SIGN = new KnownValue(72, "Sign");
|
|
701
|
+
const PRIVILEGE_ENCRYPT = new KnownValue(73, "Encrypt");
|
|
702
|
+
const PRIVILEGE_ELIDE = new KnownValue(74, "Elide");
|
|
703
|
+
const PRIVILEGE_ISSUE = new KnownValue(75, "Issue");
|
|
704
|
+
const PRIVILEGE_ACCESS = new KnownValue(76, "Access");
|
|
705
|
+
const PRIVILEGE_DELEGATE = new KnownValue(80, "Delegate");
|
|
706
|
+
const PRIVILEGE_VERIFY = new KnownValue(81, "Verify");
|
|
707
|
+
const PRIVILEGE_UPDATE = new KnownValue(82, "Update");
|
|
708
|
+
const PRIVILEGE_TRANSFER = new KnownValue(83, "Transfer");
|
|
709
|
+
const PRIVILEGE_ELECT = new KnownValue(84, "Elect");
|
|
710
|
+
const PRIVILEGE_BURN = new KnownValue(85, "Burn");
|
|
711
|
+
const PRIVILEGE_REVOKE = new KnownValue(86, "Revoke");
|
|
712
|
+
const BODY = new KnownValue(100, "body");
|
|
713
|
+
const RESULT = new KnownValue(101, "result");
|
|
714
|
+
const ERROR = new KnownValue(102, "error");
|
|
715
|
+
const OK_VALUE = new KnownValue(103, "OK");
|
|
716
|
+
const PROCESSING_VALUE = new KnownValue(104, "Processing");
|
|
717
|
+
const SENDER = new KnownValue(105, "sender");
|
|
718
|
+
const SENDER_CONTINUATION = new KnownValue(106, "senderContinuation");
|
|
719
|
+
const RECIPIENT_CONTINUATION = new KnownValue(107, "recipientContinuation");
|
|
720
|
+
const CONTENT = new KnownValue(108, "content");
|
|
721
|
+
const SEED_TYPE = new KnownValue(200, "Seed");
|
|
722
|
+
const PRIVATE_KEY_TYPE = new KnownValue(201, "PrivateKey");
|
|
723
|
+
const PUBLIC_KEY_TYPE = new KnownValue(202, "PublicKey");
|
|
724
|
+
const MASTER_KEY_TYPE = new KnownValue(203, "MasterKey");
|
|
725
|
+
const ASSET = new KnownValue(300, "asset");
|
|
726
|
+
const BITCOIN_VALUE = new KnownValue(301, "BTC");
|
|
727
|
+
const ETHEREUM_VALUE = new KnownValue(302, "ETH");
|
|
728
|
+
const TEZOS_VALUE = new KnownValue(303, "XTZ");
|
|
729
|
+
const NETWORK = new KnownValue(400, "network");
|
|
730
|
+
const MAIN_NET_VALUE = new KnownValue(401, "MainNet");
|
|
731
|
+
const TEST_NET_VALUE = new KnownValue(402, "TestNet");
|
|
732
|
+
const BIP32_KEY_TYPE = new KnownValue(500, "BIP32Key");
|
|
733
|
+
const CHAIN_CODE = new KnownValue(501, "chainCode");
|
|
734
|
+
const DERIVATION_PATH_TYPE = new KnownValue(502, "DerivationPath");
|
|
735
|
+
const PARENT_PATH = new KnownValue(503, "parent");
|
|
736
|
+
const CHILDREN_PATH = new KnownValue(504, "children");
|
|
737
|
+
const PARENT_FINGERPRINT = new KnownValue(505, "parentFingerprint");
|
|
738
|
+
const PSBT_TYPE = new KnownValue(506, "PSBT");
|
|
739
|
+
const OUTPUT_DESCRIPTOR_TYPE = new KnownValue(507, "OutputDescriptor");
|
|
740
|
+
const OUTPUT_DESCRIPTOR = new KnownValue(508, "outputDescriptor");
|
|
741
|
+
const GRAPH = new KnownValue(600, "graph");
|
|
742
|
+
const SOURCE_TARGET_GRAPH = new KnownValue(601, "SourceTargetGraph");
|
|
743
|
+
const PARENT_CHILD_GRAPH = new KnownValue(602, "ParentChildGraph");
|
|
744
|
+
const DIGRAPH = new KnownValue(603, "Digraph");
|
|
745
|
+
const ACYCLIC_GRAPH = new KnownValue(604, "AcyclicGraph");
|
|
746
|
+
const MULTIGRAPH = new KnownValue(605, "Multigraph");
|
|
747
|
+
const PSEUDOGRAPH = new KnownValue(606, "Pseudograph");
|
|
748
|
+
const GRAPH_FRAGMENT = new KnownValue(607, "GraphFragment");
|
|
749
|
+
const DAG = new KnownValue(608, "DAG");
|
|
750
|
+
const TREE = new KnownValue(609, "Tree");
|
|
751
|
+
const FOREST = new KnownValue(610, "Forest");
|
|
752
|
+
const COMPOUND_GRAPH = new KnownValue(611, "CompoundGraph");
|
|
753
|
+
const HYPERGRAPH = new KnownValue(612, "Hypergraph");
|
|
754
|
+
const DIHYPERGRAPH = new KnownValue(613, "Dihypergraph");
|
|
755
|
+
const NODE = new KnownValue(700, "node");
|
|
756
|
+
const EDGE = new KnownValue(701, "edge");
|
|
757
|
+
const SOURCE = new KnownValue(702, "source");
|
|
758
|
+
const TARGET = new KnownValue(703, "target");
|
|
759
|
+
const PARENT = new KnownValue(704, "parent");
|
|
760
|
+
const CHILD = new KnownValue(705, "child");
|
|
761
|
+
/**
|
|
762
|
+
* A lazily initialized singleton that holds the global registry of known
|
|
763
|
+
* values.
|
|
764
|
+
*
|
|
765
|
+
* This class provides thread-safe, lazy initialization of the global
|
|
766
|
+
* KnownValuesStore that contains all the predefined Known Values in the
|
|
767
|
+
* registry. The store is created only when first accessed, and subsequent
|
|
768
|
+
* accesses reuse the same instance.
|
|
769
|
+
*
|
|
770
|
+
* This is used internally by the crate and should not typically be needed by
|
|
771
|
+
* users of the API, who should access Known Values through the constants
|
|
772
|
+
* exposed in the `known_values` module.
|
|
773
|
+
*/
|
|
774
|
+
var LazyKnownValues = class {
|
|
775
|
+
_data;
|
|
776
|
+
/**
|
|
777
|
+
* Gets the global KnownValuesStore, initializing it if necessary.
|
|
778
|
+
*
|
|
779
|
+
* This method guarantees that initialization occurs exactly once.
|
|
780
|
+
*/
|
|
781
|
+
get() {
|
|
782
|
+
this._data ??= new KnownValuesStore([
|
|
783
|
+
UNIT,
|
|
784
|
+
IS_A,
|
|
785
|
+
ID,
|
|
786
|
+
SIGNED,
|
|
787
|
+
NOTE,
|
|
788
|
+
HAS_RECIPIENT,
|
|
789
|
+
SSKR_SHARE,
|
|
790
|
+
CONTROLLER,
|
|
791
|
+
KEY,
|
|
792
|
+
DEREFERENCE_VIA,
|
|
793
|
+
ENTITY,
|
|
794
|
+
NAME,
|
|
795
|
+
LANGUAGE,
|
|
796
|
+
ISSUER,
|
|
797
|
+
HOLDER,
|
|
798
|
+
SALT,
|
|
799
|
+
DATE,
|
|
800
|
+
UNKNOWN_VALUE,
|
|
801
|
+
VERSION_VALUE,
|
|
802
|
+
HAS_SECRET,
|
|
803
|
+
DIFF_EDITS,
|
|
804
|
+
VALID_FROM,
|
|
805
|
+
VALID_UNTIL,
|
|
806
|
+
POSITION,
|
|
807
|
+
NICKNAME,
|
|
808
|
+
ATTACHMENT,
|
|
809
|
+
VENDOR,
|
|
810
|
+
CONFORMS_TO,
|
|
811
|
+
ALLOW,
|
|
812
|
+
DENY,
|
|
813
|
+
ENDPOINT,
|
|
814
|
+
DELEGATE,
|
|
815
|
+
PROVENANCE,
|
|
816
|
+
PRIVATE_KEY,
|
|
817
|
+
SERVICE,
|
|
818
|
+
CAPABILITY,
|
|
819
|
+
PROVENANCE_GENERATOR,
|
|
820
|
+
PRIVILEGE_ALL,
|
|
821
|
+
PRIVILEGE_AUTH,
|
|
822
|
+
PRIVILEGE_SIGN,
|
|
823
|
+
PRIVILEGE_ENCRYPT,
|
|
824
|
+
PRIVILEGE_ELIDE,
|
|
825
|
+
PRIVILEGE_ISSUE,
|
|
826
|
+
PRIVILEGE_ACCESS,
|
|
827
|
+
PRIVILEGE_DELEGATE,
|
|
828
|
+
PRIVILEGE_VERIFY,
|
|
829
|
+
PRIVILEGE_UPDATE,
|
|
830
|
+
PRIVILEGE_TRANSFER,
|
|
831
|
+
PRIVILEGE_ELECT,
|
|
832
|
+
PRIVILEGE_BURN,
|
|
833
|
+
PRIVILEGE_REVOKE,
|
|
834
|
+
BODY,
|
|
835
|
+
RESULT,
|
|
836
|
+
ERROR,
|
|
837
|
+
OK_VALUE,
|
|
838
|
+
PROCESSING_VALUE,
|
|
839
|
+
SENDER,
|
|
840
|
+
SENDER_CONTINUATION,
|
|
841
|
+
RECIPIENT_CONTINUATION,
|
|
842
|
+
CONTENT,
|
|
843
|
+
SEED_TYPE,
|
|
844
|
+
PRIVATE_KEY_TYPE,
|
|
845
|
+
PUBLIC_KEY_TYPE,
|
|
846
|
+
MASTER_KEY_TYPE,
|
|
847
|
+
ASSET,
|
|
848
|
+
BITCOIN_VALUE,
|
|
849
|
+
ETHEREUM_VALUE,
|
|
850
|
+
TEZOS_VALUE,
|
|
851
|
+
NETWORK,
|
|
852
|
+
MAIN_NET_VALUE,
|
|
853
|
+
TEST_NET_VALUE,
|
|
854
|
+
BIP32_KEY_TYPE,
|
|
855
|
+
CHAIN_CODE,
|
|
856
|
+
DERIVATION_PATH_TYPE,
|
|
857
|
+
PARENT_PATH,
|
|
858
|
+
CHILDREN_PATH,
|
|
859
|
+
PARENT_FINGERPRINT,
|
|
860
|
+
PSBT_TYPE,
|
|
861
|
+
OUTPUT_DESCRIPTOR_TYPE,
|
|
862
|
+
OUTPUT_DESCRIPTOR,
|
|
863
|
+
GRAPH,
|
|
864
|
+
SOURCE_TARGET_GRAPH,
|
|
865
|
+
PARENT_CHILD_GRAPH,
|
|
866
|
+
DIGRAPH,
|
|
867
|
+
ACYCLIC_GRAPH,
|
|
868
|
+
MULTIGRAPH,
|
|
869
|
+
PSEUDOGRAPH,
|
|
870
|
+
GRAPH_FRAGMENT,
|
|
871
|
+
DAG,
|
|
872
|
+
TREE,
|
|
873
|
+
FOREST,
|
|
874
|
+
COMPOUND_GRAPH,
|
|
875
|
+
HYPERGRAPH,
|
|
876
|
+
DIHYPERGRAPH,
|
|
877
|
+
NODE,
|
|
878
|
+
EDGE,
|
|
879
|
+
SOURCE,
|
|
880
|
+
TARGET,
|
|
881
|
+
PARENT,
|
|
882
|
+
CHILD
|
|
883
|
+
]);
|
|
884
|
+
return this._data;
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
/**
|
|
888
|
+
* The global registry of Known Values.
|
|
889
|
+
*
|
|
890
|
+
* This static instance provides access to all standard Known Values defined in
|
|
891
|
+
* the registry specification. It is lazily initialized on first access.
|
|
892
|
+
*
|
|
893
|
+
* Most users should not need to interact with this directly, as the predefined
|
|
894
|
+
* Known Values are exposed as constants in the `known_values` module.
|
|
895
|
+
*
|
|
896
|
+
* @example
|
|
897
|
+
* ```typescript
|
|
898
|
+
* import { KNOWN_VALUES } from '@bcts/known-values';
|
|
899
|
+
*
|
|
900
|
+
* // Access the global store
|
|
901
|
+
* const knownValues = KNOWN_VALUES.get();
|
|
902
|
+
*
|
|
903
|
+
* // Look up a Known Value by name
|
|
904
|
+
* const isA = knownValues.knownValueNamed('isA');
|
|
905
|
+
* console.log(isA?.value()); // 1
|
|
906
|
+
* ```
|
|
907
|
+
*/
|
|
908
|
+
const KNOWN_VALUES = new LazyKnownValues();
|
|
909
|
+
|
|
910
|
+
//#endregion
|
|
911
|
+
export { ACYCLIC_GRAPH, ALLOW, ASSET, ATTACHMENT, BIP32_KEY_TYPE, BITCOIN_VALUE, BODY, CAPABILITY, CHAIN_CODE, CHILD, CHILDREN_PATH, COMPOUND_GRAPH, CONFORMS_TO, CONTENT, CONTROLLER, DAG, DATE, DELEGATE, DENY, DEREFERENCE_VIA, DERIVATION_PATH_TYPE, DIFF_EDITS, DIGRAPH, DIHYPERGRAPH, EDGE, ENDPOINT, ENTITY, ERROR, ETHEREUM_VALUE, FOREST, GRAPH, GRAPH_FRAGMENT, HAS_RECIPIENT, HAS_SECRET, HOLDER, HYPERGRAPH, ID, ISSUER, IS_A, KEY, KNOWN_VALUES, KNOWN_VALUE_TAG, KnownValue, KnownValuesStore, LANGUAGE, LazyKnownValues, MAIN_NET_VALUE, MASTER_KEY_TYPE, MULTIGRAPH, NAME, NETWORK, NICKNAME, NODE, NOTE, OK_VALUE, OUTPUT_DESCRIPTOR, OUTPUT_DESCRIPTOR_TYPE, PARENT, PARENT_CHILD_GRAPH, PARENT_FINGERPRINT, PARENT_PATH, POSITION, PRIVATE_KEY, PRIVATE_KEY_TYPE, PRIVILEGE_ACCESS, PRIVILEGE_ALL, PRIVILEGE_AUTH, PRIVILEGE_BURN, PRIVILEGE_DELEGATE, PRIVILEGE_ELECT, PRIVILEGE_ELIDE, PRIVILEGE_ENCRYPT, PRIVILEGE_ISSUE, PRIVILEGE_REVOKE, PRIVILEGE_SIGN, PRIVILEGE_TRANSFER, PRIVILEGE_UPDATE, PRIVILEGE_VERIFY, PROCESSING_VALUE, PROVENANCE, PROVENANCE_GENERATOR, PSBT_TYPE, PSEUDOGRAPH, PUBLIC_KEY_TYPE, RECIPIENT_CONTINUATION, RESULT, SALT, SEED_TYPE, SENDER, SENDER_CONTINUATION, SERVICE, SIGNED, SOURCE, SOURCE_TARGET_GRAPH, SSKR_SHARE, TAG_KNOWN_VALUE, TARGET, TEST_NET_VALUE, TEZOS_VALUE, TREE, UNIT, UNKNOWN_VALUE, VALID_FROM, VALID_UNTIL, VENDOR, VERSION_VALUE };
|
|
912
|
+
//# sourceMappingURL=index.mjs.map
|