@dxos/keys 0.8.4-main.5ad4a44 → 0.8.4-main.66e292d

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.
@@ -108,75 +108,13 @@ import { assertArgument, invariant as invariant2 } from "@dxos/invariant";
108
108
  init_inject_globals();
109
109
  import * as Schema from "effect/Schema";
110
110
  import { monotonicFactory } from "ulidx";
111
- function _check_private_redeclaration(obj, privateCollection) {
112
- if (privateCollection.has(obj)) {
113
- throw new TypeError("Cannot initialize the same private elements twice on an object");
114
- }
115
- }
116
- function _class_apply_descriptor_get(receiver, descriptor) {
117
- if (descriptor.get) {
118
- return descriptor.get.call(receiver);
119
- }
120
- return descriptor.value;
121
- }
122
- function _class_apply_descriptor_set(receiver, descriptor, value) {
123
- if (descriptor.set) {
124
- descriptor.set.call(receiver, value);
125
- } else {
126
- if (!descriptor.writable) {
127
- throw new TypeError("attempted to set read only private field");
128
- }
129
- descriptor.value = value;
130
- }
131
- }
132
- function _class_check_private_static_field_descriptor(descriptor, action) {
133
- if (descriptor === void 0) {
134
- throw new TypeError("attempted to " + action + " private static field before its declaration");
135
- }
136
- }
137
- function _class_extract_field_descriptor(receiver, privateMap, action) {
138
- if (!privateMap.has(receiver)) {
139
- throw new TypeError("attempted to " + action + " private field on non-instance");
140
- }
141
- return privateMap.get(receiver);
142
- }
143
- function _class_private_field_get(receiver, privateMap) {
144
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
145
- return _class_apply_descriptor_get(receiver, descriptor);
146
- }
147
- function _class_private_field_init(obj, privateMap, value) {
148
- _check_private_redeclaration(obj, privateMap);
149
- privateMap.set(obj, value);
150
- }
151
- function _class_private_field_set(receiver, privateMap, value) {
152
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
153
- _class_apply_descriptor_set(receiver, descriptor, value);
154
- return value;
155
- }
156
- function _class_static_private_field_spec_get(receiver, classConstructor, descriptor) {
157
- _class_check_private_static_access(receiver, classConstructor);
158
- _class_check_private_static_field_descriptor(descriptor, "get");
159
- return _class_apply_descriptor_get(receiver, descriptor);
160
- }
161
- function _class_static_private_field_spec_set(receiver, classConstructor, descriptor, value) {
162
- _class_check_private_static_access(receiver, classConstructor);
163
- _class_check_private_static_field_descriptor(descriptor, "set");
164
- _class_apply_descriptor_set(receiver, descriptor, value);
165
- return value;
166
- }
167
- function _class_check_private_static_access(receiver, classConstructor) {
168
- if (receiver !== classConstructor) {
169
- throw new TypeError("Private static access of wrong provenance");
170
- }
171
- }
172
- var _class;
173
- var _factory;
174
- var _seedTime;
175
111
  var ObjectIdSchema = Schema.String.pipe(Schema.pattern(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i)).annotations({
176
112
  description: "A Universally Unique Lexicographically Sortable Identifier",
177
113
  pattern: "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
178
114
  });
