@dxos/keys 0.8.4-main.c1de068 → 0.8.4-main.dedc0f3

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.
@@ -90,7 +90,7 @@ import { assertArgument, invariant as invariant2 } from "@dxos/invariant";
90
90
  import { Schema } from "effect";
91
91
  import { ulid } from "ulidx";
92
92
  var ObjectIdSchema = Schema.String.pipe(Schema.pattern(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i)).annotations({
93
- description: "a Universally Unique Lexicographically Sortable Identifier",
93
+ description: "A Universally Unique Lexicographically Sortable Identifier",
94
94
  pattern: "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
95
95
  });
96
96
  var ObjectId = class extends ObjectIdSchema {
@@ -98,7 +98,7 @@ var ObjectId = class extends ObjectIdSchema {
98
98
  try {
99
99
  Schema.decodeSync(ObjectId)(id);
100
100
  return true;
101
- } catch (err) {
101
+ } catch {
102
102
  return false;
103
103
  }
104
104
  }
@@ -182,121 +182,143 @@ var randomBytes = (length) => {
182
182
  };
183
183
 
184
184
  // src/space-id.ts
185
+ function _define_property(obj, key, value) {
186
+ if (key in obj) {
187
+ Object.defineProperty(obj, key, {
188
+ value,
189
+ enumerable: true,
190
+ configurable: true,
191
+ writable: true
192
+ });
193
+ } else {
194
+ obj[key] = value;
195
+ }
196
+ return obj;
197
+ }
198
+ var _Schema_String_pipe;
199
+ var _class;
185
200
  var __dxlog_file = "/__w/dxos/dxos/packages/common/keys/src/space-id.ts";
186
201
  var MULTIBASE_PREFIX = "B";
187
202
  var ENCODED_LENGTH = 33;
188
203
  var isValid = (value) => {
189
204
  return typeof value === "string" && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;
190
205
  };
191
- var SpaceId = class extends Schema2.String.pipe(Schema2.filter(isValid)) {
192
- static {
193
- this.byteLength = 20;
194
- }
195
- static {
196
- this.encode = (value) => {
197
- invariant(value instanceof Uint8Array, "Invalid type", {
198
- F: __dxlog_file,
199
- L: 43,
200
- S: this,
201
- A: [
202
- "value instanceof Uint8Array",
203
- "'Invalid type'"
204
- ]
205
- });
206
- invariant(value.length === SpaceId.byteLength, "Invalid length", {
207
- F: __dxlog_file,
208
- L: 44,
209
- S: this,
210
- A: [
211
- "value.length === SpaceId.byteLength",
212
- "'Invalid length'"
213
- ]
214
- });
215
- return MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
216
- };
206
+ var SpaceId = (_class = class extends (_Schema_String_pipe = Schema2.String.pipe(Schema2.filter(isValid))) {
207
+ }, _define_property(_class, "byteLength", 20), _define_property(_class, "encode", (value) => {
208
+ invariant(value instanceof Uint8Array, "Invalid type", {
209
+ F: __dxlog_file,
210
+ L: 43,
211
+ S: _class,
212
+ A: [
213
+ "value instanceof Uint8Array",
214
+ "'Invalid type'"
215
+ ]
216
+ });
217
+ invariant(value.length === SpaceId.byteLength, "Invalid length", {
218
+ F: __dxlog_file,
219
+ L: 44,
220
+ S: _class,
221
+ A: [
222
+ "value.length === SpaceId.byteLength",
223
+ "'Invalid length'"
224
+ ]
225
+ });
226
+ return MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
227
+ }), _define_property(_class, "decode", (value) => {
228
+ invariant(value.startsWith(MULTIBASE_PREFIX), "Invalid multibase32 encoding", {
229
+ F: __dxlog_file,
230
+ L: 49,
231
+ S: _class,
232
+ A: [
233
+ "value.startsWith(MULTIBASE_PREFIX)",
234
+ "'Invalid multibase32 encoding'"
235
+ ]
236
+ });
237
+ return new Uint8Array((0, import_base32_decode.default)(value.slice(1), "RFC4648"));
238
+ }), _define_property(_class, "isValid", isValid), _define_property(_class, "random", () => {
239
+ return SpaceId.encode(randomBytes(SpaceId.byteLength));
240
+ }), _class);
241
+
242
+ // src/dxn.ts
243
+ function _check_private_redeclaration(obj, privateCollection) {
244
+ if (privateCollection.has(obj)) {
245
+ throw new TypeError("Cannot initialize the same private elements twice on an object");
217
246
  }
218
- static {
219
- this.decode = (value) => {
220
- invariant(value.startsWith(MULTIBASE_PREFIX), "Invalid multibase32 encoding", {
221
- F: __dxlog_file,
222
- L: 49,
223
- S: this,
224
- A: [
225
- "value.startsWith(MULTIBASE_PREFIX)",
226
- "'Invalid multibase32 encoding'"
227
- ]
228
- });
229
- return new Uint8Array((0, import_base32_decode.default)(value.slice(1), "RFC4648"));
230
- };
247
+ }
248
+ function _class_apply_descriptor_get(receiver, descriptor) {
249
+ if (descriptor.get) {
250
+ return descriptor.get.call(receiver);
231
251
  }
232
- static {
233
- this.isValid = isValid;
252
+ return descriptor.value;
253
+ }
254
+ function _class_apply_descriptor_set(receiver, descriptor, value) {
255
+ if (descriptor.set) {
256
+ descriptor.set.call(receiver, value);
257
+ } else {
258
+ if (!descriptor.writable) {
259
+ throw new TypeError("attempted to set read only private field");
260
+ }
261
+ descriptor.value = value;
234
262
  }
235
- static {
236
- this.random = () => {
237
- return SpaceId.encode(randomBytes(SpaceId.byteLength));
238
- };
263
+ }
264
+ function _class_extract_field_descriptor(receiver, privateMap, action) {
265
+ if (!privateMap.has(receiver)) {
266
+ throw new TypeError("attempted to " + action + " private field on non-instance");
239
267
  }
240
- };
241
-
242
- // src/dxn.ts
268
+ return privateMap.get(receiver);
269
+ }
270
+ function _class_private_field_get(receiver, privateMap) {
271
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
272
+ return _class_apply_descriptor_get(receiver, descriptor);
273
+ }
274
+ function _class_private_field_init(obj, privateMap, value) {
275
+ _check_private_redeclaration(obj, privateMap);
276
+ privateMap.set(obj, value);
277
+ }
278
+ function _class_private_field_set(receiver, privateMap, value) {
279
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
280
+ _class_apply_descriptor_set(receiver, descriptor, value);
281
+ return value;
282
+ }
283
+ function _define_property2(obj, key, value) {
284
+ if (key in obj) {
285
+ Object.defineProperty(obj, key, {
286
+ value,
287
+ enumerable: true,
288
+ configurable: true,
289
+ writable: true
290
+ });
291
+ } else {
292
+ obj[key] = value;
293
+ }
294
+ return obj;
295
+ }
243
296
  var __dxlog_file2 = "/__w/dxos/dxos/packages/common/keys/src/dxn.ts";
244
297
  var LOCAL_SPACE_TAG = "@";
298
+ var DXN_ECHO_REGEXP = /@(dxn:[a-zA-Z0-p:@]+)/;
245
299
  var QueueSubspaceTags = Object.freeze({
246
300
  DATA: "data",
247
301
  TRACE: "trace"
248
302
  });
303
+ var _kind = /* @__PURE__ */ new WeakMap();
304
+ var _parts = /* @__PURE__ */ new WeakMap();
305
+ var _inspectCustom = inspectCustom;
306
+ var _devtoolsFormatter = devtoolsFormatter;
249
307
  var DXN = class _DXN {
250
- static {
251
- // TODO(dmaretskyi): Should this be a transformation into the DXN type?
252
- this.Schema = Schema3.NonEmptyString.pipe(
253
- Schema3.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),
254
- // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.
255
- // FormatAnnotation.set(FormatEnum.DXN),
256
- Schema3.annotations({
257
- title: "DXN",
258
- description: "DXN URI",
259
- examples: [
260
- "dxn:type:example.com/type/MyType",
261
- "dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6"
262
- ]
263
- })
264
- );
265
- }
266
308
  static hash(dxn) {
267
309
  return dxn.toString();
268
310
  }
269
- static {
270
- /**
271
- * Kind constants.
272
- */
273
- this.kind = Object.freeze({
274
- /**
275
- * dxn:type:<type name>[:<version>]
276
- */
277
- TYPE: "type",
278
- /**
279
- * dxn:echo:<space id>:<echo id>
280
- * dxn:echo:@:<echo id>
281
- */
282
- // TODO(burdon): Rename to OBJECT? (BREAKING CHANGE).
283
- // TODO(burdon): Add separate Kind for space.
284
- ECHO: "echo",
285
- /**
286
- * The subspace tag enables us to partition queues by usage within the context of a space.
287
- * dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
288
- * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
289
- * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
290
- */
291
- QUEUE: "queue"
292
- });
293
- }
294
- get kind() {
295
- return this.#kind;
296
- }
311
+ /**
312
+ * Exactly equals.
313
+ */
297
314
  static equals(a, b) {
298
315
  return a.kind === b.kind && a.parts.length === b.parts.length && a.parts.every((part, i) => part === b.parts[i]);
299
316
  }
317
+ static equalsEchoId(a, b) {
318
+ const a1 = a.asEchoDXN();
319
+ const b1 = b.asEchoDXN();
320
+ return !!a1 && !!b1 && a1.echoId === b1.echoId;
321
+ }
300
322
  // TODO(burdon): Rename isValid.
301
323
  static isDXNString(dxn) {
302
324
  return dxn.startsWith("dxn:");
@@ -320,7 +342,7 @@ var DXN = class _DXN {
320
342
  static tryParse(dxn) {
321
343
  try {
322
344
  return _DXN.parse(dxn);
323
- } catch (error) {
345
+ } catch {
324
346
  return void 0;
325
347
  }
326
348
  }
@@ -343,43 +365,30 @@ var DXN = class _DXN {
343
365
  ]);
344
366
  }
345
367
  /**
368
+ * @example `dxn:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6`
369
+ */
370
+ static fromSpaceAndObjectId(spaceId, objectId) {
371
+ assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);
372
+ assertArgument(ObjectId.isValid(objectId), "objectId", `Invalid object ID: ${objectId}`);
373
+ return new _DXN(_DXN.kind.ECHO, [
374
+ spaceId,
375
+ objectId
376
+ ]);
377
+ }
378
+ /**
346
379
  * @example `dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6`
347
380
  */
348
381
  static fromLocalObjectId(id) {
349
- assertArgument(ObjectId.isValid(id), `Invalid object ID: ${id}`);
382
+ assertArgument(ObjectId.isValid(id), "id", `Invalid object ID: ${id}`);
350
383
  return new _DXN(_DXN.kind.ECHO, [
351
384
  LOCAL_SPACE_TAG,
352
385
  id
353
386
  ]);
354
387
  }
355
388
  static fromQueue(subspaceTag, spaceId, queueId, objectId) {
356
- invariant2(SpaceId.isValid(spaceId), void 0, {
357
- F: __dxlog_file2,
358
- L: 151,
359
- S: this,
360
- A: [
361
- "SpaceId.isValid(spaceId)",
362
- ""
363
- ]
364
- });
365
- invariant2(ObjectId.isValid(queueId), void 0, {
366
- F: __dxlog_file2,
367
- L: 152,
368
- S: this,
369
- A: [
370
- "ObjectId.isValid(queueId)",
371
- ""
372
- ]
373
- });
374
- invariant2(!objectId || ObjectId.isValid(objectId), void 0, {
375
- F: __dxlog_file2,
376
- L: 153,
377
- S: this,
378
- A: [
379
- "!objectId || ObjectId.isValid(objectId)",
380
- ""
381
- ]
382
- });
389
+ assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);
390
+ assertArgument(ObjectId.isValid(queueId), "queueId", `Invalid queue ID: ${queueId}`);
391
+ assertArgument(!objectId || ObjectId.isValid(objectId), "objectId", `Invalid object ID: ${objectId}`);
383
392
  return new _DXN(_DXN.kind.QUEUE, [
384
393
  subspaceTag,
385
394
  spaceId,
@@ -389,44 +398,8 @@ var DXN = class _DXN {
389
398
  ] : []
390
399
  ]);
391
400
  }
392
- #kind;
393
- #parts;
394
- constructor(kind, parts) {
395
- invariant2(parts.length > 0, void 0, {
396
- F: __dxlog_file2,
397
- L: 162,
398
- S: this,
399
- A: [
400
- "parts.length > 0",
401
- ""
402
- ]
403
- });
404
- invariant2(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), void 0, {
405
- F: __dxlog_file2,
406
- L: 163,
407
- S: this,
408
- A: [
409
- "parts.every((part) => typeof part === 'string' && part.length > 0 && part.indexOf(':') === -1)",
410
- ""
411
- ]
412
- });
413
- switch (kind) {
414
- case _DXN.kind.TYPE:
415
- if (parts.length > 2) {
416
- throw new Error('Invalid "type" DXN');
417
- }
418
- break;
419
- case _DXN.kind.ECHO:
420
- if (parts.length !== 2) {
421
- throw new Error('Invalid "echo" DXN');
422
- }
423
- break;
424
- }
425
- this.#kind = kind;
426
- this.#parts = parts;
427
- }
428
401
  toString() {
429
- return `dxn:${this.#kind}:${this.#parts.join(":")}`;
402
+ return `dxn:${_class_private_field_get(this, _kind)}:${_class_private_field_get(this, _parts).join(":")}`;
430
403
  }
431
404
  toJSON() {
432
405
  return this.toString();
@@ -434,13 +407,13 @@ var DXN = class _DXN {
434
407
  /**
435
408
  * Used by Node.js to get textual representation of this object when it's printed with a `console.log` statement.
436
409
  */
437
- [inspectCustom](depth, options, inspectFn) {
410
+ [_inspectCustom](depth, options, inspectFn) {
438
411
  const printControlCode = (code) => {
439
412
  return `\x1B[${code}m`;
440
413
  };
441
414
  return printControlCode(inspectFn.colors.blueBright[0]) + this.toString() + printControlCode(inspectFn.colors.reset[0]);
442
415
  }
443
- get [devtoolsFormatter]() {
416
+ get [_devtoolsFormatter]() {
444
417
  return {
445
418
  header: () => {
446
419
  return [
@@ -453,33 +426,39 @@ var DXN = class _DXN {
453
426
  }
454
427
  };
455
428
  }
429
+ get kind() {
430
+ return _class_private_field_get(this, _kind);
431
+ }
456
432
  get parts() {
457
- return this.#parts;
433
+ return _class_private_field_get(this, _parts);
458
434
  }
459
435
  // TODO(burdon): Should getters fail?
460
436
  get typename() {
461
- invariant2(this.#kind === _DXN.kind.TYPE, void 0, {
437
+ invariant2(_class_private_field_get(this, _kind) === _DXN.kind.TYPE, void 0, {
462
438
  F: __dxlog_file2,
463
- L: 218,
439
+ L: 250,
464
440
  S: this,
465
441
  A: [
466
442
  "this.#kind === DXN.kind.TYPE",
467
443
  ""
468
444
  ]
469
445
  });
470
- return this.#parts[0];
446
+ return _class_private_field_get(this, _parts)[0];
447
+ }
448
+ equals(other) {
449
+ return _DXN.equals(this, other);
471
450
  }
472
451
  hasTypenameOf(typename) {
473
- return this.#kind === _DXN.kind.TYPE && this.#parts.length === 1 && this.#parts[0] === typename;
452
+ return _class_private_field_get(this, _kind) === _DXN.kind.TYPE && _class_private_field_get(this, _parts).length === 1 && _class_private_field_get(this, _parts)[0] === typename;
474
453
  }
475
454
  isLocalObjectId() {
476
- return this.#kind === _DXN.kind.ECHO && this.#parts[0] === LOCAL_SPACE_TAG && this.#parts.length === 2;
455
+ return _class_private_field_get(this, _kind) === _DXN.kind.ECHO && _class_private_field_get(this, _parts)[0] === LOCAL_SPACE_TAG && _class_private_field_get(this, _parts).length === 2;
477
456
  }
478
457
  asTypeDXN() {
479
458
  if (this.kind !== _DXN.kind.TYPE) {
480
459
  return void 0;
481
460
  }
482
- const [type, version] = this.#parts;
461
+ const [type, version] = _class_private_field_get(this, _parts);
483
462
  return {
484
463
  // TODO(wittjosiah): Should be `typename` for consistency.
485
464
  type,
@@ -490,9 +469,10 @@ var DXN = class _DXN {
490
469
  if (this.kind !== _DXN.kind.ECHO) {
491
470
  return void 0;
492
471
  }
493
- const [spaceId, echoId] = this.#parts;
472
+ const [spaceId, echoId] = _class_private_field_get(this, _parts);
494
473
  return {
495
474
  spaceId: spaceId === LOCAL_SPACE_TAG ? void 0 : spaceId,
475
+ // TODO(burdon): objectId.
496
476
  echoId
497
477
  };
498
478
  }
@@ -500,7 +480,7 @@ var DXN = class _DXN {
500
480
  if (this.kind !== _DXN.kind.QUEUE) {
501
481
  return void 0;
502
482
  }
503
- const [subspaceTag, spaceId, queueId, objectId] = this.#parts;
483
+ const [subspaceTag, spaceId, queueId, objectId] = _class_private_field_get(this, _parts);
504
484
  if (typeof queueId !== "string") {
505
485
  return void 0;
506
486
  }
@@ -511,7 +491,75 @@ var DXN = class _DXN {
511
491
  objectId
512
492
  };
513
493
  }
494
+ /**
495
+ * Produces a new DXN with the given parts appended.
496
+ */
497
+ extend(parts) {
498
+ return new _DXN(_class_private_field_get(this, _kind), [
499
+ ..._class_private_field_get(this, _parts),
500
+ ...parts
501
+ ]);
502
+ }
503
+ constructor(kind, parts) {
504
+ _class_private_field_init(this, _kind, {
505
+ writable: true,
506
+ value: void 0
507
+ });
508
+ _class_private_field_init(this, _parts, {
509
+ writable: true,
510
+ value: void 0
511
+ });
512
+ assertArgument(parts.length > 0, "parts", `Invalid DXN: ${parts}`);
513
+ assertArgument(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), "parts", `Invalid DXN: ${parts}`);
514
+ switch (kind) {
515
+ case _DXN.kind.TYPE:
516
+ if (parts.length > 2) {
517
+ throw new Error("Invalid DXN.kind.TYPE");
518
+ }
519
+ break;
520
+ case _DXN.kind.ECHO:
521
+ if (parts.length !== 2) {
522
+ throw new Error("Invalid DXN.kind.ECHO");
523
+ }
524
+ break;
525
+ }
526
+ _class_private_field_set(this, _kind, kind);
527
+ _class_private_field_set(this, _parts, parts);
528
+ }
514
529
  };
530
+ _define_property2(DXN, "Schema", Schema3.NonEmptyString.pipe(
531
+ Schema3.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),
532
+ // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.
533
+ // FormatAnnotation.set(FormatEnum.DXN),
534
+ Schema3.annotations({
535
+ title: "DXN",
536
+ description: "DXN URI",
537
+ examples: [
538
+ "dxn:type:example.com/type/MyType",
539
+ "dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6"
540
+ ]
541
+ })
542
+ ));
543
+ _define_property2(DXN, "kind", Object.freeze({
544
+ /**
545
+ * dxn:type:<type_name>[:<version>]
546
+ */
547
+ TYPE: "type",
548
+ /**
549
+ * dxn:echo:<space_id>:<echo_id>
550
+ * dxn:echo:@:<echo_id>
551
+ */
552
+ // TODO(burdon): Rename to OBJECT? (BREAKING CHANGE to update "echo").
553
+ // TODO(burdon): Add separate Kind for space?
554
+ ECHO: "echo",
555
+ /**
556
+ * The subspace tag enables us to partition queues by usage within the context of a space.
557
+ * dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
558
+ * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
559
+ * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
560
+ */
561
+ QUEUE: "queue"
562
+ }));
515
563
 
516
564
  // src/identity-did.ts
517
565
  var import_base32_decode2 = __toESM(require_base32_decode(), 1);
@@ -567,14 +615,27 @@ var ENCODED_LENGTH2 = 42;
567
615
  var import_base32_decode3 = __toESM(require_base32_decode(), 1);
568
616
  import { devtoolsFormatter as devtoolsFormatter2, equalsSymbol, inspectCustom as inspectCustom2, truncateKey } from "@dxos/debug";
569
617
  import { invariant as invariant4 } from "@dxos/invariant";
618
+ function _define_property3(obj, key, value) {
619
+ if (key in obj) {
620
+ Object.defineProperty(obj, key, {
621
+ value,
622
+ enumerable: true,
623
+ configurable: true,
624
+ writable: true
625
+ });
626
+ } else {
627
+ obj[key] = value;
628
+ }
629
+ return obj;
630
+ }
570
631
  var __dxlog_file4 = "/__w/dxos/dxos/packages/common/keys/src/public-key.ts";
571
632
  var PUBLIC_KEY_LENGTH = 32;
572
633
  var SECRET_KEY_LENGTH = 64;
573
634
  var isLikeArrayBuffer = (value) => typeof value === "object" && value !== null && Object.getPrototypeOf(value).constructor.name === "ArrayBuffer";
635
+ var _inspectCustom2 = inspectCustom2;
636
+ var _devtoolsFormatter2 = devtoolsFormatter2;
637
+ var _equalsSymbol = equalsSymbol;
574
638
  var PublicKey = class _PublicKey {
575
- static {
576
- this.ZERO = _PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH));
577
- }
578
639
  /**
579
640
  * Creates new instance of PublicKey automatically determining the input format.
580
641
  * @param source A Buffer, or Uint8Array, or hex encoded string, or something with an `asUint8Array` method on it
@@ -583,7 +644,7 @@ var PublicKey = class _PublicKey {
583
644
  static from(source) {
584
645
  invariant4(source, void 0, {
585
646
  F: __dxlog_file4,
586
- L: 49,
647
+ L: 50,
587
648
  S: this,
588
649
  A: [
589
650
  "source",
@@ -675,7 +736,7 @@ var PublicKey = class _PublicKey {
675
736
  static bufferize(str) {
676
737
  invariant4(typeof str === "string", "Invalid type", {
677
738
  F: __dxlog_file4,
678
- L: 152,
739
+ L: 153,
679
740
  S: this,
680
741
  A: [
681
742
  "typeof str === 'string'",
@@ -698,7 +759,7 @@ var PublicKey = class _PublicKey {
698
759
  }
699
760
  invariant4(key instanceof Buffer, "Invalid type", {
700
761
  F: __dxlog_file4,
701
- L: 171,
762
+ L: 172,
702
763
  S: this,
703
764
  A: [
704
765
  "key instanceof Buffer",
@@ -717,7 +778,7 @@ var PublicKey = class _PublicKey {
717
778
  static fromMultibase32(encoded) {
718
779
  invariant4(encoded.startsWith("B"), "Invalid multibase32 encoding", {
719
780
  F: __dxlog_file4,
720
- L: 184,
781
+ L: 185,
721
782
  S: this,
722
783
  A: [
723
784
  "encoded.startsWith('B')",
@@ -726,12 +787,6 @@ var PublicKey = class _PublicKey {
726
787
  });
727
788
  return new _PublicKey(new Uint8Array((0, import_base32_decode3.default)(encoded.slice(1), "RFC4648")));
728
789
  }
729
- constructor(_value) {
730
- this._value = _value;
731
- if (!(_value instanceof Uint8Array)) {
732
- throw new TypeError(`Expected Uint8Array, got: ${_value}`);
733
- }
734
- }
735
790
  toString() {
736
791
  return this.toHex();
737
792
  }
@@ -765,7 +820,7 @@ var PublicKey = class _PublicKey {
765
820
  /**
766
821
  * Used by Node.js to get textual representation of this object when it's printed with a `console.log` statement.
767
822
  */
768
- [inspectCustom2](depth, options, inspectFn) {
823
+ [_inspectCustom2](depth, options, inspectFn) {
769
824
  if (!options.colors || typeof process.stdout.hasColors !== "function" || !process.stdout.hasColors()) {
770
825
  return `<PublicKey ${this.truncate()}>`;
771
826
  }
@@ -790,7 +845,7 @@ var PublicKey = class _PublicKey {
790
845
  const color = colors[this.getInsecureHash(colors.length)];
791
846
  return `PublicKey(${printControlCode(inspectFn.colors[color][0])}${this.truncate()}${printControlCode(inspectFn.colors.reset[0])})`;
792
847
  }
793
- get [devtoolsFormatter2]() {
848
+ get [_devtoolsFormatter2]() {
794
849
  return {
795
850
  header: () => {
796
851
  const colors = [
@@ -843,19 +898,28 @@ var PublicKey = class _PublicKey {
843
898
  }
844
899
  let equal = true;
845
900
  for (let i = 0; i < this._value.length; i++) {
846
- equal &&= this._value[i] === otherConverted._value[i];
901
+ equal && (equal = this._value[i] === otherConverted._value[i]);
847
902
  }
848
903
  return equal;
849
904
  }
850
- [equalsSymbol](other) {
905
+ [_equalsSymbol](other) {
851
906
  if (!_PublicKey.isPublicKey(other)) {
852
907
  return false;
853
908
  }
854
909
  return this.equals(other);
855
910
  }
911
+ constructor(_value) {
912
+ _define_property3(this, "_value", void 0);
913
+ this._value = _value;
914
+ if (!(_value instanceof Uint8Array)) {
915
+ throw new TypeError(`Expected Uint8Array, got: ${_value}`);
916
+ }
917
+ }
856
918
  };
919
+ _define_property3(PublicKey, "ZERO", PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH)));
857
920
  export {
858
921
  DXN,
922
+ DXN_ECHO_REGEXP,
859
923
  IdentityDid,
860
924
  LOCAL_SPACE_TAG,
861
925
  ObjectId,