@dxos/keys 0.8.3 → 0.8.4-main.1068cf700f

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.
@@ -31,9 +31,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  mod
32
32
  ));
33
33
 
34
- // node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js
34
+ // ../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js
35
35
  var require_base32_decode = __commonJS({
36
- "node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js"(exports, module) {
36
+ "../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js"(exports, module) {
37
37
  var RFC46482 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
38
38
  var RFC4648_HEX2 = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
39
39
  var CROCKFORD2 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
@@ -81,36 +81,77 @@ var require_base32_decode = __commonJS({
81
81
  }
82
82
  });
83
83
 
84
- // packages/common/keys/src/dxn.ts
85
- import { Schema as Schema3 } from "effect";
84
+ // src/dxn.ts
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
- // packages/common/keys/src/object-id.ts
90
- import { Schema } from "effect";
91
- import { ulid } from "ulidx";
89
+ // src/object-id.ts
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
+ };
115
+ var makeTestPRNG = () => {
116
+ const rng = new SimplePRNG();
117
+ return () => {
118
+ return rng.next();
119
+ };
120
+ };
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
+ }
134
+ /**
135
+ * Generates the next pseudo-random number in the range [0, 1).
136
+ * @returns A pseudo-random number between 0 (inclusive) and 1 (exclusive).
137
+ */
138
+ next() {
139
+ this.#seed = (_SimplePRNG.#a * this.#seed + _SimplePRNG.#c) % _SimplePRNG.#m;
140
+ return this.#seed / _SimplePRNG.#m;
141
+ }
142
+ /**
143
+ * Resets the generator with a new seed.
144
+ * @param seed - New seed value.
145
+ */
146
+ reset(seed) {
147
+ this.#seed = seed;
107
148
  }
108
149
  };
109
150
 
110
- // packages/common/keys/src/space-id.ts
151
+ // src/space-id.ts
111
152
  var import_base32_decode = __toESM(require_base32_decode(), 1);
112
153
 
113
- // node_modules/.pnpm/to-data-view@2.0.0/node_modules/to-data-view/index.js
154
+ // ../../../node_modules/.pnpm/to-data-view@2.0.0/node_modules/to-data-view/index.js
114
155
  function toDataView(data) {
115
156
  if (data instanceof Int8Array || data instanceof Uint8Array || data instanceof Uint8ClampedArray) {
116
157
  return new DataView(data.buffer, data.byteOffset, data.byteLength);
@@ -121,7 +162,7 @@ function toDataView(data) {
121
162
  throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray");
122
163
  }
123
164
 
124
- // node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js
165
+ // ../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js
125
166
  var RFC4648 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
126
167
  var RFC4648_HEX = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
127
168
  var CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
@@ -169,11 +210,11 @@ function base32Encode(data, variant, options) {
169
210
  return output;
170
211
  }
171
212
 
172
- // packages/common/keys/src/space-id.ts
173
- import { Schema as Schema2 } from "effect";
213
+ // src/space-id.ts
214
+ import * as Schema2 from "effect/Schema";
174
215
  import { invariant } from "@dxos/invariant";
175
216
 
176
- // packages/common/keys/src/random-bytes.ts
217
+ // src/random-bytes.ts
177
218
  var randomBytes = (length) => {
178
219
  const webCrypto = globalThis.crypto ?? __require("node:crypto").webcrypto;
179
220
  const bytes = new Uint8Array(length);
@@ -181,122 +222,115 @@ var randomBytes = (length) => {
181
222
  return bytes;
182
223
  };
183
224
 
184
- // packages/common/keys/src/space-id.ts
185
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/common/keys/src/space-id.ts";
225
+ // src/space-id.ts
226
+ var __dxlog_file = "/__w/dxos/dxos/packages/common/keys/src/space-id.ts";
186
227
  var MULTIBASE_PREFIX = "B";
187
228
  var ENCODED_LENGTH = 33;
188
229
  var isValid = (value) => {
189
230
  return typeof value === "string" && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;
190
231
  };
191
232
  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
- }
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
+ };
240
271
  };
241
272
 
