@dxos/keys 0.8.4-main.84f28bd → 0.8.4-main.8baae0fced

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.
@@ -100,29 +100,74 @@ init_inject_globals();
100
100
 
101
101
  // src/dxn.ts
102
102
  init_inject_globals();
103
- import { Schema as Schema3 } from "effect";
103
+ import * as Schema3 from "effect/Schema";
104
104
  import { devtoolsFormatter, inspectCustom } from "@dxos/debug";
105
- import { invariant as invariant2 } from "@dxos/invariant";
105
+ import { assertArgument, invariant as invariant2 } from "@dxos/invariant";
106
106
 
107
107
  // src/object-id.ts
108
108
  init_inject_globals();
109
- import { Schema } from "effect";
110
- import { ulid } from "ulidx";
109
+ import * as Schema from "effect/Schema";
110
+ import { monotonicFactory } from "ulidx";
111
111
  var ObjectIdSchema = Schema.String.pipe(Schema.pattern(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i)).annotations({
112
- description: "a Universally Unique Lexicographically Sortable Identifier",
112
+ description: "A Universally Unique Lexicographically Sortable Identifier",
113
113
  pattern: "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
114
114
  });
115
115
  var ObjectId = class extends ObjectIdSchema {
116
+ static #factory = monotonicFactory();
117
+ static #seedTime = void 0;
116
118
  static isValid(id) {
117
119
  try {
118
120
  Schema.decodeSync(ObjectId)(id);
119
121
  return true;
120
- } catch (err) {
122
+ } catch {
121
123
  return false;
122
124
  }
123
125
  }
124
126
  static random() {
125
- return ulid();
127
+ return this.#factory(this.#seedTime);
128
+ }
129
+ static dangerouslyDisableRandomness() {
130
+ this.#factory = monotonicFactory(makeTestPRNG());
131
+ this.#seedTime = (/* @__PURE__ */ new Date("2025-01-01")).getTime();
132
+ }
133
+ static dangerouslySetSeed(time, seed) {
134
+ this.#factory = monotonicFactory(makeTestPRNG(seed));
135
+ this.#seedTime = time;
136
+ }
137
+ };
138
+ var makeTestPRNG = (seed = 0) => {
139
+ const rng = new SimplePRNG(seed);
140
+ return () => {
141
+ return rng.next();
142
+ };
143
+ };
144
+ var SimplePRNG = class _SimplePRNG {
145
+ #seed;
146
+ // LCG parameters (from Numerical Recipes)
147
+ static #a = 1664525;
148
+ static #c = 1013904223;
149
+ static #m = Math.pow(2, 32);
150
+ /**
151
+ * Creates a new PRNG instance.
152
+ * @param seed - Initial seed value. If not provided, uses 0.
153
+ */
154
+ constructor(seed = 0) {
155
+ this.#seed = seed;
156
+ }
157
+ /**
158
+ * Generates the next pseudo-random number in the range [0, 1).
159
+ * @returns A pseudo-random number between 0 (inclusive) and 1 (exclusive).
160
+ */
161
+ next() {
162
+ this.#seed = (_SimplePRNG.#a * this.#seed + _SimplePRNG.#c) % _SimplePRNG.#m;
163
+ return this.#seed / _SimplePRNG.#m;
164
+ }
165
+ /**
166
+ * Resets the generator with a new seed.
167
+ * @param seed - New seed value.
168
+ */
169
+ reset(seed) {
170
+ this.#seed = seed;
126
171
  }
127
172
  };
128
173
 
@@ -194,7 +239,7 @@ function base32Encode(data, variant, options) {
194
239
  }
195
240
 
196
241
  // src/space-id.ts
197
- import { Schema as Schema2 } from "effect";
242
+ import * as Schema2 from "effect/Schema";
198
243
  import { invariant } from "@dxos/invariant";
199
244
 
200
245
  // src/random-bytes.ts
@@ -207,121 +252,88 @@ var randomBytes = (length) => {
207
252
  };
208
253
 
209
254
  // src/space-id.ts
210
- var __dxlog_file = "/__w/dxos/dxos/packages/common/keys/src/space-id.ts";
211
255
  var MULTIBASE_PREFIX = "B";
212
256
  var ENCODED_LENGTH = 33;