179
- var ObjectId = (_class = class extends ObjectIdSchema {
115
+ var ObjectId = class extends ObjectIdSchema {
116
+ static #factory = monotonicFactory();
117
+ static #seedTime = void 0;
180
118
  static isValid(id) {
181
119
  try {
182
120
  Schema.decodeSync(ObjectId)(id);
@@ -186,65 +124,47 @@ var ObjectId = (_class = class extends ObjectIdSchema {
186
124
  }
187
125
  }
188
126
  static random() {
189
- return _class_static_private_field_spec_get(this, _class, _factory).call(_class, _class_static_private_field_spec_get(this, _class, _seedTime));
127
+ return this.#factory(this.#seedTime);
190
128
  }
191
129
  static dangerouslyDisableRandomness() {
192
- _class_static_private_field_spec_set(this, _class, _factory, monotonicFactory(makeTestPRNG()));
193
- _class_static_private_field_spec_set(this, _class, _seedTime, (/* @__PURE__ */ new Date("2025-01-01")).getTime());
194
- }
195
- }, _factory = {
196
- writable: true,
197
- value: monotonicFactory()
198
- }, _seedTime = {
199
- writable: true,
200
- value: void 0
201
- }, _class);
130
+ this.#factory = monotonicFactory(makeTestPRNG());
131
+ this.#seedTime = (/* @__PURE__ */ new Date("2025-01-01")).getTime();
132
+ }
133
+ };
202
134
  var makeTestPRNG = () => {
203
135
  const rng = new SimplePRNG();
204
136
  return () => {
205
137
  return rng.next();
206
138
  };
207
139
  };
208
- var _seed = /* @__PURE__ */ new WeakMap();
209
140
  var SimplePRNG = class _SimplePRNG {
141
+ #seed;
142
+ // LCG parameters (from Numerical Recipes)
143
+ static #a = 1664525;
144
+ static #c = 1013904223;
145
+ static #m = Math.pow(2, 32);
146
+ /**
147
+ * Creates a new PRNG instance.
148
+ * @param seed - Initial seed value. If not provided, uses 0.
149
+ */
150
+ constructor(seed = 0) {
151
+ this.#seed = seed;
152
+ }
210
153
  /**
211
154
  * Generates the next pseudo-random number in the range [0, 1).
212
155
  * @returns A pseudo-random number between 0 (inclusive) and 1 (exclusive).
213
156
  */
214
157
  next() {
215
- _class_private_field_set(this, _seed, (_class_static_private_field_spec_get(_SimplePRNG, _SimplePRNG, _a) * _class_private_field_get(this, _seed) + _class_static_private_field_spec_get(_SimplePRNG, _SimplePRNG, _c)) % _class_static_private_field_spec_get(_SimplePRNG, _SimplePRNG, _m));
216
- return _class_private_field_get(this, _seed) / _class_static_private_field_spec_get(_SimplePRNG, _SimplePRNG, _m);
158
+ this.#seed = (_SimplePRNG.#a * this.#seed + _SimplePRNG.#c) % _SimplePRNG.#m;
159
+ return this.#seed / _SimplePRNG.#m;
217
160
  }
218
161
  /**
219
162
  * Resets the generator with a new seed.
220
163
  * @param seed - New seed value.
221
164
  */
222
165
  reset(seed) {
223
- _class_private_field_set(this, _seed, seed);
166
+ this.#seed = seed;
224
167
  }
225
- /**
226
- * Creates a new PRNG instance.
227
- * @param seed - Initial seed value. If not provided, uses 0.
228
- */
229
- constructor(seed = 0) {
230
- _class_private_field_init(this, _seed, {
231
- writable: true,
232
- value: void 0
233
- });
234
- _class_private_field_set(this, _seed, seed);
235
- }
236
- };
237
- var _a = {
238
- writable: true,
239
- value: 1664525
240
- };
241
- var _c = {
242
- writable: true,
243
- value: 1013904223
244
- };
245
- var _m = {
246
- writable: true,
247
- value: Math.pow(2, 32)
248
168
  };
249
169
 
250
170
  // src/space-id.ts
@@ -328,117 +248,54 @@ var randomBytes = (length) => {
328
248
  };
329
249
 
330
250
  // src/space-id.ts
331
- function _define_property(obj, key, value) {
332
- if (key in obj) {
333
- Object.defineProperty(obj, key, {
334
- value,
335
- enumerable: true,
336
- configurable: true,
337
- writable: true
338
- });
339
- } else {
340
- obj[key] = value;
341
- }
342
- return obj;
343
- }
344
- var _Schema_String_pipe;
345
- var _class2;
346
251
  var __dxlog_file = "/__w/dxos/dxos/packages/common/keys/src/space-id.ts";
347
252
  var MULTIBASE_PREFIX = "B";
348
253
  var ENCODED_LENGTH = 33;
349
254
  var isValid = (value) => {
350
255
  return typeof value === "string" && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;
351
256
  };
352
- var SpaceId = (_class2 = class extends (_Schema_String_pipe = Schema2.String.pipe(Schema2.filter(isValid))) {
353
- }, _define_property(_class2, "byteLength", 20), _define_property(_class2, "encode", (value) => {
354
- invariant(value instanceof Uint8Array, "Invalid type", {
355
- F: __dxlog_file,
356
- L: 43,
357
- S: _class2,
358
- A: [
359
- "value instanceof Uint8Array",
360
- "'Invalid type'"
361
- ]
362
- });
363
- invariant(value.length === SpaceId.byteLength, "Invalid length", {
364
- F: __dxlog_file,
365
- L: 44,
366
- S: _class2,
367
- A: [
368
- "value.length === SpaceId.byteLength",
369
- "'Invalid length'"
370
- ]
371
- });
372
- return MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
373
- }), _define_property(_class2, "decode", (value) => {
374
- invariant(value.startsWith(MULTIBASE_PREFIX), "Invalid multibase32 encoding", {
375
- F: __dxlog_file,
376
- L: 49,
377
- S: _class2,
378
- A: [
379
- "value.startsWith(MULTIBASE_PREFIX)",
380
- "'Invalid multibase32 encoding'"
381
- ]
382
- });
383
- return new Uint8Array((0, import_base32_decode.default)(value.slice(1), "RFC4648"));
384
- }), _define_property(_class2, "isValid", isValid), _define_property(_class2, "random", () => {
385
- return SpaceId.encode(randomBytes(SpaceId.byteLength));
386
- }), _class2);
257
+ var SpaceId = class extends Schema2.String.pipe(Schema2.filter(isValid)) {
258
+ static byteLength = 20;
259
+ static encode = (value) => {
260
+ invariant(value instanceof Uint8Array, "Invalid type", {
261
+ F: __dxlog_file,
262
+ L: 43,
263
+ S: this,
264
+ A: [
265
+ "value instanceof Uint8Array",
266
+ "'Invalid type'"
267
+ ]
268
+ });
269
+ invariant(value.length === SpaceId.byteLength, "Invalid length", {
270
+ F: __dxlog_file,
271
+ L: 44,
272
+ S: this,
273
+ A: [
274
+ "value.length === SpaceId.byteLength",
275
+ "'Invalid length'"
276
+ ]
277
+ });
278
+ return MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
279
+ };
280
+ static decode = (value) => {
281
+ invariant(value.startsWith(MULTIBASE_PREFIX), "Invalid multibase32 encoding", {
282
+ F: __dxlog_file,
283
+ L: 49,
284
+ S: this,
285
+ A: [
286
+ "value.startsWith(MULTIBASE_PREFIX)",
287
+ "'Invalid multibase32 encoding'"
288
+ ]
289
+ });
290
+ return new Uint8Array((0, import_base32_decode.default)(value.slice(1), "RFC4648"));
291
+ };
292
+ static isValid = isValid;
293
+ static random = () => {
294
+ return SpaceId.encode(randomBytes(SpaceId.byteLength));
295
+ };
296
+ };
387
297
 
388
298
  // src/dxn.ts
389
- function _check_private_redeclaration2(obj, privateCollection) {
390
- if (privateCollection.has(obj)) {
391
- throw new TypeError("Cannot initialize the same private elements twice on an object");
392
- }
393
- }
394
- function _class_apply_descriptor_get2(receiver, descriptor) {
395
- if (descriptor.get) {
396
- return descriptor.get.call(receiver);
397
- }
398
- return descriptor.value;
399
- }
400
- function _class_apply_descriptor_set2(receiver, descriptor, value) {
401
- if (descriptor.set) {
402
- descriptor.set.call(receiver, value);
403
- } else {
404
- if (!descriptor.writable) {
405
- throw new TypeError("attempted to set read only private field");
406
- }
407
- descriptor.value = value;
408
- }
409
- }
410
- function _class_extract_field_descriptor2(receiver, privateMap, action) {
411
- if (!privateMap.has(receiver)) {
412
- throw new TypeError("attempted to " + action + " private field on non-instance");
413
- }
414
- return privateMap.get(receiver);
415
- }
416
- function _class_private_field_get2(receiver, privateMap) {
417
- var descriptor = _class_extract_field_descriptor2(receiver, privateMap, "get");
418
- return _class_apply_descriptor_get2(receiver, descriptor);
419
- }
420
- function _class_private_field_init2(obj, privateMap, value) {
421
- _check_private_redeclaration2(obj, privateMap);
422
- privateMap.set(obj, value);
423
- }
424
- function _class_private_field_set2(receiver, privateMap, value) {
425
- var descriptor = _class_extract_field_descriptor2(receiver, privateMap, "set");
426
- _class_apply_descriptor_set2(receiver, descriptor, value);
427
- return value;
428
- }
429
- function _define_property2(obj, key, value) {
430
- if (key in obj) {
431
- Object.defineProperty(obj, key, {
432
- value,
433
- enumerable: true,
434
- configurable: true,
435
- writable: true
436
- });
437
- } else {
438
- obj[key] = value;
439
- }
440
- return obj;
441
- }
442
299
  var __dxlog_file2 = "/__w/dxos/dxos/packages/common/keys/src/dxn.ts";
443
300
  var LOCAL_SPACE_TAG = "@";
444
301
  var DXN_ECHO_REGEXP = /@(dxn:[a-zA-Z0-p:@]+)/;
@@ -446,15 +303,49 @@ var QueueSubspaceTags = Object.freeze({
446
303
  DATA: "data",
447
304
  TRACE: "trace"
448
305
  });
449
- var _kind = /* @__PURE__ */ new WeakMap();
450
- var _parts = /* @__PURE__ */ new WeakMap();
451
- var _inspectCustom = inspectCustom;
452
- var _devtoolsFormatter = devtoolsFormatter;
453
306
  var DXN = class _DXN {
307
+ // TODO(burdon): Rename to DXN (i.e., DXN.DXN).
308
+ // TODO(dmaretskyi): Should this be a transformation into the DXN type?
309
+ static Schema = Schema3.NonEmptyString.pipe(
310
+ Schema3.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),
311
+ // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.
312
+ // FormatAnnotation.set(TypeFormat.DXN),
313
+ Schema3.annotations({
314
+ title: "DXN",
315
+ description: "DXN URI",
316
+ examples: [
317
+ "dxn:type:example.com/type/MyType",
318
+ "dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6"
319
+ ]
320
+ })
321
+ );
454
322
  static hash(dxn) {
455
323
  return dxn.toString();
456
324
  }
457
325
  /**
326
+ * Kind constants.
327
+ */
328
+ static kind = Object.freeze({
329
+ /**
330
+ * dxn:type:<type_name>[:<version>]
331
+ */
332
+ TYPE: "type",
333
+ /**
334
+ * dxn:echo:<space_id>:<echo_id>
335
+ * dxn:echo:@:<echo_id>
336
+ */
337
+ // TODO(burdon): Rename to OBJECT? (BREAKING CHANGE to update "echo").
338
+ // TODO(burdon): Add separate Kind for space?
339
+ ECHO: "echo",
340
+ /**
341
+ * The subspace tag enables us to partition queues by usage within the context of a space.
342
+ * dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
343
+ * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
344
+ * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
345
+ */
346
+ QUEUE: "queue"
347
+ });
348
+ /**
458
349
  * Exactly equals.
459
350
  */
460
351
  static equals(a, b) {
@@ -493,7 +384,7 @@ var DXN = class _DXN {
493
384
  }
494
385
  }
495
386
  /**
496
- * @example `dxn:type:example.com/type/Contact`
387
+ * @example `dxn:type:example.com/type/Person`
497
388
  */
498
389
  static fromTypename(typename) {
499
390
  return new _DXN(_DXN.kind.TYPE, [
@@ -501,7 +392,7 @@ var DXN = class _DXN {
501
392
  ]);
502
393
  }
503
394
  /**
504
- * @example `dxn:type:example.com/type/Contact:0.1.0`
395
+ * @example `dxn:type:example.com/type/Person:0.1.0`
505
396
  */
506
397
  // TODO(dmaretskyi): Consider using @ as the version separator.
507
398
  static fromTypenameAndVersion(typename, version) {
@@ -544,8 +435,28 @@ var DXN = class _DXN {
544
435
  ] : []
545
436
  ]);
546
437
  }
