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

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.
@@ -1 +1 @@
1
- {"inputs":{"inject-globals:@inject-globals":{"bytes":324,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"src/object-id.ts":{"bytes":3470,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"ulidx","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js":{"bytes":1217,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"cjs"},"../../../node_modules/.pnpm/to-data-view@2.0.0/node_modules/to-data-view/index.js":{"bytes":410,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js":{"bytes":1266,"imports":[{"path":"../../../node_modules/.pnpm/to-data-view@2.0.0/node_modules/to-data-view/index.js","kind":"import-statement","original":"to-data-view"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"src/random-bytes.ts":{"bytes":1746,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true},{"path":"@dxos/node-std/crypto","kind":"require-call","external":true}],"format":"esm"},"src/space-id.ts":{"bytes":5978,"imports":[{"path":"../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js","kind":"import-statement","original":"base32-decode"},{"path":"../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js","kind":"import-statement","original":"base32-encode"},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/random-bytes.ts","kind":"import-statement","original":"./random-bytes"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"src/dxn.ts":{"bytes":28752,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/object-id.ts","kind":"import-statement","original":"./object-id"},{"path":"src/space-id.ts","kind":"import-statement","original":"./space-id"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"src/identity-did.ts":{"bytes":5438,"imports":[{"path":"../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js","kind":"import-statement","original":"base32-decode"},{"path":"../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js","kind":"import-statement","original":"base32-encode"},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/random-bytes.ts","kind":"import-statement","original":"./random-bytes"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"src/public-key.ts":{"bytes":30965,"imports":[{"path":"../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js","kind":"import-statement","original":"base32-decode"},{"path":"../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js","kind":"import-statement","original":"base32-encode"},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/random-bytes.ts","kind":"import-statement","original":"./random-bytes"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":849,"imports":[{"path":"src/dxn.ts","kind":"import-statement","original":"./dxn"},{"path":"src/identity-did.ts","kind":"import-statement","original":"./identity-did"},{"path":"src/object-id.ts","kind":"import-statement","original":"./object-id"},{"path":"src/public-key.ts","kind":"import-statement","original":"./public-key"},{"path":"src/space-id.ts","kind":"import-statement","original":"./space-id"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":42873},"dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"ulidx","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/node-std/crypto","kind":"require-call","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"exports":["DXN","IdentityDid","LOCAL_SPACE_TAG","ObjectId","PUBLIC_KEY_LENGTH","PublicKey","QueueSubspaceTags","SECRET_KEY_LENGTH","SpaceId"],"entryPoint":"src/index.ts","inputs":{"inject-globals:@inject-globals":{"bytesInOutput":171},"../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js":{"bytesInOutput":1590},"src/index.ts":{"bytesInOutput":23},"src/dxn.ts":{"bytesInOutput":7090},"src/object-id.ts":{"bytesInOutput":547},"src/space-id.ts":{"bytesInOutput":1704},"../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js":{"bytesInOutput":1229},"../../../node_modules/.pnpm/to-data-view@2.0.0/node_modules/to-data-view/index.js":{"bytesInOutput":418},"src/random-bytes.ts":{"bytesInOutput":237},"src/identity-did.ts":{"bytesInOutput":1557},"src/public-key.ts":{"bytesInOutput":7977}},"bytes":25117}}}
1
+ {"inputs":{"inject-globals:@inject-globals":{"bytes":324,"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true}],"format":"esm"},"src/object-id.ts":{"bytes":3441,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"ulidx","kind":"import-statement","external":true},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js":{"bytes":1217,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"cjs"},"../../../node_modules/.pnpm/to-data-view@2.0.0/node_modules/to-data-view/index.js":{"bytes":410,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js":{"bytes":1266,"imports":[{"path":"../../../node_modules/.pnpm/to-data-view@2.0.0/node_modules/to-data-view/index.js","kind":"import-statement","original":"to-data-view"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"src/random-bytes.ts":{"bytes":1746,"imports":[{"path":"@inject-globals","kind":"import-statement","external":true},{"path":"@dxos/node-std/crypto","kind":"require-call","external":true}],"format":"esm"},"src/space-id.ts":{"bytes":5978,"imports":[{"path":"../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js","kind":"import-statement","original":"base32-decode"},{"path":"../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js","kind":"import-statement","original":"base32-encode"},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/random-bytes.ts","kind":"import-statement","original":"./random-bytes"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"src/dxn.ts":{"bytes":30537,"imports":[{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/object-id.ts","kind":"import-statement","original":"./object-id"},{"path":"src/space-id.ts","kind":"import-statement","original":"./space-id"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"src/identity-did.ts":{"bytes":5438,"imports":[{"path":"../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js","kind":"import-statement","original":"base32-decode"},{"path":"../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js","kind":"import-statement","original":"base32-encode"},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/random-bytes.ts","kind":"import-statement","original":"./random-bytes"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"src/public-key.ts":{"bytes":30965,"imports":[{"path":"../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js","kind":"import-statement","original":"base32-decode"},{"path":"../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js","kind":"import-statement","original":"base32-encode"},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/random-bytes.ts","kind":"import-statement","original":"./random-bytes"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":849,"imports":[{"path":"src/dxn.ts","kind":"import-statement","original":"./dxn"},{"path":"src/identity-did.ts","kind":"import-statement","original":"./identity-did"},{"path":"src/object-id.ts","kind":"import-statement","original":"./object-id"},{"path":"src/public-key.ts","kind":"import-statement","original":"./public-key"},{"path":"src/space-id.ts","kind":"import-statement","original":"./space-id"},{"path":"@inject-globals","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":44082},"dist/lib/browser/index.mjs":{"imports":[{"path":"@dxos/node-std/inject-globals","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"ulidx","kind":"import-statement","external":true},{"path":"effect","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/node-std/crypto","kind":"require-call","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"exports":["DXN","DXN_ECHO_REGEXP","IdentityDid","LOCAL_SPACE_TAG","ObjectId","PUBLIC_KEY_LENGTH","PublicKey","QueueSubspaceTags","SECRET_KEY_LENGTH","SpaceId"],"entryPoint":"src/index.ts","inputs":{"inject-globals:@inject-globals":{"bytesInOutput":171},"../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js":{"bytesInOutput":1590},"src/index.ts":{"bytesInOutput":23},"src/dxn.ts":{"bytesInOutput":7042},"src/object-id.ts":{"bytesInOutput":541},"src/space-id.ts":{"bytesInOutput":1563},"../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js":{"bytesInOutput":1229},"../../../node_modules/.pnpm/to-data-view@2.0.0/node_modules/to-data-view/index.js":{"bytesInOutput":418},"src/random-bytes.ts":{"bytesInOutput":237},"src/identity-did.ts":{"bytesInOutput":1557},"src/public-key.ts":{"bytesInOutput":7972}},"bytes":24936}}}
@@ -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
  }
@@ -189,108 +189,96 @@ var isValid = (value) => {
189
189
  return typeof value === "string" && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;
190
190
  };
191
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
- };
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
- }
192
+ static byteLength = 20;
193
+ static encode = (value) => {
194
+ invariant(value instanceof Uint8Array, "Invalid type", {
195
+ F: __dxlog_file,
196
+ L: 43,
197
+ S: this,
198
+ A: [
199
+ "value instanceof Uint8Array",
200
+ "'Invalid type'"
201
+ ]
202
+ });
203
+ invariant(value.length === SpaceId.byteLength, "Invalid length", {
204
+ F: __dxlog_file,
205
+ L: 44,
206
+ S: this,
207
+ A: [
208
+ "value.length === SpaceId.byteLength",
209
+ "'Invalid length'"
210
+ ]
211
+ });
212
+ return MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
213
+ };
214
+ static decode = (value) => {
215
+ invariant(value.startsWith(MULTIBASE_PREFIX), "Invalid multibase32 encoding", {
216
+ F: __dxlog_file,
217
+ L: 49,
218
+ S: this,
219
+ A: [
220
+ "value.startsWith(MULTIBASE_PREFIX)",
221
+ "'Invalid multibase32 encoding'"
222
+ ]
223
+ });
224
+ return new Uint8Array((0, import_base32_decode.default)(value.slice(1), "RFC4648"));
225
+ };
226
+ static isValid = isValid;
227
+ static random = () => {
228
+ return SpaceId.encode(randomBytes(SpaceId.byteLength));
229
+ };
240
230
  };
241
231
 
242
232
  // src/dxn.ts
243
233
  var __dxlog_file2 = "/__w/dxos/dxos/packages/common/keys/src/dxn.ts";
244
234
  var LOCAL_SPACE_TAG = "@";
235
+ var DXN_ECHO_REGEXP = /@(dxn:[a-zA-Z0-p:@]+)/;
245
236
  var QueueSubspaceTags = Object.freeze({
246
237
  DATA: "data",
247
238
  TRACE: "trace"
248
239
  });
249
240
  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
- }
241
+ // TODO(burdon): Rename to DXN (i.e., DXN.DXN).
242
+ // TODO(dmaretskyi): Should this be a transformation into the DXN type?
243
+ static Schema = Schema3.NonEmptyString.pipe(
244
+ Schema3.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),
245
+ // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.
246
+ // FormatAnnotation.set(FormatEnum.DXN),
247
+ Schema3.annotations({
248
+ title: "DXN",
249
+ description: "DXN URI",
250
+ examples: [
251
+ "dxn:type:example.com/type/MyType",
252
+ "dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6"
253
+ ]
254
+ })
255
+ );
266
256
  static hash(dxn) {
267
257
  return dxn.toString();
268
258
  }
269
- static {
259
+ /**
260
+ * Kind constants.
261
+ */
262
+ static kind = Object.freeze({
270
263
  /**
271
- * Kind constants.
264
+ * dxn:type:<type name>[:<version>]
272
265
  */
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
- }
266
+ TYPE: "type",
267
+ /**
268
+ * dxn:echo:<space id>:<echo id>
269
+ * dxn:echo:@:<echo id>
270
+ */
271
+ // TODO(burdon): Rename to OBJECT? (BREAKING CHANGE).
272
+ // TODO(burdon): Add separate Kind for space.
273
+ ECHO: "echo",
274
+ /**
275
+ * The subspace tag enables us to partition queues by usage within the context of a space.
276
+ * dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
277
+ * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
278
+ * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
279
+ */
280
+ QUEUE: "queue"
281
+ });
294
282
  get kind() {
295
283
  return this.#kind;
296
284
  }
@@ -320,7 +308,7 @@ var DXN = class _DXN {
320
308
  static tryParse(dxn) {
321
309
  try {
322
310
  return _DXN.parse(dxn);
323
- } catch (error) {
311
+ } catch {
324
312
  return void 0;
325
313
  }
326
314
  }
@@ -343,6 +331,17 @@ var DXN = class _DXN {
343
331
  ]);
344
332
  }
345
333
  /**
334
+ * @example `dxn:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6`
335
+ */
336
+ static fromSpaceAndObjectId(spaceId, objectId) {
337
+ assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);
338
+ assertArgument(ObjectId.isValid(objectId), `Invalid object ID: ${objectId}`);
339
+ return new _DXN(_DXN.kind.ECHO, [
340
+ spaceId,
341
+ objectId
342
+ ]);
343
+ }
344
+ /**
346
345
  * @example `dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6`
347
346
  */
348
347
  static fromLocalObjectId(id) {
@@ -353,33 +352,9 @@ var DXN = class _DXN {
353
352
  ]);
354
353
  }
355
354
  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
- });
355
+ assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);
356
+ assertArgument(ObjectId.isValid(queueId), `Invalid queue ID: ${queueId}`);
357
+ assertArgument(!objectId || ObjectId.isValid(objectId), `Invalid object ID: ${objectId}`);
383
358
  return new _DXN(_DXN.kind.QUEUE, [
384
359
  subspaceTag,
385
360
  spaceId,
@@ -392,24 +367,8 @@ var DXN = class _DXN {
392
367
  #kind;
393
368
  #parts;
394
369
  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
- });
370
+ assertArgument(parts.length > 0, `Invalid DXN: ${parts}`);
371
+ assertArgument(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), `Invalid DXN: ${parts}`);
413
372
  switch (kind) {
414
373
  case _DXN.kind.TYPE:
415
374
  if (parts.length > 2) {
@@ -460,7 +419,7 @@ var DXN = class _DXN {
460
419
  get typename() {
461
420
  invariant2(this.#kind === _DXN.kind.TYPE, void 0, {
462
421
  F: __dxlog_file2,
463
- L: 218,
422
+ L: 234,
464
423
  S: this,
465
424
  A: [
466
425
  "this.#kind === DXN.kind.TYPE",
@@ -511,6 +470,15 @@ var DXN = class _DXN {
511
470
  objectId
512
471
  };
513
472
  }
473
+ /**
474
+ * Produces a new DXN with the given parts appended.
475
+ */
476
+ extend(parts) {
477
+ return new _DXN(this.#kind, [
478
+ ...this.#parts,
479
+ ...parts
480
+ ]);
481
+ }
514
482
  };
515
483
 
516
484
  // src/identity-did.ts
@@ -572,9 +540,8 @@ var PUBLIC_KEY_LENGTH = 32;
572
540
  var SECRET_KEY_LENGTH = 64;
573
541
  var isLikeArrayBuffer = (value) => typeof value === "object" && value !== null && Object.getPrototypeOf(value).constructor.name === "ArrayBuffer";
574
542
  var PublicKey = class _PublicKey {
575
- static {
576
- this.ZERO = _PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH));
577
- }
543
+ _value;
544
+ static ZERO = _PublicKey.from("00".repeat(PUBLIC_KEY_LENGTH));
578
545
  /**
579
546
  * Creates new instance of PublicKey automatically determining the input format.
580
547
  * @param source A Buffer, or Uint8Array, or hex encoded string, or something with an `asUint8Array` method on it
@@ -583,7 +550,7 @@ var PublicKey = class _PublicKey {
583
550
  static from(source) {
584
551
  invariant4(source, void 0, {
585
552
  F: __dxlog_file4,
586
- L: 49,
553
+ L: 50,
587
554
  S: this,
588
555
  A: [
589
556
  "source",
@@ -675,7 +642,7 @@ var PublicKey = class _PublicKey {
675
642
  static bufferize(str) {
676
643
  invariant4(typeof str === "string", "Invalid type", {
677
644
  F: __dxlog_file4,
678
- L: 152,
645
+ L: 153,
679
646
  S: this,
680
647
  A: [
681
648
  "typeof str === 'string'",
@@ -698,7 +665,7 @@ var PublicKey = class _PublicKey {
698
665
  }
699
666
  invariant4(key instanceof Buffer, "Invalid type", {
700
667
  F: __dxlog_file4,
701
- L: 171,
668
+ L: 172,
702
669
  S: this,
703
670
  A: [
704
671
  "key instanceof Buffer",
@@ -717,7 +684,7 @@ var PublicKey = class _PublicKey {
717
684
  static fromMultibase32(encoded) {
718
685
  invariant4(encoded.startsWith("B"), "Invalid multibase32 encoding", {
719
686
  F: __dxlog_file4,
720
- L: 184,
687
+ L: 185,
721
688
  S: this,
722
689
  A: [
723
690
  "encoded.startsWith('B')",
@@ -856,6 +823,7 @@ var PublicKey = class _PublicKey {
856
823
  };
857
824
  export {
858
825
  DXN,
826
+ DXN_ECHO_REGEXP,
859
827
  IdentityDid,
860
828
  LOCAL_SPACE_TAG,
861
829
  ObjectId,