@deslop/auth 0.1.1241 → 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/README.md +1 -1
- package/dist/client/assets/(home)-BGXsZG4J.js +20 -0
- package/dist/client/assets/{badge-CXIN133Y.js → badge-nWdL2b3k.js} +1 -1
- package/dist/client/assets/components-DV4T0fPT.js +1 -0
- package/dist/client/assets/effect-CHiRDGLl.js +17 -0
- package/dist/client/assets/index-DXaJ5Qfh.js +2 -0
- package/dist/client/assets/people-Ih_KuuYv.js +1 -0
- package/dist/client/assets/route-CruIEHrm.js +1 -0
- package/dist/client/assets/toast-B08W4mtG.js +3 -0
- package/dist/client/index.html +3 -3
- package/dist/server.js +342 -1238
- package/package.json +2 -2
- package/dist/client/assets/(home)-ChK4Bm3J.js +0 -20
- package/dist/client/assets/components-D9wzNB0x.js +0 -1
- package/dist/client/assets/effect--GriK3-G.js +0 -17
- package/dist/client/assets/index-SSOFSSvQ.js +0 -2
- package/dist/client/assets/people-g3dSfQ29.js +0 -1
- package/dist/client/assets/route-BgzSkZVC.js +0 -1
- package/dist/client/assets/toast-jmpTfttq.js +0 -3
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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
|
-
|
|
78544
|
-
|
|
78545
|
-
|
|
78546
|
-
|
|
78547
|
-
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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
|
|
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(
|
|
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
|
|
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(
|
|
88961
|
-
}, rejected
|
|
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(
|
|
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",
|
|
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(
|
|
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",
|
|
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
|
|
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(
|
|
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:
|
|
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",
|
|
89218
|
-
authorization_servers: [new URL(
|
|
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"]
|
|
@@ -89345,7 +89474,7 @@ const update$1 = fnUntraced(function* (name) {
|
|
|
89345
89474
|
yield* activate(name, path.join(directory, "node_modules", "@deslop", name));
|
|
89346
89475
|
yield* restart(name);
|
|
89347
89476
|
const kept = [latest, ...toArray(map$11(previous, (link) => path.basename(path.resolve(link, "../../.."))))];
|
|
89348
|
-
yield* forEach$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 });
|
|
89349
89478
|
return `Updated ${name} from ${running} to ${latest}\n`;
|
|
89350
89479
|
});
|
|
89351
89480
|
// ../../packages/runtime/src/cli.ts
|
|
@@ -89454,15 +89583,6 @@ const App = Struct({
|
|
|
89454
89583
|
const Catalog = ArraySchema(App);
|
|
89455
89584
|
const AppParams = Struct({ origin: SecureOrigin });
|
|
89456
89585
|
// src/services/apps/service.ts
|
|
89457
|
-
function rejected$5(message) {
|
|
89458
|
-
return mapError$2((cause) => {
|
|
89459
|
-
if (is$2(AuthError)(cause)) return cause;
|
|
89460
|
-
return AuthError.make({
|
|
89461
|
-
cause,
|
|
89462
|
-
message
|
|
89463
|
-
});
|
|
89464
|
-
});
|
|
89465
|
-
}
|
|
89466
89586
|
var Apps = class Apps extends Service$1()("@deslop/auth/services/apps/service/Apps") {
|
|
89467
89587
|
static layer = effect(this, gen(function* () {
|
|
89468
89588
|
const store = toSchemaStore(yield* KeyValueStore, Catalog);
|
|
@@ -89477,12 +89597,12 @@ var Apps = class Apps extends Service$1()("@deslop/auth/services/apps/service/Ap
|
|
|
89477
89597
|
error: "access_denied",
|
|
89478
89598
|
message: `Only apps on ${domain} are listed`
|
|
89479
89599
|
});
|
|
89480
|
-
const runtime = yield* pipe(client.get(new URL(
|
|
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}`));
|
|
89481
89601
|
if (!exists(fromUndefinedOr(runtime.auth), (auth) => new URL(auth).origin === self.origin)) return yield* AuthError.make({
|
|
89482
89602
|
error: "access_denied",
|
|
89483
89603
|
message: `${origin} signs in elsewhere`
|
|
89484
89604
|
});
|
|
89485
|
-
const web = yield* pipe(client.get(new URL(
|
|
89605
|
+
const web = yield* pipe(client.get(new URL(MANIFEST_PATH, origin).href), timeout("10 seconds"), as(true), orElseSucceed(() => false));
|
|
89486
89606
|
const app = App.make({
|
|
89487
89607
|
name: runtime.name,
|
|
89488
89608
|
open: match$1(web, {
|
|
@@ -89494,7 +89614,7 @@ var Apps = class Apps extends Service$1()("@deslop/auth/services/apps/service/Ap
|
|
|
89494
89614
|
yield* pipe(modifyEffect(state, (current) => {
|
|
89495
89615
|
const next = sort([...filter$6(current, (known) => known.origin !== app.origin), app], mapInput(Order$3, (known) => known.name));
|
|
89496
89616
|
return as(store.set("apps", next), [void 0, next]);
|
|
89497
|
-
}), uninterruptible, rejected$
|
|
89617
|
+
}), uninterruptible, rejected$1("The app list could not be saved"));
|
|
89498
89618
|
return app;
|
|
89499
89619
|
})
|
|
89500
89620
|
});
|
|
@@ -89666,15 +89786,6 @@ const DEVELOPER_PROFILE = GitHubUser.make({
|
|
|
89666
89786
|
id: 0,
|
|
89667
89787
|
login: DEVELOPER.name
|
|
89668
89788
|
});
|
|
89669
|
-
function failed(message) {
|
|
89670
|
-
return mapError$2((cause) => {
|
|
89671
|
-
if (is$2(AuthError)(cause)) return cause;
|
|
89672
|
-
return AuthError.make({
|
|
89673
|
-
cause,
|
|
89674
|
-
message
|
|
89675
|
-
});
|
|
89676
|
-
});
|
|
89677
|
-
}
|
|
89678
89789
|
var GitHub = class GitHub extends Service$1()("@deslop/auth/services/github/service/GitHub") {
|
|
89679
89790
|
static layer = effect(GitHub, gen(function* () {
|
|
89680
89791
|
const random = yield* SecureRandom;
|
|
@@ -89737,10 +89848,10 @@ var GitHub = class GitHub extends Service$1()("@deslop/auth/services/github/serv
|
|
|
89737
89848
|
flow,
|
|
89738
89849
|
profile: yield* user(bearerToken(get$3("https://api.github.com/user"), token.access_token))
|
|
89739
89850
|
};
|
|
89740
|
-
},
|
|
89851
|
+
}, rejected$1("GitHub sign-in failed")),
|
|
89741
89852
|
profile: fn("GitHub.profile")(function* (id) {
|
|
89742
89853
|
return yield* user(get$3(`https://api.github.com/user/${id}`));
|
|
89743
|
-
},
|
|
89854
|
+
}, rejected$1("Cannot read the GitHub profile")),
|
|
89744
89855
|
start: fn("GitHub.start")(function* (flow) {
|
|
89745
89856
|
const state = yield* nonce;
|
|
89746
89857
|
const verifier = yield* nonce;
|
|
@@ -89760,7 +89871,7 @@ var GitHub = class GitHub extends Service$1()("@deslop/auth/services/github/serv
|
|
|
89760
89871
|
state,
|
|
89761
89872
|
url: url.href
|
|
89762
89873
|
};
|
|
89763
|
-
},
|
|
89874
|
+
}, rejected$1("Cannot start GitHub sign-in"))
|
|
89764
89875
|
});
|
|
89765
89876
|
}));
|
|
89766
89877
|
};
|
|
@@ -110912,989 +111023,30 @@ async function verifyAuthenticationResponse(options) {
|
|
|
110912
111023
|
};
|
|
110913
111024
|
}
|
|
110914
111025
|
// src/services/tokens/lib/utils.ts
|
|
110915
|
-
var import_ipaddr = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module, this$1) => {
|
|
110916
|
-
(function(root) {
|
|
110917
|
-
"use strict";
|
|
110918
|
-
const ipv4Part = "(0?\\d+|0x[a-f0-9]+)";
|
|
110919
|
-
const ipv4Regexes = {
|
|
110920
|
-
fourOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, "i"),
|
|
110921
|
-
threeOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}$`, "i"),
|
|
110922
|
-
twoOctet: new RegExp(`^${ipv4Part}\\.${ipv4Part}$`, "i"),
|
|
110923
|
-
longValue: new RegExp(`^${ipv4Part}$`, "i")
|
|
110924
|
-
};
|
|
110925
|
-
const octalRegex = new RegExp(`^0[0-7]+$`, "i");
|
|
110926
|
-
const hexRegex = new RegExp(`^0x[a-f0-9]+$`, "i");
|
|
110927
|
-
const zoneIndex = "%[0-9a-z]{1,}";
|
|
110928
|
-
const ipv6Part = "(?:[0-9a-f]+::?)+";
|
|
110929
|
-
const ipv6Regexes = {
|
|
110930
|
-
zoneIndex: new RegExp(zoneIndex, "i"),
|
|
110931
|
-
"native": new RegExp(`^(::)?(${ipv6Part})?([0-9a-f]+)?(::)?(${zoneIndex})?$`, "i"),
|
|
110932
|
-
deprecatedTransitional: new RegExp(`^(?:::)(${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?)$`, "i"),
|
|
110933
|
-
transitional: new RegExp(`^((?:${ipv6Part})|(?:::)(?:${ipv6Part})?)${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}\\.${ipv4Part}(${zoneIndex})?$`, "i")
|
|
110934
|
-
};
|
|
110935
|
-
function expandIPv6(string, parts) {
|
|
110936
|
-
if (string.indexOf("::") !== string.lastIndexOf("::")) return null;
|
|
110937
|
-
let colonCount = 0;
|
|
110938
|
-
let lastColon = -1;
|
|
110939
|
-
let zoneId = (string.match(ipv6Regexes.zoneIndex) || [])[0];
|
|
110940
|
-
let replacement, replacementCount;
|
|
110941
|
-
if (zoneId) {
|
|
110942
|
-
zoneId = zoneId.substring(1);
|
|
110943
|
-
string = string.replace(/%.+$/, "");
|
|
110944
|
-
}
|
|
110945
|
-
while ((lastColon = string.indexOf(":", lastColon + 1)) >= 0) colonCount++;
|
|
110946
|
-
if (string.substr(0, 2) === "::") colonCount--;
|
|
110947
|
-
if (string.substr(-2, 2) === "::") colonCount--;
|
|
110948
|
-
if (colonCount >= parts) return null;
|
|
110949
|
-
replacementCount = parts - colonCount;
|
|
110950
|
-
replacement = ":";
|
|
110951
|
-
while (replacementCount--) replacement += "0:";
|
|
110952
|
-
string = string.replace("::", replacement);
|
|
110953
|
-
if (string[0] === ":") string = string.slice(1);
|
|
110954
|
-
if (string[string.length - 1] === ":") string = string.slice(0, -1);
|
|
110955
|
-
parts = (function() {
|
|
110956
|
-
const ref = string.split(":");
|
|
110957
|
-
const results = [];
|
|
110958
|
-
for (let i = 0; i < ref.length; i++) results.push(ref[i].length > 4 ? NaN : parseInt(ref[i], 16));
|
|
110959
|
-
return results;
|
|
110960
|
-
})();
|
|
110961
|
-
return {
|
|
110962
|
-
parts,
|
|
110963
|
-
zoneId
|
|
110964
|
-
};
|
|
110965
|
-
}
|
|
110966
|
-
function matchCIDR(first, second, partSize, cidrBits) {
|
|
110967
|
-
if (first.length !== second.length) throw new Error("ipaddr: cannot match CIDR for objects with different lengths");
|
|
110968
|
-
let part = 0;
|
|
110969
|
-
let shift;
|
|
110970
|
-
while (cidrBits > 0) {
|
|
110971
|
-
shift = partSize - cidrBits;
|
|
110972
|
-
if (shift < 0) shift = 0;
|
|
110973
|
-
if (first[part] >> shift !== second[part] >> shift) return false;
|
|
110974
|
-
cidrBits -= partSize;
|
|
110975
|
-
part += 1;
|
|
110976
|
-
}
|
|
110977
|
-
return true;
|
|
110978
|
-
}
|
|
110979
|
-
function parseIntAuto(string) {
|
|
110980
|
-
if (hexRegex.test(string)) return parseInt(string, 16);
|
|
110981
|
-
if (string[0] === "0" && !isNaN(parseInt(string[1], 10))) {
|
|
110982
|
-
if (octalRegex.test(string)) return parseInt(string, 8);
|
|
110983
|
-
throw new Error(`ipaddr: cannot parse ${string} as octal`);
|
|
110984
|
-
}
|
|
110985
|
-
return parseInt(string, 10);
|
|
110986
|
-
}
|
|
110987
|
-
function padPart(part, length) {
|
|
110988
|
-
while (part.length < length) part = `0${part}`;
|
|
110989
|
-
return part;
|
|
110990
|
-
}
|
|
110991
|
-
const ipaddr = {};
|
|
110992
|
-
ipaddr.IPv4 = (function() {
|
|
110993
|
-
function IPv4(octets) {
|
|
110994
|
-
if (octets.length !== 4) throw new Error("ipaddr: ipv4 octet count should be 4");
|
|
110995
|
-
let i, octet;
|
|
110996
|
-
for (i = 0; i < octets.length; i++) {
|
|
110997
|
-
octet = octets[i];
|
|
110998
|
-
if (!(0 <= octet && octet <= 255)) throw new Error("ipaddr: ipv4 octet should fit in 8 bits");
|
|
110999
|
-
}
|
|
111000
|
-
this.octets = octets;
|
|
111001
|
-
}
|
|
111002
|
-
IPv4.prototype.SpecialRanges = {
|
|
111003
|
-
unspecified: [[new IPv4([
|
|
111004
|
-
0,
|
|
111005
|
-
0,
|
|
111006
|
-
0,
|
|
111007
|
-
0
|
|
111008
|
-
]), 8]],
|
|
111009
|
-
broadcast: [[new IPv4([
|
|
111010
|
-
255,
|
|
111011
|
-
255,
|
|
111012
|
-
255,
|
|
111013
|
-
255
|
|
111014
|
-
]), 32]],
|
|
111015
|
-
multicast: [[new IPv4([
|
|
111016
|
-
224,
|
|
111017
|
-
0,
|
|
111018
|
-
0,
|
|
111019
|
-
0
|
|
111020
|
-
]), 4]],
|
|
111021
|
-
linkLocal: [[new IPv4([
|
|
111022
|
-
169,
|
|
111023
|
-
254,
|
|
111024
|
-
0,
|
|
111025
|
-
0
|
|
111026
|
-
]), 16]],
|
|
111027
|
-
loopback: [[new IPv4([
|
|
111028
|
-
127,
|
|
111029
|
-
0,
|
|
111030
|
-
0,
|
|
111031
|
-
0
|
|
111032
|
-
]), 8]],
|
|
111033
|
-
carrierGradeNat: [[new IPv4([
|
|
111034
|
-
100,
|
|
111035
|
-
64,
|
|
111036
|
-
0,
|
|
111037
|
-
0
|
|
111038
|
-
]), 10]],
|
|
111039
|
-
"private": [
|
|
111040
|
-
[new IPv4([
|
|
111041
|
-
10,
|
|
111042
|
-
0,
|
|
111043
|
-
0,
|
|
111044
|
-
0
|
|
111045
|
-
]), 8],
|
|
111046
|
-
[new IPv4([
|
|
111047
|
-
172,
|
|
111048
|
-
16,
|
|
111049
|
-
0,
|
|
111050
|
-
0
|
|
111051
|
-
]), 12],
|
|
111052
|
-
[new IPv4([
|
|
111053
|
-
192,
|
|
111054
|
-
168,
|
|
111055
|
-
0,
|
|
111056
|
-
0
|
|
111057
|
-
]), 16]
|
|
111058
|
-
],
|
|
111059
|
-
reserved: [
|
|
111060
|
-
[new IPv4([
|
|
111061
|
-
192,
|
|
111062
|
-
0,
|
|
111063
|
-
0,
|
|
111064
|
-
0
|
|
111065
|
-
]), 24],
|
|
111066
|
-
[new IPv4([
|
|
111067
|
-
192,
|
|
111068
|
-
0,
|
|
111069
|
-
2,
|
|
111070
|
-
0
|
|
111071
|
-
]), 24],
|
|
111072
|
-
[new IPv4([
|
|
111073
|
-
192,
|
|
111074
|
-
88,
|
|
111075
|
-
99,
|
|
111076
|
-
0
|
|
111077
|
-
]), 24],
|
|
111078
|
-
[new IPv4([
|
|
111079
|
-
198,
|
|
111080
|
-
18,
|
|
111081
|
-
0,
|
|
111082
|
-
0
|
|
111083
|
-
]), 15],
|
|
111084
|
-
[new IPv4([
|
|
111085
|
-
198,
|
|
111086
|
-
51,
|
|
111087
|
-
100,
|
|
111088
|
-
0
|
|
111089
|
-
]), 24],
|
|
111090
|
-
[new IPv4([
|
|
111091
|
-
203,
|
|
111092
|
-
0,
|
|
111093
|
-
113,
|
|
111094
|
-
0
|
|
111095
|
-
]), 24],
|
|
111096
|
-
[new IPv4([
|
|
111097
|
-
240,
|
|
111098
|
-
0,
|
|
111099
|
-
0,
|
|
111100
|
-
0
|
|
111101
|
-
]), 4]
|
|
111102
|
-
],
|
|
111103
|
-
as112: [[new IPv4([
|
|
111104
|
-
192,
|
|
111105
|
-
175,
|
|
111106
|
-
48,
|
|
111107
|
-
0
|
|
111108
|
-
]), 24], [new IPv4([
|
|
111109
|
-
192,
|
|
111110
|
-
31,
|
|
111111
|
-
196,
|
|
111112
|
-
0
|
|
111113
|
-
]), 24]],
|
|
111114
|
-
amt: [[new IPv4([
|
|
111115
|
-
192,
|
|
111116
|
-
52,
|
|
111117
|
-
193,
|
|
111118
|
-
0
|
|
111119
|
-
]), 24]]
|
|
111120
|
-
};
|
|
111121
|
-
IPv4.prototype.kind = function() {
|
|
111122
|
-
return "ipv4";
|
|
111123
|
-
};
|
|
111124
|
-
IPv4.prototype.match = function(other, cidrRange) {
|
|
111125
|
-
let ref;
|
|
111126
|
-
if (cidrRange === void 0) {
|
|
111127
|
-
ref = other;
|
|
111128
|
-
other = ref[0];
|
|
111129
|
-
cidrRange = ref[1];
|
|
111130
|
-
}
|
|
111131
|
-
if (other.kind() !== "ipv4") throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");
|
|
111132
|
-
return matchCIDR(this.octets, other.octets, 8, cidrRange);
|
|
111133
|
-
};
|
|
111134
|
-
IPv4.prototype.prefixLengthFromSubnetMask = function() {
|
|
111135
|
-
let cidr = 0;
|
|
111136
|
-
let stop = false;
|
|
111137
|
-
const zerotable = {
|
|
111138
|
-
0: 8,
|
|
111139
|
-
128: 7,
|
|
111140
|
-
192: 6,
|
|
111141
|
-
224: 5,
|
|
111142
|
-
240: 4,
|
|
111143
|
-
248: 3,
|
|
111144
|
-
252: 2,
|
|
111145
|
-
254: 1,
|
|
111146
|
-
255: 0
|
|
111147
|
-
};
|
|
111148
|
-
let i, octet, zeros;
|
|
111149
|
-
for (i = 3; i >= 0; i -= 1) {
|
|
111150
|
-
octet = this.octets[i];
|
|
111151
|
-
if (octet in zerotable) {
|
|
111152
|
-
zeros = zerotable[octet];
|
|
111153
|
-
if (stop && zeros !== 0) return null;
|
|
111154
|
-
if (zeros !== 8) stop = true;
|
|
111155
|
-
cidr += zeros;
|
|
111156
|
-
} else return null;
|
|
111157
|
-
}
|
|
111158
|
-
return 32 - cidr;
|
|
111159
|
-
};
|
|
111160
|
-
IPv4.prototype.range = function() {
|
|
111161
|
-
return ipaddr.subnetMatch(this, this.SpecialRanges);
|
|
111162
|
-
};
|
|
111163
|
-
IPv4.prototype.toByteArray = function() {
|
|
111164
|
-
return this.octets.slice(0);
|
|
111165
|
-
};
|
|
111166
|
-
IPv4.prototype.toIPv4MappedAddress = function() {
|
|
111167
|
-
return ipaddr.IPv6.parse(`::ffff:${this.toString()}`);
|
|
111168
|
-
};
|
|
111169
|
-
IPv4.prototype.toNormalizedString = function() {
|
|
111170
|
-
return this.toString();
|
|
111171
|
-
};
|
|
111172
|
-
IPv4.prototype.toString = function() {
|
|
111173
|
-
return this.octets.join(".");
|
|
111174
|
-
};
|
|
111175
|
-
return IPv4;
|
|
111176
|
-
})();
|
|
111177
|
-
ipaddr.IPv4.broadcastAddressFromCIDR = function(string) {
|
|
111178
|
-
try {
|
|
111179
|
-
const cidr = this.parseCIDR(string);
|
|
111180
|
-
const ipInterfaceOctets = cidr[0].toByteArray();
|
|
111181
|
-
const subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
|
|
111182
|
-
const octets = [];
|
|
111183
|
-
let i = 0;
|
|
111184
|
-
while (i < 4) {
|
|
111185
|
-
octets.push(parseInt(ipInterfaceOctets[i], 10) | parseInt(subnetMaskOctets[i], 10) ^ 255);
|
|
111186
|
-
i++;
|
|
111187
|
-
}
|
|
111188
|
-
return new this(octets);
|
|
111189
|
-
} catch (e) {
|
|
111190
|
-
throw new Error("ipaddr: the address does not have IPv4 CIDR format", { cause: e });
|
|
111191
|
-
}
|
|
111192
|
-
};
|
|
111193
|
-
ipaddr.IPv4.isIPv4 = function(string) {
|
|
111194
|
-
return this.parser(string) !== null;
|
|
111195
|
-
};
|
|
111196
|
-
ipaddr.IPv4.isValid = function(string) {
|
|
111197
|
-
try {
|
|
111198
|
-
new this(this.parser(string));
|
|
111199
|
-
return true;
|
|
111200
|
-
} catch {
|
|
111201
|
-
return false;
|
|
111202
|
-
}
|
|
111203
|
-
};
|
|
111204
|
-
ipaddr.IPv4.isValidCIDR = function(string) {
|
|
111205
|
-
try {
|
|
111206
|
-
this.parseCIDR(string);
|
|
111207
|
-
return true;
|
|
111208
|
-
} catch {
|
|
111209
|
-
return false;
|
|
111210
|
-
}
|
|
111211
|
-
};
|
|
111212
|
-
ipaddr.IPv4.isValidFourPartDecimal = function(string) {
|
|
111213
|
-
if (ipaddr.IPv4.isValid(string) && string.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/)) return true;
|
|
111214
|
-
else return false;
|
|
111215
|
-
};
|
|
111216
|
-
ipaddr.IPv4.isValidCIDRFourPartDecimal = function(string) {
|
|
111217
|
-
const match = string.match(/^(.+)\/(\d+)$/);
|
|
111218
|
-
if (!ipaddr.IPv4.isValidCIDR(string) || !match) return false;
|
|
111219
|
-
return ipaddr.IPv4.isValidFourPartDecimal(match[1]);
|
|
111220
|
-
};
|
|
111221
|
-
ipaddr.IPv4.networkAddressFromCIDR = function(string) {
|
|
111222
|
-
let cidr, i, ipInterfaceOctets, octets, subnetMaskOctets;
|
|
111223
|
-
try {
|
|
111224
|
-
cidr = this.parseCIDR(string);
|
|
111225
|
-
ipInterfaceOctets = cidr[0].toByteArray();
|
|
111226
|
-
subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
|
|
111227
|
-
octets = [];
|
|
111228
|
-
i = 0;
|
|
111229
|
-
while (i < 4) {
|
|
111230
|
-
octets.push(parseInt(ipInterfaceOctets[i], 10) & parseInt(subnetMaskOctets[i], 10));
|
|
111231
|
-
i++;
|
|
111232
|
-
}
|
|
111233
|
-
return new this(octets);
|
|
111234
|
-
} catch (e) {
|
|
111235
|
-
throw new Error("ipaddr: the address does not have IPv4 CIDR format", { cause: e });
|
|
111236
|
-
}
|
|
111237
|
-
};
|
|
111238
|
-
ipaddr.IPv4.parse = function(string) {
|
|
111239
|
-
const parts = this.parser(string);
|
|
111240
|
-
if (parts === null) throw new Error("ipaddr: string is not formatted like an IPv4 Address");
|
|
111241
|
-
return new this(parts);
|
|
111242
|
-
};
|
|
111243
|
-
ipaddr.IPv4.parseCIDR = function(string) {
|
|
111244
|
-
let match;
|
|
111245
|
-
if (match = string.match(/^(.+)\/(\d+)$/)) {
|
|
111246
|
-
const maskLength = parseInt(match[2]);
|
|
111247
|
-
if (maskLength >= 0 && maskLength <= 32) {
|
|
111248
|
-
const parsed = [this.parse(match[1]), maskLength];
|
|
111249
|
-
Object.defineProperty(parsed, "toString", { value: function() {
|
|
111250
|
-
return this.join("/");
|
|
111251
|
-
} });
|
|
111252
|
-
return parsed;
|
|
111253
|
-
}
|
|
111254
|
-
}
|
|
111255
|
-
throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range");
|
|
111256
|
-
};
|
|
111257
|
-
ipaddr.IPv4.parser = function(string) {
|
|
111258
|
-
let match, part, value;
|
|
111259
|
-
if (match = string.match(ipv4Regexes.fourOctet)) return (function() {
|
|
111260
|
-
const ref = match.slice(1, 6);
|
|
111261
|
-
const results = [];
|
|
111262
|
-
for (let i = 0; i < ref.length; i++) {
|
|
111263
|
-
part = ref[i];
|
|
111264
|
-
results.push(parseIntAuto(part));
|
|
111265
|
-
}
|
|
111266
|
-
return results;
|
|
111267
|
-
})();
|
|
111268
|
-
else if (match = string.match(ipv4Regexes.longValue)) {
|
|
111269
|
-
value = parseIntAuto(match[1]);
|
|
111270
|
-
if (value > 4294967295 || value < 0) throw new Error("ipaddr: address outside defined range");
|
|
111271
|
-
return (function() {
|
|
111272
|
-
const results = [];
|
|
111273
|
-
let shift = 0;
|
|
111274
|
-
for (; shift <= 24; shift += 8) results.push(value >> shift & 255);
|
|
111275
|
-
return results;
|
|
111276
|
-
})().reverse();
|
|
111277
|
-
} else if (match = string.match(ipv4Regexes.twoOctet)) return (function() {
|
|
111278
|
-
const ref = match.slice(1, 4);
|
|
111279
|
-
const results = [];
|
|
111280
|
-
value = parseIntAuto(ref[1]);
|
|
111281
|
-
if (value > 16777215 || value < 0) throw new Error("ipaddr: address outside defined range");
|
|
111282
|
-
results.push(parseIntAuto(ref[0]));
|
|
111283
|
-
results.push(value >> 16 & 255);
|
|
111284
|
-
results.push(value >> 8 & 255);
|
|
111285
|
-
results.push(value & 255);
|
|
111286
|
-
return results;
|
|
111287
|
-
})();
|
|
111288
|
-
else if (match = string.match(ipv4Regexes.threeOctet)) return (function() {
|
|
111289
|
-
const ref = match.slice(1, 5);
|
|
111290
|
-
const results = [];
|
|
111291
|
-
value = parseIntAuto(ref[2]);
|
|
111292
|
-
if (value > 65535 || value < 0) throw new Error("ipaddr: address outside defined range");
|
|
111293
|
-
results.push(parseIntAuto(ref[0]));
|
|
111294
|
-
results.push(parseIntAuto(ref[1]));
|
|
111295
|
-
results.push(value >> 8 & 255);
|
|
111296
|
-
results.push(value & 255);
|
|
111297
|
-
return results;
|
|
111298
|
-
})();
|
|
111299
|
-
else return null;
|
|
111300
|
-
};
|
|
111301
|
-
ipaddr.IPv4.subnetMaskFromPrefixLength = function(prefix) {
|
|
111302
|
-
prefix = parseInt(prefix);
|
|
111303
|
-
if (Number.isNaN(prefix) || prefix < 0 || prefix > 32) throw new Error("ipaddr: invalid IPv4 prefix length");
|
|
111304
|
-
const octets = [
|
|
111305
|
-
0,
|
|
111306
|
-
0,
|
|
111307
|
-
0,
|
|
111308
|
-
0
|
|
111309
|
-
];
|
|
111310
|
-
let j = 0;
|
|
111311
|
-
const filledOctetCount = Math.floor(prefix / 8);
|
|
111312
|
-
while (j < filledOctetCount) {
|
|
111313
|
-
octets[j] = 255;
|
|
111314
|
-
j++;
|
|
111315
|
-
}
|
|
111316
|
-
if (filledOctetCount < 4) octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - prefix % 8;
|
|
111317
|
-
return new this(octets);
|
|
111318
|
-
};
|
|
111319
|
-
ipaddr.IPv6 = (function() {
|
|
111320
|
-
function IPv6(parts, zoneId) {
|
|
111321
|
-
let i, part;
|
|
111322
|
-
if (parts.length === 16) {
|
|
111323
|
-
this.parts = [];
|
|
111324
|
-
for (i = 0; i <= 14; i += 2) this.parts.push(parts[i] << 8 | parts[i + 1]);
|
|
111325
|
-
} else if (parts.length === 8) this.parts = parts;
|
|
111326
|
-
else throw new Error("ipaddr: ipv6 part count should be 8 or 16");
|
|
111327
|
-
for (i = 0; i < this.parts.length; i++) {
|
|
111328
|
-
part = this.parts[i];
|
|
111329
|
-
if (!(0 <= part && part <= 65535)) throw new Error("ipaddr: ipv6 part should fit in 16 bits");
|
|
111330
|
-
}
|
|
111331
|
-
if (zoneId) this.zoneId = zoneId;
|
|
111332
|
-
}
|
|
111333
|
-
IPv6.prototype.SpecialRanges = {
|
|
111334
|
-
unspecified: [new IPv6([
|
|
111335
|
-
0,
|
|
111336
|
-
0,
|
|
111337
|
-
0,
|
|
111338
|
-
0,
|
|
111339
|
-
0,
|
|
111340
|
-
0,
|
|
111341
|
-
0,
|
|
111342
|
-
0
|
|
111343
|
-
]), 128],
|
|
111344
|
-
linkLocal: [new IPv6([
|
|
111345
|
-
65152,
|
|
111346
|
-
0,
|
|
111347
|
-
0,
|
|
111348
|
-
0,
|
|
111349
|
-
0,
|
|
111350
|
-
0,
|
|
111351
|
-
0,
|
|
111352
|
-
0
|
|
111353
|
-
]), 10],
|
|
111354
|
-
multicast: [new IPv6([
|
|
111355
|
-
65280,
|
|
111356
|
-
0,
|
|
111357
|
-
0,
|
|
111358
|
-
0,
|
|
111359
|
-
0,
|
|
111360
|
-
0,
|
|
111361
|
-
0,
|
|
111362
|
-
0
|
|
111363
|
-
]), 8],
|
|
111364
|
-
loopback: [new IPv6([
|
|
111365
|
-
0,
|
|
111366
|
-
0,
|
|
111367
|
-
0,
|
|
111368
|
-
0,
|
|
111369
|
-
0,
|
|
111370
|
-
0,
|
|
111371
|
-
0,
|
|
111372
|
-
1
|
|
111373
|
-
]), 128],
|
|
111374
|
-
uniqueLocal: [new IPv6([
|
|
111375
|
-
64512,
|
|
111376
|
-
0,
|
|
111377
|
-
0,
|
|
111378
|
-
0,
|
|
111379
|
-
0,
|
|
111380
|
-
0,
|
|
111381
|
-
0,
|
|
111382
|
-
0
|
|
111383
|
-
]), 7],
|
|
111384
|
-
ipv4Mapped: [new IPv6([
|
|
111385
|
-
0,
|
|
111386
|
-
0,
|
|
111387
|
-
0,
|
|
111388
|
-
0,
|
|
111389
|
-
0,
|
|
111390
|
-
65535,
|
|
111391
|
-
0,
|
|
111392
|
-
0
|
|
111393
|
-
]), 96],
|
|
111394
|
-
deprecatedSiteLocal: [new IPv6([
|
|
111395
|
-
65216,
|
|
111396
|
-
0,
|
|
111397
|
-
0,
|
|
111398
|
-
0,
|
|
111399
|
-
0,
|
|
111400
|
-
0,
|
|
111401
|
-
0,
|
|
111402
|
-
0
|
|
111403
|
-
]), 10],
|
|
111404
|
-
discard: [new IPv6([
|
|
111405
|
-
256,
|
|
111406
|
-
0,
|
|
111407
|
-
0,
|
|
111408
|
-
0,
|
|
111409
|
-
0,
|
|
111410
|
-
0,
|
|
111411
|
-
0,
|
|
111412
|
-
0
|
|
111413
|
-
]), 64],
|
|
111414
|
-
rfc6145: [new IPv6([
|
|
111415
|
-
0,
|
|
111416
|
-
0,
|
|
111417
|
-
0,
|
|
111418
|
-
0,
|
|
111419
|
-
65535,
|
|
111420
|
-
0,
|
|
111421
|
-
0,
|
|
111422
|
-
0
|
|
111423
|
-
]), 96],
|
|
111424
|
-
rfc6052: [[new IPv6([
|
|
111425
|
-
100,
|
|
111426
|
-
65435,
|
|
111427
|
-
0,
|
|
111428
|
-
0,
|
|
111429
|
-
0,
|
|
111430
|
-
0,
|
|
111431
|
-
0,
|
|
111432
|
-
0
|
|
111433
|
-
]), 96], [new IPv6([
|
|
111434
|
-
100,
|
|
111435
|
-
65435,
|
|
111436
|
-
1,
|
|
111437
|
-
0,
|
|
111438
|
-
0,
|
|
111439
|
-
0,
|
|
111440
|
-
0,
|
|
111441
|
-
0
|
|
111442
|
-
]), 48]],
|
|
111443
|
-
"6to4": [new IPv6([
|
|
111444
|
-
8194,
|
|
111445
|
-
0,
|
|
111446
|
-
0,
|
|
111447
|
-
0,
|
|
111448
|
-
0,
|
|
111449
|
-
0,
|
|
111450
|
-
0,
|
|
111451
|
-
0
|
|
111452
|
-
]), 16],
|
|
111453
|
-
teredo: [new IPv6([
|
|
111454
|
-
8193,
|
|
111455
|
-
0,
|
|
111456
|
-
0,
|
|
111457
|
-
0,
|
|
111458
|
-
0,
|
|
111459
|
-
0,
|
|
111460
|
-
0,
|
|
111461
|
-
0
|
|
111462
|
-
]), 32],
|
|
111463
|
-
benchmarking: [new IPv6([
|
|
111464
|
-
8193,
|
|
111465
|
-
2,
|
|
111466
|
-
0,
|
|
111467
|
-
0,
|
|
111468
|
-
0,
|
|
111469
|
-
0,
|
|
111470
|
-
0,
|
|
111471
|
-
0
|
|
111472
|
-
]), 48],
|
|
111473
|
-
amt: [new IPv6([
|
|
111474
|
-
8193,
|
|
111475
|
-
3,
|
|
111476
|
-
0,
|
|
111477
|
-
0,
|
|
111478
|
-
0,
|
|
111479
|
-
0,
|
|
111480
|
-
0,
|
|
111481
|
-
0
|
|
111482
|
-
]), 32],
|
|
111483
|
-
as112v6: [[new IPv6([
|
|
111484
|
-
8193,
|
|
111485
|
-
4,
|
|
111486
|
-
274,
|
|
111487
|
-
0,
|
|
111488
|
-
0,
|
|
111489
|
-
0,
|
|
111490
|
-
0,
|
|
111491
|
-
0
|
|
111492
|
-
]), 48], [new IPv6([
|
|
111493
|
-
9760,
|
|
111494
|
-
79,
|
|
111495
|
-
32768,
|
|
111496
|
-
0,
|
|
111497
|
-
0,
|
|
111498
|
-
0,
|
|
111499
|
-
0,
|
|
111500
|
-
0
|
|
111501
|
-
]), 48]],
|
|
111502
|
-
deprecatedOrchid: [new IPv6([
|
|
111503
|
-
8193,
|
|
111504
|
-
16,
|
|
111505
|
-
0,
|
|
111506
|
-
0,
|
|
111507
|
-
0,
|
|
111508
|
-
0,
|
|
111509
|
-
0,
|
|
111510
|
-
0
|
|
111511
|
-
]), 28],
|
|
111512
|
-
orchid2: [new IPv6([
|
|
111513
|
-
8193,
|
|
111514
|
-
32,
|
|
111515
|
-
0,
|
|
111516
|
-
0,
|
|
111517
|
-
0,
|
|
111518
|
-
0,
|
|
111519
|
-
0,
|
|
111520
|
-
0
|
|
111521
|
-
]), 28],
|
|
111522
|
-
droneRemoteIdProtocolEntityTags: [new IPv6([
|
|
111523
|
-
8193,
|
|
111524
|
-
48,
|
|
111525
|
-
0,
|
|
111526
|
-
0,
|
|
111527
|
-
0,
|
|
111528
|
-
0,
|
|
111529
|
-
0,
|
|
111530
|
-
0
|
|
111531
|
-
]), 28],
|
|
111532
|
-
segmentRouting: [new IPv6([
|
|
111533
|
-
24320,
|
|
111534
|
-
0,
|
|
111535
|
-
0,
|
|
111536
|
-
0,
|
|
111537
|
-
0,
|
|
111538
|
-
0,
|
|
111539
|
-
0,
|
|
111540
|
-
0
|
|
111541
|
-
]), 16],
|
|
111542
|
-
reserved: [
|
|
111543
|
-
[new IPv6([
|
|
111544
|
-
8193,
|
|
111545
|
-
0,
|
|
111546
|
-
0,
|
|
111547
|
-
0,
|
|
111548
|
-
0,
|
|
111549
|
-
0,
|
|
111550
|
-
0,
|
|
111551
|
-
0
|
|
111552
|
-
]), 23],
|
|
111553
|
-
[new IPv6([
|
|
111554
|
-
8193,
|
|
111555
|
-
3512,
|
|
111556
|
-
0,
|
|
111557
|
-
0,
|
|
111558
|
-
0,
|
|
111559
|
-
0,
|
|
111560
|
-
0,
|
|
111561
|
-
0
|
|
111562
|
-
]), 32],
|
|
111563
|
-
[new IPv6([
|
|
111564
|
-
16383,
|
|
111565
|
-
0,
|
|
111566
|
-
0,
|
|
111567
|
-
0,
|
|
111568
|
-
0,
|
|
111569
|
-
0,
|
|
111570
|
-
0,
|
|
111571
|
-
0
|
|
111572
|
-
]), 20]
|
|
111573
|
-
]
|
|
111574
|
-
};
|
|
111575
|
-
IPv6.prototype.isIPv4MappedAddress = function() {
|
|
111576
|
-
return this.range() === "ipv4Mapped";
|
|
111577
|
-
};
|
|
111578
|
-
IPv6.prototype.kind = function() {
|
|
111579
|
-
return "ipv6";
|
|
111580
|
-
};
|
|
111581
|
-
IPv6.prototype.match = function(other, cidrRange) {
|
|
111582
|
-
let ref;
|
|
111583
|
-
if (cidrRange === void 0) {
|
|
111584
|
-
ref = other;
|
|
111585
|
-
other = ref[0];
|
|
111586
|
-
cidrRange = ref[1];
|
|
111587
|
-
}
|
|
111588
|
-
if (other.kind() !== "ipv6") throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");
|
|
111589
|
-
return matchCIDR(this.parts, other.parts, 16, cidrRange);
|
|
111590
|
-
};
|
|
111591
|
-
IPv6.prototype.prefixLengthFromSubnetMask = function() {
|
|
111592
|
-
let cidr = 0;
|
|
111593
|
-
let stop = false;
|
|
111594
|
-
const zerotable = {
|
|
111595
|
-
0: 16,
|
|
111596
|
-
32768: 15,
|
|
111597
|
-
49152: 14,
|
|
111598
|
-
57344: 13,
|
|
111599
|
-
61440: 12,
|
|
111600
|
-
63488: 11,
|
|
111601
|
-
64512: 10,
|
|
111602
|
-
65024: 9,
|
|
111603
|
-
65280: 8,
|
|
111604
|
-
65408: 7,
|
|
111605
|
-
65472: 6,
|
|
111606
|
-
65504: 5,
|
|
111607
|
-
65520: 4,
|
|
111608
|
-
65528: 3,
|
|
111609
|
-
65532: 2,
|
|
111610
|
-
65534: 1,
|
|
111611
|
-
65535: 0
|
|
111612
|
-
};
|
|
111613
|
-
let part, zeros;
|
|
111614
|
-
for (let i = 7; i >= 0; i -= 1) {
|
|
111615
|
-
part = this.parts[i];
|
|
111616
|
-
if (part in zerotable) {
|
|
111617
|
-
zeros = zerotable[part];
|
|
111618
|
-
if (stop && zeros !== 0) return null;
|
|
111619
|
-
if (zeros !== 16) stop = true;
|
|
111620
|
-
cidr += zeros;
|
|
111621
|
-
} else return null;
|
|
111622
|
-
}
|
|
111623
|
-
return 128 - cidr;
|
|
111624
|
-
};
|
|
111625
|
-
IPv6.prototype.range = function() {
|
|
111626
|
-
return ipaddr.subnetMatch(this, this.SpecialRanges);
|
|
111627
|
-
};
|
|
111628
|
-
IPv6.prototype.toByteArray = function() {
|
|
111629
|
-
let part;
|
|
111630
|
-
const bytes = [];
|
|
111631
|
-
const ref = this.parts;
|
|
111632
|
-
for (let i = 0; i < ref.length; i++) {
|
|
111633
|
-
part = ref[i];
|
|
111634
|
-
bytes.push(part >> 8);
|
|
111635
|
-
bytes.push(part & 255);
|
|
111636
|
-
}
|
|
111637
|
-
return bytes;
|
|
111638
|
-
};
|
|
111639
|
-
IPv6.prototype.toFixedLengthString = function() {
|
|
111640
|
-
const addr = (function() {
|
|
111641
|
-
const results = [];
|
|
111642
|
-
for (let i = 0; i < this.parts.length; i++) results.push(padPart(this.parts[i].toString(16), 4));
|
|
111643
|
-
return results;
|
|
111644
|
-
}).call(this).join(":");
|
|
111645
|
-
let suffix = "";
|
|
111646
|
-
if (this.zoneId) suffix = `%${this.zoneId}`;
|
|
111647
|
-
return addr + suffix;
|
|
111648
|
-
};
|
|
111649
|
-
IPv6.prototype.toIPv4Address = function() {
|
|
111650
|
-
if (!this.isIPv4MappedAddress()) throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");
|
|
111651
|
-
const ref = this.parts.slice(-2);
|
|
111652
|
-
const high = ref[0];
|
|
111653
|
-
const low = ref[1];
|
|
111654
|
-
return new ipaddr.IPv4([
|
|
111655
|
-
high >> 8,
|
|
111656
|
-
high & 255,
|
|
111657
|
-
low >> 8,
|
|
111658
|
-
low & 255
|
|
111659
|
-
]);
|
|
111660
|
-
};
|
|
111661
|
-
IPv6.prototype.toNormalizedString = function() {
|
|
111662
|
-
const addr = (function() {
|
|
111663
|
-
const results = [];
|
|
111664
|
-
for (let i = 0; i < this.parts.length; i++) results.push(this.parts[i].toString(16));
|
|
111665
|
-
return results;
|
|
111666
|
-
}).call(this).join(":");
|
|
111667
|
-
let suffix = "";
|
|
111668
|
-
if (this.zoneId) suffix = `%${this.zoneId}`;
|
|
111669
|
-
return addr + suffix;
|
|
111670
|
-
};
|
|
111671
|
-
IPv6.prototype.toRFC5952String = function() {
|
|
111672
|
-
const regex = /((^|:)(0(:|$)){2,})/g;
|
|
111673
|
-
let suffix = "";
|
|
111674
|
-
if (this.zoneId) suffix = `%${this.zoneId}`;
|
|
111675
|
-
const normalized = this.toNormalizedString();
|
|
111676
|
-
const string = normalized.slice(0, normalized.length - suffix.length);
|
|
111677
|
-
let bestMatchIndex = 0;
|
|
111678
|
-
let bestMatchLength = -1;
|
|
111679
|
-
let bestMatchGroups = -1;
|
|
111680
|
-
let match;
|
|
111681
|
-
while (match = regex.exec(string)) {
|
|
111682
|
-
const groups = (match[0].match(/0/g) || []).length;
|
|
111683
|
-
if (groups > bestMatchGroups) {
|
|
111684
|
-
bestMatchGroups = groups;
|
|
111685
|
-
bestMatchIndex = match.index;
|
|
111686
|
-
bestMatchLength = match[0].length;
|
|
111687
|
-
}
|
|
111688
|
-
}
|
|
111689
|
-
if (bestMatchLength < 0) return string + suffix;
|
|
111690
|
-
return `${string.substring(0, bestMatchIndex)}::${string.substring(bestMatchIndex + bestMatchLength)}${suffix}`;
|
|
111691
|
-
};
|
|
111692
|
-
IPv6.prototype.toString = function() {
|
|
111693
|
-
return this.toRFC5952String();
|
|
111694
|
-
};
|
|
111695
|
-
return IPv6;
|
|
111696
|
-
})();
|
|
111697
|
-
ipaddr.IPv6.broadcastAddressFromCIDR = function(string) {
|
|
111698
|
-
try {
|
|
111699
|
-
const cidr = this.parseCIDR(string);
|
|
111700
|
-
const ipInterfaceOctets = cidr[0].toByteArray();
|
|
111701
|
-
const subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
|
|
111702
|
-
const octets = [];
|
|
111703
|
-
let i = 0;
|
|
111704
|
-
while (i < 16) {
|
|
111705
|
-
octets.push(parseInt(ipInterfaceOctets[i], 10) | parseInt(subnetMaskOctets[i], 10) ^ 255);
|
|
111706
|
-
i++;
|
|
111707
|
-
}
|
|
111708
|
-
return new this(octets);
|
|
111709
|
-
} catch (e) {
|
|
111710
|
-
throw new Error("ipaddr: the address does not have IPv6 CIDR format", { cause: e });
|
|
111711
|
-
}
|
|
111712
|
-
};
|
|
111713
|
-
ipaddr.IPv6.isIPv6 = function(string) {
|
|
111714
|
-
return this.parser(string) !== null;
|
|
111715
|
-
};
|
|
111716
|
-
ipaddr.IPv6.isValid = function(string) {
|
|
111717
|
-
if (typeof string === "string" && string.indexOf(":") === -1) return false;
|
|
111718
|
-
try {
|
|
111719
|
-
const addr = this.parser(string);
|
|
111720
|
-
new this(addr.parts, addr.zoneId);
|
|
111721
|
-
return true;
|
|
111722
|
-
} catch {
|
|
111723
|
-
return false;
|
|
111724
|
-
}
|
|
111725
|
-
};
|
|
111726
|
-
ipaddr.IPv6.isValidCIDR = function(string) {
|
|
111727
|
-
if (typeof string === "string" && string.indexOf(":") === -1) return false;
|
|
111728
|
-
try {
|
|
111729
|
-
this.parseCIDR(string);
|
|
111730
|
-
return true;
|
|
111731
|
-
} catch {
|
|
111732
|
-
return false;
|
|
111733
|
-
}
|
|
111734
|
-
};
|
|
111735
|
-
ipaddr.IPv6.networkAddressFromCIDR = function(string) {
|
|
111736
|
-
let cidr, i, ipInterfaceOctets, octets, subnetMaskOctets;
|
|
111737
|
-
try {
|
|
111738
|
-
cidr = this.parseCIDR(string);
|
|
111739
|
-
ipInterfaceOctets = cidr[0].toByteArray();
|
|
111740
|
-
subnetMaskOctets = this.subnetMaskFromPrefixLength(cidr[1]).toByteArray();
|
|
111741
|
-
octets = [];
|
|
111742
|
-
i = 0;
|
|
111743
|
-
while (i < 16) {
|
|
111744
|
-
octets.push(parseInt(ipInterfaceOctets[i], 10) & parseInt(subnetMaskOctets[i], 10));
|
|
111745
|
-
i++;
|
|
111746
|
-
}
|
|
111747
|
-
return new this(octets);
|
|
111748
|
-
} catch (e) {
|
|
111749
|
-
throw new Error("ipaddr: the address does not have IPv6 CIDR format", { cause: e });
|
|
111750
|
-
}
|
|
111751
|
-
};
|
|
111752
|
-
ipaddr.IPv6.parse = function(string) {
|
|
111753
|
-
const addr = this.parser(string);
|
|
111754
|
-
if (addr === null) throw new Error("ipaddr: string is not formatted like an IPv6 Address");
|
|
111755
|
-
return new this(addr.parts, addr.zoneId);
|
|
111756
|
-
};
|
|
111757
|
-
ipaddr.IPv6.parseCIDR = function(string) {
|
|
111758
|
-
let maskLength, match, parsed;
|
|
111759
|
-
if (match = string.match(/^(.+)\/(\d+)$/)) {
|
|
111760
|
-
maskLength = parseInt(match[2]);
|
|
111761
|
-
if (maskLength >= 0 && maskLength <= 128) {
|
|
111762
|
-
parsed = [this.parse(match[1]), maskLength];
|
|
111763
|
-
Object.defineProperty(parsed, "toString", { value: function() {
|
|
111764
|
-
return this.join("/");
|
|
111765
|
-
} });
|
|
111766
|
-
return parsed;
|
|
111767
|
-
}
|
|
111768
|
-
}
|
|
111769
|
-
throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range");
|
|
111770
|
-
};
|
|
111771
|
-
ipaddr.IPv6.parser = function(string) {
|
|
111772
|
-
let addr, i, match, octet, octets, zoneId;
|
|
111773
|
-
if (match = string.match(ipv6Regexes.deprecatedTransitional)) return this.parser(`::ffff:${match[1]}`);
|
|
111774
|
-
if (ipv6Regexes.native.test(string)) return expandIPv6(string, 8);
|
|
111775
|
-
if (match = string.match(ipv6Regexes.transitional)) {
|
|
111776
|
-
zoneId = match[6] || "";
|
|
111777
|
-
addr = match[1];
|
|
111778
|
-
if (!match[1].endsWith("::")) addr = addr.slice(0, -1);
|
|
111779
|
-
addr = expandIPv6(addr + zoneId, 6);
|
|
111780
|
-
if (addr && addr.parts) {
|
|
111781
|
-
octets = [
|
|
111782
|
-
parseInt(match[2]),
|
|
111783
|
-
parseInt(match[3]),
|
|
111784
|
-
parseInt(match[4]),
|
|
111785
|
-
parseInt(match[5])
|
|
111786
|
-
];
|
|
111787
|
-
for (i = 0; i < octets.length; i++) {
|
|
111788
|
-
octet = octets[i];
|
|
111789
|
-
if (!(0 <= octet && octet <= 255)) return null;
|
|
111790
|
-
}
|
|
111791
|
-
addr.parts.push(octets[0] << 8 | octets[1]);
|
|
111792
|
-
addr.parts.push(octets[2] << 8 | octets[3]);
|
|
111793
|
-
return {
|
|
111794
|
-
parts: addr.parts,
|
|
111795
|
-
zoneId: addr.zoneId
|
|
111796
|
-
};
|
|
111797
|
-
}
|
|
111798
|
-
}
|
|
111799
|
-
return null;
|
|
111800
|
-
};
|
|
111801
|
-
ipaddr.IPv6.subnetMaskFromPrefixLength = function(prefix) {
|
|
111802
|
-
prefix = parseInt(prefix);
|
|
111803
|
-
if (Number.isNaN(prefix) || prefix < 0 || prefix > 128) throw new Error("ipaddr: invalid IPv6 prefix length");
|
|
111804
|
-
const octets = [
|
|
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
|
-
0
|
|
111821
|
-
];
|
|
111822
|
-
let j = 0;
|
|
111823
|
-
const filledOctetCount = Math.floor(prefix / 8);
|
|
111824
|
-
while (j < filledOctetCount) {
|
|
111825
|
-
octets[j] = 255;
|
|
111826
|
-
j++;
|
|
111827
|
-
}
|
|
111828
|
-
if (filledOctetCount < 16) octets[filledOctetCount] = Math.pow(2, prefix % 8) - 1 << 8 - prefix % 8;
|
|
111829
|
-
return new this(octets);
|
|
111830
|
-
};
|
|
111831
|
-
ipaddr.fromByteArray = function(bytes) {
|
|
111832
|
-
const length = bytes.length;
|
|
111833
|
-
if (length === 4) return new ipaddr.IPv4(bytes);
|
|
111834
|
-
else if (length === 16) return new ipaddr.IPv6(bytes);
|
|
111835
|
-
else throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address");
|
|
111836
|
-
};
|
|
111837
|
-
ipaddr.isValid = function(string) {
|
|
111838
|
-
return ipaddr.IPv6.isValid(string) || ipaddr.IPv4.isValid(string);
|
|
111839
|
-
};
|
|
111840
|
-
ipaddr.isValidCIDR = function(string) {
|
|
111841
|
-
return ipaddr.IPv6.isValidCIDR(string) || ipaddr.IPv4.isValidCIDR(string);
|
|
111842
|
-
};
|
|
111843
|
-
ipaddr.parse = function(string) {
|
|
111844
|
-
if (ipaddr.IPv6.isValid(string)) return ipaddr.IPv6.parse(string);
|
|
111845
|
-
else if (ipaddr.IPv4.isValid(string)) return ipaddr.IPv4.parse(string);
|
|
111846
|
-
else throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format");
|
|
111847
|
-
};
|
|
111848
|
-
ipaddr.parseCIDR = function(string) {
|
|
111849
|
-
try {
|
|
111850
|
-
return ipaddr.IPv6.parseCIDR(string);
|
|
111851
|
-
} catch {
|
|
111852
|
-
try {
|
|
111853
|
-
return ipaddr.IPv4.parseCIDR(string);
|
|
111854
|
-
} catch (e) {
|
|
111855
|
-
throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format", { cause: e });
|
|
111856
|
-
}
|
|
111857
|
-
}
|
|
111858
|
-
};
|
|
111859
|
-
ipaddr.process = function(string) {
|
|
111860
|
-
const addr = this.parse(string);
|
|
111861
|
-
if (addr.kind() === "ipv6" && addr.isIPv4MappedAddress()) return addr.toIPv4Address();
|
|
111862
|
-
else return addr;
|
|
111863
|
-
};
|
|
111864
|
-
ipaddr.subnetMatch = function(address, rangeList, defaultName) {
|
|
111865
|
-
let i, rangeName, rangeSubnets, subnet;
|
|
111866
|
-
if (defaultName === void 0 || defaultName === null) defaultName = "unicast";
|
|
111867
|
-
for (rangeName in rangeList) if (Object.prototype.hasOwnProperty.call(rangeList, rangeName)) {
|
|
111868
|
-
rangeSubnets = rangeList[rangeName];
|
|
111869
|
-
if (rangeSubnets[0] && !(rangeSubnets[0] instanceof Array)) rangeSubnets = [rangeSubnets];
|
|
111870
|
-
for (i = 0; i < rangeSubnets.length; i++) {
|
|
111871
|
-
subnet = rangeSubnets[i];
|
|
111872
|
-
if (address.kind() === subnet[0].kind() && address.match.apply(address, subnet)) return rangeName;
|
|
111873
|
-
}
|
|
111874
|
-
}
|
|
111875
|
-
return defaultName;
|
|
111876
|
-
};
|
|
111877
|
-
if (typeof module !== "undefined" && module.exports) module.exports = ipaddr;
|
|
111878
|
-
else root.ipaddr = ipaddr;
|
|
111879
|
-
})(this$1);
|
|
111880
|
-
})))(), 1);
|
|
111881
111026
|
const WORKERS = {
|
|
111882
111027
|
"77.237.236.132": "dev",
|
|
111883
111028
|
"100.68.201.107": "dev",
|
|
111884
111029
|
"100.97.120.3": "desktop",
|
|
111885
111030
|
"100.115.207.60": "macbook-pro"
|
|
111886
111031
|
};
|
|
111887
|
-
|
|
111888
|
-
|
|
111889
|
-
|
|
111890
|
-
|
|
111891
|
-
|
|
111892
|
-
|
|
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
|
+
}
|
|
111893
111042
|
function addressGroup(address) {
|
|
111894
|
-
|
|
111895
|
-
|
|
111896
|
-
|
|
111897
|
-
|
|
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
|
+
});
|
|
111898
111050
|
}
|
|
111899
111051
|
function clientAddress(headers, remote) {
|
|
111900
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));
|
|
@@ -111937,7 +111089,7 @@ function browserLabel(origin) {
|
|
|
111937
111089
|
}
|
|
111938
111090
|
function deviceLabel(origin) {
|
|
111939
111091
|
return pipe(flatMap$7(fromUndefinedOr(origin.address), (address) => {
|
|
111940
|
-
if (
|
|
111092
|
+
if (exists(parsedAddress(address), (ip) => isLinkLocal(ip) || isLoopback(ip) || isPrivate(ip))) return some$1("dev");
|
|
111941
111093
|
return get$13(WORKERS, address);
|
|
111942
111094
|
}), orElse$3(() => flatMap$7(fromUndefinedOr(origin.userAgent), platform)), getOrElse(() => origin.address ?? "unknown"));
|
|
111943
111095
|
}
|
|
@@ -112023,15 +111175,6 @@ function returnable(next, url) {
|
|
|
112023
111175
|
}
|
|
112024
111176
|
// src/services/passkeys/service.ts
|
|
112025
111177
|
const LIFETIME = 3e5;
|
|
112026
|
-
function rejected$4(message) {
|
|
112027
|
-
return mapError$2((cause) => {
|
|
112028
|
-
if (is$2(AuthError)(cause)) return cause;
|
|
112029
|
-
return AuthError.make({
|
|
112030
|
-
cause,
|
|
112031
|
-
message
|
|
112032
|
-
});
|
|
112033
|
-
});
|
|
112034
|
-
}
|
|
112035
111178
|
function invalid(cause) {
|
|
112036
111179
|
return AuthError.make({
|
|
112037
111180
|
cause,
|
|
@@ -112109,10 +111252,10 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
|
|
|
112109
111252
|
transports,
|
|
112110
111253
|
user
|
|
112111
111254
|
}]);
|
|
112112
|
-
}, rejected$
|
|
111255
|
+
}, rejected$1("Cannot add the passkey")),
|
|
112113
111256
|
forget: fn("Passkeys.forget")(function* (userId) {
|
|
112114
111257
|
yield* change((current) => filter$6(current, (found) => found.user.id !== userId));
|
|
112115
|
-
}, rejected$
|
|
111258
|
+
}, rejected$1("Cannot remove the account’s passkeys")),
|
|
112116
111259
|
list: (user) => map$3(changes(state), (current) => map$8(filter$6(current, (found) => found.user.id === user.id), (found) => ({
|
|
112117
111260
|
addedFrom: found.addedFrom,
|
|
112118
111261
|
createdAt: found.createdAt,
|
|
@@ -112148,17 +111291,17 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
|
|
|
112148
111291
|
expiresAt: now + LIFETIME
|
|
112149
111292
|
}));
|
|
112150
111293
|
return yield* decodeEffect(fromJsonString(CreationOptions))(yield* encodeUnknownEffect(fromJsonString(Unknown))(options));
|
|
112151
|
-
}, rejected$
|
|
111294
|
+
}, rejected$1("Cannot start adding a passkey")),
|
|
112152
111295
|
remove: fn("Passkeys.remove")(function* (id, user) {
|
|
112153
111296
|
yield* change((current) => filter$6(current, (found) => found.id !== id || found.user.id !== user.id));
|
|
112154
|
-
}, rejected$
|
|
111297
|
+
}, rejected$1("Cannot remove the passkey")),
|
|
112155
111298
|
request: pipe(tryPromise({
|
|
112156
111299
|
catch: invalid,
|
|
112157
111300
|
try: () => generateAuthenticationOptions({
|
|
112158
111301
|
rpID,
|
|
112159
111302
|
userVerification: "required"
|
|
112160
111303
|
})
|
|
112161
|
-
}), 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$
|
|
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")),
|
|
112162
111305
|
signIn: fn("Passkeys.signIn")(function* (response) {
|
|
112163
111306
|
const challenge = yield* challengeOf(response.response.clientDataJSON);
|
|
112164
111307
|
const now = yield* currentTimeMillis;
|
|
@@ -112191,21 +111334,12 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
|
|
|
112191
111334
|
};
|
|
112192
111335
|
}));
|
|
112193
111336
|
return found.user;
|
|
112194
|
-
}, rejected$
|
|
111337
|
+
}, rejected$1("Cannot sign in with the passkey"))
|
|
112195
111338
|
});
|
|
112196
111339
|
}));
|
|
112197
111340
|
};
|
|
112198
111341
|
// src/services/tokens/service.ts
|
|
112199
111342
|
const SESSION_COOKIE = "__Secure-session";
|
|
112200
|
-
function rejected$3(message) {
|
|
112201
|
-
return mapError$2((cause) => {
|
|
112202
|
-
if (is$2(AuthError)(cause)) return cause;
|
|
112203
|
-
return AuthError.make({
|
|
112204
|
-
cause,
|
|
112205
|
-
message
|
|
112206
|
-
});
|
|
112207
|
-
});
|
|
112208
|
-
}
|
|
112209
111343
|
const expired$1 = AuthError.make({
|
|
112210
111344
|
error: "invalid_grant",
|
|
112211
111345
|
message: "The authorization expired. Sign in again."
|
|
@@ -112267,7 +111401,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
112267
111401
|
user: found.grant.user,
|
|
112268
111402
|
via: found.grant.credential.via ?? "Code"
|
|
112269
111403
|
};
|
|
112270
|
-
}, rejected$
|
|
111404
|
+
}, rejected$1("Sign in first"));
|
|
112271
111405
|
const session = fn("Tokens.session")(function* (headers) {
|
|
112272
111406
|
return (yield* browser(headers)).user;
|
|
112273
111407
|
});
|
|
@@ -112279,7 +111413,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
112279
111413
|
const found = yield* grantOf(token);
|
|
112280
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" });
|
|
112281
111415
|
return found.grant.user;
|
|
112282
|
-
}, rejected$
|
|
111416
|
+
}, rejected$1("Sign in first"));
|
|
112283
111417
|
const mint = fnUntraced(function* (family, generation, resources, now) {
|
|
112284
111418
|
const accessSecret = yield* secret(32);
|
|
112285
111419
|
const refreshSecret = yield* secret(32);
|
|
@@ -112435,22 +111569,22 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
112435
111569
|
if (!exists(get$13(current, family), (grant) => grant.user.id === user.id)) return yield* AuthError.make({ message: "This sign-in has already ended" });
|
|
112436
111570
|
return [void 0, remove$6(current, family)];
|
|
112437
111571
|
}));
|
|
112438
|
-
}, rejected$
|
|
111572
|
+
}, rejected$1("Cannot sign this out")),
|
|
112439
111573
|
endSession: fn("Tokens.endSession")(function* (headers) {
|
|
112440
111574
|
const found = yield* option$1(grantOf(parseHeader(headers["cookie"] ?? "")["__Secure-session"] ?? ""));
|
|
112441
111575
|
yield* match$8(filter$8(found, (current) => current.grant.credential.hash === current.hash), {
|
|
112442
111576
|
onNone: () => void_$1,
|
|
112443
111577
|
onSome: (own) => change((saved) => succeed$5([void 0, remove$6(saved, own.family)]))
|
|
112444
111578
|
});
|
|
112445
|
-
}, rejected$
|
|
111579
|
+
}, rejected$1("Cannot sign out")),
|
|
112446
111580
|
exchange: fn("Tokens.exchange")(function* (params, origin, allowed) {
|
|
112447
111581
|
if (params.grant_type === "authorization_code") return yield* redeem(params, origin, allowed);
|
|
112448
111582
|
return yield* rotate(params, origin, allowed);
|
|
112449
|
-
}, rejected$
|
|
111583
|
+
}, rejected$1("Invalid token request")),
|
|
112450
111584
|
forget: fn("Tokens.forget")(function* (id) {
|
|
112451
111585
|
yield* change((current) => succeed$5([void 0, filter$7(current, (grant) => grant.user.id !== id)]));
|
|
112452
111586
|
yield* update$3(codes, filter((entry) => entry.state._tag === "Used" || entry.state.user.id !== id));
|
|
112453
|
-
}, rejected$
|
|
111587
|
+
}, rejected$1("Cannot sign this account out")),
|
|
112454
111588
|
issue: fn("Tokens.issue")(function* (request, user) {
|
|
112455
111589
|
const code = yield* secret(32);
|
|
112456
111590
|
const key = yield* hash(code);
|
|
@@ -112464,7 +111598,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
112464
111598
|
}
|
|
112465
111599
|
}));
|
|
112466
111600
|
return code;
|
|
112467
|
-
}, rejected$
|
|
111601
|
+
}, rejected$1("Cannot issue the authorization code")),
|
|
112468
111602
|
revoke: fn("Tokens.revoke")(function* (params) {
|
|
112469
111603
|
yield* match$8(parts(params.token), {
|
|
112470
111604
|
onNone: () => void_$1,
|
|
@@ -112476,7 +111610,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
112476
111610
|
})]));
|
|
112477
111611
|
})
|
|
112478
111612
|
});
|
|
112479
|
-
}, rejected$
|
|
111613
|
+
}, rejected$1("Cannot revoke the token")),
|
|
112480
111614
|
session,
|
|
112481
111615
|
sessionVia,
|
|
112482
111616
|
startSession: fn("Tokens.startSession")(function* (user, origin, via) {
|
|
@@ -112505,7 +111639,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
112505
111639
|
seconds,
|
|
112506
111640
|
token: `${family}.${sessionSecret}`
|
|
112507
111641
|
};
|
|
112508
|
-
}, rejected$
|
|
111642
|
+
}, rejected$1("Cannot start the session"))
|
|
112509
111643
|
});
|
|
112510
111644
|
}));
|
|
112511
111645
|
};
|
|
@@ -112515,15 +111649,6 @@ const ROLE_ORDER = {
|
|
|
112515
111649
|
Member: 2,
|
|
112516
111650
|
Waiting: 1
|
|
112517
111651
|
};
|
|
112518
|
-
function rejected$2(message) {
|
|
112519
|
-
return mapError$2((cause) => {
|
|
112520
|
-
if (is$2(AuthError)(cause)) return cause;
|
|
112521
|
-
return AuthError.make({
|
|
112522
|
-
cause,
|
|
112523
|
-
message
|
|
112524
|
-
});
|
|
112525
|
-
});
|
|
112526
|
-
}
|
|
112527
111652
|
function memberOf(github, since, status) {
|
|
112528
111653
|
return {
|
|
112529
111654
|
fullName: github.name ?? "",
|
|
@@ -112543,16 +111668,12 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
112543
111668
|
const tokens = yield* Tokens;
|
|
112544
111669
|
const passkeys = yield* Passkeys;
|
|
112545
111670
|
const github = yield* GitHub;
|
|
112546
|
-
const
|
|
112547
|
-
const admins = yield* match$1(yield* localAuth, {
|
|
112548
|
-
onFalse: () => listed,
|
|
112549
|
-
onTrue: () => withDefault$2(listed, ["0"])
|
|
112550
|
-
});
|
|
111671
|
+
const admins = yield* adminIds;
|
|
112551
111672
|
const transact = fnUntraced(function* (change) {
|
|
112552
111673
|
return yield* modifyEffect(state, (current) => tap$1(change(current), (result) => store.set("members", result[1])));
|
|
112553
111674
|
}, uninterruptible);
|
|
112554
111675
|
function roleOf(id, row) {
|
|
112555
|
-
if (
|
|
111676
|
+
if (isAdmin(admins, id)) return "Admin";
|
|
112556
111677
|
if (exists(row, (found) => found.status === "Allowed")) return "Member";
|
|
112557
111678
|
return "Waiting";
|
|
112558
111679
|
}
|
|
@@ -112578,7 +111699,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
112578
111699
|
return user;
|
|
112579
111700
|
});
|
|
112580
111701
|
const admin = fnUntraced(function* (user) {
|
|
112581
|
-
if (
|
|
111702
|
+
if (!isAdmin(admins, user.id)) return yield* AuthError.make({
|
|
112582
111703
|
error: "access_denied",
|
|
112583
111704
|
message: "Only an admin can manage people"
|
|
112584
111705
|
});
|
|
@@ -112592,7 +111713,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
112592
111713
|
role: "Admin",
|
|
112593
111714
|
since: 0
|
|
112594
111715
|
})), ...known], mapInput(Order$4, (person) => ROLE_ORDER[person.role]));
|
|
112595
|
-
}, rejected$
|
|
111716
|
+
}, rejected$1("Cannot read people"));
|
|
112596
111717
|
yield* pipe(forEach$1(admins, fnUntraced(function* (id) {
|
|
112597
111718
|
if (isSome(member(`github:${id}`, yield* get(state)))) return;
|
|
112598
111719
|
const profile = yield* github.profile(id);
|
|
@@ -112622,7 +111743,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
112622
111743
|
via: session.via
|
|
112623
111744
|
})
|
|
112624
111745
|
});
|
|
112625
|
-
}), rejected$
|
|
111746
|
+
}), rejected$1("Cannot read the account")))),
|
|
112626
111747
|
admin,
|
|
112627
111748
|
admit: fn("People.admit")(function* (params, user) {
|
|
112628
111749
|
yield* admin(user);
|
|
@@ -112649,7 +111770,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
112649
111770
|
yield* passkeys.forget(params.id);
|
|
112650
111771
|
}
|
|
112651
111772
|
return person;
|
|
112652
|
-
}, rejected$
|
|
111773
|
+
}, rejected$1("Cannot answer the access request")),
|
|
112653
111774
|
allowed: fn("People.allowed")(allowed),
|
|
112654
111775
|
list,
|
|
112655
111776
|
people: (user) => mapEffect$1(changes(state), () => list(user)),
|
|
@@ -112675,7 +111796,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
112675
111796
|
})
|
|
112676
111797
|
})]);
|
|
112677
111798
|
});
|
|
112678
|
-
}, rejected$
|
|
111799
|
+
}, rejected$1("Cannot record the GitHub account")),
|
|
112679
111800
|
remove: fn("People.remove")(function* (id, user) {
|
|
112680
111801
|
yield* admin(user);
|
|
112681
111802
|
if (roleOf(id, none()) === "Admin") return yield* AuthError.make({ message: "Admins come from GITHUB_ADMINS, so they cannot be removed here" });
|
|
@@ -112684,7 +111805,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
112684
111805
|
yield* tokens.forget(id);
|
|
112685
111806
|
yield* passkeys.forget(id);
|
|
112686
111807
|
return found;
|
|
112687
|
-
}, rejected$
|
|
111808
|
+
}, rejected$1("Cannot remove this account"))
|
|
112688
111809
|
});
|
|
112689
111810
|
return pipe(make$85(People, people), merge$4(Auth.makeContext(Auth.of({
|
|
112690
111811
|
access: fn("Auth.access")(function* (headers, resource) {
|
|
@@ -120006,15 +119127,6 @@ const waitFor = waitFor$1;
|
|
|
120006
119127
|
const start = start$1;
|
|
120007
119128
|
// src/services/sign-ins/service.ts
|
|
120008
119129
|
const REQUEST_COOKIE = "__Host-request-";
|
|
120009
|
-
function rejected$1(message) {
|
|
120010
|
-
return mapError$2((cause) => {
|
|
120011
|
-
if (is$2(AuthError)(cause)) return cause;
|
|
120012
|
-
return AuthError.make({
|
|
120013
|
-
cause,
|
|
120014
|
-
message
|
|
120015
|
-
});
|
|
120016
|
-
});
|
|
120017
|
-
}
|
|
120018
119130
|
const expired = AuthError.make({ message: "This sign-in expired. Start it again in the app." });
|
|
120019
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." });
|
|
120020
119132
|
const deliver = fnUntraced(function* (input) {
|
|
@@ -120273,7 +119385,6 @@ const COOKIE = {
|
|
|
120273
119385
|
secure: true
|
|
120274
119386
|
};
|
|
120275
119387
|
const LOGIN_COOKIE = "__Host-login";
|
|
120276
|
-
const ISSUER = `${AUTH_URL}/api/auth`;
|
|
120277
119388
|
function sessionCookie(local) {
|
|
120278
119389
|
if (local) return {
|
|
120279
119390
|
...COOKIE,
|
|
@@ -120284,15 +119395,6 @@ function sessionCookie(local) {
|
|
|
120284
119395
|
domain: cookieDomain(AUTH_URL)
|
|
120285
119396
|
};
|
|
120286
119397
|
}
|
|
120287
|
-
function rejected(message) {
|
|
120288
|
-
return mapError$2((cause) => {
|
|
120289
|
-
if (is$2(AuthError)(cause)) return cause;
|
|
120290
|
-
return AuthError.make({
|
|
120291
|
-
cause,
|
|
120292
|
-
message
|
|
120293
|
-
});
|
|
120294
|
-
});
|
|
120295
|
-
}
|
|
120296
119398
|
function oauth(handler) {
|
|
120297
119399
|
return pipe(handler, catchIf(is$2(AuthError), (failure) => succeed$5(jsonUnsafe({
|
|
120298
119400
|
error: failure.error ?? "invalid_request",
|
|
@@ -120302,6 +119404,9 @@ function oauth(handler) {
|
|
|
120302
119404
|
function originOf(request) {
|
|
120303
119405
|
return originFrom(request.headers, request.remoteAddress);
|
|
120304
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
|
+
}
|
|
120305
119410
|
function waitingAt(started) {
|
|
120306
119411
|
return setCookieUnsafe(redirect(`/?request=${started.code}`), `${REQUEST_COOKIE}${started.code}`, started.receiver, {
|
|
120307
119412
|
...COOKIE,
|
|
@@ -120366,11 +119471,11 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
120366
119471
|
}));
|
|
120367
119472
|
});
|
|
120368
119473
|
}
|
|
120369
|
-
yield* router.add("POST",
|
|
120370
|
-
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"));
|
|
120371
119476
|
return yield* schemaJson(App)(yield* apps.register(params.origin));
|
|
120372
119477
|
}), catchIf(is$2(AuthError), (failure) => succeed$5(text(failure.message, { status: 403 }))))));
|
|
120373
|
-
yield* router.add("GET",
|
|
119478
|
+
yield* router.add("GET", `/.well-known/oauth-authorization-server${ISSUER_PATH}`, jsonUnsafe({
|
|
120374
119479
|
authorization_endpoint: `${ISSUER}/oauth2/authorize`,
|
|
120375
119480
|
authorization_response_iss_parameter_supported: true,
|
|
120376
119481
|
code_challenge_methods_supported: ["S256"],
|
|
@@ -120383,7 +119488,7 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
120383
119488
|
token_endpoint: `${ISSUER}/oauth2/token`,
|
|
120384
119489
|
token_endpoint_auth_methods_supported: ["none"]
|
|
120385
119490
|
}));
|
|
120386
|
-
yield* router.add("POST",
|
|
119491
|
+
yield* router.add("POST", `${ISSUER_PATH}/oauth2/register`, limited("register", 10)(oauth(gen(function* () {
|
|
120387
119492
|
const params = yield* pipe(schemaBodyJson(Registration$1), mapError$2((cause) => AuthError.make({
|
|
120388
119493
|
cause,
|
|
120389
119494
|
error: "invalid_client_metadata",
|
|
@@ -120406,11 +119511,11 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
120406
119511
|
token_endpoint_auth_method: "none"
|
|
120407
119512
|
}, { status: 201 });
|
|
120408
119513
|
}))));
|
|
120409
|
-
yield* router.add("GET",
|
|
119514
|
+
yield* router.add("GET", `${ISSUER_PATH}/oauth2/authorize`, limited("authorize", 20)(oauth(gen(function* () {
|
|
120410
119515
|
const request = yield* HttpServerRequest;
|
|
120411
|
-
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"));
|
|
120412
119517
|
const client = yield* tokens.client(asked);
|
|
120413
|
-
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({
|
|
120414
119519
|
_tag: "Client",
|
|
120415
119520
|
request: checked
|
|
120416
119521
|
}, originOf(request))), map$5(waitingAt), catchIf(is$2(AuthError), (failure) => succeed$5(redirect(callbackUrl({
|
|
@@ -120421,13 +119526,13 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
120421
119526
|
error_description: failure.message
|
|
120422
119527
|
})))));
|
|
120423
119528
|
}))));
|
|
120424
|
-
yield* router.add("POST",
|
|
120425
|
-
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"));
|
|
120426
119531
|
if (grant.grant_type !== "authorization_code" && grant.grant_type !== "refresh_token") return yield* AuthError.make({
|
|
120427
119532
|
error: "unsupported_grant_type",
|
|
120428
119533
|
message: "Use grant_type authorization_code or refresh_token"
|
|
120429
119534
|
});
|
|
120430
|
-
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), {
|
|
120431
119536
|
Granted: (granted) => jsonUnsafe(granted.tokens),
|
|
120432
119537
|
Replayed: (replayed) => jsonUnsafe({
|
|
120433
119538
|
error: "invalid_grant",
|
|
@@ -120435,31 +119540,31 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
120435
119540
|
}, { status: 400 })
|
|
120436
119541
|
});
|
|
120437
119542
|
}))));
|
|
120438
|
-
yield* router.add("POST",
|
|
120439
|
-
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")));
|
|
120440
119545
|
return empty();
|
|
120441
119546
|
}))));
|
|
120442
|
-
yield* router.add("GET",
|
|
120443
|
-
yield* router.add("GET",
|
|
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* () {
|
|
120444
119549
|
const params = yield* schemaSearchParams(VerificationParams);
|
|
120445
119550
|
return yield* auth.access((yield* HttpServerRequest).headers, params.resource);
|
|
120446
|
-
})
|
|
119551
|
+
})));
|
|
120447
119552
|
yield* router.add("GET", "/auth/github", limited("github", 10)(oauth(gen(function* () {
|
|
120448
|
-
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")));
|
|
120449
119554
|
return setCookieUnsafe(redirect(started.url), LOGIN_COOKIE, started.state, {
|
|
120450
119555
|
...COOKIE,
|
|
120451
119556
|
maxAge: "10 minutes"
|
|
120452
119557
|
});
|
|
120453
119558
|
}))));
|
|
120454
119559
|
yield* router.add("GET", "/auth/github/callback", pipe(gen(function* () {
|
|
120455
|
-
const params = yield* pipe(schemaSearchParams(CallbackParams), rejected("GitHub sent no code"));
|
|
119560
|
+
const params = yield* pipe(schemaSearchParams(CallbackParams), rejected$1("GitHub sent no code"));
|
|
120456
119561
|
if ((yield* HttpServerRequest).cookies[LOGIN_COOKIE] !== params.state) return yield* AuthError.make({ message: "The sign-in state does not match" });
|
|
120457
119562
|
const request = yield* HttpServerRequest;
|
|
120458
119563
|
const finished = yield* github.finish(params.code, params.state);
|
|
120459
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))));
|
|
120460
119565
|
}), catch_$2((cause) => flatMap$2(option$1(flatMap$2(schemaSearchParams(LoginState), (found) => github.cancel(found.state))), (flow) => githubFailed(cause, flow)))));
|
|
120461
119566
|
yield* router.add("GET", "/auth/code", limited("code", 20)(oauth(gen(function* () {
|
|
120462
|
-
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;
|
|
120463
119568
|
return waitingAt(yield* signIns.start({
|
|
120464
119569
|
_tag: "Browser",
|
|
120465
119570
|
...pipe(fromUndefinedOr(next), filter$8((page) => returnable(page, AUTH_URL)), match$8({
|
|
@@ -120471,7 +119576,7 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
120471
119576
|
yield* router.add("GET", "/auth/passkey", limited("passkey", 20)(oauth(map$5(passkeys.request, (options) => jsonUnsafe(options)))));
|
|
120472
119577
|
yield* router.add("POST", "/auth/passkey", limited("passkey", 20)(oauth(gen(function* () {
|
|
120473
119578
|
const request = yield* HttpServerRequest;
|
|
120474
|
-
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"));
|
|
120475
119580
|
const started = yield* tokens.startSession(yield* people.allowed(yield* passkeys.signIn(input.response)), originOf(request), "Passkey");
|
|
120476
119581
|
return setCookieUnsafe(jsonUnsafe(match$8(filter$8(fromUndefinedOr(input.next), (page) => returnable(page, AUTH_URL)), {
|
|
120477
119582
|
onNone: () => ({}),
|
|
@@ -120480,7 +119585,7 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
120480
119585
|
}))));
|
|
120481
119586
|
yield* router.add("GET", "/auth/continue", pipe(gen(function* () {
|
|
120482
119587
|
const request = yield* HttpServerRequest;
|
|
120483
|
-
const params = yield* pipe(schemaSearchParams(RequestParams), rejected("Name the sign-in"));
|
|
119588
|
+
const params = yield* pipe(schemaSearchParams(RequestParams), rejected$1("Name the sign-in"));
|
|
120484
119589
|
const collected = yield* signIns.collect(params.request, request.headers);
|
|
120485
119590
|
const cookie = `${REQUEST_COOKIE}${typedCode(params.request)}`;
|
|
120486
119591
|
return valueTags(collected, {
|
|
@@ -120491,7 +119596,7 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
120491
119596
|
status: 408
|
|
120492
119597
|
})
|
|
120493
119598
|
});
|
|
120494
|
-
}), 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"))));
|
|
120495
119600
|
yield* router.add("POST", "/auth/sign-out", oauth(gen(function* () {
|
|
120496
119601
|
yield* tokens.endSession((yield* HttpServerRequest).headers);
|
|
120497
119602
|
return expireCookieUnsafe(empty(), SESSION_COOKIE, sessionCookie(local));
|
|
@@ -120614,20 +119719,19 @@ const ToolHandlers = Tools.toLayer(gen(function* () {
|
|
|
120614
119719
|
return yield* signIns.answer(input, yield* CurrentUser, "Token");
|
|
120615
119720
|
}) });
|
|
120616
119721
|
}));
|
|
120617
|
-
const layerMcp = layerMcp$1({
|
|
120618
|
-
instructions: "Approve a sign-in you started with answer_request.",
|
|
120619
|
-
registrations: pipe(toolkit(Tools), provide$2(ToolHandlers))
|
|
120620
|
-
});
|
|
120621
119722
|
// src/main.server.ts
|
|
120622
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" })));
|
|
120623
119724
|
runApp({
|
|
120624
119725
|
icon: icon_default,
|
|
120625
119726
|
middleware: (app) => map$5(app, setHeader("content-security-policy", "frame-ancestors 'none'")),
|
|
120626
|
-
routes: pipe(mergeAll$1(HttpHandlers,
|
|
119727
|
+
routes: pipe(mergeAll$1(HttpHandlers, layerRpc({
|
|
120627
119728
|
group: RpcContracts,
|
|
120628
|
-
|
|
120629
|
-
|
|
120630
|
-
|
|
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)),
|
|
120631
119735
|
settings: {
|
|
120632
119736
|
GITHUB_ADMINS: ADMINS,
|
|
120633
119737
|
GITHUB_CLIENT_ID: {
|