@dxos/keys 0.8.4-main.a4bbb77 → 0.8.4-main.ae835ea

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.
@@ -82,82 +82,20 @@ var require_base32_decode = __commonJS({
82
82
  });
83
83
 
84
84
  // src/dxn.ts
85
- import { Schema as Schema3 } from "effect";
85
+ import * as Schema3 from "effect/Schema";
86
86
  import { devtoolsFormatter, inspectCustom } from "@dxos/debug";
87
87
  import { assertArgument, invariant as invariant2 } from "@dxos/invariant";
88
88
 
89
89
  // src/object-id.ts
90
- import { Schema } from "effect";
90
+ import * as Schema from "effect/Schema";
91
91
  import { monotonicFactory } from "ulidx";
92
- function _check_private_redeclaration(obj, privateCollection) {
93
- if (privateCollection.has(obj)) {
94
- throw new TypeError("Cannot initialize the same private elements twice on an object");
95
- }
96
- }
97
- function _class_apply_descriptor_get(receiver, descriptor) {
98
- if (descriptor.get) {
99
- return descriptor.get.call(receiver);
100
- }
101
- return descriptor.value;
102
- }
103
- function _class_apply_descriptor_set(receiver, descriptor, value) {
104
- if (descriptor.set) {
105
- descriptor.set.call(receiver, value);
106
- } else {
107
- if (!descriptor.writable) {
108
- throw new TypeError("attempted to set read only private field");
109
- }
110
- descriptor.value = value;
111
- }
112
- }
113
- function _class_check_private_static_field_descriptor(descriptor, action) {
114
- if (descriptor === void 0) {
115
- throw new TypeError("attempted to " + action + " private static field before its declaration");
116
- }
117
- }
118
- function _class_extract_field_descriptor(receiver, privateMap, action) {
119
- if (!privateMap.has(receiver)) {
120
- throw new TypeError("attempted to " + action + " private field on non-instance");
121
- }
122
- return privateMap.get(receiver);
123
- }
124
- function _class_private_field_get(receiver, privateMap) {
125
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
126
- return _class_apply_descriptor_get(receiver, descriptor);
127
- }
128
- function _class_private_field_init(obj, privateMap, value) {
129
- _check_private_redeclaration(obj, privateMap);
130
- privateMap.set(obj, value);
131
- }
132
- function _class_private_field_set(receiver, privateMap, value) {
133
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
134
- _class_apply_descriptor_set(receiver, descriptor, value);
135
- return value;
136
- }
137
- function _class_static_private_field_spec_get(receiver, classConstructor, descriptor) {
138
- _class_check_private_static_access(receiver, classConstructor);
139
- _class_check_private_static_field_descriptor(descriptor, "get");
140
- return _class_apply_descriptor_get(receiver, descriptor);
141
- }
142
- function _class_static_private_field_spec_set(receiver, classConstructor, descriptor, value) {
143
- _class_check_private_static_access(receiver, classConstructor);
144
- _class_check_private_static_field_descriptor(descriptor, "set");
145
- _class_apply_descriptor_set(receiver, descriptor, value);
146
- return value;
147
- }
148
- function _class_check_private_static_access(receiver, classConstructor) {
149
- if (receiver !== classConstructor) {
150
- throw new TypeError("Private static access of wrong provenance");
151
- }
152
- }
153
- var _class;
154
- var _factory;
155
- var _seedTime;
156
92
  var ObjectIdSchema = Schema.String.pipe(Schema.pattern(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i)).annotations({
157
93
  description: "A Universally Unique Lexicographically Sortable Identifier",
158
94
  pattern: "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
159
95
  });
