@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.
@@ -82,28 +82,73 @@ 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
- import { invariant as invariant2 } from "@dxos/invariant";
87
+ import { assertArgument, invariant as invariant2 } from "@dxos/invariant";
88
88
 
89
89
  // src/object-id.ts
90
- import { Schema } from "effect";
91
- import { ulid } from "ulidx";
90
+ import * as Schema from "effect/Schema";
91
+ import { monotonicFactory } 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 {
97
+ static #factory = monotonicFactory();
98
+ static #seedTime = void 0;
97
99
  static isValid(id) {
98
100
  try {
99
101
  Schema.decodeSync(ObjectId)(id);
100
102
  return true;
101
- } catch (err) {
103
+ } catch {
102
104
  return false;
103
105
  }
104
106
  }
105
107
  static random() {
106
- return ulid();
108
+ return this.#factory(this.#seedTime);
109
+ }
110
+ static dangerouslyDisableRandomness() {
111
+ this.#factory = monotonicFactory(makeTestPRNG());
112
+ this.#seedTime = (/* @__PURE__ */ new Date("2025-01-01")).getTime();
113
+ }
114
+ static dangerouslySetSeed(time, seed) {
115
+ this.#factory = monotonicFactory(makeTestPRNG(seed));
116
+ this.#seedTime = time;
117
+ }
118
+ };
119
+ var makeTestPRNG = (seed = 0) => {
120
+ const rng = new SimplePRNG(seed);
121
+ return () => {
122
+ return rng.next();
123
+ };
124
+ };
125
+ var SimplePRNG = class _SimplePRNG {
126
+ #seed;
127
+ // LCG parameters (from Numerical Recipes)
128
+ static #a = 1664525;
129
+ static #c = 1013904223;
130
+ static #m = Math.pow(2, 32);
131
+ /**
132
+ * Creates a new PRNG instance.
133
+ * @param seed - Initial seed value. If not provided, uses 0.
134
+ */
135
+ constructor(seed = 0) {
136
+ this.#seed = seed;
137
+ }
138
+ /**
139
+ * Generates the next pseudo-random number in the range [0, 1).
140
+ * @returns A pseudo-random number between 0 (inclusive) and 1 (exclusive).
141
+ */
142
+ next() {
143
+ this.#seed = (_SimplePRNG.#a * this.#seed + _SimplePRNG.#c) % _SimplePRNG.#m;
144
+ return this.#seed / _SimplePRNG.#m;
145
+ }
146
+ /**
147
+ * Resets the generator with a new seed.
148
+ * @param seed - New seed value.
149
+ */
150
+ reset(seed) {
151
+ this.#seed = seed;
107
152
  }
108
153
  };
109
154
 
@@ -170,7 +215,7 @@ function base32Encode(data, variant, options) {
170
215
  }
171
216
 
172
217
  // src/space-id.ts
173
- import { Schema as Schema2 } from "effect";
218
+ import * as Schema2 from "effect/Schema";
174
219
  import { invariant } from "@dxos/invariant";
175
220
 
176
221
  // src/random-bytes.ts
@@ -182,121 +227,88 @@ var randomBytes = (length) => {
182
227
  };
183
228
 
184
229
  // src/space-id.ts
185
- var __dxlog_file = "/__w/dxos/dxos/packages/common/keys/src/space-id.ts";
186
230
  var MULTIBASE_PREFIX = "B";
187
231
  var ENCODED_LENGTH = 33;
188
232
  var isValid = (value) => {
189
233
  return typeof value === "string" && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;
190
234
  };
191
235
  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
- };
217
- }
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
- };
231
- }
232
- static {
233
- this.isValid = isValid;
234
- }
235
- static {
236
- this.random = () => {
237
- return SpaceId.encode(randomBytes(SpaceId.byteLength));
238
- };
239
- }
236
+ static byteLength = 20;
237
+ static encode = (value) => {
238
+ invariant(value instanceof Uint8Array, "Invalid type");
239
+ invariant(value.length === SpaceId.byteLength, "Invalid length");
240
+ return MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
241
+ };
242
+ static decode = (value) => {
243
+ invariant(value.startsWith(MULTIBASE_PREFIX), "Invalid multibase32 encoding");
244
+ return new Uint8Array((0, import_base32_decode.default)(value.slice(1), "RFC4648"));
245
+ };
246
+ static isValid = isValid;
247
+ static random = () => {
248
+ return SpaceId.encode(randomBytes(SpaceId.byteLength));
249
+ };
240
250
  };
