@dxos/keys 0.7.5-labs.a279d8c → 0.7.5-labs.e27f9b9
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 +101 -53
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +96 -50
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +100 -53
- 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 +3 -2
- package/dist/types/src/dxn.d.ts.map +1 -1
- package/dist/types/src/identity-did.d.ts +16 -0
- package/dist/types/src/identity-did.d.ts.map +1 -0
- package/dist/types/src/identity-did.test.d.ts +2 -0
- package/dist/types/src/identity-did.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- 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 +12 -16
- package/src/identity-did.test.ts +17 -0
- package/src/identity-did.ts +49 -0
- package/src/index.ts +1 -0
|
@@ -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 base32Decode4(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/identity-did.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,8 +143,7 @@ function base32Encode(data, variant, options) {
|
|
|
143
143
|
return output;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
// packages/common/keys/src/
|
|
147
|
-
import { devtoolsFormatter, equalsSymbol, inspectCustom, truncateKey } from "@dxos/debug";
|
|
146
|
+
// packages/common/keys/src/identity-did.ts
|
|
148
147
|
import { invariant } from "@dxos/invariant";
|
|
149
148
|
|
|
150
149
|
// packages/common/keys/src/random-bytes.ts
|
|
@@ -155,8 +154,59 @@ var randomBytes = (length) => {
|
|
|
155
154
|
return bytes;
|
|
156
155
|
};
|
|
157
156
|
|
|
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
|
+
|
|
158
205
|
// packages/common/keys/src/public-key.ts
|
|
159
|
-
var
|
|
206
|
+
var import_base32_decode2 = __toESM(require_base32_decode());
|
|
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";
|
|
160
210
|
var PUBLIC_KEY_LENGTH = 32;
|
|
161
211
|
var SECRET_KEY_LENGTH = 64;
|
|
162
212
|
var isLikeArrayBuffer = (value) => typeof value === "object" && value !== null && Object.getPrototypeOf(value).constructor.name === "ArrayBuffer";
|
|
@@ -170,8 +220,8 @@ var PublicKey = class _PublicKey {
|
|
|
170
220
|
* @returns PublicKey
|
|
171
221
|
*/
|
|
172
222
|
static from(source) {
|
|
173
|
-
|
|
174
|
-
F:
|
|
223
|
+
invariant2(source, void 0, {
|
|
224
|
+
F: __dxlog_file2,
|
|
175
225
|
L: 49,
|
|
176
226
|
S: this,
|
|
177
227
|
A: [
|
|
@@ -262,8 +312,8 @@ var PublicKey = class _PublicKey {
|
|
|
262
312
|
* @deprecated All keys should be represented as instances of PublicKey.
|
|
263
313
|
*/
|
|
264
314
|
static bufferize(str) {
|
|
265
|
-
|
|
266
|
-
F:
|
|
315
|
+
invariant2(typeof str === "string", "Invalid type", {
|
|
316
|
+
F: __dxlog_file2,
|
|
267
317
|
L: 152,
|
|
268
318
|
S: this,
|
|
269
319
|
A: [
|
|
@@ -285,8 +335,8 @@ var PublicKey = class _PublicKey {
|
|
|
285
335
|
} else if (key instanceof Uint8Array) {
|
|
286
336
|
key = Buffer.from(key.buffer, key.byteOffset, key.byteLength);
|
|
287
337
|
}
|
|
288
|
-
|
|
289
|
-
F:
|
|
338
|
+
invariant2(key instanceof Buffer, "Invalid type", {
|
|
339
|
+
F: __dxlog_file2,
|
|
290
340
|
L: 171,
|
|
291
341
|
S: this,
|
|
292
342
|
A: [
|
|
@@ -304,8 +354,8 @@ var PublicKey = class _PublicKey {
|
|
|
304
354
|
return key.toHex();
|
|
305
355
|
}
|
|
306
356
|
static fromMultibase32(encoded) {
|
|
307
|
-
|
|
308
|
-
F:
|
|
357
|
+
invariant2(encoded.startsWith("B"), "Invalid multibase32 encoding", {
|
|
358
|
+
F: __dxlog_file2,
|
|
309
359
|
L: 184,
|
|
310
360
|
S: this,
|
|
311
361
|
A: [
|
|
@@ -313,7 +363,7 @@ var PublicKey = class _PublicKey {
|
|
|
313
363
|
"'Invalid multibase32 encoding'"
|
|
314
364
|
]
|
|
315
365
|
});
|
|
316
|
-
return new _PublicKey(new Uint8Array((0,
|
|
366
|
+
return new _PublicKey(new Uint8Array((0, import_base32_decode2.default)(encoded.slice(1), "RFC4648")));
|
|
317
367
|
}
|
|
318
368
|
constructor(_value) {
|
|
319
369
|
this._value = _value;
|
|
@@ -445,14 +495,14 @@ var PublicKey = class _PublicKey {
|
|
|
445
495
|
};
|
|
446
496
|
|
|
447
497
|
// packages/common/keys/src/space-id.ts
|
|
448
|
-
var
|
|
449
|
-
import { invariant as
|
|
450
|
-
var
|
|
498
|
+
var import_base32_decode3 = __toESM(require_base32_decode());
|
|
499
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
500
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/common/keys/src/space-id.ts";
|
|
451
501
|
var SpaceId = Object.freeze({
|
|
452
502
|
byteLength: 20,
|
|
453
503
|
encode: (value) => {
|
|
454
|
-
|
|
455
|
-
F:
|
|
504
|
+
invariant3(value instanceof Uint8Array, "Invalid type", {
|
|
505
|
+
F: __dxlog_file3,
|
|
456
506
|
L: 22,
|
|
457
507
|
S: void 0,
|
|
458
508
|
A: [
|
|
@@ -460,8 +510,8 @@ var SpaceId = Object.freeze({
|
|
|
460
510
|
"'Invalid type'"
|
|
461
511
|
]
|
|
462
512
|
});
|
|
463
|
-
|
|
464
|
-
F:
|
|
513
|
+
invariant3(value.length === SpaceId.byteLength, "Invalid length", {
|
|
514
|
+
F: __dxlog_file3,
|
|
465
515
|
L: 23,
|
|
466
516
|
S: void 0,
|
|
467
517
|
A: [
|
|
@@ -469,11 +519,11 @@ var SpaceId = Object.freeze({
|
|
|
469
519
|
"'Invalid length'"
|
|
470
520
|
]
|
|
471
521
|
});
|
|
472
|
-
return
|
|
522
|
+
return MULTIBASE_PREFIX2 + base32Encode(value, "RFC4648");
|
|
473
523
|
},
|
|
474
524
|
decode: (value) => {
|
|
475
|
-
|
|
476
|
-
F:
|
|
525
|
+
invariant3(value.startsWith(MULTIBASE_PREFIX2), "Invalid multibase32 encoding", {
|
|
526
|
+
F: __dxlog_file3,
|
|
477
527
|
L: 28,
|
|
478
528
|
S: void 0,
|
|
479
529
|
A: [
|
|
@@ -481,22 +531,22 @@ var SpaceId = Object.freeze({
|
|
|
481
531
|
"'Invalid multibase32 encoding'"
|
|
482
532
|
]
|
|
483
533
|
});
|
|
484
|
-
return new Uint8Array((0,
|
|
534
|
+
return new Uint8Array((0, import_base32_decode3.default)(value.slice(1), "RFC4648"));
|
|
485
535
|
},
|
|
486
536
|
isValid: (value) => {
|
|
487
|
-
return typeof value === "string" && value.startsWith(
|
|
537
|
+
return typeof value === "string" && value.startsWith(MULTIBASE_PREFIX2) && value.length === ENCODED_LENGTH2;
|
|
488
538
|
},
|
|
489
539
|
random: () => {
|
|
490
540
|
return SpaceId.encode(randomBytes(SpaceId.byteLength));
|
|
491
541
|
}
|
|
492
542
|
});
|
|
493
|
-
var
|
|
494
|
-
var
|
|
543
|
+
var MULTIBASE_PREFIX2 = "B";
|
|
544
|
+
var ENCODED_LENGTH2 = 33;
|
|
495
545
|
|
|
496
546
|
// packages/common/keys/src/dxn.ts
|
|
497
547
|
import { inspectCustom as inspectCustom2 } from "@dxos/debug";
|
|
498
|
-
import { invariant as
|
|
499
|
-
var
|
|
548
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
549
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/common/keys/src/dxn.ts";
|
|
500
550
|
var DXN = class _DXN {
|
|
501
551
|
static {
|
|
502
552
|
/**
|
|
@@ -513,7 +563,8 @@ var DXN = class _DXN {
|
|
|
513
563
|
*/
|
|
514
564
|
ECHO: "echo",
|
|
515
565
|
/**
|
|
516
|
-
*
|
|
566
|
+
* The subspace tag enables us to partition queues by usage within the context of a space.
|
|
567
|
+
* dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
|
|
517
568
|
* dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
|
|
518
569
|
* dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
|
|
519
570
|
*/
|
|
@@ -526,34 +577,29 @@ var DXN = class _DXN {
|
|
|
526
577
|
static isDXNString(dxn) {
|
|
527
578
|
return dxn.startsWith("dxn:");
|
|
528
579
|
}
|
|
529
|
-
static parse(dxn
|
|
580
|
+
static parse(dxn) {
|
|
530
581
|
if (typeof dxn !== "string") {
|
|
531
|
-
if (noThrow) {
|
|
532
|
-
return void 0;
|
|
533
|
-
}
|
|
534
582
|
throw new Error(`Invalid DXN: ${dxn}`);
|
|
535
583
|
}
|
|
536
584
|
const [prefix, kind, ...parts] = dxn.split(":");
|
|
537
585
|
if (!(prefix === "dxn")) {
|
|
538
|
-
if (noThrow) {
|
|
539
|
-
return void 0;
|
|
540
|
-
}
|
|
541
586
|
throw new Error(`Invalid DXN: ${dxn}`);
|
|
542
587
|
}
|
|
543
588
|
if (!(typeof kind === "string" && kind.length > 0)) {
|
|
544
|
-
if (noThrow) {
|
|
545
|
-
return void 0;
|
|
546
|
-
}
|
|
547
589
|
throw new Error(`Invalid DXN: ${dxn}`);
|
|
548
590
|
}
|
|
549
591
|
if (!(parts.length > 0)) {
|
|
550
|
-
if (noThrow) {
|
|
551
|
-
return void 0;
|
|
552
|
-
}
|
|
553
592
|
throw new Error(`Invalid DXN: ${dxn}`);
|
|
554
593
|
}
|
|
555
594
|
return new _DXN(kind, parts);
|
|
556
595
|
}
|
|
596
|
+
static tryParse(dxn) {
|
|
597
|
+
try {
|
|
598
|
+
return _DXN.parse(dxn);
|
|
599
|
+
} catch (error) {
|
|
600
|
+
return void 0;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
557
603
|
/**
|
|
558
604
|
* @example `dxn:type:example.com/type/Contact`
|
|
559
605
|
*/
|
|
@@ -584,18 +630,18 @@ var DXN = class _DXN {
|
|
|
584
630
|
#kind;
|
|
585
631
|
#parts;
|
|
586
632
|
constructor(kind, parts) {
|
|
587
|
-
|
|
588
|
-
F:
|
|
589
|
-
L:
|
|
633
|
+
invariant4(parts.length > 0, void 0, {
|
|
634
|
+
F: __dxlog_file4,
|
|
635
|
+
L: 112,
|
|
590
636
|
S: this,
|
|
591
637
|
A: [
|
|
592
638
|
"parts.length > 0",
|
|
593
639
|
""
|
|
594
640
|
]
|
|
595
641
|
});
|
|
596
|
-
|
|
597
|
-
F:
|
|
598
|
-
L:
|
|
642
|
+
invariant4(parts.every((part) => typeof part === "string" && part.length > 0 && part.indexOf(":") === -1), void 0, {
|
|
643
|
+
F: __dxlog_file4,
|
|
644
|
+
L: 113,
|
|
599
645
|
S: this,
|
|
600
646
|
A: [
|
|
601
647
|
"parts.every((part) => typeof part === 'string' && part.length > 0 && part.indexOf(':') === -1)",
|
|
@@ -624,9 +670,9 @@ var DXN = class _DXN {
|
|
|
624
670
|
return this.#parts;
|
|
625
671
|
}
|
|
626
672
|
toTypename() {
|
|
627
|
-
|
|
628
|
-
F:
|
|
629
|
-
L:
|
|
673
|
+
invariant4(this.#kind === _DXN.kind.TYPE, void 0, {
|
|
674
|
+
F: __dxlog_file4,
|
|
675
|
+
L: 142,
|
|
630
676
|
S: this,
|
|
631
677
|
A: [
|
|
632
678
|
"this.#kind === DXN.kind.TYPE",
|
|
@@ -696,6 +742,7 @@ var QueueSubspaceTags = Object.freeze({
|
|
|
696
742
|
});
|
|
697
743
|
export {
|
|
698
744
|
DXN,
|
|
745
|
+
IdentityDid,
|
|
699
746
|
LOCAL_SPACE_TAG,
|
|
700
747
|
PUBLIC_KEY_LENGTH,
|
|
701
748
|
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 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;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,S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AAmB,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", "
|
|
3
|
+
"sources": ["../../../../../../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js", "../../../src/identity-did.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/public-key.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 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;AACnE;AAAA,QACF;AACE,gBAAM,IAAI,MAAM,6BAA6B,OAAO;AAAA,MACxD;AAEA,UAAI,SAAS,MAAM;AAEnB,UAAI,OAAO;AACX,UAAI,QAAQ;AAEZ,UAAI,QAAQ;AACZ,UAAI,SAAS,IAAI,WAAY,SAAS,IAAI,IAAK,CAAC;AAEhD,eAAS,IAAI,GAAG,IA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mB,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", "invariant", "randomBytes", "length", "webCrypto", "globalThis", "crypto", "require", "webcrypto", "bytes", "Uint8Array", "getRandomValues", "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", "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", "Error", "prefix", "split", "tryParse", "error", "undefined", "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/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":
|
|
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/identity-did.ts":{"bytes":5539,"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/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":21142,"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":846,"imports":[{"path":"packages/common/keys/src/identity-did.ts","kind":"import-statement","original":"./identity-did"},{"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":35904},"packages/common/keys/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true}],"exports":["DXN","IdentityDid","LOCAL_SPACE_TAG","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/identity-did.ts":{"bytesInOutput":1515},"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/public-key.ts":{"bytesInOutput":7916},"packages/common/keys/src/space-id.ts":{"bytesInOutput":1437},"packages/common/keys/src/dxn.ts":{"bytesInOutput":5004}},"bytes":21718}}}
|
package/dist/types/src/dxn.d.ts
CHANGED
|
@@ -34,7 +34,8 @@ export declare class DXN {
|
|
|
34
34
|
*/
|
|
35
35
|
ECHO: "echo";
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* The subspace tag enables us to partition queues by usage within the context of a space.
|
|
38
|
+
* dxn:queue:<subspace_tag>:<space_id>:<queue_id>[:object_id]
|
|
38
39
|
* dxn:queue:data:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
|
|
39
40
|
* dxn:queue:trace:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE:01J00J9B45YHYSGZQTQMSKMGJ6
|
|
40
41
|
*/
|
|
@@ -43,7 +44,7 @@ export declare class DXN {
|
|
|
43
44
|
static equals(a: DXN, b: DXN): boolean;
|
|
44
45
|
static isDXNString(dxn: string): boolean;
|
|
45
46
|
static parse(dxn: string): DXN;
|
|
46
|
-
static
|
|
47
|
+
static tryParse(dxn: string): DXN | undefined;
|
|
47
48
|
/**
|
|
48
49
|
* @example `dxn:type:example.com/type/Contact`
|
|
49
50
|
*/
|
|
@@ -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;;;;;WAKG;;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;IAkB9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0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A unique identifier for a space.
|
|
3
|
+
* 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).
|
|
4
|
+
* @example did:halo:BA25QRC2FEWCSAMRP4RZL65LWJ7352CKE
|
|
5
|
+
*/
|
|
6
|
+
export type IdentityDid = string & {
|
|
7
|
+
__IdentityDid: true;
|
|
8
|
+
};
|
|
9
|
+
export declare const IdentityDid: Readonly<{
|
|
10
|
+
byteLength: 20;
|
|
11
|
+
encode: (value: Uint8Array) => IdentityDid;
|
|
12
|
+
decode: (value: IdentityDid) => Uint8Array;
|
|
13
|
+
isValid: (value: string) => value is IdentityDid;
|
|
14
|
+
random: () => IdentityDid;
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=identity-did.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-did.d.ts","sourceRoot":"","sources":["../../../src/identity-did.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG;IAAE,aAAa,EAAE,IAAI,CAAA;CAAE,CAAC;AAE3D,eAAO,MAAM,WAAW;;oBAEN,UAAU,KAAG,WAAW;oBAMxB,WAAW,KAAG,UAAU;qBAKvB,MAAM,KAAG,KAAK,IAAI,WAAW;kBAKlC,WAAW;EAGvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-did.test.d.ts","sourceRoot":"","sources":["../../../src/identity-did.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
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
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,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.3"}
|
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.e27f9b9",
|
|
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/
|
|
29
|
+
"@dxos/invariant": "0.7.5-labs.e27f9b9",
|
|
30
|
+
"@dxos/node-std": "0.7.5-labs.e27f9b9",
|
|
31
|
+
"@dxos/debug": "0.7.5-labs.e27f9b9"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"base32-decode": "^1.0.0",
|