213
257
  var isValid = (value) => {
214
258
  return typeof value === "string" && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;
215
259
  };
216
260
  var SpaceId = class extends Schema2.String.pipe(Schema2.filter(isValid)) {
217
- static {
218
- this.byteLength = 20;
219
- }
220
- static {
221
- this.encode = (value) => {
222
- invariant(value instanceof Uint8Array, "Invalid type", {
223
- F: __dxlog_file,
224
- L: 43,
225
- S: this,
226
- A: [
227
- "value instanceof Uint8Array",
228
- "'Invalid type'"
229
- ]
230
- });
231
- invariant(value.length === SpaceId.byteLength, "Invalid length", {
232
- F: __dxlog_file,
233
- L: 44,
234
- S: this,
235
- A: [
236
- "value.length === SpaceId.byteLength",
237
- "'Invalid length'"
238
- ]
239
- });
240
- return MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
241
- };
242
- }
243
- static {
244
- this.decode = (value) => {
245
- invariant(value.startsWith(MULTIBASE_PREFIX), "Invalid multibase32 encoding", {
246
- F: __dxlog_file,
247
- L: 49,
248
- S: this,
249
- A: [
250
- "value.startsWith(MULTIBASE_PREFIX)",
251
- "'Invalid multibase32 encoding'"
252
- ]
253
- });
254
- return new Uint8Array((0, import_base32_decode.default)(value.slice(1), "RFC4648"));
255
- };
256
- }
257
- static {
258
- this.isValid = isValid;
259
- }
260
- static {
261
- this.random = () => {
262
- return SpaceId.encode(randomBytes(SpaceId.byteLength));
263
- };
264
- }
261
+ static byteLength = 20;
262
+ static encode = (value) => {
263
+ invariant(value instanceof Uint8Array, "Invalid type");
264
+ invariant(value.length === SpaceId.byteLength, "Invalid length");
265
+ return MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
266
+ };
267
+ static decode = (value) => {
268
+ invariant(value.startsWith(MULTIBASE_PREFIX), "Invalid multibase32 encoding");
269
+ return new Uint8Array((0, import_base32_decode.default)(value.slice(1), "RFC4648"));
270
+ };
271
+ static isValid = isValid;
272
+ static random = () => {
273
+ return SpaceId.encode(randomBytes(SpaceId.byteLength));
274
+ };
265
275
  };
266
276
 
267
277
  // src/dxn.ts
268
- var __dxlog_file2 = "/__w/dxos/dxos/packages/common/keys/src/dxn.ts";
269
278
  var LOCAL_SPACE_TAG = "@";
279
+ var DXN_ECHO_REGEXP = /@(dxn:[a-zA-Z0-p:@]+)/;
270
280
  var QueueSubspaceTags = Object.freeze({
271
281
  DATA: "data",
272
282
  TRACE: "trace"
273
283
  });
274
284
  var DXN = class _DXN {
275
- static {
276
- // TODO(dmaretskyi): Should this be a transformation into the DXN type?
277
- this.Schema = Schema3.NonEmptyString.pipe(
278
- Schema3.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),
279
- // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.
280
- // FormatAnnotation.set(FormatEnum.DXN),
281
- Schema3.annotations({
282
- title: "DXN",
283
- description: "DXN URI",
284
- examples: [
285
- "dxn:type:example.com/type/MyType",
286
- "dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6"
287
- ]
288
- })
289
- );
290
- }
285
+ // TODO(burdon): Rename to DXN (i.e., DXN.DXN).
286
+ // TODO(dmaretskyi): Should this be a transformation into the DXN type?
287
+ static Schema = Schema3.NonEmptyString.pipe(
288
+ Schema3.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),
289
+ // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.
290
+ // FormatAnnotation.set(TypeFormat.DXN),
291
+ Schema3.annotations({
292
+ title: "DXN",
293
+ description: "DXN URI",
294
+ examples: [
295
+ "dxn:type:com.example.type.my-type",
296
+ "dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6"
297
+ ]
298
+ })
299
+ );
291
300
  static hash(dxn) {
292
301
  return dxn.toString();
293
302
  }