242
- // packages/common/keys/src/dxn.ts
243
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/common/keys/src/dxn.ts";
273
+ // src/dxn.ts
274
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/common/keys/src/dxn.ts";
244
275
  var LOCAL_SPACE_TAG = "@";
276
+ var DXN_ECHO_REGEXP = /@(dxn:[a-zA-Z0-p:@]+)/;
245
277
  var QueueSubspaceTags = Object.freeze({
246
278
  DATA: "data",
247
279
  TRACE: "trace"
248
280
  });
249
281
  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
- }
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(TypeFormat.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
+ );
266
297
  static hash(dxn) {
267
298
  return dxn.toString();
268
299
  }
269
- static {
300
+ /**
301
+ * Kind constants.
302
+ */
303
+ static kind = Object.freeze({
270
304
  /**
271
- * Kind constants.
305
+ * dxn:type:<type_name>[:<version>]
272
306
  */
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
- }
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
+ /**
324
+ * Exactly equals.
325
+ */
297
326
  static equals(a, b) {
298
327
  return a.kind === b.kind && a.parts.length === b.parts.length && a.parts.every((part, i) => part === b.parts[i]);
299
328
  }
329
+ static equalsEchoId(a, b) {
330
+ const a1 = a.asEchoDXN();
331
+ const b1 = b.asEchoDXN();
332
+ return !!a1 && !!b1 && a1.echoId === b1.echoId;
333
+ }
300
334
  // TODO(burdon): Rename isValid.
301
335
  static isDXNString(dxn) {
302
336
  return dxn.startsWith("dxn:");
@@ -320,12 +354,12 @@ var DXN = class _DXN {
320
354
  static tryParse(dxn) {
321
355
  try {
322
356
  return _DXN.parse(dxn);
323
- } catch (error) {
357
+ } catch {
324
358
  return void 0;
325
359
  }
326
360
  }
327
361
  /**
328
- * @example `dxn:type:example.com/type/Contact`
362
+ * @example `dxn:type:example.com/type/Person`
329
363
  */
330
364
  static fromTypename(typename) {
331
365
  return new _DXN(_DXN.kind.TYPE, [
@@ -333,7 +367,7 @@ var DXN = class _DXN {
333
367
  ]);
334
368
  }
335
369
  /**
336
- * @example `dxn:type:example.com/type/Contact:0.1.0`
370
+ * @example `dxn:type:example.com/type/Person:0.1.0`
337
371
  */
338
372
  // TODO(dmaretskyi): Consider using @ as the version separator.
339
373
  static fromTypenameAndVersion(typename, version) {
@@ -343,42 +377,30 @@ var DXN = class _DXN {
343
377
  ]);
344
378
  }
345
379
  /**
380
+ * @example `dxn:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6`
381
+ */
382
+ static fromSpaceAndObjectId(spaceId, objectId) {
383
+ assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);
384
+ assertArgument(ObjectId.isValid(objectId), "objectId", `Invalid object ID: ${objectId}`);
385
+ return new _DXN(_DXN.kind.ECHO, [
386
+ spaceId,
387
+ objectId
388
+ ]);
389
+ }
390
+ /**
346
391
  * @example `dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6`
347
392
  */
348
393
  static fromLocalObjectId(id) {
394
+ assertArgument(ObjectId.isValid(id), "id", `Invalid object ID: ${id}`);
349
395
  return new _DXN(_DXN.kind.ECHO, [
350
396
  LOCAL_SPACE_TAG,
351
397
  id
352
398
  ]);
353
399
  }
354
400
  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
- });
401
+ assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);
402
+ assertArgument(ObjectId.isValid(queueId), "queueId", `Invalid queue ID: ${queueId}`);
403
+ assertArgument(!objectId || ObjectId.isValid(objectId), "objectId", `Invalid object ID: ${objectId}`);
382
404
  return new _DXN(_DXN.kind.QUEUE, [
383
405
  subspaceTag,
384
406
  spaceId,
@@ -391,39 +413,54 @@ var DXN = class _DXN {
391
413
  #kind;
392
414
  #parts;
393
415
  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
- });
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}`);
412
418
  switch (kind) {
413
419
  case _DXN.kind.TYPE:
414
420
  if (parts.length > 2) {
415
- throw new Error('Invalid "type" DXN');
421
+ throw new Error("Invalid DXN.kind.TYPE");
416
422
  }
417
423
  break;
418
424
  case _DXN.kind.ECHO:
419
425
  if (parts.length !== 2) {
420
- throw new Error('Invalid "echo" DXN');
426
+ throw new Error("Invalid DXN.kind.ECHO");
421
427
  }
422
428
  break;
423
429
  }
424
430
  this.#kind = kind;
425
431
  this.#parts = parts;
426
432
  }
433
+ toString() {
434
+ return `dxn:${this.#kind}:${this.#parts.join(":")}`;
435
+ }
436
+ toJSON() {
437
+ return this.toString();
438
+ }
439
+ /**
440
+ * Used by Node.js to get textual representation of this object when it's printed with a `console.log` statement.
441
+ */
442
+ [inspectCustom](depth, options, inspectFn) {
443
+ const printControlCode = (code) => {
444
+ return `\x1B[${code}m`;
445
+ };
446
+ return printControlCode(inspectFn.colors.blueBright[0]) + this.toString() + printControlCode(inspectFn.colors.reset[0]);
447
+ }
448
+ get [devtoolsFormatter]() {
449
+ return {
450
+ header: () => {
451
+ return [
452
+ "span",
453
+ {
454
+ style: "font-weight: bold;"
455
+ },
456
+ this.toString()
457
+ ];
458
+ }
459
+ };
460
+ }
461
+ get kind() {
462
+ return this.#kind;
463
+ }
427
464
  get parts() {
428
465
  return this.#parts;
429
466
  }
