@atproto/lexicon 0.0.4 → 0.1.0
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/blob-refs.d.ts +67 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3072 -392
- package/dist/index.js.map +4 -4
- package/dist/lexicons.d.ts +6 -4
- package/dist/serialize.d.ts +12 -0
- package/dist/types.d.ts +24498 -15979
- package/dist/util.d.ts +1 -1
- package/dist/validation.d.ts +6 -5
- package/dist/validators/blob.d.ts +0 -3
- package/dist/validators/complex.d.ts +2 -2
- package/dist/validators/formats.d.ts +9 -0
- package/dist/validators/primitives.d.ts +3 -2
- package/dist/validators/xrpc.d.ts +1 -1
- package/package.json +5 -1
- package/src/blob-refs.ts +70 -0
- package/src/index.ts +2 -0
- package/src/lexicons.ts +36 -5
- package/src/serialize.ts +93 -0
- package/src/types.ts +86 -58
- package/src/util.ts +3 -4
- package/src/validation.ts +28 -4
- package/src/validators/blob.ts +5 -43
- package/src/validators/complex.ts +33 -32
- package/src/validators/formats.ts +107 -0
- package/src/validators/primitives.ts +116 -41
- package/src/validators/xrpc.ts +29 -29
- package/tests/_scaffolds/lexicons.ts +198 -23
- package/tests/general.test.ts +365 -154
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +3 -1
package/dist/index.js
CHANGED
|
@@ -9,14 +9,14 @@ var __commonJS = (cb, mod2) => function __require() {
|
|
|
9
9
|
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
|
|
10
10
|
};
|
|
11
11
|
var __export = (target, all) => {
|
|
12
|
-
for (var
|
|
13
|
-
__defProp(target,
|
|
12
|
+
for (var name2 in all)
|
|
13
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
14
14
|
};
|
|
15
|
-
var __copyProps = (to,
|
|
16
|
-
if (
|
|
17
|
-
for (let key of __getOwnPropNames(
|
|
15
|
+
var __copyProps = (to, from3, except, desc) => {
|
|
16
|
+
if (from3 && typeof from3 === "object" || typeof from3 === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from3))
|
|
18
18
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () =>
|
|
19
|
+
__defProp(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc(from3, key)) || desc.enumerable });
|
|
20
20
|
}
|
|
21
21
|
return to;
|
|
22
22
|
};
|
|
@@ -76,8 +76,9 @@ var require_dist = __commonJS({
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
// src/index.ts
|
|
79
|
-
var
|
|
80
|
-
__export(
|
|
79
|
+
var src_exports4 = {};
|
|
80
|
+
__export(src_exports4, {
|
|
81
|
+
BlobRef: () => BlobRef,
|
|
81
82
|
InvalidLexiconError: () => InvalidLexiconError,
|
|
82
83
|
LexiconDefNotFoundError: () => LexiconDefNotFoundError,
|
|
83
84
|
LexiconDocMalformedError: () => LexiconDocMalformedError,
|
|
@@ -85,37 +86,48 @@ __export(src_exports, {
|
|
|
85
86
|
ValidationError: () => ValidationError,
|
|
86
87
|
discriminatedObject: () => discriminatedObject,
|
|
87
88
|
hasProp: () => hasProp,
|
|
89
|
+
ipldToLex: () => ipldToLex,
|
|
88
90
|
isDiscriminatedObject: () => isDiscriminatedObject,
|
|
89
91
|
isObj: () => isObj,
|
|
90
92
|
isValidLexiconDoc: () => isValidLexiconDoc,
|
|
93
|
+
jsonBlobRef: () => jsonBlobRef,
|
|
94
|
+
jsonStringToLex: () => jsonStringToLex,
|
|
95
|
+
jsonToLex: () => jsonToLex,
|
|
91
96
|
lexArray: () => lexArray,
|
|
92
|
-
lexAudio: () => lexAudio,
|
|
93
97
|
lexBlob: () => lexBlob,
|
|
94
|
-
lexBlobVariant: () => lexBlobVariant,
|
|
95
98
|
lexBoolean: () => lexBoolean,
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
lexBytes: () => lexBytes,
|
|
100
|
+
lexCidLink: () => lexCidLink,
|
|
101
|
+
lexFloat: () => lexFloat,
|
|
98
102
|
lexInteger: () => lexInteger,
|
|
99
|
-
|
|
103
|
+
lexIpldType: () => lexIpldType,
|
|
100
104
|
lexObject: () => lexObject,
|
|
101
105
|
lexPrimitive: () => lexPrimitive,
|
|
106
|
+
lexPrimitiveArray: () => lexPrimitiveArray,
|
|
102
107
|
lexRecord: () => lexRecord,
|
|
103
108
|
lexRef: () => lexRef,
|
|
104
109
|
lexRefUnion: () => lexRefUnion,
|
|
105
110
|
lexRefVariant: () => lexRefVariant,
|
|
106
111
|
lexString: () => lexString,
|
|
112
|
+
lexStringFormat: () => lexStringFormat,
|
|
113
|
+
lexToIpld: () => lexToIpld,
|
|
114
|
+
lexToJson: () => lexToJson,
|
|
107
115
|
lexToken: () => lexToken,
|
|
108
116
|
lexUnknown: () => lexUnknown,
|
|
109
117
|
lexUserType: () => lexUserType,
|
|
110
|
-
lexVideo: () => lexVideo,
|
|
111
118
|
lexXrpcBody: () => lexXrpcBody,
|
|
112
119
|
lexXrpcError: () => lexXrpcError,
|
|
113
120
|
lexXrpcParameters: () => lexXrpcParameters,
|
|
114
121
|
lexXrpcProcedure: () => lexXrpcProcedure,
|
|
115
122
|
lexXrpcQuery: () => lexXrpcQuery,
|
|
116
|
-
|
|
123
|
+
lexXrpcSubscription: () => lexXrpcSubscription,
|
|
124
|
+
lexXrpcSubscriptionMessage: () => lexXrpcSubscriptionMessage,
|
|
125
|
+
lexiconDoc: () => lexiconDoc,
|
|
126
|
+
stringifyLex: () => stringifyLex,
|
|
127
|
+
typedJsonBlobRef: () => typedJsonBlobRef,
|
|
128
|
+
untypedJsonBlobRef: () => untypedJsonBlobRef
|
|
117
129
|
});
|
|
118
|
-
module.exports = __toCommonJS(
|
|
130
|
+
module.exports = __toCommonJS(src_exports4);
|
|
119
131
|
|
|
120
132
|
// ../../node_modules/zod/lib/index.mjs
|
|
121
133
|
var util;
|
|
@@ -582,10 +594,10 @@ function processCreateParams(params2) {
|
|
|
582
594
|
return { errorMap: customMap, description };
|
|
583
595
|
}
|
|
584
596
|
var ZodType = class {
|
|
585
|
-
constructor(
|
|
597
|
+
constructor(def2) {
|
|
586
598
|
this.spa = this.safeParseAsync;
|
|
587
599
|
this.superRefine = this._refinement;
|
|
588
|
-
this._def =
|
|
600
|
+
this._def = def2;
|
|
589
601
|
this.parse = this.parse.bind(this);
|
|
590
602
|
this.safeParse = this.safeParse.bind(this);
|
|
591
603
|
this.parseAsync = this.parseAsync.bind(this);
|
|
@@ -772,8 +784,8 @@ var ZodType = class {
|
|
|
772
784
|
effect: { type: "transform", transform }
|
|
773
785
|
});
|
|
774
786
|
}
|
|
775
|
-
default(
|
|
776
|
-
const defaultValueFunc = typeof
|
|
787
|
+
default(def2) {
|
|
788
|
+
const defaultValueFunc = typeof def2 === "function" ? def2 : () => def2;
|
|
777
789
|
return new ZodDefault({
|
|
778
790
|
innerType: this,
|
|
779
791
|
defaultValue: defaultValueFunc,
|
|
@@ -1485,7 +1497,7 @@ ZodVoid.create = (params2) => {
|
|
|
1485
1497
|
var ZodArray = class extends ZodType {
|
|
1486
1498
|
_parse(input) {
|
|
1487
1499
|
const { ctx, status } = this._processInputParams(input);
|
|
1488
|
-
const
|
|
1500
|
+
const def2 = this._def;
|
|
1489
1501
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
1490
1502
|
addIssueToContext(ctx, {
|
|
1491
1503
|
code: ZodIssueCode.invalid_type,
|
|
@@ -1494,39 +1506,39 @@ var ZodArray = class extends ZodType {
|
|
|
1494
1506
|
});
|
|
1495
1507
|
return INVALID;
|
|
1496
1508
|
}
|
|
1497
|
-
if (
|
|
1498
|
-
if (ctx.data.length <
|
|
1509
|
+
if (def2.minLength !== null) {
|
|
1510
|
+
if (ctx.data.length < def2.minLength.value) {
|
|
1499
1511
|
addIssueToContext(ctx, {
|
|
1500
1512
|
code: ZodIssueCode.too_small,
|
|
1501
|
-
minimum:
|
|
1513
|
+
minimum: def2.minLength.value,
|
|
1502
1514
|
type: "array",
|
|
1503
1515
|
inclusive: true,
|
|
1504
|
-
message:
|
|
1516
|
+
message: def2.minLength.message
|
|
1505
1517
|
});
|
|
1506
1518
|
status.dirty();
|
|
1507
1519
|
}
|
|
1508
1520
|
}
|
|
1509
|
-
if (
|
|
1510
|
-
if (ctx.data.length >
|
|
1521
|
+
if (def2.maxLength !== null) {
|
|
1522
|
+
if (ctx.data.length > def2.maxLength.value) {
|
|
1511
1523
|
addIssueToContext(ctx, {
|
|
1512
1524
|
code: ZodIssueCode.too_big,
|
|
1513
|
-
maximum:
|
|
1525
|
+
maximum: def2.maxLength.value,
|
|
1514
1526
|
type: "array",
|
|
1515
1527
|
inclusive: true,
|
|
1516
|
-
message:
|
|
1528
|
+
message: def2.maxLength.message
|
|
1517
1529
|
});
|
|
1518
1530
|
status.dirty();
|
|
1519
1531
|
}
|
|
1520
1532
|
}
|
|
1521
1533
|
if (ctx.common.async) {
|
|
1522
1534
|
return Promise.all(ctx.data.map((item, i) => {
|
|
1523
|
-
return
|
|
1535
|
+
return def2.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
1524
1536
|
})).then((result2) => {
|
|
1525
1537
|
return ParseStatus.mergeArray(status, result2);
|
|
1526
1538
|
});
|
|
1527
1539
|
}
|
|
1528
1540
|
const result = ctx.data.map((item, i) => {
|
|
1529
|
-
return
|
|
1541
|
+
return def2.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
1530
1542
|
});
|
|
1531
1543
|
return ParseStatus.mergeArray(status, result);
|
|
1532
1544
|
}
|
|
@@ -1552,9 +1564,9 @@ var ZodArray = class extends ZodType {
|
|
|
1552
1564
|
return this.min(1, message);
|
|
1553
1565
|
}
|
|
1554
1566
|
};
|
|
1555
|
-
ZodArray.create = (
|
|
1567
|
+
ZodArray.create = (schema2, params2) => {
|
|
1556
1568
|
return new ZodArray({
|
|
1557
|
-
type:
|
|
1569
|
+
type: schema2,
|
|
1558
1570
|
minLength: null,
|
|
1559
1571
|
maxLength: null,
|
|
1560
1572
|
typeName: ZodFirstPartyTypeKind.ZodArray,
|
|
@@ -1570,36 +1582,36 @@ var objectUtil;
|
|
|
1570
1582
|
};
|
|
1571
1583
|
};
|
|
1572
1584
|
})(objectUtil || (objectUtil = {}));
|
|
1573
|
-
var AugmentFactory = (
|
|
1585
|
+
var AugmentFactory = (def2) => (augmentation) => {
|
|
1574
1586
|
return new ZodObject({
|
|
1575
|
-
...
|
|
1587
|
+
...def2,
|
|
1576
1588
|
shape: () => ({
|
|
1577
|
-
...
|
|
1589
|
+
...def2.shape(),
|
|
1578
1590
|
...augmentation
|
|
1579
1591
|
})
|
|
1580
1592
|
});
|
|
1581
1593
|
};
|
|
1582
|
-
function deepPartialify(
|
|
1583
|
-
if (
|
|
1594
|
+
function deepPartialify(schema2) {
|
|
1595
|
+
if (schema2 instanceof ZodObject) {
|
|
1584
1596
|
const newShape = {};
|
|
1585
|
-
for (const key in
|
|
1586
|
-
const fieldSchema =
|
|
1597
|
+
for (const key in schema2.shape) {
|
|
1598
|
+
const fieldSchema = schema2.shape[key];
|
|
1587
1599
|
newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
|
|
1588
1600
|
}
|
|
1589
1601
|
return new ZodObject({
|
|
1590
|
-
...
|
|
1602
|
+
...schema2._def,
|
|
1591
1603
|
shape: () => newShape
|
|
1592
1604
|
});
|
|
1593
|
-
} else if (
|
|
1594
|
-
return ZodArray.create(deepPartialify(
|
|
1595
|
-
} else if (
|
|
1596
|
-
return ZodOptional.create(deepPartialify(
|
|
1597
|
-
} else if (
|
|
1598
|
-
return ZodNullable.create(deepPartialify(
|
|
1599
|
-
} else if (
|
|
1600
|
-
return ZodTuple.create(
|
|
1605
|
+
} else if (schema2 instanceof ZodArray) {
|
|
1606
|
+
return ZodArray.create(deepPartialify(schema2.element));
|
|
1607
|
+
} else if (schema2 instanceof ZodOptional) {
|
|
1608
|
+
return ZodOptional.create(deepPartialify(schema2.unwrap()));
|
|
1609
|
+
} else if (schema2 instanceof ZodNullable) {
|
|
1610
|
+
return ZodNullable.create(deepPartialify(schema2.unwrap()));
|
|
1611
|
+
} else if (schema2 instanceof ZodTuple) {
|
|
1612
|
+
return ZodTuple.create(schema2.items.map((item) => deepPartialify(item)));
|
|
1601
1613
|
} else {
|
|
1602
|
-
return
|
|
1614
|
+
return schema2;
|
|
1603
1615
|
}
|
|
1604
1616
|
}
|
|
1605
1617
|
var ZodObject = class extends ZodType {
|
|
@@ -1737,8 +1749,8 @@ var ZodObject = class extends ZodType {
|
|
|
1737
1749
|
unknownKeys: "passthrough"
|
|
1738
1750
|
});
|
|
1739
1751
|
}
|
|
1740
|
-
setKey(key,
|
|
1741
|
-
return this.augment({ [key]:
|
|
1752
|
+
setKey(key, schema2) {
|
|
1753
|
+
return this.augment({ [key]: schema2 });
|
|
1742
1754
|
}
|
|
1743
1755
|
merge(merging) {
|
|
1744
1756
|
const merged = new ZodObject({
|
|
@@ -2131,10 +2143,10 @@ var ZodTuple = class extends ZodType {
|
|
|
2131
2143
|
status.dirty();
|
|
2132
2144
|
}
|
|
2133
2145
|
const items = ctx.data.map((item, itemIndex) => {
|
|
2134
|
-
const
|
|
2135
|
-
if (!
|
|
2146
|
+
const schema2 = this._def.items[itemIndex] || this._def.rest;
|
|
2147
|
+
if (!schema2)
|
|
2136
2148
|
return null;
|
|
2137
|
-
return
|
|
2149
|
+
return schema2._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
|
|
2138
2150
|
}).filter((x) => !!x);
|
|
2139
2151
|
if (ctx.common.async) {
|
|
2140
2152
|
return Promise.all(items).then((results) => {
|
|
@@ -2288,27 +2300,27 @@ var ZodSet = class extends ZodType {
|
|
|
2288
2300
|
});
|
|
2289
2301
|
return INVALID;
|
|
2290
2302
|
}
|
|
2291
|
-
const
|
|
2292
|
-
if (
|
|
2293
|
-
if (ctx.data.size <
|
|
2303
|
+
const def2 = this._def;
|
|
2304
|
+
if (def2.minSize !== null) {
|
|
2305
|
+
if (ctx.data.size < def2.minSize.value) {
|
|
2294
2306
|
addIssueToContext(ctx, {
|
|
2295
2307
|
code: ZodIssueCode.too_small,
|
|
2296
|
-
minimum:
|
|
2308
|
+
minimum: def2.minSize.value,
|
|
2297
2309
|
type: "set",
|
|
2298
2310
|
inclusive: true,
|
|
2299
|
-
message:
|
|
2311
|
+
message: def2.minSize.message
|
|
2300
2312
|
});
|
|
2301
2313
|
status.dirty();
|
|
2302
2314
|
}
|
|
2303
2315
|
}
|
|
2304
|
-
if (
|
|
2305
|
-
if (ctx.data.size >
|
|
2316
|
+
if (def2.maxSize !== null) {
|
|
2317
|
+
if (ctx.data.size > def2.maxSize.value) {
|
|
2306
2318
|
addIssueToContext(ctx, {
|
|
2307
2319
|
code: ZodIssueCode.too_big,
|
|
2308
|
-
maximum:
|
|
2320
|
+
maximum: def2.maxSize.value,
|
|
2309
2321
|
type: "set",
|
|
2310
2322
|
inclusive: true,
|
|
2311
|
-
message:
|
|
2323
|
+
message: def2.maxSize.message
|
|
2312
2324
|
});
|
|
2313
2325
|
status.dirty();
|
|
2314
2326
|
}
|
|
@@ -2625,9 +2637,9 @@ var ZodPromise = class extends ZodType {
|
|
|
2625
2637
|
}));
|
|
2626
2638
|
}
|
|
2627
2639
|
};
|
|
2628
|
-
ZodPromise.create = (
|
|
2640
|
+
ZodPromise.create = (schema2, params2) => {
|
|
2629
2641
|
return new ZodPromise({
|
|
2630
|
-
type:
|
|
2642
|
+
type: schema2,
|
|
2631
2643
|
typeName: ZodFirstPartyTypeKind.ZodPromise,
|
|
2632
2644
|
...processCreateParams(params2)
|
|
2633
2645
|
});
|
|
@@ -2708,40 +2720,40 @@ var ZodEffects = class extends ZodType {
|
|
|
2708
2720
|
}
|
|
2709
2721
|
if (effect.type === "transform") {
|
|
2710
2722
|
if (ctx.common.async === false) {
|
|
2711
|
-
const
|
|
2723
|
+
const base3 = this._def.schema._parseSync({
|
|
2712
2724
|
data: ctx.data,
|
|
2713
2725
|
path: ctx.path,
|
|
2714
2726
|
parent: ctx
|
|
2715
2727
|
});
|
|
2716
|
-
if (!isValid(
|
|
2717
|
-
return
|
|
2718
|
-
const result = effect.transform(
|
|
2728
|
+
if (!isValid(base3))
|
|
2729
|
+
return base3;
|
|
2730
|
+
const result = effect.transform(base3.value, checkCtx);
|
|
2719
2731
|
if (result instanceof Promise) {
|
|
2720
2732
|
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
2721
2733
|
}
|
|
2722
2734
|
return { status: status.value, value: result };
|
|
2723
2735
|
} else {
|
|
2724
|
-
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((
|
|
2725
|
-
if (!isValid(
|
|
2726
|
-
return
|
|
2727
|
-
return Promise.resolve(effect.transform(
|
|
2736
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base3) => {
|
|
2737
|
+
if (!isValid(base3))
|
|
2738
|
+
return base3;
|
|
2739
|
+
return Promise.resolve(effect.transform(base3.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
|
|
2728
2740
|
});
|
|
2729
2741
|
}
|
|
2730
2742
|
}
|
|
2731
2743
|
util.assertNever(effect);
|
|
2732
2744
|
}
|
|
2733
2745
|
};
|
|
2734
|
-
ZodEffects.create = (
|
|
2746
|
+
ZodEffects.create = (schema2, effect, params2) => {
|
|
2735
2747
|
return new ZodEffects({
|
|
2736
|
-
schema,
|
|
2748
|
+
schema: schema2,
|
|
2737
2749
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
2738
2750
|
effect,
|
|
2739
2751
|
...processCreateParams(params2)
|
|
2740
2752
|
});
|
|
2741
2753
|
};
|
|
2742
|
-
ZodEffects.createWithPreprocess = (preprocess,
|
|
2754
|
+
ZodEffects.createWithPreprocess = (preprocess, schema2, params2) => {
|
|
2743
2755
|
return new ZodEffects({
|
|
2744
|
-
schema,
|
|
2756
|
+
schema: schema2,
|
|
2745
2757
|
effect: { type: "preprocess", transform: preprocess },
|
|
2746
2758
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
2747
2759
|
...processCreateParams(params2)
|
|
@@ -3040,36 +3052,22 @@ var mod = /* @__PURE__ */ Object.freeze({
|
|
|
3040
3052
|
});
|
|
3041
3053
|
|
|
3042
3054
|
// ../nsid/src/index.ts
|
|
3043
|
-
var SEGMENT_RE = /^[a-zA-Z]([a-zA-Z0-9-])*$/;
|
|
3044
3055
|
var NSID = class {
|
|
3045
|
-
constructor(
|
|
3056
|
+
constructor(nsid2) {
|
|
3046
3057
|
this.segments = [];
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
throw new Error(`Invalid NSID: ${nsid}`);
|
|
3050
|
-
}
|
|
3051
|
-
for (let i = 0; i < segments.length; i++) {
|
|
3052
|
-
const segment = segments[i];
|
|
3053
|
-
if (SEGMENT_RE.test(segment)) {
|
|
3054
|
-
continue;
|
|
3055
|
-
}
|
|
3056
|
-
if (i === segments.length - 1 && segment === "*") {
|
|
3057
|
-
continue;
|
|
3058
|
-
}
|
|
3059
|
-
throw new Error(`Invalid NSID: invalid character in segment "${segment}"`);
|
|
3060
|
-
}
|
|
3061
|
-
this.segments = segments;
|
|
3058
|
+
ensureValidNsid(nsid2);
|
|
3059
|
+
this.segments = nsid2.split(".");
|
|
3062
3060
|
}
|
|
3063
|
-
static parse(
|
|
3064
|
-
return new NSID(
|
|
3061
|
+
static parse(nsid2) {
|
|
3062
|
+
return new NSID(nsid2);
|
|
3065
3063
|
}
|
|
3066
|
-
static create(authority,
|
|
3067
|
-
const segments = [...authority.split(".").reverse(),
|
|
3064
|
+
static create(authority, name2) {
|
|
3065
|
+
const segments = [...authority.split(".").reverse(), name2].join(".");
|
|
3068
3066
|
return new NSID(segments);
|
|
3069
3067
|
}
|
|
3070
|
-
static isValid(
|
|
3068
|
+
static isValid(nsid2) {
|
|
3071
3069
|
try {
|
|
3072
|
-
NSID.parse(
|
|
3070
|
+
NSID.parse(nsid2);
|
|
3073
3071
|
return true;
|
|
3074
3072
|
} catch (e) {
|
|
3075
3073
|
return false;
|
|
@@ -3085,6 +3083,42 @@ var NSID = class {
|
|
|
3085
3083
|
return this.segments.join(".");
|
|
3086
3084
|
}
|
|
3087
3085
|
};
|
|
3086
|
+
var ensureValidNsid = (nsid2) => {
|
|
3087
|
+
const split = nsid2.split(".");
|
|
3088
|
+
const toCheck = split.at(-1) === "*" ? split.slice(0, -1).join(".") : split.join(".");
|
|
3089
|
+
if (!/^[a-zA-Z0-9.-]*$/.test(toCheck)) {
|
|
3090
|
+
throw new InvalidNsidError(
|
|
3091
|
+
"Disallowed characters in NSID (ASCII letters, digits, dashes, periods only)"
|
|
3092
|
+
);
|
|
3093
|
+
}
|
|
3094
|
+
if (toCheck.length > 253 + 1 + 128) {
|
|
3095
|
+
throw new InvalidNsidError("NSID is too long (382 chars max)");
|
|
3096
|
+
}
|
|
3097
|
+
const labels = toCheck.split(".");
|
|
3098
|
+
if (split.length < 3) {
|
|
3099
|
+
throw new InvalidNsidError("NSID needs at least three parts");
|
|
3100
|
+
}
|
|
3101
|
+
for (let i = 0; i < labels.length; i++) {
|
|
3102
|
+
const l = labels[i];
|
|
3103
|
+
if (l.length < 1) {
|
|
3104
|
+
throw new InvalidNsidError("NSID parts can not be empty");
|
|
3105
|
+
}
|
|
3106
|
+
if (l.length > 63 && i + 1 < labels.length) {
|
|
3107
|
+
throw new InvalidNsidError("NSID domain part too long (max 63 chars)");
|
|
3108
|
+
}
|
|
3109
|
+
if (l.length > 128 && i + 1 == labels.length) {
|
|
3110
|
+
throw new InvalidNsidError("NSID name part too long (max 127 chars)");
|
|
3111
|
+
}
|
|
3112
|
+
if (l.endsWith("-")) {
|
|
3113
|
+
throw new InvalidNsidError("NSID parts can not end with hyphen");
|
|
3114
|
+
}
|
|
3115
|
+
if (!/^[a-zA-Z]/.test(l)) {
|
|
3116
|
+
throw new InvalidNsidError("NSID parts must start with ASCII letter");
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
};
|
|
3120
|
+
var InvalidNsidError = class extends Error {
|
|
3121
|
+
};
|
|
3088
3122
|
|
|
3089
3123
|
// src/types.ts
|
|
3090
3124
|
var lexBoolean = mod.object({
|
|
@@ -3093,8 +3127,8 @@ var lexBoolean = mod.object({
|
|
|
3093
3127
|
default: mod.boolean().optional(),
|
|
3094
3128
|
const: mod.boolean().optional()
|
|
3095
3129
|
});
|
|
3096
|
-
var
|
|
3097
|
-
type: mod.literal("
|
|
3130
|
+
var lexFloat = mod.object({
|
|
3131
|
+
type: mod.literal("float"),
|
|
3098
3132
|
description: mod.string().optional(),
|
|
3099
3133
|
default: mod.number().optional(),
|
|
3100
3134
|
minimum: mod.number().optional(),
|
|
@@ -3111,32 +3145,51 @@ var lexInteger = mod.object({
|
|
|
3111
3145
|
enum: mod.number().int().array().optional(),
|
|
3112
3146
|
const: mod.number().int().optional()
|
|
3113
3147
|
});
|
|
3148
|
+
var lexStringFormat = mod.enum([
|
|
3149
|
+
"datetime",
|
|
3150
|
+
"uri",
|
|
3151
|
+
"at-uri",
|
|
3152
|
+
"did",
|
|
3153
|
+
"handle",
|
|
3154
|
+
"at-identifier",
|
|
3155
|
+
"nsid",
|
|
3156
|
+
"cid"
|
|
3157
|
+
]);
|
|
3114
3158
|
var lexString = mod.object({
|
|
3115
3159
|
type: mod.literal("string"),
|
|
3160
|
+
format: lexStringFormat.optional(),
|
|
3116
3161
|
description: mod.string().optional(),
|
|
3117
3162
|
default: mod.string().optional(),
|
|
3118
3163
|
minLength: mod.number().int().optional(),
|
|
3119
3164
|
maxLength: mod.number().int().optional(),
|
|
3165
|
+
minGraphemes: mod.number().int().optional(),
|
|
3166
|
+
maxGraphemes: mod.number().int().optional(),
|
|
3120
3167
|
enum: mod.string().array().optional(),
|
|
3121
3168
|
const: mod.string().optional(),
|
|
3122
3169
|
knownValues: mod.string().array().optional()
|
|
3123
3170
|
});
|
|
3124
|
-
var lexDatetime = mod.object({
|
|
3125
|
-
type: mod.literal("datetime"),
|
|
3126
|
-
description: mod.string().optional()
|
|
3127
|
-
});
|
|
3128
3171
|
var lexUnknown = mod.object({
|
|
3129
3172
|
type: mod.literal("unknown"),
|
|
3130
3173
|
description: mod.string().optional()
|
|
3131
3174
|
});
|
|
3132
3175
|
var lexPrimitive = mod.union([
|
|
3133
3176
|
lexBoolean,
|
|
3134
|
-
|
|
3177
|
+
lexFloat,
|
|
3135
3178
|
lexInteger,
|
|
3136
3179
|
lexString,
|
|
3137
|
-
lexDatetime,
|
|
3138
3180
|
lexUnknown
|
|
3139
3181
|
]);
|
|
3182
|
+
var lexBytes = mod.object({
|
|
3183
|
+
type: mod.literal("bytes"),
|
|
3184
|
+
description: mod.string().optional(),
|
|
3185
|
+
maxLength: mod.number().optional(),
|
|
3186
|
+
minLength: mod.number().optional()
|
|
3187
|
+
});
|
|
3188
|
+
var lexCidLink = mod.object({
|
|
3189
|
+
type: mod.literal("cid-link"),
|
|
3190
|
+
description: mod.string().optional()
|
|
3191
|
+
});
|
|
3192
|
+
var lexIpldType = mod.union([lexBytes, lexCidLink]);
|
|
3140
3193
|
var lexRef = mod.object({
|
|
3141
3194
|
type: mod.literal("ref"),
|
|
3142
3195
|
description: mod.string().optional(),
|
|
@@ -3155,38 +3208,18 @@ var lexBlob = mod.object({
|
|
|
3155
3208
|
accept: mod.string().array().optional(),
|
|
3156
3209
|
maxSize: mod.number().optional()
|
|
3157
3210
|
});
|
|
3158
|
-
var lexImage = mod.object({
|
|
3159
|
-
type: mod.literal("image"),
|
|
3160
|
-
description: mod.string().optional(),
|
|
3161
|
-
accept: mod.string().array().optional(),
|
|
3162
|
-
maxSize: mod.number().optional(),
|
|
3163
|
-
maxWidth: mod.number().int().optional(),
|
|
3164
|
-
maxHeight: mod.number().int().optional()
|
|
3165
|
-
});
|
|
3166
|
-
var lexVideo = mod.object({
|
|
3167
|
-
type: mod.literal("video"),
|
|
3168
|
-
description: mod.string().optional(),
|
|
3169
|
-
accept: mod.string().array().optional(),
|
|
3170
|
-
maxSize: mod.number().optional(),
|
|
3171
|
-
maxWidth: mod.number().int().optional(),
|
|
3172
|
-
maxHeight: mod.number().int().optional(),
|
|
3173
|
-
maxLength: mod.number().int().optional()
|
|
3174
|
-
});
|
|
3175
|
-
var lexAudio = mod.object({
|
|
3176
|
-
type: mod.literal("audio"),
|
|
3177
|
-
description: mod.string().optional(),
|
|
3178
|
-
accept: mod.string().array().optional(),
|
|
3179
|
-
maxSize: mod.number().optional(),
|
|
3180
|
-
maxLength: mod.number().int().optional()
|
|
3181
|
-
});
|
|
3182
|
-
var lexBlobVariant = mod.union([lexBlob, lexImage, lexVideo, lexAudio]);
|
|
3183
3211
|
var lexArray = mod.object({
|
|
3184
3212
|
type: mod.literal("array"),
|
|
3185
3213
|
description: mod.string().optional(),
|
|
3186
|
-
items: mod.union([lexPrimitive,
|
|
3214
|
+
items: mod.union([lexPrimitive, lexIpldType, lexBlob, lexRefVariant]),
|
|
3187
3215
|
minLength: mod.number().int().optional(),
|
|
3188
3216
|
maxLength: mod.number().int().optional()
|
|
3189
3217
|
});
|
|
3218
|
+
var lexPrimitiveArray = lexArray.merge(
|
|
3219
|
+
mod.object({
|
|
3220
|
+
items: lexPrimitive
|
|
3221
|
+
})
|
|
3222
|
+
);
|
|
3190
3223
|
var lexToken = mod.object({
|
|
3191
3224
|
type: mod.literal("token"),
|
|
3192
3225
|
description: mod.string().optional()
|
|
@@ -3195,19 +3228,26 @@ var lexObject = mod.object({
|
|
|
3195
3228
|
type: mod.literal("object"),
|
|
3196
3229
|
description: mod.string().optional(),
|
|
3197
3230
|
required: mod.string().array().optional(),
|
|
3198
|
-
|
|
3231
|
+
nullable: mod.string().array().optional(),
|
|
3232
|
+
properties: mod.record(
|
|
3233
|
+
mod.union([lexRefVariant, lexIpldType, lexArray, lexBlob, lexPrimitive])
|
|
3234
|
+
).optional()
|
|
3199
3235
|
});
|
|
3200
3236
|
var lexXrpcParameters = mod.object({
|
|
3201
3237
|
type: mod.literal("params"),
|
|
3202
3238
|
description: mod.string().optional(),
|
|
3203
3239
|
required: mod.string().array().optional(),
|
|
3204
|
-
properties: mod.record(lexPrimitive)
|
|
3240
|
+
properties: mod.record(mod.union([lexPrimitive, lexPrimitiveArray]))
|
|
3205
3241
|
});
|
|
3206
3242
|
var lexXrpcBody = mod.object({
|
|
3207
3243
|
description: mod.string().optional(),
|
|
3208
3244
|
encoding: mod.string(),
|
|
3209
3245
|
schema: mod.union([lexRefVariant, lexObject]).optional()
|
|
3210
3246
|
});
|
|
3247
|
+
var lexXrpcSubscriptionMessage = mod.object({
|
|
3248
|
+
description: mod.string().optional(),
|
|
3249
|
+
schema: mod.union([lexRefVariant, lexObject]).optional()
|
|
3250
|
+
});
|
|
3211
3251
|
var lexXrpcError = mod.object({
|
|
3212
3252
|
name: mod.string(),
|
|
3213
3253
|
description: mod.string().optional()
|
|
@@ -3227,6 +3267,14 @@ var lexXrpcProcedure = mod.object({
|
|
|
3227
3267
|
output: lexXrpcBody.optional(),
|
|
3228
3268
|
errors: lexXrpcError.array().optional()
|
|
3229
3269
|
});
|
|
3270
|
+
var lexXrpcSubscription = mod.object({
|
|
3271
|
+
type: mod.literal("subscription"),
|
|
3272
|
+
description: mod.string().optional(),
|
|
3273
|
+
parameters: lexXrpcParameters.optional(),
|
|
3274
|
+
message: lexXrpcSubscriptionMessage.optional(),
|
|
3275
|
+
infos: lexXrpcError.array().optional(),
|
|
3276
|
+
errors: lexXrpcError.array().optional()
|
|
3277
|
+
});
|
|
3230
3278
|
var lexRecord = mod.object({
|
|
3231
3279
|
type: mod.literal("record"),
|
|
3232
3280
|
description: mod.string().optional(),
|
|
@@ -3237,18 +3285,17 @@ var lexUserType = mod.union([
|
|
|
3237
3285
|
lexRecord,
|
|
3238
3286
|
lexXrpcQuery,
|
|
3239
3287
|
lexXrpcProcedure,
|
|
3288
|
+
lexXrpcSubscription,
|
|
3240
3289
|
lexBlob,
|
|
3241
|
-
lexImage,
|
|
3242
|
-
lexVideo,
|
|
3243
|
-
lexAudio,
|
|
3244
3290
|
lexArray,
|
|
3245
3291
|
lexToken,
|
|
3246
3292
|
lexObject,
|
|
3247
3293
|
lexBoolean,
|
|
3248
|
-
|
|
3294
|
+
lexFloat,
|
|
3249
3295
|
lexInteger,
|
|
3250
3296
|
lexString,
|
|
3251
|
-
|
|
3297
|
+
lexBytes,
|
|
3298
|
+
lexCidLink,
|
|
3252
3299
|
lexUnknown
|
|
3253
3300
|
]);
|
|
3254
3301
|
var lexiconDoc = mod.object({
|
|
@@ -3261,11 +3308,11 @@ var lexiconDoc = mod.object({
|
|
|
3261
3308
|
defs: mod.record(lexUserType)
|
|
3262
3309
|
}).superRefine((doc, ctx) => {
|
|
3263
3310
|
for (const defId in doc.defs) {
|
|
3264
|
-
const
|
|
3265
|
-
if (defId !== "main" && (
|
|
3311
|
+
const def2 = doc.defs[defId];
|
|
3312
|
+
if (defId !== "main" && (def2.type === "record" || def2.type === "procedure" || def2.type === "query" || def2.type === "subscription")) {
|
|
3266
3313
|
ctx.addIssue({
|
|
3267
3314
|
code: mod.ZodIssueCode.custom,
|
|
3268
|
-
message: `Records, procedures, and
|
|
3315
|
+
message: `Records, procedures, queries, and subscriptions must be the main definition.`
|
|
3269
3316
|
});
|
|
3270
3317
|
}
|
|
3271
3318
|
}
|
|
@@ -3299,35 +3346,2487 @@ var InvalidLexiconError = class extends Error {
|
|
|
3299
3346
|
var LexiconDefNotFoundError = class extends Error {
|
|
3300
3347
|
};
|
|
3301
3348
|
|
|
3302
|
-
// src/
|
|
3349
|
+
// ../common-web/src/check.ts
|
|
3350
|
+
var check_exports = {};
|
|
3351
|
+
__export(check_exports, {
|
|
3352
|
+
assure: () => assure,
|
|
3353
|
+
is: () => is,
|
|
3354
|
+
isObject: () => isObject
|
|
3355
|
+
});
|
|
3356
|
+
var is = (obj, def2) => {
|
|
3357
|
+
return def2.safeParse(obj).success;
|
|
3358
|
+
};
|
|
3359
|
+
var assure = (def2, obj) => {
|
|
3360
|
+
return def2.parse(obj);
|
|
3361
|
+
};
|
|
3362
|
+
var isObject = (obj) => {
|
|
3363
|
+
return typeof obj === "object" && obj !== null;
|
|
3364
|
+
};
|
|
3365
|
+
|
|
3366
|
+
// ../../node_modules/multiformats/esm/vendor/varint.js
|
|
3367
|
+
var encode_1 = encode;
|
|
3368
|
+
var MSB = 128;
|
|
3369
|
+
var REST = 127;
|
|
3370
|
+
var MSBALL = ~REST;
|
|
3371
|
+
var INT = Math.pow(2, 31);
|
|
3372
|
+
function encode(num, out, offset) {
|
|
3373
|
+
out = out || [];
|
|
3374
|
+
offset = offset || 0;
|
|
3375
|
+
var oldOffset = offset;
|
|
3376
|
+
while (num >= INT) {
|
|
3377
|
+
out[offset++] = num & 255 | MSB;
|
|
3378
|
+
num /= 128;
|
|
3379
|
+
}
|
|
3380
|
+
while (num & MSBALL) {
|
|
3381
|
+
out[offset++] = num & 255 | MSB;
|
|
3382
|
+
num >>>= 7;
|
|
3383
|
+
}
|
|
3384
|
+
out[offset] = num | 0;
|
|
3385
|
+
encode.bytes = offset - oldOffset + 1;
|
|
3386
|
+
return out;
|
|
3387
|
+
}
|
|
3388
|
+
var decode = read;
|
|
3389
|
+
var MSB$1 = 128;
|
|
3390
|
+
var REST$1 = 127;
|
|
3391
|
+
function read(buf, offset) {
|
|
3392
|
+
var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
|
|
3393
|
+
do {
|
|
3394
|
+
if (counter >= l) {
|
|
3395
|
+
read.bytes = 0;
|
|
3396
|
+
throw new RangeError("Could not decode varint");
|
|
3397
|
+
}
|
|
3398
|
+
b = buf[counter++];
|
|
3399
|
+
res += shift < 28 ? (b & REST$1) << shift : (b & REST$1) * Math.pow(2, shift);
|
|
3400
|
+
shift += 7;
|
|
3401
|
+
} while (b >= MSB$1);
|
|
3402
|
+
read.bytes = counter - offset;
|
|
3403
|
+
return res;
|
|
3404
|
+
}
|
|
3405
|
+
var N1 = Math.pow(2, 7);
|
|
3406
|
+
var N2 = Math.pow(2, 14);
|
|
3407
|
+
var N3 = Math.pow(2, 21);
|
|
3408
|
+
var N4 = Math.pow(2, 28);
|
|
3409
|
+
var N5 = Math.pow(2, 35);
|
|
3410
|
+
var N6 = Math.pow(2, 42);
|
|
3411
|
+
var N7 = Math.pow(2, 49);
|
|
3412
|
+
var N8 = Math.pow(2, 56);
|
|
3413
|
+
var N9 = Math.pow(2, 63);
|
|
3414
|
+
var length = function(value) {
|
|
3415
|
+
return value < N1 ? 1 : value < N2 ? 2 : value < N3 ? 3 : value < N4 ? 4 : value < N5 ? 5 : value < N6 ? 6 : value < N7 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10;
|
|
3416
|
+
};
|
|
3417
|
+
var varint = {
|
|
3418
|
+
encode: encode_1,
|
|
3419
|
+
decode,
|
|
3420
|
+
encodingLength: length
|
|
3421
|
+
};
|
|
3422
|
+
var _brrp_varint = varint;
|
|
3423
|
+
var varint_default = _brrp_varint;
|
|
3424
|
+
|
|
3425
|
+
// ../../node_modules/multiformats/esm/src/varint.js
|
|
3426
|
+
var decode2 = (data, offset = 0) => {
|
|
3427
|
+
const code2 = varint_default.decode(data, offset);
|
|
3428
|
+
return [
|
|
3429
|
+
code2,
|
|
3430
|
+
varint_default.decode.bytes
|
|
3431
|
+
];
|
|
3432
|
+
};
|
|
3433
|
+
var encodeTo = (int, target, offset = 0) => {
|
|
3434
|
+
varint_default.encode(int, target, offset);
|
|
3435
|
+
return target;
|
|
3436
|
+
};
|
|
3437
|
+
var encodingLength = (int) => {
|
|
3438
|
+
return varint_default.encodingLength(int);
|
|
3439
|
+
};
|
|
3440
|
+
|
|
3441
|
+
// ../../node_modules/multiformats/esm/src/bytes.js
|
|
3442
|
+
var empty = new Uint8Array(0);
|
|
3443
|
+
var equals = (aa, bb) => {
|
|
3444
|
+
if (aa === bb)
|
|
3445
|
+
return true;
|
|
3446
|
+
if (aa.byteLength !== bb.byteLength) {
|
|
3447
|
+
return false;
|
|
3448
|
+
}
|
|
3449
|
+
for (let ii = 0; ii < aa.byteLength; ii++) {
|
|
3450
|
+
if (aa[ii] !== bb[ii]) {
|
|
3451
|
+
return false;
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
return true;
|
|
3455
|
+
};
|
|
3456
|
+
var coerce = (o) => {
|
|
3457
|
+
if (o instanceof Uint8Array && o.constructor.name === "Uint8Array")
|
|
3458
|
+
return o;
|
|
3459
|
+
if (o instanceof ArrayBuffer)
|
|
3460
|
+
return new Uint8Array(o);
|
|
3461
|
+
if (ArrayBuffer.isView(o)) {
|
|
3462
|
+
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
|
3463
|
+
}
|
|
3464
|
+
throw new Error("Unknown type, must be binary type");
|
|
3465
|
+
};
|
|
3466
|
+
var fromString = (str) => new TextEncoder().encode(str);
|
|
3467
|
+
var toString = (b) => new TextDecoder().decode(b);
|
|
3468
|
+
|
|
3469
|
+
// ../../node_modules/multiformats/esm/src/hashes/digest.js
|
|
3470
|
+
var create = (code2, digest2) => {
|
|
3471
|
+
const size = digest2.byteLength;
|
|
3472
|
+
const sizeOffset = encodingLength(code2);
|
|
3473
|
+
const digestOffset = sizeOffset + encodingLength(size);
|
|
3474
|
+
const bytes2 = new Uint8Array(digestOffset + size);
|
|
3475
|
+
encodeTo(code2, bytes2, 0);
|
|
3476
|
+
encodeTo(size, bytes2, sizeOffset);
|
|
3477
|
+
bytes2.set(digest2, digestOffset);
|
|
3478
|
+
return new Digest(code2, size, digest2, bytes2);
|
|
3479
|
+
};
|
|
3480
|
+
var decode3 = (multihash) => {
|
|
3481
|
+
const bytes2 = coerce(multihash);
|
|
3482
|
+
const [code2, sizeOffset] = decode2(bytes2);
|
|
3483
|
+
const [size, digestOffset] = decode2(bytes2.subarray(sizeOffset));
|
|
3484
|
+
const digest2 = bytes2.subarray(sizeOffset + digestOffset);
|
|
3485
|
+
if (digest2.byteLength !== size) {
|
|
3486
|
+
throw new Error("Incorrect length");
|
|
3487
|
+
}
|
|
3488
|
+
return new Digest(code2, size, digest2, bytes2);
|
|
3489
|
+
};
|
|
3490
|
+
var equals2 = (a, b) => {
|
|
3491
|
+
if (a === b) {
|
|
3492
|
+
return true;
|
|
3493
|
+
} else {
|
|
3494
|
+
return a.code === b.code && a.size === b.size && equals(a.bytes, b.bytes);
|
|
3495
|
+
}
|
|
3496
|
+
};
|
|
3497
|
+
var Digest = class {
|
|
3498
|
+
constructor(code2, size, digest2, bytes2) {
|
|
3499
|
+
this.code = code2;
|
|
3500
|
+
this.size = size;
|
|
3501
|
+
this.digest = digest2;
|
|
3502
|
+
this.bytes = bytes2;
|
|
3503
|
+
}
|
|
3504
|
+
};
|
|
3505
|
+
|
|
3506
|
+
// ../../node_modules/multiformats/esm/src/bases/base58.js
|
|
3507
|
+
var base58_exports = {};
|
|
3508
|
+
__export(base58_exports, {
|
|
3509
|
+
base58btc: () => base58btc,
|
|
3510
|
+
base58flickr: () => base58flickr
|
|
3511
|
+
});
|
|
3512
|
+
|
|
3513
|
+
// ../../node_modules/multiformats/esm/vendor/base-x.js
|
|
3514
|
+
function base(ALPHABET, name2) {
|
|
3515
|
+
if (ALPHABET.length >= 255) {
|
|
3516
|
+
throw new TypeError("Alphabet too long");
|
|
3517
|
+
}
|
|
3518
|
+
var BASE_MAP = new Uint8Array(256);
|
|
3519
|
+
for (var j = 0; j < BASE_MAP.length; j++) {
|
|
3520
|
+
BASE_MAP[j] = 255;
|
|
3521
|
+
}
|
|
3522
|
+
for (var i = 0; i < ALPHABET.length; i++) {
|
|
3523
|
+
var x = ALPHABET.charAt(i);
|
|
3524
|
+
var xc = x.charCodeAt(0);
|
|
3525
|
+
if (BASE_MAP[xc] !== 255) {
|
|
3526
|
+
throw new TypeError(x + " is ambiguous");
|
|
3527
|
+
}
|
|
3528
|
+
BASE_MAP[xc] = i;
|
|
3529
|
+
}
|
|
3530
|
+
var BASE = ALPHABET.length;
|
|
3531
|
+
var LEADER = ALPHABET.charAt(0);
|
|
3532
|
+
var FACTOR = Math.log(BASE) / Math.log(256);
|
|
3533
|
+
var iFACTOR = Math.log(256) / Math.log(BASE);
|
|
3534
|
+
function encode5(source) {
|
|
3535
|
+
if (source instanceof Uint8Array)
|
|
3536
|
+
;
|
|
3537
|
+
else if (ArrayBuffer.isView(source)) {
|
|
3538
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
3539
|
+
} else if (Array.isArray(source)) {
|
|
3540
|
+
source = Uint8Array.from(source);
|
|
3541
|
+
}
|
|
3542
|
+
if (!(source instanceof Uint8Array)) {
|
|
3543
|
+
throw new TypeError("Expected Uint8Array");
|
|
3544
|
+
}
|
|
3545
|
+
if (source.length === 0) {
|
|
3546
|
+
return "";
|
|
3547
|
+
}
|
|
3548
|
+
var zeroes = 0;
|
|
3549
|
+
var length2 = 0;
|
|
3550
|
+
var pbegin = 0;
|
|
3551
|
+
var pend = source.length;
|
|
3552
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
3553
|
+
pbegin++;
|
|
3554
|
+
zeroes++;
|
|
3555
|
+
}
|
|
3556
|
+
var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
|
|
3557
|
+
var b58 = new Uint8Array(size);
|
|
3558
|
+
while (pbegin !== pend) {
|
|
3559
|
+
var carry = source[pbegin];
|
|
3560
|
+
var i2 = 0;
|
|
3561
|
+
for (var it1 = size - 1; (carry !== 0 || i2 < length2) && it1 !== -1; it1--, i2++) {
|
|
3562
|
+
carry += 256 * b58[it1] >>> 0;
|
|
3563
|
+
b58[it1] = carry % BASE >>> 0;
|
|
3564
|
+
carry = carry / BASE >>> 0;
|
|
3565
|
+
}
|
|
3566
|
+
if (carry !== 0) {
|
|
3567
|
+
throw new Error("Non-zero carry");
|
|
3568
|
+
}
|
|
3569
|
+
length2 = i2;
|
|
3570
|
+
pbegin++;
|
|
3571
|
+
}
|
|
3572
|
+
var it2 = size - length2;
|
|
3573
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
3574
|
+
it2++;
|
|
3575
|
+
}
|
|
3576
|
+
var str = LEADER.repeat(zeroes);
|
|
3577
|
+
for (; it2 < size; ++it2) {
|
|
3578
|
+
str += ALPHABET.charAt(b58[it2]);
|
|
3579
|
+
}
|
|
3580
|
+
return str;
|
|
3581
|
+
}
|
|
3582
|
+
function decodeUnsafe(source) {
|
|
3583
|
+
if (typeof source !== "string") {
|
|
3584
|
+
throw new TypeError("Expected String");
|
|
3585
|
+
}
|
|
3586
|
+
if (source.length === 0) {
|
|
3587
|
+
return new Uint8Array();
|
|
3588
|
+
}
|
|
3589
|
+
var psz = 0;
|
|
3590
|
+
if (source[psz] === " ") {
|
|
3591
|
+
return;
|
|
3592
|
+
}
|
|
3593
|
+
var zeroes = 0;
|
|
3594
|
+
var length2 = 0;
|
|
3595
|
+
while (source[psz] === LEADER) {
|
|
3596
|
+
zeroes++;
|
|
3597
|
+
psz++;
|
|
3598
|
+
}
|
|
3599
|
+
var size = (source.length - psz) * FACTOR + 1 >>> 0;
|
|
3600
|
+
var b256 = new Uint8Array(size);
|
|
3601
|
+
while (source[psz]) {
|
|
3602
|
+
var carry = BASE_MAP[source.charCodeAt(psz)];
|
|
3603
|
+
if (carry === 255) {
|
|
3604
|
+
return;
|
|
3605
|
+
}
|
|
3606
|
+
var i2 = 0;
|
|
3607
|
+
for (var it3 = size - 1; (carry !== 0 || i2 < length2) && it3 !== -1; it3--, i2++) {
|
|
3608
|
+
carry += BASE * b256[it3] >>> 0;
|
|
3609
|
+
b256[it3] = carry % 256 >>> 0;
|
|
3610
|
+
carry = carry / 256 >>> 0;
|
|
3611
|
+
}
|
|
3612
|
+
if (carry !== 0) {
|
|
3613
|
+
throw new Error("Non-zero carry");
|
|
3614
|
+
}
|
|
3615
|
+
length2 = i2;
|
|
3616
|
+
psz++;
|
|
3617
|
+
}
|
|
3618
|
+
if (source[psz] === " ") {
|
|
3619
|
+
return;
|
|
3620
|
+
}
|
|
3621
|
+
var it4 = size - length2;
|
|
3622
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
3623
|
+
it4++;
|
|
3624
|
+
}
|
|
3625
|
+
var vch = new Uint8Array(zeroes + (size - it4));
|
|
3626
|
+
var j2 = zeroes;
|
|
3627
|
+
while (it4 !== size) {
|
|
3628
|
+
vch[j2++] = b256[it4++];
|
|
3629
|
+
}
|
|
3630
|
+
return vch;
|
|
3631
|
+
}
|
|
3632
|
+
function decode6(string3) {
|
|
3633
|
+
var buffer = decodeUnsafe(string3);
|
|
3634
|
+
if (buffer) {
|
|
3635
|
+
return buffer;
|
|
3636
|
+
}
|
|
3637
|
+
throw new Error(`Non-${name2} character`);
|
|
3638
|
+
}
|
|
3639
|
+
return {
|
|
3640
|
+
encode: encode5,
|
|
3641
|
+
decodeUnsafe,
|
|
3642
|
+
decode: decode6
|
|
3643
|
+
};
|
|
3644
|
+
}
|
|
3645
|
+
var src = base;
|
|
3646
|
+
var _brrp__multiformats_scope_baseX = src;
|
|
3647
|
+
var base_x_default = _brrp__multiformats_scope_baseX;
|
|
3648
|
+
|
|
3649
|
+
// ../../node_modules/multiformats/esm/src/bases/base.js
|
|
3650
|
+
var Encoder = class {
|
|
3651
|
+
constructor(name2, prefix, baseEncode) {
|
|
3652
|
+
this.name = name2;
|
|
3653
|
+
this.prefix = prefix;
|
|
3654
|
+
this.baseEncode = baseEncode;
|
|
3655
|
+
}
|
|
3656
|
+
encode(bytes2) {
|
|
3657
|
+
if (bytes2 instanceof Uint8Array) {
|
|
3658
|
+
return `${this.prefix}${this.baseEncode(bytes2)}`;
|
|
3659
|
+
} else {
|
|
3660
|
+
throw Error("Unknown type, must be binary type");
|
|
3661
|
+
}
|
|
3662
|
+
}
|
|
3663
|
+
};
|
|
3664
|
+
var Decoder = class {
|
|
3665
|
+
constructor(name2, prefix, baseDecode) {
|
|
3666
|
+
this.name = name2;
|
|
3667
|
+
this.prefix = prefix;
|
|
3668
|
+
if (prefix.codePointAt(0) === void 0) {
|
|
3669
|
+
throw new Error("Invalid prefix character");
|
|
3670
|
+
}
|
|
3671
|
+
this.prefixCodePoint = prefix.codePointAt(0);
|
|
3672
|
+
this.baseDecode = baseDecode;
|
|
3673
|
+
}
|
|
3674
|
+
decode(text) {
|
|
3675
|
+
if (typeof text === "string") {
|
|
3676
|
+
if (text.codePointAt(0) !== this.prefixCodePoint) {
|
|
3677
|
+
throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
|
|
3678
|
+
}
|
|
3679
|
+
return this.baseDecode(text.slice(this.prefix.length));
|
|
3680
|
+
} else {
|
|
3681
|
+
throw Error("Can only multibase decode strings");
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
or(decoder) {
|
|
3685
|
+
return or(this, decoder);
|
|
3686
|
+
}
|
|
3687
|
+
};
|
|
3688
|
+
var ComposedDecoder = class {
|
|
3689
|
+
constructor(decoders) {
|
|
3690
|
+
this.decoders = decoders;
|
|
3691
|
+
}
|
|
3692
|
+
or(decoder) {
|
|
3693
|
+
return or(this, decoder);
|
|
3694
|
+
}
|
|
3695
|
+
decode(input) {
|
|
3696
|
+
const prefix = input[0];
|
|
3697
|
+
const decoder = this.decoders[prefix];
|
|
3698
|
+
if (decoder) {
|
|
3699
|
+
return decoder.decode(input);
|
|
3700
|
+
} else {
|
|
3701
|
+
throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
|
|
3702
|
+
}
|
|
3703
|
+
}
|
|
3704
|
+
};
|
|
3705
|
+
var or = (left, right) => new ComposedDecoder({
|
|
3706
|
+
...left.decoders || { [left.prefix]: left },
|
|
3707
|
+
...right.decoders || { [right.prefix]: right }
|
|
3708
|
+
});
|
|
3709
|
+
var Codec = class {
|
|
3710
|
+
constructor(name2, prefix, baseEncode, baseDecode) {
|
|
3711
|
+
this.name = name2;
|
|
3712
|
+
this.prefix = prefix;
|
|
3713
|
+
this.baseEncode = baseEncode;
|
|
3714
|
+
this.baseDecode = baseDecode;
|
|
3715
|
+
this.encoder = new Encoder(name2, prefix, baseEncode);
|
|
3716
|
+
this.decoder = new Decoder(name2, prefix, baseDecode);
|
|
3717
|
+
}
|
|
3718
|
+
encode(input) {
|
|
3719
|
+
return this.encoder.encode(input);
|
|
3720
|
+
}
|
|
3721
|
+
decode(input) {
|
|
3722
|
+
return this.decoder.decode(input);
|
|
3723
|
+
}
|
|
3724
|
+
};
|
|
3725
|
+
var from = ({ name: name2, prefix, encode: encode5, decode: decode6 }) => new Codec(name2, prefix, encode5, decode6);
|
|
3726
|
+
var baseX = ({ prefix, name: name2, alphabet: alphabet2 }) => {
|
|
3727
|
+
const { encode: encode5, decode: decode6 } = base_x_default(alphabet2, name2);
|
|
3728
|
+
return from({
|
|
3729
|
+
prefix,
|
|
3730
|
+
name: name2,
|
|
3731
|
+
encode: encode5,
|
|
3732
|
+
decode: (text) => coerce(decode6(text))
|
|
3733
|
+
});
|
|
3734
|
+
};
|
|
3735
|
+
var decode4 = (string3, alphabet2, bitsPerChar, name2) => {
|
|
3736
|
+
const codes = {};
|
|
3737
|
+
for (let i = 0; i < alphabet2.length; ++i) {
|
|
3738
|
+
codes[alphabet2[i]] = i;
|
|
3739
|
+
}
|
|
3740
|
+
let end = string3.length;
|
|
3741
|
+
while (string3[end - 1] === "=") {
|
|
3742
|
+
--end;
|
|
3743
|
+
}
|
|
3744
|
+
const out = new Uint8Array(end * bitsPerChar / 8 | 0);
|
|
3745
|
+
let bits = 0;
|
|
3746
|
+
let buffer = 0;
|
|
3747
|
+
let written = 0;
|
|
3748
|
+
for (let i = 0; i < end; ++i) {
|
|
3749
|
+
const value = codes[string3[i]];
|
|
3750
|
+
if (value === void 0) {
|
|
3751
|
+
throw new SyntaxError(`Non-${name2} character`);
|
|
3752
|
+
}
|
|
3753
|
+
buffer = buffer << bitsPerChar | value;
|
|
3754
|
+
bits += bitsPerChar;
|
|
3755
|
+
if (bits >= 8) {
|
|
3756
|
+
bits -= 8;
|
|
3757
|
+
out[written++] = 255 & buffer >> bits;
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
if (bits >= bitsPerChar || 255 & buffer << 8 - bits) {
|
|
3761
|
+
throw new SyntaxError("Unexpected end of data");
|
|
3762
|
+
}
|
|
3763
|
+
return out;
|
|
3764
|
+
};
|
|
3765
|
+
var encode2 = (data, alphabet2, bitsPerChar) => {
|
|
3766
|
+
const pad = alphabet2[alphabet2.length - 1] === "=";
|
|
3767
|
+
const mask = (1 << bitsPerChar) - 1;
|
|
3768
|
+
let out = "";
|
|
3769
|
+
let bits = 0;
|
|
3770
|
+
let buffer = 0;
|
|
3771
|
+
for (let i = 0; i < data.length; ++i) {
|
|
3772
|
+
buffer = buffer << 8 | data[i];
|
|
3773
|
+
bits += 8;
|
|
3774
|
+
while (bits > bitsPerChar) {
|
|
3775
|
+
bits -= bitsPerChar;
|
|
3776
|
+
out += alphabet2[mask & buffer >> bits];
|
|
3777
|
+
}
|
|
3778
|
+
}
|
|
3779
|
+
if (bits) {
|
|
3780
|
+
out += alphabet2[mask & buffer << bitsPerChar - bits];
|
|
3781
|
+
}
|
|
3782
|
+
if (pad) {
|
|
3783
|
+
while (out.length * bitsPerChar & 7) {
|
|
3784
|
+
out += "=";
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
return out;
|
|
3788
|
+
};
|
|
3789
|
+
var rfc4648 = ({ name: name2, prefix, bitsPerChar, alphabet: alphabet2 }) => {
|
|
3790
|
+
return from({
|
|
3791
|
+
prefix,
|
|
3792
|
+
name: name2,
|
|
3793
|
+
encode(input) {
|
|
3794
|
+
return encode2(input, alphabet2, bitsPerChar);
|
|
3795
|
+
},
|
|
3796
|
+
decode(input) {
|
|
3797
|
+
return decode4(input, alphabet2, bitsPerChar, name2);
|
|
3798
|
+
}
|
|
3799
|
+
});
|
|
3800
|
+
};
|
|
3801
|
+
|
|
3802
|
+
// ../../node_modules/multiformats/esm/src/bases/base58.js
|
|
3803
|
+
var base58btc = baseX({
|
|
3804
|
+
name: "base58btc",
|
|
3805
|
+
prefix: "z",
|
|
3806
|
+
alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
|
3807
|
+
});
|
|
3808
|
+
var base58flickr = baseX({
|
|
3809
|
+
name: "base58flickr",
|
|
3810
|
+
prefix: "Z",
|
|
3811
|
+
alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
|
|
3812
|
+
});
|
|
3813
|
+
|
|
3814
|
+
// ../../node_modules/multiformats/esm/src/bases/base32.js
|
|
3815
|
+
var base32_exports = {};
|
|
3816
|
+
__export(base32_exports, {
|
|
3817
|
+
base32: () => base32,
|
|
3818
|
+
base32hex: () => base32hex,
|
|
3819
|
+
base32hexpad: () => base32hexpad,
|
|
3820
|
+
base32hexpadupper: () => base32hexpadupper,
|
|
3821
|
+
base32hexupper: () => base32hexupper,
|
|
3822
|
+
base32pad: () => base32pad,
|
|
3823
|
+
base32padupper: () => base32padupper,
|
|
3824
|
+
base32upper: () => base32upper,
|
|
3825
|
+
base32z: () => base32z
|
|
3826
|
+
});
|
|
3827
|
+
var base32 = rfc4648({
|
|
3828
|
+
prefix: "b",
|
|
3829
|
+
name: "base32",
|
|
3830
|
+
alphabet: "abcdefghijklmnopqrstuvwxyz234567",
|
|
3831
|
+
bitsPerChar: 5
|
|
3832
|
+
});
|
|
3833
|
+
var base32upper = rfc4648({
|
|
3834
|
+
prefix: "B",
|
|
3835
|
+
name: "base32upper",
|
|
3836
|
+
alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
|
|
3837
|
+
bitsPerChar: 5
|
|
3838
|
+
});
|
|
3839
|
+
var base32pad = rfc4648({
|
|
3840
|
+
prefix: "c",
|
|
3841
|
+
name: "base32pad",
|
|
3842
|
+
alphabet: "abcdefghijklmnopqrstuvwxyz234567=",
|
|
3843
|
+
bitsPerChar: 5
|
|
3844
|
+
});
|
|
3845
|
+
var base32padupper = rfc4648({
|
|
3846
|
+
prefix: "C",
|
|
3847
|
+
name: "base32padupper",
|
|
3848
|
+
alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
|
|
3849
|
+
bitsPerChar: 5
|
|
3850
|
+
});
|
|
3851
|
+
var base32hex = rfc4648({
|
|
3852
|
+
prefix: "v",
|
|
3853
|
+
name: "base32hex",
|
|
3854
|
+
alphabet: "0123456789abcdefghijklmnopqrstuv",
|
|
3855
|
+
bitsPerChar: 5
|
|
3856
|
+
});
|
|
3857
|
+
var base32hexupper = rfc4648({
|
|
3858
|
+
prefix: "V",
|
|
3859
|
+
name: "base32hexupper",
|
|
3860
|
+
alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
|
|
3861
|
+
bitsPerChar: 5
|
|
3862
|
+
});
|
|
3863
|
+
var base32hexpad = rfc4648({
|
|
3864
|
+
prefix: "t",
|
|
3865
|
+
name: "base32hexpad",
|
|
3866
|
+
alphabet: "0123456789abcdefghijklmnopqrstuv=",
|
|
3867
|
+
bitsPerChar: 5
|
|
3868
|
+
});
|
|
3869
|
+
var base32hexpadupper = rfc4648({
|
|
3870
|
+
prefix: "T",
|
|
3871
|
+
name: "base32hexpadupper",
|
|
3872
|
+
alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=",
|
|
3873
|
+
bitsPerChar: 5
|
|
3874
|
+
});
|
|
3875
|
+
var base32z = rfc4648({
|
|
3876
|
+
prefix: "h",
|
|
3877
|
+
name: "base32z",
|
|
3878
|
+
alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769",
|
|
3879
|
+
bitsPerChar: 5
|
|
3880
|
+
});
|
|
3881
|
+
|
|
3882
|
+
// ../../node_modules/multiformats/esm/src/cid.js
|
|
3883
|
+
var CID = class {
|
|
3884
|
+
constructor(version2, code2, multihash, bytes2) {
|
|
3885
|
+
this.code = code2;
|
|
3886
|
+
this.version = version2;
|
|
3887
|
+
this.multihash = multihash;
|
|
3888
|
+
this.bytes = bytes2;
|
|
3889
|
+
this.byteOffset = bytes2.byteOffset;
|
|
3890
|
+
this.byteLength = bytes2.byteLength;
|
|
3891
|
+
this.asCID = this;
|
|
3892
|
+
this._baseCache = /* @__PURE__ */ new Map();
|
|
3893
|
+
Object.defineProperties(this, {
|
|
3894
|
+
byteOffset: hidden,
|
|
3895
|
+
byteLength: hidden,
|
|
3896
|
+
code: readonly,
|
|
3897
|
+
version: readonly,
|
|
3898
|
+
multihash: readonly,
|
|
3899
|
+
bytes: readonly,
|
|
3900
|
+
_baseCache: hidden,
|
|
3901
|
+
asCID: hidden
|
|
3902
|
+
});
|
|
3903
|
+
}
|
|
3904
|
+
toV0() {
|
|
3905
|
+
switch (this.version) {
|
|
3906
|
+
case 0: {
|
|
3907
|
+
return this;
|
|
3908
|
+
}
|
|
3909
|
+
default: {
|
|
3910
|
+
const { code: code2, multihash } = this;
|
|
3911
|
+
if (code2 !== DAG_PB_CODE) {
|
|
3912
|
+
throw new Error("Cannot convert a non dag-pb CID to CIDv0");
|
|
3913
|
+
}
|
|
3914
|
+
if (multihash.code !== SHA_256_CODE) {
|
|
3915
|
+
throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");
|
|
3916
|
+
}
|
|
3917
|
+
return CID.createV0(multihash);
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3921
|
+
toV1() {
|
|
3922
|
+
switch (this.version) {
|
|
3923
|
+
case 0: {
|
|
3924
|
+
const { code: code2, digest: digest2 } = this.multihash;
|
|
3925
|
+
const multihash = create(code2, digest2);
|
|
3926
|
+
return CID.createV1(this.code, multihash);
|
|
3927
|
+
}
|
|
3928
|
+
case 1: {
|
|
3929
|
+
return this;
|
|
3930
|
+
}
|
|
3931
|
+
default: {
|
|
3932
|
+
throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
equals(other) {
|
|
3937
|
+
return other && this.code === other.code && this.version === other.version && equals2(this.multihash, other.multihash);
|
|
3938
|
+
}
|
|
3939
|
+
toString(base3) {
|
|
3940
|
+
const { bytes: bytes2, version: version2, _baseCache } = this;
|
|
3941
|
+
switch (version2) {
|
|
3942
|
+
case 0:
|
|
3943
|
+
return toStringV0(bytes2, _baseCache, base3 || base58btc.encoder);
|
|
3944
|
+
default:
|
|
3945
|
+
return toStringV1(bytes2, _baseCache, base3 || base32.encoder);
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
toJSON() {
|
|
3949
|
+
return {
|
|
3950
|
+
code: this.code,
|
|
3951
|
+
version: this.version,
|
|
3952
|
+
hash: this.multihash.bytes
|
|
3953
|
+
};
|
|
3954
|
+
}
|
|
3955
|
+
get [Symbol.toStringTag]() {
|
|
3956
|
+
return "CID";
|
|
3957
|
+
}
|
|
3958
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
3959
|
+
return "CID(" + this.toString() + ")";
|
|
3960
|
+
}
|
|
3961
|
+
static isCID(value) {
|
|
3962
|
+
deprecate(/^0\.0/, IS_CID_DEPRECATION);
|
|
3963
|
+
return !!(value && (value[cidSymbol] || value.asCID === value));
|
|
3964
|
+
}
|
|
3965
|
+
get toBaseEncodedString() {
|
|
3966
|
+
throw new Error("Deprecated, use .toString()");
|
|
3967
|
+
}
|
|
3968
|
+
get codec() {
|
|
3969
|
+
throw new Error('"codec" property is deprecated, use integer "code" property instead');
|
|
3970
|
+
}
|
|
3971
|
+
get buffer() {
|
|
3972
|
+
throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead");
|
|
3973
|
+
}
|
|
3974
|
+
get multibaseName() {
|
|
3975
|
+
throw new Error('"multibaseName" property is deprecated');
|
|
3976
|
+
}
|
|
3977
|
+
get prefix() {
|
|
3978
|
+
throw new Error('"prefix" property is deprecated');
|
|
3979
|
+
}
|
|
3980
|
+
static asCID(value) {
|
|
3981
|
+
if (value instanceof CID) {
|
|
3982
|
+
return value;
|
|
3983
|
+
} else if (value != null && value.asCID === value) {
|
|
3984
|
+
const { version: version2, code: code2, multihash, bytes: bytes2 } = value;
|
|
3985
|
+
return new CID(version2, code2, multihash, bytes2 || encodeCID(version2, code2, multihash.bytes));
|
|
3986
|
+
} else if (value != null && value[cidSymbol] === true) {
|
|
3987
|
+
const { version: version2, multihash, code: code2 } = value;
|
|
3988
|
+
const digest2 = decode3(multihash);
|
|
3989
|
+
return CID.create(version2, code2, digest2);
|
|
3990
|
+
} else {
|
|
3991
|
+
return null;
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
static create(version2, code2, digest2) {
|
|
3995
|
+
if (typeof code2 !== "number") {
|
|
3996
|
+
throw new Error("String codecs are no longer supported");
|
|
3997
|
+
}
|
|
3998
|
+
switch (version2) {
|
|
3999
|
+
case 0: {
|
|
4000
|
+
if (code2 !== DAG_PB_CODE) {
|
|
4001
|
+
throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
|
|
4002
|
+
} else {
|
|
4003
|
+
return new CID(version2, code2, digest2, digest2.bytes);
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4006
|
+
case 1: {
|
|
4007
|
+
const bytes2 = encodeCID(version2, code2, digest2.bytes);
|
|
4008
|
+
return new CID(version2, code2, digest2, bytes2);
|
|
4009
|
+
}
|
|
4010
|
+
default: {
|
|
4011
|
+
throw new Error("Invalid version");
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
static createV0(digest2) {
|
|
4016
|
+
return CID.create(0, DAG_PB_CODE, digest2);
|
|
4017
|
+
}
|
|
4018
|
+
static createV1(code2, digest2) {
|
|
4019
|
+
return CID.create(1, code2, digest2);
|
|
4020
|
+
}
|
|
4021
|
+
static decode(bytes2) {
|
|
4022
|
+
const [cid2, remainder] = CID.decodeFirst(bytes2);
|
|
4023
|
+
if (remainder.length) {
|
|
4024
|
+
throw new Error("Incorrect length");
|
|
4025
|
+
}
|
|
4026
|
+
return cid2;
|
|
4027
|
+
}
|
|
4028
|
+
static decodeFirst(bytes2) {
|
|
4029
|
+
const specs = CID.inspectBytes(bytes2);
|
|
4030
|
+
const prefixSize = specs.size - specs.multihashSize;
|
|
4031
|
+
const multihashBytes = coerce(bytes2.subarray(prefixSize, prefixSize + specs.multihashSize));
|
|
4032
|
+
if (multihashBytes.byteLength !== specs.multihashSize) {
|
|
4033
|
+
throw new Error("Incorrect length");
|
|
4034
|
+
}
|
|
4035
|
+
const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
|
|
4036
|
+
const digest2 = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
|
|
4037
|
+
const cid2 = specs.version === 0 ? CID.createV0(digest2) : CID.createV1(specs.codec, digest2);
|
|
4038
|
+
return [
|
|
4039
|
+
cid2,
|
|
4040
|
+
bytes2.subarray(specs.size)
|
|
4041
|
+
];
|
|
4042
|
+
}
|
|
4043
|
+
static inspectBytes(initialBytes) {
|
|
4044
|
+
let offset = 0;
|
|
4045
|
+
const next = () => {
|
|
4046
|
+
const [i, length2] = decode2(initialBytes.subarray(offset));
|
|
4047
|
+
offset += length2;
|
|
4048
|
+
return i;
|
|
4049
|
+
};
|
|
4050
|
+
let version2 = next();
|
|
4051
|
+
let codec = DAG_PB_CODE;
|
|
4052
|
+
if (version2 === 18) {
|
|
4053
|
+
version2 = 0;
|
|
4054
|
+
offset = 0;
|
|
4055
|
+
} else if (version2 === 1) {
|
|
4056
|
+
codec = next();
|
|
4057
|
+
}
|
|
4058
|
+
if (version2 !== 0 && version2 !== 1) {
|
|
4059
|
+
throw new RangeError(`Invalid CID version ${version2}`);
|
|
4060
|
+
}
|
|
4061
|
+
const prefixSize = offset;
|
|
4062
|
+
const multihashCode = next();
|
|
4063
|
+
const digestSize = next();
|
|
4064
|
+
const size = offset + digestSize;
|
|
4065
|
+
const multihashSize = size - prefixSize;
|
|
4066
|
+
return {
|
|
4067
|
+
version: version2,
|
|
4068
|
+
codec,
|
|
4069
|
+
multihashCode,
|
|
4070
|
+
digestSize,
|
|
4071
|
+
multihashSize,
|
|
4072
|
+
size
|
|
4073
|
+
};
|
|
4074
|
+
}
|
|
4075
|
+
static parse(source, base3) {
|
|
4076
|
+
const [prefix, bytes2] = parseCIDtoBytes(source, base3);
|
|
4077
|
+
const cid2 = CID.decode(bytes2);
|
|
4078
|
+
cid2._baseCache.set(prefix, source);
|
|
4079
|
+
return cid2;
|
|
4080
|
+
}
|
|
4081
|
+
};
|
|
4082
|
+
var parseCIDtoBytes = (source, base3) => {
|
|
4083
|
+
switch (source[0]) {
|
|
4084
|
+
case "Q": {
|
|
4085
|
+
const decoder = base3 || base58btc;
|
|
4086
|
+
return [
|
|
4087
|
+
base58btc.prefix,
|
|
4088
|
+
decoder.decode(`${base58btc.prefix}${source}`)
|
|
4089
|
+
];
|
|
4090
|
+
}
|
|
4091
|
+
case base58btc.prefix: {
|
|
4092
|
+
const decoder = base3 || base58btc;
|
|
4093
|
+
return [
|
|
4094
|
+
base58btc.prefix,
|
|
4095
|
+
decoder.decode(source)
|
|
4096
|
+
];
|
|
4097
|
+
}
|
|
4098
|
+
case base32.prefix: {
|
|
4099
|
+
const decoder = base3 || base32;
|
|
4100
|
+
return [
|
|
4101
|
+
base32.prefix,
|
|
4102
|
+
decoder.decode(source)
|
|
4103
|
+
];
|
|
4104
|
+
}
|
|
4105
|
+
default: {
|
|
4106
|
+
if (base3 == null) {
|
|
4107
|
+
throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");
|
|
4108
|
+
}
|
|
4109
|
+
return [
|
|
4110
|
+
source[0],
|
|
4111
|
+
base3.decode(source)
|
|
4112
|
+
];
|
|
4113
|
+
}
|
|
4114
|
+
}
|
|
4115
|
+
};
|
|
4116
|
+
var toStringV0 = (bytes2, cache, base3) => {
|
|
4117
|
+
const { prefix } = base3;
|
|
4118
|
+
if (prefix !== base58btc.prefix) {
|
|
4119
|
+
throw Error(`Cannot string encode V0 in ${base3.name} encoding`);
|
|
4120
|
+
}
|
|
4121
|
+
const cid2 = cache.get(prefix);
|
|
4122
|
+
if (cid2 == null) {
|
|
4123
|
+
const cid3 = base3.encode(bytes2).slice(1);
|
|
4124
|
+
cache.set(prefix, cid3);
|
|
4125
|
+
return cid3;
|
|
4126
|
+
} else {
|
|
4127
|
+
return cid2;
|
|
4128
|
+
}
|
|
4129
|
+
};
|
|
4130
|
+
var toStringV1 = (bytes2, cache, base3) => {
|
|
4131
|
+
const { prefix } = base3;
|
|
4132
|
+
const cid2 = cache.get(prefix);
|
|
4133
|
+
if (cid2 == null) {
|
|
4134
|
+
const cid3 = base3.encode(bytes2);
|
|
4135
|
+
cache.set(prefix, cid3);
|
|
4136
|
+
return cid3;
|
|
4137
|
+
} else {
|
|
4138
|
+
return cid2;
|
|
4139
|
+
}
|
|
4140
|
+
};
|
|
4141
|
+
var DAG_PB_CODE = 112;
|
|
4142
|
+
var SHA_256_CODE = 18;
|
|
4143
|
+
var encodeCID = (version2, code2, multihash) => {
|
|
4144
|
+
const codeOffset = encodingLength(version2);
|
|
4145
|
+
const hashOffset = codeOffset + encodingLength(code2);
|
|
4146
|
+
const bytes2 = new Uint8Array(hashOffset + multihash.byteLength);
|
|
4147
|
+
encodeTo(version2, bytes2, 0);
|
|
4148
|
+
encodeTo(code2, bytes2, codeOffset);
|
|
4149
|
+
bytes2.set(multihash, hashOffset);
|
|
4150
|
+
return bytes2;
|
|
4151
|
+
};
|
|
4152
|
+
var cidSymbol = Symbol.for("@ipld/js-cid/CID");
|
|
4153
|
+
var readonly = {
|
|
4154
|
+
writable: false,
|
|
4155
|
+
configurable: false,
|
|
4156
|
+
enumerable: true
|
|
4157
|
+
};
|
|
4158
|
+
var hidden = {
|
|
4159
|
+
writable: false,
|
|
4160
|
+
enumerable: false,
|
|
4161
|
+
configurable: false
|
|
4162
|
+
};
|
|
4163
|
+
var version = "0.0.0-dev";
|
|
4164
|
+
var deprecate = (range, message) => {
|
|
4165
|
+
if (range.test(version)) {
|
|
4166
|
+
console.warn(message);
|
|
4167
|
+
} else {
|
|
4168
|
+
throw new Error(message);
|
|
4169
|
+
}
|
|
4170
|
+
};
|
|
4171
|
+
var IS_CID_DEPRECATION = `CID.isCID(v) is deprecated and will be removed in the next major release.
|
|
4172
|
+
Following code pattern:
|
|
4173
|
+
|
|
4174
|
+
if (CID.isCID(value)) {
|
|
4175
|
+
doSomethingWithCID(value)
|
|
4176
|
+
}
|
|
4177
|
+
|
|
4178
|
+
Is replaced with:
|
|
4179
|
+
|
|
4180
|
+
const cid = CID.asCID(value)
|
|
4181
|
+
if (cid) {
|
|
4182
|
+
// Make sure to use cid instead of value
|
|
4183
|
+
doSomethingWithCID(cid)
|
|
4184
|
+
}
|
|
4185
|
+
`;
|
|
4186
|
+
|
|
4187
|
+
// ../../node_modules/multiformats/esm/src/bases/identity.js
|
|
4188
|
+
var identity_exports = {};
|
|
4189
|
+
__export(identity_exports, {
|
|
4190
|
+
identity: () => identity
|
|
4191
|
+
});
|
|
4192
|
+
var identity = from({
|
|
4193
|
+
prefix: "\0",
|
|
4194
|
+
name: "identity",
|
|
4195
|
+
encode: (buf) => toString(buf),
|
|
4196
|
+
decode: (str) => fromString(str)
|
|
4197
|
+
});
|
|
4198
|
+
|
|
4199
|
+
// ../../node_modules/multiformats/esm/src/bases/base2.js
|
|
4200
|
+
var base2_exports = {};
|
|
4201
|
+
__export(base2_exports, {
|
|
4202
|
+
base2: () => base2
|
|
4203
|
+
});
|
|
4204
|
+
var base2 = rfc4648({
|
|
4205
|
+
prefix: "0",
|
|
4206
|
+
name: "base2",
|
|
4207
|
+
alphabet: "01",
|
|
4208
|
+
bitsPerChar: 1
|
|
4209
|
+
});
|
|
4210
|
+
|
|
4211
|
+
// ../../node_modules/multiformats/esm/src/bases/base8.js
|
|
4212
|
+
var base8_exports = {};
|
|
4213
|
+
__export(base8_exports, {
|
|
4214
|
+
base8: () => base8
|
|
4215
|
+
});
|
|
4216
|
+
var base8 = rfc4648({
|
|
4217
|
+
prefix: "7",
|
|
4218
|
+
name: "base8",
|
|
4219
|
+
alphabet: "01234567",
|
|
4220
|
+
bitsPerChar: 3
|
|
4221
|
+
});
|
|
4222
|
+
|
|
4223
|
+
// ../../node_modules/multiformats/esm/src/bases/base10.js
|
|
4224
|
+
var base10_exports = {};
|
|
4225
|
+
__export(base10_exports, {
|
|
4226
|
+
base10: () => base10
|
|
4227
|
+
});
|
|
4228
|
+
var base10 = baseX({
|
|
4229
|
+
prefix: "9",
|
|
4230
|
+
name: "base10",
|
|
4231
|
+
alphabet: "0123456789"
|
|
4232
|
+
});
|
|
4233
|
+
|
|
4234
|
+
// ../../node_modules/multiformats/esm/src/bases/base16.js
|
|
4235
|
+
var base16_exports = {};
|
|
4236
|
+
__export(base16_exports, {
|
|
4237
|
+
base16: () => base16,
|
|
4238
|
+
base16upper: () => base16upper
|
|
4239
|
+
});
|
|
4240
|
+
var base16 = rfc4648({
|
|
4241
|
+
prefix: "f",
|
|
4242
|
+
name: "base16",
|
|
4243
|
+
alphabet: "0123456789abcdef",
|
|
4244
|
+
bitsPerChar: 4
|
|
4245
|
+
});
|
|
4246
|
+
var base16upper = rfc4648({
|
|
4247
|
+
prefix: "F",
|
|
4248
|
+
name: "base16upper",
|
|
4249
|
+
alphabet: "0123456789ABCDEF",
|
|
4250
|
+
bitsPerChar: 4
|
|
4251
|
+
});
|
|
4252
|
+
|
|
4253
|
+
// ../../node_modules/multiformats/esm/src/bases/base36.js
|
|
4254
|
+
var base36_exports = {};
|
|
4255
|
+
__export(base36_exports, {
|
|
4256
|
+
base36: () => base36,
|
|
4257
|
+
base36upper: () => base36upper
|
|
4258
|
+
});
|
|
4259
|
+
var base36 = baseX({
|
|
4260
|
+
prefix: "k",
|
|
4261
|
+
name: "base36",
|
|
4262
|
+
alphabet: "0123456789abcdefghijklmnopqrstuvwxyz"
|
|
4263
|
+
});
|
|
4264
|
+
var base36upper = baseX({
|
|
4265
|
+
prefix: "K",
|
|
4266
|
+
name: "base36upper",
|
|
4267
|
+
alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
4268
|
+
});
|
|
4269
|
+
|
|
4270
|
+
// ../../node_modules/multiformats/esm/src/bases/base64.js
|
|
4271
|
+
var base64_exports = {};
|
|
4272
|
+
__export(base64_exports, {
|
|
4273
|
+
base64: () => base64,
|
|
4274
|
+
base64pad: () => base64pad,
|
|
4275
|
+
base64url: () => base64url,
|
|
4276
|
+
base64urlpad: () => base64urlpad
|
|
4277
|
+
});
|
|
4278
|
+
var base64 = rfc4648({
|
|
4279
|
+
prefix: "m",
|
|
4280
|
+
name: "base64",
|
|
4281
|
+
alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
|
4282
|
+
bitsPerChar: 6
|
|
4283
|
+
});
|
|
4284
|
+
var base64pad = rfc4648({
|
|
4285
|
+
prefix: "M",
|
|
4286
|
+
name: "base64pad",
|
|
4287
|
+
alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
|
4288
|
+
bitsPerChar: 6
|
|
4289
|
+
});
|
|
4290
|
+
var base64url = rfc4648({
|
|
4291
|
+
prefix: "u",
|
|
4292
|
+
name: "base64url",
|
|
4293
|
+
alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",
|
|
4294
|
+
bitsPerChar: 6
|
|
4295
|
+
});
|
|
4296
|
+
var base64urlpad = rfc4648({
|
|
4297
|
+
prefix: "U",
|
|
4298
|
+
name: "base64urlpad",
|
|
4299
|
+
alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",
|
|
4300
|
+
bitsPerChar: 6
|
|
4301
|
+
});
|
|
4302
|
+
|
|
4303
|
+
// ../../node_modules/multiformats/esm/src/bases/base256emoji.js
|
|
4304
|
+
var base256emoji_exports = {};
|
|
4305
|
+
__export(base256emoji_exports, {
|
|
4306
|
+
base256emoji: () => base256emoji
|
|
4307
|
+
});
|
|
4308
|
+
var alphabet = Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}");
|
|
4309
|
+
var alphabetBytesToChars = alphabet.reduce((p, c, i) => {
|
|
4310
|
+
p[i] = c;
|
|
4311
|
+
return p;
|
|
4312
|
+
}, []);
|
|
4313
|
+
var alphabetCharsToBytes = alphabet.reduce((p, c, i) => {
|
|
4314
|
+
p[c.codePointAt(0)] = i;
|
|
4315
|
+
return p;
|
|
4316
|
+
}, []);
|
|
4317
|
+
function encode3(data) {
|
|
4318
|
+
return data.reduce((p, c) => {
|
|
4319
|
+
p += alphabetBytesToChars[c];
|
|
4320
|
+
return p;
|
|
4321
|
+
}, "");
|
|
4322
|
+
}
|
|
4323
|
+
function decode5(str) {
|
|
4324
|
+
const byts = [];
|
|
4325
|
+
for (const char of str) {
|
|
4326
|
+
const byt = alphabetCharsToBytes[char.codePointAt(0)];
|
|
4327
|
+
if (byt === void 0) {
|
|
4328
|
+
throw new Error(`Non-base256emoji character: ${char}`);
|
|
4329
|
+
}
|
|
4330
|
+
byts.push(byt);
|
|
4331
|
+
}
|
|
4332
|
+
return new Uint8Array(byts);
|
|
4333
|
+
}
|
|
4334
|
+
var base256emoji = from({
|
|
4335
|
+
prefix: "\u{1F680}",
|
|
4336
|
+
name: "base256emoji",
|
|
4337
|
+
encode: encode3,
|
|
4338
|
+
decode: decode5
|
|
4339
|
+
});
|
|
4340
|
+
|
|
4341
|
+
// ../../node_modules/multiformats/esm/src/hashes/sha2.js
|
|
4342
|
+
var sha2_exports = {};
|
|
4343
|
+
__export(sha2_exports, {
|
|
4344
|
+
sha256: () => sha256,
|
|
4345
|
+
sha512: () => sha512
|
|
4346
|
+
});
|
|
4347
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
4348
|
+
|
|
4349
|
+
// ../../node_modules/multiformats/esm/src/hashes/hasher.js
|
|
4350
|
+
var from2 = ({ name: name2, code: code2, encode: encode5 }) => new Hasher(name2, code2, encode5);
|
|
4351
|
+
var Hasher = class {
|
|
4352
|
+
constructor(name2, code2, encode5) {
|
|
4353
|
+
this.name = name2;
|
|
4354
|
+
this.code = code2;
|
|
4355
|
+
this.encode = encode5;
|
|
4356
|
+
}
|
|
4357
|
+
digest(input) {
|
|
4358
|
+
if (input instanceof Uint8Array) {
|
|
4359
|
+
const result = this.encode(input);
|
|
4360
|
+
return result instanceof Uint8Array ? create(this.code, result) : result.then((digest2) => create(this.code, digest2));
|
|
4361
|
+
} else {
|
|
4362
|
+
throw Error("Unknown type, must be binary type");
|
|
4363
|
+
}
|
|
4364
|
+
}
|
|
4365
|
+
};
|
|
4366
|
+
|
|
4367
|
+
// ../../node_modules/multiformats/esm/src/hashes/sha2.js
|
|
4368
|
+
var sha256 = from2({
|
|
4369
|
+
name: "sha2-256",
|
|
4370
|
+
code: 18,
|
|
4371
|
+
encode: (input) => coerce(import_crypto.default.createHash("sha256").update(input).digest())
|
|
4372
|
+
});
|
|
4373
|
+
var sha512 = from2({
|
|
4374
|
+
name: "sha2-512",
|
|
4375
|
+
code: 19,
|
|
4376
|
+
encode: (input) => coerce(import_crypto.default.createHash("sha512").update(input).digest())
|
|
4377
|
+
});
|
|
4378
|
+
|
|
4379
|
+
// ../../node_modules/multiformats/esm/src/hashes/identity.js
|
|
4380
|
+
var identity_exports2 = {};
|
|
4381
|
+
__export(identity_exports2, {
|
|
4382
|
+
identity: () => identity2
|
|
4383
|
+
});
|
|
4384
|
+
var code = 0;
|
|
4385
|
+
var name = "identity";
|
|
4386
|
+
var encode4 = coerce;
|
|
4387
|
+
var digest = (input) => create(code, encode4(input));
|
|
4388
|
+
var identity2 = {
|
|
4389
|
+
code,
|
|
4390
|
+
name,
|
|
4391
|
+
encode: encode4,
|
|
4392
|
+
digest
|
|
4393
|
+
};
|
|
4394
|
+
|
|
4395
|
+
// ../../node_modules/multiformats/esm/src/codecs/json.js
|
|
4396
|
+
var textEncoder = new TextEncoder();
|
|
4397
|
+
var textDecoder = new TextDecoder();
|
|
4398
|
+
|
|
4399
|
+
// ../../node_modules/multiformats/esm/src/basics.js
|
|
4400
|
+
var bases = {
|
|
4401
|
+
...identity_exports,
|
|
4402
|
+
...base2_exports,
|
|
4403
|
+
...base8_exports,
|
|
4404
|
+
...base10_exports,
|
|
4405
|
+
...base16_exports,
|
|
4406
|
+
...base32_exports,
|
|
4407
|
+
...base36_exports,
|
|
4408
|
+
...base58_exports,
|
|
4409
|
+
...base64_exports,
|
|
4410
|
+
...base256emoji_exports
|
|
4411
|
+
};
|
|
4412
|
+
var hashes = {
|
|
4413
|
+
...sha2_exports,
|
|
4414
|
+
...identity_exports2
|
|
4415
|
+
};
|
|
4416
|
+
|
|
4417
|
+
// ../../node_modules/uint8arrays/esm/src/util/bases.js
|
|
4418
|
+
function createCodec(name2, prefix, encode5, decode6) {
|
|
4419
|
+
return {
|
|
4420
|
+
name: name2,
|
|
4421
|
+
prefix,
|
|
4422
|
+
encoder: {
|
|
4423
|
+
name: name2,
|
|
4424
|
+
prefix,
|
|
4425
|
+
encode: encode5
|
|
4426
|
+
},
|
|
4427
|
+
decoder: { decode: decode6 }
|
|
4428
|
+
};
|
|
4429
|
+
}
|
|
4430
|
+
var string = createCodec("utf8", "u", (buf) => {
|
|
4431
|
+
const decoder = new TextDecoder("utf8");
|
|
4432
|
+
return "u" + decoder.decode(buf);
|
|
4433
|
+
}, (str) => {
|
|
4434
|
+
const encoder = new TextEncoder();
|
|
4435
|
+
return encoder.encode(str.substring(1));
|
|
4436
|
+
});
|
|
4437
|
+
var ascii = createCodec("ascii", "a", (buf) => {
|
|
4438
|
+
let string3 = "a";
|
|
4439
|
+
for (let i = 0; i < buf.length; i++) {
|
|
4440
|
+
string3 += String.fromCharCode(buf[i]);
|
|
4441
|
+
}
|
|
4442
|
+
return string3;
|
|
4443
|
+
}, (str) => {
|
|
4444
|
+
str = str.substring(1);
|
|
4445
|
+
const buf = new Uint8Array(str.length);
|
|
4446
|
+
for (let i = 0; i < str.length; i++) {
|
|
4447
|
+
buf[i] = str.charCodeAt(i);
|
|
4448
|
+
}
|
|
4449
|
+
return buf;
|
|
4450
|
+
});
|
|
4451
|
+
var BASES = {
|
|
4452
|
+
utf8: string,
|
|
4453
|
+
"utf-8": string,
|
|
4454
|
+
hex: bases.base16,
|
|
4455
|
+
latin1: ascii,
|
|
4456
|
+
ascii,
|
|
4457
|
+
binary: ascii,
|
|
4458
|
+
...bases
|
|
4459
|
+
};
|
|
4460
|
+
var bases_default = BASES;
|
|
4461
|
+
|
|
4462
|
+
// ../../node_modules/uint8arrays/esm/src/from-string.js
|
|
4463
|
+
function fromString2(string3, encoding = "utf8") {
|
|
4464
|
+
const base3 = bases_default[encoding];
|
|
4465
|
+
if (!base3) {
|
|
4466
|
+
throw new Error(`Unsupported encoding "${encoding}"`);
|
|
4467
|
+
}
|
|
4468
|
+
return base3.decoder.decode(`${base3.prefix}${string3}`);
|
|
4469
|
+
}
|
|
4470
|
+
|
|
4471
|
+
// ../../node_modules/uint8arrays/esm/src/to-string.js
|
|
4472
|
+
function toString2(array2, encoding = "utf8") {
|
|
4473
|
+
const base3 = bases_default[encoding];
|
|
4474
|
+
if (!base3) {
|
|
4475
|
+
throw new Error(`Unsupported encoding "${encoding}"`);
|
|
4476
|
+
}
|
|
4477
|
+
return base3.encoder.encode(array2).substring(1);
|
|
4478
|
+
}
|
|
4479
|
+
|
|
4480
|
+
// ../common-web/src/ipld.ts
|
|
4481
|
+
var jsonToIpld = (val) => {
|
|
4482
|
+
if (Array.isArray(val)) {
|
|
4483
|
+
return val.map((item) => jsonToIpld(item));
|
|
4484
|
+
}
|
|
4485
|
+
if (val && typeof val === "object") {
|
|
4486
|
+
if (typeof val["$link"] === "string" && Object.keys(val).length === 1) {
|
|
4487
|
+
return CID.parse(val["$link"]);
|
|
4488
|
+
}
|
|
4489
|
+
if (typeof val["$bytes"] === "string" && Object.keys(val).length === 1) {
|
|
4490
|
+
return fromString2(val["$bytes"], "base64");
|
|
4491
|
+
}
|
|
4492
|
+
const toReturn = {};
|
|
4493
|
+
for (const key of Object.keys(val)) {
|
|
4494
|
+
toReturn[key] = jsonToIpld(val[key]);
|
|
4495
|
+
}
|
|
4496
|
+
return toReturn;
|
|
4497
|
+
}
|
|
4498
|
+
return val;
|
|
4499
|
+
};
|
|
4500
|
+
var ipldToJson = (val) => {
|
|
4501
|
+
if (Array.isArray(val)) {
|
|
4502
|
+
return val.map((item) => ipldToJson(item));
|
|
4503
|
+
}
|
|
4504
|
+
if (val && typeof val === "object") {
|
|
4505
|
+
if (val instanceof Uint8Array) {
|
|
4506
|
+
return {
|
|
4507
|
+
$bytes: toString2(val, "base64")
|
|
4508
|
+
};
|
|
4509
|
+
}
|
|
4510
|
+
if (CID.asCID(val)) {
|
|
4511
|
+
return {
|
|
4512
|
+
$link: val.toString()
|
|
4513
|
+
};
|
|
4514
|
+
}
|
|
4515
|
+
const toReturn = {};
|
|
4516
|
+
for (const key of Object.keys(val)) {
|
|
4517
|
+
toReturn[key] = ipldToJson(val[key]);
|
|
4518
|
+
}
|
|
4519
|
+
return toReturn;
|
|
4520
|
+
}
|
|
4521
|
+
return val;
|
|
4522
|
+
};
|
|
4523
|
+
|
|
4524
|
+
// ../common-web/src/types.ts
|
|
4525
|
+
var cidSchema = mod.any().refine((obj) => CID.asCID(obj) !== null, {
|
|
4526
|
+
message: "Not a CID"
|
|
4527
|
+
}).transform((obj) => CID.asCID(obj));
|
|
4528
|
+
var schema = {
|
|
4529
|
+
cid: cidSchema,
|
|
4530
|
+
bytes: mod.instanceof(Uint8Array),
|
|
4531
|
+
string: mod.string(),
|
|
4532
|
+
array: mod.array(mod.unknown()),
|
|
4533
|
+
map: mod.record(mod.string(), mod.unknown()),
|
|
4534
|
+
unknown: mod.unknown()
|
|
4535
|
+
};
|
|
4536
|
+
var def = {
|
|
4537
|
+
cid: {
|
|
4538
|
+
name: "cid",
|
|
4539
|
+
schema: schema.cid
|
|
4540
|
+
},
|
|
4541
|
+
bytes: {
|
|
4542
|
+
name: "bytes",
|
|
4543
|
+
schema: schema.bytes
|
|
4544
|
+
},
|
|
4545
|
+
string: {
|
|
4546
|
+
name: "string",
|
|
4547
|
+
schema: schema.string
|
|
4548
|
+
},
|
|
4549
|
+
map: {
|
|
4550
|
+
name: "map",
|
|
4551
|
+
schema: schema.map
|
|
4552
|
+
},
|
|
4553
|
+
unknown: {
|
|
4554
|
+
name: "unknown",
|
|
4555
|
+
schema: schema.unknown
|
|
4556
|
+
}
|
|
4557
|
+
};
|
|
4558
|
+
|
|
4559
|
+
// ../common-web/src/times.ts
|
|
4560
|
+
var SECOND = 1e3;
|
|
4561
|
+
var MINUTE = SECOND * 60;
|
|
4562
|
+
var HOUR = MINUTE * 60;
|
|
4563
|
+
var DAY = HOUR * 24;
|
|
4564
|
+
|
|
4565
|
+
// ../common-web/src/strings.ts
|
|
4566
|
+
var utf8Len = (str) => {
|
|
4567
|
+
return new TextEncoder().encode(str).byteLength;
|
|
4568
|
+
};
|
|
4569
|
+
var graphemeLen = (str) => {
|
|
4570
|
+
return [...new Intl.Segmenter().segment(str)].length;
|
|
4571
|
+
};
|
|
4572
|
+
|
|
4573
|
+
// ../identifier/src/reserved.ts
|
|
4574
|
+
var atpSpecific = [
|
|
4575
|
+
"at",
|
|
4576
|
+
"atp",
|
|
4577
|
+
"plc",
|
|
4578
|
+
"pds",
|
|
4579
|
+
"did",
|
|
4580
|
+
"repo",
|
|
4581
|
+
"tid",
|
|
4582
|
+
"nsid",
|
|
4583
|
+
"xrpc",
|
|
4584
|
+
"lex",
|
|
4585
|
+
"lexicon",
|
|
4586
|
+
"bsky",
|
|
4587
|
+
"bluesky",
|
|
4588
|
+
"handle"
|
|
4589
|
+
];
|
|
4590
|
+
var commonlyReserved = [
|
|
4591
|
+
"about",
|
|
4592
|
+
"abuse",
|
|
4593
|
+
"access",
|
|
4594
|
+
"account",
|
|
4595
|
+
"accounts",
|
|
4596
|
+
"acme",
|
|
4597
|
+
"activate",
|
|
4598
|
+
"activities",
|
|
4599
|
+
"activity",
|
|
4600
|
+
"ad",
|
|
4601
|
+
"add",
|
|
4602
|
+
"address",
|
|
4603
|
+
"adm",
|
|
4604
|
+
"admanager",
|
|
4605
|
+
"admin",
|
|
4606
|
+
"administration",
|
|
4607
|
+
"administrator",
|
|
4608
|
+
"administrators",
|
|
4609
|
+
"admins",
|
|
4610
|
+
"ads",
|
|
4611
|
+
"adsense",
|
|
4612
|
+
"adult",
|
|
4613
|
+
"advertising",
|
|
4614
|
+
"adwords",
|
|
4615
|
+
"affiliate",
|
|
4616
|
+
"affiliatepage",
|
|
4617
|
+
"affiliates",
|
|
4618
|
+
"afp",
|
|
4619
|
+
"ajax",
|
|
4620
|
+
"all",
|
|
4621
|
+
"alpha",
|
|
4622
|
+
"analysis",
|
|
4623
|
+
"analytics",
|
|
4624
|
+
"android",
|
|
4625
|
+
"anon",
|
|
4626
|
+
"anonymous",
|
|
4627
|
+
"answer",
|
|
4628
|
+
"answers",
|
|
4629
|
+
"ap",
|
|
4630
|
+
"api",
|
|
4631
|
+
"apis",
|
|
4632
|
+
"app",
|
|
4633
|
+
"appengine",
|
|
4634
|
+
"appnews",
|
|
4635
|
+
"apps",
|
|
4636
|
+
"archive",
|
|
4637
|
+
"archives",
|
|
4638
|
+
"article",
|
|
4639
|
+
"asdf",
|
|
4640
|
+
"asset",
|
|
4641
|
+
"assets",
|
|
4642
|
+
"auth",
|
|
4643
|
+
"authentication",
|
|
4644
|
+
"avatar",
|
|
4645
|
+
"backup",
|
|
4646
|
+
"bank",
|
|
4647
|
+
"banner",
|
|
4648
|
+
"banners",
|
|
4649
|
+
"base",
|
|
4650
|
+
"beginners",
|
|
4651
|
+
"beta",
|
|
4652
|
+
"billing",
|
|
4653
|
+
"bin",
|
|
4654
|
+
"binaries",
|
|
4655
|
+
"binary",
|
|
4656
|
+
"blackberry",
|
|
4657
|
+
"blog",
|
|
4658
|
+
"blogs",
|
|
4659
|
+
"blogsearch",
|
|
4660
|
+
"board",
|
|
4661
|
+
"book",
|
|
4662
|
+
"bookmark",
|
|
4663
|
+
"bookmarks",
|
|
4664
|
+
"books",
|
|
4665
|
+
"bot",
|
|
4666
|
+
"bots",
|
|
4667
|
+
"bug",
|
|
4668
|
+
"bugs",
|
|
4669
|
+
"business",
|
|
4670
|
+
"buy",
|
|
4671
|
+
"buzz",
|
|
4672
|
+
"cache",
|
|
4673
|
+
"calendar",
|
|
4674
|
+
"call",
|
|
4675
|
+
"campaign",
|
|
4676
|
+
"cancel",
|
|
4677
|
+
"captcha",
|
|
4678
|
+
"career",
|
|
4679
|
+
"careers",
|
|
4680
|
+
"cart",
|
|
4681
|
+
"catalog",
|
|
4682
|
+
"catalogs",
|
|
4683
|
+
"categories",
|
|
4684
|
+
"category",
|
|
4685
|
+
"cdn",
|
|
4686
|
+
"cgi",
|
|
4687
|
+
"cgi-bin",
|
|
4688
|
+
"changelog",
|
|
4689
|
+
"chart",
|
|
4690
|
+
"charts",
|
|
4691
|
+
"chat",
|
|
4692
|
+
"check",
|
|
4693
|
+
"checked",
|
|
4694
|
+
"checking",
|
|
4695
|
+
"checkout",
|
|
4696
|
+
"client",
|
|
4697
|
+
"cliente",
|
|
4698
|
+
"clients",
|
|
4699
|
+
"clients1",
|
|
4700
|
+
"cnarne",
|
|
4701
|
+
"code",
|
|
4702
|
+
"comercial",
|
|
4703
|
+
"comment",
|
|
4704
|
+
"comments",
|
|
4705
|
+
"communities",
|
|
4706
|
+
"community",
|
|
4707
|
+
"company",
|
|
4708
|
+
"compare",
|
|
4709
|
+
"compras",
|
|
4710
|
+
"config",
|
|
4711
|
+
"configuration",
|
|
4712
|
+
"confirm",
|
|
4713
|
+
"confirmation",
|
|
4714
|
+
"connect",
|
|
4715
|
+
"contact",
|
|
4716
|
+
"contacts",
|
|
4717
|
+
"contactus",
|
|
4718
|
+
"contact-us",
|
|
4719
|
+
"contact_us",
|
|
4720
|
+
"content",
|
|
4721
|
+
"contest",
|
|
4722
|
+
"contribute",
|
|
4723
|
+
"contributor",
|
|
4724
|
+
"contributors",
|
|
4725
|
+
"coppa",
|
|
4726
|
+
"copyright",
|
|
4727
|
+
"copyrights",
|
|
4728
|
+
"core",
|
|
4729
|
+
"corp",
|
|
4730
|
+
"countries",
|
|
4731
|
+
"country",
|
|
4732
|
+
"cpanel",
|
|
4733
|
+
"create",
|
|
4734
|
+
"css",
|
|
4735
|
+
"cssproxy",
|
|
4736
|
+
"customise",
|
|
4737
|
+
"customize",
|
|
4738
|
+
"dashboard",
|
|
4739
|
+
"data",
|
|
4740
|
+
"db",
|
|
4741
|
+
"default",
|
|
4742
|
+
"delete",
|
|
4743
|
+
"demo",
|
|
4744
|
+
"design",
|
|
4745
|
+
"designer",
|
|
4746
|
+
"desktop",
|
|
4747
|
+
"destroy",
|
|
4748
|
+
"dev",
|
|
4749
|
+
"devel",
|
|
4750
|
+
"developer",
|
|
4751
|
+
"developers",
|
|
4752
|
+
"devs",
|
|
4753
|
+
"diagram",
|
|
4754
|
+
"diary",
|
|
4755
|
+
"dict",
|
|
4756
|
+
"dictionary",
|
|
4757
|
+
"die",
|
|
4758
|
+
"dir",
|
|
4759
|
+
"directory",
|
|
4760
|
+
"direct_messages",
|
|
4761
|
+
"direct-messages",
|
|
4762
|
+
"dist",
|
|
4763
|
+
"diversity",
|
|
4764
|
+
"dl",
|
|
4765
|
+
"dmca",
|
|
4766
|
+
"doc",
|
|
4767
|
+
"docs",
|
|
4768
|
+
"documentation",
|
|
4769
|
+
"documentations",
|
|
4770
|
+
"documents",
|
|
4771
|
+
"domain",
|
|
4772
|
+
"domains",
|
|
4773
|
+
"donate",
|
|
4774
|
+
"download",
|
|
4775
|
+
"downloads",
|
|
4776
|
+
"e",
|
|
4777
|
+
"e-mail",
|
|
4778
|
+
"earth",
|
|
4779
|
+
"ecommerce",
|
|
4780
|
+
"edit",
|
|
4781
|
+
"edits",
|
|
4782
|
+
"editor",
|
|
4783
|
+
"edu",
|
|
4784
|
+
"education",
|
|
4785
|
+
"email",
|
|
4786
|
+
"embed",
|
|
4787
|
+
"embedded",
|
|
4788
|
+
"employment",
|
|
4789
|
+
"employments",
|
|
4790
|
+
"empty",
|
|
4791
|
+
"enable",
|
|
4792
|
+
"encrypted",
|
|
4793
|
+
"end",
|
|
4794
|
+
"engine",
|
|
4795
|
+
"enterprise",
|
|
4796
|
+
"enterprises",
|
|
4797
|
+
"entries",
|
|
4798
|
+
"entry",
|
|
4799
|
+
"error",
|
|
4800
|
+
"errorlog",
|
|
4801
|
+
"errors",
|
|
4802
|
+
"eval",
|
|
4803
|
+
"event",
|
|
4804
|
+
"example",
|
|
4805
|
+
"examplecommunity",
|
|
4806
|
+
"exampleopenid",
|
|
4807
|
+
"examplesyn",
|
|
4808
|
+
"examplesyndicated",
|
|
4809
|
+
"exampleusername",
|
|
4810
|
+
"exchange",
|
|
4811
|
+
"exit",
|
|
4812
|
+
"explore",
|
|
4813
|
+
"faq",
|
|
4814
|
+
"faqs",
|
|
4815
|
+
"favorite",
|
|
4816
|
+
"favorites",
|
|
4817
|
+
"favourite",
|
|
4818
|
+
"favourites",
|
|
4819
|
+
"feature",
|
|
4820
|
+
"features",
|
|
4821
|
+
"feed",
|
|
4822
|
+
"feedback",
|
|
4823
|
+
"feedburner",
|
|
4824
|
+
"feedproxy",
|
|
4825
|
+
"feeds",
|
|
4826
|
+
"file",
|
|
4827
|
+
"files",
|
|
4828
|
+
"finance",
|
|
4829
|
+
"folder",
|
|
4830
|
+
"folders",
|
|
4831
|
+
"first",
|
|
4832
|
+
"following",
|
|
4833
|
+
"forgot",
|
|
4834
|
+
"form",
|
|
4835
|
+
"forms",
|
|
4836
|
+
"forum",
|
|
4837
|
+
"forums",
|
|
4838
|
+
"founder",
|
|
4839
|
+
"free",
|
|
4840
|
+
"friend",
|
|
4841
|
+
"friends",
|
|
4842
|
+
"ftp",
|
|
4843
|
+
"fuck",
|
|
4844
|
+
"fun",
|
|
4845
|
+
"fusion",
|
|
4846
|
+
"gadget",
|
|
4847
|
+
"gadgets",
|
|
4848
|
+
"game",
|
|
4849
|
+
"games",
|
|
4850
|
+
"gears",
|
|
4851
|
+
"general",
|
|
4852
|
+
"geographic",
|
|
4853
|
+
"get",
|
|
4854
|
+
"gettingstarted",
|
|
4855
|
+
"gift",
|
|
4856
|
+
"gifts",
|
|
4857
|
+
"gist",
|
|
4858
|
+
"git",
|
|
4859
|
+
"github",
|
|
4860
|
+
"gmail",
|
|
4861
|
+
"go",
|
|
4862
|
+
"golang",
|
|
4863
|
+
"goto",
|
|
4864
|
+
"gov",
|
|
4865
|
+
"graph",
|
|
4866
|
+
"graphs",
|
|
4867
|
+
"group",
|
|
4868
|
+
"groups",
|
|
4869
|
+
"guest",
|
|
4870
|
+
"guests",
|
|
4871
|
+
"guide",
|
|
4872
|
+
"guides",
|
|
4873
|
+
"hack",
|
|
4874
|
+
"hacks",
|
|
4875
|
+
"head",
|
|
4876
|
+
"help",
|
|
4877
|
+
"home",
|
|
4878
|
+
"homepage",
|
|
4879
|
+
"host",
|
|
4880
|
+
"hosting",
|
|
4881
|
+
"hostmaster",
|
|
4882
|
+
"hostname",
|
|
4883
|
+
"howto",
|
|
4884
|
+
"how-to",
|
|
4885
|
+
"how_to",
|
|
4886
|
+
"html",
|
|
4887
|
+
"htrnl",
|
|
4888
|
+
"http",
|
|
4889
|
+
"httpd",
|
|
4890
|
+
"https",
|
|
4891
|
+
"i",
|
|
4892
|
+
"iamges",
|
|
4893
|
+
"icon",
|
|
4894
|
+
"icons",
|
|
4895
|
+
"id",
|
|
4896
|
+
"idea",
|
|
4897
|
+
"ideas",
|
|
4898
|
+
"im",
|
|
4899
|
+
"image",
|
|
4900
|
+
"images",
|
|
4901
|
+
"img",
|
|
4902
|
+
"imap",
|
|
4903
|
+
"inbox",
|
|
4904
|
+
"inboxes",
|
|
4905
|
+
"index",
|
|
4906
|
+
"indexes",
|
|
4907
|
+
"info",
|
|
4908
|
+
"information",
|
|
4909
|
+
"inquiry",
|
|
4910
|
+
"intranet",
|
|
4911
|
+
"investor",
|
|
4912
|
+
"investors",
|
|
4913
|
+
"invitation",
|
|
4914
|
+
"invitations",
|
|
4915
|
+
"invite",
|
|
4916
|
+
"invoice",
|
|
4917
|
+
"invoices",
|
|
4918
|
+
"imac",
|
|
4919
|
+
"ios",
|
|
4920
|
+
"ipad",
|
|
4921
|
+
"iphone",
|
|
4922
|
+
"irc",
|
|
4923
|
+
"irnages",
|
|
4924
|
+
"irng",
|
|
4925
|
+
"is",
|
|
4926
|
+
"issue",
|
|
4927
|
+
"issues",
|
|
4928
|
+
"it",
|
|
4929
|
+
"item",
|
|
4930
|
+
"items",
|
|
4931
|
+
"java",
|
|
4932
|
+
"javascript",
|
|
4933
|
+
"job",
|
|
4934
|
+
"jobs",
|
|
4935
|
+
"join",
|
|
4936
|
+
"js",
|
|
4937
|
+
"json",
|
|
4938
|
+
"jump",
|
|
4939
|
+
"kb",
|
|
4940
|
+
"knowledge-base",
|
|
4941
|
+
"knowledgebase",
|
|
4942
|
+
"lab",
|
|
4943
|
+
"labs",
|
|
4944
|
+
"language",
|
|
4945
|
+
"languages",
|
|
4946
|
+
"last",
|
|
4947
|
+
"ldap_status",
|
|
4948
|
+
"ldap-status",
|
|
4949
|
+
"ldapstatus",
|
|
4950
|
+
"legal",
|
|
4951
|
+
"license",
|
|
4952
|
+
"licenses",
|
|
4953
|
+
"link",
|
|
4954
|
+
"links",
|
|
4955
|
+
"linux",
|
|
4956
|
+
"list",
|
|
4957
|
+
"lists",
|
|
4958
|
+
"livejournal",
|
|
4959
|
+
"lj",
|
|
4960
|
+
"local",
|
|
4961
|
+
"locale",
|
|
4962
|
+
"location",
|
|
4963
|
+
"log",
|
|
4964
|
+
"log-in",
|
|
4965
|
+
"log-out",
|
|
4966
|
+
"login",
|
|
4967
|
+
"logout",
|
|
4968
|
+
"logs",
|
|
4969
|
+
"log_in",
|
|
4970
|
+
"log_out",
|
|
4971
|
+
"m",
|
|
4972
|
+
"mac",
|
|
4973
|
+
"macos",
|
|
4974
|
+
"macosx",
|
|
4975
|
+
"mac-os",
|
|
4976
|
+
"mac-os-x",
|
|
4977
|
+
"mac_os_x",
|
|
4978
|
+
"mail",
|
|
4979
|
+
"mailer",
|
|
4980
|
+
"mailing",
|
|
4981
|
+
"main",
|
|
4982
|
+
"maintenance",
|
|
4983
|
+
"manage",
|
|
4984
|
+
"manager",
|
|
4985
|
+
"manual",
|
|
4986
|
+
"map",
|
|
4987
|
+
"maps",
|
|
4988
|
+
"marketing",
|
|
4989
|
+
"master",
|
|
4990
|
+
"me",
|
|
4991
|
+
"media",
|
|
4992
|
+
"member",
|
|
4993
|
+
"members",
|
|
4994
|
+
"memories",
|
|
4995
|
+
"memory",
|
|
4996
|
+
"merchandise",
|
|
4997
|
+
"message",
|
|
4998
|
+
"messages",
|
|
4999
|
+
"messenger",
|
|
5000
|
+
"mg",
|
|
5001
|
+
"microblog",
|
|
5002
|
+
"microblogs",
|
|
5003
|
+
"mine",
|
|
5004
|
+
"mis",
|
|
5005
|
+
"misc",
|
|
5006
|
+
"mms",
|
|
5007
|
+
"mob",
|
|
5008
|
+
"mobile",
|
|
5009
|
+
"model",
|
|
5010
|
+
"models",
|
|
5011
|
+
"money",
|
|
5012
|
+
"movie",
|
|
5013
|
+
"movies",
|
|
5014
|
+
"mp3",
|
|
5015
|
+
"mp4",
|
|
5016
|
+
"msg",
|
|
5017
|
+
"msn",
|
|
5018
|
+
"music",
|
|
5019
|
+
"mx",
|
|
5020
|
+
"my",
|
|
5021
|
+
"mymme",
|
|
5022
|
+
"mysql",
|
|
5023
|
+
"name",
|
|
5024
|
+
"named",
|
|
5025
|
+
"nan",
|
|
5026
|
+
"navi",
|
|
5027
|
+
"navigation",
|
|
5028
|
+
"net",
|
|
5029
|
+
"network",
|
|
5030
|
+
"networks",
|
|
5031
|
+
"new",
|
|
5032
|
+
"news",
|
|
5033
|
+
"newsletter",
|
|
5034
|
+
"nick",
|
|
5035
|
+
"nickname",
|
|
5036
|
+
"nil",
|
|
5037
|
+
"none",
|
|
5038
|
+
"notes",
|
|
5039
|
+
"noticias",
|
|
5040
|
+
"notification",
|
|
5041
|
+
"notifications",
|
|
5042
|
+
"notify",
|
|
5043
|
+
"ns",
|
|
5044
|
+
"ns1",
|
|
5045
|
+
"ns2",
|
|
5046
|
+
"ns3",
|
|
5047
|
+
"ns4",
|
|
5048
|
+
"ns5",
|
|
5049
|
+
"null",
|
|
5050
|
+
"oauth",
|
|
5051
|
+
"oauth-clients",
|
|
5052
|
+
"oauth_clients",
|
|
5053
|
+
"ocsp",
|
|
5054
|
+
"offer",
|
|
5055
|
+
"offers",
|
|
5056
|
+
"official",
|
|
5057
|
+
"old",
|
|
5058
|
+
"online",
|
|
5059
|
+
"openid",
|
|
5060
|
+
"operator",
|
|
5061
|
+
"option",
|
|
5062
|
+
"options",
|
|
5063
|
+
"order",
|
|
5064
|
+
"orders",
|
|
5065
|
+
"org",
|
|
5066
|
+
"organization",
|
|
5067
|
+
"organizations",
|
|
5068
|
+
"other",
|
|
5069
|
+
"overview",
|
|
5070
|
+
"owner",
|
|
5071
|
+
"owners",
|
|
5072
|
+
"p0rn",
|
|
5073
|
+
"pack",
|
|
5074
|
+
"page",
|
|
5075
|
+
"pager",
|
|
5076
|
+
"pages",
|
|
5077
|
+
"paid",
|
|
5078
|
+
"panel",
|
|
5079
|
+
"partner",
|
|
5080
|
+
"partnerpage",
|
|
5081
|
+
"partners",
|
|
5082
|
+
"password",
|
|
5083
|
+
"patch",
|
|
5084
|
+
"pay",
|
|
5085
|
+
"payment",
|
|
5086
|
+
"people",
|
|
5087
|
+
"perl",
|
|
5088
|
+
"person",
|
|
5089
|
+
"phone",
|
|
5090
|
+
"photo",
|
|
5091
|
+
"photoalbum",
|
|
5092
|
+
"photos",
|
|
5093
|
+
"php",
|
|
5094
|
+
"phpmyadmin",
|
|
5095
|
+
"phppgadmin",
|
|
5096
|
+
"phpredisadmin",
|
|
5097
|
+
"pic",
|
|
5098
|
+
"pics",
|
|
5099
|
+
"picture",
|
|
5100
|
+
"pictures",
|
|
5101
|
+
"ping",
|
|
5102
|
+
"pixel",
|
|
5103
|
+
"places",
|
|
5104
|
+
"plan",
|
|
5105
|
+
"plans",
|
|
5106
|
+
"plugin",
|
|
5107
|
+
"plugins",
|
|
5108
|
+
"podcasts",
|
|
5109
|
+
"policies",
|
|
5110
|
+
"policy",
|
|
5111
|
+
"pop",
|
|
5112
|
+
"pop3",
|
|
5113
|
+
"popular",
|
|
5114
|
+
"porn",
|
|
5115
|
+
"portal",
|
|
5116
|
+
"portals",
|
|
5117
|
+
"post",
|
|
5118
|
+
"postfix",
|
|
5119
|
+
"postmaster",
|
|
5120
|
+
"posts",
|
|
5121
|
+
"pr",
|
|
5122
|
+
"pr0n",
|
|
5123
|
+
"premium",
|
|
5124
|
+
"press",
|
|
5125
|
+
"price",
|
|
5126
|
+
"pricing",
|
|
5127
|
+
"principles",
|
|
5128
|
+
"print",
|
|
5129
|
+
"privacy",
|
|
5130
|
+
"privacy-policy",
|
|
5131
|
+
"privacypolicy",
|
|
5132
|
+
"privacy_policy",
|
|
5133
|
+
"private",
|
|
5134
|
+
"prod",
|
|
5135
|
+
"product",
|
|
5136
|
+
"production",
|
|
5137
|
+
"products",
|
|
5138
|
+
"profile",
|
|
5139
|
+
"profiles",
|
|
5140
|
+
"project",
|
|
5141
|
+
"projects",
|
|
5142
|
+
"promo",
|
|
5143
|
+
"promotions",
|
|
5144
|
+
"proxies",
|
|
5145
|
+
"proxy",
|
|
5146
|
+
"pub",
|
|
5147
|
+
"public",
|
|
5148
|
+
"purchase",
|
|
5149
|
+
"purpose",
|
|
5150
|
+
"put",
|
|
5151
|
+
"python",
|
|
5152
|
+
"queries",
|
|
5153
|
+
"query",
|
|
5154
|
+
"radio",
|
|
5155
|
+
"random",
|
|
5156
|
+
"ranking",
|
|
5157
|
+
"read",
|
|
5158
|
+
"reader",
|
|
5159
|
+
"readme",
|
|
5160
|
+
"recent",
|
|
5161
|
+
"recruit",
|
|
5162
|
+
"recruitment",
|
|
5163
|
+
"redirect",
|
|
5164
|
+
"register",
|
|
5165
|
+
"registration",
|
|
5166
|
+
"release",
|
|
5167
|
+
"remove",
|
|
5168
|
+
"replies",
|
|
5169
|
+
"report",
|
|
5170
|
+
"reports",
|
|
5171
|
+
"repositories",
|
|
5172
|
+
"repository",
|
|
5173
|
+
"req",
|
|
5174
|
+
"request",
|
|
5175
|
+
"requests",
|
|
5176
|
+
"research",
|
|
5177
|
+
"reset",
|
|
5178
|
+
"resolve",
|
|
5179
|
+
"resolver",
|
|
5180
|
+
"review",
|
|
5181
|
+
"rnail",
|
|
5182
|
+
"rnicrosoft",
|
|
5183
|
+
"roc",
|
|
5184
|
+
"root",
|
|
5185
|
+
"rss",
|
|
5186
|
+
"ruby",
|
|
5187
|
+
"rule",
|
|
5188
|
+
"sag",
|
|
5189
|
+
"sale",
|
|
5190
|
+
"sales",
|
|
5191
|
+
"sample",
|
|
5192
|
+
"samples",
|
|
5193
|
+
"sandbox",
|
|
5194
|
+
"save",
|
|
5195
|
+
"scholar",
|
|
5196
|
+
"school",
|
|
5197
|
+
"schools",
|
|
5198
|
+
"script",
|
|
5199
|
+
"scripts",
|
|
5200
|
+
"search",
|
|
5201
|
+
"secure",
|
|
5202
|
+
"security",
|
|
5203
|
+
"self",
|
|
5204
|
+
"seminars",
|
|
5205
|
+
"send",
|
|
5206
|
+
"server",
|
|
5207
|
+
"server-info",
|
|
5208
|
+
"server_info",
|
|
5209
|
+
"server-status",
|
|
5210
|
+
"server_status",
|
|
5211
|
+
"servers",
|
|
5212
|
+
"service",
|
|
5213
|
+
"services",
|
|
5214
|
+
"session",
|
|
5215
|
+
"sessions",
|
|
5216
|
+
"setting",
|
|
5217
|
+
"settings",
|
|
5218
|
+
"setup",
|
|
5219
|
+
"share",
|
|
5220
|
+
"shop",
|
|
5221
|
+
"shopping",
|
|
5222
|
+
"shortcut",
|
|
5223
|
+
"shortcuts",
|
|
5224
|
+
"show",
|
|
5225
|
+
"sign-in",
|
|
5226
|
+
"sign-up",
|
|
5227
|
+
"signin",
|
|
5228
|
+
"signout",
|
|
5229
|
+
"signup",
|
|
5230
|
+
"sign_in",
|
|
5231
|
+
"sign_up",
|
|
5232
|
+
"site",
|
|
5233
|
+
"sitemap",
|
|
5234
|
+
"sitemaps",
|
|
5235
|
+
"sitenews",
|
|
5236
|
+
"sites",
|
|
5237
|
+
"sketchup",
|
|
5238
|
+
"sky",
|
|
5239
|
+
"slash",
|
|
5240
|
+
"slashinvoice",
|
|
5241
|
+
"slut",
|
|
5242
|
+
"smartphone",
|
|
5243
|
+
"sms",
|
|
5244
|
+
"smtp",
|
|
5245
|
+
"soap",
|
|
5246
|
+
"software",
|
|
5247
|
+
"sorry",
|
|
5248
|
+
"source",
|
|
5249
|
+
"spec",
|
|
5250
|
+
"special",
|
|
5251
|
+
"spreadsheet",
|
|
5252
|
+
"spreadsheets",
|
|
5253
|
+
"sql",
|
|
5254
|
+
"src",
|
|
5255
|
+
"srntp",
|
|
5256
|
+
"ssh",
|
|
5257
|
+
"ssl",
|
|
5258
|
+
"ssladmin",
|
|
5259
|
+
"ssladministrator",
|
|
5260
|
+
"sslwebmaster",
|
|
5261
|
+
"ssytem",
|
|
5262
|
+
"staff",
|
|
5263
|
+
"stage",
|
|
5264
|
+
"staging",
|
|
5265
|
+
"start",
|
|
5266
|
+
"stat",
|
|
5267
|
+
"state",
|
|
5268
|
+
"static",
|
|
5269
|
+
"statistics",
|
|
5270
|
+
"stats",
|
|
5271
|
+
"status",
|
|
5272
|
+
"store",
|
|
5273
|
+
"stores",
|
|
5274
|
+
"stories",
|
|
5275
|
+
"style",
|
|
5276
|
+
"styleguide",
|
|
5277
|
+
"styles",
|
|
5278
|
+
"stylesheet",
|
|
5279
|
+
"stylesheets",
|
|
5280
|
+
"subdomain",
|
|
5281
|
+
"subscribe",
|
|
5282
|
+
"subscription",
|
|
5283
|
+
"subscriptions",
|
|
5284
|
+
"suggest",
|
|
5285
|
+
"suggestqueries",
|
|
5286
|
+
"support",
|
|
5287
|
+
"survey",
|
|
5288
|
+
"surveys",
|
|
5289
|
+
"surveytool",
|
|
5290
|
+
"svn",
|
|
5291
|
+
"swf",
|
|
5292
|
+
"syn",
|
|
5293
|
+
"sync",
|
|
5294
|
+
"syndicated",
|
|
5295
|
+
"sys",
|
|
5296
|
+
"sysadmin",
|
|
5297
|
+
"sysadministrator",
|
|
5298
|
+
"sysadmins",
|
|
5299
|
+
"system",
|
|
5300
|
+
"tablet",
|
|
5301
|
+
"tablets",
|
|
5302
|
+
"tag",
|
|
5303
|
+
"tags",
|
|
5304
|
+
"talk",
|
|
5305
|
+
"talkgadget",
|
|
5306
|
+
"task",
|
|
5307
|
+
"tasks",
|
|
5308
|
+
"team",
|
|
5309
|
+
"teams",
|
|
5310
|
+
"tech",
|
|
5311
|
+
"telnet",
|
|
5312
|
+
"term",
|
|
5313
|
+
"terms",
|
|
5314
|
+
"terms-of-service",
|
|
5315
|
+
"termsofservice",
|
|
5316
|
+
"terms_of_service",
|
|
5317
|
+
"test",
|
|
5318
|
+
"testing",
|
|
5319
|
+
"tests",
|
|
5320
|
+
"text",
|
|
5321
|
+
"theme",
|
|
5322
|
+
"themes",
|
|
5323
|
+
"thread",
|
|
5324
|
+
"threads",
|
|
5325
|
+
"ticket",
|
|
5326
|
+
"tickets",
|
|
5327
|
+
"tmp",
|
|
5328
|
+
"todo",
|
|
5329
|
+
"to-do",
|
|
5330
|
+
"to_do",
|
|
5331
|
+
"toml",
|
|
5332
|
+
"tool",
|
|
5333
|
+
"toolbar",
|
|
5334
|
+
"toolbars",
|
|
5335
|
+
"tools",
|
|
5336
|
+
"top",
|
|
5337
|
+
"topic",
|
|
5338
|
+
"topics",
|
|
5339
|
+
"tos",
|
|
5340
|
+
"tour",
|
|
5341
|
+
"trac",
|
|
5342
|
+
"translate",
|
|
5343
|
+
"trace",
|
|
5344
|
+
"translation",
|
|
5345
|
+
"translations",
|
|
5346
|
+
"translator",
|
|
5347
|
+
"trends",
|
|
5348
|
+
"tutorial",
|
|
5349
|
+
"tux",
|
|
5350
|
+
"tv",
|
|
5351
|
+
"twitter",
|
|
5352
|
+
"txt",
|
|
5353
|
+
"ul",
|
|
5354
|
+
"undef",
|
|
5355
|
+
"unfollow",
|
|
5356
|
+
"unsubscribe",
|
|
5357
|
+
"update",
|
|
5358
|
+
"updates",
|
|
5359
|
+
"upgrade",
|
|
5360
|
+
"upgrades",
|
|
5361
|
+
"upi",
|
|
5362
|
+
"upload",
|
|
5363
|
+
"uploads",
|
|
5364
|
+
"url",
|
|
5365
|
+
"usage",
|
|
5366
|
+
"user",
|
|
5367
|
+
"username",
|
|
5368
|
+
"usernames",
|
|
5369
|
+
"users",
|
|
5370
|
+
"uuid",
|
|
5371
|
+
"validation",
|
|
5372
|
+
"validations",
|
|
5373
|
+
"ver",
|
|
5374
|
+
"version",
|
|
5375
|
+
"video",
|
|
5376
|
+
"videos",
|
|
5377
|
+
"video-stats",
|
|
5378
|
+
"visitor",
|
|
5379
|
+
"visitors",
|
|
5380
|
+
"voice",
|
|
5381
|
+
"volunteer",
|
|
5382
|
+
"volunteers",
|
|
5383
|
+
"w",
|
|
5384
|
+
"watch",
|
|
5385
|
+
"wave",
|
|
5386
|
+
"weather",
|
|
5387
|
+
"web",
|
|
5388
|
+
"webdisk",
|
|
5389
|
+
"webhook",
|
|
5390
|
+
"webhooks",
|
|
5391
|
+
"webmail",
|
|
5392
|
+
"webmaster",
|
|
5393
|
+
"webmasters",
|
|
5394
|
+
"webrnail",
|
|
5395
|
+
"website",
|
|
5396
|
+
"websites",
|
|
5397
|
+
"welcome",
|
|
5398
|
+
"whm",
|
|
5399
|
+
"whois",
|
|
5400
|
+
"widget",
|
|
5401
|
+
"widgets",
|
|
5402
|
+
"wifi",
|
|
5403
|
+
"wiki",
|
|
5404
|
+
"wikis",
|
|
5405
|
+
"win",
|
|
5406
|
+
"windows",
|
|
5407
|
+
"word",
|
|
5408
|
+
"work",
|
|
5409
|
+
"works",
|
|
5410
|
+
"workshop",
|
|
5411
|
+
"wpad",
|
|
5412
|
+
"ww",
|
|
5413
|
+
"wws",
|
|
5414
|
+
"www",
|
|
5415
|
+
"wwws",
|
|
5416
|
+
"wwww",
|
|
5417
|
+
"xfn",
|
|
5418
|
+
"xhtml",
|
|
5419
|
+
"xhtrnl",
|
|
5420
|
+
"xml",
|
|
5421
|
+
"xmpp",
|
|
5422
|
+
"xpg",
|
|
5423
|
+
"xxx",
|
|
5424
|
+
"yaml",
|
|
5425
|
+
"year",
|
|
5426
|
+
"yml",
|
|
5427
|
+
"you",
|
|
5428
|
+
"yourdomain",
|
|
5429
|
+
"yourname",
|
|
5430
|
+
"yoursite",
|
|
5431
|
+
"yourusername"
|
|
5432
|
+
];
|
|
5433
|
+
var famousAccounts = [
|
|
5434
|
+
"10ronaldinho",
|
|
5435
|
+
"3gerardpique",
|
|
5436
|
+
"adele",
|
|
5437
|
+
"akshaykumar",
|
|
5438
|
+
"aliaa08",
|
|
5439
|
+
"aliciakeys",
|
|
5440
|
+
"amitshah",
|
|
5441
|
+
"andresiniesta8",
|
|
5442
|
+
"anushkasharma",
|
|
5443
|
+
"arianagrande",
|
|
5444
|
+
"arrahman",
|
|
5445
|
+
"arvindkejriwal",
|
|
5446
|
+
"avrillavigne",
|
|
5447
|
+
"barackobama",
|
|
5448
|
+
"bbcbreaking",
|
|
5449
|
+
"bbcworld",
|
|
5450
|
+
"beingsalmankhan",
|
|
5451
|
+
"billgates",
|
|
5452
|
+
"britneyspears",
|
|
5453
|
+
"brunomars",
|
|
5454
|
+
"bts_bighit",
|
|
5455
|
+
"bts_twt",
|
|
5456
|
+
"championsleague",
|
|
5457
|
+
"chrisbrown",
|
|
5458
|
+
"cnnbrk",
|
|
5459
|
+
"coldplay",
|
|
5460
|
+
"conanobrien",
|
|
5461
|
+
"cristiano",
|
|
5462
|
+
"danieltosh",
|
|
5463
|
+
"davidguetta",
|
|
5464
|
+
"ddlovato",
|
|
5465
|
+
"deepikapadukone",
|
|
5466
|
+
"drake",
|
|
5467
|
+
"elisapie",
|
|
5468
|
+
"ellendegeneres",
|
|
5469
|
+
"elonmusk",
|
|
5470
|
+
"eminem",
|
|
5471
|
+
"emmawatson",
|
|
5472
|
+
"fcbarcelona",
|
|
5473
|
+
"foxnews",
|
|
5474
|
+
"harry_styles",
|
|
5475
|
+
"hillaryclinton",
|
|
5476
|
+
"iamsrk",
|
|
5477
|
+
"ihrithik",
|
|
5478
|
+
"imvkohli",
|
|
5479
|
+
"instagram",
|
|
5480
|
+
"jimmyfallon",
|
|
5481
|
+
"jlo",
|
|
5482
|
+
"joebiden",
|
|
5483
|
+
"jtimberlake",
|
|
5484
|
+
"justinbieber",
|
|
5485
|
+
"kaka",
|
|
5486
|
+
"kanyewest",
|
|
5487
|
+
"katyperry",
|
|
5488
|
+
"kendalljenner",
|
|
5489
|
+
"kevinhart4real",
|
|
5490
|
+
"khloekardashian",
|
|
5491
|
+
"kimkardashian",
|
|
5492
|
+
"kingjames",
|
|
5493
|
+
"kourtneykardash",
|
|
5494
|
+
"kyliejenner",
|
|
5495
|
+
"ladygaga",
|
|
5496
|
+
"liampayne",
|
|
5497
|
+
"liltunechi",
|
|
5498
|
+
"manutd",
|
|
5499
|
+
"mariahcarey",
|
|
5500
|
+
"mileycyrus",
|
|
5501
|
+
"mohamadalarefe",
|
|
5502
|
+
"narendramodi",
|
|
5503
|
+
"nasa",
|
|
5504
|
+
"nba",
|
|
5505
|
+
"neymarjr",
|
|
5506
|
+
"nfl",
|
|
5507
|
+
"niallofficial",
|
|
5508
|
+
"nickiminaj",
|
|
5509
|
+
"nytimes",
|
|
5510
|
+
"onedirection",
|
|
5511
|
+
"oprah",
|
|
5512
|
+
"pink",
|
|
5513
|
+
"pitbull",
|
|
5514
|
+
"playstation",
|
|
5515
|
+
"pmoindia",
|
|
5516
|
+
"premierleague",
|
|
5517
|
+
"priyankachopra",
|
|
5518
|
+
"realdonaldtrump",
|
|
5519
|
+
"ricky_martin",
|
|
5520
|
+
"rihanna",
|
|
5521
|
+
"sachin_rt",
|
|
5522
|
+
"selenagomez",
|
|
5523
|
+
"shakira",
|
|
5524
|
+
"shawnmendes",
|
|
5525
|
+
"sportscenter",
|
|
5526
|
+
"srbachchan",
|
|
5527
|
+
"subhisharma100",
|
|
5528
|
+
"taylorswift13",
|
|
5529
|
+
"theeconomist",
|
|
5530
|
+
"twitter",
|
|
5531
|
+
"virendersehwag",
|
|
5532
|
+
"whitehouse45",
|
|
5533
|
+
"wizkhalifa",
|
|
5534
|
+
"youtube",
|
|
5535
|
+
"zaynmalik",
|
|
5536
|
+
"beyonce",
|
|
5537
|
+
"billieeilish",
|
|
5538
|
+
"leomessi",
|
|
5539
|
+
"natgeo",
|
|
5540
|
+
"nike",
|
|
5541
|
+
"snoopdogg",
|
|
5542
|
+
"taylorswift",
|
|
5543
|
+
"therock",
|
|
5544
|
+
"10downingstreet",
|
|
5545
|
+
"aoc",
|
|
5546
|
+
"carterjwm",
|
|
5547
|
+
"dril",
|
|
5548
|
+
"gretathunberg",
|
|
5549
|
+
"kamalaharris",
|
|
5550
|
+
"kremlinrussia_e",
|
|
5551
|
+
"potus",
|
|
5552
|
+
"rondesantisfl",
|
|
5553
|
+
"ukraine",
|
|
5554
|
+
"washingtonpost",
|
|
5555
|
+
"yousuck2020",
|
|
5556
|
+
"zelenskyyua"
|
|
5557
|
+
];
|
|
5558
|
+
var reservedSubdomains = [
|
|
5559
|
+
...atpSpecific,
|
|
5560
|
+
...commonlyReserved,
|
|
5561
|
+
...famousAccounts
|
|
5562
|
+
].reduce((acc, cur) => {
|
|
5563
|
+
return {
|
|
5564
|
+
...acc,
|
|
5565
|
+
[cur]: true
|
|
5566
|
+
};
|
|
5567
|
+
}, {});
|
|
5568
|
+
|
|
5569
|
+
// ../identifier/src/handle.ts
|
|
5570
|
+
var ensureValidHandle = (handle2) => {
|
|
5571
|
+
if (!/^[a-zA-Z0-9.-]*$/.test(handle2)) {
|
|
5572
|
+
throw new InvalidHandleError(
|
|
5573
|
+
"Disallowed characters in handle (ASCII letters, digits, dashes, periods only)"
|
|
5574
|
+
);
|
|
5575
|
+
}
|
|
5576
|
+
if (handle2.length > 253) {
|
|
5577
|
+
throw new InvalidHandleError("Handle is too long (253 chars max)");
|
|
5578
|
+
}
|
|
5579
|
+
const labels = handle2.split(".");
|
|
5580
|
+
if (labels.length < 2) {
|
|
5581
|
+
throw new InvalidHandleError("Handle domain needs at least two parts");
|
|
5582
|
+
}
|
|
5583
|
+
for (let i = 0; i < labels.length; i++) {
|
|
5584
|
+
const l = labels[i];
|
|
5585
|
+
if (l.length < 1) {
|
|
5586
|
+
throw new InvalidHandleError("Handle parts can not be empty");
|
|
5587
|
+
}
|
|
5588
|
+
if (l.length > 63) {
|
|
5589
|
+
throw new InvalidHandleError("Handle part too long (max 63 chars)");
|
|
5590
|
+
}
|
|
5591
|
+
if (l.endsWith("-") || l.startsWith("-")) {
|
|
5592
|
+
throw new InvalidHandleError(
|
|
5593
|
+
"Handle parts can not start or end with hyphens"
|
|
5594
|
+
);
|
|
5595
|
+
}
|
|
5596
|
+
if (i + 1 == labels.length && !/^[a-zA-Z]/.test(l)) {
|
|
5597
|
+
throw new InvalidHandleError(
|
|
5598
|
+
"Handle final component (TLD) must start with ASCII letter"
|
|
5599
|
+
);
|
|
5600
|
+
}
|
|
5601
|
+
}
|
|
5602
|
+
};
|
|
5603
|
+
var InvalidHandleError = class extends Error {
|
|
5604
|
+
};
|
|
5605
|
+
|
|
5606
|
+
// ../identifier/src/did.ts
|
|
5607
|
+
var ensureValidDid = (did2) => {
|
|
5608
|
+
if (!/^[a-zA-Z0-9._:%-]*$/.test(did2)) {
|
|
5609
|
+
throw new InvalidDidError(
|
|
5610
|
+
"Disallowed characters in DID (ASCII letters, digits, and a couple other characters only)"
|
|
5611
|
+
);
|
|
5612
|
+
}
|
|
5613
|
+
const parts = did2.split(":");
|
|
5614
|
+
if (parts.length < 3) {
|
|
5615
|
+
throw new InvalidDidError(
|
|
5616
|
+
"DID requires prefix, method, and method-specific content"
|
|
5617
|
+
);
|
|
5618
|
+
}
|
|
5619
|
+
if (parts[0] != "did") {
|
|
5620
|
+
throw new InvalidDidError('DID requires "did:" prefix');
|
|
5621
|
+
}
|
|
5622
|
+
if (!/^[a-z]+$/.test(parts[1])) {
|
|
5623
|
+
throw new InvalidDidError("DID method must be lower-case letters");
|
|
5624
|
+
}
|
|
5625
|
+
if (did2.endsWith(":") || did2.endsWith("%")) {
|
|
5626
|
+
throw new InvalidDidError('DID can not end with ":" or "%"');
|
|
5627
|
+
}
|
|
5628
|
+
if (did2.length > 8 * 1024) {
|
|
5629
|
+
throw new InvalidDidError("DID is far too long");
|
|
5630
|
+
}
|
|
5631
|
+
};
|
|
5632
|
+
var InvalidDidError = class extends Error {
|
|
5633
|
+
};
|
|
5634
|
+
|
|
5635
|
+
// ../uri/src/validation.ts
|
|
5636
|
+
var ensureValidAtUri = (uri2) => {
|
|
5637
|
+
const uriParts = uri2.split("#");
|
|
5638
|
+
if (uriParts.length > 2) {
|
|
5639
|
+
throw new Error('ATURI can have at most one "#", separating fragment out');
|
|
5640
|
+
}
|
|
5641
|
+
const fragmentPart = uriParts[1] || null;
|
|
5642
|
+
uri2 = uriParts[0];
|
|
5643
|
+
if (!/^[a-zA-Z0-9._~:@!$&')(*+,;=%/-]*$/.test(uri2)) {
|
|
5644
|
+
throw new Error("Disallowed characters in ATURI (ASCII)");
|
|
5645
|
+
}
|
|
5646
|
+
const parts = uri2.split("/");
|
|
5647
|
+
if (parts.length >= 3 && (parts[0] != "at:" || parts[1].length != 0)) {
|
|
5648
|
+
throw new Error('ATURI must start with "at://"');
|
|
5649
|
+
}
|
|
5650
|
+
if (parts.length < 3) {
|
|
5651
|
+
throw new Error("ATURI requires at least method and authority sections");
|
|
5652
|
+
}
|
|
5653
|
+
try {
|
|
5654
|
+
ensureValidHandle(parts[2]);
|
|
5655
|
+
} catch {
|
|
5656
|
+
try {
|
|
5657
|
+
ensureValidDid(parts[2]);
|
|
5658
|
+
} catch {
|
|
5659
|
+
throw new Error("ATURI authority must be a valid handle or DID");
|
|
5660
|
+
}
|
|
5661
|
+
}
|
|
5662
|
+
if (parts.length >= 4) {
|
|
5663
|
+
if (parts[3].length == 0) {
|
|
5664
|
+
throw new Error(
|
|
5665
|
+
"ATURI can not have a slash after authority without a path segment"
|
|
5666
|
+
);
|
|
5667
|
+
}
|
|
5668
|
+
try {
|
|
5669
|
+
ensureValidNsid(parts[3]);
|
|
5670
|
+
} catch {
|
|
5671
|
+
throw new Error(
|
|
5672
|
+
"ATURI requires first path segment (if supplied) to be valid NSID"
|
|
5673
|
+
);
|
|
5674
|
+
}
|
|
5675
|
+
}
|
|
5676
|
+
if (parts.length >= 5) {
|
|
5677
|
+
if (parts[4].length == 0) {
|
|
5678
|
+
throw new Error(
|
|
5679
|
+
"ATURI can not have a slash after collection, unless record key is provided"
|
|
5680
|
+
);
|
|
5681
|
+
}
|
|
5682
|
+
}
|
|
5683
|
+
if (parts.length >= 6) {
|
|
5684
|
+
throw new Error(
|
|
5685
|
+
"ATURI path can have at most two parts, and no trailing slash"
|
|
5686
|
+
);
|
|
5687
|
+
}
|
|
5688
|
+
if (uriParts.length >= 2 && fragmentPart == null) {
|
|
5689
|
+
throw new Error("ATURI fragment must be non-empty and start with slash");
|
|
5690
|
+
}
|
|
5691
|
+
if (fragmentPart != null) {
|
|
5692
|
+
if (fragmentPart.length == 0 || fragmentPart[0] != "/") {
|
|
5693
|
+
throw new Error("ATURI fragment must be non-empty and start with slash");
|
|
5694
|
+
}
|
|
5695
|
+
if (!/^\/[a-zA-Z0-9._~:@!$&')(*+,;=%[\]/-]*$/.test(fragmentPart)) {
|
|
5696
|
+
throw new Error("Disallowed characters in ATURI fragment (ASCII)");
|
|
5697
|
+
}
|
|
5698
|
+
}
|
|
5699
|
+
if (uri2.length > 8 * 1024) {
|
|
5700
|
+
throw new Error("ATURI is far too long");
|
|
5701
|
+
}
|
|
5702
|
+
};
|
|
5703
|
+
|
|
5704
|
+
// src/validators/formats.ts
|
|
3303
5705
|
var import_iso_datestring_validator = __toESM(require_dist());
|
|
3304
|
-
function
|
|
3305
|
-
|
|
5706
|
+
function datetime(path, value) {
|
|
5707
|
+
try {
|
|
5708
|
+
if (!(0, import_iso_datestring_validator.isValidISODateString)(value)) {
|
|
5709
|
+
throw new Error();
|
|
5710
|
+
}
|
|
5711
|
+
} catch {
|
|
5712
|
+
return {
|
|
5713
|
+
success: false,
|
|
5714
|
+
error: new ValidationError(
|
|
5715
|
+
`${path} must be an iso8601 formatted datetime`
|
|
5716
|
+
)
|
|
5717
|
+
};
|
|
5718
|
+
}
|
|
5719
|
+
return { success: true, value };
|
|
5720
|
+
}
|
|
5721
|
+
function uri(path, value) {
|
|
5722
|
+
const isUri = value.match(/^\w+:(?:\/\/)?[^\s/][^\s]*$/) !== null;
|
|
5723
|
+
if (!isUri) {
|
|
5724
|
+
return {
|
|
5725
|
+
success: false,
|
|
5726
|
+
error: new ValidationError(`${path} must be a uri`)
|
|
5727
|
+
};
|
|
5728
|
+
}
|
|
5729
|
+
return { success: true, value };
|
|
5730
|
+
}
|
|
5731
|
+
function atUri(path, value) {
|
|
5732
|
+
try {
|
|
5733
|
+
ensureValidAtUri(value);
|
|
5734
|
+
} catch {
|
|
5735
|
+
return {
|
|
5736
|
+
success: false,
|
|
5737
|
+
error: new ValidationError(`${path} must be a valid at-uri`)
|
|
5738
|
+
};
|
|
5739
|
+
}
|
|
5740
|
+
return { success: true, value };
|
|
5741
|
+
}
|
|
5742
|
+
function did(path, value) {
|
|
5743
|
+
try {
|
|
5744
|
+
ensureValidDid(value);
|
|
5745
|
+
} catch {
|
|
5746
|
+
return {
|
|
5747
|
+
success: false,
|
|
5748
|
+
error: new ValidationError(`${path} must be a valid did`)
|
|
5749
|
+
};
|
|
5750
|
+
}
|
|
5751
|
+
return { success: true, value };
|
|
5752
|
+
}
|
|
5753
|
+
function handle(path, value) {
|
|
5754
|
+
try {
|
|
5755
|
+
ensureValidHandle(value);
|
|
5756
|
+
} catch {
|
|
5757
|
+
return {
|
|
5758
|
+
success: false,
|
|
5759
|
+
error: new ValidationError(`${path} must be a valid handle`)
|
|
5760
|
+
};
|
|
5761
|
+
}
|
|
5762
|
+
return { success: true, value };
|
|
5763
|
+
}
|
|
5764
|
+
function atIdentifier(path, value) {
|
|
5765
|
+
const isDid = did(path, value);
|
|
5766
|
+
if (!isDid.success) {
|
|
5767
|
+
const isHandle = handle(path, value);
|
|
5768
|
+
if (!isHandle.success) {
|
|
5769
|
+
return {
|
|
5770
|
+
success: false,
|
|
5771
|
+
error: new ValidationError(`${path} must be a valid did or a handle`)
|
|
5772
|
+
};
|
|
5773
|
+
}
|
|
5774
|
+
}
|
|
5775
|
+
return { success: true, value };
|
|
5776
|
+
}
|
|
5777
|
+
function nsid(path, value) {
|
|
5778
|
+
try {
|
|
5779
|
+
ensureValidNsid(value);
|
|
5780
|
+
} catch {
|
|
5781
|
+
return {
|
|
5782
|
+
success: false,
|
|
5783
|
+
error: new ValidationError(`${path} must be a valid nsid`)
|
|
5784
|
+
};
|
|
5785
|
+
}
|
|
5786
|
+
return { success: true, value };
|
|
5787
|
+
}
|
|
5788
|
+
function cid(path, value) {
|
|
5789
|
+
try {
|
|
5790
|
+
CID.parse(value);
|
|
5791
|
+
} catch {
|
|
5792
|
+
return {
|
|
5793
|
+
success: false,
|
|
5794
|
+
error: new ValidationError(`${path} must be a cid string`)
|
|
5795
|
+
};
|
|
5796
|
+
}
|
|
5797
|
+
return { success: true, value };
|
|
5798
|
+
}
|
|
5799
|
+
|
|
5800
|
+
// src/validators/primitives.ts
|
|
5801
|
+
function validate(lexicons, path, def2, value) {
|
|
5802
|
+
switch (def2.type) {
|
|
3306
5803
|
case "boolean":
|
|
3307
|
-
return boolean(lexicons, path,
|
|
3308
|
-
case "
|
|
3309
|
-
return
|
|
5804
|
+
return boolean(lexicons, path, def2, value);
|
|
5805
|
+
case "float":
|
|
5806
|
+
return float(lexicons, path, def2, value);
|
|
3310
5807
|
case "integer":
|
|
3311
|
-
return integer(lexicons, path,
|
|
5808
|
+
return integer(lexicons, path, def2, value);
|
|
3312
5809
|
case "string":
|
|
3313
|
-
return
|
|
3314
|
-
case "
|
|
3315
|
-
return
|
|
5810
|
+
return string2(lexicons, path, def2, value);
|
|
5811
|
+
case "bytes":
|
|
5812
|
+
return bytes(lexicons, path, def2, value);
|
|
5813
|
+
case "cid-link":
|
|
5814
|
+
return cidLink(lexicons, path, def2, value);
|
|
3316
5815
|
case "unknown":
|
|
3317
|
-
return unknown(lexicons, path,
|
|
5816
|
+
return unknown(lexicons, path, def2, value);
|
|
3318
5817
|
default:
|
|
3319
5818
|
return {
|
|
3320
5819
|
success: false,
|
|
3321
|
-
error: new ValidationError(`Unexpected lexicon type: ${
|
|
5820
|
+
error: new ValidationError(`Unexpected lexicon type: ${def2.type}`)
|
|
3322
5821
|
};
|
|
3323
5822
|
}
|
|
3324
5823
|
}
|
|
3325
|
-
function boolean(lexicons, path,
|
|
3326
|
-
|
|
5824
|
+
function boolean(lexicons, path, def2, value) {
|
|
5825
|
+
def2 = def2;
|
|
3327
5826
|
const type = typeof value;
|
|
3328
|
-
if (type
|
|
3329
|
-
if (typeof
|
|
3330
|
-
return { success: true };
|
|
5827
|
+
if (type === "undefined") {
|
|
5828
|
+
if (typeof def2.default === "boolean") {
|
|
5829
|
+
return { success: true, value: def2.default };
|
|
3331
5830
|
}
|
|
3332
5831
|
return {
|
|
3333
5832
|
success: false,
|
|
@@ -3339,22 +5838,22 @@ function boolean(lexicons, path, def, value) {
|
|
|
3339
5838
|
error: new ValidationError(`${path} must be a boolean`)
|
|
3340
5839
|
};
|
|
3341
5840
|
}
|
|
3342
|
-
if (typeof
|
|
3343
|
-
if (value !==
|
|
5841
|
+
if (typeof def2.const === "boolean") {
|
|
5842
|
+
if (value !== def2.const) {
|
|
3344
5843
|
return {
|
|
3345
5844
|
success: false,
|
|
3346
|
-
error: new ValidationError(`${path} must be ${
|
|
5845
|
+
error: new ValidationError(`${path} must be ${def2.const}`)
|
|
3347
5846
|
};
|
|
3348
5847
|
}
|
|
3349
5848
|
}
|
|
3350
|
-
return { success: true };
|
|
5849
|
+
return { success: true, value };
|
|
3351
5850
|
}
|
|
3352
|
-
function
|
|
3353
|
-
|
|
5851
|
+
function float(lexicons, path, def2, value) {
|
|
5852
|
+
def2 = def2;
|
|
3354
5853
|
const type = typeof value;
|
|
3355
|
-
if (type
|
|
3356
|
-
if (typeof
|
|
3357
|
-
return { success: true };
|
|
5854
|
+
if (type === "undefined") {
|
|
5855
|
+
if (typeof def2.default === "number") {
|
|
5856
|
+
return { success: true, value: def2.default };
|
|
3358
5857
|
}
|
|
3359
5858
|
return {
|
|
3360
5859
|
success: false,
|
|
@@ -3366,51 +5865,53 @@ function number(lexicons, path, def, value) {
|
|
|
3366
5865
|
error: new ValidationError(`${path} must be a number`)
|
|
3367
5866
|
};
|
|
3368
5867
|
}
|
|
3369
|
-
if (typeof
|
|
3370
|
-
if (value !==
|
|
5868
|
+
if (typeof def2.const === "number") {
|
|
5869
|
+
if (value !== def2.const) {
|
|
3371
5870
|
return {
|
|
3372
5871
|
success: false,
|
|
3373
|
-
error: new ValidationError(`${path} must be ${
|
|
5872
|
+
error: new ValidationError(`${path} must be ${def2.const}`)
|
|
3374
5873
|
};
|
|
3375
5874
|
}
|
|
3376
5875
|
}
|
|
3377
|
-
if (Array.isArray(
|
|
3378
|
-
if (!
|
|
5876
|
+
if (Array.isArray(def2.enum)) {
|
|
5877
|
+
if (!def2.enum.includes(value)) {
|
|
3379
5878
|
return {
|
|
3380
5879
|
success: false,
|
|
3381
5880
|
error: new ValidationError(
|
|
3382
|
-
`${path} must be one of (${
|
|
5881
|
+
`${path} must be one of (${def2.enum.join("|")})`
|
|
3383
5882
|
)
|
|
3384
5883
|
};
|
|
3385
5884
|
}
|
|
3386
5885
|
}
|
|
3387
|
-
if (typeof
|
|
3388
|
-
if (value >
|
|
5886
|
+
if (typeof def2.maximum === "number") {
|
|
5887
|
+
if (value > def2.maximum) {
|
|
3389
5888
|
return {
|
|
3390
5889
|
success: false,
|
|
3391
5890
|
error: new ValidationError(
|
|
3392
|
-
`${path} can not be greater than ${
|
|
5891
|
+
`${path} can not be greater than ${def2.maximum}`
|
|
3393
5892
|
)
|
|
3394
5893
|
};
|
|
3395
5894
|
}
|
|
3396
5895
|
}
|
|
3397
|
-
if (typeof
|
|
3398
|
-
if (value <
|
|
5896
|
+
if (typeof def2.minimum === "number") {
|
|
5897
|
+
if (value < def2.minimum) {
|
|
3399
5898
|
return {
|
|
3400
5899
|
success: false,
|
|
3401
5900
|
error: new ValidationError(
|
|
3402
|
-
`${path} can not be less than ${
|
|
5901
|
+
`${path} can not be less than ${def2.minimum}`
|
|
3403
5902
|
)
|
|
3404
5903
|
};
|
|
3405
5904
|
}
|
|
3406
5905
|
}
|
|
3407
|
-
return { success: true };
|
|
5906
|
+
return { success: true, value };
|
|
3408
5907
|
}
|
|
3409
|
-
function integer(lexicons, path,
|
|
3410
|
-
|
|
3411
|
-
const numRes =
|
|
5908
|
+
function integer(lexicons, path, def2, value) {
|
|
5909
|
+
def2 = def2;
|
|
5910
|
+
const numRes = float(lexicons, path, def2, value);
|
|
3412
5911
|
if (!numRes.success) {
|
|
3413
5912
|
return numRes;
|
|
5913
|
+
} else {
|
|
5914
|
+
value = numRes.value;
|
|
3414
5915
|
}
|
|
3415
5916
|
if (!Number.isInteger(value)) {
|
|
3416
5917
|
return {
|
|
@@ -3418,192 +5919,272 @@ function integer(lexicons, path, def, value) {
|
|
|
3418
5919
|
error: new ValidationError(`${path} must be an integer`)
|
|
3419
5920
|
};
|
|
3420
5921
|
}
|
|
3421
|
-
return { success: true };
|
|
5922
|
+
return { success: true, value };
|
|
3422
5923
|
}
|
|
3423
|
-
function
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
return { success: true };
|
|
5924
|
+
function string2(lexicons, path, def2, value) {
|
|
5925
|
+
def2 = def2;
|
|
5926
|
+
if (typeof value === "undefined") {
|
|
5927
|
+
if (typeof def2.default === "string") {
|
|
5928
|
+
return { success: true, value: def2.default };
|
|
3429
5929
|
}
|
|
3430
5930
|
return {
|
|
3431
5931
|
success: false,
|
|
3432
5932
|
error: new ValidationError(`${path} must be a string`)
|
|
3433
5933
|
};
|
|
3434
|
-
} else if (
|
|
5934
|
+
} else if (typeof value !== "string") {
|
|
3435
5935
|
return {
|
|
3436
5936
|
success: false,
|
|
3437
5937
|
error: new ValidationError(`${path} must be a string`)
|
|
3438
5938
|
};
|
|
3439
5939
|
}
|
|
3440
|
-
if (typeof
|
|
3441
|
-
if (value !==
|
|
5940
|
+
if (typeof def2.const === "string") {
|
|
5941
|
+
if (value !== def2.const) {
|
|
5942
|
+
return {
|
|
5943
|
+
success: false,
|
|
5944
|
+
error: new ValidationError(`${path} must be ${def2.const}`)
|
|
5945
|
+
};
|
|
5946
|
+
}
|
|
5947
|
+
}
|
|
5948
|
+
if (Array.isArray(def2.enum)) {
|
|
5949
|
+
if (!def2.enum.includes(value)) {
|
|
3442
5950
|
return {
|
|
3443
5951
|
success: false,
|
|
3444
|
-
error: new ValidationError(
|
|
5952
|
+
error: new ValidationError(
|
|
5953
|
+
`${path} must be one of (${def2.enum.join("|")})`
|
|
5954
|
+
)
|
|
3445
5955
|
};
|
|
3446
5956
|
}
|
|
3447
5957
|
}
|
|
3448
|
-
if (
|
|
3449
|
-
if (
|
|
5958
|
+
if (typeof def2.maxLength === "number") {
|
|
5959
|
+
if (utf8Len(value) > def2.maxLength) {
|
|
3450
5960
|
return {
|
|
3451
5961
|
success: false,
|
|
3452
5962
|
error: new ValidationError(
|
|
3453
|
-
`${path} must be
|
|
5963
|
+
`${path} must not be longer than ${def2.maxLength} characters`
|
|
3454
5964
|
)
|
|
3455
5965
|
};
|
|
3456
5966
|
}
|
|
3457
5967
|
}
|
|
3458
|
-
if (typeof
|
|
3459
|
-
if (value
|
|
5968
|
+
if (typeof def2.minLength === "number") {
|
|
5969
|
+
if (utf8Len(value) < def2.minLength) {
|
|
3460
5970
|
return {
|
|
3461
5971
|
success: false,
|
|
3462
5972
|
error: new ValidationError(
|
|
3463
|
-
`${path} must not be
|
|
5973
|
+
`${path} must not be shorter than ${def2.minLength} characters`
|
|
3464
5974
|
)
|
|
3465
5975
|
};
|
|
3466
5976
|
}
|
|
3467
5977
|
}
|
|
3468
|
-
if (typeof
|
|
3469
|
-
if (value
|
|
5978
|
+
if (typeof def2.maxGraphemes === "number") {
|
|
5979
|
+
if (graphemeLen(value) > def2.maxGraphemes) {
|
|
3470
5980
|
return {
|
|
3471
5981
|
success: false,
|
|
3472
5982
|
error: new ValidationError(
|
|
3473
|
-
`${path} must not be
|
|
5983
|
+
`${path} must not be longer than ${def2.maxGraphemes} graphemes`
|
|
3474
5984
|
)
|
|
3475
5985
|
};
|
|
3476
5986
|
}
|
|
3477
5987
|
}
|
|
3478
|
-
|
|
5988
|
+
if (typeof def2.minGraphemes === "number") {
|
|
5989
|
+
if (graphemeLen(value) < def2.minGraphemes) {
|
|
5990
|
+
return {
|
|
5991
|
+
success: false,
|
|
5992
|
+
error: new ValidationError(
|
|
5993
|
+
`${path} must not be shorter than ${def2.minGraphemes} graphemes`
|
|
5994
|
+
)
|
|
5995
|
+
};
|
|
5996
|
+
}
|
|
5997
|
+
}
|
|
5998
|
+
if (typeof def2.format === "string") {
|
|
5999
|
+
switch (def2.format) {
|
|
6000
|
+
case "datetime":
|
|
6001
|
+
return datetime(path, value);
|
|
6002
|
+
case "uri":
|
|
6003
|
+
return uri(path, value);
|
|
6004
|
+
case "at-uri":
|
|
6005
|
+
return atUri(path, value);
|
|
6006
|
+
case "did":
|
|
6007
|
+
return did(path, value);
|
|
6008
|
+
case "handle":
|
|
6009
|
+
return handle(path, value);
|
|
6010
|
+
case "at-identifier":
|
|
6011
|
+
return atIdentifier(path, value);
|
|
6012
|
+
case "nsid":
|
|
6013
|
+
return nsid(path, value);
|
|
6014
|
+
case "cid":
|
|
6015
|
+
return cid(path, value);
|
|
6016
|
+
}
|
|
6017
|
+
}
|
|
6018
|
+
return { success: true, value };
|
|
3479
6019
|
}
|
|
3480
|
-
function
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
if (type !== "string") {
|
|
6020
|
+
function bytes(lexicons, path, def2, value) {
|
|
6021
|
+
def2 = def2;
|
|
6022
|
+
if (!value || !(value instanceof Uint8Array)) {
|
|
3484
6023
|
return {
|
|
3485
6024
|
success: false,
|
|
3486
|
-
error: new ValidationError(`${path} must be a
|
|
6025
|
+
error: new ValidationError(`${path} must be a byte array`)
|
|
3487
6026
|
};
|
|
3488
6027
|
}
|
|
3489
|
-
{
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
throw new ValidationError(`${path} must be an iso8601 formatted datetime`);
|
|
6028
|
+
if (typeof def2.maxLength === "number") {
|
|
6029
|
+
if (value.byteLength > def2.maxLength) {
|
|
6030
|
+
return {
|
|
6031
|
+
success: false,
|
|
6032
|
+
error: new ValidationError(
|
|
6033
|
+
`${path} must not be larger than ${def2.maxLength} bytes`
|
|
6034
|
+
)
|
|
6035
|
+
};
|
|
3498
6036
|
}
|
|
3499
6037
|
}
|
|
3500
|
-
|
|
6038
|
+
if (typeof def2.minLength === "number") {
|
|
6039
|
+
if (value.byteLength < def2.minLength) {
|
|
6040
|
+
return {
|
|
6041
|
+
success: false,
|
|
6042
|
+
error: new ValidationError(
|
|
6043
|
+
`${path} must not be smaller than ${def2.minLength} bytes`
|
|
6044
|
+
)
|
|
6045
|
+
};
|
|
6046
|
+
}
|
|
6047
|
+
}
|
|
6048
|
+
return { success: true, value };
|
|
3501
6049
|
}
|
|
3502
|
-
function
|
|
6050
|
+
function cidLink(lexicons, path, def2, value) {
|
|
6051
|
+
if (CID.asCID(value) === null) {
|
|
6052
|
+
return {
|
|
6053
|
+
success: false,
|
|
6054
|
+
error: new ValidationError(`${path} must be a CID`)
|
|
6055
|
+
};
|
|
6056
|
+
}
|
|
6057
|
+
return { success: true, value };
|
|
6058
|
+
}
|
|
6059
|
+
function unknown(lexicons, path, def2, value) {
|
|
3503
6060
|
if (!value || typeof value !== "object") {
|
|
3504
6061
|
return {
|
|
3505
6062
|
success: false,
|
|
3506
6063
|
error: new ValidationError(`${path} must be an object`)
|
|
3507
6064
|
};
|
|
3508
6065
|
}
|
|
3509
|
-
return { success: true };
|
|
6066
|
+
return { success: true, value };
|
|
3510
6067
|
}
|
|
3511
6068
|
|
|
3512
|
-
// src/
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
6069
|
+
// src/blob-refs.ts
|
|
6070
|
+
var typedJsonBlobRef = mod.object({
|
|
6071
|
+
$type: mod.literal("blob"),
|
|
6072
|
+
ref: schema.cid,
|
|
6073
|
+
mimeType: mod.string(),
|
|
6074
|
+
size: mod.number()
|
|
6075
|
+
}).strict();
|
|
6076
|
+
var untypedJsonBlobRef = mod.object({
|
|
6077
|
+
cid: mod.string(),
|
|
6078
|
+
mimeType: mod.string()
|
|
6079
|
+
}).strict();
|
|
6080
|
+
var jsonBlobRef = mod.union([typedJsonBlobRef, untypedJsonBlobRef]);
|
|
6081
|
+
var BlobRef = class {
|
|
6082
|
+
constructor(ref, mimeType, size, original) {
|
|
6083
|
+
this.ref = ref;
|
|
6084
|
+
this.mimeType = mimeType;
|
|
6085
|
+
this.size = size;
|
|
6086
|
+
this.original = original ?? {
|
|
6087
|
+
$type: "blob",
|
|
6088
|
+
ref,
|
|
6089
|
+
mimeType,
|
|
6090
|
+
size
|
|
3518
6091
|
};
|
|
3519
6092
|
}
|
|
3520
|
-
|
|
6093
|
+
static asBlobRef(obj) {
|
|
6094
|
+
if (check_exports.is(obj, jsonBlobRef)) {
|
|
6095
|
+
return BlobRef.fromJsonRef(obj);
|
|
6096
|
+
}
|
|
6097
|
+
return null;
|
|
6098
|
+
}
|
|
6099
|
+
static fromJsonRef(json) {
|
|
6100
|
+
if (check_exports.is(json, typedJsonBlobRef)) {
|
|
6101
|
+
return new BlobRef(json.ref, json.mimeType, json.size);
|
|
6102
|
+
} else {
|
|
6103
|
+
return new BlobRef(CID.parse(json.cid), json.mimeType, -1, json);
|
|
6104
|
+
}
|
|
6105
|
+
}
|
|
6106
|
+
ipld() {
|
|
3521
6107
|
return {
|
|
3522
|
-
|
|
3523
|
-
|
|
6108
|
+
$type: "blob",
|
|
6109
|
+
ref: this.ref,
|
|
6110
|
+
mimeType: this.mimeType,
|
|
6111
|
+
size: this.size
|
|
3524
6112
|
};
|
|
3525
6113
|
}
|
|
3526
|
-
|
|
6114
|
+
toJSON() {
|
|
6115
|
+
return ipldToJson(this.ipld());
|
|
6116
|
+
}
|
|
6117
|
+
};
|
|
6118
|
+
|
|
6119
|
+
// src/validators/blob.ts
|
|
6120
|
+
function blob(lexicons, path, def2, value) {
|
|
6121
|
+
if (!value || !(value instanceof BlobRef)) {
|
|
3527
6122
|
return {
|
|
3528
6123
|
success: false,
|
|
3529
|
-
error: new ValidationError(`${path}
|
|
6124
|
+
error: new ValidationError(`${path} should be a blob ref`)
|
|
3530
6125
|
};
|
|
3531
6126
|
}
|
|
3532
|
-
return { success: true };
|
|
3533
|
-
}
|
|
3534
|
-
function image(lexicons, path, def, value) {
|
|
3535
|
-
return blob(lexicons, path, def, value);
|
|
3536
|
-
}
|
|
3537
|
-
function video(lexicons, path, def, value) {
|
|
3538
|
-
return blob(lexicons, path, def, value);
|
|
3539
|
-
}
|
|
3540
|
-
function audio(lexicons, path, def, value) {
|
|
3541
|
-
return blob(lexicons, path, def, value);
|
|
6127
|
+
return { success: true, value };
|
|
3542
6128
|
}
|
|
3543
6129
|
|
|
3544
6130
|
// src/validators/complex.ts
|
|
3545
|
-
function validate2(lexicons, path,
|
|
3546
|
-
switch (
|
|
6131
|
+
function validate2(lexicons, path, def2, value) {
|
|
6132
|
+
switch (def2.type) {
|
|
3547
6133
|
case "boolean":
|
|
3548
|
-
return boolean(lexicons, path,
|
|
3549
|
-
case "
|
|
3550
|
-
return
|
|
6134
|
+
return boolean(lexicons, path, def2, value);
|
|
6135
|
+
case "float":
|
|
6136
|
+
return float(lexicons, path, def2, value);
|
|
3551
6137
|
case "integer":
|
|
3552
|
-
return integer(lexicons, path,
|
|
6138
|
+
return integer(lexicons, path, def2, value);
|
|
3553
6139
|
case "string":
|
|
3554
|
-
return
|
|
3555
|
-
case "
|
|
3556
|
-
return
|
|
6140
|
+
return string2(lexicons, path, def2, value);
|
|
6141
|
+
case "bytes":
|
|
6142
|
+
return bytes(lexicons, path, def2, value);
|
|
6143
|
+
case "cid-link":
|
|
6144
|
+
return cidLink(lexicons, path, def2, value);
|
|
3557
6145
|
case "unknown":
|
|
3558
|
-
return unknown(lexicons, path,
|
|
6146
|
+
return unknown(lexicons, path, def2, value);
|
|
3559
6147
|
case "object":
|
|
3560
|
-
return object(lexicons, path,
|
|
6148
|
+
return object(lexicons, path, def2, value);
|
|
3561
6149
|
case "array":
|
|
3562
|
-
return array(lexicons, path,
|
|
6150
|
+
return array(lexicons, path, def2, value);
|
|
3563
6151
|
case "blob":
|
|
3564
|
-
return blob(lexicons, path,
|
|
3565
|
-
case "image":
|
|
3566
|
-
return image(lexicons, path, def, value);
|
|
3567
|
-
case "video":
|
|
3568
|
-
return video(lexicons, path, def, value);
|
|
3569
|
-
case "audio":
|
|
3570
|
-
return audio(lexicons, path, def, value);
|
|
6152
|
+
return blob(lexicons, path, def2, value);
|
|
3571
6153
|
default:
|
|
3572
6154
|
return {
|
|
3573
6155
|
success: false,
|
|
3574
|
-
error: new ValidationError(`Unexpected lexicon type: ${
|
|
6156
|
+
error: new ValidationError(`Unexpected lexicon type: ${def2.type}`)
|
|
3575
6157
|
};
|
|
3576
6158
|
}
|
|
3577
6159
|
}
|
|
3578
|
-
function array(lexicons, path,
|
|
3579
|
-
def = def;
|
|
6160
|
+
function array(lexicons, path, def2, value) {
|
|
3580
6161
|
if (!Array.isArray(value)) {
|
|
3581
6162
|
return {
|
|
3582
6163
|
success: false,
|
|
3583
6164
|
error: new ValidationError(`${path} must be an array`)
|
|
3584
6165
|
};
|
|
3585
6166
|
}
|
|
3586
|
-
if (typeof
|
|
3587
|
-
if (value.length >
|
|
6167
|
+
if (typeof def2.maxLength === "number") {
|
|
6168
|
+
if (value.length > def2.maxLength) {
|
|
3588
6169
|
return {
|
|
3589
6170
|
success: false,
|
|
3590
6171
|
error: new ValidationError(
|
|
3591
|
-
`${path} must not have more than ${
|
|
6172
|
+
`${path} must not have more than ${def2.maxLength} elements`
|
|
3592
6173
|
)
|
|
3593
6174
|
};
|
|
3594
6175
|
}
|
|
3595
6176
|
}
|
|
3596
|
-
if (typeof
|
|
3597
|
-
if (value.length <
|
|
6177
|
+
if (typeof def2.minLength === "number") {
|
|
6178
|
+
if (value.length < def2.minLength) {
|
|
3598
6179
|
return {
|
|
3599
6180
|
success: false,
|
|
3600
6181
|
error: new ValidationError(
|
|
3601
|
-
`${path} must not have fewer than ${
|
|
6182
|
+
`${path} must not have fewer than ${def2.minLength} elements`
|
|
3602
6183
|
)
|
|
3603
6184
|
};
|
|
3604
6185
|
}
|
|
3605
6186
|
}
|
|
3606
|
-
const itemsDef =
|
|
6187
|
+
const itemsDef = def2.items;
|
|
3607
6188
|
for (let i = 0; i < value.length; i++) {
|
|
3608
6189
|
const itemValue = value[i];
|
|
3609
6190
|
const itemPath = `${path}/${i}`;
|
|
@@ -3612,41 +6193,46 @@ function array(lexicons, path, def, value) {
|
|
|
3612
6193
|
return res;
|
|
3613
6194
|
}
|
|
3614
6195
|
}
|
|
3615
|
-
return { success: true };
|
|
6196
|
+
return { success: true, value };
|
|
3616
6197
|
}
|
|
3617
|
-
function object(lexicons, path,
|
|
3618
|
-
|
|
6198
|
+
function object(lexicons, path, def2, value) {
|
|
6199
|
+
def2 = def2;
|
|
3619
6200
|
if (!value || typeof value !== "object") {
|
|
3620
6201
|
return {
|
|
3621
6202
|
success: false,
|
|
3622
6203
|
error: new ValidationError(`${path} must be an object`)
|
|
3623
6204
|
};
|
|
3624
6205
|
}
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
6206
|
+
const requiredProps = new Set(def2.required);
|
|
6207
|
+
const nullableProps = new Set(def2.nullable);
|
|
6208
|
+
let resultValue = value;
|
|
6209
|
+
if (typeof def2.properties === "object") {
|
|
6210
|
+
for (const key in def2.properties) {
|
|
6211
|
+
if (value[key] === null && nullableProps.has(key)) {
|
|
6212
|
+
continue;
|
|
6213
|
+
}
|
|
6214
|
+
const propDef = def2.properties[key];
|
|
6215
|
+
const propPath = `${path}/${key}`;
|
|
6216
|
+
const validated = validateOneOf(lexicons, propPath, propDef, value[key]);
|
|
6217
|
+
const propValue = validated.success ? validated.value : value[key];
|
|
6218
|
+
const propIsUndefined = typeof propValue === "undefined";
|
|
6219
|
+
if (propIsUndefined && requiredProps.has(key)) {
|
|
3628
6220
|
return {
|
|
3629
6221
|
success: false,
|
|
3630
6222
|
error: new ValidationError(`${path} must have the property "${key}"`)
|
|
3631
6223
|
};
|
|
6224
|
+
} else if (!propIsUndefined && !validated.success) {
|
|
6225
|
+
return validated;
|
|
3632
6226
|
}
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
if (typeof propValue === "undefined") {
|
|
3639
|
-
continue;
|
|
3640
|
-
}
|
|
3641
|
-
const propDef = def.properties[key];
|
|
3642
|
-
const propPath = `${path}/${key}`;
|
|
3643
|
-
const res = validateOneOf(lexicons, propPath, propDef, propValue);
|
|
3644
|
-
if (!res.success) {
|
|
3645
|
-
return res;
|
|
6227
|
+
if (propValue !== value[key]) {
|
|
6228
|
+
if (resultValue === value) {
|
|
6229
|
+
resultValue = { ...value };
|
|
6230
|
+
}
|
|
6231
|
+
resultValue[key] = propValue;
|
|
3646
6232
|
}
|
|
3647
6233
|
}
|
|
3648
6234
|
}
|
|
3649
|
-
return { success: true };
|
|
6235
|
+
return { success: true, value: resultValue };
|
|
3650
6236
|
}
|
|
3651
6237
|
|
|
3652
6238
|
// src/util.ts
|
|
@@ -3662,10 +6248,10 @@ function toLexUri(str, baseUri) {
|
|
|
3662
6248
|
}
|
|
3663
6249
|
return `lex:${str}`;
|
|
3664
6250
|
}
|
|
3665
|
-
function validateOneOf(lexicons, path,
|
|
6251
|
+
function validateOneOf(lexicons, path, def2, value, mustBeObj = false) {
|
|
3666
6252
|
let error;
|
|
3667
6253
|
let concreteDefs;
|
|
3668
|
-
if (
|
|
6254
|
+
if (def2.type === "union") {
|
|
3669
6255
|
if (!isDiscriminatedObject(value)) {
|
|
3670
6256
|
return {
|
|
3671
6257
|
success: false,
|
|
@@ -3674,16 +6260,16 @@ function validateOneOf(lexicons, path, def, value, mustBeObj = false) {
|
|
|
3674
6260
|
)
|
|
3675
6261
|
};
|
|
3676
6262
|
}
|
|
3677
|
-
if (!
|
|
3678
|
-
if (
|
|
6263
|
+
if (!def2.refs.includes(toLexUri(value.$type))) {
|
|
6264
|
+
if (def2.closed) {
|
|
3679
6265
|
return {
|
|
3680
6266
|
success: false,
|
|
3681
6267
|
error: new ValidationError(
|
|
3682
|
-
`${path} $type must be one of ${
|
|
6268
|
+
`${path} $type must be one of ${def2.refs.join(", ")}`
|
|
3683
6269
|
)
|
|
3684
6270
|
};
|
|
3685
6271
|
}
|
|
3686
|
-
return { success: true };
|
|
6272
|
+
return { success: true, value };
|
|
3687
6273
|
} else {
|
|
3688
6274
|
concreteDefs = toConcreteTypes(lexicons, {
|
|
3689
6275
|
type: "ref",
|
|
@@ -3691,7 +6277,7 @@ function validateOneOf(lexicons, path, def, value, mustBeObj = false) {
|
|
|
3691
6277
|
});
|
|
3692
6278
|
}
|
|
3693
6279
|
} else {
|
|
3694
|
-
concreteDefs = toConcreteTypes(lexicons,
|
|
6280
|
+
concreteDefs = toConcreteTypes(lexicons, def2);
|
|
3695
6281
|
}
|
|
3696
6282
|
for (const concreteDef of concreteDefs) {
|
|
3697
6283
|
const result = mustBeObj ? object(lexicons, path, concreteDef, value) : validate2(lexicons, path, concreteDef, value);
|
|
@@ -3710,77 +6296,86 @@ function validateOneOf(lexicons, path, def, value, mustBeObj = false) {
|
|
|
3710
6296
|
}
|
|
3711
6297
|
return { success: false, error };
|
|
3712
6298
|
}
|
|
3713
|
-
function assertValidOneOf(lexicons, path,
|
|
3714
|
-
const res = validateOneOf(lexicons, path,
|
|
3715
|
-
if (!res.success)
|
|
6299
|
+
function assertValidOneOf(lexicons, path, def2, value, mustBeObj = false) {
|
|
6300
|
+
const res = validateOneOf(lexicons, path, def2, value, mustBeObj);
|
|
6301
|
+
if (!res.success)
|
|
3716
6302
|
throw res.error;
|
|
3717
|
-
|
|
6303
|
+
return res.value;
|
|
3718
6304
|
}
|
|
3719
|
-
function toConcreteTypes(lexicons,
|
|
3720
|
-
if (
|
|
3721
|
-
return [lexicons.getDefOrThrow(
|
|
3722
|
-
} else if (
|
|
3723
|
-
return
|
|
6305
|
+
function toConcreteTypes(lexicons, def2) {
|
|
6306
|
+
if (def2.type === "ref") {
|
|
6307
|
+
return [lexicons.getDefOrThrow(def2.ref)];
|
|
6308
|
+
} else if (def2.type === "union") {
|
|
6309
|
+
return def2.refs.map((ref) => lexicons.getDefOrThrow(ref)).flat();
|
|
3724
6310
|
} else {
|
|
3725
|
-
return [
|
|
6311
|
+
return [def2];
|
|
3726
6312
|
}
|
|
3727
6313
|
}
|
|
3728
6314
|
|
|
3729
6315
|
// src/validators/xrpc.ts
|
|
3730
|
-
function params(lexicons, path,
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
6316
|
+
function params(lexicons, path, def2, val) {
|
|
6317
|
+
const value = val && typeof val === "object" ? val : {};
|
|
6318
|
+
const requiredProps = new Set(def2.required ?? []);
|
|
6319
|
+
let resultValue = value;
|
|
6320
|
+
if (typeof def2.properties === "object") {
|
|
6321
|
+
for (const key in def2.properties) {
|
|
6322
|
+
const propDef = def2.properties[key];
|
|
6323
|
+
const validated = propDef.type === "array" ? array(lexicons, key, propDef, value[key]) : validate(lexicons, key, propDef, value[key]);
|
|
6324
|
+
const propValue = validated.success ? validated.value : value[key];
|
|
6325
|
+
const propIsUndefined = typeof propValue === "undefined";
|
|
6326
|
+
if (propIsUndefined && requiredProps.has(key)) {
|
|
3738
6327
|
return {
|
|
3739
6328
|
success: false,
|
|
3740
6329
|
error: new ValidationError(`${path} must have the property "${key}"`)
|
|
3741
6330
|
};
|
|
6331
|
+
} else if (!propIsUndefined && !validated.success) {
|
|
6332
|
+
return validated;
|
|
6333
|
+
}
|
|
6334
|
+
if (propValue !== value[key]) {
|
|
6335
|
+
if (resultValue === value) {
|
|
6336
|
+
resultValue = { ...value };
|
|
6337
|
+
}
|
|
6338
|
+
resultValue[key] = propValue;
|
|
3742
6339
|
}
|
|
3743
6340
|
}
|
|
3744
6341
|
}
|
|
3745
|
-
|
|
3746
|
-
if (typeof value[key] === "undefined") {
|
|
3747
|
-
continue;
|
|
3748
|
-
}
|
|
3749
|
-
const paramDef = def.properties[key];
|
|
3750
|
-
const res = validate(
|
|
3751
|
-
lexicons,
|
|
3752
|
-
key,
|
|
3753
|
-
paramDef,
|
|
3754
|
-
value[key]
|
|
3755
|
-
);
|
|
3756
|
-
if (!res.success) {
|
|
3757
|
-
return res;
|
|
3758
|
-
}
|
|
3759
|
-
}
|
|
3760
|
-
return { success: true };
|
|
6342
|
+
return { success: true, value: resultValue };
|
|
3761
6343
|
}
|
|
3762
6344
|
|
|
3763
6345
|
// src/validation.ts
|
|
3764
|
-
function assertValidRecord(lexicons,
|
|
3765
|
-
const res = object(lexicons, "Record",
|
|
6346
|
+
function assertValidRecord(lexicons, def2, value) {
|
|
6347
|
+
const res = object(lexicons, "Record", def2.record, value);
|
|
3766
6348
|
if (!res.success)
|
|
3767
6349
|
throw res.error;
|
|
6350
|
+
return res.value;
|
|
3768
6351
|
}
|
|
3769
|
-
function assertValidXrpcParams(lexicons,
|
|
3770
|
-
if (
|
|
3771
|
-
const res = params(lexicons, "Params",
|
|
6352
|
+
function assertValidXrpcParams(lexicons, def2, value) {
|
|
6353
|
+
if (def2.parameters) {
|
|
6354
|
+
const res = params(lexicons, "Params", def2.parameters, value);
|
|
3772
6355
|
if (!res.success)
|
|
3773
6356
|
throw res.error;
|
|
6357
|
+
return res.value;
|
|
6358
|
+
}
|
|
6359
|
+
}
|
|
6360
|
+
function assertValidXrpcInput(lexicons, def2, value) {
|
|
6361
|
+
if (def2.input?.schema) {
|
|
6362
|
+
return assertValidOneOf(lexicons, "Input", def2.input.schema, value, true);
|
|
3774
6363
|
}
|
|
3775
6364
|
}
|
|
3776
|
-
function
|
|
3777
|
-
if (
|
|
3778
|
-
assertValidOneOf(lexicons, "
|
|
6365
|
+
function assertValidXrpcOutput(lexicons, def2, value) {
|
|
6366
|
+
if (def2.output?.schema) {
|
|
6367
|
+
return assertValidOneOf(lexicons, "Output", def2.output.schema, value, true);
|
|
3779
6368
|
}
|
|
3780
6369
|
}
|
|
3781
|
-
function
|
|
3782
|
-
if (
|
|
3783
|
-
assertValidOneOf(
|
|
6370
|
+
function assertValidXrpcMessage(lexicons, def2, value) {
|
|
6371
|
+
if (def2.message?.schema) {
|
|
6372
|
+
return assertValidOneOf(
|
|
6373
|
+
lexicons,
|
|
6374
|
+
"Message",
|
|
6375
|
+
def2.message.schema,
|
|
6376
|
+
value,
|
|
6377
|
+
true
|
|
6378
|
+
);
|
|
3784
6379
|
}
|
|
3785
6380
|
}
|
|
3786
6381
|
|
|
@@ -3810,64 +6405,64 @@ var Lexicons = class {
|
|
|
3810
6405
|
}
|
|
3811
6406
|
}
|
|
3812
6407
|
const validatedDoc = doc;
|
|
3813
|
-
const
|
|
3814
|
-
if (this.docs.has(
|
|
3815
|
-
throw new Error(`${
|
|
6408
|
+
const uri2 = toLexUri(validatedDoc.id);
|
|
6409
|
+
if (this.docs.has(uri2)) {
|
|
6410
|
+
throw new Error(`${uri2} has already been registered`);
|
|
3816
6411
|
}
|
|
3817
|
-
resolveRefUris(validatedDoc,
|
|
3818
|
-
this.docs.set(
|
|
3819
|
-
for (const [defUri,
|
|
3820
|
-
this.defs.set(defUri,
|
|
6412
|
+
resolveRefUris(validatedDoc, uri2);
|
|
6413
|
+
this.docs.set(uri2, validatedDoc);
|
|
6414
|
+
for (const [defUri, def2] of iterDefs(validatedDoc)) {
|
|
6415
|
+
this.defs.set(defUri, def2);
|
|
3821
6416
|
}
|
|
3822
6417
|
}
|
|
3823
|
-
remove(
|
|
3824
|
-
|
|
3825
|
-
const doc = this.docs.get(
|
|
6418
|
+
remove(uri2) {
|
|
6419
|
+
uri2 = toLexUri(uri2);
|
|
6420
|
+
const doc = this.docs.get(uri2);
|
|
3826
6421
|
if (!doc) {
|
|
3827
|
-
throw new Error(`Unable to remove "${
|
|
6422
|
+
throw new Error(`Unable to remove "${uri2}": does not exist`);
|
|
3828
6423
|
}
|
|
3829
6424
|
for (const [defUri, _def] of iterDefs(doc)) {
|
|
3830
6425
|
this.defs.delete(defUri);
|
|
3831
6426
|
}
|
|
3832
|
-
this.docs.delete(
|
|
6427
|
+
this.docs.delete(uri2);
|
|
3833
6428
|
}
|
|
3834
|
-
get(
|
|
3835
|
-
|
|
3836
|
-
return this.docs.get(
|
|
6429
|
+
get(uri2) {
|
|
6430
|
+
uri2 = toLexUri(uri2);
|
|
6431
|
+
return this.docs.get(uri2);
|
|
3837
6432
|
}
|
|
3838
|
-
getDef(
|
|
3839
|
-
|
|
3840
|
-
return this.defs.get(
|
|
6433
|
+
getDef(uri2) {
|
|
6434
|
+
uri2 = toLexUri(uri2);
|
|
6435
|
+
return this.defs.get(uri2);
|
|
3841
6436
|
}
|
|
3842
|
-
getDefOrThrow(
|
|
3843
|
-
const
|
|
3844
|
-
if (!
|
|
3845
|
-
throw new LexiconDefNotFoundError(`Lexicon not found: ${
|
|
6437
|
+
getDefOrThrow(uri2, types) {
|
|
6438
|
+
const def2 = this.getDef(uri2);
|
|
6439
|
+
if (!def2) {
|
|
6440
|
+
throw new LexiconDefNotFoundError(`Lexicon not found: ${uri2}`);
|
|
3846
6441
|
}
|
|
3847
|
-
if (types && !types.includes(
|
|
6442
|
+
if (types && !types.includes(def2.type)) {
|
|
3848
6443
|
throw new InvalidLexiconError(
|
|
3849
|
-
`Not a ${types.join(" or ")} lexicon: ${
|
|
6444
|
+
`Not a ${types.join(" or ")} lexicon: ${uri2}`
|
|
3850
6445
|
);
|
|
3851
6446
|
}
|
|
3852
|
-
return
|
|
6447
|
+
return def2;
|
|
3853
6448
|
}
|
|
3854
6449
|
validate(lexUri, value) {
|
|
3855
6450
|
lexUri = toLexUri(lexUri);
|
|
3856
|
-
const
|
|
6451
|
+
const def2 = this.getDefOrThrow(lexUri, ["record", "object"]);
|
|
3857
6452
|
if (!isObj(value)) {
|
|
3858
6453
|
throw new ValidationError(`Value must be an object`);
|
|
3859
6454
|
}
|
|
3860
|
-
if (
|
|
3861
|
-
return object(this, "Record",
|
|
3862
|
-
} else if (
|
|
3863
|
-
return object(this, "Object",
|
|
6455
|
+
if (def2.type === "record") {
|
|
6456
|
+
return object(this, "Record", def2.record, value);
|
|
6457
|
+
} else if (def2.type === "object") {
|
|
6458
|
+
return object(this, "Object", def2, value);
|
|
3864
6459
|
} else {
|
|
3865
6460
|
throw new InvalidLexiconError("Definition must be a record or object");
|
|
3866
6461
|
}
|
|
3867
6462
|
}
|
|
3868
6463
|
assertValidRecord(lexUri, value) {
|
|
3869
6464
|
lexUri = toLexUri(lexUri);
|
|
3870
|
-
const
|
|
6465
|
+
const def2 = this.getDefOrThrow(lexUri, ["record"]);
|
|
3871
6466
|
if (!isObj(value)) {
|
|
3872
6467
|
throw new ValidationError(`Record must be an object`);
|
|
3873
6468
|
}
|
|
@@ -3880,22 +6475,43 @@ var Lexicons = class {
|
|
|
3880
6475
|
`Invalid $type: must be ${lexUri}, got ${$type}`
|
|
3881
6476
|
);
|
|
3882
6477
|
}
|
|
3883
|
-
assertValidRecord(this,
|
|
6478
|
+
return assertValidRecord(this, def2, value);
|
|
3884
6479
|
}
|
|
3885
6480
|
assertValidXrpcParams(lexUri, value) {
|
|
3886
6481
|
lexUri = toLexUri(lexUri);
|
|
3887
|
-
const
|
|
3888
|
-
|
|
6482
|
+
const def2 = this.getDefOrThrow(lexUri, [
|
|
6483
|
+
"query",
|
|
6484
|
+
"procedure",
|
|
6485
|
+
"subscription"
|
|
6486
|
+
]);
|
|
6487
|
+
return assertValidXrpcParams(
|
|
6488
|
+
this,
|
|
6489
|
+
def2,
|
|
6490
|
+
value
|
|
6491
|
+
);
|
|
3889
6492
|
}
|
|
3890
6493
|
assertValidXrpcInput(lexUri, value) {
|
|
3891
6494
|
lexUri = toLexUri(lexUri);
|
|
3892
|
-
const
|
|
3893
|
-
assertValidXrpcInput(this,
|
|
6495
|
+
const def2 = this.getDefOrThrow(lexUri, ["procedure"]);
|
|
6496
|
+
return assertValidXrpcInput(this, def2, value);
|
|
3894
6497
|
}
|
|
3895
6498
|
assertValidXrpcOutput(lexUri, value) {
|
|
3896
6499
|
lexUri = toLexUri(lexUri);
|
|
3897
|
-
const
|
|
3898
|
-
assertValidXrpcOutput(
|
|
6500
|
+
const def2 = this.getDefOrThrow(lexUri, ["query", "procedure"]);
|
|
6501
|
+
return assertValidXrpcOutput(
|
|
6502
|
+
this,
|
|
6503
|
+
def2,
|
|
6504
|
+
value
|
|
6505
|
+
);
|
|
6506
|
+
}
|
|
6507
|
+
assertValidXrpcMessage(lexUri, value) {
|
|
6508
|
+
lexUri = toLexUri(lexUri);
|
|
6509
|
+
const def2 = this.getDefOrThrow(lexUri, ["subscription"]);
|
|
6510
|
+
return assertValidXrpcMessage(this, def2, value);
|
|
6511
|
+
}
|
|
6512
|
+
resolveLexUri(lexUri, ref) {
|
|
6513
|
+
lexUri = toLexUri(lexUri);
|
|
6514
|
+
return toLexUri(ref, lexUri);
|
|
3899
6515
|
}
|
|
3900
6516
|
};
|
|
3901
6517
|
function* iterDefs(doc) {
|
|
@@ -3927,8 +6543,61 @@ function resolveRefUris(obj, baseUri) {
|
|
|
3927
6543
|
}
|
|
3928
6544
|
return obj;
|
|
3929
6545
|
}
|
|
6546
|
+
|
|
6547
|
+
// src/serialize.ts
|
|
6548
|
+
var lexToIpld = (val) => {
|
|
6549
|
+
if (Array.isArray(val)) {
|
|
6550
|
+
return val.map((item) => lexToIpld(item));
|
|
6551
|
+
}
|
|
6552
|
+
if (val && typeof val === "object") {
|
|
6553
|
+
if (val instanceof BlobRef) {
|
|
6554
|
+
return val.original;
|
|
6555
|
+
}
|
|
6556
|
+
if (CID.asCID(val) || val instanceof Uint8Array) {
|
|
6557
|
+
return val;
|
|
6558
|
+
}
|
|
6559
|
+
const toReturn = {};
|
|
6560
|
+
for (const key of Object.keys(val)) {
|
|
6561
|
+
toReturn[key] = lexToIpld(val[key]);
|
|
6562
|
+
}
|
|
6563
|
+
return toReturn;
|
|
6564
|
+
}
|
|
6565
|
+
return val;
|
|
6566
|
+
};
|
|
6567
|
+
var ipldToLex = (val) => {
|
|
6568
|
+
if (Array.isArray(val)) {
|
|
6569
|
+
return val.map((item) => ipldToLex(item));
|
|
6570
|
+
}
|
|
6571
|
+
if (val && typeof val === "object") {
|
|
6572
|
+
if ((val["$type"] === "blob" || typeof val["cid"] === "string" && typeof val["mimeType"] === "string") && check_exports.is(val, jsonBlobRef)) {
|
|
6573
|
+
return BlobRef.fromJsonRef(val);
|
|
6574
|
+
}
|
|
6575
|
+
if (CID.asCID(val) || val instanceof Uint8Array) {
|
|
6576
|
+
return val;
|
|
6577
|
+
}
|
|
6578
|
+
const toReturn = {};
|
|
6579
|
+
for (const key of Object.keys(val)) {
|
|
6580
|
+
toReturn[key] = ipldToLex(val[key]);
|
|
6581
|
+
}
|
|
6582
|
+
return toReturn;
|
|
6583
|
+
}
|
|
6584
|
+
return val;
|
|
6585
|
+
};
|
|
6586
|
+
var lexToJson = (val) => {
|
|
6587
|
+
return ipldToJson(lexToIpld(val));
|
|
6588
|
+
};
|
|
6589
|
+
var stringifyLex = (val) => {
|
|
6590
|
+
return JSON.stringify(lexToJson(val));
|
|
6591
|
+
};
|
|
6592
|
+
var jsonToLex = (val) => {
|
|
6593
|
+
return ipldToLex(jsonToIpld(val));
|
|
6594
|
+
};
|
|
6595
|
+
var jsonStringToLex = (val) => {
|
|
6596
|
+
return jsonToLex(JSON.parse(val));
|
|
6597
|
+
};
|
|
3930
6598
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3931
6599
|
0 && (module.exports = {
|
|
6600
|
+
BlobRef,
|
|
3932
6601
|
InvalidLexiconError,
|
|
3933
6602
|
LexiconDefNotFoundError,
|
|
3934
6603
|
LexiconDocMalformedError,
|
|
@@ -3936,34 +6605,45 @@ function resolveRefUris(obj, baseUri) {
|
|
|
3936
6605
|
ValidationError,
|
|
3937
6606
|
discriminatedObject,
|
|
3938
6607
|
hasProp,
|
|
6608
|
+
ipldToLex,
|
|
3939
6609
|
isDiscriminatedObject,
|
|
3940
6610
|
isObj,
|
|
3941
6611
|
isValidLexiconDoc,
|
|
6612
|
+
jsonBlobRef,
|
|
6613
|
+
jsonStringToLex,
|
|
6614
|
+
jsonToLex,
|
|
3942
6615
|
lexArray,
|
|
3943
|
-
lexAudio,
|
|
3944
6616
|
lexBlob,
|
|
3945
|
-
lexBlobVariant,
|
|
3946
6617
|
lexBoolean,
|
|
3947
|
-
|
|
3948
|
-
|
|
6618
|
+
lexBytes,
|
|
6619
|
+
lexCidLink,
|
|
6620
|
+
lexFloat,
|
|
3949
6621
|
lexInteger,
|
|
3950
|
-
|
|
6622
|
+
lexIpldType,
|
|
3951
6623
|
lexObject,
|
|
3952
6624
|
lexPrimitive,
|
|
6625
|
+
lexPrimitiveArray,
|
|
3953
6626
|
lexRecord,
|
|
3954
6627
|
lexRef,
|
|
3955
6628
|
lexRefUnion,
|
|
3956
6629
|
lexRefVariant,
|
|
3957
6630
|
lexString,
|
|
6631
|
+
lexStringFormat,
|
|
6632
|
+
lexToIpld,
|
|
6633
|
+
lexToJson,
|
|
3958
6634
|
lexToken,
|
|
3959
6635
|
lexUnknown,
|
|
3960
6636
|
lexUserType,
|
|
3961
|
-
lexVideo,
|
|
3962
6637
|
lexXrpcBody,
|
|
3963
6638
|
lexXrpcError,
|
|
3964
6639
|
lexXrpcParameters,
|
|
3965
6640
|
lexXrpcProcedure,
|
|
3966
6641
|
lexXrpcQuery,
|
|
3967
|
-
|
|
6642
|
+
lexXrpcSubscription,
|
|
6643
|
+
lexXrpcSubscriptionMessage,
|
|
6644
|
+
lexiconDoc,
|
|
6645
|
+
stringifyLex,
|
|
6646
|
+
typedJsonBlobRef,
|
|
6647
|
+
untypedJsonBlobRef
|
|
3968
6648
|
});
|
|
3969
6649
|
//# sourceMappingURL=index.js.map
|