160
- var ObjectId = (_class = class extends ObjectIdSchema {
96
+ var ObjectId = class extends ObjectIdSchema {
97
+ static #factory = monotonicFactory();
98
+ static #seedTime = void 0;
161
99
  static isValid(id) {
162
100
  try {
163
101
  Schema.decodeSync(ObjectId)(id);
@@ -167,65 +105,47 @@ var ObjectId = (_class = class extends ObjectIdSchema {
167
105
  }
168
106
  }
169
107
  static random() {
170
- return _class_static_private_field_spec_get(this, _class, _factory).call(_class, _class_static_private_field_spec_get(this, _class, _seedTime));
108
+ return this.#factory(this.#seedTime);
171
109
  }
172
110
  static dangerouslyDisableRandomness() {
173
- _class_static_private_field_spec_set(this, _class, _factory, monotonicFactory(makeTestPRNG()));
174
- _class_static_private_field_spec_set(this, _class, _seedTime, (/* @__PURE__ */ new Date("2025-01-01")).getTime());
175
- }
176
- }, _factory = {
177
- writable: true,
178
- value: monotonicFactory()
179
- }, _seedTime = {
180
- writable: true,
181
- value: void 0
182
- }, _class);
111
+ this.#factory = monotonicFactory(makeTestPRNG());
112
+ this.#seedTime = (/* @__PURE__ */ new Date("2025-01-01")).getTime();
113
+ }
114
+ };
183
115
  var makeTestPRNG = () => {
184
116
  const rng = new SimplePRNG();
185
117
  return () => {
186
118
  return rng.next();
187
119
  };
188
120
  };
189
- var _seed = /* @__PURE__ */ new WeakMap();
190
121
  var SimplePRNG = class _SimplePRNG {
122
+ #seed;
123
+ // LCG parameters (from Numerical Recipes)
124
+ static #a = 1664525;
125
+ static #c = 1013904223;
126
+ static #m = Math.pow(2, 32);
127
+ /**
128
+ * Creates a new PRNG instance.
129
+ * @param seed - Initial seed value. If not provided, uses 0.
130
+ */
131
+ constructor(seed = 0) {
132
+ this.#seed = seed;
133
+ }
191
134
  /**
192
135
  * Generates the next pseudo-random number in the range [0, 1).
193
136
  * @returns A pseudo-random number between 0 (inclusive) and 1 (exclusive).
194
137
  */
195
138
  next() {
196
- _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));
197
- return _class_private_field_get(this, _seed) / _class_static_private_field_spec_get(_SimplePRNG, _SimplePRNG, _m);
139
+ this.#seed = (_SimplePRNG.#a * this.#seed + _SimplePRNG.#c) % _SimplePRNG.#m;
140
+ return this.#seed / _SimplePRNG.#m;
198
141
  }
199
142
  /**
200
143
  * Resets the generator with a new seed.
201
144
  * @param seed - New seed value.
202
145
  */
203
146
  reset(seed) {
204
- _class_private_field_set(this, _seed, seed);
147
+ this.#seed = seed;
205
148
  }
206
- /**
207
- * Creates a new PRNG instance.
208
- * @param seed - Initial seed value. If not provided, uses 0.
209
- */
210
- constructor(seed = 0) {
211
- _class_private_field_init(this, _seed, {
212
- writable: true,
213
- value: void 0
214
- });
215
- _class_private_field_set(this, _seed, seed);
216
- }
217
- };
218
- var _a = {
219
- writable: true,
220
- value: 1664525
221
- };
222
- var _c = {
223
- writable: true,
224
- value: 1013904223
225
- };
226
- var _m = {
227
- writable: true,
228
- value: Math.pow(2, 32)
229
149
  };
230
150
 
231
151
  // src/space-id.ts
@@ -291,7 +211,7 @@ function base32Encode(data, variant, options) {
291
211
  }
292
212
 
293
213
  // src/space-id.ts
294
- import { Schema as Schema2 } from "effect";
214
+ import * as Schema2 from "effect/Schema";
295
215
  import { invariant } from "@dxos/invariant";
296
216
 
297
217
  // src/random-bytes.ts
@@ -303,117 +223,54 @@ var randomBytes = (length) => {
303
223
  };
304
224
 
305
225
  // src/space-id.ts