@@ -431,7 +468,7 @@ var DXN = class _DXN {
431
468
  get typename() {
432
469
  invariant2(this.#kind === _DXN.kind.TYPE, void 0, {
433
470
  F: __dxlog_file2,
434
- L: 188,
471
+ L: 250,
435
472
  S: this,
436
473
  A: [
437
474
  "this.#kind === DXN.kind.TYPE",
@@ -440,6 +477,9 @@ var DXN = class _DXN {
440
477
  });
441
478
  return this.#parts[0];
442
479
  }
480
+ equals(other) {
481
+ return _DXN.equals(this, other);
482
+ }
443
483
  hasTypenameOf(typename) {
444
484
  return this.#kind === _DXN.kind.TYPE && this.#parts.length === 1 && this.#parts[0] === typename;
445
485
  }
@@ -452,6 +492,7 @@ var DXN = class _DXN {
452
492
  }
453
493
  const [type, version] = this.#parts;
454
494
  return {
495
+ // TODO(wittjosiah): Should be `typename` for consistency.
455
496
  type,
456
497
  version
457
498
  };
@@ -463,6 +504,7 @@ var DXN = class _DXN {
463
504
  const [spaceId, echoId] = this.#parts;
464
505
  return {
465
506
  spaceId: spaceId === LOCAL_SPACE_TAG ? void 0 : spaceId,
507
+ // TODO(burdon): objectId.
466
508
  echoId
467
509
  };
468
510
  }
@@ -481,37 +523,21 @@ var DXN = class _DXN {
481
523
  objectId
482
524
  };
483
525
  }
484
- toString() {
485
- return `dxn:${this.#kind}:${this.#parts.join(":")}`;
486
- }
487
526
  /**
488
- * Used by Node.js to get textual representation of this object when it's printed with a `console.log` statement.
527
+ * Produces a new DXN with the given parts appended.
489
528
  */
490
- [inspectCustom](depth, options, inspectFn) {
491
- const printControlCode = (code) => {
492
- return `\x1B[${code}m`;
493
- };
494
- return printControlCode(inspectFn.colors.blueBright[0]) + this.toString() + printControlCode(inspectFn.colors.reset[0]);
495
- }
496
- get [devtoolsFormatter]() {
497
- return {
498
- header: () => {
499
- return [
500
- "span",
501
- {
502
- style: "font-weight: bold;"
503
- },
504
- this.toString()
505
- ];
506
- }
507
- };
529
+ extend(parts) {
530
+ return new _DXN(this.#kind, [
531
+ ...this.#parts,
532
+ ...parts
533
+ ]);
508
534
  }
509
535
  };