241
251
 
242
252
  // src/dxn.ts
243
- var __dxlog_file2 = "/__w/dxos/dxos/packages/common/keys/src/dxn.ts";
244
253
  var LOCAL_SPACE_TAG = "@";
254
+ var DXN_ECHO_REGEXP = /@(dxn:[a-zA-Z0-p:@]+)/;
245
255
  var QueueSubspaceTags = Object.freeze({
246
256
  DATA: "data",
247
257
  TRACE: "trace"
248
258
  });
249
259
  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
- }
260
+ // TODO(burdon): Rename to DXN (i.e., DXN.DXN).
261
+ // TODO(dmaretskyi): Should this be a transformation into the DXN type?
262
+ static Schema = Schema3.NonEmptyString.pipe(
263
+ Schema3.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),
264
+ // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.
265
+ // FormatAnnotation.set(TypeFormat.DXN),
266
+ Schema3.annotations({
267
+ title: "DXN",
268
+ description: "DXN URI",
269
+ examples: [
270
+ "dxn:type:com.example.type.my-type",
271
+ "dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6"
272
+ ]
273
+ })
274
+ );
266
275
  static hash(dxn) {
267
276
  return dxn.toString();
268
277
  }
269
- static {
278
+ /**
279
+ * Kind constants.
280
+ */
281
+ static kind = Object.freeze({
270
282
  /**
271
- * Kind constants.
283
+ * dxn:type:<type_name>[:<version>]
272
284
  */
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
- }
285
+ TYPE: "type",
286
+ /**
287
+ * dxn:echo:<space_id>:<echo_id>
288
+ * dxn:echo:@:<echo_id>
289
+ */
290
+ // TODO(burdon): Rename to OBJECT? (BREAKING CHANGE to update "echo").
291
+ // TODO(burdon): Add separate Kind for space?
292
+ ECHO: "echo",
293
+ /**
294
+ * The subspace tag enables us to partition queues by usage within the context of a space.
295
+ * dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
296
+ * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
297
+ * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
298
+ */
299
+ QUEUE: "queue"
300
+ });
301
+ /**
302
+ * Exactly equals.
303
+ */
297
304
  static equals(a, b) {
298
305
  return a.kind === b.kind && a.parts.length === b.parts.length && a.parts.every((part, i) => part === b.parts[i]);
299
306
  }
307
+ static equalsEchoId(a, b) {
308
+ const a1 = a.asEchoDXN();
309
+ const b1 = b.asEchoDXN();
310
+ return !!a1 && !!b1 && a1.echoId === b1.echoId;
311
+ }
300
312
  // TODO(burdon): Rename isValid.