294
- static {
303
+ /**
304
+ * Kind constants.
305
+ */
306
+ static kind = Object.freeze({
295
307
  /**
296
- * Kind constants.
308
+ * dxn:type:<type_name>[:<version>]
297
309
  */
298
- this.kind = Object.freeze({
299
- /**
300
- * dxn:type:<type name>[:<version>]
301
- */
302
- TYPE: "type",
303
- /**
304
- * dxn:echo:<space id>:<echo id>
305
- * dxn:echo:@:<echo id>
306
- */
307
- // TODO(burdon): Rename to OBJECT? (BREAKING CHANGE).
308
- // TODO(burdon): Add separate Kind for space.
309
- ECHO: "echo",
310
- /**
311
- * The subspace tag enables us to partition queues by usage within the context of a space.
312
- * dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
313
- * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
314
- * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
315
- */
316
- QUEUE: "queue"
317
- });
318
- }
319
- get kind() {
320
- return this.#kind;
321
- }
310
+ TYPE: "type",
311
+ /**
312
+ * dxn:echo:<space_id>:<echo_id>
313
+ * dxn:echo:@:<echo_id>
314
+ */
315
+ // TODO(burdon): Rename to OBJECT? (BREAKING CHANGE to update "echo").
316
+ // TODO(burdon): Add separate Kind for space?
317
+ ECHO: "echo",
318
+ /**
319
+ * The subspace tag enables us to partition queues by usage within the context of a space.
320
+ * dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
321
+ * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
322
+ * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
323
+ */
324
+ QUEUE: "queue"
325
+ });
326
+ /**
327
+ * Exactly equals.
328
+ */
322
329
  static equals(a, b) {
323
330
  return a.kind === b.kind && a.parts.length === b.parts.length && a.parts.every((part, i) => part === b.parts[i]);
324
331
  }
332
+ static equalsEchoId(a, b) {
333
+ const a1 = a.asEchoDXN();
334
+ const b1 = b.asEchoDXN();
335
+ return !!a1 && !!b1 && a1.echoId === b1.echoId;
336
+ }
325
337
  // TODO(burdon): Rename isValid.