510
536
 
511
- // packages/common/keys/src/identity-did.ts
537
+ // src/identity-did.ts
512
538
  var import_base32_decode2 = __toESM(require_base32_decode(), 1);
513
539
  import { invariant as invariant3 } from "@dxos/invariant";
514
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/common/keys/src/identity-did.ts";
540
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/common/keys/src/identity-did.ts";
515
541
  var IdentityDid = Object.freeze({
516
542
  byteLength: 20,
517
543
  encode: (value) => {
@@ -558,18 +584,17 @@ var MULTIBASE_PREFIX2 = "B";
558
584
  var DID_PREFIX = "did:halo:";
559
585
  var ENCODED_LENGTH2 = 42;
560
586
 
561
- // packages/common/keys/src/public-key.ts
587
+ // src/public-key.ts
562
588
  var import_base32_decode3 = __toESM(require_base32_decode(), 1);
563
589
  import { devtoolsFormatter as devtoolsFormatter2, equalsSymbol, inspectCustom as inspectCustom2, truncateKey } from "@dxos/debug";
564
590
  import { invariant as invariant4 } from "@dxos/invariant";
565
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/common/keys/src/public-key.ts";
591
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/common/keys/src/public-key.ts";
566
592
  var PUBLIC_KEY_LENGTH = 32;
567
593
  var SECRET_KEY_LENGTH = 64;
568
594
  var isLikeArrayBuffer = (value) => typeof value === "object" && value !== null && Object.getPrototypeOf(value).constructor.name === "ArrayBuffer";
569
595
  var PublicKey = class _PublicKey {
570
- static {
571
- this.ZERO = _PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH));
572
- }
596
+ _value;
597
+ static ZERO = _PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH));
573
598
  /**
574
599
  * Creates new instance of PublicKey automatically determining the input format.
575
600
  * @param source A Buffer, or Uint8Array, or hex encoded string, or something with an `asUint8Array` method on it
@@ -578,7 +603,7 @@ var PublicKey = class _PublicKey {
578
603
  static from(source) {
579
604
  invariant4(source, void 0, {
580
605
  F: __dxlog_file4,
581
- L: 49,
606
+ L: 50,
582
607
  S: this,
583
608
  A: [
584
609
  "source",
@@ -670,7 +695,7 @@ var PublicKey = class _PublicKey {
670
695
  static bufferize(str) {
671
696
  invariant4(typeof str === "string", "Invalid type", {
672
697
  F: __dxlog_file4,
673
- L: 152,
698
+ L: 153,
674
699
  S: this,
675
700
  A: [
676
701
  "typeof str === 'string'",
@@ -693,7 +718,7 @@ var PublicKey = class _PublicKey {
693
718
  }
694
719
  invariant4(key instanceof Buffer, "Invalid type", {
695
720
  F: __dxlog_file4,
696
- L: 171,
721
+ L: 172,
697
722
  S: this,
698
723
  A: [
699
724
  "key instanceof Buffer",
@@ -712,7 +737,7 @@ var PublicKey = class _PublicKey {
712
737
  static fromMultibase32(encoded) {
713
738
  invariant4(encoded.startsWith("B"), "Invalid multibase32 encoding", {
714
739
  F: __dxlog_file4,
715
- L: 184,
740
+ L: 185,
716
741
  S: this,
717
742
  A: [
718
743
  "encoded.startsWith('B')",
@@ -851,6 +876,7 @@ var PublicKey = class _PublicKey {
851
876
  };
852
877
  export {
853
878
  DXN,
879
+ DXN_ECHO_REGEXP,
854
880
  IdentityDid,
855
881
  LOCAL_SPACE_TAG,
856
882
  ObjectId,
@@ -858,6 +884,7 @@ export {
858
884
  PublicKey,
859
885
  QueueSubspaceTags,
860
886
  SECRET_KEY_LENGTH,
887
+ SimplePRNG,
861
888
  SpaceId
862
889
  };
863
890
  //# sourceMappingURL=index.mjs.map