301
313
  static isDXNString(dxn) {
302
314
  return dxn.startsWith("dxn:");
@@ -320,12 +332,12 @@ var DXN = class _DXN {
320
332
  static tryParse(dxn) {
321
333
  try {
322
334
  return _DXN.parse(dxn);
323
- } catch (error) {
335
+ } catch {
324
336
  return void 0;
325
337
  }
326
338
  }
327
339
  /**
328
- * @example `dxn:type:example.com/type/Contact`
340
+ * @example `dxn:type:com.example.type.person`
329
341
  */
330
342
  static fromTypename(typename) {
331
343
  return new _DXN(_DXN.kind.TYPE, [
@@ -333,7 +345,7 @@ var DXN = class _DXN {
333
345
  ]);
334
346
  }
335
347
  /**
336
- * @example `dxn:type:example.com/type/Contact:0.1.0`
348
+ * @example `dxn:type:com.example.type.person:0.1.0`
337
349
  */
338
350
  // TODO(dmaretskyi): Consider using @ as the version separator.
339
351
  static fromTypenameAndVersion(typename, version) {
@@ -343,42 +355,30 @@ var DXN = class _DXN {
343
355
  ]);
344
356
  }
345
357
  /**
358
+ * @example `dxn:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6`
359
+ */
360
+ static fromSpaceAndObjectId(spaceId, objectId) {
361
+ assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);
362
+ assertArgument(ObjectId.isValid(objectId), "objectId", `Invalid object ID: ${objectId}`);
363
+ return new _DXN(_DXN.kind.ECHO, [
364
+ spaceId,
365
+ objectId
366
+ ]);
367
+ }
368
+ /**
346
369
  * @example `dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6`
347
370
  */
348
371
  static fromLocalObjectId(id) {
372
+ assertArgument(ObjectId.isValid(id), "id", `Invalid object ID: ${id}`);
349
373
  return new _DXN(_DXN.kind.ECHO, [
350
374
  LOCAL_SPACE_TAG,
351
375
  id
352
376
  ]);
353
377
  }
354
378
  static fromQueue(subspaceTag, spaceId, queueId, objectId) {
355
- invariant2(SpaceId.isValid(spaceId), void 0, {
356
- F: __dxlog_file2,
357
- L: 150,
358
- S: this,
359
- A: [
360
- "SpaceId.isValid(spaceId)",
361
- ""
362
- ]
363
- });
364
- invariant2(ObjectId.isValid(queueId), void 0, {
365
- F: __dxlog_file2,
366
- L: 151,
367
- S: this,
368
- A: [
369
- "ObjectId.isValid(queueId)",
370
- ""
371
- ]
372
- });
373
- invariant2(!objectId || ObjectId.isValid(objectId), void 0, {
374
- F: __dxlog_file2,
375
- L: 152,
376
- S: this,
377
- A: [
378
- "!objectId || ObjectId.isValid(objectId)",
379
- ""
380
- ]
381
- });
379
+ assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);
380
+ assertArgument(ObjectId.isValid(queueId), "queueId", `Invalid queue ID: ${queueId}`);
381
+ assertArgument(!objectId || ObjectId.isValid(objectId), "objectId", `Invalid object ID: ${objectId}`);
382
382
  return new _DXN(_DXN.kind.QUEUE, [
383
383
  subspaceTag,
384
384
  spaceId,
@@ -391,33 +391,17 @@ var DXN = class _DXN {
391
391
  #kind;
392
392
  #parts;
393
393
  constructor(kind, parts) {
394
- invariant2(parts.length > 0, void 0, {
395
- F: __dxlog_file2,
396
- L: 161,
397
- S: this,
398
- A: [
399
- "parts.length > 0",
400
- ""
401
- ]
402
- });
403
- invariant2(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), void 0, {
404
- F: __dxlog_file2,
405
- L: 162,
406
- S: this,
407
- A: [
408
- "parts.every((part) => typeof part === 'string' && part.length > 0 && part.indexOf(':') === -1)",
409
- ""
410
- ]
411
- });
394
+ assertArgument(parts.length > 0, "parts", `Invalid DXN: ${parts}`);
395
+ assertArgument(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), "parts", `Invalid DXN: ${parts}`);
412
396
  switch (kind) {
413
397
  case _DXN.kind.TYPE:
414
398
  if (parts.length > 2) {
415
- throw new Error('Invalid "type" DXN');
399
+ throw new Error("Invalid DXN.kind.TYPE");
416
400
  }
417
401
  break;
418
402
  case _DXN.kind.ECHO:
419
403
  if (parts.length !== 2) {
420
- throw new Error('Invalid "echo" DXN');
404
+ throw new Error("Invalid DXN.kind.ECHO");
421
405
  }
422
406
  break;
423
407
  }
@@ -452,22 +436,20 @@ var DXN = class _DXN {
452
436
  }
453
437
  };
454
438
  }
439
+ get kind() {
440
+ return this.#kind;
441
+ }
455
442
  get parts() {
456
443
  return this.#parts;
457
444
  }
458
445
  // TODO(burdon): Should getters fail?
459
446
  get typename() {
460
- invariant2(this.#kind === _DXN.kind.TYPE, void 0, {
461
- F: __dxlog_file2,
462
- L: 217,
463
- S: this,
464
- A: [
465
- "this.#kind === DXN.kind.TYPE",
466
- ""
467
- ]
468
- });
447
+ invariant2(this.#kind === _DXN.kind.TYPE);
469
448
  return this.#parts[0];
470
449
  }
450
+ equals(other) {
451
+ return _DXN.equals(this, other);
452
+ }
471
453
  hasTypenameOf(typename) {
472
454
  return this.#kind === _DXN.kind.TYPE && this.#parts.length === 1 && this.#parts[0] === typename;
473
455
  }
@@ -480,6 +462,7 @@ var DXN = class _DXN {
480
462
  }
481
463
  const [type, version] = this.#parts;
482
464
  return {
465
+ // TODO(wittjosiah): Should be `typename` for consistency.
483
466
  type,
484
467
  version
485
468
  };
@@ -491,6 +474,7 @@ var DXN = class _DXN {
491
474
  const [spaceId, echoId] = this.#parts;
492
475
  return {
493
476
  spaceId: spaceId === LOCAL_SPACE_TAG ? void 0 : spaceId,
477
+ // TODO(burdon): objectId.
494
478
  echoId
495
479
  };
496
480
  }
@@ -509,45 +493,29 @@ var DXN = class _DXN {
509
493
  objectId
510
494
  };
511
495
  }
