@deslop/auth 0.1.1307 → 0.1.1312
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/(home)-CjNaYZr2.js +1 -0
- package/dist/client/assets/{Key.es-HCyZxhkH.js → Key.es-CciAV_uS.js} +1 -1
- package/dist/client/assets/app-bar-CMqfw6-k.js +2 -0
- package/dist/client/assets/auth-BNZWl1l6.js +1 -0
- package/dist/client/assets/{classes-DZJw-UPS.js → classes-DPMqTZNl.js} +1 -1
- package/dist/client/assets/components-DFpuUZ0C.js +1 -0
- package/dist/client/assets/dropdown-menu-BJ4ICzOG.js +1 -0
- package/dist/client/assets/{effect-C8zHkveL.js → effect-Cp782Xa9.js} +3 -3
- package/dist/client/assets/index-CDrOetKk.js +2 -0
- package/dist/client/assets/index-CZkeO0Bf.css +2 -0
- package/dist/client/assets/people-DRJK7J-M.js +1 -0
- package/dist/client/assets/{route-YDLb9hu7.js → route-DV3vVIwn.js} +1 -1
- package/dist/client/assets/route-DrBzRDDa.js +1 -0
- package/dist/client/assets/{useValueChanged-REzhet3E.js → useValueChanged-KanIHJJw.js} +1 -1
- package/dist/client/index.html +6 -6
- package/dist/server.js +91 -90
- package/package.json +2 -2
- package/dist/client/assets/(home)-oyW7SEwe.js +0 -1
- package/dist/client/assets/app-bar-CjAEEcKr.js +0 -2
- package/dist/client/assets/auth-kRvZth2E.js +0 -1
- package/dist/client/assets/components-B435d0-V.js +0 -1
- package/dist/client/assets/dropdown-menu-CRr0GfBh.js +0 -1
- package/dist/client/assets/index-Cvfuhb_M.js +0 -2
- package/dist/client/assets/index-OKVuL1St.css +0 -2
- package/dist/client/assets/people-S0zn_xwc.js +0 -1
- package/dist/client/assets/route-Cc3IuqZL.js +0 -1
package/dist/server.js
CHANGED
|
@@ -108230,7 +108230,7 @@ var Sessions = class Sessions extends Service$1()("@deslop/runtime/server/sessio
|
|
|
108230
108230
|
});
|
|
108231
108231
|
const granted = fnUntraced(function* (params) {
|
|
108232
108232
|
const response = yield* post$1(TOKEN_PATH, params);
|
|
108233
|
-
if (response.status === 400 || response.status === 401) return yield* RefusedError.make({ message: pipe(yield* option$1(schemaBodyJson$1(Refusal$1)(response)), flatMap$8((body) => body.error_description), getOrElse((
|
|
108233
|
+
if (response.status === 400 || response.status === 401) return yield* RefusedError.make({ message: pipe(yield* option$1(schemaBodyJson$1(Refusal$1)(response)), flatMap$8((body) => body.error_description), getOrElse(constant("Auth refused the sign-in"))) });
|
|
108234
108234
|
return yield* schemaBodyJson$1(TokenResponse$1)(yield* filterStatusOk$1(response));
|
|
108235
108235
|
});
|
|
108236
108236
|
const sessionOf = fnUntraced(function* (tokens, clientId, idHash) {
|
|
@@ -108314,7 +108314,7 @@ var Sessions = class Sessions extends Service$1()("@deslop/runtime/server/sessio
|
|
|
108314
108314
|
for (const session of yield* findSessionsOf(userId)) {
|
|
108315
108315
|
if (yield* fresh(session)) return value$2(session.access);
|
|
108316
108316
|
const renewed = yield* result$1(asAuthError("AI access is temporarily unavailable")(refreshed(session.idHash)));
|
|
108317
|
-
if (renewed
|
|
108317
|
+
if (isSuccess$1(renewed)) return value$2(renewed.success.access);
|
|
108318
108318
|
if (is$2(AuthError)(renewed.failure) && renewed.failure.error === "temporarily_unavailable") return yield* renewed.failure;
|
|
108319
108319
|
}
|
|
108320
108320
|
const now$8 = yield* now;
|
|
@@ -108395,7 +108395,7 @@ var Auth = class Auth extends Service$1()("@deslop/runtime/server/auth") {
|
|
|
108395
108395
|
issuer: new URL(ISSUER_PATH, issuer).href,
|
|
108396
108396
|
typ: "at+jwt"
|
|
108397
108397
|
}), provideService$2(Jwks, jwks), provideService$2(Signature, signature), mapError$2((cause) => {
|
|
108398
|
-
if (isJoseError(cause) && cause.reason
|
|
108398
|
+
if (isJoseError(cause) && cause.reason instanceof KeySetUnavailable) return AuthError.make({
|
|
108399
108399
|
cause,
|
|
108400
108400
|
error: "temporarily_unavailable",
|
|
108401
108401
|
message: "The authorization service is temporarily unavailable"
|
|
@@ -109244,6 +109244,11 @@ const SpanKind = {
|
|
|
109244
109244
|
consumer: 5
|
|
109245
109245
|
};
|
|
109246
109246
|
// ../../packages/runtime/src/shared/telemetry.ts
|
|
109247
|
+
Literals([
|
|
109248
|
+
"web",
|
|
109249
|
+
"mobile",
|
|
109250
|
+
"server"
|
|
109251
|
+
]);
|
|
109247
109252
|
function layerOtlp(serviceName, url, runtime, version) {
|
|
109248
109253
|
return catchCause$3(unwrap$7(gen(function* () {
|
|
109249
109254
|
const start = `${yield* currentTimeNanos}`;
|
|
@@ -109635,7 +109640,7 @@ const setLoadExtensionEnabled = (db, enabled) => {
|
|
|
109635
109640
|
// ../../packages/runtime/src/server/store.ts
|
|
109636
109641
|
const checkoutRoot = fnUntraced(function* (directory) {
|
|
109637
109642
|
const path = yield* Path$1;
|
|
109638
|
-
if (yield*
|
|
109643
|
+
if (getOrElse(yield* option$1((yield* FileSystem).exists(path.join(directory, "pnpm-workspace.yaml"))), constFalse$1)) return some$1(directory);
|
|
109639
109644
|
if (path.dirname(directory) === directory) return none();
|
|
109640
109645
|
return yield* checkoutRoot(path.dirname(directory));
|
|
109641
109646
|
});
|
|
@@ -109825,8 +109830,8 @@ const installService = fnUntraced(function* (name, command, options) {
|
|
|
109825
109830
|
yield* systemctl("daemon-reload");
|
|
109826
109831
|
yield* systemctl("enable", unit);
|
|
109827
109832
|
yield* systemctl(match(options?.restart === false, {
|
|
109828
|
-
onFalse: (
|
|
109829
|
-
onTrue: (
|
|
109833
|
+
onFalse: constant("restart"),
|
|
109834
|
+
onTrue: constant("start")
|
|
109830
109835
|
}), unit);
|
|
109831
109836
|
return `${unit} installed\n`;
|
|
109832
109837
|
});
|
|
@@ -109899,10 +109904,10 @@ function layerSignIn(issuer) {
|
|
|
109899
109904
|
})
|
|
109900
109905
|
});
|
|
109901
109906
|
}
|
|
109902
|
-
function withRedirect(
|
|
109907
|
+
function withRedirect(route) {
|
|
109903
109908
|
return flatMap$3(HttpServerRequest, (request) => pipe(liftThrowable(() => new URL(new URL(request.url, canonical).searchParams.get("next") ?? canonical, canonical))(), filter$9((next) => next.origin === canonical), match$7({
|
|
109904
109909
|
onNone: () => succeed$5(empty$2({ status: 400 })),
|
|
109905
|
-
onSome: (next) =>
|
|
109910
|
+
onSome: (next) => route(request, next)
|
|
109906
109911
|
})));
|
|
109907
109912
|
}
|
|
109908
109913
|
yield* router.add("GET", "/auth/sign-in", withRedirect(fnUntraced(function* (_, next) {
|
|
@@ -109935,7 +109940,7 @@ function layerSignIn(issuer) {
|
|
|
109935
109940
|
const started = yield* result$1(gen(function* () {
|
|
109936
109941
|
const params = yield* schemaSearchParams(CallbackParams$1);
|
|
109937
109942
|
if (!contains$1(params.state, saved.state)) return yield* AuthError.make({ message: "The sign-in began in another browser" });
|
|
109938
|
-
if (isSome(params.error) || isNone(params.code)) return yield* AuthError.make({ message: `Auth answered ${getOrElse(params.error, (
|
|
109943
|
+
if (isSome(params.error) || isNone(params.code)) return yield* AuthError.make({ message: `Auth answered ${getOrElse(params.error, constant("without a code"))}` });
|
|
109939
109944
|
if (!contains$1(params.iss, new URL("/api/auth", issuer).href)) return yield* AuthError.make({ message: "The answer came from another issuer" });
|
|
109940
109945
|
return yield* sessions.start({
|
|
109941
109946
|
client_id: yield* clientId,
|
|
@@ -110063,6 +110068,8 @@ const configProvider = fnUntraced(function* (given, defaultPort) {
|
|
|
110063
110068
|
}), fromEnv());
|
|
110064
110069
|
});
|
|
110065
110070
|
const layerPlatform = mergeAll$2(layer$8, layer$16, layer$19);
|
|
110071
|
+
Literals(["Error", "GlobalError"]);
|
|
110072
|
+
Literals(["Requires", "GlobalRequires"]);
|
|
110066
110073
|
function server(app) {
|
|
110067
110074
|
const routes = provide$2(mergeAll$2(app.routes, layerRoutes, layerIcon(app.icon), layerWeb), match$7(fromUndefinedOr(app.middleware), {
|
|
110068
110075
|
onNone: () => empty$13,
|
|
@@ -110160,6 +110167,13 @@ const ClientRequest = Struct$2({
|
|
|
110160
110167
|
redirectUri: NonEmptyString,
|
|
110161
110168
|
state: OptionFromOptionalKey(NonEmptyString)
|
|
110162
110169
|
});
|
|
110170
|
+
const Code = TaggedUnion({
|
|
110171
|
+
Fresh: {
|
|
110172
|
+
owner: CredentialOwner,
|
|
110173
|
+
request: ClientRequest
|
|
110174
|
+
},
|
|
110175
|
+
Used: { family: SignInFamily }
|
|
110176
|
+
});
|
|
110163
110177
|
const DeviceRequest = Struct$2({
|
|
110164
110178
|
clientId: ClientId.check(isNonEmpty()),
|
|
110165
110179
|
clientName: String$6
|
|
@@ -110265,7 +110279,7 @@ const RevokeParams = Struct$2({
|
|
|
110265
110279
|
client_id: ClientId.check(isNonEmpty()),
|
|
110266
110280
|
token: NonEmptyString
|
|
110267
110281
|
});
|
|
110268
|
-
|
|
110282
|
+
Literals(["Session", "Token"]);
|
|
110269
110283
|
const SignInKind = Literals(["App", "Browser"]);
|
|
110270
110284
|
const SignInCode = pipe(String$6, brand("SignInCode"));
|
|
110271
110285
|
const PendingAuthorization = Struct$2({
|
|
@@ -110282,7 +110296,7 @@ const AuthorizationStatus = TaggedUnion({
|
|
|
110282
110296
|
Expired: {},
|
|
110283
110297
|
Waiting: { request: PendingAuthorization }
|
|
110284
110298
|
});
|
|
110285
|
-
TaggedUnion({
|
|
110299
|
+
const Delivery = TaggedUnion({
|
|
110286
110300
|
Browser: { next: OptionFromOptionalKey(String$6) },
|
|
110287
110301
|
Client: { request: ClientRequest },
|
|
110288
110302
|
Device: { request: DeviceRequest }
|
|
@@ -110338,7 +110352,7 @@ const Person = Struct$2({
|
|
|
110338
110352
|
since: pipe(Finite, decodeTo(Option(DateTimeUtc), {
|
|
110339
110353
|
decode: transform$4((value) => pipe(value, liftPredicate((time) => time !== 0), map$13(makeUnsafe$2))),
|
|
110340
110354
|
encode: transform$4((value) => match$7(value, {
|
|
110341
|
-
onNone: ()
|
|
110355
|
+
onNone: constant(0),
|
|
110342
110356
|
onSome: toEpochMillis
|
|
110343
110357
|
}))
|
|
110344
110358
|
}))
|
|
@@ -110503,7 +110517,7 @@ function originFrom(headers, remote) {
|
|
|
110503
110517
|
};
|
|
110504
110518
|
}
|
|
110505
110519
|
function clientLabel(name) {
|
|
110506
|
-
return pipe(name, replace(/\s*\([^)]*\)$/u, ""), trim, capitalize, liftPredicate(isNonEmpty$1), getOrElse((
|
|
110520
|
+
return pipe(name, replace(/\s*\([^)]*\)$/u, ""), trim, capitalize, liftPredicate(isNonEmpty$1), getOrElse(constant("Unknown client")));
|
|
110507
110521
|
}
|
|
110508
110522
|
function platform$1(userAgent) {
|
|
110509
110523
|
if (includes("iPhone")(userAgent)) return some$1("iPhone");
|
|
@@ -110517,7 +110531,7 @@ function platform$1(userAgent) {
|
|
|
110517
110531
|
}
|
|
110518
110532
|
function browserLabel(origin) {
|
|
110519
110533
|
return match$7(origin.userAgent, {
|
|
110520
|
-
onNone: (
|
|
110534
|
+
onNone: constant("Browser"),
|
|
110521
110535
|
onSome: (agent) => {
|
|
110522
110536
|
if (includes("Edg/")(agent)) return "Edge";
|
|
110523
110537
|
if (includes("Firefox/")(agent)) return "Firefox";
|
|
@@ -110531,7 +110545,7 @@ function deviceLabel(origin) {
|
|
|
110531
110545
|
return pipe(flatMap$8(origin.address, (address) => {
|
|
110532
110546
|
if (exists(parsedAddress(address), (ip) => isLinkLocal(ip) || isLoopback(ip) || isPrivateAddress(ip))) return some$1("dev");
|
|
110533
110547
|
return get$10(WORKERS, address);
|
|
110534
|
-
}), orElse$3(() => flatMap$8(origin.userAgent, platform$1)), getOrElse(() => getOrElse(origin.address, (
|
|
110548
|
+
}), orElse$3(() => flatMap$8(origin.userAgent, platform$1)), getOrElse(() => getOrElse(origin.address, constant("unknown"))));
|
|
110535
110549
|
}
|
|
110536
110550
|
function loopback(redirect) {
|
|
110537
110551
|
return filter$9(getSuccess(fromString(redirect)), (target) => target.protocol === "http:" && contains([
|
|
@@ -110617,7 +110631,7 @@ function callbackUrl(request, answer, issuer) {
|
|
|
110617
110631
|
function returnable(next, url) {
|
|
110618
110632
|
const domain = "mp281x.xyz";
|
|
110619
110633
|
return match$5(fromString(next), {
|
|
110620
|
-
onFailure:
|
|
110634
|
+
onFailure: constFalse$1,
|
|
110621
110635
|
onSuccess: (target) => (target.origin === new URL(url).origin || target.protocol === "https:" && (target.hostname === domain || endsWith(`.${domain}`)(target.hostname))) && isEmpty$1(target.username) && isEmpty$1(target.password)
|
|
110622
110636
|
});
|
|
110623
110637
|
}
|
|
@@ -132353,7 +132367,7 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
|
|
|
132353
132367
|
const sql = yield* SqlClient;
|
|
132354
132368
|
const origin = new URL(yield* String$5("APP_URL")).origin;
|
|
132355
132369
|
const rpID = match(yield* localAuth, {
|
|
132356
|
-
onFalse: (
|
|
132370
|
+
onFalse: constant("mp281x.xyz"),
|
|
132357
132371
|
onTrue: () => new URL(origin).hostname
|
|
132358
132372
|
});
|
|
132359
132373
|
const registering = yield* makeRecords(LIFETIME);
|
|
@@ -132837,16 +132851,16 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
132837
132851
|
issuer,
|
|
132838
132852
|
typ: "at+jwt"
|
|
132839
132853
|
}), Signature, signature);
|
|
132840
|
-
const now$
|
|
132854
|
+
const now$5 = yield* now;
|
|
132841
132855
|
const grant = yield* flatMap$3(findGrant({
|
|
132842
132856
|
family: verified.claims.sid,
|
|
132843
|
-
now: now$
|
|
132857
|
+
now: now$5
|
|
132844
132858
|
}), fromOption);
|
|
132845
132859
|
if (grant.userId !== verified.claims.sub) return yield* AuthError.make({ message: "Sign in first" });
|
|
132846
|
-
if (isGreaterThan$1(now$
|
|
132847
|
-
before: subtractDuration(now$
|
|
132860
|
+
if (isGreaterThan$1(now$5, addDuration(grant.lastActive, minutes(1)))) yield* pipe(touchGrant({
|
|
132861
|
+
before: subtractDuration(now$5, minutes(1)),
|
|
132848
132862
|
family: grant.family,
|
|
132849
|
-
now: now$
|
|
132863
|
+
now: now$5
|
|
132850
132864
|
}), mutation(["tokens"]), ignore$1({
|
|
132851
132865
|
log: "Warn",
|
|
132852
132866
|
message: "The token’s last use could not be saved"
|
|
@@ -132909,9 +132923,9 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
132909
132923
|
const verifier = yield* hash(params.code_verifier);
|
|
132910
132924
|
const family = SignInFamily.make(yield* randomToken(16));
|
|
132911
132925
|
const result = yield* pipe(gen(function* () {
|
|
132912
|
-
const now$
|
|
132926
|
+
const now$7 = yield* now;
|
|
132913
132927
|
const code = yield* pipe(yield* codes.get(key), map$13((entry) => entry.value), fromOption, mapError$2(() => expired$1));
|
|
132914
|
-
if (
|
|
132928
|
+
if (Code.guards.Used(code)) {
|
|
132915
132929
|
yield* deleteFamily(code.family);
|
|
132916
132930
|
return Exchange.cases.Replayed.make({ message: "This authorization code was already used, so the tokens it gave are revoked; sign in again" });
|
|
132917
132931
|
}
|
|
@@ -132926,26 +132940,23 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
132926
132940
|
onSome: fnUntraced(function* (parent) {
|
|
132927
132941
|
if (!exists(yield* findSession({
|
|
132928
132942
|
family: parent,
|
|
132929
|
-
now: now$
|
|
132943
|
+
now: now$7
|
|
132930
132944
|
}), (found) => sameOwner(credentialOwnerOf(found), fresh.owner))) return yield* expired$1;
|
|
132931
132945
|
})
|
|
132932
132946
|
});
|
|
132933
|
-
return Exchange.cases.Granted.make({ tokens: yield* signIn(now$
|
|
132947
|
+
return Exchange.cases.Granted.make({ tokens: yield* signIn(now$7, family, fresh.request, fresh.owner, origin) });
|
|
132934
132948
|
}), mutation(["tokens"]), sql.withTransaction);
|
|
132935
|
-
if (
|
|
132936
|
-
_tag: "Used",
|
|
132937
|
-
family
|
|
132938
|
-
}));
|
|
132949
|
+
if (Exchange.guards.Granted(result)) yield* codes.consume(key, some$1(Code.cases.Used.make({ family })));
|
|
132939
132950
|
return result;
|
|
132940
132951
|
}, uninterruptible, withPermit(redeeming));
|
|
132941
132952
|
const rotate = fnUntraced(function* (params, origin, allowed) {
|
|
132942
132953
|
const presented = yield* pipe(parts(params.refresh_token), fromOption, mapError$2(() => expired$1));
|
|
132943
132954
|
const presentedHash = yield* hash(presented.secret);
|
|
132944
132955
|
return yield* pipe(gen(function* () {
|
|
132945
|
-
const now$
|
|
132956
|
+
const now$6 = yield* now;
|
|
132946
132957
|
const grant = yield* flatMap$3(findGrant({
|
|
132947
132958
|
family: presented.family,
|
|
132948
|
-
now: now$
|
|
132959
|
+
now: now$6
|
|
132949
132960
|
}), match$7({
|
|
132950
132961
|
onNone: () => fail$7(expired$1),
|
|
132951
132962
|
onSome: succeed$5
|
|
@@ -132955,7 +132966,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
132955
132966
|
message: "The refresh token belongs to another client"
|
|
132956
132967
|
});
|
|
132957
132968
|
if (match$7(presented.generation, {
|
|
132958
|
-
onNone:
|
|
132969
|
+
onNone: constTrue,
|
|
132959
132970
|
onSome: (generation) => generation < grant.generation
|
|
132960
132971
|
}) && isSome(yield* isSpent({
|
|
132961
132972
|
family: grant.family,
|
|
@@ -132967,7 +132978,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
132967
132978
|
if (!contains$1(presented.generation, grant.generation) || presentedHash !== grant.hash) return yield* expired$1;
|
|
132968
132979
|
const owner = credentialOwnerOf(grant);
|
|
132969
132980
|
yield* allowed(owner);
|
|
132970
|
-
const minted = yield* asAuthError("Cannot sign the access token")(mint(grant.family, grant.generation + 1, owner, grant.client, now$
|
|
132981
|
+
const minted = yield* asAuthError("Cannot sign the access token")(mint(grant.family, grant.generation + 1, owner, grant.client, now$6));
|
|
132971
132982
|
yield* insertSpent({
|
|
132972
132983
|
family: grant.family,
|
|
132973
132984
|
hash: grant.hash
|
|
@@ -132977,7 +132988,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
132977
132988
|
device: deviceLabel(origin),
|
|
132978
132989
|
family: grant.family,
|
|
132979
132990
|
generation: grant.generation + 1,
|
|
132980
|
-
lastActive: now$
|
|
132991
|
+
lastActive: now$6,
|
|
132981
132992
|
...minted.refresh
|
|
132982
132993
|
});
|
|
132983
132994
|
return Exchange.cases.Granted.make({ tokens: minted.tokens });
|
|
@@ -133017,13 +133028,13 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
133017
133028
|
}, withReactivity, asAuthError("Cannot sign the command in")),
|
|
133018
133029
|
disconnect: fn("Tokens.disconnect")(function* (family, owner) {
|
|
133019
133030
|
yield* pipe(gen(function* () {
|
|
133020
|
-
const now$
|
|
133031
|
+
const now$4 = yield* now;
|
|
133021
133032
|
const signedIn = [...toArray$1(yield* findSession({
|
|
133022
133033
|
family,
|
|
133023
|
-
now: now$
|
|
133034
|
+
now: now$4
|
|
133024
133035
|
})), ...toArray$1(yield* findGrant({
|
|
133025
133036
|
family,
|
|
133026
|
-
now: now$
|
|
133037
|
+
now: now$4
|
|
133027
133038
|
}))];
|
|
133028
133039
|
if (!some(signedIn, (row) => sameOwner(credentialOwnerOf(row), owner))) return yield* AuthError.make({ message: "This sign-in has already ended" });
|
|
133029
133040
|
yield* deleteFamily(family);
|
|
@@ -133044,11 +133055,10 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
133044
133055
|
}, withReactivity, asAuthError("Cannot sign this account out")),
|
|
133045
133056
|
issue: fn("Tokens.issue")(function* (request, owner) {
|
|
133046
133057
|
const code = yield* randomToken(32);
|
|
133047
|
-
yield* codes.create(yield* hash(code), {
|
|
133048
|
-
_tag: "Fresh",
|
|
133058
|
+
yield* codes.create(yield* hash(code), Code.cases.Fresh.make({
|
|
133049
133059
|
owner,
|
|
133050
133060
|
request
|
|
133051
|
-
});
|
|
133061
|
+
}));
|
|
133052
133062
|
return code;
|
|
133053
133063
|
}, asAuthError("Cannot issue the authorization code")),
|
|
133054
133064
|
issuer,
|
|
@@ -133077,14 +133087,14 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
133077
133087
|
hash: presented
|
|
133078
133088
|
})))));
|
|
133079
133089
|
yield* pipe(gen(function* () {
|
|
133080
|
-
const now$
|
|
133081
|
-
yield* deleteExpired(now$
|
|
133090
|
+
const now$3 = yield* now;
|
|
133091
|
+
yield* deleteExpired(now$3);
|
|
133082
133092
|
yield* match$7(previous, {
|
|
133083
133093
|
onNone: () => void_$2,
|
|
133084
133094
|
onSome: fnUntraced(function* (prior) {
|
|
133085
133095
|
if (exists(yield* findSession({
|
|
133086
133096
|
family: prior.family,
|
|
133087
|
-
now: now$
|
|
133097
|
+
now: now$3
|
|
133088
133098
|
}), (found) => found.hash === prior.hash)) yield* deleteFamily(prior.family);
|
|
133089
133099
|
})
|
|
133090
133100
|
});
|
|
@@ -133092,11 +133102,11 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
133092
133102
|
address: origin.address,
|
|
133093
133103
|
client: browserLabel(origin),
|
|
133094
133104
|
device: deviceLabel(origin),
|
|
133095
|
-
expiresAt: addDuration(now$
|
|
133105
|
+
expiresAt: addDuration(now$3, seconds),
|
|
133096
133106
|
family,
|
|
133097
133107
|
hash: sessionHash,
|
|
133098
133108
|
incarnation: owner.incarnation,
|
|
133099
|
-
lastActive: now$
|
|
133109
|
+
lastActive: now$3,
|
|
133100
133110
|
userId: owner.user.id,
|
|
133101
133111
|
userName: owner.user.name,
|
|
133102
133112
|
via
|
|
@@ -133283,8 +133293,8 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
133283
133293
|
name: profile.login,
|
|
133284
133294
|
since,
|
|
133285
133295
|
status: match(isAdmin(admins, id), {
|
|
133286
|
-
onFalse: (
|
|
133287
|
-
onTrue: (
|
|
133296
|
+
onFalse: constant("Waiting"),
|
|
133297
|
+
onTrue: constant("Allowed")
|
|
133288
133298
|
})
|
|
133289
133299
|
})),
|
|
133290
133300
|
onSome: () => renameMember({
|
|
@@ -133334,7 +133344,7 @@ function typedCode(text) {
|
|
|
133334
133344
|
return toUpperCase(replaceAll(/[^a-z]/giu, "")(text));
|
|
133335
133345
|
}
|
|
133336
133346
|
function codeFrom(bytes) {
|
|
133337
|
-
return SignInCode.make(pipe(fromIterable$5(bytes), map$10((byte) => pipe(CODE_LETTERS, charAt(byte % 20), getOrElse((
|
|
133347
|
+
return SignInCode.make(pipe(fromIterable$5(bytes), map$10((byte) => pipe(CODE_LETTERS, charAt(byte % 20), getOrElse(constant("")))), join$4("")));
|
|
133338
133348
|
}
|
|
133339
133349
|
// src/services/sign-ins/service.ts
|
|
133340
133350
|
const REQUEST_COOKIE = "__Host-request-";
|
|
@@ -133357,9 +133367,9 @@ function pendingOf(entry) {
|
|
|
133357
133367
|
Device: (device) => clientIconOf(device.request.clientId)
|
|
133358
133368
|
}),
|
|
133359
133369
|
id: signIn.id,
|
|
133360
|
-
kind: match(signIn.delivery
|
|
133361
|
-
onFalse: (
|
|
133362
|
-
onTrue: (
|
|
133370
|
+
kind: match(Delivery.guards.Browser(signIn.delivery), {
|
|
133371
|
+
onFalse: constant("App"),
|
|
133372
|
+
onTrue: constant("Browser")
|
|
133363
133373
|
})
|
|
133364
133374
|
});
|
|
133365
133375
|
}
|
|
@@ -133419,7 +133429,7 @@ var SignIns = class SignIns extends Service$1()("@deslop/auth/services/sign-ins/
|
|
|
133419
133429
|
yield* people.allowed(owner);
|
|
133420
133430
|
const entry = yield* pipe(find(params.request), flatMap$3(fromOption), mapError$2(() => notWaiting));
|
|
133421
133431
|
if (isSome(entry.value.answer)) return yield* notWaiting;
|
|
133422
|
-
if (via === "Token" && entry.value.delivery
|
|
133432
|
+
if (via === "Token" && Delivery.guards.Browser(entry.value.delivery)) return yield* AuthError.make({ message: `A browser sign-in is approved only from a signed-in browser: ask the user to approve it at ${AUTH_URL}` });
|
|
133423
133433
|
yield* records.update(entry.value.id, (signIn) => ({
|
|
133424
133434
|
...signIn,
|
|
133425
133435
|
answer: some$1(liftPredicate(owner, () => params.accept))
|
|
@@ -133436,7 +133446,7 @@ var SignIns = class SignIns extends Service$1()("@deslop/auth/services/sign-ins/
|
|
|
133436
133446
|
error: "expired_token",
|
|
133437
133447
|
message: "The device code expired; sign in again"
|
|
133438
133448
|
})));
|
|
133439
|
-
if (entry.value.delivery
|
|
133449
|
+
if (!Delivery.guards.Device(entry.value.delivery) || entry.value.delivery.request.clientId !== params.client_id) return yield* AuthError.make({
|
|
133440
133450
|
error: "invalid_grant",
|
|
133441
133451
|
message: "The device code belongs to another client"
|
|
133442
133452
|
});
|
|
@@ -133445,7 +133455,7 @@ var SignIns = class SignIns extends Service$1()("@deslop/auth/services/sign-ins/
|
|
|
133445
133455
|
message: "Waiting for approval"
|
|
133446
133456
|
});
|
|
133447
133457
|
const answer = yield* deliver(entry, none());
|
|
133448
|
-
if (
|
|
133458
|
+
if (!Collected.guards.Granted(answer)) return yield* AuthError.make({
|
|
133449
133459
|
error: "access_denied",
|
|
133450
133460
|
message: "The sign-in was denied"
|
|
133451
133461
|
});
|
|
@@ -133454,9 +133464,9 @@ var SignIns = class SignIns extends Service$1()("@deslop/auth/services/sign-ins/
|
|
|
133454
133464
|
start: fn("SignIns.start")(function* (delivery, origin) {
|
|
133455
133465
|
const code = codeFrom(yield* random.randomBytes(8));
|
|
133456
133466
|
const receiver = yield* randomToken(32);
|
|
133457
|
-
const group = addressGroup(getOrElse(origin.address, (
|
|
133467
|
+
const group = addressGroup(getOrElse(origin.address, constant("unknown")));
|
|
133458
133468
|
const current = yield* records.values;
|
|
133459
|
-
const fromGroup = filter$7(current, (entry) => addressGroup(getOrElse(entry.value.origin.address, (
|
|
133469
|
+
const fromGroup = filter$7(current, (entry) => addressGroup(getOrElse(entry.value.origin.address, constant("unknown"))) === group);
|
|
133460
133470
|
if (current.length >= 1e3 || fromGroup.length >= 20 || isSome(yield* records.get(code))) return yield* AuthError.make({
|
|
133461
133471
|
error: "temporarily_unavailable",
|
|
133462
133472
|
message: "Start the sign-in again"
|
|
@@ -133479,7 +133489,7 @@ var SignIns = class SignIns extends Service$1()("@deslop/auth/services/sign-ins/
|
|
|
133479
133489
|
onFalse: () => AuthorizationStatus.cases.Decided.make({}),
|
|
133480
133490
|
onTrue: () => AuthorizationStatus.cases.Waiting.make({ request: pendingOf(signIn) })
|
|
133481
133491
|
}))
|
|
133482
|
-
})), takeUntil((status) =>
|
|
133492
|
+
})), takeUntil((status) => !AuthorizationStatus.guards.Waiting(status)), withSpan("SignIns.status", { attributes: { "rpc.stream": true } }))
|
|
133483
133493
|
});
|
|
133484
133494
|
}));
|
|
133485
133495
|
};
|
|
@@ -133520,7 +133530,7 @@ function githubFailed(cause, flow) {
|
|
|
133520
133530
|
}
|
|
133521
133531
|
function returnTo(flow, origin) {
|
|
133522
133532
|
return pipe(toString$1(fromInput(omit(encodeSync(SignInParams)(flow), ["next"]))), liftPredicate(isNonEmpty$1), match$7({
|
|
133523
|
-
onNone: () => pipe(flow.next, filter$9((next) => returnable(next, origin)), getOrElse((
|
|
133533
|
+
onNone: () => pipe(flow.next, filter$9((next) => returnable(next, origin)), getOrElse(constant("/"))),
|
|
133524
133534
|
onSome: (search) => `/?${search}`
|
|
133525
133535
|
}));
|
|
133526
133536
|
}
|
|
@@ -133535,7 +133545,7 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
133535
133545
|
function limited(route, perAddress) {
|
|
133536
133546
|
return fnUntraced(function* (handler) {
|
|
133537
133547
|
const request = yield* HttpServerRequest;
|
|
133538
|
-
const address = pipe(clientAddress(request.headers, request.remoteAddress), map$13(addressGroup), getOrElse((
|
|
133548
|
+
const address = pipe(clientAddress(request.headers, request.remoteAddress), map$13(addressGroup), getOrElse(constant("unknown")));
|
|
133539
133549
|
return yield* matchEffect(limiter.consume({
|
|
133540
133550
|
key: `${route}:${address}`,
|
|
133541
133551
|
limit: perAddress,
|
|
@@ -133545,7 +133555,7 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
133545
133555
|
onFailure: (failure) => succeed$5(text("Too many requests; retry later", {
|
|
133546
133556
|
headers: { "retry-after": valueTags(failure.reason, {
|
|
133547
133557
|
RateLimitExceeded: (exceeded) => `${Math.ceil(toSeconds(exceeded.retryAfter))}`,
|
|
133548
|
-
RateLimitStoreError: (
|
|
133558
|
+
RateLimitStoreError: constant("5")
|
|
133549
133559
|
}) },
|
|
133550
133560
|
status: 429
|
|
133551
133561
|
})),
|
|
@@ -133583,7 +133593,7 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
133583
133593
|
error: "invalid_redirect_uri",
|
|
133584
133594
|
message: "Use a Deslop web or iOS callback, a loopback callback or a Gateway server callback"
|
|
133585
133595
|
});
|
|
133586
|
-
const name = getOrElse(params.client_name, (
|
|
133596
|
+
const name = getOrElse(params.client_name, constant("Unknown client"));
|
|
133587
133597
|
return jsonUnsafe({
|
|
133588
133598
|
client_id: clientIdOf({
|
|
133589
133599
|
name,
|
|
@@ -133601,12 +133611,9 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
133601
133611
|
const asked = yield* asAuthError("The authorization request names no client_id")(schemaSearchParams(AuthorizeClient));
|
|
133602
133612
|
const client = yield* tokens.client(asked);
|
|
133603
133613
|
return yield* pipe(schemaSearchParams(AuthorizeParams), asAuthError("Invalid authorization request"), flatMap$3((params) => clientRequest(asked, client, params)), flatMap$3(fnUntraced(function* (checked) {
|
|
133604
|
-
if (!webRedirect(checked.redirectUri)) return waitingAt(yield* signIns.start({
|
|
133605
|
-
_tag: "Client",
|
|
133606
|
-
request: checked
|
|
133607
|
-
}, originOf(request)));
|
|
133614
|
+
if (!webRedirect(checked.redirectUri)) return waitingAt(yield* signIns.start(Delivery.cases.Client.make({ request: checked }), originOf(request)));
|
|
133608
133615
|
const browser = yield* pipe(tokens.browserSession(request.headers), tap$2((found) => people.allowed(found.owner)), result$1);
|
|
133609
|
-
if (browser
|
|
133616
|
+
if (isFailure$1(browser)) {
|
|
133610
133617
|
if (browser.failure.error === "temporarily_unavailable" || browser.failure.error === "access_denied") return yield* browser.failure;
|
|
133611
133618
|
return redirect(`/?${new URLSearchParams({ next: new URL(request.url, origin).href })}`);
|
|
133612
133619
|
}
|
|
@@ -133625,17 +133632,14 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
133625
133632
|
yield* router.add("POST", DEVICE_PATH, limited("device", 10)(oauth(gen(function* () {
|
|
133626
133633
|
const request = yield* HttpServerRequest;
|
|
133627
133634
|
const params = yield* asAuthError("Send a client_id")(schemaBodyUrlParams(DeviceParams));
|
|
133628
|
-
const started = yield* signIns.start({
|
|
133629
|
-
|
|
133630
|
-
|
|
133631
|
-
|
|
133632
|
-
|
|
133633
|
-
|
|
133634
|
-
|
|
133635
|
-
|
|
133636
|
-
})).clientName
|
|
133637
|
-
}
|
|
133638
|
-
}, originOf(request));
|
|
133635
|
+
const started = yield* signIns.start(Delivery.cases.Device.make({ request: {
|
|
133636
|
+
clientId: params.client_id,
|
|
133637
|
+
clientName: (yield* tokens.client({
|
|
133638
|
+
client_id: params.client_id,
|
|
133639
|
+
redirect_uri: none(),
|
|
133640
|
+
state: none()
|
|
133641
|
+
})).clientName
|
|
133642
|
+
} }), originOf(request));
|
|
133639
133643
|
return jsonUnsafe({
|
|
133640
133644
|
device_code: started.receiver,
|
|
133641
133645
|
expires_in: toSeconds(SIGN_IN_LIFETIME),
|
|
@@ -133671,19 +133675,16 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
133671
133675
|
maxAge: "10 minutes"
|
|
133672
133676
|
});
|
|
133673
133677
|
}))));
|
|
133674
|
-
yield* router.add("GET", "/auth/github/callback",
|
|
133678
|
+
yield* router.add("GET", "/auth/github/callback", catchTag(gen(function* () {
|
|
133675
133679
|
const params = yield* asAuthError("GitHub sent no code")(schemaSearchParams(CallbackParams));
|
|
133676
133680
|
if ((yield* HttpServerRequest).cookies[LOGIN_COOKIE] !== params.state) return yield* AuthError.make({ message: "The sign-in state does not match" });
|
|
133677
133681
|
const request = yield* HttpServerRequest;
|
|
133678
133682
|
const finished = yield* github.finish(params.code, params.state);
|
|
133679
|
-
return yield* pipe(people.register(finished.profile), flatMap$3((user) => tokens.startSession(user, originOf(request), "GitHub", browserToken(request.headers))), map$7((started) => pipe(redirect(returnTo(finished.flow, origin)), expireCookieUnsafe(LOGIN_COOKIE, COOKIE), setCookieUnsafe(SESSION_COOKIE, started.token, session(started.seconds)))),
|
|
133680
|
-
}), (cause) => flatMap$3(option$1(flatMap$3(schemaSearchParams(LoginState), (found) => github.cancel(found.state))), (flow) => githubFailed(cause, flow))));
|
|
133683
|
+
return yield* pipe(people.register(finished.profile), flatMap$3((user) => tokens.startSession(user, originOf(request), "GitHub", browserToken(request.headers))), map$7((started) => pipe(redirect(returnTo(finished.flow, origin)), expireCookieUnsafe(LOGIN_COOKIE, COOKIE), setCookieUnsafe(SESSION_COOKIE, started.token, session(started.seconds)))), catchTag("AuthError", (cause) => githubFailed(cause, some$1(finished.flow))));
|
|
133684
|
+
}), "AuthError", (cause) => flatMap$3(option$1(flatMap$3(schemaSearchParams(LoginState), (found) => github.cancel(found.state))), (flow) => githubFailed(cause, flow))));
|
|
133681
133685
|
yield* router.add("GET", "/auth/code", limited("code", 20)(oauth(gen(function* () {
|
|
133682
133686
|
const next = (yield* asAuthError("Invalid sign-in request")(schemaSearchParams(BrowserParams))).next;
|
|
133683
|
-
return waitingAt(yield* signIns.start({
|
|
133684
|
-
_tag: "Browser",
|
|
133685
|
-
next: filter$9(next, (page) => returnable(page, origin))
|
|
133686
|
-
}, originOf(yield* HttpServerRequest)));
|
|
133687
|
+
return waitingAt(yield* signIns.start(Delivery.cases.Browser.make({ next: filter$9(next, (page) => returnable(page, origin)) }), originOf(yield* HttpServerRequest)));
|
|
133687
133688
|
}))));
|
|
133688
133689
|
yield* router.add("GET", "/auth/passkey", limited("passkey", 20)(oauth(flatMap$3(passkeys.request, schemaJson(RequestOptions)))));
|
|
133689
133690
|
yield* router.add("POST", "/auth/passkey", limited("passkey", 20)(oauth(gen(function* () {
|
|
@@ -133704,9 +133705,9 @@ const HttpHandlers = use((router) => gen(function* () {
|
|
|
133704
133705
|
Denied: () => text("This sign-in belongs to a command", { status: 400 }),
|
|
133705
133706
|
Granted: () => text("This sign-in belongs to a command", { status: 400 }),
|
|
133706
133707
|
Redirect: (found) => expireCookieUnsafe(redirect(found.url), cookie, COOKIE),
|
|
133707
|
-
Session: (found) => pipe(redirect(getOrElse(found.next, (
|
|
133708
|
+
Session: (found) => pipe(redirect(getOrElse(found.next, constant("/"))), expireCookieUnsafe(cookie, COOKIE), setCookieUnsafe(SESSION_COOKIE, found.token, session(found.seconds)))
|
|
133708
133709
|
});
|
|
133709
|
-
}), asAuthError("Cannot complete the sign-in"),
|
|
133710
|
+
}), asAuthError("Cannot complete the sign-in"), catchTag("AuthError", (failure) => succeed$5(text(failure.message, { status: 400 }))), map$7(setHeader("cache-control", "no-store"))));
|
|
133710
133711
|
yield* router.add("POST", "/auth/sign-out", oauth(gen(function* () {
|
|
133711
133712
|
yield* tokens.endSession((yield* HttpServerRequest).headers);
|
|
133712
133713
|
return expireCookieUnsafe(empty$2(), SESSION_COOKIE, COOKIE);
|
|
@@ -133828,7 +133829,7 @@ const ToolContracts = make$18(make$19("answer_sign_in", {
|
|
|
133828
133829
|
// src/tools/handlers.ts
|
|
133829
133830
|
function page(rows, key, input) {
|
|
133830
133831
|
const remaining = pipe(rows, sort(mapInput(String$10, key)), filter$7((row) => match$7(input.cursor, {
|
|
133831
|
-
onNone:
|
|
133832
|
+
onNone: constTrue,
|
|
133832
133833
|
onSome: (cursor) => key(row) > cursor
|
|
133833
133834
|
})));
|
|
133834
133835
|
const items = take$3(remaining, input.limit);
|
|
@@ -133849,8 +133850,8 @@ const layerMcpOwner = unwrap$7(gen(function* () {
|
|
|
133849
133850
|
})
|
|
133850
133851
|
}), mapError$2((error) => McpErrorBase.make({
|
|
133851
133852
|
code: match(error.error === "temporarily_unavailable", {
|
|
133852
|
-
onFalse: (
|
|
133853
|
-
onTrue: (
|
|
133853
|
+
onFalse: constant(-32001),
|
|
133854
|
+
onTrue: constant(-32603)
|
|
133854
133855
|
}),
|
|
133855
133856
|
message: error.message
|
|
133856
133857
|
})), flatMap$3((owner) => provideService$2(effect, CurrentOwner, owner)))).layer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deslop/auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1312",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/MP281X/deslop.git",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=26"
|
|
35
35
|
},
|
|
36
|
-
"fingerprint": "
|
|
36
|
+
"fingerprint": "75d0e60b8e5eb941a7289428c2ec8abc0d3b85f05a659e81b486298fd68a5d9b"
|
|
37
37
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,n,o as r}from"./react-BPjvcVqE.js";import{B as i,E as a,I as o,N as s,R as c,c as l,f as u,p as d,u as f,w as p}from"./auth-kRvZth2E.js";import{Bo as m,Lo as h,Po as g,Qo as _,Za as v,pt as y}from"./effect-C8zHkveL.js";import{n as b,t as ee}from"./useValueChanged-REzhet3E.js";import{t as x}from"./Key.es-HCyZxhkH.js";import{_ as S,g as C,i as w,m as T,o as E,s as D,t as O,v as k,z as A}from"./classes-DZJw-UPS.js";import{r as j}from"./route-YDLb9hu7.js";import{D as te,H as M,L as ne,P as re,U as N,i as P,r as F,z as I}from"./components-B435d0-V.js";var L=e(r(),1),R=new Map([[`bold`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z`}))],[`duotone`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`,opacity:`0.2`}),L.createElement(`path`,{d:`M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z`}))],[`fill`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM181.66,170.34a8,8,0,0,1-11.32,11.32L128,139.31,85.66,181.66a8,8,0,0,1-11.32-11.32L116.69,128,74.34,85.66A8,8,0,0,1,85.66,74.34L128,116.69l42.34-42.35a8,8,0,0,1,11.32,11.32L139.31,128Z`}))],[`light`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M204.24,195.76a6,6,0,1,1-8.48,8.48L128,136.49,60.24,204.24a6,6,0,0,1-8.48-8.48L119.51,128,51.76,60.24a6,6,0,0,1,8.48-8.48L128,119.51l67.76-67.75a6,6,0,0,1,8.48,8.48L136.49,128Z`}))],[`regular`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M205.66,194.34a8,8,0,0,1-11.32,11.32L128,139.31,61.66,205.66a8,8,0,0,1-11.32-11.32L116.69,128,50.34,61.66A8,8,0,0,1,61.66,50.34L128,116.69l66.34-66.35a8,8,0,0,1,11.32,11.32L139.31,128Z`}))],[`thin`,L.createElement(L.Fragment,null,L.createElement(`path`,{d:`M202.83,197.17a4,4,0,0,1-5.66,5.66L128,133.66,58.83,202.83a4,4,0,0,1-5.66-5.66L122.34,128,53.17,58.83a4,4,0,0,1,5.66-5.66L128,122.34l69.17-69.17a4,4,0,1,1,5.66,5.66L133.66,128Z`}))]]),z=L.forwardRef((e,t)=>L.createElement(A,{ref:t,...e,weights:R}));z.displayName=`XIcon`;var ie=`data-valid`,ae=`data-invalid`,B={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},V={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},H={valid(e){return e===null?null:e?{[ie]:``}:{[ae]:``}}},U={invalid:void 0,name:void 0,validityData:{state:B,errors:[],error:``,value:``,initialValue:null},setValidityData:D,disabled:void 0,setTouched:D,setDirty:D,setFilled:D,setFocused:D,focusOwnerRef:{current:void 0},validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:V,registerFieldControl:D,validation:{getValidationProps:(e,t=E)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:D,getInputControl:()=>null,commit:async()=>{},change:D}},W=L.createContext(U);function G(e=!0){let t=L.useContext(W);if(t.setValidityData===D&&!e)throw Error(T(28));return t}var K=L.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:D,validationMode:`onSubmit`,submitCountRef:{current:0}});function q(){return L.useContext(K)}var J=L.createContext({controlId:void 0,registerControlId:D,resetControlId:D,labelId:void 0,setLabelId:D,messageIds:[],setMessageIds:D,getDescriptionProps:e=>e});function Y(){return L.useContext(J)}function oe(e,t,n){let{setFocused:r,focusOwnerRef:i}=G(),a=S(t=>{(t?!e:i.current===a)&&(i.current=t&&a,n?.(t),r(t))});return C(()=>{let e=t.current;return e?.getRootNode()?.activeElement===e&&a(!0),()=>a(!1)},[e,t,a]),a}function se(e,t,n,r,i=!0,a){let{registerFieldControl:o}=G(),s=k(()=>Symbol());C(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),C(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}function ce(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=Y(),o=I(),s=k(()=>Symbol()),c=L.useRef(!1),l=L.useRef(!1),u=S(()=>{c.current&&i!==D&&(c.current=!1,i(s.current,void 0))});return C(()=>{if(!n||i===D){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),C(()=>u,[u]),(n?r:void 0)??t??o}var le=L.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:g,setDirty:_,validityData:v,setFilled:y,validationMode:b,validation:x}=G(),{clearErrors:T,elementRef:E,submitCountRef:D}=q(),O=h||s,k=m??a,A={...p,disabled:O},{labelId:j}=Y(),M=ce({id:i}),N=o!==void 0,P=o==null?void 0:String(o),F=S(()=>x.inputRef.current?.value);se(x.inputRef,M,P,F,!O,a),C(()=>{let e=P??x.inputRef.current?.value;e!==void 0&&y(e!==``)},[P,l,x.inputRef,y]),ee(P,()=>{P!==void 0&&(T(k),_(P!==(v.initialValue??``)),x.change(P))});let I=L.useRef(null),R=oe(O,I),z=ne();return w(`input`,e,{ref:[t,I],state:A,props:[{id:M,disabled:O,name:k,ref:x.inputRef,"aria-labelledby":j,autoFocus:u,...N?{value:o}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=re(te,e.nativeEvent);c?.(t,n),N||(_(t!==(v.initialValue??``)),y(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(T(k),x.change(t)))},onFocus(){R(!0)},onBlur(e){if(g(!0),R(!1),b===`onBlur`){let t=e.currentTarget.value;x.commit(t),N&&queueMicrotask(()=>{let e=x.inputRef.current?.value;e!==void 0&&e!==t&&e!==(v.initialValue??``)&&x.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){g(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===E.current&&!e.defaultPrevented){let t=e.currentTarget,n=D.current;z.start(0,()=>{D.current===n&&x.commit(t.value)})}else x.commit(t)}}},f,e=>x.getValidationProps(O,e)],stateAttributesMapping:H})}),X=t(),ue=L.forwardRef(function(e,t){return(0,X.jsx)(le,{ref:t,...e})}),Z=n();function de(e){let t=(0,Z.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,type:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===n?a=t[5]:(a=O(`h-8 w-full min-w-0 rounded-none border border-input bg-transparent px-2.5 py-1 text-xs outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 md:text-xs dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,n),t[4]=n,t[5]=a);let o;return t[6]!==r||t[7]!==a||t[8]!==i?(o=(0,X.jsx)(ue,{type:i,"data-slot":`input`,className:a,...r}),t[6]=r,t[7]=a,t[8]=i,t[9]=o):o=t[9],o}function fe(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=O(`group/input-group relative flex h-8 w-full min-w-0 items-center rounded-none border border-input outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-1 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-1 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(`div`,{"data-slot":`input-group`,role:`group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var pe=s(`flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-xs font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-none [&>svg:not([class*='size-'])]:size-4`,{variants:{align:{"inline-start":`order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]`,"inline-end":`order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]`,"block-start":`order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2`,"block-end":`order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2`}},defaultVariants:{align:`inline-start`}});function me(e){let t=(0,Z.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,align:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`inline-start`:i,o;t[4]!==a||t[5]!==n?(o=O(pe({align:a}),n),t[4]=a,t[5]=n,t[6]=o):o=t[6];let s;return t[7]!==a||t[8]!==r||t[9]!==o?(s=(0,X.jsx)(`div`,{role:`group`,"data-slot":`input-group-addon`,"data-align":a,className:o,onClick:he,...r}),t[7]=a,t[8]=r,t[9]=o,t[10]=s):s=t[10],s}function he(e){e.target.closest(`button`)||e.currentTarget.parentElement?.querySelector(`input`)?.focus()}s(`flex items-center gap-2 text-xs shadow-none`,{variants:{size:{xs:`h-6 gap-1 rounded-none px-1.5 [&>svg:not([class*='size-'])]:size-3.5`,sm:`gap-1`,"icon-xs":`size-6 rounded-none p-0 has-[>svg]:p-0`,"icon-sm":`size-7 p-0 has-[>svg]:p-0`}},defaultVariants:{size:`xs`}});function ge(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=O(`flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,X.jsx)(de,{"data-slot":`input-group-control`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var Q=j(`/(home)/`);function _e(e){function t(){e.blur()}function n(){document.visibilityState===`hidden`&&t()}return document.addEventListener(`visibilitychange`,n),addEventListener(`pagehide`,t),()=>{document.removeEventListener(`visibilitychange`,n),removeEventListener(`pagehide`,t)}}function ve(e){let t=(0,Z.c)(26),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={select:$},t[0]=n):n=t[0];let r=Q.useSearch(n),i;t[1]===e.state?i=t[2]:(i=e.state===`Missing`||_(e.state),t[1]=e.state,t[2]=i);let o=i,s;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(me,{children:(0,X.jsx)(x,{})}),t[3]=s):s=t[3];let c;t[4]===e?c=t[5]:(c=t=>e.onType(a(t.target.value)),t[4]=e,t[5]=c);let l=e.state===`Checking`,u;t[6]!==o||t[7]!==r||t[8]!==e.typed||t[9]!==c||t[10]!==l?(u=(0,X.jsxs)(fe,{className:`h-9 max-sm:h-11`,children:[s,(0,X.jsx)(ge,{id:`code`,ref:_e,className:`max-sm:h-11`,"aria-label":`Code of a sign-in to approve`,placeholder:`Code`,maxLength:8,value:e.typed,onChange:c,autoFocus:r,autoComplete:`off`,autoCapitalize:`characters`,spellCheck:!1,disabled:l,"aria-invalid":o,"aria-describedby":`code-error`})]}),t[6]=o,t[7]=r,t[8]=e.typed,t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]===e.state?d=t[13]:(d=e.state===`Missing`&&(0,X.jsx)(N,{id:`code-error`,children:`No waiting sign-in has this code.`}),t[12]=e.state,t[13]=d);let f;t[14]===e.state?f=t[15]:(f=_(e.state)&&(0,X.jsx)(N,{id:`code-error`,children:e.state.failed}),t[14]=e.state,t[15]=f);let p;t[16]!==o||t[17]!==u||t[18]!==d||t[19]!==f?(p=(0,X.jsxs)(M,{"data-invalid":o,children:[u,d,f]}),t[16]=o,t[17]=u,t[18]=d,t[19]=f,t[20]=p):p=t[20];let h;t[21]===e.answered?h=t[22]:(h=m(e.answered,{onNone:be,onSome:ye}),t[21]=e.answered,t[22]=h);let g;return t[23]!==p||t[24]!==h?(g=(0,X.jsxs)(`section`,{className:`flex w-full flex-col gap-2`,children:[p,h]}),t[23]=p,t[24]=h,t[25]=g):g=t[25],g}function ye(e){return(0,X.jsx)(`p`,{className:`text-muted-foreground flex items-center gap-1.5 text-xs`,role:`status`,children:v(e.accept,{onFalse:()=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{className:`size-3.5`}),p(e.request.clientName,e.request.device),` denied`]}),onTrue:()=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(b,{className:`size-3.5`}),p(e.request.clientName,e.request.device),` approved`]})})})}function be(){return null}function $(e){return h(e.code)}function xe(e){let t=(0,Z.c)(20),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsx)(`h1`,{className:`sr-only`,children:`Auth`}),t[0]=n):n=t[0];let r;t[1]!==e.answered||t[2]!==e.onType||t[3]!==e.state||t[4]!==e.typed?(r=(0,X.jsx)(ve,{answered:e.answered,onType:e.onType,state:e.state,typed:e.typed}),t[1]=e.answered,t[2]=e.onType,t[3]=e.state,t[4]=e.typed,t[5]=r):r=t[5];let i;t[6]!==e.pending||t[7]!==e.state?(i=e.state===`Checking`||h(e.pending),t[6]=e.pending,t[7]=e.state,t[8]=i):i=t[8];let a;t[9]===i?a=t[10]:(a=(0,X.jsx)(P,{pending:i}),t[9]=i,t[10]=a);let o=e.state===`Checking`,s;t[11]!==e.pending||t[12]!==o?(s=(0,X.jsx)(F,{checking:o,pending:e.pending}),t[11]=e.pending,t[12]=o,t[13]=s):s=t[13];let c;t[14]!==a||t[15]!==s?(c=(0,X.jsx)(L.Suspense,{fallback:a,children:s}),t[14]=a,t[15]=s,t[16]=c):c=t[16];let l;return t[17]!==r||t[18]!==c?(l=(0,X.jsxs)(X.Fragment,{children:[n,r,c]}),t[17]=r,t[18]=c,t[19]=l):l=t[19],l}function Se(){let e=(0,Z.c)(7),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={select:we},e[0]=t):t=e[0];let n=Q.useSearch(t),r;e[1]===n?r=e[2]:(r=d(n),e[1]=n,e[2]=r),o(r),o(u);let a=c(l.send),s;e[3]===a?s=e[4]:(s=function(e){a({_tag:`Typed`,typed:e})},e[3]=a,e[4]=s);let p=s,h;return e[5]===p?h=e[6]:(h=e=>(0,X.jsx)(xe,{...e,onType:p}),e[5]=p,e[6]=h),m(y(i(f)),{onNone:Ce,onSome:h})}function Ce(){return null}function we(e){return g(e.code,Te)}function Te(){return``}export{Se as component};
|