306
- function _define_property(obj, key, value) {
307
- if (key in obj) {
308
- Object.defineProperty(obj, key, {
309
- value,
310
- enumerable: true,
311
- configurable: true,
312
- writable: true
313
- });
314
- } else {
315
- obj[key] = value;
316
- }
317
- return obj;
318
- }
319
- var _Schema_String_pipe;
320
- var _class2;
321
226
  var __dxlog_file = "/__w/dxos/dxos/packages/common/keys/src/space-id.ts";
322
227
  var MULTIBASE_PREFIX = "B";
323
228
  var ENCODED_LENGTH = 33;
324
229
  var isValid = (value) => {
325
230
  return typeof value === "string" && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;
326
231
  };
327
- var SpaceId = (_class2 = class extends (_Schema_String_pipe = Schema2.String.pipe(Schema2.filter(isValid))) {
328
- }, _define_property(_class2, "byteLength", 20), _define_property(_class2, "encode", (value) => {
329
- invariant(value instanceof Uint8Array, "Invalid type", {
330
- F: __dxlog_file,
331
- L: 43,
332
- S: _class2,
333
- A: [
334
- "value instanceof Uint8Array",
335
- "'Invalid type'"
336
- ]
337
- });
338
- invariant(value.length === SpaceId.byteLength, "Invalid length", {
339
- F: __dxlog_file,
340
- L: 44,
341
- S: _class2,
342
- A: [
343
- "value.length === SpaceId.byteLength",
344
- "'Invalid length'"
345
- ]
346
- });
347
- return MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
348
- }), _define_property(_class2, "decode", (value) => {
349
- invariant(value.startsWith(MULTIBASE_PREFIX), "Invalid multibase32 encoding", {
350
- F: __dxlog_file,
351
- L: 49,
352
- S: _class2,
353
- A: [
354
- "value.startsWith(MULTIBASE_PREFIX)",
355
- "'Invalid multibase32 encoding'"
356
- ]
357
- });
358
- return new Uint8Array((0, import_base32_decode.default)(value.slice(1), "RFC4648"));
359
- }), _define_property(_class2, "isValid", isValid), _define_property(_class2, "random", () => {
360
- return SpaceId.encode(randomBytes(SpaceId.byteLength));
361
- }), _class2);
232
+ var SpaceId = class extends Schema2.String.pipe(Schema2.filter(isValid)) {
233
+ static byteLength = 20;
234
+ static encode = (value) => {
235
+ invariant(value instanceof Uint8Array, "Invalid type", {
236
+ F: __dxlog_file,
237
+ L: 43,
238
+ S: this,
239
+ A: [
240
+ "value instanceof Uint8Array",
241
+ "'Invalid type'"
242
+ ]
243
+ });
244
+ invariant(value.length === SpaceId.byteLength, "Invalid length", {
245
+ F: __dxlog_file,
246
+ L: 44,
247
+ S: this,
248
+ A: [
249
+ "value.length === SpaceId.byteLength",
250
+ "'Invalid length'"
251
+ ]
252
+ });
253
+ return MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
254
+ };
255
+ static decode = (value) => {
256
+ invariant(value.startsWith(MULTIBASE_PREFIX), "Invalid multibase32 encoding", {
257
+ F: __dxlog_file,
258
+ L: 49,
259
+ S: this,
260
+ A: [
261
+ "value.startsWith(MULTIBASE_PREFIX)",
262
+ "'Invalid multibase32 encoding'"
263
+ ]
264
+ });
265
+ return new Uint8Array((0, import_base32_decode.default)(value.slice(1), "RFC4648"));
266
+ };
267
+ static isValid = isValid;
268
+ static random = () => {
269
+ return SpaceId.encode(randomBytes(SpaceId.byteLength));
270
+ };
271
+ };
362
272
 
363
273
  // src/dxn.ts