496
+ /**
497
+ * Produces a new DXN with the given parts appended.
498
+ */
499
+ extend(parts) {
500
+ return new _DXN(this.#kind, [
501
+ ...this.#parts,
502
+ ...parts
503
+ ]);
504
+ }
512
505
  };
513
506
 
514
507
  // src/identity-did.ts
515
508
  var import_base32_decode2 = __toESM(require_base32_decode(), 1);
516
509
  import { invariant as invariant3 } from "@dxos/invariant";
517
- var __dxlog_file3 = "/__w/dxos/dxos/packages/common/keys/src/identity-did.ts";
518
510
  var IdentityDid = Object.freeze({
519
511
  byteLength: 20,
520
512
  encode: (value) => {
521
- invariant3(value instanceof Uint8Array, "Invalid type", {
522
- F: __dxlog_file3,
523
- L: 22,
524
- S: void 0,
525
- A: [
526
- "value instanceof Uint8Array",
527
- "'Invalid type'"
528
- ]
529
- });
530
- invariant3(value.length === IdentityDid.byteLength, "Invalid length", {
531
- F: __dxlog_file3,
532
- L: 23,
533
- S: void 0,
534
- A: [
535
- "value.length === IdentityDid.byteLength",
536
- "'Invalid length'"
537
- ]
538
- });
513
+ invariant3(value instanceof Uint8Array, "Invalid type");
514
+ invariant3(value.length === IdentityDid.byteLength, "Invalid length");
539
515
  return DID_PREFIX + MULTIBASE_PREFIX2 + base32Encode(value, "RFC4648");
540
516
  },
541
517
  decode: (value) => {
542
- invariant3(value.startsWith(DID_PREFIX + MULTIBASE_PREFIX2), "Invalid multibase32 encoding", {
543
- F: __dxlog_file3,
544
- L: 28,
545
- S: void 0,
546
- A: [
547
- "value.startsWith(DID_PREFIX + MULTIBASE_PREFIX)",
548
- "'Invalid multibase32 encoding'"
549
- ]
550
- });
518
+ invariant3(value.startsWith(DID_PREFIX + MULTIBASE_PREFIX2), "Invalid multibase32 encoding");
551
519
  return new Uint8Array((0, import_base32_decode2.default)(value.slice(10), "RFC4648"));
552
520
  },
553
521
  isValid: (value) => {
@@ -561,33 +529,49 @@ var MULTIBASE_PREFIX2 = "B";
561
529
  var DID_PREFIX = "did:halo:";
562
530
  var ENCODED_LENGTH2 = 42;
563
531
 
532
+ // src/parse-id.ts
533
+ var SPACE_ID_LENGTH = 33;
534
+ var OBJECT_ID_LENGTH = 26;
535
+ var FQ_ID_LENGTH = SPACE_ID_LENGTH + OBJECT_ID_LENGTH + 1;
536
+ var parseId = (id) => {
537
+ if (!id) {
538
+ return {};
539
+ } else if (id.length === SPACE_ID_LENGTH) {
540
+ return {
541
+ spaceId: id
542
+ };
543
+ } else if (id.length === OBJECT_ID_LENGTH) {
544
+ return {
545
+ objectId: id
546
+ };
547
+ } else if (id.length === FQ_ID_LENGTH && id.indexOf(":") === SPACE_ID_LENGTH) {
548
+ const [spaceId, objectId] = id.split(":");
549
+ return {
550
+ spaceId,
551
+ objectId
552
+ };
553
+ } else {
554
+ return {};
555
+ }
556
+ };
557
+
564
558
  // src/public-key.ts
565
559
  var import_base32_decode3 = __toESM(require_base32_decode(), 1);
566
560
  import { devtoolsFormatter as devtoolsFormatter2, equalsSymbol, inspectCustom as inspectCustom2, truncateKey } from "@dxos/debug";
567
561
  import { invariant as invariant4 } from "@dxos/invariant";
568
- var __dxlog_file4 = "/__w/dxos/dxos/packages/common/keys/src/public-key.ts";
569
562
  var PUBLIC_KEY_LENGTH = 32;
570
563
  var SECRET_KEY_LENGTH = 64;
571
564
  var isLikeArrayBuffer = (value) => typeof value === "object" && value !== null && Object.getPrototypeOf(value).constructor.name === "ArrayBuffer";
572
565
  var PublicKey = class _PublicKey {
573
- static {
574
- this.ZERO = _PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH));
575
- }
566
+ _value;
567
+ static ZERO = _PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH));
576
568
  /**
577
569
  * Creates new instance of PublicKey automatically determining the input format.
578
570
  * @param source A Buffer, or Uint8Array, or hex encoded string, or something with an `asUint8Array` method on it
579
571
  * @returns PublicKey
580
572
  */
