@deslop/auth 0.1.1239 → 0.1.1243

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/server.js CHANGED
@@ -7720,6 +7720,61 @@ const containsWith = (isEquivalent) => dual(2, (self, a) => {
7720
7720
  * @since 2.0.0
7721
7721
  */
7722
7722
  const contains = /*#__PURE__*/ containsWith(/*#__PURE__*/ asEquivalence());
7723
+ const hashBucketsAdd = (buckets, value) => {
7724
+ const hash$6 = hash(value);
7725
+ const bucket = buckets.get(hash$6);
7726
+ if (bucket === void 0) {
7727
+ buckets.set(hash$6, [value]);
7728
+ return true;
7729
+ }
7730
+ for (const previous of bucket) if (equals$1(previous, value)) return false;
7731
+ bucket.push(value);
7732
+ return true;
7733
+ };
7734
+ const makeHashBuckets = (values) => {
7735
+ const buckets = /* @__PURE__ */ new Map();
7736
+ for (const value of values) hashBucketsAdd(buckets, value);
7737
+ return buckets;
7738
+ };
7739
+ const hashBucketsHas = (buckets, value) => {
7740
+ const bucket = buckets.get(hash(value));
7741
+ if (bucket === void 0) return false;
7742
+ for (const candidate of bucket) if (equals$1(candidate, value)) return true;
7743
+ return false;
7744
+ };
7745
+ /**
7746
+ * Computes elements in the first array that are not in the second, using
7747
+ * `Equal.asEquivalence()`.
7748
+ *
7749
+ * **When to use**
7750
+ *
7751
+ * Use when you need to keep values from the first array that are absent from
7752
+ * the second and the default `Equal.asEquivalence()` comparison is appropriate.
7753
+ *
7754
+ * **Example** (Computing array differences)
7755
+ *
7756
+ * ```ts import.meta.vitest
7757
+ * import { Array } from "effect"
7758
+ *
7759
+ * Array.difference([1, 2, 3], [2, 3, 4]) // => [1]
7760
+ * ```
7761
+ *
7762
+ * @see {@link differenceWith} — use custom equality
7763
+ * @see {@link union} — elements in either array
7764
+ * @see {@link intersection} — elements in both arrays
7765
+ *
7766
+ * @stability stable
7767
+ * @category set operations
7768
+ * @since 2.0.0
7769
+ */
7770
+ const difference = /*#__PURE__*/ dual(2, (self, that) => {
7771
+ const thatArray = fromIterable$3(that);
7772
+ const selfArray = fromIterable$3(self);
7773
+ if (selfArray.length === 0) return [];
7774
+ if (thatArray.length === 0) return selfArray.filter(() => true);
7775
+ const buckets = makeHashBuckets(thatArray);
7776
+ return selfArray.filter((value) => !hashBucketsHas(buckets, value));
7777
+ });
7723
7778
  /**
7724
7779
  * Creates an empty array.
7725
7780
  *
@@ -21863,6 +21918,48 @@ const formatIp = (self) => {
21863
21918
  return `${segments.slice(0, bestStart).map((segment) => segment.toString(16)).join(":")}::${segments.slice(bestStart + bestLength).map((segment) => segment.toString(16)).join(":")}`;
21864
21919
  };
21865
21920
  /**
21921
+ * Returns `true` for IPv4 `127.0.0.0/8` or IPv6 `::1`.
21922
+ *
21923
+ * @stability unstable
21924
+ * @category predicates
21925
+ * @since 4.0.0
21926
+ */
21927
+ const isLoopback = (self) => {
21928
+ if (isIpv4Address(self)) return ipv4Value(self) >>> 24 === 127;
21929
+ const { w0, w1, w2, w3 } = ipv6Words(self);
21930
+ return w0 === 0 && w1 === 0 && w2 === 0 && w3 === 1;
21931
+ };
21932
+ /**
21933
+ * Returns `true` for IPv4 `169.254.0.0/16` or IPv6 `fe80::/10`.
21934
+ *
21935
+ * @stability unstable
21936
+ * @category predicates
21937
+ * @since 4.0.0
21938
+ */
21939
+ const isLinkLocal = (self) => {
21940
+ if (isIpv4Address(self)) return ipv4Value(self) >>> 16 === 43518;
21941
+ return (ipv6Words(self).w0 >>> 16 & 65472) === 65152;
21942
+ };
21943
+ /**
21944
+ * Returns `true` for IPv4 private-use ranges defined by RFC 1918.
21945
+ *
21946
+ * @stability unstable
21947
+ * @category predicates
21948
+ * @since 4.0.0
21949
+ */
21950
+ const isPrivate$1 = (self) => {
21951
+ const value = ipv4Value(self);
21952
+ return value >>> 24 === 10 || (value >>> 16 & 65520) === 44048 || value >>> 16 === 49320;
21953
+ };
21954
+ /**
21955
+ * Returns `true` for IPv6 unique-local addresses in `fc00::/7`.
21956
+ *
21957
+ * @stability unstable
21958
+ * @category predicates
21959
+ * @since 4.0.0
21960
+ */
21961
+ const isUniqueLocal = (self) => (ipv6Words(self).w0 >>> 24 & 254) === 252;
21962
+ /**
21866
21963
  * Returns `true` when an IPv6 address is in the `::ffff:0:0/96` mapped range.
21867
21964
  *
21868
21965
  * @stability unstable
@@ -21873,6 +21970,14 @@ const isIpv4Mapped = (self) => {
21873
21970
  const { w0, w1, w2 } = ipv6Words(self);
21874
21971
  return w0 === 0 && w1 === 0 && w2 === 65535;
21875
21972
  };
21973
+ /**
21974
+ * Extracts the IPv4 value from an IPv4-mapped IPv6 address.
21975
+ *
21976
+ * @stability unstable
21977
+ * @category converting
21978
+ * @since 4.0.0
21979
+ */
21980
+ const fromIpv4Mapped = (self) => isIpv4Mapped(self) ? some$1(makeIpv4(ipv6Words(self).w3)) : none();
21876
21981
  const InetV4Proto = {
21877
21982
  ...BaseProto,
21878
21983
  _tag: "InetAddressV4",
@@ -71223,70 +71328,6 @@ const makeMemoryStore = /*#__PURE__*/ gen(function* () {
71223
71328
  * @since 4.0.0
71224
71329
  */
71225
71330
  const layerStoreMemory = /*#__PURE__*/ effect(RateLimiterStore)(/*#__PURE__*/ map$5(makeMemoryStore, (memory) => memory.store));
71226
- // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/rpc/RpcMiddleware.js
71227
- /**
71228
- * Middleware services for the unstable RPC runtime.
71229
- *
71230
- * A middleware service wraps server handler execution and can also install a
71231
- * client-side wrapper for generated clients. Its metadata records the services
71232
- * provided to downstream handlers, the services required by the middleware
71233
- * implementation, the schema for server-visible failures, the client-only error
71234
- * type, and whether generated clients must require the matching client layer.
71235
- *
71236
- * @stability unstable
71237
- * @since 4.0.0
71238
- */
71239
- /**
71240
- * The runtime type id used to attach and inspect RPC middleware metadata.
71241
- *
71242
- * @stability unstable
71243
- * @category type IDs
71244
- * @since 4.0.0
71245
- */
71246
- const TypeId$8 = "~effect/rpc/RpcMiddleware";
71247
- /**
71248
- * Creates a typed RPC middleware service class, with optional service
71249
- * requirements, provided services, error schema, and client-side requirement
71250
- * metadata.
71251
- *
71252
- * @stability unstable
71253
- * @category constructors
71254
- * @since 4.0.0
71255
- */
71256
- const Service = () => (id, options) => {
71257
- const limit = getStackTraceLimit();
71258
- let creationError;
71259
- if (limit !== 0) {
71260
- setStackTraceLimit(2);
71261
- creationError = new globalThis.Error();
71262
- setStackTraceLimit(limit);
71263
- }
71264
- function ServiceClass() {}
71265
- const ServiceClass_ = ServiceClass;
71266
- Object.setPrototypeOf(ServiceClass, Object.getPrototypeOf(Service$1(id)));
71267
- ServiceClass.key = id;
71268
- Object.defineProperty(ServiceClass, "stack", { get() {
71269
- return creationError?.stack;
71270
- } });
71271
- ServiceClass_[TypeId$8] = TypeId$8;
71272
- ServiceClass_.error = options?.error ?? Never;
71273
- ServiceClass_.requiredForClient = options?.requiredForClient ?? false;
71274
- return ServiceClass;
71275
- };
71276
- /**
71277
- * Provides the client-side implementation for an RPC middleware service,
71278
- * capturing the layer's environment and merging it into each middleware
71279
- * invocation.
71280
- *
71281
- * @stability unstable
71282
- * @category layers
71283
- * @since 4.0.0
71284
- */
71285
- const layerClient = (tag, service) => effectContext(gen(function* () {
71286
- const services = (yield* context()).pipe(omit$2(Scope));
71287
- const middleware = isEffect(service) ? yield* service : service;
71288
- return makeUnsafe$10(/* @__PURE__ */ new Map([[`${tag.key}/Client`, (options) => updateContext(middleware(options), (requestContext) => merge$4(services, requestContext))]]));
71289
- }));
71290
71331
  // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/cli/CliError.js
71291
71332
  /**
71292
71333
  * Defines structured errors for the unstable CLI parser and runner.
@@ -71308,7 +71349,7 @@ const layerClient = (tag, service) => effectContext(gen(function* () {
71308
71349
  * @category type IDs
71309
71350
  * @since 4.0.0
71310
71351
  */
71311
- const TypeId$7 = "~effect/cli/CliError";
71352
+ const TypeId$8 = "~effect/cli/CliError";
71312
71353
  /**
71313
71354
  * Type guard to check if a value is a CLI error.
71314
71355
  *
@@ -71330,7 +71371,7 @@ const TypeId$7 = "~effect/cli/CliError";
71330
71371
  * @category guards
71331
71372
  * @since 4.0.0
71332
71373
  */
71333
- const isCliError = (u) => hasProperty(u, TypeId$7);
71374
+ const isCliError = (u) => hasProperty(u, TypeId$8);
71334
71375
  /**
71335
71376
  * Defines the runtime property key used to give an object error a user-facing
71336
71377
  * message.
@@ -71417,7 +71458,7 @@ const getUserMessage = (error) => "~effect/cli/CliError/userMessage" in error &&
71417
71458
  * @category errors
71418
71459
  * @since 4.0.0
71419
71460
  */
71420
- var UnrecognizedOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/UnrecognizedOption`)("UnrecognizedOption", {
71461
+ var UnrecognizedOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId$8}/UnrecognizedOption`)("UnrecognizedOption", {
71421
71462
  option: String$6,
71422
71463
  command: /*#__PURE__*/ optional$8(/*#__PURE__*/ ArraySchema(String$6)),
71423
71464
  suggestions: /*#__PURE__*/ ArraySchema(String$6)
@@ -71428,7 +71469,7 @@ var UnrecognizedOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/U
71428
71469
  * @stability unstable
71429
71470
  * @since 4.0.0
71430
71471
  */
71431
- [TypeId$7] = TypeId$7;
71472
+ [TypeId$8] = TypeId$8;
71432
71473
  /**
71433
71474
  * Formats the unrecognized option with command context and suggestions.
71434
71475
  *
@@ -71464,7 +71505,7 @@ var UnrecognizedOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/U
71464
71505
  * @category errors
71465
71506
  * @since 4.0.0
71466
71507
  */
71467
- var DuplicateOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/DuplicateOption`)("DuplicateOption", {
71508
+ var DuplicateOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId$8}/DuplicateOption`)("DuplicateOption", {
71468
71509
  option: String$6,
71469
71510
  parentCommand: String$6,
71470
71511
  childCommand: String$6
@@ -71475,7 +71516,7 @@ var DuplicateOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/Dupl
71475
71516
  * @stability unstable
71476
71517
  * @since 4.0.0
71477
71518
  */
71478
- [TypeId$7] = TypeId$7;
71519
+ [TypeId$8] = TypeId$8;
71479
71520
  /**
71480
71521
  * Explains which parent and child commands define the duplicate option.
71481
71522
  *
@@ -71519,14 +71560,14 @@ var DuplicateOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/Dupl
71519
71560
  * @category errors
71520
71561
  * @since 4.0.0
71521
71562
  */
71522
- var MissingOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/MissingOption`)("MissingOption", { option: String$6 })) {
71563
+ var MissingOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId$8}/MissingOption`)("MissingOption", { option: String$6 })) {
71523
71564
  /**
71524
71565
  * Marks this value as a missing CLI option error for runtime guards.
71525
71566
  *
71526
71567
  * @stability unstable
71527
71568
  * @since 4.0.0
71528
71569
  */
71529
- [TypeId$7] = TypeId$7;
71570
+ [TypeId$8] = TypeId$8;
71530
71571
  /**
71531
71572
  * Formats the missing required flag for display.
71532
71573
  *
@@ -71569,14 +71610,14 @@ var MissingOption = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/Missin
71569
71610
  * @category errors
71570
71611
  * @since 4.0.0
71571
71612
  */
71572
- var MissingArgument = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/MissingArgument`)("MissingArgument", { argument: String$6 })) {
71613
+ var MissingArgument = class extends (/*#__PURE__*/ TaggedError(`${TypeId$8}/MissingArgument`)("MissingArgument", { argument: String$6 })) {
71573
71614
  /**
71574
71615
  * Marks this value as a missing CLI argument error for runtime guards.
71575
71616
  *
71576
71617
  * @stability unstable
71577
71618
  * @since 4.0.0
71578
71619
  */
71579
- [TypeId$7] = TypeId$7;
71620
+ [TypeId$8] = TypeId$8;
71580
71621
  /**
71581
71622
  * Formats the missing required positional argument for display.
71582
71623
  *
@@ -71607,14 +71648,14 @@ var MissingArgument = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/Miss
71607
71648
  * @category errors
71608
71649
  * @since 4.0.0
71609
71650
  */
71610
- var UnexpectedArgument = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/UnexpectedArgument`)("UnexpectedArgument", { arguments: /*#__PURE__*/ ArraySchema(String$6) })) {
71651
+ var UnexpectedArgument = class extends (/*#__PURE__*/ TaggedError(`${TypeId$8}/UnexpectedArgument`)("UnexpectedArgument", { arguments: /*#__PURE__*/ ArraySchema(String$6) })) {
71611
71652
  /**
71612
71653
  * Marks this value as an unexpected CLI argument error for runtime guards.
71613
71654
  *
71614
71655
  * @stability unstable
71615
71656
  * @since 4.0.0
71616
71657
  */
71617
- [TypeId$7] = TypeId$7;
71658
+ [TypeId$8] = TypeId$8;
71618
71659
  /**
71619
71660
  * Formats the unexpected positional arguments for display.
71620
71661
  *
@@ -71660,7 +71701,7 @@ var UnexpectedArgument = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/U
71660
71701
  * @category errors
71661
71702
  * @since 4.0.0
71662
71703
  */
71663
- var InvalidValue = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/InvalidValue`)("InvalidValue", {
71704
+ var InvalidValue = class extends (/*#__PURE__*/ TaggedError(`${TypeId$8}/InvalidValue`)("InvalidValue", {
71664
71705
  option: String$6,
71665
71706
  value: String$6,
71666
71707
  expected: String$6,
@@ -71672,7 +71713,7 @@ var InvalidValue = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/Invalid
71672
71713
  * @stability unstable
71673
71714
  * @since 4.0.0
71674
71715
  */
71675
- [TypeId$7] = TypeId$7;
71716
+ [TypeId$8] = TypeId$8;
71676
71717
  /**
71677
71718
  * Formats the invalid flag or argument value with the expected input.
71678
71719
  *
@@ -71723,7 +71764,7 @@ var InvalidValue = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/Invalid
71723
71764
  * @category errors
71724
71765
  * @since 4.0.0
71725
71766
  */
71726
- var UnknownSubcommand = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/UnknownSubcommand`)("UnknownSubcommand", {
71767
+ var UnknownSubcommand = class extends (/*#__PURE__*/ TaggedError(`${TypeId$8}/UnknownSubcommand`)("UnknownSubcommand", {
71727
71768
  subcommand: String$6,
71728
71769
  parent: /*#__PURE__*/ optional$8(/*#__PURE__*/ ArraySchema(String$6)),
71729
71770
  suggestions: /*#__PURE__*/ ArraySchema(String$6)
@@ -71734,7 +71775,7 @@ var UnknownSubcommand = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/Un
71734
71775
  * @stability unstable
71735
71776
  * @since 4.0.0
71736
71777
  */
71737
- [TypeId$7] = TypeId$7;
71778
+ [TypeId$8] = TypeId$8;
71738
71779
  /**
71739
71780
  * Formats the unknown subcommand with parent command context and suggestions.
71740
71781
  *
@@ -71773,14 +71814,14 @@ var UnknownSubcommand = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/Un
71773
71814
  * @category errors
71774
71815
  * @since 4.1.0
71775
71816
  */
71776
- var ValidationError = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/ValidationError`)("ValidationError", { message: String$6 })) {
71817
+ var ValidationError = class extends (/*#__PURE__*/ TaggedError(`${TypeId$8}/ValidationError`)("ValidationError", { message: String$6 })) {
71777
71818
  /**
71778
71819
  * Marks this value as a CLI validation error for runtime guards.
71779
71820
  *
71780
71821
  * @stability unstable
71781
71822
  * @since 4.1.0
71782
71823
  */
71783
- [TypeId$7] = TypeId$7;
71824
+ [TypeId$8] = TypeId$8;
71784
71825
  };
71785
71826
  /**
71786
71827
  * Error wrapper for user handler failures in the CLI error channel.
@@ -71828,7 +71869,7 @@ var ValidationError = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/Vali
71828
71869
  * @category errors
71829
71870
  * @since 4.0.0
71830
71871
  */
71831
- var UserError = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/UserError`)("UserError", {
71872
+ var UserError = class extends (/*#__PURE__*/ TaggedError(`${TypeId$8}/UserError`)("UserError", {
71832
71873
  cause: /*#__PURE__*/ Defect(),
71833
71874
  userMessage: /*#__PURE__*/ optionalKey(String$6)
71834
71875
  })) {
@@ -71838,7 +71879,7 @@ var UserError = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/UserError`
71838
71879
  * @stability unstable
71839
71880
  * @since 4.0.0
71840
71881
  */
71841
- [TypeId$7] = TypeId$7;
71882
+ [TypeId$8] = TypeId$8;
71842
71883
  /**
71843
71884
  * Controls whether the runtime logger should report this error. The CLI
71844
71885
  * runner sets this to `false` after rendering the error itself.
@@ -71905,11 +71946,11 @@ const NonShowHelpErrors = /*#__PURE__*/ Union([
71905
71946
  * @category errors
71906
71947
  * @since 4.0.0
71907
71948
  */
71908
- var ShowHelp = class extends (/*#__PURE__*/ TaggedError(`${TypeId$7}/ShowHelp`)("ShowHelp", {
71949
+ var ShowHelp = class extends (/*#__PURE__*/ TaggedError(`${TypeId$8}/ShowHelp`)("ShowHelp", {
71909
71950
  commandPath: /*#__PURE__*/ ArraySchema(String$6),
71910
71951
  errors: /*#__PURE__*/ ArraySchema(NonShowHelpErrors)
71911
71952
  })) {
71912
- [TypeId$7] = TypeId$7;
71953
+ [TypeId$8] = TypeId$8;
71913
71954
  [errorExitCode] = this.errors.length ? 1 : 0;
71914
71955
  [errorReported] = false;
71915
71956
  get message() {
@@ -72297,7 +72338,7 @@ const eraseLines = (rows) => {
72297
72338
  * @stability unstable
72298
72339
  * @since 4.0.0
72299
72340
  */
72300
- const TypeId$6 = "~effect/cli/Prompt";
72341
+ const TypeId$7 = "~effect/cli/Prompt";
72301
72342
  const defaultTheme = {
72302
72343
  prefix: "?",
72303
72344
  arrowUp: "↑",
@@ -72712,7 +72753,7 @@ const proto = {
72712
72753
  return run$3(this);
72713
72754
  }
72714
72755
  }),
72715
- [TypeId$6]: { _Output: (_) => _ }
72756
+ [TypeId$7]: { _Output: (_) => _ }
72716
72757
  };
72717
72758
  const runWithInput = (prompt, terminal, input) => suspend$2(() => {
72718
72759
  const op = prompt;
@@ -73848,7 +73889,7 @@ const fromProcess = () => {
73848
73889
  * @stability unstable
73849
73890
  * @since 4.0.0
73850
73891
  */
73851
- const TypeId$5 = "~effect/cli/Param";
73892
+ const TypeId$6 = "~effect/cli/Param";
73852
73893
  /**
73853
73894
  * Defines the kind discriminator for flag parameters.
73854
73895
  *
@@ -73865,7 +73906,7 @@ const TypeId$5 = "~effect/cli/Param";
73865
73906
  */
73866
73907
  const flagKind = "flag";
73867
73908
  const Proto$4 = {
73868
- [TypeId$5]: { _A: identity },
73909
+ [TypeId$6]: { _A: identity },
73869
73910
  pipe() {
73870
73911
  return pipeArguments(this, arguments);
73871
73912
  }
@@ -73887,7 +73928,7 @@ const Proto$4 = {
73887
73928
  * @category guards
73888
73929
  * @since 4.0.0
73889
73930
  */
73890
- const isParam = (u) => hasProperty(u, TypeId$5);
73931
+ const isParam = (u) => hasProperty(u, TypeId$6);
73891
73932
  /**
73892
73933
  * Type guard to check if a Single param is a flag (not an argument).
73893
73934
  *
@@ -75119,7 +75160,7 @@ const reconstructTree = (tree, results) => {
75119
75160
  * Internal implementation details for CLI commands.
75120
75161
  * Public API is in ../Command.ts
75121
75162
  */
75122
- const TypeId$4 = "~effect/cli/Command";
75163
+ const TypeId$5 = "~effect/cli/Command";
75123
75164
  /**
75124
75165
  * Casts a Command to its internal implementation.
75125
75166
  * For use by internal modules that need access to config, parse, handle, etc.
@@ -75203,7 +75244,7 @@ const makeCommand = (options) => {
75203
75244
  };
75204
75245
  };
75205
75246
  return Object.assign(Object.create(Proto$3), {
75206
- [TypeId$4]: TypeId$4,
75247
+ [TypeId$5]: TypeId$5,
75207
75248
  name: options.name,
75208
75249
  examples: resolveExamples([options.name]),
75209
75250
  resolveExamples,
@@ -77853,7 +77894,7 @@ const formatShellArg = (arg) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(arg) ? arg : `'$
77853
77894
  * @category guards
77854
77895
  * @since 4.0.0
77855
77896
  */
77856
- const isCommand = (u) => hasProperty(u, TypeId$4);
77897
+ const isCommand = (u) => hasProperty(u, TypeId$5);
77857
77898
  /**
77858
77899
  * Creates a `Command` from a name, an optional configuration, and an optional
77859
77900
  * handler.
@@ -78539,32 +78580,25 @@ Struct({
78539
78580
  expires_in: Finite,
78540
78581
  refresh_token: NonEmptyString
78541
78582
  });
78542
- const Origin$1 = String$6.check(makeFilter((value) => {
78543
- if (!URL.canParse(value)) return false;
78544
- const url = new URL(value);
78545
- return contains(["http:", "https:"], url.protocol) && url.username === "" && url.password === "" && url.hash === "";
78546
- }, { expected: "an HTTP(S) URL without credentials or a fragment" })).check(makeFilter((value) => {
78547
- if (!URL.canParse(value)) return false;
78548
- const url = new URL(value);
78549
- return url.pathname === "/" && url.search === "";
78550
- }, { expected: "an HTTP(S) origin without a path or query" }));
78551
- const SecureOrigin = Origin$1.check(makeFilter((value) => {
78552
- if (!URL.canParse(value)) return false;
78553
- const url = new URL(value);
78554
- return url.protocol === "https:" || contains([
78555
- "localhost",
78556
- "127.0.0.1",
78557
- "[::1]"
78558
- ], url.hostname);
78559
- }, { expected: "HTTPS outside loopback" }));
78583
+ const Origin$1 = String$6.check(makeFilter((value) => exists(getSuccess(fromString(value)), (url) => contains(["http:", "https:"], url.protocol) && url.username === "" && url.password === "" && url.hash === ""), { expected: "an HTTP(S) URL without credentials or a fragment" })).check(makeFilter((value) => exists(getSuccess(fromString(value)), (url) => url.pathname === "/" && url.search === ""), { expected: "an HTTP(S) origin without a path or query" }));
78584
+ const SecureOrigin = Origin$1.check(makeFilter((value) => exists(getSuccess(fromString(value)), (url) => url.protocol === "https:" || contains([
78585
+ "localhost",
78586
+ "127.0.0.1",
78587
+ "[::1]"
78588
+ ], url.hostname)), { expected: "HTTPS outside loopback" }));
78560
78589
  const Port = String$6.check(isPattern(/^\d{1,5}$/u), makeFilter((value) => exists(parse$2(value), (port) => port >= 1 && port <= 65535), { expected: "a port between 1 and 65535" }));
78561
78590
  const AppVersion = String$6.check(isPattern(/^0\.1\.\d+$/u));
78591
+ const RUNTIME_PATH = "/api/runtime";
78562
78592
  const RuntimeConfig = Struct({
78563
78593
  auth: optionalKey(String$6),
78564
78594
  name: String$6,
78565
78595
  traces: String$6,
78566
78596
  version: AppVersion
78567
78597
  });
78598
+ const RPC_PATH = "/api/rpc";
78599
+ const MCP_PATH = "/mcp";
78600
+ const MCP_METADATA_PATH = "/.well-known/oauth-protected-resource/mcp";
78601
+ const MANIFEST_PATH = "/manifest.webmanifest";
78568
78602
  const Account$1 = Struct({
78569
78603
  ...User.fields,
78570
78604
  signOut: Boolean$5
@@ -79834,7 +79868,7 @@ const AiErrorReason = /*#__PURE__*/ Union([
79834
79868
  ToolkitRequiredError,
79835
79869
  InvalidUserInputError
79836
79870
  ]);
79837
- const TypeId$3 = "~effect/ai/AiError";
79871
+ const TypeId$4 = "~effect/ai/AiError";
79838
79872
  /**
79839
79873
  * Schema for the top-level AI error wrapper using the `reason` pattern.
79840
79874
  *
@@ -79883,7 +79917,7 @@ var AiError = class extends (/*#__PURE__*/ Error$1("effect/ai/AiError/AiError")(
79883
79917
  method: String$6,
79884
79918
  reason: AiErrorReason
79885
79919
  })) {
79886
- [TypeId$3] = TypeId$3;
79920
+ [TypeId$4] = TypeId$4;
79887
79921
  cause = this.reason;
79888
79922
  /**
79889
79923
  * Delegates to the underlying reason's `isRetryable` getter.
@@ -79929,7 +79963,7 @@ var AiError = class extends (/*#__PURE__*/ Error$1("effect/ai/AiError/AiError")(
79929
79963
  * @category guards
79930
79964
  * @since 4.0.0
79931
79965
  */
79932
- const isAiError = (u) => hasProperty(u, TypeId$3);
79966
+ const isAiError = (u) => hasProperty(u, TypeId$4);
79933
79967
  /**
79934
79968
  * Type guard to check if a value is an `AiErrorReason`.
79935
79969
  *
@@ -80001,7 +80035,7 @@ const make$14 = (params) => new AiError(params);
80001
80035
  * @category type IDs
80002
80036
  * @since 4.0.0
80003
80037
  */
80004
- const TypeId$2 = "~effect/ai/Tool";
80038
+ const TypeId$3 = "~effect/ai/Tool";
80005
80039
  /**
80006
80040
  * Runtime type identifier carried by dynamic tools.
80007
80041
  *
@@ -80043,7 +80077,7 @@ const DynamicTypeId = "~effect/ai/Tool/Dynamic";
80043
80077
  const isDynamic = (u) => hasProperty(u, DynamicTypeId);
80044
80078
  const clone = (self, overrides) => Object.assign(Object.create(Object.getPrototypeOf(self)), self, overrides);
80045
80079
  const Proto$2 = {
80046
- [TypeId$2]: { _Requirements: identity },
80080
+ [TypeId$3]: { _Requirements: identity },
80047
80081
  pipe() {
80048
80082
  return pipeArguments(this, arguments);
80049
80083
  },
@@ -80427,7 +80461,7 @@ function resolveTopLevelReference(document) {
80427
80461
  * @stability unstable
80428
80462
  * @since 4.0.0
80429
80463
  */
80430
- const TypeId$1 = "~effect/ai/Toolkit";
80464
+ const TypeId$2 = "~effect/ai/Toolkit";
80431
80465
  /**
80432
80466
  * Cause annotation identifying the phase of a typed `Toolkit.handle` failure.
80433
80467
  *
@@ -80646,7 +80680,7 @@ const Proto$1 = {
80646
80680
  };
80647
80681
  })
80648
80682
  }),
80649
- [TypeId$1]: TypeId$1,
80683
+ [TypeId$2]: TypeId$2,
80650
80684
  of: identity,
80651
80685
  toHandlers(build) {
80652
80686
  return gen({ self: this }, function* () {
@@ -80723,6 +80757,70 @@ const resolveInput = (...tools) => {
80723
80757
  * @since 4.0.0
80724
80758
  */
80725
80759
  const make$12 = (...tools) => makeProto(resolveInput(...tools));
80760
+ // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/rpc/RpcMiddleware.js
80761
+ /**
80762
+ * Middleware services for the unstable RPC runtime.
80763
+ *
80764
+ * A middleware service wraps server handler execution and can also install a
80765
+ * client-side wrapper for generated clients. Its metadata records the services
80766
+ * provided to downstream handlers, the services required by the middleware
80767
+ * implementation, the schema for server-visible failures, the client-only error
80768
+ * type, and whether generated clients must require the matching client layer.
80769
+ *
80770
+ * @stability unstable
80771
+ * @since 4.0.0
80772
+ */
80773
+ /**
80774
+ * The runtime type id used to attach and inspect RPC middleware metadata.
80775
+ *
80776
+ * @stability unstable
80777
+ * @category type IDs
80778
+ * @since 4.0.0
80779
+ */
80780
+ const TypeId$1 = "~effect/rpc/RpcMiddleware";
80781
+ /**
80782
+ * Creates a typed RPC middleware service class, with optional service
80783
+ * requirements, provided services, error schema, and client-side requirement
80784
+ * metadata.
80785
+ *
80786
+ * @stability unstable
80787
+ * @category constructors
80788
+ * @since 4.0.0
80789
+ */
80790
+ const Service = () => (id, options) => {
80791
+ const limit = getStackTraceLimit();
80792
+ let creationError;
80793
+ if (limit !== 0) {
80794
+ setStackTraceLimit(2);
80795
+ creationError = new globalThis.Error();
80796
+ setStackTraceLimit(limit);
80797
+ }
80798
+ function ServiceClass() {}
80799
+ const ServiceClass_ = ServiceClass;
80800
+ Object.setPrototypeOf(ServiceClass, Object.getPrototypeOf(Service$1(id)));
80801
+ ServiceClass.key = id;
80802
+ Object.defineProperty(ServiceClass, "stack", { get() {
80803
+ return creationError?.stack;
80804
+ } });
80805
+ ServiceClass_[TypeId$1] = TypeId$1;
80806
+ ServiceClass_.error = options?.error ?? Never;
80807
+ ServiceClass_.requiredForClient = options?.requiredForClient ?? false;
80808
+ return ServiceClass;
80809
+ };
80810
+ /**
80811
+ * Provides the client-side implementation for an RPC middleware service,
80812
+ * capturing the layer's environment and merging it into each middleware
80813
+ * invocation.
80814
+ *
80815
+ * @stability unstable
80816
+ * @category layers
80817
+ * @since 4.0.0
80818
+ */
80819
+ const layerClient = (tag, service) => effectContext(gen(function* () {
80820
+ const services = (yield* context()).pipe(omit$2(Scope));
80821
+ const middleware = isEffect(service) ? yield* service : service;
80822
+ return makeUnsafe$10(/* @__PURE__ */ new Map([[`${tag.key}/Client`, (options) => updateContext(middleware(options), (requestContext) => merge$4(services, requestContext))]]));
80823
+ }));
80726
80824
  // ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/ai/McpSchema.js
80727
80825
  /**
80728
80826
  * Defines schemas for Model Context Protocol messages.
@@ -88901,11 +88999,33 @@ function layerOtlp(serviceName, url, runtime, version) {
88901
88999
  }
88902
89000
  // ../../packages/runtime/src/auth/lib/utils.ts
88903
89001
  const AUTH_URL = "https://auth.mp281x.xyz";
89002
+ const ISSUER_PATH = "/api/auth";
89003
+ const ISSUER = `${AUTH_URL}${ISSUER_PATH}`;
89004
+ const APPS_PATH = "/api/apps";
89005
+ const SESSION_PATH = "/auth/session";
89006
+ const VERIFY_PATH = "/auth/verify";
88904
89007
  const DEVELOPER = {
88905
89008
  id: "github:0",
88906
89009
  name: "dev"
88907
89010
  };
88908
89011
  const localAuth = map$2(option(String$5("AUTH_URL")), isNone);
89012
+ const adminIds = gen(function* () {
89013
+ const listed = Array$1(String$6, "GITHUB_ADMINS");
89014
+ if (yield* localAuth) return yield* withDefault$2(listed, ["0"]);
89015
+ return yield* listed;
89016
+ });
89017
+ function isAdmin(admins, id) {
89018
+ return contains(admins, replace("github:", "")(id));
89019
+ }
89020
+ function rejected$1(message) {
89021
+ return mapError$2((cause) => {
89022
+ if (is$2(AuthError)(cause)) return cause;
89023
+ return AuthError.make({
89024
+ cause,
89025
+ message
89026
+ });
89027
+ });
89028
+ }
88909
89029
  var CurrentUser = class extends Service$1()("@deslop/runtime/auth/lib/utils/CurrentUser") {};
88910
89030
  var RpcAuth = class RpcAuth extends Service()("@deslop/runtime/auth/lib/utils/RpcAuth", { error: AuthError }) {
88911
89031
  static layerClient = (token) => layerClient(RpcAuth, (options) => gen(function* () {
@@ -88916,7 +89036,7 @@ var RpcAuth = class RpcAuth extends Service()("@deslop/runtime/auth/lib/utils/Rp
88916
89036
  }));
88917
89037
  };
88918
89038
  // ../../packages/runtime/src/auth/service.ts
88919
- function rejected$6(message) {
89039
+ function rejected(message) {
88920
89040
  return mapError$2((cause) => {
88921
89041
  if (is$2(AuthError)(cause)) return cause;
88922
89042
  if (isHttpClientError(cause) && cause.reason._tag === "StatusCodeError" && cause.reason.response.status === 401) return AuthError.make({
@@ -88948,17 +89068,17 @@ var Auth = class Auth extends Service$1()("@deslop/runtime/auth/service/Auth") {
88948
89068
  const canonical = new URL(yield* String$5("APP_URL")).origin;
88949
89069
  const client = filterStatusOk(yield* HttpClient);
88950
89070
  const access = fn("Auth.access")(function* (headers, audience) {
88951
- return yield* pipe(client.get(new URL("/auth/verify", issuer).href, {
89071
+ return yield* pipe(client.get(new URL(VERIFY_PATH, issuer).href, {
88952
89072
  headers: { authorization: headers["authorization"] ?? "" },
88953
89073
  urlParams: { resource: audience }
88954
89074
  }), flatMap$2(schemaBodyJson$1(User)), timeout("10 seconds"));
88955
- }, rejected$6("Sign in first"));
89075
+ }, rejected("Sign in first"));
88956
89076
  return Auth.makeContext(Auth.of({
88957
89077
  access,
88958
89078
  user: fn("Auth.user")(function* (headers) {
88959
89079
  if (isSome(get$6(headers, "authorization"))) return yield* access(headers, canonical);
88960
- return yield* pipe(client.get(new URL("/auth/session", issuer).href, { headers: { cookie: headers["cookie"] ?? "" } }), flatMap$2(schemaBodyJson$1(User)), timeout("10 seconds"));
88961
- }, rejected$6("Sign in first"))
89080
+ return yield* pipe(client.get(new URL(SESSION_PATH, issuer).href, { headers: { cookie: headers["cookie"] ?? "" } }), flatMap$2(schemaBodyJson$1(User)), timeout("10 seconds"));
89081
+ }, rejected("Sign in first"))
88962
89082
  }));
88963
89083
  }));
88964
89084
  };
@@ -88979,7 +89099,7 @@ function layerMcpAuth(resource) {
88979
89099
  if (yield* localAuth) return (app) => provideService(app, CurrentUser, DEVELOPER);
88980
89100
  return (app) => gen(function* () {
88981
89101
  const headers = (yield* HttpServerRequest).headers;
88982
- const challenge = `Bearer resource_metadata="${new URL("/.well-known/oauth-protected-resource/mcp", resource).href}", scope="deslop"`;
89102
+ const challenge = `Bearer resource_metadata="${new URL(MCP_METADATA_PATH, resource).href}", scope="deslop"`;
88983
89103
  if (isNone(get$6(headers, "authorization"))) return text("OAuth authorization required; sign in with your MCP client", {
88984
89104
  headers: { "www-authenticate": challenge },
88985
89105
  status: 401
@@ -89115,7 +89235,7 @@ const layerRoutes = use((router) => gen(function* () {
89115
89235
  })
89116
89236
  });
89117
89237
  });
89118
- yield* router.add("GET", "/api/runtime", gen(function* () {
89238
+ yield* router.add("GET", RUNTIME_PATH, gen(function* () {
89119
89239
  return yield* schemaJson(RuntimeConfig)({
89120
89240
  ...match$8(issuer, {
89121
89241
  onNone: () => ({}),
@@ -89143,7 +89263,7 @@ const layerAnnounce = effectDiscard(gen(function* () {
89143
89263
  yield* match$8(yield* option(String$5("AUTH_URL")), {
89144
89264
  onNone: () => void_$1,
89145
89265
  onSome: fnUntraced(function* (issuer) {
89146
- yield* pipe(post(new URL("/api/apps", issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), retry({
89266
+ yield* pipe(post(new URL(APPS_PATH, issuer).href), bodyJsonUnsafe({ origin }), client.execute, delay("2 seconds"), retry({
89147
89267
  schedule: spaced("1 minute"),
89148
89268
  times: 60
89149
89269
  }), ignore$1({
@@ -89164,7 +89284,7 @@ const layerWeb = unwrap$7(gen(function* () {
89164
89284
  const client = fileURLToPath(new URL("./client", import.meta.url));
89165
89285
  if (!(yield* (yield* FileSystem).exists((yield* Path$1).join(client, "index.html")))) return empty$11;
89166
89286
  const name = capitalize(yield* appName);
89167
- return mergeAll$1(add("GET", "/manifest.webmanifest", succeed$5(jsonUnsafe({
89287
+ return mergeAll$1(add("GET", MANIFEST_PATH, succeed$5(jsonUnsafe({
89168
89288
  background_color: "#0a0a0a",
89169
89289
  display: "standalone",
89170
89290
  icons: [{
@@ -89193,29 +89313,38 @@ const layerWeb = unwrap$7(gen(function* () {
89193
89313
  spa: true
89194
89314
  }));
89195
89315
  }));
89196
- function layerMcp$1(options) {
89316
+ function layerRpc(options) {
89317
+ return pipe(layerHttp$1({
89318
+ disableTracing: options.disableTracing,
89319
+ group: options.group,
89320
+ path: RPC_PATH,
89321
+ protocol: "websocket"
89322
+ }), provide$2(options.handlers));
89323
+ }
89324
+ function layerMcp(options) {
89197
89325
  return unwrap$7(gen(function* () {
89198
89326
  const metadata = yield* packageMetadata;
89199
89327
  const canonical = yield* String$5("APP_URL");
89200
89328
  const issuer = yield* option(String$5("AUTH_URL"));
89201
- const resource = new URL("/mcp", canonical).href;
89329
+ const resource = new URL(MCP_PATH, canonical).href;
89202
89330
  const endpoint = pipe(layerHttp({
89203
- ...options,
89204
89331
  allowSessionTermination: true,
89205
89332
  icons: [{ src: new URL("/icon", canonical).href }],
89333
+ instructions: options.instructions,
89206
89334
  name: yield* appName,
89207
- path: "/mcp",
89335
+ path: MCP_PATH,
89208
89336
  protocols: [
89209
89337
  v2026_07_28,
89210
89338
  v2025_11_25,
89211
89339
  v2025_06_18
89212
89340
  ],
89341
+ registrations: pipe(toolkit(options.tools), provide$2(options.handlers)),
89213
89342
  version: metadata.version
89214
89343
  }), provide$2(layerMcpAuth(resource)));
89215
89344
  return match$8(issuer, {
89216
89345
  onNone: () => endpoint,
89217
- onSome: (origin) => mergeAll$1(endpoint, add("GET", "/.well-known/oauth-protected-resource/mcp", succeed$5(jsonUnsafe({
89218
- authorization_servers: [new URL("/api/auth", origin).href],
89346
+ onSome: (origin) => mergeAll$1(endpoint, add("GET", MCP_METADATA_PATH, succeed$5(jsonUnsafe({
89347
+ authorization_servers: [new URL(ISSUER_PATH, origin).href],
89219
89348
  bearer_methods_supported: ["header"],
89220
89349
  resource,
89221
89350
  scopes_supported: ["deslop"]
@@ -89337,6 +89466,7 @@ const update$1 = fnUntraced(function* (name) {
89337
89466
  "--no-audit",
89338
89467
  "--no-fund",
89339
89468
  "--omit=dev",
89469
+ "--prefer-online",
89340
89470
  "--registry=https://registry.npmjs.org",
89341
89471
  `@deslop/${name}@${latest}`
89342
89472
  ]), timeout("5 minutes"));
@@ -89344,7 +89474,7 @@ const update$1 = fnUntraced(function* (name) {
89344
89474
  yield* activate(name, path.join(directory, "node_modules", "@deslop", name));
89345
89475
  yield* restart(name);
89346
89476
  const kept = [latest, ...toArray(map$11(previous, (link) => path.basename(path.resolve(link, "../../.."))))];
89347
- yield* forEach$1(filter$6(yield* fs.readDirectory(path.join(root, "releases")), (entry) => !contains(kept, entry)), (entry) => fs.remove(path.join(root, "releases", entry), { recursive: true }), { concurrency: 1 });
89477
+ yield* forEach$1(difference(yield* fs.readDirectory(path.join(root, "releases")), kept), (entry) => fs.remove(path.join(root, "releases", entry), { recursive: true }), { concurrency: 1 });
89348
89478
  return `Updated ${name} from ${running} to ${latest}\n`;
89349
89479
  });
89350
89480
  // ../../packages/runtime/src/cli.ts
@@ -89453,15 +89583,6 @@ const App = Struct({
89453
89583
  const Catalog = ArraySchema(App);
89454
89584
  const AppParams = Struct({ origin: SecureOrigin });
89455
89585
  // src/services/apps/service.ts
89456
- function rejected$5(message) {
89457
- return mapError$2((cause) => {
89458
- if (is$2(AuthError)(cause)) return cause;
89459
- return AuthError.make({
89460
- cause,
89461
- message
89462
- });
89463
- });
89464
- }
89465
89586
  var Apps = class Apps extends Service$1()("@deslop/auth/services/apps/service/Apps") {
89466
89587
  static layer = effect(this, gen(function* () {
89467
89588
  const store = toSchemaStore(yield* KeyValueStore, Catalog);
@@ -89476,12 +89597,12 @@ var Apps = class Apps extends Service$1()("@deslop/auth/services/apps/service/Ap
89476
89597
  error: "access_denied",
89477
89598
  message: `Only apps on ${domain} are listed`
89478
89599
  });
89479
- const runtime = yield* pipe(client.get(new URL("/api/runtime", origin).href), flatMap$2(schemaBodyJson$1(RuntimeConfig)), timeout("10 seconds"), rejected$5(`${origin} did not answer /api/runtime`));
89600
+ const runtime = yield* pipe(client.get(new URL(RUNTIME_PATH, origin).href), flatMap$2(schemaBodyJson$1(RuntimeConfig)), timeout("10 seconds"), rejected$1(`${origin} did not answer ${RUNTIME_PATH}`));
89480
89601
  if (!exists(fromUndefinedOr(runtime.auth), (auth) => new URL(auth).origin === self.origin)) return yield* AuthError.make({
89481
89602
  error: "access_denied",
89482
89603
  message: `${origin} signs in elsewhere`
89483
89604
  });
89484
- const web = yield* pipe(client.get(new URL("/manifest.webmanifest", origin).href), timeout("10 seconds"), as(true), orElseSucceed(() => false));
89605
+ const web = yield* pipe(client.get(new URL(MANIFEST_PATH, origin).href), timeout("10 seconds"), as(true), orElseSucceed(() => false));
89485
89606
  const app = App.make({
89486
89607
  name: runtime.name,
89487
89608
  open: match$1(web, {
@@ -89493,7 +89614,7 @@ var Apps = class Apps extends Service$1()("@deslop/auth/services/apps/service/Ap
89493
89614
  yield* pipe(modifyEffect(state, (current) => {
89494
89615
  const next = sort([...filter$6(current, (known) => known.origin !== app.origin), app], mapInput(Order$3, (known) => known.name));
89495
89616
  return as(store.set("apps", next), [void 0, next]);
89496
- }), uninterruptible, rejected$5("The app list could not be saved"));
89617
+ }), uninterruptible, rejected$1("The app list could not be saved"));
89497
89618
  return app;
89498
89619
  })
89499
89620
  });
@@ -89665,15 +89786,6 @@ const DEVELOPER_PROFILE = GitHubUser.make({
89665
89786
  id: 0,
89666
89787
  login: DEVELOPER.name
89667
89788
  });
89668
- function failed(message) {
89669
- return mapError$2((cause) => {
89670
- if (is$2(AuthError)(cause)) return cause;
89671
- return AuthError.make({
89672
- cause,
89673
- message
89674
- });
89675
- });
89676
- }
89677
89789
  var GitHub = class GitHub extends Service$1()("@deslop/auth/services/github/service/GitHub") {
89678
89790
  static layer = effect(GitHub, gen(function* () {
89679
89791
  const random = yield* SecureRandom;
@@ -89736,10 +89848,10 @@ var GitHub = class GitHub extends Service$1()("@deslop/auth/services/github/serv
89736
89848
  flow,
89737
89849
  profile: yield* user(bearerToken(get$3("https://api.github.com/user"), token.access_token))
89738
89850
  };
89739
- }, failed("GitHub sign-in failed")),
89851
+ }, rejected$1("GitHub sign-in failed")),
89740
89852
  profile: fn("GitHub.profile")(function* (id) {
89741
89853
  return yield* user(get$3(`https://api.github.com/user/${id}`));
89742
- }, failed("Cannot read the GitHub profile")),
89854
+ }, rejected$1("Cannot read the GitHub profile")),
89743
89855
  start: fn("GitHub.start")(function* (flow) {
89744
89856
  const state = yield* nonce;
89745
89857
  const verifier = yield* nonce;
@@ -89759,7 +89871,7 @@ var GitHub = class GitHub extends Service$1()("@deslop/auth/services/github/serv
89759
89871
  state,
89760
89872
  url: url.href
89761
89873
  };
89762
- }, failed("Cannot start GitHub sign-in"))
89874
+ }, rejected$1("Cannot start GitHub sign-in"))
89763
89875
  });
89764
89876
  }));
89765
89877
  };
@@ -110911,989 +111023,30 @@ async function verifyAuthenticationResponse(options) {
110911
111023
  };
110912
111024
  }
110913
111025
  // src/services/tokens/lib/utils.ts
110914
- var import_ipaddr = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module, this$1) => {
110915
- (function(root) {
110916
- "use strict";
110917
- const ipv4Part = "(0?\\d+|0x[a-f0-9]+)";
110918
- const ipv4Regexes = {
110919
- fourOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, "i"),
110920
- threeOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, "i"),
110921
- twoOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}$`, "i"),
110922
- longValue: new RegExp(`^${ipv4Part}$`, "i")
110923
- };
110924
- const octalRegex = new RegExp(`^0[0-7]+$`, "i");
110925
- const hexRegex = new RegExp(`^0x[a-f0-9]+$`, "i");
110926
- const zoneIndex = "%[0-9a-z]{1,}";
110927
- const ipv6Part = "(?:[0-9a-f]+::?)+";
110928
- const ipv6Regexes = {
110929
- zoneIndex: new RegExp(zoneIndex, "i"),
110930
- "native": new RegExp(`^(::)?(${ipv6Part})?([0-9a-f]+)?(::)?(${zoneIndex})?$`, "i"),
110931
- deprecatedTransitional: new RegExp(`^(?:::)(${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?)$`, "i"),
110932
- transitional: new RegExp(`^((?:${ipv6Part})|(?:::)(?:${ipv6Part})?)${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?$`, "i")
110933
- };
110934
- function expandIPv6(string, parts) {
110935
- if (string.indexOf("::") !== string.lastIndexOf("::")) return null;
110936
- let colonCount = 0;
110937
- let lastColon = -1;
110938
- let zoneId = (string.match(ipv6Regexes.zoneIndex) || [])[0];
110939
- let replacement, replacementCount;
110940
- if (zoneId) {
110941
- zoneId = zoneId.substring(1);
110942
- string = string.replace(/%.+$/, "");
110943
- }
110944
- while ((lastColon = string.indexOf(":", lastColon + 1)) >= 0) colonCount++;
110945
- if (string.substr(0, 2) === "::") colonCount--;
110946
- if (string.substr(-2, 2) === "::") colonCount--;
110947
- if (colonCount >= parts) return null;
110948
- replacementCount = parts - colonCount;
110949
- replacement = ":";
110950
- while (replacementCount--) replacement += "0:";
110951
- string = string.replace("::", replacement);
110952
- if (string[0] === ":") string = string.slice(1);
110953
- if (string[string.length - 1] === ":") string = string.slice(0, -1);
110954
- parts = (function() {
110955
- const ref = string.split(":");
110956
- const results = [];
110957
- for (let i = 0; i < ref.length; i++) results.push(ref[i].length > 4 ? NaN : parseInt(ref[i], 16));
110958
- return results;
110959
- })();
110960
- return {
110961
- parts,
110962
- zoneId
110963
- };
110964
- }
110965
- function matchCIDR(first, second, partSize, cidrBits) {
110966
- if (first.length !== second.length) throw new Error("ipaddr: cannot match CIDR for objects with different lengths");
110967
- let part = 0;
110968
- let shift;
110969
- while (cidrBits > 0) {
110970
- shift = partSize - cidrBits;
110971
- if (shift < 0) shift = 0;
110972
- if (first[part] >> shift !== second[part] >> shift) return false;
110973
- cidrBits -= partSize;
110974
- part += 1;
110975
- }
110976
- return true;
110977
- }
110978
- function parseIntAuto(string) {
110979
- if (hexRegex.test(string)) return parseInt(string, 16);
110980
- if (string[0] === "0" && !isNaN(parseInt(string[1], 10))) {
110981
- if (octalRegex.test(string)) return parseInt(string, 8);
110982
- throw new Error(`ipaddr: cannot parse ${string} as octal`);
110983
- }
110984
- return parseInt(string, 10);
110985
- }
110986
- function padPart(part, length) {
110987
- while (part.length < length) part = `0${part}`;
110988
- return part;
110989
- }
110990
- const ipaddr = {};
110991
- ipaddr.IPv4 = (function() {
110992
- function IPv4(octets) {
110993
- if (octets.length !== 4) throw new Error("ipaddr: ipv4 octet count should be 4");
110994
- let i, octet;
110995
- for (i = 0; i < octets.length; i++) {
110996
- octet = octets[i];
110997
- if (!(0 <= octet && octet <= 255)) throw new Error("ipaddr: ipv4 octet should fit in 8 bits");
110998
- }
110999
- this.octets = octets;
111000
- }
111001
- IPv4.prototype.SpecialRanges = {
111002
- unspecified: [[new IPv4([
111003
- 0,
111004
- 0,
111005
- 0,
111006
- 0
111007
- ]), 8]],
111008
- broadcast: [[new IPv4([
111009
- 255,
111010
- 255,
111011
- 255,
111012
- 255
111013
- ]), 32]],
111014
- multicast: [[new IPv4([
111015
- 224,
111016
- 0,
111017
- 0,
111018
- 0
111019
- ]), 4]],
111020
- linkLocal: [[new IPv4([
111021
- 169,
111022
- 254,
111023
- 0,
111024
- 0
111025
- ]), 16]],
111026
- loopback: [[new IPv4([
111027
- 127,
111028
- 0,
111029
- 0,
111030
- 0
111031
- ]), 8]],
111032
- carrierGradeNat: [[new IPv4([
111033
- 100,
111034
- 64,
111035
- 0,
111036
- 0
111037
- ]), 10]],
111038
- "private": [
111039
- [new IPv4([
111040
- 10,
111041
- 0,
111042
- 0,
111043
- 0
111044
- ]), 8],
111045
- [new IPv4([
111046
- 172,
111047
- 16,
111048
- 0,
111049
- 0
111050
- ]), 12],
111051
- [new IPv4([
111052
- 192,
111053
- 168,
111054
- 0,
111055
- 0
111056
- ]), 16]
111057
- ],
111058
- reserved: [
111059
- [new IPv4([
111060
- 192,
111061
- 0,
111062
- 0,
111063
- 0
111064
- ]), 24],
111065
- [new IPv4([
111066
- 192,
111067
- 0,
111068
- 2,
111069
- 0
111070
- ]), 24],
111071
- [new IPv4([
111072
- 192,
111073
- 88,
111074
- 99,
111075
- 0
111076
- ]), 24],
111077
- [new IPv4([
111078
- 198,
111079
- 18,
111080
- 0,
111081
- 0
111082
- ]), 15],
111083
- [new IPv4([
111084
- 198,
111085
- 51,
111086
- 100,
111087
- 0
111088
- ]), 24],
111089
- [new IPv4([
111090
- 203,
111091
- 0,
111092
- 113,
111093
- 0
111094
- ]), 24],
111095
- [new IPv4([
111096
- 240,
111097
- 0,
111098
- 0,
111099
- 0
111100
- ]), 4]
111101
- ],
111102
- as112: [[new IPv4([
111103
- 192,
111104
- 175,
111105
- 48,
111106
- 0
111107
- ]), 24], [new IPv4([
111108
- 192,
111109
- 31,
111110
- 196,
111111
- 0
111112
- ]), 24]],
111113
- amt: [[new IPv4([
111114
- 192,
111115
- 52,
111116
- 193,
111117
- 0
111118
- ]), 24]]
111119
- };
111120
- IPv4.prototype.kind = function() {
111121
- return "ipv4";
111122
- };
111123
- IPv4.prototype.match = function(other, cidrRange) {
111124
- let ref;
111125
- if (cidrRange === void 0) {
111126
- ref = other;
111127
- other = ref[0];
111128
- cidrRange = ref[1];
111129
- }
111130
- if (other.kind() !== "ipv4") throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");
111131
- return matchCIDR(this.octets, other.octets, 8, cidrRange);
111132
- };
111133
- IPv4.prototype.prefixLengthFromSubnetMask = function() {
111134
- let cidr = 0;
111135
- let stop = false;
111136
- const zerotable = {
111137
- 0: 8,
111138
- 128: 7,
111139
- 192: 6,
111140
- 224: 5,
111141
- 240: 4,
111142
- 248: 3,
111143
- 252: 2,
111144
- 254: 1,
111145
- 255: 0
111146
- };
111147
- let i, octet, zeros;
111148
- for (i = 3; i >= 0; i -= 1) {
111149
- octet = this.octets[i];
111150
- if (octet in zerotable) {
111151
- zeros = zerotable[octet];
111152
- if (stop && zeros !== 0) return null;
111153
- if (zeros !== 8) stop = true;
111154
- cidr += zeros;
111155
- } else return null;
111156
- }
111157
- return 32 - cidr;
111158
- };
111159
- IPv4.prototype.range = function() {
111160
- return ipaddr.subnetMatch(this, this.SpecialRanges);
111161
- };
111162
- IPv4.prototype.toByteArray = function() {
111163
- return this.octets.slice(0);
111164
- };
111165
- IPv4.prototype.toIPv4MappedAddress = function() {
111166
- return ipaddr.IPv6.parse(`::ffff:${this.toString()}`);
111167
- };
111168
- IPv4.prototype.toNormalizedString = function() {
111169
- return this.toString();
111170
- };
111171
- IPv4.prototype.toString = function() {
111172
- return this.octets.join(".");
111173
- };
111174
- return IPv4;
111175
- })();
111176
- ipaddr.IPv4.broadcastAddressFromCIDR = function(string) {
111177
- try {
111178
- const cidr = this.parseCIDR(string);
111179
- const ipInterfaceOctets = cidr[0].toByteArray();
111180
- const subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
111181
- const octets = [];
111182
- let i = 0;
111183
- while (i < 4) {
111184
- octets.push(parseInt(ipInterfaceOctets[i], 10) | parseInt(subnetMaskOctets[i], 10) ^ 255);
111185
- i++;
111186
- }
111187
- return new this(octets);
111188
- } catch (e) {
111189
- throw new Error("ipaddr: the address does not have IPv4 CIDR format", { cause: e });
111190
- }
111191
- };
111192
- ipaddr.IPv4.isIPv4 = function(string) {
111193
- return this.parser(string) !== null;
111194
- };
111195
- ipaddr.IPv4.isValid = function(string) {
111196
- try {
111197
- new this(this.parser(string));
111198
- return true;
111199
- } catch {
111200
- return false;
111201
- }
111202
- };
111203
- ipaddr.IPv4.isValidCIDR = function(string) {
111204
- try {
111205
- this.parseCIDR(string);
111206
- return true;
111207
- } catch {
111208
- return false;
111209
- }
111210
- };
111211
- ipaddr.IPv4.isValidFourPartDecimal = function(string) {
111212
- if (ipaddr.IPv4.isValid(string) && string.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/)) return true;
111213
- else return false;
111214
- };
111215
- ipaddr.IPv4.isValidCIDRFourPartDecimal = function(string) {
111216
- const match = string.match(/^(.+)\/(\d+)$/);
111217
- if (!ipaddr.IPv4.isValidCIDR(string) || !match) return false;
111218
- return ipaddr.IPv4.isValidFourPartDecimal(match[1]);
111219
- };
111220
- ipaddr.IPv4.networkAddressFromCIDR = function(string) {
111221
- let cidr, i, ipInterfaceOctets, octets, subnetMaskOctets;
111222
- try {
111223
- cidr = this.parseCIDR(string);
111224
- ipInterfaceOctets = cidr[0].toByteArray();
111225
- subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
111226
- octets = [];
111227
- i = 0;
111228
- while (i < 4) {
111229
- octets.push(parseInt(ipInterfaceOctets[i], 10) & parseInt(subnetMaskOctets[i], 10));
111230
- i++;
111231
- }
111232
- return new this(octets);
111233
- } catch (e) {
111234
- throw new Error("ipaddr: the address does not have IPv4 CIDR format", { cause: e });
111235
- }
111236
- };
111237
- ipaddr.IPv4.parse = function(string) {
111238
- const parts = this.parser(string);
111239
- if (parts === null) throw new Error("ipaddr: string is not formatted like an IPv4 Address");
111240
- return new this(parts);
111241
- };
111242
- ipaddr.IPv4.parseCIDR = function(string) {
111243
- let match;
111244
- if (match = string.match(/^(.+)\/(\d+)$/)) {
111245
- const maskLength = parseInt(match[2]);
111246
- if (maskLength >= 0 && maskLength <= 32) {
111247
- const parsed = [this.parse(match[1]), maskLength];
111248
- Object.defineProperty(parsed, "toString", { value: function() {
111249
- return this.join("/");
111250
- } });
111251
- return parsed;
111252
- }
111253
- }
111254
- throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range");
111255
- };
111256
- ipaddr.IPv4.parser = function(string) {
111257
- let match, part, value;
111258
- if (match = string.match(ipv4Regexes.fourOctet)) return (function() {
111259
- const ref = match.slice(1, 6);
111260
- const results = [];
111261
- for (let i = 0; i < ref.length; i++) {
111262
- part = ref[i];
111263
- results.push(parseIntAuto(part));
111264
- }
111265
- return results;
111266
- })();
111267
- else if (match = string.match(ipv4Regexes.longValue)) {
111268
- value = parseIntAuto(match[1]);
111269
- if (value > 4294967295 || value < 0) throw new Error("ipaddr: address outside defined range");
111270
- return (function() {
111271
- const results = [];
111272
- let shift = 0;
111273
- for (; shift <= 24; shift += 8) results.push(value >> shift & 255);
111274
- return results;
111275
- })().reverse();
111276
- } else if (match = string.match(ipv4Regexes.twoOctet)) return (function() {
111277
- const ref = match.slice(1, 4);
111278
- const results = [];
111279
- value = parseIntAuto(ref[1]);
111280
- if (value > 16777215 || value < 0) throw new Error("ipaddr: address outside defined range");
111281
- results.push(parseIntAuto(ref[0]));
111282
- results.push(value >> 16 & 255);
111283
- results.push(value >> 8 & 255);
111284
- results.push(value & 255);
111285
- return results;
111286
- })();
111287
- else if (match = string.match(ipv4Regexes.threeOctet)) return (function() {
111288
- const ref = match.slice(1, 5);
111289
- const results = [];
111290
- value = parseIntAuto(ref[2]);
111291
- if (value > 65535 || value < 0) throw new Error("ipaddr: address outside defined range");
111292
- results.push(parseIntAuto(ref[0]));
111293
- results.push(parseIntAuto(ref[1]));
111294
- results.push(value >> 8 & 255);
111295
- results.push(value & 255);
111296
- return results;
111297
- })();
111298
- else return null;
111299
- };
111300
- ipaddr.IPv4.subnetMaskFromPrefixLength = function(prefix) {
111301
- prefix = parseInt(prefix);
111302
- if (Number.isNaN(prefix) || prefix < 0 || prefix > 32) throw new Error("ipaddr: invalid IPv4 prefix length");
111303
- const octets = [
111304
- 0,
111305
- 0,
111306
- 0,
111307
- 0
111308
- ];
111309
- let j = 0;
111310
- const filledOctetCount = Math.floor(prefix / 8);
111311
- while (j < filledOctetCount) {
111312
- octets[j] = 255;
111313
- j++;
111314
- }
111315
- if (filledOctetCount < 4) octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - prefix % 8;
111316
- return new this(octets);
111317
- };
111318
- ipaddr.IPv6 = (function() {
111319
- function IPv6(parts, zoneId) {
111320
- let i, part;
111321
- if (parts.length === 16) {
111322
- this.parts = [];
111323
- for (i = 0; i <= 14; i += 2) this.parts.push(parts[i] << 8 | parts[i + 1]);
111324
- } else if (parts.length === 8) this.parts = parts;
111325
- else throw new Error("ipaddr: ipv6 part count should be 8 or 16");
111326
- for (i = 0; i < this.parts.length; i++) {
111327
- part = this.parts[i];
111328
- if (!(0 <= part && part <= 65535)) throw new Error("ipaddr: ipv6 part should fit in 16 bits");
111329
- }
111330
- if (zoneId) this.zoneId = zoneId;
111331
- }
111332
- IPv6.prototype.SpecialRanges = {
111333
- unspecified: [new IPv6([
111334
- 0,
111335
- 0,
111336
- 0,
111337
- 0,
111338
- 0,
111339
- 0,
111340
- 0,
111341
- 0
111342
- ]), 128],
111343
- linkLocal: [new IPv6([
111344
- 65152,
111345
- 0,
111346
- 0,
111347
- 0,
111348
- 0,
111349
- 0,
111350
- 0,
111351
- 0
111352
- ]), 10],
111353
- multicast: [new IPv6([
111354
- 65280,
111355
- 0,
111356
- 0,
111357
- 0,
111358
- 0,
111359
- 0,
111360
- 0,
111361
- 0
111362
- ]), 8],
111363
- loopback: [new IPv6([
111364
- 0,
111365
- 0,
111366
- 0,
111367
- 0,
111368
- 0,
111369
- 0,
111370
- 0,
111371
- 1
111372
- ]), 128],
111373
- uniqueLocal: [new IPv6([
111374
- 64512,
111375
- 0,
111376
- 0,
111377
- 0,
111378
- 0,
111379
- 0,
111380
- 0,
111381
- 0
111382
- ]), 7],
111383
- ipv4Mapped: [new IPv6([
111384
- 0,
111385
- 0,
111386
- 0,
111387
- 0,
111388
- 0,
111389
- 65535,
111390
- 0,
111391
- 0
111392
- ]), 96],
111393
- deprecatedSiteLocal: [new IPv6([
111394
- 65216,
111395
- 0,
111396
- 0,
111397
- 0,
111398
- 0,
111399
- 0,
111400
- 0,
111401
- 0
111402
- ]), 10],
111403
- discard: [new IPv6([
111404
- 256,
111405
- 0,
111406
- 0,
111407
- 0,
111408
- 0,
111409
- 0,
111410
- 0,
111411
- 0
111412
- ]), 64],
111413
- rfc6145: [new IPv6([
111414
- 0,
111415
- 0,
111416
- 0,
111417
- 0,
111418
- 65535,
111419
- 0,
111420
- 0,
111421
- 0
111422
- ]), 96],
111423
- rfc6052: [[new IPv6([
111424
- 100,
111425
- 65435,
111426
- 0,
111427
- 0,
111428
- 0,
111429
- 0,
111430
- 0,
111431
- 0
111432
- ]), 96], [new IPv6([
111433
- 100,
111434
- 65435,
111435
- 1,
111436
- 0,
111437
- 0,
111438
- 0,
111439
- 0,
111440
- 0
111441
- ]), 48]],
111442
- "6to4": [new IPv6([
111443
- 8194,
111444
- 0,
111445
- 0,
111446
- 0,
111447
- 0,
111448
- 0,
111449
- 0,
111450
- 0
111451
- ]), 16],
111452
- teredo: [new IPv6([
111453
- 8193,
111454
- 0,
111455
- 0,
111456
- 0,
111457
- 0,
111458
- 0,
111459
- 0,
111460
- 0
111461
- ]), 32],
111462
- benchmarking: [new IPv6([
111463
- 8193,
111464
- 2,
111465
- 0,
111466
- 0,
111467
- 0,
111468
- 0,
111469
- 0,
111470
- 0
111471
- ]), 48],
111472
- amt: [new IPv6([
111473
- 8193,
111474
- 3,
111475
- 0,
111476
- 0,
111477
- 0,
111478
- 0,
111479
- 0,
111480
- 0
111481
- ]), 32],
111482
- as112v6: [[new IPv6([
111483
- 8193,
111484
- 4,
111485
- 274,
111486
- 0,
111487
- 0,
111488
- 0,
111489
- 0,
111490
- 0
111491
- ]), 48], [new IPv6([
111492
- 9760,
111493
- 79,
111494
- 32768,
111495
- 0,
111496
- 0,
111497
- 0,
111498
- 0,
111499
- 0
111500
- ]), 48]],
111501
- deprecatedOrchid: [new IPv6([
111502
- 8193,
111503
- 16,
111504
- 0,
111505
- 0,
111506
- 0,
111507
- 0,
111508
- 0,
111509
- 0
111510
- ]), 28],
111511
- orchid2: [new IPv6([
111512
- 8193,
111513
- 32,
111514
- 0,
111515
- 0,
111516
- 0,
111517
- 0,
111518
- 0,
111519
- 0
111520
- ]), 28],
111521
- droneRemoteIdProtocolEntityTags: [new IPv6([
111522
- 8193,
111523
- 48,
111524
- 0,
111525
- 0,
111526
- 0,
111527
- 0,
111528
- 0,
111529
- 0
111530
- ]), 28],
111531
- segmentRouting: [new IPv6([
111532
- 24320,
111533
- 0,
111534
- 0,
111535
- 0,
111536
- 0,
111537
- 0,
111538
- 0,
111539
- 0
111540
- ]), 16],
111541
- reserved: [
111542
- [new IPv6([
111543
- 8193,
111544
- 0,
111545
- 0,
111546
- 0,
111547
- 0,
111548
- 0,
111549
- 0,
111550
- 0
111551
- ]), 23],
111552
- [new IPv6([
111553
- 8193,
111554
- 3512,
111555
- 0,
111556
- 0,
111557
- 0,
111558
- 0,
111559
- 0,
111560
- 0
111561
- ]), 32],
111562
- [new IPv6([
111563
- 16383,
111564
- 0,
111565
- 0,
111566
- 0,
111567
- 0,
111568
- 0,
111569
- 0,
111570
- 0
111571
- ]), 20]
111572
- ]
111573
- };
111574
- IPv6.prototype.isIPv4MappedAddress = function() {
111575
- return this.range() === "ipv4Mapped";
111576
- };
111577
- IPv6.prototype.kind = function() {
111578
- return "ipv6";
111579
- };
111580
- IPv6.prototype.match = function(other, cidrRange) {
111581
- let ref;
111582
- if (cidrRange === void 0) {
111583
- ref = other;
111584
- other = ref[0];
111585
- cidrRange = ref[1];
111586
- }
111587
- if (other.kind() !== "ipv6") throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");
111588
- return matchCIDR(this.parts, other.parts, 16, cidrRange);
111589
- };
111590
- IPv6.prototype.prefixLengthFromSubnetMask = function() {
111591
- let cidr = 0;
111592
- let stop = false;
111593
- const zerotable = {
111594
- 0: 16,
111595
- 32768: 15,
111596
- 49152: 14,
111597
- 57344: 13,
111598
- 61440: 12,
111599
- 63488: 11,
111600
- 64512: 10,
111601
- 65024: 9,
111602
- 65280: 8,
111603
- 65408: 7,
111604
- 65472: 6,
111605
- 65504: 5,
111606
- 65520: 4,
111607
- 65528: 3,
111608
- 65532: 2,
111609
- 65534: 1,
111610
- 65535: 0
111611
- };
111612
- let part, zeros;
111613
- for (let i = 7; i >= 0; i -= 1) {
111614
- part = this.parts[i];
111615
- if (part in zerotable) {
111616
- zeros = zerotable[part];
111617
- if (stop && zeros !== 0) return null;
111618
- if (zeros !== 16) stop = true;
111619
- cidr += zeros;
111620
- } else return null;
111621
- }
111622
- return 128 - cidr;
111623
- };
111624
- IPv6.prototype.range = function() {
111625
- return ipaddr.subnetMatch(this, this.SpecialRanges);
111626
- };
111627
- IPv6.prototype.toByteArray = function() {
111628
- let part;
111629
- const bytes = [];
111630
- const ref = this.parts;
111631
- for (let i = 0; i < ref.length; i++) {
111632
- part = ref[i];
111633
- bytes.push(part >> 8);
111634
- bytes.push(part & 255);
111635
- }
111636
- return bytes;
111637
- };
111638
- IPv6.prototype.toFixedLengthString = function() {
111639
- const addr = (function() {
111640
- const results = [];
111641
- for (let i = 0; i < this.parts.length; i++) results.push(padPart(this.parts[i].toString(16), 4));
111642
- return results;
111643
- }).call(this).join(":");
111644
- let suffix = "";
111645
- if (this.zoneId) suffix = `%${this.zoneId}`;
111646
- return addr + suffix;
111647
- };
111648
- IPv6.prototype.toIPv4Address = function() {
111649
- if (!this.isIPv4MappedAddress()) throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");
111650
- const ref = this.parts.slice(-2);
111651
- const high = ref[0];
111652
- const low = ref[1];
111653
- return new ipaddr.IPv4([
111654
- high >> 8,
111655
- high & 255,
111656
- low >> 8,
111657
- low & 255
111658
- ]);
111659
- };
111660
- IPv6.prototype.toNormalizedString = function() {
111661
- const addr = (function() {
111662
- const results = [];
111663
- for (let i = 0; i < this.parts.length; i++) results.push(this.parts[i].toString(16));
111664
- return results;
111665
- }).call(this).join(":");
111666
- let suffix = "";
111667
- if (this.zoneId) suffix = `%${this.zoneId}`;
111668
- return addr + suffix;
111669
- };
111670
- IPv6.prototype.toRFC5952String = function() {
111671
- const regex = /((^|:)(0(:|$)){2,})/g;
111672
- let suffix = "";
111673
- if (this.zoneId) suffix = `%${this.zoneId}`;
111674
- const normalized = this.toNormalizedString();
111675
- const string = normalized.slice(0, normalized.length - suffix.length);
111676
- let bestMatchIndex = 0;
111677
- let bestMatchLength = -1;
111678
- let bestMatchGroups = -1;
111679
- let match;
111680
- while (match = regex.exec(string)) {
111681
- const groups = (match[0].match(/0/g) || []).length;
111682
- if (groups > bestMatchGroups) {
111683
- bestMatchGroups = groups;
111684
- bestMatchIndex = match.index;
111685
- bestMatchLength = match[0].length;
111686
- }
111687
- }
111688
- if (bestMatchLength < 0) return string + suffix;
111689
- return `${string.substring(0, bestMatchIndex)}::${string.substring(bestMatchIndex + bestMatchLength)}${suffix}`;
111690
- };
111691
- IPv6.prototype.toString = function() {
111692
- return this.toRFC5952String();
111693
- };
111694
- return IPv6;
111695
- })();
111696
- ipaddr.IPv6.broadcastAddressFromCIDR = function(string) {
111697
- try {
111698
- const cidr = this.parseCIDR(string);
111699
- const ipInterfaceOctets = cidr[0].toByteArray();
111700
- const subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
111701
- const octets = [];
111702
- let i = 0;
111703
- while (i < 16) {
111704
- octets.push(parseInt(ipInterfaceOctets[i], 10) | parseInt(subnetMaskOctets[i], 10) ^ 255);
111705
- i++;
111706
- }
111707
- return new this(octets);
111708
- } catch (e) {
111709
- throw new Error("ipaddr: the address does not have IPv6 CIDR format", { cause: e });
111710
- }
111711
- };
111712
- ipaddr.IPv6.isIPv6 = function(string) {
111713
- return this.parser(string) !== null;
111714
- };
111715
- ipaddr.IPv6.isValid = function(string) {
111716
- if (typeof string === "string" && string.indexOf(":") === -1) return false;
111717
- try {
111718
- const addr = this.parser(string);
111719
- new this(addr.parts, addr.zoneId);
111720
- return true;
111721
- } catch {
111722
- return false;
111723
- }
111724
- };
111725
- ipaddr.IPv6.isValidCIDR = function(string) {
111726
- if (typeof string === "string" && string.indexOf(":") === -1) return false;
111727
- try {
111728
- this.parseCIDR(string);
111729
- return true;
111730
- } catch {
111731
- return false;
111732
- }
111733
- };
111734
- ipaddr.IPv6.networkAddressFromCIDR = function(string) {
111735
- let cidr, i, ipInterfaceOctets, octets, subnetMaskOctets;
111736
- try {
111737
- cidr = this.parseCIDR(string);
111738
- ipInterfaceOctets = cidr[0].toByteArray();
111739
- subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
111740
- octets = [];
111741
- i = 0;
111742
- while (i < 16) {
111743
- octets.push(parseInt(ipInterfaceOctets[i], 10) & parseInt(subnetMaskOctets[i], 10));
111744
- i++;
111745
- }
111746
- return new this(octets);
111747
- } catch (e) {
111748
- throw new Error("ipaddr: the address does not have IPv6 CIDR format", { cause: e });
111749
- }
111750
- };
111751
- ipaddr.IPv6.parse = function(string) {
111752
- const addr = this.parser(string);
111753
- if (addr === null) throw new Error("ipaddr: string is not formatted like an IPv6 Address");
111754
- return new this(addr.parts, addr.zoneId);
111755
- };
111756
- ipaddr.IPv6.parseCIDR = function(string) {
111757
- let maskLength, match, parsed;
111758
- if (match = string.match(/^(.+)\/(\d+)$/)) {
111759
- maskLength = parseInt(match[2]);
111760
- if (maskLength >= 0 && maskLength <= 128) {
111761
- parsed = [this.parse(match[1]), maskLength];
111762
- Object.defineProperty(parsed, "toString", { value: function() {
111763
- return this.join("/");
111764
- } });
111765
- return parsed;
111766
- }
111767
- }
111768
- throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range");
111769
- };
111770
- ipaddr.IPv6.parser = function(string) {
111771
- let addr, i, match, octet, octets, zoneId;
111772
- if (match = string.match(ipv6Regexes.deprecatedTransitional)) return this.parser(`::ffff:${match[1]}`);
111773
- if (ipv6Regexes.native.test(string)) return expandIPv6(string, 8);
111774
- if (match = string.match(ipv6Regexes.transitional)) {
111775
- zoneId = match[6] || "";
111776
- addr = match[1];
111777
- if (!match[1].endsWith("::")) addr = addr.slice(0, -1);
111778
- addr = expandIPv6(addr + zoneId, 6);
111779
- if (addr && addr.parts) {
111780
- octets = [
111781
- parseInt(match[2]),
111782
- parseInt(match[3]),
111783
- parseInt(match[4]),
111784
- parseInt(match[5])
111785
- ];
111786
- for (i = 0; i < octets.length; i++) {
111787
- octet = octets[i];
111788
- if (!(0 <= octet && octet <= 255)) return null;
111789
- }
111790
- addr.parts.push(octets[0] << 8 | octets[1]);
111791
- addr.parts.push(octets[2] << 8 | octets[3]);
111792
- return {
111793
- parts: addr.parts,
111794
- zoneId: addr.zoneId
111795
- };
111796
- }
111797
- }
111798
- return null;
111799
- };
111800
- ipaddr.IPv6.subnetMaskFromPrefixLength = function(prefix) {
111801
- prefix = parseInt(prefix);
111802
- if (Number.isNaN(prefix) || prefix < 0 || prefix > 128) throw new Error("ipaddr: invalid IPv6 prefix length");
111803
- const octets = [
111804
- 0,
111805
- 0,
111806
- 0,
111807
- 0,
111808
- 0,
111809
- 0,
111810
- 0,
111811
- 0,
111812
- 0,
111813
- 0,
111814
- 0,
111815
- 0,
111816
- 0,
111817
- 0,
111818
- 0,
111819
- 0
111820
- ];
111821
- let j = 0;
111822
- const filledOctetCount = Math.floor(prefix / 8);
111823
- while (j < filledOctetCount) {
111824
- octets[j] = 255;
111825
- j++;
111826
- }
111827
- if (filledOctetCount < 16) octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - prefix % 8;
111828
- return new this(octets);
111829
- };
111830
- ipaddr.fromByteArray = function(bytes) {
111831
- const length = bytes.length;
111832
- if (length === 4) return new ipaddr.IPv4(bytes);
111833
- else if (length === 16) return new ipaddr.IPv6(bytes);
111834
- else throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address");
111835
- };
111836
- ipaddr.isValid = function(string) {
111837
- return ipaddr.IPv6.isValid(string) || ipaddr.IPv4.isValid(string);
111838
- };
111839
- ipaddr.isValidCIDR = function(string) {
111840
- return ipaddr.IPv6.isValidCIDR(string) || ipaddr.IPv4.isValidCIDR(string);
111841
- };
111842
- ipaddr.parse = function(string) {
111843
- if (ipaddr.IPv6.isValid(string)) return ipaddr.IPv6.parse(string);
111844
- else if (ipaddr.IPv4.isValid(string)) return ipaddr.IPv4.parse(string);
111845
- else throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format");
111846
- };
111847
- ipaddr.parseCIDR = function(string) {
111848
- try {
111849
- return ipaddr.IPv6.parseCIDR(string);
111850
- } catch {
111851
- try {
111852
- return ipaddr.IPv4.parseCIDR(string);
111853
- } catch (e) {
111854
- throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format", { cause: e });
111855
- }
111856
- }
111857
- };
111858
- ipaddr.process = function(string) {
111859
- const addr = this.parse(string);
111860
- if (addr.kind() === "ipv6" && addr.isIPv4MappedAddress()) return addr.toIPv4Address();
111861
- else return addr;
111862
- };
111863
- ipaddr.subnetMatch = function(address, rangeList, defaultName) {
111864
- let i, rangeName, rangeSubnets, subnet;
111865
- if (defaultName === void 0 || defaultName === null) defaultName = "unicast";
111866
- for (rangeName in rangeList) if (Object.prototype.hasOwnProperty.call(rangeList, rangeName)) {
111867
- rangeSubnets = rangeList[rangeName];
111868
- if (rangeSubnets[0] && !(rangeSubnets[0] instanceof Array)) rangeSubnets = [rangeSubnets];
111869
- for (i = 0; i < rangeSubnets.length; i++) {
111870
- subnet = rangeSubnets[i];
111871
- if (address.kind() === subnet[0].kind() && address.match.apply(address, subnet)) return rangeName;
111872
- }
111873
- }
111874
- return defaultName;
111875
- };
111876
- if (typeof module !== "undefined" && module.exports) module.exports = ipaddr;
111877
- else root.ipaddr = ipaddr;
111878
- })(this$1);
111879
- })))(), 1);
111880
111026
  const WORKERS = {
111881
111027
  "77.237.236.132": "dev",
111882
111028
  "100.68.201.107": "dev",
111883
111029
  "100.97.120.3": "desktop",
111884
111030
  "100.115.207.60": "macbook-pro"
111885
111031
  };
111886
- const LOCAL_RANGES = [
111887
- "linkLocal",
111888
- "loopback",
111889
- "private",
111890
- "uniqueLocal"
111891
- ];
111032
+ function parsedAddress(address) {
111033
+ return pipe(getSuccess(ipFromString(address)), map$11((ip) => {
111034
+ if (isIpv6Address(ip)) return getOrElse(fromIpv4Mapped(ip), () => ip);
111035
+ return ip;
111036
+ }));
111037
+ }
111038
+ function isPrivate(ip) {
111039
+ if (isIpv4Address(ip)) return isPrivate$1(ip);
111040
+ return isUniqueLocal(ip);
111041
+ }
111892
111042
  function addressGroup(address) {
111893
- if (!import_ipaddr.default.isValid(address)) return address;
111894
- const parsed = import_ipaddr.default.process(address);
111895
- if (parsed.kind() === "ipv4") return parsed.toString();
111896
- return join$2(take$3(split$1(parsed.toNormalizedString(), ":"), 4), ":");
111043
+ return match$8(parsedAddress(address), {
111044
+ onNone: () => address,
111045
+ onSome: (ip) => {
111046
+ if (isIpv4Address(ip)) return formatIp(ip);
111047
+ return join$2(map$8(take$3(ipv6ToSegments(ip), 4), (segment) => segment.toString(16)), ":");
111048
+ }
111049
+ });
111897
111050
  }
111898
111051
  function clientAddress(headers, remote) {
111899
111052
  return pipe(get$6(headers, "x-forwarded-for"), flatMap$7((forwarded) => last(split$1(",")(forwarded))), map$11(trim), filter$8(isNonEmpty$1), orElse$3(() => remote));
@@ -111936,7 +111089,7 @@ function browserLabel(origin) {
111936
111089
  }
111937
111090
  function deviceLabel(origin) {
111938
111091
  return pipe(flatMap$7(fromUndefinedOr(origin.address), (address) => {
111939
- if (import_ipaddr.default.isValid(address) && contains(LOCAL_RANGES, import_ipaddr.default.process(address).range())) return some$1("dev");
111092
+ if (exists(parsedAddress(address), (ip) => isLinkLocal(ip) || isLoopback(ip) || isPrivate(ip))) return some$1("dev");
111940
111093
  return get$13(WORKERS, address);
111941
111094
  }), orElse$3(() => flatMap$7(fromUndefinedOr(origin.userAgent), platform)), getOrElse(() => origin.address ?? "unknown"));
111942
111095
  }
@@ -112022,15 +111175,6 @@ function returnable(next, url) {
112022
111175
  }
112023
111176
  // src/services/passkeys/service.ts
112024
111177
  const LIFETIME = 3e5;
112025
- function rejected$4(message) {
112026
- return mapError$2((cause) => {
112027
- if (is$2(AuthError)(cause)) return cause;
112028
- return AuthError.make({
112029
- cause,
112030
- message
112031
- });
112032
- });
112033
- }
112034
111178
  function invalid(cause) {
112035
111179
  return AuthError.make({
112036
111180
  cause,
@@ -112108,10 +111252,10 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
112108
111252
  transports,
112109
111253
  user
112110
111254
  }]);
112111
- }, rejected$4("Cannot add the passkey")),
111255
+ }, rejected$1("Cannot add the passkey")),
112112
111256
  forget: fn("Passkeys.forget")(function* (userId) {
112113
111257
  yield* change((current) => filter$6(current, (found) => found.user.id !== userId));
112114
- }, rejected$4("Cannot remove the account’s passkeys")),
111258
+ }, rejected$1("Cannot remove the account’s passkeys")),
112115
111259
  list: (user) => map$3(changes(state), (current) => map$8(filter$6(current, (found) => found.user.id === user.id), (found) => ({
112116
111260
  addedFrom: found.addedFrom,
112117
111261
  createdAt: found.createdAt,
@@ -112147,17 +111291,17 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
112147
111291
  expiresAt: now + LIFETIME
112148
111292
  }));
112149
111293
  return yield* decodeEffect(fromJsonString(CreationOptions))(yield* encodeUnknownEffect(fromJsonString(Unknown))(options));
112150
- }, rejected$4("Cannot start adding a passkey")),
111294
+ }, rejected$1("Cannot start adding a passkey")),
112151
111295
  remove: fn("Passkeys.remove")(function* (id, user) {
112152
111296
  yield* change((current) => filter$6(current, (found) => found.id !== id || found.user.id !== user.id));
112153
- }, rejected$4("Cannot remove the passkey")),
111297
+ }, rejected$1("Cannot remove the passkey")),
112154
111298
  request: pipe(tryPromise({
112155
111299
  catch: invalid,
112156
111300
  try: () => generateAuthenticationOptions({
112157
111301
  rpID,
112158
111302
  userVerification: "required"
112159
111303
  })
112160
- }), tap$1((options) => flatMap$2(currentTimeMillis, (now) => update$3(signingIn, (issued) => set$1(live$1(issued, now), options.challenge, { expiresAt: now + LIFETIME })))), flatMap$2(encodeUnknownEffect(fromJsonString(Unknown))), flatMap$2(decodeEffect(fromJsonString(RequestOptions))), rejected$4("Cannot start a passkey sign-in"), withSpan("Passkeys.request")),
111304
+ }), tap$1((options) => flatMap$2(currentTimeMillis, (now) => update$3(signingIn, (issued) => set$1(live$1(issued, now), options.challenge, { expiresAt: now + LIFETIME })))), flatMap$2(encodeUnknownEffect(fromJsonString(Unknown))), flatMap$2(decodeEffect(fromJsonString(RequestOptions))), rejected$1("Cannot start a passkey sign-in"), withSpan("Passkeys.request")),
112161
111305
  signIn: fn("Passkeys.signIn")(function* (response) {
112162
111306
  const challenge = yield* challengeOf(response.response.clientDataJSON);
112163
111307
  const now = yield* currentTimeMillis;
@@ -112190,21 +111334,12 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
112190
111334
  };
112191
111335
  }));
112192
111336
  return found.user;
112193
- }, rejected$4("Cannot sign in with the passkey"))
111337
+ }, rejected$1("Cannot sign in with the passkey"))
112194
111338
  });
112195
111339
  }));
112196
111340
  };
112197
111341
  // src/services/tokens/service.ts
112198
111342
  const SESSION_COOKIE = "__Secure-session";
112199
- function rejected$3(message) {
112200
- return mapError$2((cause) => {
112201
- if (is$2(AuthError)(cause)) return cause;
112202
- return AuthError.make({
112203
- cause,
112204
- message
112205
- });
112206
- });
112207
- }
112208
111343
  const expired$1 = AuthError.make({
112209
111344
  error: "invalid_grant",
112210
111345
  message: "The authorization expired. Sign in again."
@@ -112266,7 +111401,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
112266
111401
  user: found.grant.user,
112267
111402
  via: found.grant.credential.via ?? "Code"
112268
111403
  };
112269
- }, rejected$3("Sign in first"));
111404
+ }, rejected$1("Sign in first"));
112270
111405
  const session = fn("Tokens.session")(function* (headers) {
112271
111406
  return (yield* browser(headers)).user;
112272
111407
  });
@@ -112278,7 +111413,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
112278
111413
  const found = yield* grantOf(token);
112279
111414
  if (found.grant.credential._tag !== "App" || !some(found.grant.credential.access, (entry) => entry.hash === found.hash && contains(entry.resources, resource))) return yield* AuthError.make({ message: "The token is not valid for this app" });
112280
111415
  return found.grant.user;
112281
- }, rejected$3("Sign in first"));
111416
+ }, rejected$1("Sign in first"));
112282
111417
  const mint = fnUntraced(function* (family, generation, resources, now) {
112283
111418
  const accessSecret = yield* secret(32);
112284
111419
  const refreshSecret = yield* secret(32);
@@ -112434,22 +111569,22 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
112434
111569
  if (!exists(get$13(current, family), (grant) => grant.user.id === user.id)) return yield* AuthError.make({ message: "This sign-in has already ended" });
112435
111570
  return [void 0, remove$6(current, family)];
112436
111571
  }));
112437
- }, rejected$3("Cannot sign this out")),
111572
+ }, rejected$1("Cannot sign this out")),
112438
111573
  endSession: fn("Tokens.endSession")(function* (headers) {
112439
111574
  const found = yield* option$1(grantOf(parseHeader(headers["cookie"] ?? "")["__Secure-session"] ?? ""));
112440
111575
  yield* match$8(filter$8(found, (current) => current.grant.credential.hash === current.hash), {
112441
111576
  onNone: () => void_$1,
112442
111577
  onSome: (own) => change((saved) => succeed$5([void 0, remove$6(saved, own.family)]))
112443
111578
  });
112444
- }, rejected$3("Cannot sign out")),
111579
+ }, rejected$1("Cannot sign out")),
112445
111580
  exchange: fn("Tokens.exchange")(function* (params, origin, allowed) {
112446
111581
  if (params.grant_type === "authorization_code") return yield* redeem(params, origin, allowed);
112447
111582
  return yield* rotate(params, origin, allowed);
112448
- }, rejected$3("Invalid token request")),
111583
+ }, rejected$1("Invalid token request")),
112449
111584
  forget: fn("Tokens.forget")(function* (id) {
112450
111585
  yield* change((current) => succeed$5([void 0, filter$7(current, (grant) => grant.user.id !== id)]));
112451
111586
  yield* update$3(codes, filter((entry) => entry.state._tag === "Used" || entry.state.user.id !== id));
112452
- }, rejected$3("Cannot sign this account out")),
111587
+ }, rejected$1("Cannot sign this account out")),
112453
111588
  issue: fn("Tokens.issue")(function* (request, user) {
112454
111589
  const code = yield* secret(32);
112455
111590
  const key = yield* hash(code);
@@ -112463,7 +111598,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
112463
111598
  }
112464
111599
  }));
112465
111600
  return code;
112466
- }, rejected$3("Cannot issue the authorization code")),
111601
+ }, rejected$1("Cannot issue the authorization code")),
112467
111602
  revoke: fn("Tokens.revoke")(function* (params) {
112468
111603
  yield* match$8(parts(params.token), {
112469
111604
  onNone: () => void_$1,
@@ -112475,7 +111610,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
112475
111610
  })]));
112476
111611
  })
112477
111612
  });
112478
- }, rejected$3("Cannot revoke the token")),
111613
+ }, rejected$1("Cannot revoke the token")),
112479
111614
  session,
112480
111615
  sessionVia,
112481
111616
  startSession: fn("Tokens.startSession")(function* (user, origin, via) {
@@ -112504,7 +111639,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
112504
111639
  seconds,
112505
111640
  token: `${family}.${sessionSecret}`
112506
111641
  };
112507
- }, rejected$3("Cannot start the session"))
111642
+ }, rejected$1("Cannot start the session"))
112508
111643
  });
112509
111644
  }));
112510
111645
  };
@@ -112514,15 +111649,6 @@ const ROLE_ORDER = {
112514
111649
  Member: 2,
112515
111650
  Waiting: 1
112516
111651
  };
112517
- function rejected$2(message) {
112518
- return mapError$2((cause) => {
112519
- if (is$2(AuthError)(cause)) return cause;
112520
- return AuthError.make({
112521
- cause,
112522
- message
112523
- });
112524
- });
112525
- }
112526
111652
  function memberOf(github, since, status) {
112527
111653
  return {
112528
111654
  fullName: github.name ?? "",
@@ -112542,16 +111668,12 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
112542
111668
  const tokens = yield* Tokens;
112543
111669
  const passkeys = yield* Passkeys;
112544
111670
  const github = yield* GitHub;
112545
- const listed = Array$1(String$6, "GITHUB_ADMINS");
112546
- const admins = yield* match$1(yield* localAuth, {
112547
- onFalse: () => listed,
112548
- onTrue: () => withDefault$2(listed, ["0"])
112549
- });
111671
+ const admins = yield* adminIds;
112550
111672
  const transact = fnUntraced(function* (change) {
112551
111673
  return yield* modifyEffect(state, (current) => tap$1(change(current), (result) => store.set("members", result[1])));
112552
111674
  }, uninterruptible);
112553
111675
  function roleOf(id, row) {
112554
- if (contains(admins, replace("github:", "")(id))) return "Admin";
111676
+ if (isAdmin(admins, id)) return "Admin";
112555
111677
  if (exists(row, (found) => found.status === "Allowed")) return "Member";
112556
111678
  return "Waiting";
112557
111679
  }
@@ -112577,7 +111699,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
112577
111699
  return user;
112578
111700
  });
112579
111701
  const admin = fnUntraced(function* (user) {
112580
- if (roleOf(user.id, none()) !== "Admin") return yield* AuthError.make({
111702
+ if (!isAdmin(admins, user.id)) return yield* AuthError.make({
112581
111703
  error: "access_denied",
112582
111704
  message: "Only an admin can manage people"
112583
111705
  });
@@ -112591,7 +111713,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
112591
111713
  role: "Admin",
112592
111714
  since: 0
112593
111715
  })), ...known], mapInput(Order$4, (person) => ROLE_ORDER[person.role]));
112594
- }, rejected$2("Cannot read people"));
111716
+ }, rejected$1("Cannot read people"));
112595
111717
  yield* pipe(forEach$1(admins, fnUntraced(function* (id) {
112596
111718
  if (isSome(member(`github:${id}`, yield* get(state)))) return;
112597
111719
  const profile = yield* github.profile(id);
@@ -112621,7 +111743,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
112621
111743
  via: session.via
112622
111744
  })
112623
111745
  });
112624
- }), rejected$2("Cannot read the account")))),
111746
+ }), rejected$1("Cannot read the account")))),
112625
111747
  admin,
112626
111748
  admit: fn("People.admit")(function* (params, user) {
112627
111749
  yield* admin(user);
@@ -112648,7 +111770,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
112648
111770
  yield* passkeys.forget(params.id);
112649
111771
  }
112650
111772
  return person;
112651
- }, rejected$2("Cannot answer the access request")),
111773
+ }, rejected$1("Cannot answer the access request")),
112652
111774
  allowed: fn("People.allowed")(allowed),
112653
111775
  list,
112654
111776
  people: (user) => mapEffect$1(changes(state), () => list(user)),
@@ -112674,7 +111796,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
112674
111796
  })
112675
111797
  })]);
112676
111798
  });
112677
- }, rejected$2("Cannot record the GitHub account")),
111799
+ }, rejected$1("Cannot record the GitHub account")),
112678
111800
  remove: fn("People.remove")(function* (id, user) {
112679
111801
  yield* admin(user);
112680
111802
  if (roleOf(id, none()) === "Admin") return yield* AuthError.make({ message: "Admins come from GITHUB_ADMINS, so they cannot be removed here" });
@@ -112683,7 +111805,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
112683
111805
  yield* tokens.forget(id);
112684
111806
  yield* passkeys.forget(id);
112685
111807
  return found;
112686
- }, rejected$2("Cannot remove this account"))
111808
+ }, rejected$1("Cannot remove this account"))
112687
111809
  });
112688
111810
  return pipe(make$85(People, people), merge$4(Auth.makeContext(Auth.of({
112689
111811
  access: fn("Auth.access")(function* (headers, resource) {
@@ -120005,15 +119127,6 @@ const waitFor = waitFor$1;
120005
119127
  const start = start$1;
120006
119128
  // src/services/sign-ins/service.ts
120007
119129
  const REQUEST_COOKIE = "__Host-request-";
120008
- function rejected$1(message) {
120009
- return mapError$2((cause) => {
120010
- if (is$2(AuthError)(cause)) return cause;
120011
- return AuthError.make({
120012
- cause,
120013
- message
120014
- });
120015
- });
120016
- }
120017
119130
  const expired = AuthError.make({ message: "This sign-in expired. Start it again in the app." });
120018
119131
  const notWaiting = AuthError.make({ message: "No waiting sign-in has this code: it is mistyped, already answered or expired after 10 minutes. Read the code again from the page or command that is still waiting; start a new sign-in only if none is." });
120019
119132
  const deliver = fnUntraced(function* (input) {
@@ -120272,7 +119385,6 @@ const COOKIE = {
120272
119385
  secure: true
120273
119386
  };
120274
119387
  const LOGIN_COOKIE = "__Host-login";
120275
- const ISSUER = `${AUTH_URL}/api/auth`;
120276
119388
  function sessionCookie(local) {
120277
119389
  if (local) return {
120278
119390
  ...COOKIE,
@@ -120283,15 +119395,6 @@ function sessionCookie(local) {
120283
119395
  domain: cookieDomain(AUTH_URL)
120284
119396
  };
120285
119397
  }
120286
- function rejected(message) {
120287
- return mapError$2((cause) => {
120288
- if (is$2(AuthError)(cause)) return cause;
120289
- return AuthError.make({
120290
- cause,
120291
- message
120292
- });
120293
- });
120294
- }
120295
119398
  function oauth(handler) {
120296
119399
  return pipe(handler, catchIf(is$2(AuthError), (failure) => succeed$5(jsonUnsafe({
120297
119400
  error: failure.error ?? "invalid_request",
@@ -120301,6 +119404,9 @@ function oauth(handler) {
120301
119404
  function originOf(request) {
120302
119405
  return originFrom(request.headers, request.remoteAddress);
120303
119406
  }
119407
+ function answered(answer) {
119408
+ return pipe(answer, flatMap$2((user) => schemaJson(User)(user, { headers: { "cache-control": "no-store" } })), orElseSucceed(() => empty({ status: 401 })));
119409
+ }
120304
119410
  function waitingAt(started) {
120305
119411
  return setCookieUnsafe(redirect(`/?request=${started.code}`), `${REQUEST_COOKIE}${started.code}`, started.receiver, {
120306
119412
  ...COOKIE,
@@ -120365,11 +119471,11 @@ const HttpHandlers = use((router) => gen(function* () {
120365
119471
  }));
120366
119472
  });
120367
119473
  }
120368
- yield* router.add("POST", "/api/apps", limited("apps", 10)(pipe(gen(function* () {
120369
- const params = yield* pipe(schemaBodyJson(AppParams), rejected("Send the app’s origin"));
119474
+ yield* router.add("POST", APPS_PATH, limited("apps", 10)(pipe(gen(function* () {
119475
+ const params = yield* pipe(schemaBodyJson(AppParams), rejected$1("Send the app’s origin"));
120370
119476
  return yield* schemaJson(App)(yield* apps.register(params.origin));
120371
119477
  }), catchIf(is$2(AuthError), (failure) => succeed$5(text(failure.message, { status: 403 }))))));
120372
- yield* router.add("GET", "/.well-known/oauth-authorization-server/api/auth", jsonUnsafe({
119478
+ yield* router.add("GET", `/.well-known/oauth-authorization-server${ISSUER_PATH}`, jsonUnsafe({
120373
119479
  authorization_endpoint: `${ISSUER}/oauth2/authorize`,
120374
119480
  authorization_response_iss_parameter_supported: true,
120375
119481
  code_challenge_methods_supported: ["S256"],
@@ -120382,7 +119488,7 @@ const HttpHandlers = use((router) => gen(function* () {
120382
119488
  token_endpoint: `${ISSUER}/oauth2/token`,
120383
119489
  token_endpoint_auth_methods_supported: ["none"]
120384
119490
  }));
120385
- yield* router.add("POST", "/api/auth/oauth2/register", limited("register", 10)(oauth(gen(function* () {
119491
+ yield* router.add("POST", `${ISSUER_PATH}/oauth2/register`, limited("register", 10)(oauth(gen(function* () {
120386
119492
  const params = yield* pipe(schemaBodyJson(Registration$1), mapError$2((cause) => AuthError.make({
120387
119493
  cause,
120388
119494
  error: "invalid_client_metadata",
@@ -120405,11 +119511,11 @@ const HttpHandlers = use((router) => gen(function* () {
120405
119511
  token_endpoint_auth_method: "none"
120406
119512
  }, { status: 201 });
120407
119513
  }))));
120408
- yield* router.add("GET", "/api/auth/oauth2/authorize", limited("authorize", 20)(oauth(gen(function* () {
119514
+ yield* router.add("GET", `${ISSUER_PATH}/oauth2/authorize`, limited("authorize", 20)(oauth(gen(function* () {
120409
119515
  const request = yield* HttpServerRequest;
120410
- const asked = yield* pipe(schemaSearchParams(AuthorizeClient), rejected("The authorization request names no client_id"));
119516
+ const asked = yield* pipe(schemaSearchParams(AuthorizeClient), rejected$1("The authorization request names no client_id"));
120411
119517
  const client = yield* tokens.client(asked);
120412
- return yield* pipe(schemaSearchParams(AuthorizeParams), rejected("Invalid authorization request"), flatMap$2((params) => clientRequest(asked, client, params)), flatMap$2((checked) => signIns.start({
119518
+ return yield* pipe(schemaSearchParams(AuthorizeParams), rejected$1("Invalid authorization request"), flatMap$2((params) => clientRequest(asked, client, params)), flatMap$2((checked) => signIns.start({
120413
119519
  _tag: "Client",
120414
119520
  request: checked
120415
119521
  }, originOf(request))), map$5(waitingAt), catchIf(is$2(AuthError), (failure) => succeed$5(redirect(callbackUrl({
@@ -120420,13 +119526,13 @@ const HttpHandlers = use((router) => gen(function* () {
120420
119526
  error_description: failure.message
120421
119527
  })))));
120422
119528
  }))));
120423
- yield* router.add("POST", "/api/auth/oauth2/token", limited("token", 60)(oauth(gen(function* () {
120424
- const grant = yield* pipe(schemaBodyUrlParams(TokenGrant), rejected("Send a grant_type"));
119529
+ yield* router.add("POST", `${ISSUER_PATH}/oauth2/token`, limited("token", 60)(oauth(gen(function* () {
119530
+ const grant = yield* pipe(schemaBodyUrlParams(TokenGrant), rejected$1("Send a grant_type"));
120425
119531
  if (grant.grant_type !== "authorization_code" && grant.grant_type !== "refresh_token") return yield* AuthError.make({
120426
119532
  error: "unsupported_grant_type",
120427
119533
  message: "Use grant_type authorization_code or refresh_token"
120428
119534
  });
120429
- return valueTags(yield* tokens.exchange(yield* pipe(schemaBodyUrlParams(TokenParams), rejected("Invalid token request")), originOf(yield* HttpServerRequest), people.allowed), {
119535
+ return valueTags(yield* tokens.exchange(yield* pipe(schemaBodyUrlParams(TokenParams), rejected$1("Invalid token request")), originOf(yield* HttpServerRequest), people.allowed), {
120430
119536
  Granted: (granted) => jsonUnsafe(granted.tokens),
120431
119537
  Replayed: (replayed) => jsonUnsafe({
120432
119538
  error: "invalid_grant",
@@ -120434,31 +119540,31 @@ const HttpHandlers = use((router) => gen(function* () {
120434
119540
  }, { status: 400 })
120435
119541
  });
120436
119542
  }))));
120437
- yield* router.add("POST", "/api/auth/oauth2/revoke", limited("revoke", 60)(oauth(gen(function* () {
120438
- yield* tokens.revoke(yield* pipe(schemaBodyUrlParams(RevokeParams), rejected("Invalid revocation request")));
119543
+ yield* router.add("POST", `${ISSUER_PATH}/oauth2/revoke`, limited("revoke", 60)(oauth(gen(function* () {
119544
+ yield* tokens.revoke(yield* pipe(schemaBodyUrlParams(RevokeParams), rejected$1("Invalid revocation request")));
120439
119545
  return empty();
120440
119546
  }))));
120441
- yield* router.add("GET", "/auth/session", pipe(flatMap$2(HttpServerRequest, (request) => auth.user(request.headers)), flatMap$2((user) => schemaJson(User)(user, { headers: { "cache-control": "no-store" } })), orElseSucceed(() => empty({ status: 401 }))));
120442
- yield* router.add("GET", "/auth/verify", pipe(gen(function* () {
119547
+ yield* router.add("GET", SESSION_PATH, answered(flatMap$2(HttpServerRequest, (request) => auth.user(request.headers))));
119548
+ yield* router.add("GET", VERIFY_PATH, answered(gen(function* () {
120443
119549
  const params = yield* schemaSearchParams(VerificationParams);
120444
119550
  return yield* auth.access((yield* HttpServerRequest).headers, params.resource);
120445
- }), flatMap$2((user) => schemaJson(User)(user, { headers: { "cache-control": "no-store" } })), orElseSucceed(() => empty({ status: 401 }))));
119551
+ })));
120446
119552
  yield* router.add("GET", "/auth/github", limited("github", 10)(oauth(gen(function* () {
120447
- const started = yield* github.start(yield* pipe(schemaSearchParams(SignInParams), rejected("Invalid sign-in request")));
119553
+ const started = yield* github.start(yield* pipe(schemaSearchParams(SignInParams), rejected$1("Invalid sign-in request")));
120448
119554
  return setCookieUnsafe(redirect(started.url), LOGIN_COOKIE, started.state, {
120449
119555
  ...COOKIE,
120450
119556
  maxAge: "10 minutes"
120451
119557
  });
120452
119558
  }))));
120453
119559
  yield* router.add("GET", "/auth/github/callback", pipe(gen(function* () {
120454
- const params = yield* pipe(schemaSearchParams(CallbackParams), rejected("GitHub sent no code"));
119560
+ const params = yield* pipe(schemaSearchParams(CallbackParams), rejected$1("GitHub sent no code"));
120455
119561
  if ((yield* HttpServerRequest).cookies[LOGIN_COOKIE] !== params.state) return yield* AuthError.make({ message: "The sign-in state does not match" });
120456
119562
  const request = yield* HttpServerRequest;
120457
119563
  const finished = yield* github.finish(params.code, params.state);
120458
119564
  return yield* pipe(people.register(finished.profile), tap$1(() => tokens.endSession(request.headers)), flatMap$2((user) => tokens.startSession(user, originOf(request), "GitHub")), map$5((started) => pipe(redirect(returnTo(finished.flow)), expireCookieUnsafe(LOGIN_COOKIE, COOKIE), setCookieUnsafe(SESSION_COOKIE, started.token, session(started.seconds)))), catch_$2((cause) => githubFailed(cause, some$1(finished.flow))));
120459
119565
  }), catch_$2((cause) => flatMap$2(option$1(flatMap$2(schemaSearchParams(LoginState), (found) => github.cancel(found.state))), (flow) => githubFailed(cause, flow)))));
120460
119566
  yield* router.add("GET", "/auth/code", limited("code", 20)(oauth(gen(function* () {
120461
- const next = (yield* pipe(schemaSearchParams(BrowserParams), rejected("Invalid sign-in request"))).next;
119567
+ const next = (yield* pipe(schemaSearchParams(BrowserParams), rejected$1("Invalid sign-in request"))).next;
120462
119568
  return waitingAt(yield* signIns.start({
120463
119569
  _tag: "Browser",
120464
119570
  ...pipe(fromUndefinedOr(next), filter$8((page) => returnable(page, AUTH_URL)), match$8({
@@ -120470,7 +119576,7 @@ const HttpHandlers = use((router) => gen(function* () {
120470
119576
  yield* router.add("GET", "/auth/passkey", limited("passkey", 20)(oauth(map$5(passkeys.request, (options) => jsonUnsafe(options)))));
120471
119577
  yield* router.add("POST", "/auth/passkey", limited("passkey", 20)(oauth(gen(function* () {
120472
119578
  const request = yield* HttpServerRequest;
120473
- const input = yield* pipe(schemaBodyJson(PasskeySignIn), rejected("Send the passkey’s answer"));
119579
+ const input = yield* pipe(schemaBodyJson(PasskeySignIn), rejected$1("Send the passkey’s answer"));
120474
119580
  const started = yield* tokens.startSession(yield* people.allowed(yield* passkeys.signIn(input.response)), originOf(request), "Passkey");
120475
119581
  return setCookieUnsafe(jsonUnsafe(match$8(filter$8(fromUndefinedOr(input.next), (page) => returnable(page, AUTH_URL)), {
120476
119582
  onNone: () => ({}),
@@ -120479,7 +119585,7 @@ const HttpHandlers = use((router) => gen(function* () {
120479
119585
  }))));
120480
119586
  yield* router.add("GET", "/auth/continue", pipe(gen(function* () {
120481
119587
  const request = yield* HttpServerRequest;
120482
- const params = yield* pipe(schemaSearchParams(RequestParams), rejected("Name the sign-in"));
119588
+ const params = yield* pipe(schemaSearchParams(RequestParams), rejected$1("Name the sign-in"));
120483
119589
  const collected = yield* signIns.collect(params.request, request.headers);
120484
119590
  const cookie = `${REQUEST_COOKIE}${typedCode(params.request)}`;
120485
119591
  return valueTags(collected, {
@@ -120490,7 +119596,7 @@ const HttpHandlers = use((router) => gen(function* () {
120490
119596
  status: 408
120491
119597
  })
120492
119598
  });
120493
- }), rejected("Cannot complete the sign-in"), catch_$2((failure) => succeed$5(text(failure.message, { status: 400 }))), map$5(setHeader("cache-control", "no-store"))));
119599
+ }), rejected$1("Cannot complete the sign-in"), catch_$2((failure) => succeed$5(text(failure.message, { status: 400 }))), map$5(setHeader("cache-control", "no-store"))));
120494
119600
  yield* router.add("POST", "/auth/sign-out", oauth(gen(function* () {
120495
119601
  yield* tokens.endSession((yield* HttpServerRequest).headers);
120496
119602
  return expireCookieUnsafe(empty(), SESSION_COOKIE, sessionCookie(local));
@@ -120613,20 +119719,19 @@ const ToolHandlers = Tools.toLayer(gen(function* () {
120613
119719
  return yield* signIns.answer(input, yield* CurrentUser, "Token");
120614
119720
  }) });
120615
119721
  }));
120616
- const layerMcp = layerMcp$1({
120617
- instructions: "Approve a sign-in you started with answer_request.",
120618
- registrations: pipe(toolkit(Tools), provide$2(ToolHandlers))
120619
- });
120620
119722
  // src/main.server.ts
120621
119723
  const layerServices = pipe(mergeAll$1(SignIns.layer, layer$3), provideMerge(People.layer), provideMerge(mergeAll$1(Tokens.layer, Passkeys.layer, GitHub.layer, Apps.layer, layerStoreMemory)), provide$2(layerDataStore), provide$2(succeed$6(RequestInit, { redirect: "error" })));
120622
119724
  runApp({
120623
119725
  icon: icon_default,
120624
119726
  middleware: (app) => map$5(app, setHeader("content-security-policy", "frame-ancestors 'none'")),
120625
- routes: pipe(mergeAll$1(HttpHandlers, pipe(layerHttp$1({
119727
+ routes: pipe(mergeAll$1(HttpHandlers, layerRpc({
120626
119728
  group: RpcContracts,
120627
- path: "/api/rpc",
120628
- protocol: "websocket"
120629
- }), provide$2(RpcHandlers)), layerMcp), provide$2(layerServices)),
119729
+ handlers: RpcHandlers
119730
+ }), layerMcp({
119731
+ handlers: ToolHandlers,
119732
+ instructions: "Approve a sign-in you started with answer_request.",
119733
+ tools: Tools
119734
+ })), provide$2(layerServices)),
120630
119735
  settings: {
120631
119736
  GITHUB_ADMINS: ADMINS,
120632
119737
  GITHUB_CLIENT_ID: {