@dxos/keys 0.7.5-labs.35b4b42 → 0.7.5-labs.a279d8c
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 +53 -101
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +50 -96
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +53 -100
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/dxn.d.ts +2 -3
- package/dist/types/src/dxn.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/dxn.ts +16 -12
- package/src/index.ts +0 -1
- package/dist/types/src/identity-did.d.ts +0 -16
- package/dist/types/src/identity-did.d.ts.map +0 -1
- package/dist/types/src/identity-did.test.d.ts +0 -2
- package/dist/types/src/identity-did.test.d.ts.map +0 -1
- package/src/identity-did.test.ts +0 -17
- package/src/identity-did.ts +0 -49
|
@@ -44,7 +44,7 @@ var require_base32_decode = __commonJS({
|
|
|
44
44
|
}
|
|
45
45
|
return idx;
|
|
46
46
|
}
|
|
47
|
-
module.exports = function
|
|
47
|
+
module.exports = function base32Decode3(input, variant) {
|
|
48
48
|
var alphabet;
|
|
49
49
|
switch (variant) {
|
|
50
50
|
case "RFC3548":
|
|
@@ -81,7 +81,7 @@ var require_base32_decode = __commonJS({
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
// packages/common/keys/src/
|
|
84
|
+
// packages/common/keys/src/public-key.ts
|
|
85
85
|
var import_base32_decode = __toESM(require_base32_decode());
|
|
86
86
|
|
|
87
87
|
// node_modules/.pnpm/to-data-view@2.0.0/node_modules/to-data-view/index.js
|
|
@@ -143,7 +143,8 @@ function base32Encode(data, variant, options) {
|
|
|
143
143
|
return output;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
// packages/common/keys/src/
|
|
146
|
+
// packages/common/keys/src/public-key.ts
|
|
147
|
+
import { devtoolsFormatter, equalsSymbol, inspectCustom, truncateKey } from "@dxos/debug";
|
|
147
148
|
import { invariant } from "@dxos/invariant";
|
|
148
149
|
|
|
149
150
|
// packages/common/keys/src/random-bytes.ts
|
|
@@ -154,59 +155,8 @@ var randomBytes = (length) => {
|
|
|
154
155
|
return bytes;
|
|
155
156
|
};
|
|
156
157
|
|
|
157
|
-
// packages/common/keys/src/identity-did.ts
|
|
158
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/common/keys/src/identity-did.ts";
|
|
159
|
-
var IdentityDid = Object.freeze({
|
|
160
|
-
byteLength: 20,
|
|
161
|
-
encode: (value) => {
|
|
162
|
-
invariant(value instanceof Uint8Array, "Invalid type", {
|
|
163
|
-
F: __dxlog_file,
|
|
164
|
-
L: 22,
|
|
165
|
-
S: void 0,
|
|
166
|
-
A: [
|
|
167
|
-
"value instanceof Uint8Array",
|
|
168
|
-
"'Invalid type'"
|
|
169
|
-
]
|
|
170
|
-
});
|
|
171
|
-
invariant(value.length === IdentityDid.byteLength, "Invalid length", {
|
|
172
|
-
F: __dxlog_file,
|
|
173
|
-
L: 23,
|
|
174
|
-
S: void 0,
|
|
175
|
-
A: [
|
|
176
|
-
"value.length === IdentityDid.byteLength",
|
|
177
|
-
"'Invalid length'"
|
|
178
|
-
]
|
|
179
|
-
});
|
|
180
|
-
return DID_PREFIX + MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
|
|
181
|
-
},
|
|
182
|
-
decode: (value) => {
|
|
183
|
-
invariant(value.startsWith(DID_PREFIX + MULTIBASE_PREFIX), "Invalid multibase32 encoding", {
|
|
184
|
-
F: __dxlog_file,
|
|
185
|
-
L: 28,
|
|
186
|
-
S: void 0,
|
|
187
|
-
A: [
|
|
188
|
-
"value.startsWith(DID_PREFIX + MULTIBASE_PREFIX)",
|
|
189
|
-
"'Invalid multibase32 encoding'"
|
|
190
|
-
]
|
|
191
|
-
});
|
|
192
|
-
return new Uint8Array((0, import_base32_decode.default)(value.slice(10), "RFC4648"));
|
|
193
|
-
},
|
|
194
|
-
isValid: (value) => {
|
|
195
|
-
return typeof value === "string" && value.startsWith(DID_PREFIX + MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;
|
|
196
|
-
},
|
|
197
|
-
random: () => {
|
|
198
|
-
return IdentityDid.encode(randomBytes(IdentityDid.byteLength));
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
var MULTIBASE_PREFIX = "B";
|
|
202
|
-
var DID_PREFIX = "did:halo:";
|
|
203
|
-
var ENCODED_LENGTH = 42;
|
|
204
|
-
|
|
205
158
|
// packages/common/keys/src/public-key.ts
|
|
206
|
-
var
|
|
207
|
-
import { devtoolsFormatter, equalsSymbol, inspectCustom, truncateKey } from "@dxos/debug";
|
|
208
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
209
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/common/keys/src/public-key.ts";
|
|
159
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/common/keys/src/public-key.ts";
|
|
210
160
|
var PUBLIC_KEY_LENGTH = 32;
|
|
211
161
|
var SECRET_KEY_LENGTH = 64;
|
|
212
162
|
var isLikeArrayBuffer = (value) => typeof value === "object" && value !== null && Object.getPrototypeOf(value).constructor.name === "ArrayBuffer";
|
|
@@ -220,8 +170,8 @@ var PublicKey = class _PublicKey {
|
|
|
220
170
|
* @returns PublicKey
|
|
221
171
|
*/
|
|
222
172
|
static from(source) {
|
|
223
|
-
|
|
224
|
-
F:
|
|
173
|
+
invariant(source, void 0, {
|
|
174
|
+
F: __dxlog_file,
|
|
225
175
|
L: 49,
|
|
226
176
|
S: this,
|
|
227
177
|
A: [
|
|
@@ -312,8 +262,8 @@ var PublicKey = class _PublicKey {
|
|
|
312
262
|
* @deprecated All keys should be represented as instances of PublicKey.
|
|
313
263
|
*/
|
|
314
264
|
static bufferize(str) {
|
|
315
|
-
|
|
316
|
-
F:
|
|
265
|
+
invariant(typeof str === "string", "Invalid type", {
|
|
266
|
+
F: __dxlog_file,
|
|
317
267
|
L: 152,
|
|
318
268
|
S: this,
|
|
319
269
|
A: [
|
|
@@ -335,8 +285,8 @@ var PublicKey = class _PublicKey {
|
|
|
335
285
|
} else if (key instanceof Uint8Array) {
|
|
336
286
|
key = Buffer.from(key.buffer, key.byteOffset, key.byteLength);
|
|
337
287
|
}
|
|
338
|
-
|
|
339
|
-
F:
|
|
288
|
+
invariant(key instanceof Buffer, "Invalid type", {
|
|
289
|
+
F: __dxlog_file,
|
|
340
290
|
L: 171,
|
|
341
291
|
S: this,
|
|
342
292
|
A: [
|
|
@@ -354,8 +304,8 @@ var PublicKey = class _PublicKey {
|
|
|
354
304
|
return key.toHex();
|
|
355
305
|
}
|
|
356
306
|
static fromMultibase32(encoded) {
|
|
357
|
-
|
|
358
|
-
F:
|
|
307
|
+
invariant(encoded.startsWith("B"), "Invalid multibase32 encoding", {
|
|
308
|
+
F: __dxlog_file,
|
|
359
309
|
L: 184,
|
|
360
310
|
S: this,
|
|
361
311
|
A: [
|
|
@@ -363,7 +313,7 @@ var PublicKey = class _PublicKey {
|
|
|
363
313
|
"'Invalid multibase32 encoding'"
|
|
364
314
|
]
|
|
365
315
|
});
|
|
366
|
-
return new _PublicKey(new Uint8Array((0,
|
|
316
|
+
return new _PublicKey(new Uint8Array((0, import_base32_decode.default)(encoded.slice(1), "RFC4648")));
|
|
367
317
|
}
|
|
368
318
|
constructor(_value) {
|
|
369
319
|
this._value = _value;
|
|
@@ -495,14 +445,14 @@ var PublicKey = class _PublicKey {
|
|
|
495
445
|
};
|
|
496
446
|
|
|
497
447
|
// packages/common/keys/src/space-id.ts
|
|
498
|
-
var
|
|
499
|
-
import { invariant as
|
|
500
|
-
var
|
|
448
|
+
var import_base32_decode2 = __toESM(require_base32_decode());
|
|
449
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
450
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/common/keys/src/space-id.ts";
|
|
501
451
|
var SpaceId = Object.freeze({
|
|
502
452
|
byteLength: 20,
|
|
503
453
|
encode: (value) => {
|
|
504
|
-
|
|
505
|
-
F:
|
|
454
|
+
invariant2(value instanceof Uint8Array, "Invalid type", {
|
|
455
|
+
F: __dxlog_file2,
|
|
506
456
|
L: 22,
|
|
507
457
|
S: void 0,
|
|
508
458
|
A: [
|
|
@@ -510,8 +460,8 @@ var SpaceId = Object.freeze({
|
|
|
510
460
|
"'Invalid type'"
|
|
511
461
|
]
|
|
512
462
|
});
|
|
513
|
-
|
|
514
|
-
F:
|
|
463
|
+
invariant2(value.length === SpaceId.byteLength, "Invalid length", {
|
|
464
|
+
F: __dxlog_file2,
|
|
515
465
|
L: 23,
|
|
516
466
|
S: void 0,
|
|
517
467
|
A: [
|
|
@@ -519,11 +469,11 @@ var SpaceId = Object.freeze({
|
|
|
519
469
|
"'Invalid length'"
|
|
520
470
|
]
|
|
521
471
|
});
|
|
522
|
-
return
|
|
472
|
+
return MULTIBASE_PREFIX + base32Encode(value, "RFC4648");
|
|
523
473
|
},
|
|
524
474
|
decode: (value) => {
|
|
525
|
-
|
|
526
|
-
F:
|
|
475
|
+
invariant2(value.startsWith(MULTIBASE_PREFIX), "Invalid multibase32 encoding", {
|
|
476
|
+
F: __dxlog_file2,
|
|
527
477
|
L: 28,
|
|
528
478
|
S: void 0,
|
|
529
479
|
A: [
|
|
@@ -531,22 +481,22 @@ var SpaceId = Object.freeze({
|
|
|
531
481
|
"'Invalid multibase32 encoding'"
|
|
532
482
|
]
|
|
533
483
|
});
|
|
534
|
-
return new Uint8Array((0,
|
|
484
|
+
return new Uint8Array((0, import_base32_decode2.default)(value.slice(1), "RFC4648"));
|
|
535
485
|
},
|
|
536
486
|
isValid: (value) => {
|
|
537
|
-
return typeof value === "string" && value.startsWith(
|
|
487
|
+
return typeof value === "string" && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;
|
|
538
488
|
},
|
|
539
489
|
random: () => {
|
|
540
490
|
return SpaceId.encode(randomBytes(SpaceId.byteLength));
|
|
541
491
|
}
|
|
542
492
|
});
|
|
543
|
-
var
|
|
544
|
-
var
|
|
493
|
+
var MULTIBASE_PREFIX = "B";
|
|
494
|
+
var ENCODED_LENGTH = 33;
|
|
545
495
|
|
|
546
496
|
// packages/common/keys/src/dxn.ts
|
|
547
497
|
import { inspectCustom as inspectCustom2 } from "@dxos/debug";
|
|
548
|
-
import { invariant as
|
|
549
|
-
var
|
|
498
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
499
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/common/keys/src/dxn.ts";
|
|
550
500
|
var DXN = class _DXN {
|
|
551
501
|
static {
|
|
552
502
|
/**
|
|
@@ -563,8 +513,7 @@ var DXN = class _DXN {
|
|
|
563
513
|
*/
|
|
564
514
|
ECHO: "echo",
|
|
565
515
|
/**
|
|
566
|
-
*
|
|
567
|
-
* dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
|
|
516
|
+
* dxn:queue:<subspace tag>:<space id>:<queue id>[:object id]
|
|
568
517
|
* dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
|
|
569
518
|
* dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
|
|
570
519
|
*/
|
|
@@ -577,29 +526,34 @@ var DXN = class _DXN {
|
|
|
577
526
|
static isDXNString(dxn) {
|
|
578
527
|
return dxn.startsWith("dxn:");
|
|
579
528
|
}
|
|
580
|
-
static parse(dxn) {
|
|
529
|
+
static parse(dxn, noThrow) {
|
|
581
530
|
if (typeof dxn !== "string") {
|
|
531
|
+
if (noThrow) {
|
|
532
|
+
return void 0;
|
|
533
|
+
}
|
|
582
534
|
throw new Error(`Invalid DXN: ${dxn}`);
|
|
583
535
|
}
|
|
584
536
|
const [prefix, kind, ...parts] = dxn.split(":");
|
|
585
537
|
if (!(prefix === "dxn")) {
|
|
538
|
+
if (noThrow) {
|
|
539
|
+
return void 0;
|
|
540
|
+
}
|
|
586
541
|
throw new Error(`Invalid DXN: ${dxn}`);
|
|
587
542
|
}
|
|
588
543
|
if (!(typeof kind === "string" && kind.length > 0)) {
|
|
544
|
+
if (noThrow) {
|
|
545
|
+
return void 0;
|
|
546
|
+
}
|
|
589
547
|
throw new Error(`Invalid DXN: ${dxn}`);
|
|
590
548
|
}
|
|
591
549
|
if (!(parts.length > 0)) {
|
|
550
|
+
if (noThrow) {
|
|
551
|
+
return void 0;
|
|
552
|
+
}
|
|
592
553
|
throw new Error(`Invalid DXN: ${dxn}`);
|
|
593
554
|
}
|
|
594
555
|
return new _DXN(kind, parts);
|
|
595
556
|
}
|
|
596
|
-
static tryParse(dxn) {
|
|
597
|
-
try {
|
|
598
|
-
return _DXN.parse(dxn);
|
|
599
|
-
} catch (error) {
|
|
600
|
-
return void 0;
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
557
|
/**
|
|
604
558
|
* @example `dxn:type:example.com/type/Contact`
|
|
605
559
|
*/
|
|
@@ -630,18 +584,18 @@ var DXN = class _DXN {
|
|
|
630
584
|
#kind;
|
|
631
585
|
#parts;
|
|
632
586
|
constructor(kind, parts) {
|
|
633
|
-
|
|
634
|
-
F:
|
|
635
|
-
L:
|
|
587
|
+
invariant3(parts.length > 0, void 0, {
|
|
588
|
+
F: __dxlog_file3,
|
|
589
|
+
L: 117,
|
|
636
590
|
S: this,
|
|
637
591
|
A: [
|
|
638
592
|
"parts.length > 0",
|
|
639
593
|
""
|
|
640
594
|
]
|
|
641
595
|
});
|
|
642
|
-
|
|
643
|
-
F:
|
|
644
|
-
L:
|
|
596
|
+
invariant3(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), void 0, {
|
|
597
|
+
F: __dxlog_file3,
|
|
598
|
+
L: 118,
|
|
645
599
|
S: this,
|
|
646
600
|
A: [
|
|
647
601
|
"parts.every((part) => typeof part === 'string' && part.length > 0 && part.indexOf(':') === -1)",
|
|
@@ -670,9 +624,9 @@ var DXN = class _DXN {
|
|
|
670
624
|
return this.#parts;
|
|
671
625
|
}
|
|
672
626
|
toTypename() {
|
|
673
|
-
|
|
674
|
-
F:
|
|
675
|
-
L:
|
|
627
|
+
invariant3(this.#kind === _DXN.kind.TYPE, void 0, {
|
|
628
|
+
F: __dxlog_file3,
|
|
629
|
+
L: 147,
|
|
676
630
|
S: this,
|
|
677
631
|
A: [
|
|
678
632
|
"this.#kind === DXN.kind.TYPE",
|
|
@@ -742,7 +696,6 @@ var QueueSubspaceTags = Object.freeze({
|
|
|
742
696
|
});
|
|
743
697
|
export {
|
|
744
698
|
DXN,
|
|
745
|
-
IdentityDid,
|
|
746
699
|
LOCAL_SPACE_TAG,
|
|
747
700
|
PUBLIC_KEY_LENGTH,
|
|
748
701
|
PublicKey,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js", "../../../src/
|
|
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 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 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 did:halo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE\n */\nexport type IdentityDid = string & { __IdentityDid: true };\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", "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-var-requires\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 2020 DXOS.org\n//\n\nimport base32Decode from 'base32-decode';\nimport base32Encode from 'base32-encode';\nimport { type inspect, type InspectOptionsStylized } from 'node:util';\n\nimport {\n devtoolsFormatter,\n type DevtoolsFormatter,\n equalsSymbol,\n type Equatable,\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) {\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) {\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() {\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) {\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) {\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) {\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) {\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) {\n if (!PublicKey.isPublicKey(other)) {\n return false;\n }\n\n return this.equals(other);\n }\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 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 */\nexport type SpaceId = string & { __SpaceId: true };\n\nexport const SpaceId = Object.freeze({\n byteLength: 20,\n encode: (value: Uint8Array): SpaceId => {\n invariant(value instanceof Uint8Array, 'Invalid type');\n invariant(value.length === SpaceId.byteLength, 'Invalid length');\n\n return (MULTIBASE_PREFIX + base32Encode(value, 'RFC4648')) as SpaceId;\n },\n decode: (value: SpaceId): Uint8Array => {\n invariant(value.startsWith(MULTIBASE_PREFIX), 'Invalid multibase32 encoding');\n\n return new Uint8Array(base32Decode(value.slice(1), 'RFC4648'));\n },\n isValid: (value: string): value is SpaceId => {\n return typeof value === 'string' && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;\n },\n random: (): SpaceId => {\n return SpaceId.encode(randomBytes(SpaceId.byteLength));\n },\n});\n\n/**\n * Denotes RFC4648 base-32 format.\n */\nconst MULTIBASE_PREFIX = 'B';\n\nconst ENCODED_LENGTH = 33;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { inspect, InspectOptionsStylized } from 'node:util';\n\nimport { inspectCustom } from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\n\nimport type { SpaceId } from './space-id';\n\n/**\n * DXN unambiguously names a resource like an ECHO object, schema definition, plugin, etc.\n * Each DXN starts with a dx 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 * ```\n * dx:echo:<space key>:<echo id>\n * dx:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6\n * dx:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6\n * dx:type:dxos.org/type/Calendar\n * dx:plugin:dxos.org/agent/plugin/functions\n * ```\n */\nexport class DXN {\n /**\n * Kind constants.\n */\n static kind = Object.freeze({\n /**\n * dxn:type:<type name>[:<version>]\n */\n TYPE: 'type',\n /**\n * dxn:echo:<space id>:<echo id>\n * dxn:echo:@:<echo id>\n */\n ECHO: 'echo',\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 static equals(a: DXN, b: DXN) {\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 isDXNString(dxn: string) {\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) {\n try {\n return DXN.parse(dxn);\n } catch (error) {\n return undefined;\n }\n }\n\n /**\n * @example `dxn:type:example.com/type/Contact`\n */\n static fromTypename(type: string) {\n return new DXN(DXN.kind.TYPE, [type]);\n }\n\n /**\n * @example `dxn:type:example.com/type/Contact:0.1.0`\n */\n // TODO(dmaretskyi): Consider using @ as the version separator.\n static fromTypenameAndVersion(type: string, version: string) {\n return new DXN(DXN.kind.TYPE, [type, version]);\n }\n\n /**\n * @example `dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6`\n */\n static fromLocalObjectId(id: string) {\n return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, id]);\n }\n\n #kind: string;\n #parts: string[];\n\n constructor(kind: string, parts: string[]) {\n invariant(parts.length > 0);\n invariant(parts.every((part) => typeof part === 'string' && part.length > 0 && part.indexOf(':') === -1));\n\n // Per-type validation.\n switch (kind) {\n case DXN.kind.TYPE:\n if (parts.length > 2) {\n throw new Error('Invalid \"type\" DXN');\n }\n break;\n case DXN.kind.ECHO:\n if (parts.length !== 2) {\n throw new Error('Invalid \"echo\" DXN');\n }\n break;\n }\n\n this.#kind = kind;\n this.#parts = parts;\n }\n\n get kind() {\n return this.#kind;\n }\n\n get parts() {\n return this.#parts;\n }\n\n toTypename() {\n invariant(this.#kind === DXN.kind.TYPE);\n return this.#parts[0];\n }\n\n hasTypenameOf(typename: string) {\n return this.#kind === DXN.kind.TYPE && this.#parts.length === 1 && this.#parts[0] === typename;\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 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 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,\n spaceId: spaceId as SpaceId,\n queueId,\n objectId: objectId as string | undefined,\n };\n }\n\n isLocalObjectId() {\n return this.#kind === DXN.kind.ECHO && this.#parts[0] === LOCAL_SPACE_TAG && this.#parts.length === 2;\n }\n\n toString() {\n return `dxn:${this.#kind}:${this.#parts.join(':')}`;\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) {\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\nexport declare namespace DXN {\n export type TypeDXN = {\n type: string;\n version?: string;\n };\n\n export type EchoDXN = {\n spaceId?: SpaceId;\n echoId: string; // TODO(dmaretskyi): ObjectId.\n };\n\n export type QueueDXN = {\n subspaceTag: string;\n spaceId: SpaceId;\n queueId: string; // TODO(dmaretskyi): ObjectId.\n objectId?: string; // TODO(dmaretskyi): ObjectId.\n };\n}\n\n/**\n * Tags for ECHO DXNs that should resolve the object ID in the local space.\n */\nexport const LOCAL_SPACE_TAG = '@';\n\nexport const QueueSubspaceTags = Object.freeze({\n DATA: 'data',\n TRACE: 'trace',\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,qBAAWH;AACX,kBAAQ,MAAM,QAAQ,OAAO,EAAE;AAC/B;AAAA,QACF,KAAK;AACH,qBAAWC;AACX,kBAAQ,MAAM,QAAQ,OAAO,EAAE;AAC/B;AAAA,QACF,KAAK;AACH,qBAAWC;AACX,kBAAQ,MAAM,YAAY,EAAE,QAAQ,MAAM,GAAG,EAAE,QAAQ,SAAS,GAAG;A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AaH,SAASI,SAASC,QAAAA,IAAY,KAAK;AACvD,QAAI,OAAOD,YAAY,UAAU;AAC/B,aAAOnB;IACT;AAEA,WAAO;MACLkB;MACAH;MACAI;MACAC;IACF;EACF;EAEAC,kBAAkB;AAChB,WAAO,KAAK,UAAU7C,KAAIC,KAAKI,QAAQ,KAAK,OAAO,CAAA,MAAO0B,mBAAmB,KAAK,OAAOpB,WAAW;EACtG;EAEAmC,WAAW;AACT,WAAO,OAAO,KAAK,KAAK,IAAI,KAAK,OAAOC,KAAK,GAAA,CAAA;EAC/C;;;;EAKA,CAACjD,cAAAA,EAAekD,OAAeC,SAAiCC,WAA2B;AACzF,UAAMC,mBAAmB,CAACC,SAAAA;AACxB,aAAO,QAAQA,IAAAA;IACjB;AAEA,WACED,iBAAiBD,UAAUG,OAAOC,WAAY,CAAA,CAAE,IAAI,KAAKR,SAAQ,IAAKK,iBAAiBD,UAAUG,OAAOE,MAAO,CAAA,CAAE;EAErH;AACF;AAwBO,IAAMxB,kBAAkB;AAExB,IAAMyB,oBAAoBtD,OAAOC,OAAO;EAC7CsD,MAAM;EACNC,OAAO;AACT,CAAA;",
|
|
6
|
-
"names": ["RFC4648", "RFC4648_HEX", "CROCKFORD", "base32Decode", "
|
|
3
|
+
"sources": ["../../../../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js", "../../../src/public-key.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/space-id.ts", "../../../src/dxn.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 2020 DXOS.org\n//\n\nimport base32Decode from 'base32-decode';\nimport base32Encode from 'base32-encode';\nimport { type inspect, type InspectOptionsStylized } from 'node:util';\n\nimport {\n devtoolsFormatter,\n type DevtoolsFormatter,\n equalsSymbol,\n type Equatable,\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) {\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) {\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() {\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) {\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) {\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) {\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) {\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) {\n if (!PublicKey.isPublicKey(other)) {\n return false;\n }\n\n return this.equals(other);\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-var-requires\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 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 */\nexport type SpaceId = string & { __SpaceId: true };\n\nexport const SpaceId = Object.freeze({\n byteLength: 20,\n encode: (value: Uint8Array): SpaceId => {\n invariant(value instanceof Uint8Array, 'Invalid type');\n invariant(value.length === SpaceId.byteLength, 'Invalid length');\n\n return (MULTIBASE_PREFIX + base32Encode(value, 'RFC4648')) as SpaceId;\n },\n decode: (value: SpaceId): Uint8Array => {\n invariant(value.startsWith(MULTIBASE_PREFIX), 'Invalid multibase32 encoding');\n\n return new Uint8Array(base32Decode(value.slice(1), 'RFC4648'));\n },\n isValid: (value: string): value is SpaceId => {\n return typeof value === 'string' && value.startsWith(MULTIBASE_PREFIX) && value.length === ENCODED_LENGTH;\n },\n random: (): SpaceId => {\n return SpaceId.encode(randomBytes(SpaceId.byteLength));\n },\n});\n\n/**\n * Denotes RFC4648 base-32 format.\n */\nconst MULTIBASE_PREFIX = 'B';\n\nconst ENCODED_LENGTH = 33;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport type { inspect, InspectOptionsStylized } from 'node:util';\n\nimport { inspectCustom } from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\n\nimport type { SpaceId } from './space-id';\n\n/**\n * DXN unambiguously names a resource like an ECHO object, schema definition, plugin, etc.\n * Each DXN starts with a dx 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 * ```\n * dx:echo:<space key>:<echo id>\n * dx:echo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6\n * dx:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6\n * dx:type:dxos.org/type/Calendar\n * dx:plugin:dxos.org/agent/plugin/functions\n * ```\n */\nexport class DXN {\n /**\n * Kind constants.\n */\n static kind = Object.freeze({\n /**\n * dxn:type:<type name>[:<version>]\n */\n TYPE: 'type',\n /**\n * dxn:echo:<space id>:<echo id>\n * dxn:echo:@:<echo id>\n */\n ECHO: 'echo',\n /**\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 static equals(a: DXN, b: DXN) {\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 isDXNString(dxn: string) {\n return dxn.startsWith('dxn:');\n }\n\n static parse(dxn: string): DXN;\n static parse(dxn: string, noThrow: boolean): DXN | undefined;\n static parse(dxn: string, noThrow?: boolean): DXN | undefined {\n if (typeof dxn !== 'string') {\n if (noThrow) {\n return undefined;\n }\n throw new Error(`Invalid DXN: ${dxn}`);\n }\n const [prefix, kind, ...parts] = dxn.split(':');\n if (!(prefix === 'dxn')) {\n if (noThrow) {\n return undefined;\n }\n throw new Error(`Invalid DXN: ${dxn}`);\n }\n if (!(typeof kind === 'string' && kind.length > 0)) {\n if (noThrow) {\n return undefined;\n }\n throw new Error(`Invalid DXN: ${dxn}`);\n }\n if (!(parts.length > 0)) {\n if (noThrow) {\n return undefined;\n }\n throw new Error(`Invalid DXN: ${dxn}`);\n }\n\n return new DXN(kind, parts);\n }\n\n /**\n * @example `dxn:type:example.com/type/Contact`\n */\n static fromTypename(type: string) {\n return new DXN(DXN.kind.TYPE, [type]);\n }\n\n /**\n * @example `dxn:type:example.com/type/Contact:0.1.0`\n */\n // TODO(dmaretskyi): Consider using @ as the version separator.\n static fromTypenameAndVersion(type: string, version: string) {\n return new DXN(DXN.kind.TYPE, [type, version]);\n }\n\n /**\n * @example `dxn:echo:@:01J00J9B45YHYSGZQTQMSKMGJ6`\n */\n static fromLocalObjectId(id: string) {\n return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, id]);\n }\n\n #kind: string;\n #parts: string[];\n\n constructor(kind: string, parts: string[]) {\n invariant(parts.length > 0);\n invariant(parts.every((part) => typeof part === 'string' && part.length > 0 && part.indexOf(':') === -1));\n\n // Per-type validation.\n switch (kind) {\n case DXN.kind.TYPE:\n if (parts.length > 2) {\n throw new Error('Invalid \"type\" DXN');\n }\n break;\n case DXN.kind.ECHO:\n if (parts.length !== 2) {\n throw new Error('Invalid \"echo\" DXN');\n }\n break;\n }\n\n this.#kind = kind;\n this.#parts = parts;\n }\n\n get kind() {\n return this.#kind;\n }\n\n get parts() {\n return this.#parts;\n }\n\n toTypename() {\n invariant(this.#kind === DXN.kind.TYPE);\n return this.#parts[0];\n }\n\n hasTypenameOf(typename: string) {\n return this.#kind === DXN.kind.TYPE && this.#parts.length === 1 && this.#parts[0] === typename;\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 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 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 return {\n subspaceTag,\n spaceId: spaceId as SpaceId,\n queueId,\n objectId: objectId as string | undefined,\n };\n }\n\n isLocalObjectId() {\n return this.#kind === DXN.kind.ECHO && this.#parts[0] === LOCAL_SPACE_TAG && this.#parts.length === 2;\n }\n\n toString() {\n return `dxn:${this.#kind}:${this.#parts.join(':')}`;\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) {\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\nexport declare namespace DXN {\n export type TypeDXN = {\n type: string;\n version?: string;\n };\n\n export type EchoDXN = {\n spaceId?: SpaceId;\n echoId: string; // TODO(dmaretskyi): ObjectId.\n };\n\n export type QueueDXN = {\n subspaceTag: string;\n spaceId: SpaceId;\n queueId: string; // TODO(dmaretskyi): ObjectId.\n objectId?: string; // TODO(dmaretskyi): ObjectId.\n };\n}\n\n/**\n * Tags for ECHO DXNs that should resolve the object ID in the local space.\n */\nexport const LOCAL_SPACE_TAG = '@';\n\nexport const QueueSubspaceTags = Object.freeze({\n DATA: 'data',\n TRACE: 'trace',\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,QAAIA,WAAU;AACd,QAAIC,eAAc;AAClB,QAAIC,aAAY;A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KAAK,OAAOnB,WAAW;EACtG;EAEAkC,WAAW;AACT,WAAO,OAAO,KAAK,KAAK,IAAI,KAAK,OAAOC,KAAK,GAAA,CAAA;EAC/C;;;;EAKA,CAAChD,cAAAA,EAAeiD,OAAeC,SAAiCC,WAA2B;AACzF,UAAMC,mBAAmB,CAACC,SAAAA;AACxB,aAAO,QAAQA,IAAAA;IACjB;AAEA,WACED,iBAAiBD,UAAUG,OAAOC,WAAY,CAAA,CAAE,IAAI,KAAKR,SAAQ,IAAKK,iBAAiBD,UAAUG,OAAOE,MAAO,CAAA,CAAE;EAErH;AACF;AAwBO,IAAMxB,kBAAkB;AAExB,IAAMyB,oBAAoBrD,OAAOC,OAAO;EAC7CqD,MAAM;EACNC,OAAO;AACT,CAAA;",
|
|
6
|
+
"names": ["RFC4648", "RFC4648_HEX", "CROCKFORD", "base32Decode", "devtoolsFormatter", "equalsSymbol", "inspectCustom", "truncateKey", "invariant", "randomBytes", "length", "webCrypto", "globalThis", "crypto", "require", "webcrypto", "bytes", "Uint8Array", "getRandomValues", "PUBLIC_KEY_LENGTH", "SECRET_KEY_LENGTH", "isLikeArrayBuffer", "value", "Object", "getPrototypeOf", "constructor", "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", "import_base32_decode", "invariant", "SpaceId", "Object", "freeze", "byteLength", "encode", "value", "invariant", "Uint8Array", "length", "MULTIBASE_PREFIX", "base32Encode", "decode", "startsWith", "base32Decode", "slice", "isValid", "ENCODED_LENGTH", "random", "randomBytes", "inspectCustom", "invariant", "DXN", "kind", "Object", "freeze", "TYPE", "ECHO", "QUEUE", "equals", "a", "b", "parts", "length", "every", "part", "i", "isDXNString", "dxn", "startsWith", "parse", "noThrow", "undefined", "Error", "prefix", "split", "fromTypename", "type", "fromTypenameAndVersion", "version", "fromLocalObjectId", "id", "LOCAL_SPACE_TAG", "constructor", "indexOf", "toTypename", "hasTypenameOf", "typename", "asTypeDXN", "asEchoDXN", "spaceId", "echoId", "asQueueDXN", "subspaceTag", "queueId", "objectId", "isLocalObjectId", "toString", "join", "depth", "options", "inspectFn", "printControlCode", "code", "colors", "blueBright", "reset", "QueueSubspaceTags", "DATA", "TRACE"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"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"},"packages/common/keys/src/random-bytes.ts":{"bytes":1792,"imports":[{"path":"node:crypto","kind":"require-call","external":true}],"format":"esm"},"packages/common/keys/src/
|
|
1
|
+
{"inputs":{"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"},"packages/common/keys/src/random-bytes.ts":{"bytes":1792,"imports":[{"path":"node:crypto","kind":"require-call","external":true}],"format":"esm"},"packages/common/keys/src/public-key.ts":{"bytes":31358,"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":"packages/common/keys/src/random-bytes.ts","kind":"import-statement","original":"./random-bytes"}],"format":"esm"},"packages/common/keys/src/types.ts":{"bytes":528,"imports":[],"format":"esm"},"packages/common/keys/src/space-id.ts":{"bytes":5162,"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":"packages/common/keys/src/random-bytes.ts","kind":"import-statement","original":"./random-bytes"}],"format":"esm"},"packages/common/keys/src/dxn.ts":{"bytes":21416,"imports":[{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"format":"esm"},"packages/common/keys/src/index.ts":{"bytes":746,"imports":[{"path":"packages/common/keys/src/public-key.ts","kind":"import-statement","original":"./public-key"},{"path":"packages/common/keys/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/common/keys/src/space-id.ts","kind":"import-statement","original":"./space-id"},{"path":"packages/common/keys/src/dxn.ts","kind":"import-statement","original":"./dxn"}],"format":"esm"}},"outputs":{"packages/common/keys/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":33424},"packages/common/keys/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@dxos/debug","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","LOCAL_SPACE_TAG","PUBLIC_KEY_LENGTH","PublicKey","QueueSubspaceTags","SECRET_KEY_LENGTH","SpaceId"],"entryPoint":"packages/common/keys/src/index.ts","inputs":{"node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js":{"bytesInOutput":1554},"packages/common/keys/src/public-key.ts":{"bytesInOutput":7891},"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},"packages/common/keys/src/random-bytes.ts":{"bytesInOutput":204},"packages/common/keys/src/index.ts":{"bytesInOutput":0},"packages/common/keys/src/space-id.ts":{"bytesInOutput":1431},"packages/common/keys/src/dxn.ts":{"bytesInOutput":5007}},"bytes":20111}}}
|
package/dist/types/src/dxn.d.ts
CHANGED
|
@@ -34,8 +34,7 @@ export declare class DXN {
|
|
|
34
34
|
*/
|
|
35
35
|
ECHO: "echo";
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
* dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
|
|
37
|
+
* dxn:queue:<subspace tag>:<space id>:<queue id>[:object id]
|
|
39
38
|
* dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
|
|
40
39
|
* dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
|
|
41
40
|
*/
|
|
@@ -44,7 +43,7 @@ export declare class DXN {
|
|
|
44
43
|
static equals(a: DXN, b: DXN): boolean;
|
|
45
44
|
static isDXNString(dxn: string): boolean;
|
|
46
45
|
static parse(dxn: string): DXN;
|
|
47
|
-
static
|
|
46
|
+
static parse(dxn: string, noThrow: boolean): DXN | undefined;
|
|
48
47
|
/**
|
|
49
48
|
* @example `dxn:type:example.com/type/Contact`
|
|
50
49
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dxn.d.ts","sourceRoot":"","sources":["../../../src/dxn.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,GAAG;;IACd;;OAEG;IACH,MAAM,CAAC,IAAI;QACT;;WAEG;;QAEH;;;WAGG;;QAEH
|
|
1
|
+
{"version":3,"file":"dxn.d.ts","sourceRoot":"","sources":["../../../src/dxn.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,GAAG;;IACd;;OAEG;IACH,MAAM,CAAC,IAAI;QACT;;WAEG;;QAEH;;;WAGG;;QAEH;;;;WAIG;;OAEF;IAEH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG;IAI5B,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM;IAI9B,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IAC9B,MAA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AAM,iBAAiB;;;EAG5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.7.
|
|
1
|
+
{"version":"5.7.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/keys",
|
|
3
|
-
"version": "0.7.5-labs.
|
|
3
|
+
"version": "0.7.5-labs.a279d8c",
|
|
4
4
|
"description": "Key utils and definitions.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"src"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/node-std": "0.7.5-labs.
|
|
29
|
+
"@dxos/debug": "0.7.5-labs.a279d8c",
|
|
30
|
+
"@dxos/invariant": "0.7.5-labs.a279d8c",
|
|
31
|
+
"@dxos/node-std": "0.7.5-labs.a279d8c"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"base32-decode": "^1.0.0",
|