581
573
  static from(source) {
582
- invariant4(source, void 0, {
583
- F: __dxlog_file4,
584
- L: 49,
585
- S: this,
586
- A: [
587
- "source",
588
- ""
589
- ]
590
- });
574
+ invariant4(source);
591
575
  if (source instanceof _PublicKey) {
592
576
  return source;
593
577
  } else if (source instanceof Buffer) {
@@ -671,15 +655,7 @@ var PublicKey = class _PublicKey {
671
655
  * @deprecated All keys should be represented as instances of PublicKey.
672
656
  */
673
657
  static bufferize(str) {
674
- invariant4(typeof str === "string", "Invalid type", {
675
- F: __dxlog_file4,
676
- L: 152,
677
- S: this,
678
- A: [
679
- "typeof str === 'string'",
680
- "'Invalid type'"
681
- ]
682
- });
658
+ invariant4(typeof str === "string", "Invalid type");
683
659
  const buffer = Buffer.from(str, "hex");
684
660
  return buffer;
685
661
  }
@@ -694,15 +670,7 @@ var PublicKey = class _PublicKey {
694
670
  } else if (key instanceof Uint8Array) {
695
671
  key = Buffer.from(key.buffer, key.byteOffset, key.byteLength);
696
672
  }
697
- invariant4(key instanceof Buffer, "Invalid type", {
698
- F: __dxlog_file4,
699
- L: 171,
700
- S: this,
701
- A: [
702
- "key instanceof Buffer",
703
- "'Invalid type'"
704
- ]
705
- });
673
+ invariant4(key instanceof Buffer, "Invalid type");
706
674
  return key.toString("hex");
707
675
  }
708
676
  /**
@@ -713,15 +681,7 @@ var PublicKey = class _PublicKey {
713
681
  return key.toHex();
714
682
  }
715
683
  static fromMultibase32(encoded) {
716
- invariant4(encoded.startsWith("B"), "Invalid multibase32 encoding", {
717
- F: __dxlog_file4,
718
- L: 184,
719
- S: this,
720
- A: [
721
- "encoded.startsWith('B')",
722
- "'Invalid multibase32 encoding'"
723
- ]
724
- });
684
+ invariant4(encoded.startsWith("B"), "Invalid multibase32 encoding");
725
685
  return new _PublicKey(new Uint8Array((0, import_base32_decode3.default)(encoded.slice(1), "RFC4648")));
726
686
  }
727
687
  constructor(_value) {
@@ -748,7 +708,7 @@ var PublicKey = class _PublicKey {
748
708
  toMultibase32() {
749
709
  return "B" + base32Encode(this._value, "RFC4648");
750
710
  }
751
- truncate(length = void 0) {
711
+ truncate(length) {
752
712
  return truncateKey(this, length);
753
713
  }
754
714
  asBuffer() {
@@ -854,13 +814,19 @@ var PublicKey = class _PublicKey {
854
814
  };
855
815
  export {
856
816
  DXN,
817
+ DXN_ECHO_REGEXP,
818
+ FQ_ID_LENGTH,
857
819
  IdentityDid,
858
820
  LOCAL_SPACE_TAG,
821
+ OBJECT_ID_LENGTH,
859
822
  ObjectId,
860
823
  PUBLIC_KEY_LENGTH,
861
824
  PublicKey,
862
825
  QueueSubspaceTags,
863
826
  SECRET_KEY_LENGTH,
864
- SpaceId
827
+ SPACE_ID_LENGTH,
828
+ SimplePRNG,
829
+ SpaceId,
830
+ parseId
865
831
  };
866
832
  //# sourceMappingURL=index.mjs.map