326
338
  static isDXNString(dxn) {
327
339
  return dxn.startsWith("dxn:");
@@ -345,12 +357,12 @@ var DXN = class _DXN {
345
357
  static tryParse(dxn) {
346
358
  try {
347
359
  return _DXN.parse(dxn);
348
- } catch (error) {
360
+ } catch {
349
361
  return void 0;
350
362
  }
351
363
  }
352
364
  /**
353
- * @example `dxn:type:example.com/type/Contact`
365
+ * @example `dxn:type:com.example.type.person`
354
366
  */
355
367
  static fromTypename(typename) {
356
368
  return new _DXN(_DXN.kind.TYPE, [
@@ -358,7 +370,7 @@ var DXN = class _DXN {
358
370
  ]);
359
371
  }
360
372
  /**
361
- * @example `dxn:type:example.com/type/Contact:0.1.0`
373
+ * @example `dxn:type:com.example.type.person:0.1.0`
362
374
  */
363
375
  // TODO(dmaretskyi): Consider using @ as the version separator.
364
376
  static fromTypenameAndVersion(typename, version) {
@@ -368,42 +380,30 @@ var DXN = class _DXN {
368
380
  ]);
369
381
  }
370
382
  /**
383
+ * @example `dxn:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6`
384
+ */
385
+ static fromSpaceAndObjectId(spaceId, objectId) {
386
+ assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);
387
+ assertArgument(ObjectId.isValid(objectId), "objectId", `Invalid object ID: ${objectId}`);
388
+ return new _DXN(_DXN.kind.ECHO, [
389
+ spaceId,
390
+ objectId
391
+ ]);
392
+ }
393
+ /**
371
394
  * @example `dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6`
372
395
  */
373
396
  static fromLocalObjectId(id) {
397
+ assertArgument(ObjectId.isValid(id), "id", `Invalid object ID: ${id}`);
374
398
  return new _DXN(_DXN.kind.ECHO, [
375
399
  LOCAL_SPACE_TAG,
376
400
  id
377
401
  ]);
378
402
  }
379
403
  static fromQueue(subspaceTag, spaceId, queueId, objectId) {
380
- invariant2(SpaceId.isValid(spaceId), void 0, {
381
- F: __dxlog_file2,
382
- L: 150,
383
- S: this,
384
- A: [
385
- "SpaceId.isValid(spaceId)",
386
- ""
387
- ]
388
- });
389
- invariant2(ObjectId.isValid(queueId), void 0, {
390
- F: __dxlog_file2,
391
- L: 151,
392
- S: this,
393
- A: [
394
- "ObjectId.isValid(queueId)",
395
- ""
396
- ]
397
- });
398
- invariant2(!objectId || ObjectId.isValid(objectId), void 0, {
399
- F: __dxlog_file2,
400
- L: 152,
401
- S: this,
402
- A: [
403
- "!objectId || ObjectId.isValid(objectId)",
404
- ""
405
- ]
406
- });
404
+ assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);
405
+ assertArgument(ObjectId.isValid(queueId), "queueId", `Invalid queue ID: ${queueId}`);
406
+ assertArgument(!objectId || ObjectId.isValid(objectId), "objectId", `Invalid object ID: ${objectId}`);
407
407
  return new _DXN(_DXN.kind.QUEUE, [
408
408
  subspaceTag,
409
409
  spaceId,
@@ -416,33 +416,17 @@ var DXN = class _DXN {
416
416
  #kind;
417
417
  #parts;
418
418
  constructor(kind, parts) {
419
- invariant2(parts.length > 0, void 0, {
420
- F: __dxlog_file2,
421
- L: 161,
422
- S: this,
423
- A: [
424
- "parts.length > 0",
425
- ""
426
- ]
427
- });
428
- invariant2(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), void 0, {
429
- F: __dxlog_file2,
430
- L: 162,
431
- S: this,
432
- A: [
433
- "parts.every((part) => typeof part === 'string' && part.length > 0 && part.indexOf(':') === -1)",
434
- ""
435
- ]
436
- });
419
+ assertArgument(parts.length > 0, "parts", `Invalid DXN: ${parts}`);
420
+ assertArgument(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), "parts", `Invalid DXN: ${parts}`);
437
421
  switch (kind) {
438
422
  case _DXN.kind.TYPE:
439
423
  if (parts.length > 2) {
440
- throw new Error('Invalid "type" DXN');
424
+ throw new Error("Invalid DXN.kind.TYPE");
441
425
  }
442
426
  break;
443
427
  case _DXN.kind.ECHO:
444
428
  if (parts.length !== 2) {
445
- throw new Error('Invalid "echo" DXN');
429
+ throw new Error("Invalid DXN.kind.ECHO");
446
430
  }
447
431
  break;
448
432
  }
@@ -477,22 +461,20 @@ var DXN = class _DXN {
477
461
  }
478
462
  };
479
463
  }
464
+ get kind() {
465
+ return this.#kind;
466
+ }
480
467
  get parts() {
481
468
  return this.#parts;
482
469
  }
483
470
  // TODO(burdon): Should getters fail?
484
471
  get typename() {
485
- invariant2(this.#kind === _DXN.kind.TYPE, void 0, {
486
- F: __dxlog_file2,
487
- L: 217,
488
- S: this,
489
- A: [
490
- "this.#kind === DXN.kind.TYPE",
491
- ""
492
- ]
493
- });
472
+ invariant2(this.#kind === _DXN.kind.TYPE);
494
473
  return this.#parts[0];
495
474
  }
475
+ equals(other) {
476
+ return _DXN.equals(this, other);
477
+ }
496
478
  hasTypenameOf(typename) {
497
479
  return this.#kind === _DXN.kind.TYPE && this.#parts.length === 1 && this.#parts[0] === typename;
498
480
  }
@@ -505,6 +487,7 @@ var DXN = class _DXN {
505
487
  }
506
488
  const [type, version] = this.#parts;
507
489
  return {
490
+ // TODO(wittjosiah): Should be `typename` for consistency.
508
491
  type,
509
492
  version
510
493
  };
@@ -516,6 +499,7 @@ var DXN = class _DXN {
516
499
  const [spaceId, echoId] = this.#parts;
517
500
  return {
518
501
  spaceId: spaceId === LOCAL_SPACE_TAG ? void 0 : spaceId,
502
+ // TODO(burdon): objectId.
519
503
  echoId
520
504
  };
521
505
  }
@@ -534,46 +518,30 @@ var DXN = class _DXN {
534
518
  objectId
535
519
  };
536
520
  }
