@dxos/keys 0.8.4-main.fbb7a13 → 0.8.4-main.fcc0d83b33
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.
- package/dist/lib/browser/index.mjs +15 -107
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +15 -107
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/dxn.d.ts +5 -5
- package/dist/types/src/dxn.d.ts.map +1 -1
- package/dist/types/src/object-id.d.ts.map +1 -1
- package/dist/types/src/prng.d.ts.map +1 -1
- package/dist/types/src/public-key.d.ts +1 -1
- package/dist/types/src/public-key.d.ts.map +1 -1
- package/dist/types/src/random-bytes.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -9
- package/src/dxn.ts +7 -8
- package/src/public-key.ts +2 -3
|
@@ -223,7 +223,6 @@ var randomBytes = (length) => {
|
|
|
223
223
|
};
|
|
224
224
|
|
|
225
225
|
// src/space-id.ts
|
|
226
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/common/keys/src/space-id.ts";
|
|
227
226
|
var MULTIBASE_PREFIX = "B";
|
|
228
227
|
var ENCODED_LENGTH = 33;
|
|
229
228
|
var isValid = (value) => {
|
|
@@ -232,36 +231,12 @@ var isValid = (value) => {
|
|
|
232
231
|
var SpaceId = class extends Schema2.String.pipe(Schema2.filter(isValid)) {
|
|
233
232
|
static byteLength = 20;
|
|
234
233
|
static encode = (value) => {
|
|
235
|
-
invariant(value instanceof Uint8Array, "Invalid type"
|
|
236
|
-
|
|
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
|
-
});
|
|
234
|
+
invariant(value instanceof Uint8Array, "Invalid type");
|
|
235
|
+
invariant(value.length === SpaceId.byteLength, "Invalid length");
|
|
253
236
|
return MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
|
|
254
237
|
};
|
|
255
238
|
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
|
-
});
|
|
239
|
+
invariant(value.startsWith(MULTIBASE_PREFIX), "Invalid multibase32 encoding");
|
|
265
240
|
return new Uint8Array((0, import_base32_decode.default)(value.slice(1), "RFC4648"));
|
|
266
241
|
};
|
|
267
242
|
static isValid = isValid;
|
|
@@ -271,7 +246,6 @@ var SpaceId = class extends Schema2.String.pipe(Schema2.filter(isValid)) {
|
|
|
271
246
|
};
|
|
272
247
|
|
|
273
248
|
// src/dxn.ts
|
|
274
|
-
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/keys/src/dxn.ts";
|
|
275
249
|
var LOCAL_SPACE_TAG = "@";
|
|
276
250
|
var DXN_ECHO_REGEXP = /@(dxn:[a-zA-Z0-p:@]+)/;
|
|
277
251
|
var QueueSubspaceTags = Object.freeze({
|
|
@@ -289,7 +263,7 @@ var DXN = class _DXN {
|
|
|
289
263
|
title: "DXN",
|
|
290
264
|
description: "DXN URI",
|
|
291
265
|
examples: [
|
|
292
|
-
"dxn:type:example.
|
|
266
|
+
"dxn:type:com.example.type.my-type",
|
|
293
267
|
"dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6"
|
|
294
268
|
]
|
|
295
269
|
})
|
|
@@ -359,7 +333,7 @@ var DXN = class _DXN {
|
|
|
359
333
|
}
|
|
360
334
|
}
|
|
361
335
|
/**
|
|
362
|
-
* @example `dxn:type:example.
|
|
336
|
+
* @example `dxn:type:com.example.type.person`
|
|
363
337
|
*/
|
|
364
338
|
static fromTypename(typename) {
|
|
365
339
|
return new _DXN(_DXN.kind.TYPE, [
|
|
@@ -367,7 +341,7 @@ var DXN = class _DXN {
|
|
|
367
341
|
]);
|
|
368
342
|
}
|
|
369
343
|
/**
|
|
370
|
-
* @example `dxn:type:example.
|
|
344
|
+
* @example `dxn:type:com.example.type.person:0.1.0`
|
|
371
345
|
*/
|
|
372
346
|
// TODO(dmaretskyi): Consider using @ as the version separator.
|
|
373
347
|
static fromTypenameAndVersion(typename, version) {
|
|
@@ -466,15 +440,7 @@ var DXN = class _DXN {
|
|
|
466
440
|
}
|
|
467
441
|
// TODO(burdon): Should getters fail?
|
|
468
442
|
get typename() {
|
|
469
|
-
invariant2(this.#kind === _DXN.kind.TYPE
|
|
470
|
-
F: __dxlog_file2,
|
|
471
|
-
L: 250,
|
|
472
|
-
S: this,
|
|
473
|
-
A: [
|
|
474
|
-
"this.#kind === DXN.kind.TYPE",
|
|
475
|
-
""
|
|
476
|
-
]
|
|
477
|
-
});
|
|
443
|
+
invariant2(this.#kind === _DXN.kind.TYPE);
|
|
478
444
|
return this.#parts[0];
|
|
479
445
|
}
|
|
480
446
|
equals(other) {
|
|
@@ -537,40 +503,15 @@ var DXN = class _DXN {
|
|
|
537
503
|
// src/identity-did.ts
|
|
538
504
|
var import_base32_decode2 = __toESM(require_base32_decode(), 1);
|
|
539
505
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
540
|
-
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/keys/src/identity-did.ts";
|
|
541
506
|
var IdentityDid = Object.freeze({
|
|
542
507
|
byteLength: 20,
|
|
543
508
|
encode: (value) => {
|
|
544
|
-
invariant3(value instanceof Uint8Array, "Invalid type"
|
|
545
|
-
|
|
546
|
-
L: 22,
|
|
547
|
-
S: void 0,
|
|
548
|
-
A: [
|
|
549
|
-
"value instanceof Uint8Array",
|
|
550
|
-
"'Invalid type'"
|
|
551
|
-
]
|
|
552
|
-
});
|
|
553
|
-
invariant3(value.length === IdentityDid.byteLength, "Invalid length", {
|
|
554
|
-
F: __dxlog_file3,
|
|
555
|
-
L: 23,
|
|
556
|
-
S: void 0,
|
|
557
|
-
A: [
|
|
558
|
-
"value.length === IdentityDid.byteLength",
|
|
559
|
-
"'Invalid length'"
|
|
560
|
-
]
|
|
561
|
-
});
|
|
509
|
+
invariant3(value instanceof Uint8Array, "Invalid type");
|
|
510
|
+
invariant3(value.length === IdentityDid.byteLength, "Invalid length");
|
|
562
511
|
return DID_PREFIX + MULTIBASE_PREFIX2 + base32Encode(value, "RFC4648");
|
|
563
512
|
},
|
|
564
513
|
decode: (value) => {
|
|
565
|
-
invariant3(value.startsWith(DID_PREFIX + MULTIBASE_PREFIX2), "Invalid multibase32 encoding"
|
|
566
|
-
F: __dxlog_file3,
|
|
567
|
-
L: 28,
|
|
568
|
-
S: void 0,
|
|
569
|
-
A: [
|
|
570
|
-
"value.startsWith(DID_PREFIX + MULTIBASE_PREFIX)",
|
|
571
|
-
"'Invalid multibase32 encoding'"
|
|
572
|
-
]
|
|
573
|
-
});
|
|
514
|
+
invariant3(value.startsWith(DID_PREFIX + MULTIBASE_PREFIX2), "Invalid multibase32 encoding");
|
|
574
515
|
return new Uint8Array((0, import_base32_decode2.default)(value.slice(10), "RFC4648"));
|
|
575
516
|
},
|
|
576
517
|
isValid: (value) => {
|
|
@@ -588,7 +529,6 @@ var ENCODED_LENGTH2 = 42;
|
|
|
588
529
|
var import_base32_decode3 = __toESM(require_base32_decode(), 1);
|
|
589
530
|
import { devtoolsFormatter as devtoolsFormatter2, equalsSymbol, inspectCustom as inspectCustom2, truncateKey } from "@dxos/debug";
|
|
590
531
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
591
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/common/keys/src/public-key.ts";
|
|
592
532
|
var PUBLIC_KEY_LENGTH = 32;
|
|
593
533
|
var SECRET_KEY_LENGTH = 64;
|
|
594
534
|
var isLikeArrayBuffer = (value) => typeof value === "object" && value !== null && Object.getPrototypeOf(value).constructor.name === "ArrayBuffer";
|
|
@@ -601,15 +541,7 @@ var PublicKey = class _PublicKey {
|
|
|
601
541
|
* @returns PublicKey
|
|
602
542
|
*/
|
|
603
543
|
static from(source) {
|
|
604
|
-
invariant4(source
|
|
605
|
-
F: __dxlog_file4,
|
|
606
|
-
L: 50,
|
|
607
|
-
S: this,
|
|
608
|
-
A: [
|
|
609
|
-
"source",
|
|
610
|
-
""
|
|
611
|
-
]
|
|
612
|
-
});
|
|
544
|
+
invariant4(source);
|
|
613
545
|
if (source instanceof _PublicKey) {
|
|
614
546
|
return source;
|
|
615
547
|
} else if (source instanceof Buffer) {
|
|
@@ -693,15 +625,7 @@ var PublicKey = class _PublicKey {
|
|
|
693
625
|
* @deprecated All keys should be represented as instances of PublicKey.
|
|
694
626
|
*/
|
|
695
627
|
static bufferize(str) {
|
|
696
|
-
invariant4(typeof str === "string", "Invalid type"
|
|
697
|
-
F: __dxlog_file4,
|
|
698
|
-
L: 153,
|
|
699
|
-
S: this,
|
|
700
|
-
A: [
|
|
701
|
-
"typeof str === 'string'",
|
|
702
|
-
"'Invalid type'"
|
|
703
|
-
]
|
|
704
|
-
});
|
|
628
|
+
invariant4(typeof str === "string", "Invalid type");
|
|
705
629
|
const buffer = Buffer.from(str, "hex");
|
|
706
630
|
return buffer;
|
|
707
631
|
}
|
|
@@ -716,15 +640,7 @@ var PublicKey = class _PublicKey {
|
|
|
716
640
|
} else if (key instanceof Uint8Array) {
|
|
717
641
|
key = Buffer.from(key.buffer, key.byteOffset, key.byteLength);
|
|
718
642
|
}
|
|
719
|
-
invariant4(key instanceof Buffer, "Invalid type"
|
|
720
|
-
F: __dxlog_file4,
|
|
721
|
-
L: 172,
|
|
722
|
-
S: this,
|
|
723
|
-
A: [
|
|
724
|
-
"key instanceof Buffer",
|
|
725
|
-
"'Invalid type'"
|
|
726
|
-
]
|
|
727
|
-
});
|
|
643
|
+
invariant4(key instanceof Buffer, "Invalid type");
|
|
728
644
|
return key.toString("hex");
|
|
729
645
|
}
|
|
730
646
|
/**
|
|
@@ -735,15 +651,7 @@ var PublicKey = class _PublicKey {
|
|
|
735
651
|
return key.toHex();
|
|
736
652
|
}
|
|
737
653
|
static fromMultibase32(encoded) {
|
|
738
|
-
invariant4(encoded.startsWith("B"), "Invalid multibase32 encoding"
|
|
739
|
-
F: __dxlog_file4,
|
|
740
|
-
L: 185,
|
|
741
|
-
S: this,
|
|
742
|
-
A: [
|
|
743
|
-
"encoded.startsWith('B')",
|
|
744
|
-
"'Invalid multibase32 encoding'"
|
|
745
|
-
]
|
|
746
|
-
});
|
|
654
|
+
invariant4(encoded.startsWith("B"), "Invalid multibase32 encoding");
|
|
747
655
|
return new _PublicKey(new Uint8Array((0, import_base32_decode3.default)(encoded.slice(1), "RFC4648")));
|
|
748
656
|
}
|
|
749
657
|
constructor(_value) {
|
|
@@ -770,7 +678,7 @@ var PublicKey = class _PublicKey {
|
|
|
770
678
|
toMultibase32() {
|
|
771
679
|
return "B" + base32Encode(this._value, "RFC4648");
|
|
772
680
|
}
|
|
773
|
-
truncate(length
|
|
681
|
+
truncate(length) {
|
|
774
682
|
return truncateKey(this, length);
|
|
775
683
|
}
|
|
776
684
|
asBuffer() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js", "../../../src/dxn.ts", "../../../src/object-id.ts", "../../../src/space-id.ts", "../../../../../../node_modules/.pnpm/to-data-view@2.0.0/node_modules/to-data-view/index.js", "../../../../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js", "../../../src/random-bytes.ts", "../../../src/identity-did.ts", "../../../src/public-key.ts"],
|
|
4
|
-
"sourcesContent": ["var RFC4648 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'\nvar RFC4648_HEX = '0123456789ABCDEFGHIJKLMNOPQRSTUV'\nvar CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'\n\nfunction readChar (alphabet, char) {\n var idx = alphabet.indexOf(char)\n\n if (idx === -1) {\n throw new Error('Invalid character found: ' + char)\n }\n\n return idx\n}\n\nmodule.exports = function base32Decode (input, variant) {\n var alphabet\n\n switch (variant) {\n case 'RFC3548':\n case 'RFC4648':\n alphabet = RFC4648\n input = input.replace(/=+$/, '')\n break\n case 'RFC4648-HEX':\n alphabet = RFC4648_HEX\n input = input.replace(/=+$/, '')\n break\n case 'Crockford':\n alphabet = CROCKFORD\n input = input.toUpperCase().replace(/O/g, '0').replace(/[IL]/g, '1')\n break\n default:\n throw new Error('Unknown base32 variant: ' + variant)\n }\n\n var length = input.length\n\n var bits = 0\n var value = 0\n\n var index = 0\n var output = new Uint8Array((length * 5 / 8) | 0)\n\n for (var i = 0; i < length; i++) {\n value = (value << 5) | readChar(alphabet, input[i])\n bits += 5\n\n if (bits >= 8) {\n output[index++] = (value >>> (bits - 8)) & 255\n bits -= 8\n }\n }\n\n return output.buffer\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { InspectOptionsStylized, inspect } from 'node:util';\n\nimport * as Schema from 'effect/Schema';\n\nimport { type DevtoolsFormatter, devtoolsFormatter, inspectCustom } from '@dxos/debug';\nimport { assertArgument, invariant } from '@dxos/invariant';\n\nimport { ObjectId } from './object-id';\nimport { SpaceId } from './space-id';\n\n/**\n * Tags for ECHO DXNs that should resolve the object ID in the local space.\n */\n// TODO(dmaretskyi): Rebrand this as \"unknown location\" to specify objects in the same space or queue. Essentially making the DXN it a URI not URL\n// TODO(dmaretskyi): \"@\" is a separator character in the URI spec.\nexport const LOCAL_SPACE_TAG = '@';\n\nexport const DXN_ECHO_REGEXP = /@(dxn:[a-zA-Z0-p:@]+)/;\n\n// TODO(burdon): Namespace for.\nexport const QueueSubspaceTags = Object.freeze({\n DATA: 'data',\n TRACE: 'trace',\n});\n\nexport type QueueSubspaceTag = (typeof QueueSubspaceTags)[keyof typeof QueueSubspaceTags];\n\n// TODO(burdon): Refactor.\n// Consider: https://github.com/multiformats/multiaddr\n// dxn:echo:[<space-id>:[<queue-id>:]]<object-id>\n// dxn:echo:[S/<space-id>:[Q/<queue-id>:]]<object-id>\n// dxn:type:dxos.org/markdown/Contact\n\n/**\n * DXN unambiguously names a resource like an ECHO object, schema definition, plugin, etc.\n * Each DXN starts with a dxn prefix, followed by a resource kind.\n * Colon Symbol : is used a delimiter between parts.\n * DXNs may contain slashes.\n * '@' in the place of the space id is used to denote that the DXN should be resolved in the local space.\n *\n * @example\n * ```\n * dxn:echo:<space key>:<echo id>\n * dxn:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6\n * dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6\n * dxn:type:dxos.org/type/Calendar\n * dxn:plugin:dxos.org/agent/plugin/functions\n * ```\n */\nexport class DXN {\n // TODO(burdon): Rename to DXN (i.e., DXN.DXN).\n // TODO(dmaretskyi): Should this be a transformation into the DXN type?\n static Schema = Schema.NonEmptyString.pipe(\n Schema.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),\n // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.\n // FormatAnnotation.set(TypeFormat.DXN),\n Schema.annotations({\n title: 'DXN',\n description: 'DXN URI',\n examples: ['dxn:type:example.com/type/MyType', 'dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6'],\n }),\n );\n\n static hash(dxn: DXN): string {\n return dxn.toString();\n }\n\n /**\n * Kind constants.\n */\n static kind = Object.freeze({\n /**\n * dxn:type:<type_name>[:<version>]\n */\n TYPE: 'type',\n\n /**\n * dxn:echo:<space_id>:<echo_id>\n * dxn:echo:@:<echo_id>\n */\n // TODO(burdon): Rename to OBJECT? (BREAKING CHANGE to update \"echo\").\n // TODO(burdon): Add separate Kind for space?\n ECHO: 'echo',\n\n /**\n * The subspace tag enables us to partition queues by usage within the context of a space.\n * dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]\n * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6\n * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6\n */\n QUEUE: 'queue',\n });\n\n /**\n * Exactly equals.\n */\n static equals(a: DXN, b: DXN): boolean {\n return a.kind === b.kind && a.parts.length === b.parts.length && a.parts.every((part, i) => part === b.parts[i]);\n }\n\n static equalsEchoId(a: DXN, b: DXN): boolean {\n const a1 = a.asEchoDXN();\n const b1 = b.asEchoDXN();\n return !!a1 && !!b1 && a1.echoId === b1.echoId;\n }\n\n // TODO(burdon): Rename isValid.\n static isDXNString(dxn: string): boolean {\n return dxn.startsWith('dxn:');\n }\n\n static parse(dxn: string): DXN {\n if (typeof dxn !== 'string') {\n throw new Error(`Invalid DXN: ${dxn}`);\n }\n const [prefix, kind, ...parts] = dxn.split(':');\n if (!(prefix === 'dxn')) {\n throw new Error(`Invalid DXN: ${dxn}`);\n }\n if (!(typeof kind === 'string' && kind.length > 0)) {\n throw new Error(`Invalid DXN: ${dxn}`);\n }\n if (!(parts.length > 0)) {\n throw new Error(`Invalid DXN: ${dxn}`);\n }\n\n return new DXN(kind, parts);\n }\n\n static tryParse(dxn: string): DXN | undefined {\n try {\n return DXN.parse(dxn);\n } catch {\n return undefined;\n }\n }\n\n /**\n * @example `dxn:type:example.com/type/Person`\n */\n static fromTypename(typename: string): DXN {\n return new DXN(DXN.kind.TYPE, [typename]);\n }\n\n /**\n * @example `dxn:type:example.com/type/Person:0.1.0`\n */\n // TODO(dmaretskyi): Consider using @ as the version separator.\n static fromTypenameAndVersion(typename: string, version: string): DXN {\n return new DXN(DXN.kind.TYPE, [typename, version]);\n }\n\n /**\n * @example `dxn:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6`\n */\n static fromSpaceAndObjectId(spaceId: SpaceId, objectId: ObjectId): DXN {\n assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);\n assertArgument(ObjectId.isValid(objectId), 'objectId', `Invalid object ID: ${objectId}`);\n return new DXN(DXN.kind.ECHO, [spaceId, objectId]);\n }\n\n /**\n * @example `dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6`\n */\n static fromLocalObjectId(id: string): DXN {\n assertArgument(ObjectId.isValid(id), 'id', `Invalid object ID: ${id}`);\n return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, id]);\n }\n\n static fromQueue(subspaceTag: QueueSubspaceTag, spaceId: SpaceId, queueId: ObjectId, objectId?: ObjectId) {\n assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);\n assertArgument(ObjectId.isValid(queueId), 'queueId', `Invalid queue ID: ${queueId}`);\n assertArgument(!objectId || ObjectId.isValid(objectId), 'objectId', `Invalid object ID: ${objectId}`);\n\n return new DXN(DXN.kind.QUEUE, [subspaceTag, spaceId, queueId, ...(objectId ? [objectId] : [])]);\n }\n\n #kind: string;\n #parts: string[];\n\n constructor(kind: string, parts: string[]) {\n assertArgument(parts.length > 0, 'parts', `Invalid DXN: ${parts}`);\n assertArgument(\n parts.every((part) => typeof part === 'string' && part.length > 0 && part.indexOf(':') === -1),\n 'parts',\n `Invalid DXN: ${parts}`,\n );\n\n // Per-type validation.\n switch (kind) {\n case DXN.kind.TYPE:\n if (parts.length > 2) {\n throw new Error('Invalid DXN.kind.TYPE');\n }\n break;\n case DXN.kind.ECHO:\n if (parts.length !== 2) {\n throw new Error('Invalid DXN.kind.ECHO');\n }\n break;\n }\n\n this.#kind = kind;\n this.#parts = parts;\n }\n\n toString(): DXN.String {\n return `dxn:${this.#kind}:${this.#parts.join(':')}` as DXN.String;\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n /**\n * Used by Node.js to get textual representation of this object when it's printed with a `console.log` statement.\n */\n [inspectCustom](depth: number, options: InspectOptionsStylized, inspectFn: typeof inspect): string {\n const printControlCode = (code: number) => {\n return `\\x1b[${code}m`;\n };\n\n return (\n printControlCode(inspectFn.colors.blueBright![0]) + this.toString() + printControlCode(inspectFn.colors.reset![0])\n );\n }\n\n get [devtoolsFormatter](): DevtoolsFormatter {\n return {\n header: () => {\n return ['span', { style: 'font-weight: bold;' }, this.toString()];\n },\n };\n }\n\n get kind() {\n return this.#kind;\n }\n\n get parts() {\n return this.#parts;\n }\n\n // TODO(burdon): Should getters fail?\n get typename() {\n invariant(this.#kind === DXN.kind.TYPE);\n return this.#parts[0];\n }\n\n equals(other: DXN): boolean {\n return DXN.equals(this, other);\n }\n\n hasTypenameOf(typename: string): boolean {\n return this.#kind === DXN.kind.TYPE && this.#parts.length === 1 && this.#parts[0] === typename;\n }\n\n isLocalObjectId(): boolean {\n return this.#kind === DXN.kind.ECHO && this.#parts[0] === LOCAL_SPACE_TAG && this.#parts.length === 2;\n }\n\n asTypeDXN(): DXN.TypeDXN | undefined {\n if (this.kind !== DXN.kind.TYPE) {\n return undefined;\n }\n\n const [type, version] = this.#parts;\n return {\n // TODO(wittjosiah): Should be `typename` for consistency.\n type,\n version: version as string | undefined,\n };\n }\n\n asEchoDXN(): DXN.EchoDXN | undefined {\n if (this.kind !== DXN.kind.ECHO) {\n return undefined;\n }\n\n const [spaceId, echoId] = this.#parts;\n return {\n spaceId: spaceId === LOCAL_SPACE_TAG ? undefined : (spaceId as SpaceId | undefined),\n // TODO(burdon): objectId.\n echoId,\n };\n }\n\n asQueueDXN(): DXN.QueueDXN | undefined {\n if (this.kind !== DXN.kind.QUEUE) {\n return undefined;\n }\n\n const [subspaceTag, spaceId, queueId, objectId] = this.#parts;\n if (typeof queueId !== 'string') {\n return undefined;\n }\n\n return {\n subspaceTag: subspaceTag as QueueSubspaceTag,\n spaceId: spaceId as SpaceId,\n queueId,\n objectId: objectId as string | undefined,\n };\n }\n\n /**\n * Produces a new DXN with the given parts appended.\n */\n extend(parts: string[]): DXN {\n return new DXN(this.#kind, [...this.#parts, ...parts]);\n }\n}\n\n/**\n * API namespace.\n */\nexport declare namespace DXN {\n /**\n * DXN represented as a javascript string.\n */\n // TODO(burdon): Use Effect branded string?\n // export const String = S.String.pipe(S.brand('DXN'));\n // export type String = S.To(typoeof String);\n export type String = string & { __DXNString: never };\n\n export type TypeDXN = {\n type: string;\n version?: string;\n };\n\n export type EchoDXN = {\n spaceId?: SpaceId;\n echoId: string; // TODO(dmaretskyi): Rename to `objectId` and use `ObjectId` for the type.\n };\n\n export type QueueDXN = {\n subspaceTag: QueueSubspaceTag;\n spaceId: SpaceId;\n queueId: string; // TODO(dmaretskyi): ObjectId.\n objectId?: string; // TODO(dmaretskyi): ObjectId.\n };\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport { type PRNG, type ULIDFactory, monotonicFactory } from 'ulidx';\n\n// TODO(dmaretskyi): Make brand.\n// export const ObjectIdBrand: unique symbol = Symbol('@dxos/echo/ObjectId');\n// export const ObjectIdSchema = Schema.ULID.pipe(S.brand(ObjectIdBrand));\nconst ObjectIdSchema = Schema.String.pipe(Schema.pattern(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i)).annotations({\n description: 'A Universally Unique Lexicographically Sortable Identifier',\n pattern: '^[0-7][0-9A-HJKMNP-TV-Z]{25}$',\n});\n\nexport type ObjectId = typeof ObjectIdSchema.Type;\n\nexport interface ObjectIdClass extends Schema.SchemaClass<ObjectId, string> {\n /**\n * @returns true if the string is a valid ObjectId.\n */\n isValid(id: string): id is ObjectId;\n\n /**\n * Creates an ObjectId from a string validating the format.\n */\n make(id: string): ObjectId;\n\n /**\n * Generates a random ObjectId.\n */\n random(): ObjectId;\n\n /**\n * WARNING: To be used only within tests.\n *\n * Disables randomness in ObjectId generation, causing the same sequence of IDs to be generated.\n * Do not use in production code as this will cause data collisions.\n * Place this at the top of the test file to ensure that the same sequence of IDs is generated.\n *\n * ```ts\n * ObjectId.dangerouslyDisableRandomness();\n *\n * describe('suite', () => {\n * // ...\n * });\n * ```\n *\n * NOTE: The generated IDs depend on the order of ObjectId.random() calls, which might be affected by test order, scheduling, etc.\n */\n dangerouslyDisableRandomness(): void;\n}\n\n/**\n * Randomly generated unique identifier for an object.\n *\n * Follows ULID spec.\n */\nexport const ObjectId: ObjectIdClass = class extends ObjectIdSchema {\n static #factory: ULIDFactory = monotonicFactory();\n static #seedTime: number | undefined = undefined;\n\n static isValid(id: string): id is ObjectId {\n try {\n Schema.decodeSync(ObjectId)(id);\n return true;\n } catch {\n return false;\n }\n }\n\n static random(): ObjectId {\n return this.#factory(this.#seedTime) as ObjectId;\n }\n\n static dangerouslyDisableRandomness() {\n this.#factory = monotonicFactory(makeTestPRNG());\n this.#seedTime = new Date('2025-01-01').getTime();\n }\n};\n\n/**\n * Test PRNG that always starts with the same seed and produces the same sequence.\n */\nconst makeTestPRNG = (): PRNG => {\n const rng = new SimplePRNG();\n return () => {\n return rng.next();\n };\n};\n\n/**\n * Simple Linear Congruential Generator (LCG) for pseudo-random number generation.\n * Returns numbers in the range [0, 1) (0 inclusive, 1 exclusive).\n */\nexport class SimplePRNG {\n #seed: number;\n\n // LCG parameters (from Numerical Recipes)\n static readonly #a = 1664525;\n static readonly #c = 1013904223;\n static readonly #m = Math.pow(2, 32);\n\n /**\n * Creates a new PRNG instance.\n * @param seed - Initial seed value. If not provided, uses 0.\n */\n constructor(seed: number = 0) {\n this.#seed = seed;\n }\n\n /**\n * Generates the next pseudo-random number in the range [0, 1).\n * @returns A pseudo-random number between 0 (inclusive) and 1 (exclusive).\n */\n next(): number {\n // Update seed using LCG formula: (a * seed + c) mod m\n this.#seed = (SimplePRNG.#a * this.#seed + SimplePRNG.#c) % SimplePRNG.#m;\n\n // Normalize to [0, 1) range\n return this.#seed / SimplePRNG.#m;\n }\n\n /**\n * Resets the generator with a new seed.\n * @param seed - New seed value.\n */\n reset(seed: number): void {\n this.#seed = seed;\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport base32Decode from 'base32-decode';\nimport base32Encode from 'base32-encode';\nimport * as Schema from 'effect/Schema';\n\nimport { invariant } from '@dxos/invariant';\n\nimport { randomBytes } from './random-bytes';\n\n/**\n * Denotes RFC4648 base-32 format.\n */\nconst MULTIBASE_PREFIX = 'B';\n\nconst ENCODED_LENGTH = 33;\n\nconst isValid = (value: unknown): value is SpaceId => {\n return typeof value === 'string' && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;\n};\n\n/**\n * A unique identifier for a space.\n * Space keys are generated by creating a keypair, and then taking the first 20 bytes of the SHA-256 hash of the public key and encoding them to multibase RFC4648 base-32 format (prefixed with B, see Multibase Table).\n * @example BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE\n */\n// TODO(burdon): Use effect branded type?\nexport type SpaceId = string & { __SpaceId: true };\n\nexport const SpaceId: Schema.Schema<SpaceId, string> & {\n byteLength: number;\n encode: (value: Uint8Array) => SpaceId;\n decode: (value: SpaceId) => Uint8Array;\n isValid: (value: unknown) => value is SpaceId;\n make: (value: string) => SpaceId;\n random: () => SpaceId;\n} = class extends Schema.String.pipe(Schema.filter(isValid)) {\n static byteLength = 20;\n\n static encode = (value: Uint8Array): SpaceId => {\n invariant(value instanceof Uint8Array, 'Invalid type');\n invariant(value.length === SpaceId.byteLength, 'Invalid length');\n return (MULTIBASE_PREFIX + base32Encode(value, 'RFC4648')) as SpaceId;\n };\n\n static decode = (value: SpaceId): Uint8Array => {\n invariant(value.startsWith(MULTIBASE_PREFIX), 'Invalid multibase32 encoding');\n return new Uint8Array(base32Decode(value.slice(1), 'RFC4648'));\n };\n\n static isValid = isValid;\n\n static random = (): SpaceId => {\n return SpaceId.encode(randomBytes(SpaceId.byteLength));\n };\n};\n", "export default function toDataView (data) {\n if (data instanceof Int8Array || data instanceof Uint8Array || data instanceof Uint8ClampedArray) {\n return new DataView(data.buffer, data.byteOffset, data.byteLength)\n }\n\n if (data instanceof ArrayBuffer) {\n return new DataView(data)\n }\n\n throw new TypeError('Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray')\n}\n", "import toDataView from 'to-data-view'\n\nconst RFC4648 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'\nconst RFC4648_HEX = '0123456789ABCDEFGHIJKLMNOPQRSTUV'\nconst CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'\n\nexport default function base32Encode (data, variant, options) {\n options = options || {}\n let alphabet, defaultPadding\n\n switch (variant) {\n case 'RFC3548':\n case 'RFC4648':\n alphabet = RFC4648\n defaultPadding = true\n break\n case 'RFC4648-HEX':\n alphabet = RFC4648_HEX\n defaultPadding = true\n break\n case 'Crockford':\n alphabet = CROCKFORD\n defaultPadding = false\n break\n default:\n throw new Error('Unknown base32 variant: ' + variant)\n }\n\n const padding = (options.padding !== undefined ? options.padding : defaultPadding)\n const view = toDataView(data)\n\n let bits = 0\n let value = 0\n let output = ''\n\n for (let i = 0; i < view.byteLength; i++) {\n value = (value << 8) | view.getUint8(i)\n bits += 8\n\n while (bits >= 5) {\n output += alphabet[(value >>> (bits - 5)) & 31]\n bits -= 5\n }\n }\n\n if (bits > 0) {\n output += alphabet[(value << (5 - bits)) & 31]\n }\n\n if (padding) {\n while ((output.length % 8) !== 0) {\n output += '='\n }\n }\n\n return output\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport const randomBytes = (length: number) => {\n // globalThis.crypto is not available in Node.js when running in vitest even though the documentation says it should be.\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const webCrypto = globalThis.crypto ?? require('node:crypto').webcrypto;\n\n const bytes = new Uint8Array(length);\n webCrypto.getRandomValues(bytes);\n return bytes;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport base32Decode from 'base32-decode';\nimport base32Encode from 'base32-encode';\n\nimport { invariant } from '@dxos/invariant';\n\nimport { randomBytes } from './random-bytes';\n\n/**\n * A unique identifier for an identity.\n * Identity DIDs are generated by creating a keypair, and then taking the first 20 bytes of the SHA-256 hash of the public key and encoding them to multibase RFC4648 base-32 format (prefixed with B, see Multibase Table).\n * @example did:halo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE\n */\nexport type IdentityDid = string & { __IdentityDid: never };\n\nexport const IdentityDid = Object.freeze({\n byteLength: 20,\n encode: (value: Uint8Array): IdentityDid => {\n invariant(value instanceof Uint8Array, 'Invalid type');\n invariant(value.length === IdentityDid.byteLength, 'Invalid length');\n\n return (DID_PREFIX + MULTIBASE_PREFIX + base32Encode(value, 'RFC4648')) as IdentityDid;\n },\n decode: (value: IdentityDid): Uint8Array => {\n invariant(value.startsWith(DID_PREFIX + MULTIBASE_PREFIX), 'Invalid multibase32 encoding');\n\n return new Uint8Array(base32Decode(value.slice(10), 'RFC4648'));\n },\n isValid: (value: string): value is IdentityDid => {\n return (\n typeof value === 'string' && value.startsWith(DID_PREFIX + MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH\n );\n },\n random: (): IdentityDid => {\n return IdentityDid.encode(randomBytes(IdentityDid.byteLength));\n },\n});\n\n/**\n * Denotes RFC4648 base-32 format.\n */\nconst MULTIBASE_PREFIX = 'B';\n\nconst DID_PREFIX = 'did:halo:';\n\nconst ENCODED_LENGTH = 42;\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type InspectOptionsStylized, type inspect } from 'node:util';\n\nimport base32Decode from 'base32-decode';\nimport base32Encode from 'base32-encode';\n\nimport {\n type DevtoolsFormatter,\n type Equatable,\n devtoolsFormatter,\n equalsSymbol,\n inspectCustom,\n truncateKey,\n} from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\n\nimport { randomBytes } from './random-bytes';\n\nexport const PUBLIC_KEY_LENGTH = 32;\nexport const SECRET_KEY_LENGTH = 64;\n\n/**\n * All representations that can be converted to a PublicKey.\n */\nexport type PublicKeyLike = PublicKey | Buffer | Uint8Array | ArrayBuffer | string;\n\n/**\n * Vitest with JSDom causes instanceof ArrayBuffer check to fail\n */\nconst isLikeArrayBuffer = (value: any): value is ArrayBuffer =>\n typeof value === 'object' && value !== null && Object.getPrototypeOf(value).constructor.name === 'ArrayBuffer';\n\n/**\n * The purpose of this class is to assure consistent use of keys throughout the project.\n * Keys should be maintained as buffers in objects and proto definitions, and converted to hex\n * strings as late as possible (eg, to log/display).\n */\nexport class PublicKey implements Equatable {\n static ZERO = PublicKey.from('00'.repeat(PUBLIC_KEY_LENGTH));\n\n /**\n * Creates new instance of PublicKey automatically determining the input format.\n * @param source A Buffer, or Uint8Array, or hex encoded string, or something with an `asUint8Array` method on it\n * @returns PublicKey\n */\n static from(source: PublicKeyLike): PublicKey {\n invariant(source);\n if (source instanceof PublicKey) {\n return source;\n } else if (source instanceof Buffer) {\n return new PublicKey(new Uint8Array(source.buffer, source.byteOffset, source.byteLength));\n } else if (source instanceof Uint8Array) {\n return new PublicKey(source);\n } else if (source instanceof ArrayBuffer || isLikeArrayBuffer(source)) {\n return new PublicKey(new Uint8Array(source));\n } else if (typeof source === 'string') {\n // TODO(burdon): Check length.\n return PublicKey.fromHex(source);\n } else if ((<any>source).asUint8Array) {\n return new PublicKey((<any>source).asUint8Array());\n } else {\n throw new TypeError(`Unable to create PublicKey from ${source}`);\n }\n }\n\n /**\n * Same as `PublicKey.from` but does not throw and instead returns a `{ key: PublicKey }` or `{ error: Error }`\n * @param source Same PublicKeyLike argument as for `PublicKey.from`\n * @returns PublicKey\n */\n static safeFrom(source?: PublicKeyLike): PublicKey | undefined {\n if (!source) {\n return undefined;\n }\n\n try {\n const key = PublicKey.from(source);\n // TODO(wittjosiah): Space keys don't pass this check.\n // if (key.length !== PUBLIC_KEY_LENGTH && key.length !== SECRET_KEY_LENGTH) {\n // return undefined;\n // }\n return key;\n } catch (err: any) {\n return undefined;\n }\n }\n\n /**\n * Creates new instance of PublicKey from hex string.\n */\n static fromHex(hex: string): PublicKey {\n if (hex.startsWith('0x')) {\n hex = hex.slice(2);\n }\n\n const buf = Buffer.from(hex, 'hex');\n // TODO(burdon): Test if key.\n return new PublicKey(new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength));\n }\n\n /**\n * Creates a new key.\n */\n static random(): PublicKey {\n // TODO(burdon): Enable seed for debugging.\n return PublicKey.from(randomBytes(PUBLIC_KEY_LENGTH));\n }\n\n static randomOfLength(length: number): PublicKey {\n return PublicKey.from(randomBytes(length));\n }\n\n static *randomSequence(): Generator<PublicKey> {\n for (let i = 0; i < 1_0000; i++) {\n // Counter just to protect against infinite loops.\n yield PublicKey.random();\n }\n throw new Error('Too many keys requested');\n }\n\n /**\n * Tests if provided values is an instance of PublicKey.\n */\n static isPublicKey(value: any): value is PublicKey {\n return value instanceof PublicKey;\n }\n\n /**\n * Asserts that provided values is an instance of PublicKey.\n */\n static assertValidPublicKey(value: any): asserts value is PublicKey {\n if (!this.isPublicKey(value)) {\n throw new TypeError('Invalid PublicKey');\n }\n }\n\n /**\n * Tests two keys for equality.\n */\n static equals(left: PublicKeyLike, right: PublicKeyLike): boolean {\n return PublicKey.from(left).equals(right);\n }\n\n /**\n * @param str string representation of key.\n * @return Key buffer.\n * @deprecated All keys should be represented as instances of PublicKey.\n */\n static bufferize(str: string): Buffer {\n invariant(typeof str === 'string', 'Invalid type');\n const buffer = Buffer.from(str, 'hex');\n // invariant(buffer.length === PUBLIC_KEY_LENGTH || buffer.length === SECRET_KEY_LENGTH,\n // `Invalid key length: ${buffer.length}`);\n return buffer;\n }\n\n /**\n * @param key key like data structure (but not PublicKey which should use toString).\n * @return Hex string representation of key.\n * @deprecated All keys should be represented as instances of PublicKey.\n */\n static stringify(key: Buffer | Uint8Array | ArrayBuffer): string {\n if (key instanceof PublicKey) {\n key = key.asBuffer();\n } else if (key instanceof Uint8Array) {\n key = Buffer.from(key.buffer, key.byteOffset, key.byteLength);\n }\n\n invariant(key instanceof Buffer, 'Invalid type');\n return key.toString('hex');\n }\n\n /**\n * To be used with ComplexMap and ComplexSet.\n * Returns a scalar representation for this key.\n */\n static hash(key: PublicKey): string {\n return key.toHex();\n }\n\n static fromMultibase32(encoded: string): PublicKey {\n invariant(encoded.startsWith('B'), 'Invalid multibase32 encoding');\n\n return new PublicKey(new Uint8Array(base32Decode(encoded.slice(1), 'RFC4648')));\n }\n\n constructor(private readonly _value: Uint8Array) {\n if (!(_value instanceof Uint8Array)) {\n throw new TypeError(`Expected Uint8Array, got: ${_value}`);\n }\n }\n\n toString(): string {\n return this.toHex();\n }\n\n toJSON(): string {\n return this.toHex();\n }\n\n toJSONL(): string {\n return this.truncate();\n }\n\n get length() {\n return this._value.length;\n }\n\n toHex(): string {\n return this.asBuffer().toString('hex');\n }\n\n toMultibase32(): string {\n return 'B' + base32Encode(this._value, 'RFC4648');\n }\n\n truncate(length = undefined): string {\n return truncateKey(this, length);\n }\n\n asBuffer(): Buffer {\n return Buffer.from(this._value.buffer, this._value.byteOffset, this._value.byteLength);\n }\n\n asUint8Array(): Uint8Array {\n return this._value;\n }\n\n getInsecureHash(modulo: number): number {\n return Math.abs(this._value.reduce((acc, val) => (acc ^ val) | 0, 0)) % modulo;\n }\n\n /**\n * Used by Node.js to get textual representation of this object when it's printed with a `console.log` statement.\n */\n [inspectCustom](depth: number, options: InspectOptionsStylized, inspectFn: typeof inspect): string {\n if (!options.colors || typeof process.stdout.hasColors !== 'function' || !process.stdout.hasColors()) {\n return `<PublicKey ${this.truncate()}>`;\n }\n\n const printControlCode = (code: number) => {\n return `\\x1b[${code}m`;\n };\n\n // NOTE: Keep in sync with formatter colors.\n const colors = [\n 'red',\n 'green',\n 'yellow',\n 'blue',\n 'magenta',\n 'cyan',\n 'redBright',\n 'greenBright',\n 'yellowBright',\n 'blueBright',\n 'magentaBright',\n 'cyanBright',\n 'whiteBright',\n ];\n const color = colors[this.getInsecureHash(colors.length)];\n\n return `PublicKey(${printControlCode(inspectFn.colors[color]![0])}${this.truncate()}${printControlCode(\n inspectFn.colors.reset![0],\n )})`;\n }\n\n get [devtoolsFormatter](): DevtoolsFormatter {\n return {\n header: () => {\n // NOTE: Keep in sync with inspect colors.\n const colors = [\n 'darkred',\n 'green',\n 'orange',\n 'blue',\n 'darkmagenta',\n 'darkcyan',\n 'red',\n 'green',\n 'orange',\n 'blue',\n 'magenta',\n 'darkcyan',\n 'black',\n ];\n const color = colors[this.getInsecureHash(colors.length)];\n\n return [\n 'span',\n {},\n ['span', {}, 'PublicKey('],\n ['span', { style: `color: ${color};` }, this.truncate()],\n ['span', {}, ')'],\n ];\n },\n };\n }\n\n /**\n * Test this key for equality with some other key.\n */\n equals(other: PublicKeyLike): boolean {\n const otherConverted = PublicKey.from(other);\n if (this._value.length !== otherConverted._value.length) {\n return false;\n }\n\n let equal = true;\n for (let i = 0; i < this._value.length; i++) {\n equal &&= this._value[i] === otherConverted._value[i];\n }\n\n return equal;\n }\n\n [equalsSymbol](other: any): boolean {\n if (!PublicKey.isPublicKey(other)) {\n return false;\n }\n\n return this.equals(other);\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,QAAIA,WAAU;AACd,QAAIC,eAAc;AAClB,QAAIC,aAAY;AAEhB,aAAS,SAAU,UAAU,MAAM;AACjC,UAAI,MAAM,SAAS,QAAQ,IAAI;AAE/B,UAAI,QAAQ,IAAI;AACd,cAAM,IAAI,MAAM,8BAA8B,IAAI;AAAA,MACpD;AAEA,aAAO;AAAA,IACT;AAEA,WAAO,UAAU,SAASC,cAAc,OAAO,SAAS;AACtD,UAAI;AAEJ,cAAQ,SAAS;AAAA,QACf,KAAK;AAAA,QACL,KAAK;AACH,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648", "RFC4648_HEX", "CROCKFORD", "base32Decode", "Schema", "devtoolsFormatter", "inspectCustom", "assertArgument", "invariant", "Schema", "monotonicFactory", "ObjectIdSchema", "String", "pipe", "pattern", "annotations", "description", "ObjectId", "
|
|
4
|
+
"sourcesContent": ["var RFC4648 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'\nvar RFC4648_HEX = '0123456789ABCDEFGHIJKLMNOPQRSTUV'\nvar CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'\n\nfunction readChar (alphabet, char) {\n var idx = alphabet.indexOf(char)\n\n if (idx === -1) {\n throw new Error('Invalid character found: ' + char)\n }\n\n return idx\n}\n\nmodule.exports = function base32Decode (input, variant) {\n var alphabet\n\n switch (variant) {\n case 'RFC3548':\n case 'RFC4648':\n alphabet = RFC4648\n input = input.replace(/=+$/, '')\n break\n case 'RFC4648-HEX':\n alphabet = RFC4648_HEX\n input = input.replace(/=+$/, '')\n break\n case 'Crockford':\n alphabet = CROCKFORD\n input = input.toUpperCase().replace(/O/g, '0').replace(/[IL]/g, '1')\n break\n default:\n throw new Error('Unknown base32 variant: ' + variant)\n }\n\n var length = input.length\n\n var bits = 0\n var value = 0\n\n var index = 0\n var output = new Uint8Array((length * 5 / 8) | 0)\n\n for (var i = 0; i < length; i++) {\n value = (value << 5) | readChar(alphabet, input[i])\n bits += 5\n\n if (bits >= 8) {\n output[index++] = (value >>> (bits - 8)) & 255\n bits -= 8\n }\n }\n\n return output.buffer\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport type { InspectOptionsStylized, inspect } from 'node:util';\n\nimport { type DevtoolsFormatter, devtoolsFormatter, inspectCustom } from '@dxos/debug';\nimport { assertArgument, invariant } from '@dxos/invariant';\n\nimport { ObjectId } from './object-id';\nimport { SpaceId } from './space-id';\n\n/**\n * Tags for ECHO DXNs that should resolve the object ID in the local space.\n */\n// TODO(dmaretskyi): Rebrand this as \"unknown location\" to specify objects in the same space or queue. Essentially making the DXN it a URI not URL\n// TODO(dmaretskyi): \"@\" is a separator character in the URI spec.\nexport const LOCAL_SPACE_TAG = '@';\n\nexport const DXN_ECHO_REGEXP = /@(dxn:[a-zA-Z0-p:@]+)/;\n\n// TODO(burdon): Namespace for.\nexport const QueueSubspaceTags = Object.freeze({\n DATA: 'data',\n TRACE: 'trace',\n});\n\nexport type QueueSubspaceTag = (typeof QueueSubspaceTags)[keyof typeof QueueSubspaceTags];\n\n// TODO(burdon): Refactor.\n// Consider: https://github.com/multiformats/multiaddr\n// dxn:echo:[<space-id>:[<queue-id>:]]<object-id>\n// dxn:echo:[S/<space-id>:[Q/<queue-id>:]]<object-id>\n// dxn:type:org.dxos.markdown.contact\n\n/**\n * DXN unambiguously names a resource like an ECHO object, schema definition, plugin, etc.\n * Each DXN starts with a dxn prefix, followed by a resource kind.\n * Colon Symbol : is used a delimiter between parts.\n * DXNs may contain slashes.\n * '@' in the place of the space id is used to denote that the DXN should be resolved in the local space.\n *\n * @example\n * ```\n * dxn:echo:<space key>:<echo id>\n * dxn:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6\n * dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6\n * dxn:type:org.dxos.type.calendar\n * dxn:plugin:org.dxos.agent.plugin.functions\n * ```\n */\nexport class DXN {\n // TODO(burdon): Rename to DXN (i.e., DXN.DXN).\n // TODO(dmaretskyi): Should this be a transformation into the DXN type?\n static Schema = Schema.NonEmptyString.pipe(\n Schema.pattern(/^dxn:([^:]+):(?:[^:]+:?)+[^:]$/),\n // TODO(dmaretskyi): To set the format we need to move the annotation IDs out of the echo-schema package.\n // FormatAnnotation.set(TypeFormat.DXN),\n Schema.annotations({\n title: 'DXN',\n description: 'DXN URI',\n examples: ['dxn:type:com.example.type.my-type', 'dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6'],\n }),\n );\n\n static hash(dxn: DXN): string {\n return dxn.toString();\n }\n\n /**\n * Kind constants.\n */\n static kind = Object.freeze({\n /**\n * dxn:type:<type_name>[:<version>]\n */\n TYPE: 'type',\n\n /**\n * dxn:echo:<space_id>:<echo_id>\n * dxn:echo:@:<echo_id>\n */\n // TODO(burdon): Rename to OBJECT? (BREAKING CHANGE to update \"echo\").\n // TODO(burdon): Add separate Kind for space?\n ECHO: 'echo',\n\n /**\n * The subspace tag enables us to partition queues by usage within the context of a space.\n * dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]\n * dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6\n * dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6\n */\n QUEUE: 'queue',\n });\n\n /**\n * Exactly equals.\n */\n static equals(a: DXN, b: DXN): boolean {\n return a.kind === b.kind && a.parts.length === b.parts.length && a.parts.every((part, i) => part === b.parts[i]);\n }\n\n static equalsEchoId(a: DXN, b: DXN): boolean {\n const a1 = a.asEchoDXN();\n const b1 = b.asEchoDXN();\n return !!a1 && !!b1 && a1.echoId === b1.echoId;\n }\n\n // TODO(burdon): Rename isValid.\n static isDXNString(dxn: string): boolean {\n return dxn.startsWith('dxn:');\n }\n\n static parse(dxn: string): DXN {\n if (typeof dxn !== 'string') {\n throw new Error(`Invalid DXN: ${dxn}`);\n }\n const [prefix, kind, ...parts] = dxn.split(':');\n if (!(prefix === 'dxn')) {\n throw new Error(`Invalid DXN: ${dxn}`);\n }\n if (!(typeof kind === 'string' && kind.length > 0)) {\n throw new Error(`Invalid DXN: ${dxn}`);\n }\n if (!(parts.length > 0)) {\n throw new Error(`Invalid DXN: ${dxn}`);\n }\n\n return new DXN(kind, parts);\n }\n\n static tryParse(dxn: string): DXN | undefined {\n try {\n return DXN.parse(dxn);\n } catch {\n return undefined;\n }\n }\n\n /**\n * @example `dxn:type:com.example.type.person`\n */\n static fromTypename(typename: string): DXN {\n return new DXN(DXN.kind.TYPE, [typename]);\n }\n\n /**\n * @example `dxn:type:com.example.type.person:0.1.0`\n */\n // TODO(dmaretskyi): Consider using @ as the version separator.\n static fromTypenameAndVersion(typename: string, version: string): DXN {\n return new DXN(DXN.kind.TYPE, [typename, version]);\n }\n\n /**\n * @example `dxn:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6`\n */\n static fromSpaceAndObjectId(spaceId: SpaceId, objectId: ObjectId): DXN {\n assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);\n assertArgument(ObjectId.isValid(objectId), 'objectId', `Invalid object ID: ${objectId}`);\n return new DXN(DXN.kind.ECHO, [spaceId, objectId]);\n }\n\n /**\n * @example `dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6`\n */\n static fromLocalObjectId(id: string): DXN {\n assertArgument(ObjectId.isValid(id), 'id', `Invalid object ID: ${id}`);\n return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, id]);\n }\n\n static fromQueue(subspaceTag: QueueSubspaceTag, spaceId: SpaceId, queueId: ObjectId, objectId?: ObjectId) {\n assertArgument(SpaceId.isValid(spaceId), `Invalid space ID: ${spaceId}`);\n assertArgument(ObjectId.isValid(queueId), 'queueId', `Invalid queue ID: ${queueId}`);\n assertArgument(!objectId || ObjectId.isValid(objectId), 'objectId', `Invalid object ID: ${objectId}`);\n\n return new DXN(DXN.kind.QUEUE, [subspaceTag, spaceId, queueId, ...(objectId ? [objectId] : [])]);\n }\n\n #kind: string;\n #parts: string[];\n\n constructor(kind: string, parts: string[]) {\n assertArgument(parts.length > 0, 'parts', `Invalid DXN: ${parts}`);\n assertArgument(\n parts.every((part) => typeof part === 'string' && part.length > 0 && part.indexOf(':') === -1),\n 'parts',\n `Invalid DXN: ${parts}`,\n );\n\n // Per-type validation.\n switch (kind) {\n case DXN.kind.TYPE:\n if (parts.length > 2) {\n throw new Error('Invalid DXN.kind.TYPE');\n }\n break;\n case DXN.kind.ECHO:\n if (parts.length !== 2) {\n throw new Error('Invalid DXN.kind.ECHO');\n }\n break;\n }\n\n this.#kind = kind;\n this.#parts = parts;\n }\n\n toString(): DXN.String {\n return `dxn:${this.#kind}:${this.#parts.join(':')}` as DXN.String;\n }\n\n toJSON(): string {\n return this.toString();\n }\n\n /**\n * Used by Node.js to get textual representation of this object when it's printed with a `console.log` statement.\n */\n [inspectCustom](depth: number, options: InspectOptionsStylized, inspectFn: typeof inspect): string {\n const printControlCode = (code: number) => {\n return `\\x1b[${code}m`;\n };\n\n return (\n printControlCode(inspectFn.colors.blueBright![0]) + this.toString() + printControlCode(inspectFn.colors.reset![0])\n );\n }\n\n get [devtoolsFormatter](): DevtoolsFormatter {\n return {\n header: () => {\n return ['span', { style: 'font-weight: bold;' }, this.toString()];\n },\n };\n }\n\n get kind() {\n return this.#kind;\n }\n\n get parts() {\n return this.#parts;\n }\n\n // TODO(burdon): Should getters fail?\n get typename() {\n invariant(this.#kind === DXN.kind.TYPE);\n return this.#parts[0];\n }\n\n equals(other: DXN): boolean {\n return DXN.equals(this, other);\n }\n\n hasTypenameOf(typename: string): boolean {\n return this.#kind === DXN.kind.TYPE && this.#parts.length === 1 && this.#parts[0] === typename;\n }\n\n isLocalObjectId(): boolean {\n return this.#kind === DXN.kind.ECHO && this.#parts[0] === LOCAL_SPACE_TAG && this.#parts.length === 2;\n }\n\n asTypeDXN(): DXN.TypeDXN | undefined {\n if (this.kind !== DXN.kind.TYPE) {\n return undefined;\n }\n\n const [type, version] = this.#parts;\n return {\n // TODO(wittjosiah): Should be `typename` for consistency.\n type,\n version: version as string | undefined,\n };\n }\n\n asEchoDXN(): DXN.EchoDXN | undefined {\n if (this.kind !== DXN.kind.ECHO) {\n return undefined;\n }\n\n const [spaceId, echoId] = this.#parts;\n return {\n spaceId: spaceId === LOCAL_SPACE_TAG ? undefined : (spaceId as SpaceId | undefined),\n // TODO(burdon): objectId.\n echoId,\n };\n }\n\n asQueueDXN(): DXN.QueueDXN | undefined {\n if (this.kind !== DXN.kind.QUEUE) {\n return undefined;\n }\n\n const [subspaceTag, spaceId, queueId, objectId] = this.#parts;\n if (typeof queueId !== 'string') {\n return undefined;\n }\n\n return {\n subspaceTag: subspaceTag as QueueSubspaceTag,\n spaceId: spaceId as SpaceId,\n queueId,\n objectId: objectId as string | undefined,\n };\n }\n\n /**\n * Produces a new DXN with the given parts appended.\n */\n extend(parts: string[]): DXN {\n return new DXN(this.#kind, [...this.#parts, ...parts]);\n }\n}\n\n/**\n * API namespace.\n */\nexport declare namespace DXN {\n /**\n * DXN represented as a javascript string.\n */\n // TODO(burdon): Use Effect branded string?\n // export const String = S.String.pipe(S.brand('DXN'));\n // export type String = S.To(typoeof String);\n export type String = string & { __DXNString: never };\n\n export type TypeDXN = {\n type: string;\n version?: string;\n };\n\n export type EchoDXN = {\n spaceId?: SpaceId;\n echoId: string; // TODO(dmaretskyi): Rename to `objectId` and use `ObjectId` for the type.\n };\n\n export type QueueDXN = {\n subspaceTag: QueueSubspaceTag;\n spaceId: SpaceId;\n queueId: string; // TODO(dmaretskyi): ObjectId.\n objectId?: string; // TODO(dmaretskyi): ObjectId.\n };\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport { type PRNG, type ULIDFactory, monotonicFactory } from 'ulidx';\n\n// TODO(dmaretskyi): Make brand.\n// export const ObjectIdBrand: unique symbol = Symbol('@dxos/echo/ObjectId');\n// export const ObjectIdSchema = Schema.ULID.pipe(S.brand(ObjectIdBrand));\nconst ObjectIdSchema = Schema.String.pipe(Schema.pattern(/^[0-7][0-9A-HJKMNP-TV-Z]{25}$/i)).annotations({\n description: 'A Universally Unique Lexicographically Sortable Identifier',\n pattern: '^[0-7][0-9A-HJKMNP-TV-Z]{25}$',\n});\n\nexport type ObjectId = typeof ObjectIdSchema.Type;\n\nexport interface ObjectIdClass extends Schema.SchemaClass<ObjectId, string> {\n /**\n * @returns true if the string is a valid ObjectId.\n */\n isValid(id: string): id is ObjectId;\n\n /**\n * Creates an ObjectId from a string validating the format.\n */\n make(id: string): ObjectId;\n\n /**\n * Generates a random ObjectId.\n */\n random(): ObjectId;\n\n /**\n * WARNING: To be used only within tests.\n *\n * Disables randomness in ObjectId generation, causing the same sequence of IDs to be generated.\n * Do not use in production code as this will cause data collisions.\n * Place this at the top of the test file to ensure that the same sequence of IDs is generated.\n *\n * ```ts\n * ObjectId.dangerouslyDisableRandomness();\n *\n * describe('suite', () => {\n * // ...\n * });\n * ```\n *\n * NOTE: The generated IDs depend on the order of ObjectId.random() calls, which might be affected by test order, scheduling, etc.\n */\n dangerouslyDisableRandomness(): void;\n}\n\n/**\n * Randomly generated unique identifier for an object.\n *\n * Follows ULID spec.\n */\nexport const ObjectId: ObjectIdClass = class extends ObjectIdSchema {\n static #factory: ULIDFactory = monotonicFactory();\n static #seedTime: number | undefined = undefined;\n\n static isValid(id: string): id is ObjectId {\n try {\n Schema.decodeSync(ObjectId)(id);\n return true;\n } catch {\n return false;\n }\n }\n\n static random(): ObjectId {\n return this.#factory(this.#seedTime) as ObjectId;\n }\n\n static dangerouslyDisableRandomness() {\n this.#factory = monotonicFactory(makeTestPRNG());\n this.#seedTime = new Date('2025-01-01').getTime();\n }\n};\n\n/**\n * Test PRNG that always starts with the same seed and produces the same sequence.\n */\nconst makeTestPRNG = (): PRNG => {\n const rng = new SimplePRNG();\n return () => {\n return rng.next();\n };\n};\n\n/**\n * Simple Linear Congruential Generator (LCG) for pseudo-random number generation.\n * Returns numbers in the range [0, 1) (0 inclusive, 1 exclusive).\n */\nexport class SimplePRNG {\n #seed: number;\n\n // LCG parameters (from Numerical Recipes)\n static readonly #a = 1664525;\n static readonly #c = 1013904223;\n static readonly #m = Math.pow(2, 32);\n\n /**\n * Creates a new PRNG instance.\n * @param seed - Initial seed value. If not provided, uses 0.\n */\n constructor(seed: number = 0) {\n this.#seed = seed;\n }\n\n /**\n * Generates the next pseudo-random number in the range [0, 1).\n * @returns A pseudo-random number between 0 (inclusive) and 1 (exclusive).\n */\n next(): number {\n // Update seed using LCG formula: (a * seed + c) mod m\n this.#seed = (SimplePRNG.#a * this.#seed + SimplePRNG.#c) % SimplePRNG.#m;\n\n // Normalize to [0, 1) range\n return this.#seed / SimplePRNG.#m;\n }\n\n /**\n * Resets the generator with a new seed.\n * @param seed - New seed value.\n */\n reset(seed: number): void {\n this.#seed = seed;\n }\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport base32Decode from 'base32-decode';\nimport base32Encode from 'base32-encode';\nimport * as Schema from 'effect/Schema';\n\nimport { invariant } from '@dxos/invariant';\n\nimport { randomBytes } from './random-bytes';\n\n/**\n * Denotes RFC4648 base-32 format.\n */\nconst MULTIBASE_PREFIX = 'B';\n\nconst ENCODED_LENGTH = 33;\n\nconst isValid = (value: unknown): value is SpaceId => {\n return typeof value === 'string' && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;\n};\n\n/**\n * A unique identifier for a space.\n * Space keys are generated by creating a keypair, and then taking the first 20 bytes of the SHA-256 hash of the public key and encoding them to multibase RFC4648 base-32 format (prefixed with B, see Multibase Table).\n * @example BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE\n */\n// TODO(burdon): Use effect branded type?\nexport type SpaceId = string & { __SpaceId: true };\n\nexport const SpaceId: Schema.Schema<SpaceId, string> & {\n byteLength: number;\n encode: (value: Uint8Array) => SpaceId;\n decode: (value: SpaceId) => Uint8Array;\n isValid: (value: unknown) => value is SpaceId;\n make: (value: string) => SpaceId;\n random: () => SpaceId;\n} = class extends Schema.String.pipe(Schema.filter(isValid)) {\n static byteLength = 20;\n\n static encode = (value: Uint8Array): SpaceId => {\n invariant(value instanceof Uint8Array, 'Invalid type');\n invariant(value.length === SpaceId.byteLength, 'Invalid length');\n return (MULTIBASE_PREFIX + base32Encode(value, 'RFC4648')) as SpaceId;\n };\n\n static decode = (value: SpaceId): Uint8Array => {\n invariant(value.startsWith(MULTIBASE_PREFIX), 'Invalid multibase32 encoding');\n return new Uint8Array(base32Decode(value.slice(1), 'RFC4648'));\n };\n\n static isValid = isValid;\n\n static random = (): SpaceId => {\n return SpaceId.encode(randomBytes(SpaceId.byteLength));\n };\n};\n", "export default function toDataView (data) {\n if (data instanceof Int8Array || data instanceof Uint8Array || data instanceof Uint8ClampedArray) {\n return new DataView(data.buffer, data.byteOffset, data.byteLength)\n }\n\n if (data instanceof ArrayBuffer) {\n return new DataView(data)\n }\n\n throw new TypeError('Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray')\n}\n", "import toDataView from 'to-data-view'\n\nconst RFC4648 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'\nconst RFC4648_HEX = '0123456789ABCDEFGHIJKLMNOPQRSTUV'\nconst CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ'\n\nexport default function base32Encode (data, variant, options) {\n options = options || {}\n let alphabet, defaultPadding\n\n switch (variant) {\n case 'RFC3548':\n case 'RFC4648':\n alphabet = RFC4648\n defaultPadding = true\n break\n case 'RFC4648-HEX':\n alphabet = RFC4648_HEX\n defaultPadding = true\n break\n case 'Crockford':\n alphabet = CROCKFORD\n defaultPadding = false\n break\n default:\n throw new Error('Unknown base32 variant: ' + variant)\n }\n\n const padding = (options.padding !== undefined ? options.padding : defaultPadding)\n const view = toDataView(data)\n\n let bits = 0\n let value = 0\n let output = ''\n\n for (let i = 0; i < view.byteLength; i++) {\n value = (value << 8) | view.getUint8(i)\n bits += 8\n\n while (bits >= 5) {\n output += alphabet[(value >>> (bits - 5)) & 31]\n bits -= 5\n }\n }\n\n if (bits > 0) {\n output += alphabet[(value << (5 - bits)) & 31]\n }\n\n if (padding) {\n while ((output.length % 8) !== 0) {\n output += '='\n }\n }\n\n return output\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nexport const randomBytes = (length: number) => {\n // globalThis.crypto is not available in Node.js when running in vitest even though the documentation says it should be.\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const webCrypto = globalThis.crypto ?? require('node:crypto').webcrypto;\n\n const bytes = new Uint8Array(length);\n webCrypto.getRandomValues(bytes);\n return bytes;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport base32Decode from 'base32-decode';\nimport base32Encode from 'base32-encode';\n\nimport { invariant } from '@dxos/invariant';\n\nimport { randomBytes } from './random-bytes';\n\n/**\n * A unique identifier for an identity.\n * Identity DIDs are generated by creating a keypair, and then taking the first 20 bytes of the SHA-256 hash of the public key and encoding them to multibase RFC4648 base-32 format (prefixed with B, see Multibase Table).\n * @example did:halo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE\n */\nexport type IdentityDid = string & { __IdentityDid: never };\n\nexport const IdentityDid = Object.freeze({\n byteLength: 20,\n encode: (value: Uint8Array): IdentityDid => {\n invariant(value instanceof Uint8Array, 'Invalid type');\n invariant(value.length === IdentityDid.byteLength, 'Invalid length');\n\n return (DID_PREFIX + MULTIBASE_PREFIX + base32Encode(value, 'RFC4648')) as IdentityDid;\n },\n decode: (value: IdentityDid): Uint8Array => {\n invariant(value.startsWith(DID_PREFIX + MULTIBASE_PREFIX), 'Invalid multibase32 encoding');\n\n return new Uint8Array(base32Decode(value.slice(10), 'RFC4648'));\n },\n isValid: (value: string): value is IdentityDid => {\n return (\n typeof value === 'string' && value.startsWith(DID_PREFIX + MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH\n );\n },\n random: (): IdentityDid => {\n return IdentityDid.encode(randomBytes(IdentityDid.byteLength));\n },\n});\n\n/**\n * Denotes RFC4648 base-32 format.\n */\nconst MULTIBASE_PREFIX = 'B';\n\nconst DID_PREFIX = 'did:halo:';\n\nconst ENCODED_LENGTH = 42;\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport base32Decode from 'base32-decode';\nimport base32Encode from 'base32-encode';\nimport { type InspectOptionsStylized, type inspect } from 'node:util';\n\nimport {\n type DevtoolsFormatter,\n type Equatable,\n devtoolsFormatter,\n equalsSymbol,\n inspectCustom,\n truncateKey,\n} from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\n\nimport { randomBytes } from './random-bytes';\n\nexport const PUBLIC_KEY_LENGTH = 32;\nexport const SECRET_KEY_LENGTH = 64;\n\n/**\n * All representations that can be converted to a PublicKey.\n */\nexport type PublicKeyLike = PublicKey | Buffer | Uint8Array | ArrayBuffer | string;\n\n/**\n * Vitest with JSDom causes instanceof ArrayBuffer check to fail\n */\nconst isLikeArrayBuffer = (value: any): value is ArrayBuffer =>\n typeof value === 'object' && value !== null && Object.getPrototypeOf(value).constructor.name === 'ArrayBuffer';\n\n/**\n * The purpose of this class is to assure consistent use of keys throughout the project.\n * Keys should be maintained as buffers in objects and proto definitions, and converted to hex\n * strings as late as possible (eg, to log/display).\n */\nexport class PublicKey implements Equatable {\n static ZERO = PublicKey.from('00'.repeat(PUBLIC_KEY_LENGTH));\n\n /**\n * Creates new instance of PublicKey automatically determining the input format.\n * @param source A Buffer, or Uint8Array, or hex encoded string, or something with an `asUint8Array` method on it\n * @returns PublicKey\n */\n static from(source: PublicKeyLike): PublicKey {\n invariant(source);\n if (source instanceof PublicKey) {\n return source;\n } else if (source instanceof Buffer) {\n return new PublicKey(new Uint8Array(source.buffer, source.byteOffset, source.byteLength));\n } else if (source instanceof Uint8Array) {\n return new PublicKey(source);\n } else if (source instanceof ArrayBuffer || isLikeArrayBuffer(source)) {\n return new PublicKey(new Uint8Array(source));\n } else if (typeof source === 'string') {\n // TODO(burdon): Check length.\n return PublicKey.fromHex(source);\n } else if ((<any>source).asUint8Array) {\n return new PublicKey((<any>source).asUint8Array());\n } else {\n throw new TypeError(`Unable to create PublicKey from ${source}`);\n }\n }\n\n /**\n * Same as `PublicKey.from` but does not throw and instead returns a `{ key: PublicKey }` or `{ error: Error }`\n * @param source Same PublicKeyLike argument as for `PublicKey.from`\n * @returns PublicKey\n */\n static safeFrom(source?: PublicKeyLike): PublicKey | undefined {\n if (!source) {\n return undefined;\n }\n\n try {\n const key = PublicKey.from(source);\n // TODO(wittjosiah): Space keys don't pass this check.\n // if (key.length !== PUBLIC_KEY_LENGTH && key.length !== SECRET_KEY_LENGTH) {\n // return undefined;\n // }\n return key;\n } catch (err: any) {\n return undefined;\n }\n }\n\n /**\n * Creates new instance of PublicKey from hex string.\n */\n static fromHex(hex: string): PublicKey {\n if (hex.startsWith('0x')) {\n hex = hex.slice(2);\n }\n\n const buf = Buffer.from(hex, 'hex');\n // TODO(burdon): Test if key.\n return new PublicKey(new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength));\n }\n\n /**\n * Creates a new key.\n */\n static random(): PublicKey {\n // TODO(burdon): Enable seed for debugging.\n return PublicKey.from(randomBytes(PUBLIC_KEY_LENGTH));\n }\n\n static randomOfLength(length: number): PublicKey {\n return PublicKey.from(randomBytes(length));\n }\n\n static *randomSequence(): Generator<PublicKey> {\n for (let i = 0; i < 1_0000; i++) {\n // Counter just to protect against infinite loops.\n yield PublicKey.random();\n }\n throw new Error('Too many keys requested');\n }\n\n /**\n * Tests if provided values is an instance of PublicKey.\n */\n static isPublicKey(value: any): value is PublicKey {\n return value instanceof PublicKey;\n }\n\n /**\n * Asserts that provided values is an instance of PublicKey.\n */\n static assertValidPublicKey(value: any): asserts value is PublicKey {\n if (!this.isPublicKey(value)) {\n throw new TypeError('Invalid PublicKey');\n }\n }\n\n /**\n * Tests two keys for equality.\n */\n static equals(left: PublicKeyLike, right: PublicKeyLike): boolean {\n return PublicKey.from(left).equals(right);\n }\n\n /**\n * @param str string representation of key.\n * @return Key buffer.\n * @deprecated All keys should be represented as instances of PublicKey.\n */\n static bufferize(str: string): Buffer {\n invariant(typeof str === 'string', 'Invalid type');\n const buffer = Buffer.from(str, 'hex');\n // invariant(buffer.length === PUBLIC_KEY_LENGTH || buffer.length === SECRET_KEY_LENGTH,\n // `Invalid key length: ${buffer.length}`);\n return buffer;\n }\n\n /**\n * @param key key like data structure (but not PublicKey which should use toString).\n * @return Hex string representation of key.\n * @deprecated All keys should be represented as instances of PublicKey.\n */\n static stringify(key: Buffer | Uint8Array | ArrayBuffer): string {\n if (key instanceof PublicKey) {\n key = key.asBuffer();\n } else if (key instanceof Uint8Array) {\n key = Buffer.from(key.buffer, key.byteOffset, key.byteLength);\n }\n\n invariant(key instanceof Buffer, 'Invalid type');\n return key.toString('hex');\n }\n\n /**\n * To be used with ComplexMap and ComplexSet.\n * Returns a scalar representation for this key.\n */\n static hash(key: PublicKey): string {\n return key.toHex();\n }\n\n static fromMultibase32(encoded: string): PublicKey {\n invariant(encoded.startsWith('B'), 'Invalid multibase32 encoding');\n\n return new PublicKey(new Uint8Array(base32Decode(encoded.slice(1), 'RFC4648')));\n }\n\n constructor(private readonly _value: Uint8Array) {\n if (!(_value instanceof Uint8Array)) {\n throw new TypeError(`Expected Uint8Array, got: ${_value}`);\n }\n }\n\n toString(): string {\n return this.toHex();\n }\n\n toJSON(): string {\n return this.toHex();\n }\n\n toJSONL(): string {\n return this.truncate();\n }\n\n get length() {\n return this._value.length;\n }\n\n toHex(): string {\n return this.asBuffer().toString('hex');\n }\n\n toMultibase32(): string {\n return 'B' + base32Encode(this._value, 'RFC4648');\n }\n\n truncate(length?: number): string {\n return truncateKey(this, length);\n }\n\n asBuffer(): Buffer {\n return Buffer.from(this._value.buffer, this._value.byteOffset, this._value.byteLength);\n }\n\n asUint8Array(): Uint8Array {\n return this._value;\n }\n\n getInsecureHash(modulo: number): number {\n return Math.abs(this._value.reduce((acc, val) => (acc ^ val) | 0, 0)) % modulo;\n }\n\n /**\n * Used by Node.js to get textual representation of this object when it's printed with a `console.log` statement.\n */\n [inspectCustom](depth: number, options: InspectOptionsStylized, inspectFn: typeof inspect): string {\n if (!options.colors || typeof process.stdout.hasColors !== 'function' || !process.stdout.hasColors()) {\n return `<PublicKey ${this.truncate()}>`;\n }\n\n const printControlCode = (code: number) => {\n return `\\x1b[${code}m`;\n };\n\n // NOTE: Keep in sync with formatter colors.\n const colors = [\n 'red',\n 'green',\n 'yellow',\n 'blue',\n 'magenta',\n 'cyan',\n 'redBright',\n 'greenBright',\n 'yellowBright',\n 'blueBright',\n 'magentaBright',\n 'cyanBright',\n 'whiteBright',\n ];\n const color = colors[this.getInsecureHash(colors.length)];\n\n return `PublicKey(${printControlCode(inspectFn.colors[color]![0])}${this.truncate()}${printControlCode(\n inspectFn.colors.reset![0],\n )})`;\n }\n\n get [devtoolsFormatter](): DevtoolsFormatter {\n return {\n header: () => {\n // NOTE: Keep in sync with inspect colors.\n const colors = [\n 'darkred',\n 'green',\n 'orange',\n 'blue',\n 'darkmagenta',\n 'darkcyan',\n 'red',\n 'green',\n 'orange',\n 'blue',\n 'magenta',\n 'darkcyan',\n 'black',\n ];\n const color = colors[this.getInsecureHash(colors.length)];\n\n return [\n 'span',\n {},\n ['span', {}, 'PublicKey('],\n ['span', { style: `color: ${color};` }, this.truncate()],\n ['span', {}, ')'],\n ];\n },\n };\n }\n\n /**\n * Test this key for equality with some other key.\n */\n equals(other: PublicKeyLike): boolean {\n const otherConverted = PublicKey.from(other);\n if (this._value.length !== otherConverted._value.length) {\n return false;\n }\n\n let equal = true;\n for (let i = 0; i < this._value.length; i++) {\n equal &&= this._value[i] === otherConverted._value[i];\n }\n\n return equal;\n }\n\n [equalsSymbol](other: any): boolean {\n if (!PublicKey.isPublicKey(other)) {\n return false;\n }\n\n return this.equals(other);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,QAAIA,WAAU;AACd,QAAIC,eAAc;AAClB,QAAIC,aAAY;AAEhB,aAAS,SAAU,UAAU,MAAM;AACjC,UAAI,MAAM,SAAS,QAAQ,IAAI;AAE/B,UAAI,QAAQ,IAAI;AACd,cAAM,IAAI,MAAM,8BAA8B,IAAI;AAAA,MACpD;AAEA,aAAO;AAAA,IACT;AAEA,WAAO,UAAU,SAASC,cAAc,OAAO,SAAS;AACtD,UAAI;AAEJ,cAAQ,SAAS;AAAA,QACf,KAA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,QAAQN,OAAO,KAAKX,gBAAgBW,OAAOrC,MAAM,CAAA;AAEvD,WAAO,aAAayC,iBAAiBL,UAAUC,OAAOM,KAAAA,EAAQ,CAAA,CAAE,CAAA,GAAI,KAAKrB,SAAQ,CAAA,GAAKmB,iBACpFL,UAAUC,OAAOO,MAAO,CAAA,CAAE,CAAA;EAE9B;EAEA,KAAKC,kBAAAA,IAAwC;AAC3C,WAAO;MACLC,QAAQ,MAAA;AAEN,cAAMT,SAAS;UACb;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;AAEF,cAAMM,QAAQN,OAAO,KAAKX,gBAAgBW,OAAOrC,MAAM,CAAA;AAEvD,eAAO;UACL;UACA,CAAC;UACD;YAAC;YAAQ,CAAC;YAAG;;UACb;YAAC;YAAQ;cAAE+C,OAAO,UAAUJ,KAAAA;YAAS;YAAG,KAAKrB,SAAQ;;UACrD;YAAC;YAAQ,CAAC;YAAG;;;MAEjB;IACF;EACF;;;;EAKAhB,OAAO0C,OAA+B;AACpC,UAAMC,iBAAiB3E,WAAUE,KAAKwE,KAAAA;AACtC,QAAI,KAAK7B,OAAOnB,WAAWiD,eAAe9B,OAAOnB,QAAQ;AACvD,aAAO;IACT;AAEA,QAAIkD,QAAQ;AACZ,aAAShD,IAAI,GAAGA,IAAI,KAAKiB,OAAOnB,QAAQE,KAAK;AAC3CgD,gBAAU,KAAK/B,OAAOjB,CAAAA,MAAO+C,eAAe9B,OAAOjB,CAAAA;IACrD;AAEA,WAAOgD;EACT;EAEA,CAACC,YAAAA,EAAcH,OAAqB;AAClC,QAAI,CAAC1E,WAAU8B,YAAY4C,KAAAA,GAAQ;AACjC,aAAO;IACT;AAEA,WAAO,KAAK1C,OAAO0C,KAAAA;EACrB;AACF;",
|
|
6
|
+
"names": ["RFC4648", "RFC4648_HEX", "CROCKFORD", "base32Decode", "Schema", "devtoolsFormatter", "inspectCustom", "assertArgument", "invariant", "Schema", "monotonicFactory", "ObjectIdSchema", "String", "pipe", "pattern", "annotations", "description", "ObjectId", "undefined", "isValid", "id", "decodeSync", "random", "dangerouslyDisableRandomness", "makeTestPRNG", "Date", "getTime", "rng", "SimplePRNG", "next", "Math", "pow", "seed", "reset", "Schema", "invariant", "randomBytes", "length", "webCrypto", "globalThis", "crypto", "require", "webcrypto", "bytes", "Uint8Array", "getRandomValues", "MULTIBASE_PREFIX", "ENCODED_LENGTH", "isValid", "value", "startsWith", "length", "SpaceId", "String", "pipe", "filter", "byteLength", "encode", "invariant", "Uint8Array", "base32Encode", "decode", "base32Decode", "slice", "random", "randomBytes", "LOCAL_SPACE_TAG", "DXN_ECHO_REGEXP", "QueueSubspaceTags", "Object", "freeze", "DATA", "TRACE", "DXN", "Schema", "NonEmptyString", "pipe", "pattern", "annotations", "title", "description", "examples", "hash", "dxn", "toString", "kind", "TYPE", "ECHO", "QUEUE", "equals", "a", "b", "parts", "length", "every", "part", "i", "equalsEchoId", "a1", "asEchoDXN", "b1", "echoId", "isDXNString", "startsWith", "parse", "Error", "prefix", "split", "tryParse", "undefined", "fromTypename", "typename", "fromTypenameAndVersion", "version", "fromSpaceAndObjectId", "spaceId", "objectId", "assertArgument", "SpaceId", "isValid", "ObjectId", "fromLocalObjectId", "id", "fromQueue", "subspaceTag", "queueId", "indexOf", "join", "toJSON", "inspectCustom", "depth", "options", "inspectFn", "printControlCode", "code", "colors", "blueBright", "reset", "devtoolsFormatter", "header", "style", "invariant", "other", "hasTypenameOf", "isLocalObjectId", "asTypeDXN", "type", "asQueueDXN", "extend", "import_base32_decode", "invariant", "IdentityDid", "Object", "freeze", "byteLength", "encode", "value", "invariant", "Uint8Array", "length", "DID_PREFIX", "MULTIBASE_PREFIX", "base32Encode", "decode", "startsWith", "base32Decode", "slice", "isValid", "ENCODED_LENGTH", "random", "randomBytes", "import_base32_decode", "devtoolsFormatter", "equalsSymbol", "inspectCustom", "truncateKey", "invariant", "PUBLIC_KEY_LENGTH", "SECRET_KEY_LENGTH", "isLikeArrayBuffer", "value", "Object", "getPrototypeOf", "name", "PublicKey", "ZERO", "from", "repeat", "source", "invariant", "Buffer", "Uint8Array", "buffer", "byteOffset", "byteLength", "ArrayBuffer", "fromHex", "asUint8Array", "TypeError", "safeFrom", "undefined", "key", "err", "hex", "startsWith", "slice", "buf", "random", "randomBytes", "randomOfLength", "length", "randomSequence", "i", "Error", "isPublicKey", "assertValidPublicKey", "equals", "left", "right", "bufferize", "str", "stringify", "asBuffer", "toString", "hash", "toHex", "fromMultibase32", "encoded", "base32Decode", "_value", "toJSON", "toJSONL", "truncate", "toMultibase32", "base32Encode", "truncateKey", "getInsecureHash", "modulo", "Math", "abs", "reduce", "acc", "val", "inspectCustom", "depth", "options", "inspectFn", "colors", "process", "stdout", "hasColors", "printControlCode", "code", "color", "reset", "devtoolsFormatter", "header", "style", "other", "otherConverted", "equal", "equalsSymbol"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/object-id.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/object-id.ts":{"bytes":9634,"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"ulidx","kind":"import-statement","external":true}],"format":"esm"},"../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js":{"bytes":1217,"imports":[],"format":"cjs"},"../../../node_modules/.pnpm/to-data-view@2.0.0/node_modules/to-data-view/index.js":{"bytes":410,"imports":[],"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"}],"format":"esm"},"src/random-bytes.ts":{"bytes":1664,"imports":[{"path":"node:crypto","kind":"require-call","external":true}],"format":"esm"},"src/space-id.ts":{"bytes":5276,"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/Schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"src/random-bytes.ts","kind":"import-statement","original":"./random-bytes"}],"format":"esm"},"src/dxn.ts":{"bytes":31959,"imports":[{"path":"effect/Schema","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"}],"format":"esm"},"src/identity-did.ts":{"bytes":4699,"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"}],"format":"esm"},"src/public-key.ts":{"bytes":30071,"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"}],"format":"esm"},"src/index.ts":{"bytes":778,"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"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":47077},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"ulidx","kind":"import-statement","external":true},{"path":"effect/Schema","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"node: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","SimplePRNG","SpaceId"],"entryPoint":"src/index.ts","inputs":{"../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js":{"bytesInOutput":1563},"src/dxn.ts":{"bytesInOutput":7157},"src/object-id.ts":{"bytesInOutput":1664},"src/space-id.ts":{"bytesInOutput":1002},"../../../node_modules/.pnpm/to-data-view@2.0.0/node_modules/to-data-view/index.js":{"bytesInOutput":395},"../../../node_modules/.pnpm/base32-encode@2.0.0/node_modules/base32-encode/index.js":{"bytesInOutput":1206},"src/random-bytes.ts":{"bytesInOutput":204},"src/index.ts":{"bytesInOutput":0},"src/identity-did.ts":{"bytesInOutput":967},"src/public-key.ts":{"bytesInOutput":7303}},"bytes":23901}}}
|
package/dist/types/src/dxn.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { InspectOptionsStylized, inspect } from 'node:util';
|
|
2
1
|
import * as Schema from 'effect/Schema';
|
|
2
|
+
import type { InspectOptionsStylized, inspect } from 'node:util';
|
|
3
3
|
import { type DevtoolsFormatter, devtoolsFormatter, inspectCustom } from '@dxos/debug';
|
|
4
4
|
import { ObjectId } from './object-id';
|
|
5
5
|
import { SpaceId } from './space-id';
|
|
@@ -25,8 +25,8 @@ export type QueueSubspaceTag = (typeof QueueSubspaceTags)[keyof typeof QueueSubs
|
|
|
25
25
|
* dxn:echo:<space key>:<echo id>
|
|
26
26
|
* dxn:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
|
|
27
27
|
* dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6
|
|
28
|
-
* dxn:type:dxos.
|
|
29
|
-
* dxn:plugin:dxos.
|
|
28
|
+
* dxn:type:org.dxos.type.calendar
|
|
29
|
+
* dxn:plugin:org.dxos.agent.plugin.functions
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
export declare class DXN {
|
|
@@ -63,11 +63,11 @@ export declare class DXN {
|
|
|
63
63
|
static parse(dxn: string): DXN;
|
|
64
64
|
static tryParse(dxn: string): DXN | undefined;
|
|
65
65
|
/**
|
|
66
|
-
* @example `dxn:type:example.
|
|
66
|
+
* @example `dxn:type:com.example.type.person`
|
|
67
67
|
*/
|
|
68
68
|
static fromTypename(typename: string): DXN;
|
|
69
69
|
/**
|
|
70
|
-
* @example `dxn:type:example.
|
|
70
|
+
* @example `dxn:type:com.example.type.person:0.1.0`
|
|
71
71
|
*/
|
|
72
72
|
static fromTypenameAndVersion(typename: string, version: string): DXN;
|
|
73
73
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dxn.d.ts","sourceRoot":"","sources":["../../../src/dxn.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,
|
|
1
|
+
{"version":3,"file":"dxn.d.ts","sourceRoot":"","sources":["../../../src/dxn.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM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AG;QAAE,WAAW,EAAE,KAAK,CAAA;KAAE,CAAC;IAErD,KAAY,OAAO,GAAG;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IAEF,KAAY,OAAO,GAAG;QACpB,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAEF,KAAY,QAAQ,GAAG;QACrB,WAAW,EAAE,gBAAgB,CAAC;QAC9B,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-id.d.ts","sourceRoot":"","sources":["../../../src/object-id.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAMxC,QAAA,MAAM,cAAc,6CAGlB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAElD,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC;IACzE;;OAEG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI,QAAQ,CAAC;IAEpC;;OAEG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAAC;IAE3B;;OAEG;IACH,MAAM,IAAI,QAAQ,CAAC;IAEnB;;;;;;;;;;;;;;;;OAgBG;IACH,4BAA4B,IAAI,IAAI,CAAC;CACtC;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,aAqBtB,CAAC;AAYF;;;GAGG;AACH,qBAAa,UAAU;;IAQrB;;;OAGG;
|
|
1
|
+
{"version":3,"file":"object-id.d.ts","sourceRoot":"","sources":["../../../src/object-id.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAMxC,QAAA,MAAM,cAAc,6CAGlB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAElD,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC;IACzE;;OAEG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,EAAE,IAAI,QAAQ,CAAC;IAEpC;;OAEG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAAC;IAE3B;;OAEG;IACH,MAAM,IAAI,QAAQ,CAAC;IAEnB;;;;;;;;;;;;;;;;OAgBG;IACH,4BAA4B,IAAI,IAAI,CAAC;CACtC;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,aAqBtB,CAAC;AAYF;;;GAGG;AACH,qBAAa,UAAU;;IAQrB;;;OAGG;IACH,YAAY,IAAI,GAAE,MAAU,EAE3B;IAED;;;OAGG;IACH,IAAI,IAAI,MAAM,CAMb;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAExB;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prng.d.ts","sourceRoot":"","sources":["../../../src/prng.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAAS;IAGtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAW;IACrC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAc;IACxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAmB;IAE7C;;;OAGG;
|
|
1
|
+
{"version":3,"file":"prng.d.ts","sourceRoot":"","sources":["../../../src/prng.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAAS;IAGtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAW;IACrC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAc;IACxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAmB;IAE7C;;;OAGG;IACH,YAAY,IAAI,CAAC,EAAE,MAAM,EAExB;IAED;;;OAGG;IACH,IAAI,IAAI,MAAM,CAMb;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAExB;CACF;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,CAAC,MAAM,MAAM,CAGvD,CAAC"}
|
|
@@ -73,7 +73,7 @@ export declare class PublicKey implements Equatable {
|
|
|
73
73
|
get length(): number;
|
|
74
74
|
toHex(): string;
|
|
75
75
|
toMultibase32(): string;
|
|
76
|
-
truncate(length?:
|
|
76
|
+
truncate(length?: number): string;
|
|
77
77
|
asBuffer(): Buffer;
|
|
78
78
|
asUint8Array(): Uint8Array;
|
|
79
79
|
getInsecureHash(modulo: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-key.d.ts","sourceRoot":"","sources":["../../../src/public-key.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"public-key.d.ts","sourceRoot":"","sources":["../../../src/public-key.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,sBAAsB,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAEtE,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,iBAAiB,EACjB,YAAY,EACZ,aAAa,EAEd,MAAM,aAAa,CAAC;AAKrB,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC;AAQnF;;;;GAIG;AACH,qBAAa,SAA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AAM,IAAI,MAAM,CAEf;IAED,OAAO,IAAI,MAAM,CAEhB;IAED,IAAI,MAAM,WAET;IAED,KAAK,IAAI,MAAM,CAEd;IAED,aAAa,IAAI,MAAM,CAEtB;IAED,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhC;IAED,QAAQ,IAAI,MAAM,CAEjB;IAED,YAAY,IAAI,UAAU,CAEzB;IAED,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtC;IAED;;OAEG;IACH,CAAC,aAAa,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,OAAO,OAAO,GAAG,MAAM,CA8BjG;IAED,IAAI,CAAC,iBAAiB,CAAC,IAAI,iBAAiB,CA8B3C;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAYpC;IAED,CAAC,YAAY,CAAC,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAMlC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random-bytes.d.ts","sourceRoot":"","sources":["../../../src/random-bytes.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"random-bytes.d.ts","sourceRoot":"","sources":["../../../src/random-bytes.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,WAAW,WAAY,MAAM,4BAQzC,CAAC"}
|