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