438
+ #kind;
439
+ #parts;
440
+ constructor(kind, parts) {
441
+ assertArgument(parts.length > 0, "parts", `Invalid DXN: ${parts}`);
442
+ assertArgument(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), "parts", `Invalid DXN: ${parts}`);
443
+ switch (kind) {
444
+ case _DXN.kind.TYPE:
445
+ if (parts.length > 2) {
446
+ throw new Error("Invalid DXN.kind.TYPE");
447
+ }
448
+ break;
449
+ case _DXN.kind.ECHO:
450
+ if (parts.length !== 2) {
451
+ throw new Error("Invalid DXN.kind.ECHO");
452
+ }
453
+ break;
454
+ }
455
+ this.#kind = kind;
456
+ this.#parts = parts;
457
+ }
547
458
  toString() {
548
- return `dxn:${_class_private_field_get2(this, _kind)}:${_class_private_field_get2(this, _parts).join(":")}`;
459
+ return `dxn:${this.#kind}:${this.#parts.join(":")}`;
549
460
  }
550
461
  toJSON() {
551
462
  return this.toString();
@@ -553,13 +464,13 @@ var DXN = class _DXN {
553
464
  /**
554
465
  * Used by Node.js to get textual representation of this object when it's printed with a `console.log` statement.
555
466
  */
556
- [_inspectCustom](depth, options, inspectFn) {
467
+ [inspectCustom](depth, options, inspectFn) {
557
468
  const printControlCode = (code) => {
558
469
  return `\x1B[${code}m`;
559
470
  };
560
471
  return printControlCode(inspectFn.colors.blueBright[0]) + this.toString() + printControlCode(inspectFn.colors.reset[0]);
561
472
  }
562
- get [_devtoolsFormatter]() {
473
+ get [devtoolsFormatter]() {
563
474
  return {
564
475
  header: () => {
565
476
  return [
@@ -573,14 +484,14 @@ var DXN = class _DXN {
573
484
  };
574
485
  }
575
486
  get kind() {
576
- return _class_private_field_get2(this, _kind);
487
+ return this.#kind;
577
488
  }
578
489
  get parts() {
579
- return _class_private_field_get2(this, _parts);
490
+ return this.#parts;
580
491
  }
581
492
  // TODO(burdon): Should getters fail?
582
493
  get typename() {
583
- invariant2(_class_private_field_get2(this, _kind) === _DXN.kind.TYPE, void 0, {
494
+ invariant2(this.#kind === _DXN.kind.TYPE, void 0, {
584
495
  F: __dxlog_file2,
585
496
  L: 250,
586
497
  S: this,
@@ -589,22 +500,22 @@ var DXN = class _DXN {
589
500
  ""
590
501
  ]
591
502
  });
592
- return _class_private_field_get2(this, _parts)[0];
503
+ return this.#parts[0];
593
504
  }
594
505
  equals(other) {
595
506
  return _DXN.equals(this, other);
596
507
  }
597
508
  hasTypenameOf(typename) {
598
- return _class_private_field_get2(this, _kind) === _DXN.kind.TYPE && _class_private_field_get2(this, _parts).length === 1 && _class_private_field_get2(this, _parts)[0] === typename;
509
+ return this.#kind === _DXN.kind.TYPE && this.#parts.length === 1 && this.#parts[0] === typename;
599
510
  }
600
511
  isLocalObjectId() {
601
- return _class_private_field_get2(this, _kind) === _DXN.kind.ECHO && _class_private_field_get2(this, _parts)[0] === LOCAL_SPACE_TAG && _class_private_field_get2(this, _parts).length === 2;
512
+ return this.#kind === _DXN.kind.ECHO && this.#parts[0] === LOCAL_SPACE_TAG && this.#parts.length === 2;
602
513
  }
603
514
  asTypeDXN() {
604
515
  if (this.kind !== _DXN.kind.TYPE) {
605
516
  return void 0;
606
517
  }
607
- const [type, version] = _class_private_field_get2(this, _parts);
518
+ const [type, version] = this.#parts;
608
519
  return {
609
520
  // TODO(wittjosiah): Should be `typename` for consistency.
610
521
  type,
@@ -615,7 +526,7 @@ var DXN = class _DXN {
615
526
  if (this.kind !== _DXN.kind.ECHO) {
616
527
  return void 0;
617
528
  }
618
- const [spaceId, echoId] = _class_private_field_get2(this, _parts);
529
+ const [spaceId, echoId] = this.#parts;
619
530
  return {
620
531
  spaceId: spaceId === LOCAL_SPACE_TAG ? void 0 : spaceId,
621
532
  // TODO(burdon): objectId.
@@ -626,7 +537,7 @@ var DXN = class _DXN {
626
537
  if (this.kind !== _DXN.kind.QUEUE) {
627
538
  return void 0;
628
539
  }
629
- const [subspaceTag, spaceId, queueId, objectId] = _class_private_field_get2(this, _parts);
540
+ const [subspaceTag, spaceId, queueId, objectId] = this.#parts;
630
541
  if (typeof queueId !== "string") {
631
542
  return void 0;
632
543
  }
@@ -641,71 +552,12 @@ var DXN = class _DXN {
641
552
  * Produces a new DXN with the given parts appended.
642
553
  */
643
554
  extend(parts) {
644
- return new _DXN(_class_private_field_get2(this, _kind), [
645
- ..._class_private_field_get2(this, _parts),
555
+ return new _DXN(this.#kind, [
556
+ ...this.#parts,
646
557
  ...parts
647
558
  ]);
648
559
  }
649
- constructor(kind, parts) {
650
- _class_private_field_init2(this, _kind, {
651
- writable: true,
652
- value: void 0
653
- });
654
- _class_private_field_init2(this, _parts, {
655
- writable: true,
656
- value: void 0
657
- });
658
- assertArgument(parts.length > 0, "parts", `Invalid DXN: ${parts}`);
659
- assertArgument(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), "parts", `Invalid DXN: ${parts}`);
660
- switch (kind) {
661
- case _DXN.kind.TYPE:
662
- if (parts.length > 2) {
663
- throw new Error("Invalid DXN.kind.TYPE");
664
- }
665
- break;
666
- case _DXN.kind.ECHO:
667
- if (parts.length !== 2) {
668
- throw new Error("Invalid DXN.kind.ECHO");
669
- }
670
- break;
671
- }
672
- _class_private_field_set2(this, _kind, kind);
673
- _class_private_field_set2(this, _parts, parts);
674
- }
675
560
  };
676
- _define_property2(DXN, "Schema", Schema3.NonEmptyString.pipe(
677
- Schema3.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),
678
- // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.
679
- // FormatAnnotation.set(FormatEnum.DXN),
680
- Schema3.annotations({
681
- title: "DXN",
682
- description: "DXN URI",
683
- examples: [
684
- "dxn:type:example.com/type/MyType",
685
- "dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6"
686
- ]
687
- })
688
- ));
689
- _define_property2(DXN, "kind", Object.freeze({
690
- /**
691
- * dxn:type:<type_name>[:<version>]
692
- */
693
- TYPE: "type",
694
- /**
695
- * dxn:echo:<space_id>:<echo_id>
696
- * dxn:echo:@:<echo_id>
697
- */
698
- // TODO(burdon): Rename to OBJECT? (BREAKING CHANGE to update "echo").
699
- // TODO(burdon): Add separate Kind for space?
700
- ECHO: "echo",
701
- /**
702
- * The subspace tag enables us to partition queues by usage within the context of a space.
703
- * dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
704
- * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
705
- * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
706
- */
707
- QUEUE: "queue"
708
- }));
709
561
 
710
562
  // src/identity-did.ts
711
563
  init_inject_globals();
@@ -763,27 +615,13 @@ init_inject_globals();
763
615
  var import_base32_decode3 = __toESM(require_base32_decode(), 1);
764
616
  import { devtoolsFormatter as devtoolsFormatter2, equalsSymbol, inspectCustom as inspectCustom2, truncateKey } from "@dxos/debug";
765
617
  import { invariant as invariant4 } from "@dxos/invariant";
766
- function _define_property3(obj, key, value) {
767
- if (key in obj) {
768
- Object.defineProperty(obj, key, {
769
- value,
770
- enumerable: true,
771
- configurable: true,
772
- writable: true
773
- });
774
- } else {
775
- obj[key] = value;
776
- }
777
- return obj;
778
- }
779
618
  var __dxlog_file4 = "/__w/dxos/dxos/packages/common/keys/src/public-key.ts";
780
619
  var PUBLIC_KEY_LENGTH = 32;
781
620
  var SECRET_KEY_LENGTH = 64;
782
621
  var isLikeArrayBuffer = (value) => typeof value === "object" && value !== null && Object.getPrototypeOf(value).constructor.name === "ArrayBuffer";
783
- var _inspectCustom2 = inspectCustom2;
784
- var _devtoolsFormatter2 = devtoolsFormatter2;
785
- var _equalsSymbol = equalsSymbol;
786
622
  var PublicKey = class _PublicKey {
623
+ _value;
624
+ static ZERO = _PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH));
787
625
  /**
788
626
  * Creates new instance of PublicKey automatically determining the input format.
789
627
  * @param source A Buffer, or Uint8Array, or hex encoded string, or something with an `asUint8Array` method on it
@@ -935,6 +773,12 @@ var PublicKey = class _PublicKey {
935
773
  });
936
774
  return new _PublicKey(new Uint8Array((0, import_base32_decode3.default)(encoded.slice(1), "RFC4648")));
937
775
  }
776
+ constructor(_value) {
777
+ this._value = _value;
778
+ if (!(_value instanceof Uint8Array)) {
779
+ throw new TypeError(`Expected Uint8Array, got: ${_value}`);
780
+ }
781
+ }
938
782
  toString() {
939
783
  return this.toHex();
940
784
  }
@@ -968,7 +812,7 @@ var PublicKey = class _PublicKey {
968
812
  /**
969
813
  * Used by Node.js to get textual representation of this object when it's printed with a `console.log` statement.
970
814
  */
971
- [_inspectCustom2](depth, options, inspectFn) {
815
+ [inspectCustom2](depth, options, inspectFn) {
972
816
  if (!options.colors || typeof process.stdout.hasColors !== "function" || !process.stdout.hasColors()) {
973
817
  return `<PublicKey ${this.truncate()}>`;
974
818
  }
@@ -993,7 +837,7 @@ var PublicKey = class _PublicKey {
993
837
  const color = colors[this.getInsecureHash(colors.length)];
994
838
  return `PublicKey(${printControlCode(inspectFn.colors[color][0])}${this.truncate()}${printControlCode(inspectFn.colors.reset[0])})`;
995
839
  }
996
- get [_devtoolsFormatter2]() {
840
+ get [devtoolsFormatter2]() {
997
841
  return {
998
842
  header: () => {
999
843
  const colors = [
@@ -1046,25 +890,17 @@ var PublicKey = class _PublicKey {
1046
890
  }
1047
891
  let equal = true;
1048
892
  for (let i = 0; i < this._value.length; i++) {
1049
- equal && (equal = this._value[i] === otherConverted._value[i]);
893
+ equal &&= this._value[i] === otherConverted._value[i];
1050
894
  }
1051
895
  return equal;
1052
896
  }
1053
- [_equalsSymbol](other) {
897
+ [equalsSymbol](other) {
1054
898
  if (!_PublicKey.isPublicKey(other)) {
1055
899
  return false;
1056
900
  }
1057
901
  return this.equals(other);
1058
902
  }
1059
- constructor(_value) {
1060
- _define_property3(this, "_value", void 0);
1061
- this._value = _value;
1062
- if (!(_value instanceof Uint8Array)) {
1063
- throw new TypeError(`Expected Uint8Array, got: ${_value}`);
1064
- }
1065
- }
1066
903
  };
1067
- _define_property3(PublicKey, "ZERO", PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH)));
1068
904
  export {
1069
905
  DXN,
1070
906
  DXN_ECHO_REGEXP,