364
- function _check_private_redeclaration2(obj, privateCollection) {
365
- if (privateCollection.has(obj)) {
366
- throw new TypeError("Cannot initialize the same private elements twice on an object");
367
- }
368
- }
369
- function _class_apply_descriptor_get2(receiver, descriptor) {
370
- if (descriptor.get) {
371
- return descriptor.get.call(receiver);
372
- }
373
- return descriptor.value;
374
- }
375
- function _class_apply_descriptor_set2(receiver, descriptor, value) {
376
- if (descriptor.set) {
377
- descriptor.set.call(receiver, value);
378
- } else {
379
- if (!descriptor.writable) {
380
- throw new TypeError("attempted to set read only private field");
381
- }
382
- descriptor.value = value;
383
- }
384
- }
385
- function _class_extract_field_descriptor2(receiver, privateMap, action) {
386
- if (!privateMap.has(receiver)) {
387
- throw new TypeError("attempted to " + action + " private field on non-instance");
388
- }
389
- return privateMap.get(receiver);
390
- }
391
- function _class_private_field_get2(receiver, privateMap) {
392
- var descriptor = _class_extract_field_descriptor2(receiver, privateMap, "get");
393
- return _class_apply_descriptor_get2(receiver, descriptor);
394
- }
395
- function _class_private_field_init2(obj, privateMap, value) {
396
- _check_private_redeclaration2(obj, privateMap);
397
- privateMap.set(obj, value);
398
- }
399
- function _class_private_field_set2(receiver, privateMap, value) {
400
- var descriptor = _class_extract_field_descriptor2(receiver, privateMap, "set");
401
- _class_apply_descriptor_set2(receiver, descriptor, value);
402
- return value;
403
- }
404
- function _define_property2(obj, key, value) {
405
- if (key in obj) {
406
- Object.defineProperty(obj, key, {
407
- value,
408
- enumerable: true,
409
- configurable: true,
410
- writable: true
411
- });
412
- } else {
413
- obj[key] = value;
414
- }
415
- return obj;
416
- }
417
274
  var __dxlog_file2 = "/__w/dxos/dxos/packages/common/keys/src/dxn.ts";
418
275
  var LOCAL_SPACE_TAG = "@";
419
276
  var DXN_ECHO_REGEXP = /@(dxn:[a-zA-Z0-p:@]+)/;
@@ -421,15 +278,49 @@ var QueueSubspaceTags = Object.freeze({
421
278
  DATA: "data",
422
279
  TRACE: "trace"
423
280
  });
424
- var _kind = /* @__PURE__ */ new WeakMap();
425
- var _parts = /* @__PURE__ */ new WeakMap();
426
- var _inspectCustom = inspectCustom;
427
- var _devtoolsFormatter = devtoolsFormatter;
428
281
  var DXN = class _DXN {
282
+ // TODO(burdon): Rename to DXN (i.e., DXN.DXN).
283
+ // TODO(dmaretskyi): Should this be a transformation into the DXN type?
284
+ static Schema = Schema3.NonEmptyString.pipe(
285
+ Schema3.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),
286
+ // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.
287
+ // FormatAnnotation.set(FormatEnum.DXN),
288
+ Schema3.annotations({
289
+ title: "DXN",
290
+ description: "DXN URI",
291
+ examples: [
292
+ "dxn:type:example.com/type/MyType",
293
+ "dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6"
294
+ ]
295
+ })
296
+ );
429
297
  static hash(dxn) {
430
298
  return dxn.toString();
431
299
  }
432
300
  /**
301
+ * Kind constants.
302
+ */
303
+ static kind = Object.freeze({
304
+ /**
305
+ * dxn:type:<type_name>[:<version>]
306
+ */
307
+ TYPE: "type",
308
+ /**
309
+ * dxn:echo:<space_id>:<echo_id>
310
+ * dxn:echo:@:<echo_id>
311
+ */
312
+ // TODO(burdon): Rename to OBJECT? (BREAKING CHANGE to update "echo").
313
+ // TODO(burdon): Add separate Kind for space?
314
+ ECHO: "echo",
315
+ /**
316
+ * The subspace tag enables us to partition queues by usage within the context of a space.
317
+ * dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
318
+ * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
319
+ * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
320
+ */
321
+ QUEUE: "queue"
322
+ });
323
+ /**
433
324
  * Exactly equals.
434
325
  */