521
+ /**
522
+ * Produces a new DXN with the given parts appended.
523
+ */
524
+ extend(parts) {
525
+ return new _DXN(this.#kind, [
526
+ ...this.#parts,
527
+ ...parts
528
+ ]);
529
+ }
537
530
  };
538
531
 
539
532
  // src/identity-did.ts
540
533
  init_inject_globals();
541
534
  var import_base32_decode2 = __toESM(require_base32_decode(), 1);
542
535
  import { invariant as invariant3 } from "@dxos/invariant";
543
- var __dxlog_file3 = "/__w/dxos/dxos/packages/common/keys/src/identity-did.ts";
544
536
  var IdentityDid = Object.freeze({
545
537
  byteLength: 20,
546
538
  encode: (value) => {
547
- invariant3(value instanceof Uint8Array, "Invalid type", {
548
- F: __dxlog_file3,
549
- L: 22,
550
- S: void 0,
551
- A: [
552
- "value instanceof Uint8Array",
553
- "'Invalid type'"
554
- ]
555
- });
556
- invariant3(value.length === IdentityDid.byteLength, "Invalid length", {
557
- F: __dxlog_file3,
558
- L: 23,
559
- S: void 0,
560
- A: [
561
- "value.length === IdentityDid.byteLength",
562
- "'Invalid length'"
563
- ]
564
- });
539
+ invariant3(value instanceof Uint8Array, "Invalid type");
540
+ invariant3(value.length === IdentityDid.byteLength, "Invalid length");
565
541
  return DID_PREFIX + MULTIBASE_PREFIX2 + base32Encode(value, "RFC4648");
566
542
  },
567
543
  decode: (value) => {
568
- invariant3(value.startsWith(DID_PREFIX + MULTIBASE_PREFIX2), "Invalid multibase32 encoding", {
569
- F: __dxlog_file3,
570
- L: 28,
571
- S: void 0,
572
- A: [
573
- "value.startsWith(DID_PREFIX + MULTIBASE_PREFIX)",
574
- "'Invalid multibase32 encoding'"
575
- ]
576
- });
544
+ invariant3(value.startsWith(DID_PREFIX + MULTIBASE_PREFIX2), "Invalid multibase32 encoding");
577
545
  return new Uint8Array((0, import_base32_decode2.default)(value.slice(10), "RFC4648"));
578
546
  },
579
547
  isValid: (value) => {
@@ -587,34 +555,51 @@ var MULTIBASE_PREFIX2 = "B";
587
555
  var DID_PREFIX = "did:halo:";
588
556
  var ENCODED_LENGTH2 = 42;
589
557
 
558
+ // src/parse-id.ts
559
+ init_inject_globals();
560
+ var SPACE_ID_LENGTH = 33;
561
+ var OBJECT_ID_LENGTH = 26;
562
+ var FQ_ID_LENGTH = SPACE_ID_LENGTH + OBJECT_ID_LENGTH + 1;
563
+ var parseId = (id) => {
564
+ if (!id) {
565
+ return {};
566
+ } else if (id.length === SPACE_ID_LENGTH) {
567
+ return {
568
+ spaceId: id
569
+ };
570
+ } else if (id.length === OBJECT_ID_LENGTH) {
571
+ return {
572
+ objectId: id
573
+ };
574
+ } else if (id.length === FQ_ID_LENGTH && id.indexOf(":") === SPACE_ID_LENGTH) {
575
+ const [spaceId, objectId] = id.split(":");
576
+ return {
577
+ spaceId,
578
+ objectId
579
+ };
580
+ } else {
581
+ return {};
582
+ }
583
+ };
584
+
590
585
  // src/public-key.ts
591
586
  init_inject_globals();
592
587
  var import_base32_decode3 = __toESM(require_base32_decode(), 1);
593
588
  import { devtoolsFormatter as devtoolsFormatter2, equalsSymbol, inspectCustom as inspectCustom2, truncateKey } from "@dxos/debug";
594
589
  import { invariant as invariant4 } from "@dxos/invariant";
595
- var __dxlog_file4 = "/__w/dxos/dxos/packages/common/keys/src/public-key.ts";
596
590
  var PUBLIC_KEY_LENGTH = 32;
597
591
  var SECRET_KEY_LENGTH = 64;
598
592
  var isLikeArrayBuffer = (value) => typeof value === "object" && value !== null && Object.getPrototypeOf(value).constructor.name === "ArrayBuffer";
599
593
  var PublicKey = class _PublicKey {
600
- static {
601
- this.ZERO = _PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH));
602
- }
594
+ _value;
595
+ static ZERO = _PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH));
603
596
  /**
604
597
  * Creates new instance of PublicKey automatically determining the input format.
605
598
  * @param source A Buffer, or Uint8Array, or hex encoded string, or something with an `asUint8Array` method on it
606
599
  * @returns PublicKey
607
600
  */