435
326
  static equals(a, b) {
@@ -519,8 +410,28 @@ var DXN = class _DXN {
519
410
  ] : []
520
411
  ]);
521
412
  }
413
+ #kind;
414
+ #parts;
415
+ constructor(kind, parts) {
416
+ assertArgument(parts.length > 0, "parts", `Invalid DXN: ${parts}`);
417
+ assertArgument(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), "parts", `Invalid DXN: ${parts}`);
418
+ switch (kind) {
419
+ case _DXN.kind.TYPE:
420
+ if (parts.length > 2) {
421
+ throw new Error("Invalid DXN.kind.TYPE");
422
+ }
423
+ break;
424
+ case _DXN.kind.ECHO:
425
+ if (parts.length !== 2) {
426
+ throw new Error("Invalid DXN.kind.ECHO");
427
+ }
428
+ break;
429
+ }
430
+ this.#kind = kind;
431
+ this.#parts = parts;
432
+ }
522
433
  toString() {
523
- return `dxn:${_class_private_field_get2(this, _kind)}:${_class_private_field_get2(this, _parts).join(":")}`;
434
+ return `dxn:${this.#kind}:${this.#parts.join(":")}`;
524
435
  }
525
436
  toJSON() {
526
437
  return this.toString();
@@ -528,13 +439,13 @@ var DXN = class _DXN {
528
439
  /**
529
440
  * Used by Node.js to get textual representation of this object when it's printed with a `console.log` statement.
530
441
  */
531
- [_inspectCustom](depth, options, inspectFn) {
442
+ [inspectCustom](depth, options, inspectFn) {
532
443
  const printControlCode = (code) => {
533
444
  return `\x1B[${code}m`;
534
445
  };
535
446
  return printControlCode(inspectFn.colors.blueBright[0]) + this.toString() + printControlCode(inspectFn.colors.reset[0]);
536
447
  }
537
- get [_devtoolsFormatter]() {
448
+ get [devtoolsFormatter]() {
538
449
  return {
539
450
  header: () => {
540
451
  return [
@@ -548,14 +459,14 @@ var DXN = class _DXN {
548
459
  };
549
460
  }
550
461
  get kind() {
551
- return _class_private_field_get2(this, _kind);
462
+ return this.#kind;
552
463
  }
553
464
  get parts() {
554
- return _class_private_field_get2(this, _parts);
465
+ return this.#parts;
555
466
  }
556
467
  // TODO(burdon): Should getters fail?
557
468
  get typename() {
558
- invariant2(_class_private_field_get2(this, _kind) === _DXN.kind.TYPE, void 0, {
469
+ invariant2(this.#kind === _DXN.kind.TYPE, void 0, {
559
470
  F: __dxlog_file2,
560
471
  L: 250,
561
472
  S: this,
@@ -564,22 +475,22 @@ var DXN = class _DXN {
564
475
  ""
565
476
  ]
566
477
  });
567
- return _class_private_field_get2(this, _parts)[0];
478
+ return this.#parts[0];
568
479
  }
569
480
  equals(other) {
570
481
  return _DXN.equals(this, other);
571
482
  }
572
483
  hasTypenameOf(typename) {
573
- 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;
484
+ return this.#kind === _DXN.kind.TYPE && this.#parts.length === 1 && this.#parts[0] === typename;
574
485
  }
575
486
  isLocalObjectId() {
576
- 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;
487
+ return this.#kind === _DXN.kind.ECHO && this.#parts[0] === LOCAL_SPACE_TAG && this.#parts.length === 2;
577
488
  }
578
489
  asTypeDXN() {
579
490
  if (this.kind !== _DXN.kind.TYPE) {
580
491
  return void 0;
581
492
  }
582
- const [type, version] = _class_private_field_get2(this, _parts);
493
+ const [type, version] = this.#parts;
583
494
  return {
584
495
  // TODO(wittjosiah): Should be `typename` for consistency.
585
496
  type,
@@ -590,7 +501,7 @@ var DXN = class _DXN {
590
501
  if (this.kind !== _DXN.kind.ECHO) {
591
502
  return void 0;
592
503
  }
593
- const [spaceId, echoId] = _class_private_field_get2(this, _parts);
504
+ const [spaceId, echoId] = this.#parts;
594
505
  return {
595
506
  spaceId: spaceId === LOCAL_SPACE_TAG ? void 0 : spaceId,
596
507
  // TODO(burdon): objectId.
@@ -601,7 +512,7 @@ var DXN = class _DXN {
601
512
  if (this.kind !== _DXN.kind.QUEUE) {
602
513
  return void 0;
603
514
  }
604
- const [subspaceTag, spaceId, queueId, objectId] = _class_private_field_get2(this, _parts);
515
+ const [subspaceTag, spaceId, queueId, objectId] = this.#parts;
605
516
  if (typeof queueId !== "string") {
606
517
  return void 0;
607
518
  }
@@ -616,71 +527,12 @@ var DXN = class _DXN {
616
527
  * Produces a new DXN with the given parts appended.
617
528
  */
618
529
  extend(parts) {
619
- return new _DXN(_class_private_field_get2(this, _kind), [
620
- ..._class_private_field_get2(this, _parts),
530
+ return new _DXN(this.#kind, [
531
+ ...this.#parts,
621
532
  ...parts
622
533
  ]);
623
534
  }
624
- constructor(kind, parts) {
625
- _class_private_field_init2(this, _kind, {
626
- writable: true,
627
- value: void 0
628
- });
629
- _class_private_field_init2(this, _parts, {
630
- writable: true,
631
- value: void 0
632
- });
633
- assertArgument(parts.length > 0, "parts", `Invalid DXN: ${parts}`);
634
- assertArgument(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), "parts", `Invalid DXN: ${parts}`);
635
- switch (kind) {
636
- case _DXN.kind.TYPE:
637
- if (parts.length > 2) {
638
- throw new Error("Invalid DXN.kind.TYPE");
639
- }
640
- break;
641
- case _DXN.kind.ECHO:
642
- if (parts.length !== 2) {
643
- throw new Error("Invalid DXN.kind.ECHO");
644
- }
645
- break;
646
- }
647
- _class_private_field_set2(this, _kind, kind);
648
- _class_private_field_set2(this, _parts, parts);
649
- }
650
535
  };
651
- _define_property2(DXN, "Schema", Schema3.NonEmptyString.pipe(
652
- Schema3.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),
653
- // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.
654
- // FormatAnnotation.set(FormatEnum.DXN),
655
- Schema3.annotations({
656
- title: "DXN",
657
- description: "DXN URI",
658
- examples: [
659
- "dxn:type:example.com/type/MyType",
660
- "dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6"
661
- ]
662
- })
663
- ));
664
- _define_property2(DXN, "kind", Object.freeze({
665
- /**
666
- * dxn:type:<type_name>[:<version>]
667
- */
668
- TYPE: "type",
669
- /**
670
- * dxn:echo:<space_id>:<echo_id>
671
- * dxn:echo:@:<echo_id>
672
- */
673
- // TODO(burdon): Rename to OBJECT? (BREAKING CHANGE to update "echo").
674
- // TODO(burdon): Add separate Kind for space?
675
- ECHO: "echo",
676
- /**
677
- * The subspace tag enables us to partition queues by usage within the context of a space.
678
- * dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
679
- * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
680
- * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
681
- */
682
- QUEUE: "queue"
683
- }));
684
536
 
685
537
  // src/identity-did.ts
686
538
  var import_base32_decode2 = __toESM(require_base32_decode(), 1);
@@ -736,27 +588,13 @@ var ENCODED_LENGTH2 = 42;
736
588
  var import_base32_decode3 = __toESM(require_base32_decode(), 1);
737
589
  import { devtoolsFormatter as devtoolsFormatter2, equalsSymbol, inspectCustom as inspectCustom2, truncateKey } from "@dxos/debug";
738
590
  import { invariant as invariant4 } from "@dxos/invariant";
739
- function _define_property3(obj, key, value) {
740
- if (key in obj) {
741
- Object.defineProperty(obj, key, {
742
- value,
743
- enumerable: true,
744
- configurable: true,
745
- writable: true
746
- });
747
- } else {
748
- obj[key] = value;
749
- }
750
- return obj;
751
- }
752
591
  var __dxlog_file4 = "/__w/dxos/dxos/packages/common/keys/src/public-key.ts";
753
592
  var PUBLIC_KEY_LENGTH = 32;
754
593
  var SECRET_KEY_LENGTH = 64;
755
594
  var isLikeArrayBuffer = (value) => typeof value === "object" && value !== null && Object.getPrototypeOf(value).constructor.name === "ArrayBuffer";
756
- var _inspectCustom2 = inspectCustom2;
757
- var _devtoolsFormatter2 = devtoolsFormatter2;
758
- var _equalsSymbol = equalsSymbol;
759
595
  var PublicKey = class _PublicKey {
596
+ _value;
597
+ static ZERO = _PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH));
760
598
  /**
761
599
  * Creates new instance of PublicKey automatically determining the input format.
762
600
  * @param source A Buffer, or Uint8Array, or hex encoded string, or something with an `asUint8Array` method on it
@@ -908,6 +746,12 @@ var PublicKey = class _PublicKey {
908
746
  });
909
747
  return new _PublicKey(new Uint8Array((0, import_base32_decode3.default)(encoded.slice(1), "RFC4648")));
910
748
  }
749
+ constructor(_value) {
750
+ this._value = _value;
751
+ if (!(_value instanceof Uint8Array)) {
752
+ throw new TypeError(`Expected Uint8Array, got: ${_value}`);
753
+ }
754
+ }
911
755
  toString() {
912
756
  return this.toHex();
913
757
  }
@@ -941,7 +785,7 @@ var PublicKey = class _PublicKey {
941
785
  /**
942
786
  * Used by Node.js to get textual representation of this object when it's printed with a `console.log` statement.
943
787
  */
944
- [_inspectCustom2](depth, options, inspectFn) {
788
+ [inspectCustom2](depth, options, inspectFn) {
945
789
  if (!options.colors || typeof process.stdout.hasColors !== "function" || !process.stdout.hasColors()) {
946
790
  return `<PublicKey ${this.truncate()}>`;
947
791
  }
@@ -966,7 +810,7 @@ var PublicKey = class _PublicKey {
966
810
  const color = colors[this.getInsecureHash(colors.length)];
967
811
  return `PublicKey(${printControlCode(inspectFn.colors[color][0])}${this.truncate()}${printControlCode(inspectFn.colors.reset[0])})`;
968
812
  }
969
- get [_devtoolsFormatter2]() {
813
+ get [devtoolsFormatter2]() {
970
814
  return {
971
815
  header: () => {
972
816
  const colors = [
@@ -1019,25 +863,17 @@ var PublicKey = class _PublicKey {
1019
863
  }
1020
864
  let equal = true;
1021
865
  for (let i = 0; i < this._value.length; i++) {
1022
- equal && (equal = this._value[i] === otherConverted._value[i]);
866
+ equal &&= this._value[i] === otherConverted._value[i];
1023
867
  }
1024
868
  return equal;
1025
869
  }
1026
- [_equalsSymbol](other) {
870
+ [equalsSymbol](other) {
1027
871
  if (!_PublicKey.isPublicKey(other)) {
1028
872
  return false;
1029
873
  }
1030
874
  return this.equals(other);
1031
875
  }
1032
- constructor(_value) {
1033
- _define_property3(this, "_value", void 0);
1034
- this._value = _value;
1035
- if (!(_value instanceof Uint8Array)) {
1036
- throw new TypeError(`Expected Uint8Array, got: ${_value}`);
1037
- }
1038
- }
1039
876
  };
1040
- _define_property3(PublicKey, "ZERO", PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH)));
1041
877
  export {
1042
878
  DXN,
1043
879
  DXN_ECHO_REGEXP,