608
601
  static from(source) {
609
- invariant4(source, void 0, {
610
- F: __dxlog_file4,
611
- L: 49,
612
- S: this,
613
- A: [
614
- "source",
615
- ""
616
- ]
617
- });
602
+ invariant4(source);
618
603
  if (source instanceof _PublicKey) {
619
604
  return source;
620
605
  } else if (source instanceof Buffer2) {
@@ -698,15 +683,7 @@ var PublicKey = class _PublicKey {
698
683
  * @deprecated All keys should be represented as instances of PublicKey.
699
684
  */
700
685
  static bufferize(str) {
701
- invariant4(typeof str === "string", "Invalid type", {
702
- F: __dxlog_file4,
703
- L: 152,
704
- S: this,
705
- A: [
706
- "typeof str === 'string'",
707
- "'Invalid type'"
708
- ]
709
- });
686
+ invariant4(typeof str === "string", "Invalid type");
710
687
  const buffer = Buffer2.from(str, "hex");
711
688
  return buffer;
712
689
  }
@@ -721,15 +698,7 @@ var PublicKey = class _PublicKey {
721
698
  } else if (key instanceof Uint8Array) {
722
699
  key = Buffer2.from(key.buffer, key.byteOffset, key.byteLength);
723
700
  }
724
- invariant4(key instanceof Buffer2, "Invalid type", {
725
- F: __dxlog_file4,
726
- L: 171,
727
- S: this,
728
- A: [
729
- "key instanceof Buffer",
730
- "'Invalid type'"
731
- ]
732
- });
701
+ invariant4(key instanceof Buffer2, "Invalid type");
733
702
  return key.toString("hex");
734
703
  }
735
704
  /**
@@ -740,15 +709,7 @@ var PublicKey = class _PublicKey {
740
709
  return key.toHex();
741
710
  }
742
711
  static fromMultibase32(encoded) {
743
- invariant4(encoded.startsWith("B"), "Invalid multibase32 encoding", {
744
- F: __dxlog_file4,
745
- L: 184,
746
- S: this,
747
- A: [
748
- "encoded.startsWith('B')",
749
- "'Invalid multibase32 encoding'"
750
- ]
751
- });
712
+ invariant4(encoded.startsWith("B"), "Invalid multibase32 encoding");
752
713
  return new _PublicKey(new Uint8Array((0, import_base32_decode3.default)(encoded.slice(1), "RFC4648")));
753
714
  }
754
715
  constructor(_value) {
@@ -775,7 +736,7 @@ var PublicKey = class _PublicKey {
775
736
  toMultibase32() {
776
737
  return "B" + base32Encode(this._value, "RFC4648");
777
738
  }
778
- truncate(length = void 0) {
739
+ truncate(length) {
779
740
  return truncateKey(this, length);
780
741
  }
781
742
  asBuffer() {
@@ -881,13 +842,19 @@ var PublicKey = class _PublicKey {
881
842
  };
882
843
  export {
883
844
  DXN,
845
+ DXN_ECHO_REGEXP,
846
+ FQ_ID_LENGTH,
884
847
  IdentityDid,
885
848
  LOCAL_SPACE_TAG,
849
+ OBJECT_ID_LENGTH,
886
850
  ObjectId,
887
851
  PUBLIC_KEY_LENGTH,
888
852
  PublicKey,
889
853
  QueueSubspaceTags,
890
854
  SECRET_KEY_LENGTH,
891
- SpaceId
855
+ SPACE_ID_LENGTH,
856
+ SimplePRNG,
857
+ SpaceId,
858
+ parseId
892
859
  };
893
860
  //# sourceMappingURL=index.mjs.map