@deslop/auth 0.1.1260 → 0.1.1266
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)-DGIqrJyw.js → (home)-C6w15Knq.js} +1 -1
- package/dist/client/assets/{Check.es-AeXSmS94.js → Check.es-C9l513Ch.js} +1 -1
- package/dist/client/assets/{components-Ch6q3AXb.js → components-Dzgxr0NK.js} +1 -1
- package/dist/client/assets/{dialog-DhfNJiqT.js → dialog-hH_i4j1g.js} +1 -1
- package/dist/client/assets/{index-DhM_XKY3.js → index-CW-CqO1U.js} +2 -2
- package/dist/client/assets/{people-DlPxEkG3.js → people-Bk8xVEDM.js} +1 -1
- package/dist/client/assets/{route-Cv57jbpK.js → route-C2Xf2CnS.js} +1 -1
- package/dist/client/assets/utils-BepQ-yTS.js +2 -0
- package/dist/client/index.html +2 -2
- package/dist/server.js +211 -148
- package/package.json +2 -2
- package/dist/client/assets/utils-C0__Xx0_.js +0 -2
package/dist/server.js
CHANGED
|
@@ -3503,6 +3503,8 @@ SuccessImpl.prototype = SuccessProto;
|
|
|
3503
3503
|
const succeed$11 = (success) => new SuccessImpl(success);
|
|
3504
3504
|
/** @internal */
|
|
3505
3505
|
const getSuccess$1 = (self) => isFailure$2(self) ? none$1 : some$2(self.success);
|
|
3506
|
+
/** @internal */
|
|
3507
|
+
const fromOption$3 = /*#__PURE__*/ dual(2, (self, onNone) => isNone$1(self) ? fail$14(onNone()) : succeed$11(self.value));
|
|
3506
3508
|
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Order.js
|
|
3507
3509
|
/**
|
|
3508
3510
|
* Defines comparison functions for ordered values.
|
|
@@ -6133,6 +6135,39 @@ const succeed$10 = succeed$11;
|
|
|
6133
6135
|
* @since 4.0.0
|
|
6134
6136
|
*/
|
|
6135
6137
|
const fail$13 = fail$14;
|
|
6138
|
+
/**
|
|
6139
|
+
* Converts an `Option<A>` into a `Result<A, E>`.
|
|
6140
|
+
*
|
|
6141
|
+
* **When to use**
|
|
6142
|
+
*
|
|
6143
|
+
* Use when an existing `Option` should become a `Result`, preserving `Some` as
|
|
6144
|
+
* success and turning `None` into a caller-provided failure.
|
|
6145
|
+
*
|
|
6146
|
+
* **Details**
|
|
6147
|
+
*
|
|
6148
|
+
* - `Some<A>` becomes `Success<A>`
|
|
6149
|
+
* - `None` becomes `Failure<E>` using the provided function
|
|
6150
|
+
* - Supports both data-first and data-last (piped) usage
|
|
6151
|
+
*
|
|
6152
|
+
* **Example** (Converting an Option to a Result)
|
|
6153
|
+
*
|
|
6154
|
+
* ```ts import.meta.vitest
|
|
6155
|
+
* import { Option, Result } from "effect"
|
|
6156
|
+
*
|
|
6157
|
+
* Result.fromOption(Option.some(1), () => "missing") // => Result.succeed(1)
|
|
6158
|
+
*
|
|
6159
|
+
* Result.fromOption(Option.none(), () => "missing") // => Result.fail("missing")
|
|
6160
|
+
* ```
|
|
6161
|
+
*
|
|
6162
|
+
* @see {@link getSuccess} to extract the success value as an Option
|
|
6163
|
+
* @see {@link getFailure} to extract the failure value as an Option
|
|
6164
|
+
* @see {@link fromNullishOr} to build a Result from nullable values
|
|
6165
|
+
*
|
|
6166
|
+
* @stability stable
|
|
6167
|
+
* @category constructors
|
|
6168
|
+
* @since 2.0.0
|
|
6169
|
+
*/
|
|
6170
|
+
const fromOption$2 = fromOption$3;
|
|
6136
6171
|
const try_$2 = (evaluate) => {
|
|
6137
6172
|
if (isFunction(evaluate)) try {
|
|
6138
6173
|
return succeed$10(evaluate());
|
|
@@ -63073,7 +63108,7 @@ const fromDuplex = (open, options) => withFiber((fiber) => {
|
|
|
63073
63108
|
writer
|
|
63074
63109
|
}));
|
|
63075
63110
|
});
|
|
63076
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
63111
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js
|
|
63077
63112
|
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
63078
63113
|
const BINARY_TYPES = [
|
|
63079
63114
|
"nodebuffer",
|
|
@@ -63095,7 +63130,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63095
63130
|
NOOP: () => {}
|
|
63096
63131
|
};
|
|
63097
63132
|
}));
|
|
63098
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
63133
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/buffer-util.js
|
|
63099
63134
|
var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
63100
63135
|
const { websocketMask, websocketUnmask } = __require("http");
|
|
63101
63136
|
const { EMPTY_BUFFER } = require_constants();
|
|
@@ -63203,7 +63238,7 @@ var require_buffer_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63203
63238
|
};
|
|
63204
63239
|
} catch (e) {}
|
|
63205
63240
|
}));
|
|
63206
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
63241
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/limiter.js
|
|
63207
63242
|
var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
63208
63243
|
const kDone = Symbol("kDone");
|
|
63209
63244
|
const kRun = Symbol("kRun");
|
|
@@ -63253,7 +63288,7 @@ var require_limiter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63253
63288
|
};
|
|
63254
63289
|
module.exports = Limiter;
|
|
63255
63290
|
}));
|
|
63256
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
63291
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/permessage-deflate.js
|
|
63257
63292
|
var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
63258
63293
|
const zlib = __require("zlib");
|
|
63259
63294
|
const bufferUtil = require_buffer_util();
|
|
@@ -63588,7 +63623,7 @@ var require_permessage_deflate = /* @__PURE__ */ __commonJSMin(((exports, module
|
|
|
63588
63623
|
this[kCallback](err);
|
|
63589
63624
|
}
|
|
63590
63625
|
}));
|
|
63591
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
63626
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/validation.js
|
|
63592
63627
|
var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
63593
63628
|
const { isUtf8 } = __require("buffer");
|
|
63594
63629
|
const { hasBlob } = require_constants();
|
|
@@ -63783,7 +63818,7 @@ var require_validation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63783
63818
|
};
|
|
63784
63819
|
} catch (e) {}
|
|
63785
63820
|
}));
|
|
63786
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
63821
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/receiver.js
|
|
63787
63822
|
var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
63788
63823
|
const { Writable } = __require("stream");
|
|
63789
63824
|
const PerMessageDeflate = require_permessage_deflate();
|
|
@@ -64083,6 +64118,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
64083
64118
|
data = this.consume(this._payloadLength);
|
|
64084
64119
|
if (this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0) unmask(data, this._mask);
|
|
64085
64120
|
}
|
|
64121
|
+
this._mask = void 0;
|
|
64086
64122
|
if (this._opcode > 7) {
|
|
64087
64123
|
this.controlMessage(data, cb);
|
|
64088
64124
|
return;
|
|
@@ -64245,7 +64281,7 @@ var require_receiver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
64245
64281
|
};
|
|
64246
64282
|
module.exports = Receiver;
|
|
64247
64283
|
}));
|
|
64248
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
64284
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/sender.js
|
|
64249
64285
|
var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
64250
64286
|
const { Duplex } = __require("stream");
|
|
64251
64287
|
const { randomFillSync } = __require("crypto");
|
|
@@ -64743,7 +64779,7 @@ var require_sender = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
64743
64779
|
sender.onerror(err);
|
|
64744
64780
|
}
|
|
64745
64781
|
}));
|
|
64746
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
64782
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/event-target.js
|
|
64747
64783
|
var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
64748
64784
|
const { kForOnEventAttribute, kListener } = require_constants();
|
|
64749
64785
|
const kCode = Symbol("kCode");
|
|
@@ -64973,7 +65009,7 @@ var require_event_target = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
64973
65009
|
else listener.call(thisArg, event);
|
|
64974
65010
|
}
|
|
64975
65011
|
}));
|
|
64976
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
65012
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/extension.js
|
|
64977
65013
|
var require_extension$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
64978
65014
|
const { tokenChars } = require_validation();
|
|
64979
65015
|
/**
|
|
@@ -65118,12 +65154,13 @@ var require_extension$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
65118
65154
|
parse
|
|
65119
65155
|
};
|
|
65120
65156
|
}));
|
|
65121
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
65157
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket.js
|
|
65122
65158
|
var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
65123
65159
|
const EventEmitter = __require("events");
|
|
65124
65160
|
const https = __require("https");
|
|
65125
65161
|
const http = __require("http");
|
|
65126
65162
|
const net = __require("net");
|
|
65163
|
+
const querystring = __require("querystring");
|
|
65127
65164
|
const tls = __require("tls");
|
|
65128
65165
|
const { randomBytes, createHash } = __require("crypto");
|
|
65129
65166
|
const { Duplex, Readable } = __require("stream");
|
|
@@ -65682,8 +65719,10 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
65682
65719
|
} catch {
|
|
65683
65720
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
65684
65721
|
}
|
|
65685
|
-
if (parsedUrl.protocol === "http:"
|
|
65686
|
-
|
|
65722
|
+
if (parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:") {
|
|
65723
|
+
parsedUrl = new URL(parsedUrl);
|
|
65724
|
+
parsedUrl.protocol = parsedUrl.protocol === "http:" ? "ws:" : "wss:";
|
|
65725
|
+
}
|
|
65687
65726
|
websocket._url = parsedUrl.href;
|
|
65688
65727
|
const isSecure = parsedUrl.protocol === "wss:";
|
|
65689
65728
|
const isIpcUrl = parsedUrl.protocol === "ws+unix:";
|
|
@@ -65736,7 +65775,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
65736
65775
|
if (opts.protocolVersion < 13) opts.headers["Sec-WebSocket-Origin"] = opts.origin;
|
|
65737
65776
|
else opts.headers.Origin = opts.origin;
|
|
65738
65777
|
}
|
|
65739
|
-
if (parsedUrl.username || parsedUrl.password) opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
|
|
65778
|
+
if (parsedUrl.username || parsedUrl.password) opts.auth = `${querystring.unescape(parsedUrl.username)}:${querystring.unescape(parsedUrl.password)}`;
|
|
65740
65779
|
if (isIpcUrl) {
|
|
65741
65780
|
const i = opts.path.indexOf(":");
|
|
65742
65781
|
if (i === -1) {
|
|
@@ -65952,8 +65991,12 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
65952
65991
|
function receiverOnConclude(code, reason) {
|
|
65953
65992
|
const websocket = this[kWebSocket];
|
|
65954
65993
|
websocket._closeFrameReceived = true;
|
|
65955
|
-
websocket._closeMessage = reason;
|
|
65956
65994
|
websocket._closeCode = code;
|
|
65995
|
+
if (reason.length === 0) websocket._closeMessage = EMPTY_BUFFER;
|
|
65996
|
+
else {
|
|
65997
|
+
websocket._closeMessage = Buffer.allocUnsafeSlow(reason.length);
|
|
65998
|
+
websocket._closeMessage.set(reason);
|
|
65999
|
+
}
|
|
65957
66000
|
if (websocket._socket[kWebSocket] === void 0) return;
|
|
65958
66001
|
websocket._socket.removeListener("data", socketOnData);
|
|
65959
66002
|
process.nextTick(resume, websocket._socket);
|
|
@@ -66121,7 +66164,7 @@ var require_websocket = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66121
66164
|
}
|
|
66122
66165
|
}
|
|
66123
66166
|
}));
|
|
66124
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
66167
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/stream.js
|
|
66125
66168
|
var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
66126
66169
|
require_websocket();
|
|
66127
66170
|
const { Duplex } = __require("stream");
|
|
@@ -66236,7 +66279,7 @@ var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66236
66279
|
}
|
|
66237
66280
|
module.exports = createWebSocketStream;
|
|
66238
66281
|
}));
|
|
66239
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
66282
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/subprotocol.js
|
|
66240
66283
|
var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
66241
66284
|
const { tokenChars } = require_validation();
|
|
66242
66285
|
/**
|
|
@@ -66274,7 +66317,7 @@ var require_subprotocol = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
66274
66317
|
}
|
|
66275
66318
|
module.exports = { parse };
|
|
66276
66319
|
}));
|
|
66277
|
-
// ../../node_modules/.pnpm/ws@8.22.
|
|
66320
|
+
// ../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket-server.js
|
|
66278
66321
|
var require_websocket_server = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
66279
66322
|
const EventEmitter = __require("events");
|
|
66280
66323
|
const http = __require("http");
|
|
@@ -90278,6 +90321,9 @@ const AUTH_URL = "https://auth.mp281x.xyz";
|
|
|
90278
90321
|
const ISSUER_PATH = "/api/auth";
|
|
90279
90322
|
const APPS_PATH = "/api/apps";
|
|
90280
90323
|
const SESSION_COOKIE = "__Host-session";
|
|
90324
|
+
function matchingSessions(saved, userId) {
|
|
90325
|
+
return sort(filter$6(getSomes(saved), (session) => session.value.user.id === userId), mapInput(flip$1(Number$6), (session) => session.value.expiresAt));
|
|
90326
|
+
}
|
|
90281
90327
|
function bearerOf(headers) {
|
|
90282
90328
|
return flatMapNullishOr(match$3(/^bearer +(?<token>\S+) *$/iu)(headers["authorization"] ?? ""), (found) => found.groups?.["token"]);
|
|
90283
90329
|
}
|
|
@@ -91626,8 +91672,7 @@ var Sessions = class Sessions extends Service$1()("@deslop/runtime/auth/sessions
|
|
|
91626
91672
|
key,
|
|
91627
91673
|
value
|
|
91628
91674
|
}))), { concurrency: "unbounded" });
|
|
91629
|
-
const
|
|
91630
|
-
for (const session of candidates) {
|
|
91675
|
+
for (const session of matchingSessions(saved, userId)) {
|
|
91631
91676
|
if (yield* fresh(session.value)) return session.value.access;
|
|
91632
91677
|
const renewed = yield* result$1(pipe(refreshed(session.key), rejected("AI access is temporarily unavailable")));
|
|
91633
91678
|
if (renewed._tag === "Success") return renewed.success.access;
|
|
@@ -92404,6 +92449,10 @@ const App = Struct({
|
|
|
92404
92449
|
});
|
|
92405
92450
|
const Catalog = ArraySchema(App);
|
|
92406
92451
|
const AppParams = Struct({ origin: SecureOrigin });
|
|
92452
|
+
// src/services/apps/lib/utils.ts
|
|
92453
|
+
function registerApp(current, app) {
|
|
92454
|
+
return sort([...filter$6(current, (known) => known.origin !== app.origin), app], mapInput(Order$3, (known) => known.name));
|
|
92455
|
+
}
|
|
92407
92456
|
// src/services/apps/service.ts
|
|
92408
92457
|
var Apps = class Apps extends Service$1()("@deslop/auth/services/apps/service/Apps") {
|
|
92409
92458
|
static layer = effect(this, gen(function* () {
|
|
@@ -92437,7 +92486,7 @@ var Apps = class Apps extends Service$1()("@deslop/auth/services/apps/service/Ap
|
|
|
92437
92486
|
origin: new URL(origin).origin
|
|
92438
92487
|
});
|
|
92439
92488
|
yield* pipe(updateEffect(state, (current) => {
|
|
92440
|
-
const next =
|
|
92489
|
+
const next = registerApp(current, app);
|
|
92441
92490
|
return as(store.set("apps", next), next);
|
|
92442
92491
|
}), uninterruptible, rejected("The app list could not be saved"));
|
|
92443
92492
|
return app;
|
|
@@ -114315,6 +114364,26 @@ function browserToken(headers) {
|
|
|
114315
114364
|
function sameOwner(left, right) {
|
|
114316
114365
|
return left.user.id === right.user.id && left.incarnation === right.incarnation;
|
|
114317
114366
|
}
|
|
114367
|
+
function live$1(grants, now) {
|
|
114368
|
+
const current = filter$7(grants, (grant) => grant.credential.expiresAt > now);
|
|
114369
|
+
return filter$7(current, (grant) => grant.parent === void 0 || exists(get$13(current, grant.parent), (parent) => parent.credential._tag === "Browser"));
|
|
114370
|
+
}
|
|
114371
|
+
function signedInApps(grants, now, owner) {
|
|
114372
|
+
return pipe(toEntries(live$1(grants, now)), filter$6((entry) => sameOwner(entry[1], owner)), map$8((entry) => ({
|
|
114373
|
+
client: entry[1].client,
|
|
114374
|
+
createdAt: entry[1].createdAt,
|
|
114375
|
+
device: entry[1].device,
|
|
114376
|
+
expiresAt: entry[1].credential.expiresAt,
|
|
114377
|
+
family: entry[0],
|
|
114378
|
+
kind: entry[1].credential._tag,
|
|
114379
|
+
lastActive: entry[1].lastActive,
|
|
114380
|
+
...pick(entry[1], ["parent"]),
|
|
114381
|
+
...match$8(fromUndefinedOr(entry[1].origin.address), {
|
|
114382
|
+
onNone: () => ({}),
|
|
114383
|
+
onSome: (address) => ({ address })
|
|
114384
|
+
})
|
|
114385
|
+
})), sort(flip$1(mapInput(Number$6, (app) => app.lastActive))));
|
|
114386
|
+
}
|
|
114318
114387
|
function parsedAddress(address) {
|
|
114319
114388
|
return pipe(getSuccess(ipFromString(address)), map$11((ip) => {
|
|
114320
114389
|
if (isIpv6Address(ip)) return getOrElse(fromIpv4Mapped(ip), () => ip);
|
|
@@ -114471,7 +114540,7 @@ const owned = fnUntraced(function* (via) {
|
|
|
114471
114540
|
const challengeOf = fnUntraced(function* (clientDataJSON) {
|
|
114472
114541
|
return (yield* decodeEffect(fromJsonString(ClientData))(yield* fromResult(decodeString$2(clientDataJSON)))).challenge;
|
|
114473
114542
|
});
|
|
114474
|
-
function live
|
|
114543
|
+
function live(issued, now) {
|
|
114475
114544
|
return filter(issued, (entry) => entry.expiresAt > now);
|
|
114476
114545
|
}
|
|
114477
114546
|
function registrationKey(owner) {
|
|
@@ -114497,7 +114566,7 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
|
|
|
114497
114566
|
const key = registrationKey(session.owner);
|
|
114498
114567
|
const from = session.from;
|
|
114499
114568
|
const now = yield* currentTimeMillis;
|
|
114500
|
-
const challenge = yield* pipe(modify$5(registering, (issued) => [get$4(live
|
|
114569
|
+
const challenge = yield* pipe(modify$5(registering, (issued) => [get$4(live(issued, now), key), remove$1(live(issued, now), key)]), flatMap$2(fromOption), mapError$2(() => AuthError.make({ message: "Adding the passkey took too long; start again" })));
|
|
114501
114570
|
const transports = filter$6(response.response.transports ?? [], is$2(Transport));
|
|
114502
114571
|
const verified = yield* tryPromise({
|
|
114503
114572
|
catch: invalid,
|
|
@@ -114567,7 +114636,7 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
|
|
|
114567
114636
|
})
|
|
114568
114637
|
});
|
|
114569
114638
|
const now = yield* currentTimeMillis;
|
|
114570
|
-
yield* update$3(registering, (issued) => set$1(live
|
|
114639
|
+
yield* update$3(registering, (issued) => set$1(live(issued, now), registrationKey(owner), {
|
|
114571
114640
|
challenge: options.challenge,
|
|
114572
114641
|
expiresAt: now + LIFETIME
|
|
114573
114642
|
}));
|
|
@@ -114582,11 +114651,11 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
|
|
|
114582
114651
|
rpID,
|
|
114583
114652
|
userVerification: "required"
|
|
114584
114653
|
})
|
|
114585
|
-
}), tap$1((options) => flatMap$2(currentTimeMillis, (now) => update$3(signingIn, (issued) => set$1(live
|
|
114654
|
+
}), tap$1((options) => flatMap$2(currentTimeMillis, (now) => update$3(signingIn, (issued) => set$1(live(issued, now), options.challenge, { expiresAt: now + LIFETIME })))), flatMap$2(encodeUnknownEffect(fromJsonString(Unknown))), flatMap$2(decodeEffect(fromJsonString(RequestOptions))), rejected("Cannot start a passkey sign-in"), withSpan("Passkeys.request")),
|
|
114586
114655
|
signIn: fn("Passkeys.signIn")(function* (response) {
|
|
114587
114656
|
const challenge = yield* challengeOf(response.response.clientDataJSON);
|
|
114588
114657
|
const now = yield* currentTimeMillis;
|
|
114589
|
-
if (!(yield* modify$5(signingIn, (issued) => [has$2(live
|
|
114658
|
+
if (!(yield* modify$5(signingIn, (issued) => [has$2(live(issued, now), challenge), remove$1(live(issued, now), challenge)]))) return yield* AuthError.make({ message: "The sign-in took too long; start again" });
|
|
114590
114659
|
const found = yield* mapError$2(fromOption(findFirst(yield* get(state), (stored) => stored.id === response.id)), () => unknown);
|
|
114591
114660
|
const publicKey = new Uint8Array(yield* fromResult(decode$1(found.publicKey)));
|
|
114592
114661
|
const verified = yield* tryPromise({
|
|
@@ -114720,6 +114789,99 @@ var RpcContracts = class extends make$31(make$35("auth.lookup", {
|
|
|
114720
114789
|
stream: true,
|
|
114721
114790
|
success: AuthorizationStatus
|
|
114722
114791
|
}))) {};
|
|
114792
|
+
// src/services/people/lib/utils.ts
|
|
114793
|
+
const ROLE_ORDER = {
|
|
114794
|
+
Admin: 0,
|
|
114795
|
+
Member: 2,
|
|
114796
|
+
Waiting: 1
|
|
114797
|
+
};
|
|
114798
|
+
function ownerOf(row) {
|
|
114799
|
+
return {
|
|
114800
|
+
incarnation: row.incarnation,
|
|
114801
|
+
user: {
|
|
114802
|
+
id: row.id,
|
|
114803
|
+
name: row.name
|
|
114804
|
+
}
|
|
114805
|
+
};
|
|
114806
|
+
}
|
|
114807
|
+
function roleOf(admins, id, row) {
|
|
114808
|
+
if (isAdmin(admins, id)) return "Admin";
|
|
114809
|
+
if (exists(row, (found) => found.status === "Allowed")) return "Member";
|
|
114810
|
+
return "Waiting";
|
|
114811
|
+
}
|
|
114812
|
+
function personOf(admins, row) {
|
|
114813
|
+
return Person.make({
|
|
114814
|
+
...pick(row, [
|
|
114815
|
+
"id",
|
|
114816
|
+
"name",
|
|
114817
|
+
"since"
|
|
114818
|
+
]),
|
|
114819
|
+
...match$8(liftPredicate(row.fullName, isNonEmpty$1), {
|
|
114820
|
+
onNone: () => ({}),
|
|
114821
|
+
onSome: (fullName) => ({ fullName })
|
|
114822
|
+
}),
|
|
114823
|
+
role: roleOf(admins, row.id, some$1(row))
|
|
114824
|
+
});
|
|
114825
|
+
}
|
|
114826
|
+
function admission(current, admins, params, now) {
|
|
114827
|
+
return pipe(fromOption$2(findFirst(current, (row) => row.id === params.id), () => new NoSuchElementError()), flatMap$6((row) => {
|
|
114828
|
+
const found = personOf(admins, row);
|
|
114829
|
+
if (found.role !== "Waiting") return fail$13(AuthError.make({ message: "This account is not asking for access" }));
|
|
114830
|
+
if (!params.allow) return succeed$10([{
|
|
114831
|
+
owner: ownerOf(row),
|
|
114832
|
+
person: found
|
|
114833
|
+
}, filter$6(current, (stored) => stored.id !== params.id)]);
|
|
114834
|
+
return succeed$10([{
|
|
114835
|
+
owner: ownerOf(row),
|
|
114836
|
+
person: Person.make({
|
|
114837
|
+
...found,
|
|
114838
|
+
role: "Member",
|
|
114839
|
+
since: now
|
|
114840
|
+
})
|
|
114841
|
+
}, map$8(current, (stored) => {
|
|
114842
|
+
if (stored.id !== params.id) return stored;
|
|
114843
|
+
return {
|
|
114844
|
+
...stored,
|
|
114845
|
+
since: now,
|
|
114846
|
+
status: "Allowed"
|
|
114847
|
+
};
|
|
114848
|
+
})]);
|
|
114849
|
+
}));
|
|
114850
|
+
}
|
|
114851
|
+
function registerMember(current, admins, profile, since, incarnation) {
|
|
114852
|
+
const row = {
|
|
114853
|
+
fullName: profile.name ?? "",
|
|
114854
|
+
id: `github:${profile.id}`,
|
|
114855
|
+
incarnation,
|
|
114856
|
+
name: profile.login,
|
|
114857
|
+
since,
|
|
114858
|
+
status: match$1(isAdmin(admins, `github:${profile.id}`), {
|
|
114859
|
+
onFalse: () => "Waiting",
|
|
114860
|
+
onTrue: () => "Allowed"
|
|
114861
|
+
})
|
|
114862
|
+
};
|
|
114863
|
+
return [ownerOf(row), match$8(findFirst(current, (stored) => stored.id === row.id), {
|
|
114864
|
+
onNone: () => [...current, row],
|
|
114865
|
+
onSome: () => map$8(current, (stored) => {
|
|
114866
|
+
if (stored.id !== row.id) return stored;
|
|
114867
|
+
return {
|
|
114868
|
+
...stored,
|
|
114869
|
+
fullName: row.fullName,
|
|
114870
|
+
name: row.name
|
|
114871
|
+
};
|
|
114872
|
+
})
|
|
114873
|
+
})];
|
|
114874
|
+
}
|
|
114875
|
+
function listPeople(current, admins) {
|
|
114876
|
+
const known = pipe(current, reverse, sort(flip$1(mapInput(Number$6, (row) => row.since))), map$8((row) => personOf(admins, row)));
|
|
114877
|
+
const knownIds = fromIterable(map$8(known, (person) => person.id));
|
|
114878
|
+
return sort([...map$8(filter$6(admins, (id) => !has(knownIds, `github:${id}`)), (id) => Person.make({
|
|
114879
|
+
id: `github:${id}`,
|
|
114880
|
+
name: `GitHub ${id}`,
|
|
114881
|
+
role: "Admin",
|
|
114882
|
+
since: 0
|
|
114883
|
+
})), ...known], mapInput(Order$4, (person) => ROLE_ORDER[person.role]));
|
|
114884
|
+
}
|
|
114723
114885
|
// src/services/tokens/service.ts
|
|
114724
114886
|
const expired$1 = AuthError.make({
|
|
114725
114887
|
error: "invalid_grant",
|
|
@@ -114732,10 +114894,6 @@ function parts(token) {
|
|
|
114732
114894
|
secret: found.groups?.["secret"] ?? ""
|
|
114733
114895
|
}));
|
|
114734
114896
|
}
|
|
114735
|
-
function live(grants, now) {
|
|
114736
|
-
const current = filter$7(grants, (grant) => grant.credential.expiresAt > now);
|
|
114737
|
-
return filter$7(current, (grant) => grant.parent === void 0 || exists(get$13(current, grant.parent), (parent) => parent.credential._tag === "Browser"));
|
|
114738
|
-
}
|
|
114739
114897
|
function end(grants, family) {
|
|
114740
114898
|
return filter$7(grants, (grant, key) => key !== family && grant.parent !== family);
|
|
114741
114899
|
}
|
|
@@ -114773,7 +114931,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
114773
114931
|
const change = fnUntraced(function* (update) {
|
|
114774
114932
|
return yield* modifyEffect(grants, (current) => gen(function* () {
|
|
114775
114933
|
const now = yield* currentTimeMillis;
|
|
114776
|
-
const [result, next] = yield* update(live(current, now), now);
|
|
114934
|
+
const [result, next] = yield* update(live$1(current, now), now);
|
|
114777
114935
|
yield* store.set("sign-ins", next);
|
|
114778
114936
|
return [result, next];
|
|
114779
114937
|
}));
|
|
@@ -114783,7 +114941,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
114783
114941
|
const now = yield* currentTimeMillis;
|
|
114784
114942
|
return {
|
|
114785
114943
|
...found,
|
|
114786
|
-
grant: yield* fromOption(get$13(live(yield* get(grants), now), found.family)),
|
|
114944
|
+
grant: yield* fromOption(get$13(live$1(yield* get(grants), now), found.family)),
|
|
114787
114945
|
hash: yield* hash(found.secret),
|
|
114788
114946
|
now
|
|
114789
114947
|
};
|
|
@@ -114813,7 +114971,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
114813
114971
|
typ: "at+jwt"
|
|
114814
114972
|
}), Signature, signature);
|
|
114815
114973
|
const now = yield* currentTimeMillis;
|
|
114816
|
-
const signedIn = yield* fromOption(get$13(live(yield* get(grants), now), verified.claims.sid));
|
|
114974
|
+
const signedIn = yield* fromOption(get$13(live$1(yield* get(grants), now), verified.claims.sid));
|
|
114817
114975
|
if (signedIn.credential._tag !== "App" || signedIn.user.id !== verified.claims.sub) return yield* AuthError.make({ message: "Sign in first" });
|
|
114818
114976
|
const found = {
|
|
114819
114977
|
family: verified.claims.sid,
|
|
@@ -114954,20 +115112,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
114954
115112
|
});
|
|
114955
115113
|
const listApps = fnUntraced(function* (owner) {
|
|
114956
115114
|
const now = yield* currentTimeMillis;
|
|
114957
|
-
return
|
|
114958
|
-
client: entry[1].client,
|
|
114959
|
-
createdAt: entry[1].createdAt,
|
|
114960
|
-
device: entry[1].device,
|
|
114961
|
-
expiresAt: entry[1].credential.expiresAt,
|
|
114962
|
-
family: entry[0],
|
|
114963
|
-
kind: entry[1].credential._tag,
|
|
114964
|
-
lastActive: entry[1].lastActive,
|
|
114965
|
-
...pick(entry[1], ["parent"]),
|
|
114966
|
-
...match$8(fromUndefinedOr(entry[1].origin.address), {
|
|
114967
|
-
onNone: () => ({}),
|
|
114968
|
-
onSome: (address) => ({ address })
|
|
114969
|
-
})
|
|
114970
|
-
})), sort(flip$1(mapInput(Number$6, (app) => app.lastActive))));
|
|
115115
|
+
return signedInApps(yield* get(grants), now, owner);
|
|
114971
115116
|
});
|
|
114972
115117
|
return Tokens.of({
|
|
114973
115118
|
apps: (user) => pipe(merge$1(changes(grants), drop(tick("1 minute"), 1)), mapEffect$1(() => listApps(user))),
|
|
@@ -115086,30 +115231,6 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
|
|
|
115086
115231
|
}));
|
|
115087
115232
|
};
|
|
115088
115233
|
// src/services/people/service.ts
|
|
115089
|
-
const ROLE_ORDER = {
|
|
115090
|
-
Admin: 0,
|
|
115091
|
-
Member: 2,
|
|
115092
|
-
Waiting: 1
|
|
115093
|
-
};
|
|
115094
|
-
function memberOf(github, since, status, incarnation) {
|
|
115095
|
-
return {
|
|
115096
|
-
fullName: github.name ?? "",
|
|
115097
|
-
id: `github:${github.id}`,
|
|
115098
|
-
incarnation,
|
|
115099
|
-
name: github.login,
|
|
115100
|
-
since,
|
|
115101
|
-
status
|
|
115102
|
-
};
|
|
115103
|
-
}
|
|
115104
|
-
function ownerOf(row) {
|
|
115105
|
-
return {
|
|
115106
|
-
incarnation: row.incarnation,
|
|
115107
|
-
user: {
|
|
115108
|
-
id: row.id,
|
|
115109
|
-
name: row.name
|
|
115110
|
-
}
|
|
115111
|
-
};
|
|
115112
|
-
}
|
|
115113
115234
|
function member(id, current) {
|
|
115114
115235
|
return findFirst(current, (row) => row.id === id);
|
|
115115
115236
|
}
|
|
@@ -115130,25 +115251,6 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
115130
115251
|
const transact = fnUntraced(function* (change) {
|
|
115131
115252
|
return yield* modifyEffect(state, (current) => tap$1(change(current), (result) => store.set("members", result[1])));
|
|
115132
115253
|
}, uninterruptible);
|
|
115133
|
-
function roleOf(id, row) {
|
|
115134
|
-
if (isAdmin(admins, id)) return "Admin";
|
|
115135
|
-
if (exists(row, (found) => found.status === "Allowed")) return "Member";
|
|
115136
|
-
return "Waiting";
|
|
115137
|
-
}
|
|
115138
|
-
function personOf(row) {
|
|
115139
|
-
return Person.make({
|
|
115140
|
-
...pick(row, [
|
|
115141
|
-
"id",
|
|
115142
|
-
"name",
|
|
115143
|
-
"since"
|
|
115144
|
-
]),
|
|
115145
|
-
...match$8(liftPredicate(row.fullName, isNonEmpty$1), {
|
|
115146
|
-
onNone: () => ({}),
|
|
115147
|
-
onSome: (fullName) => ({ fullName })
|
|
115148
|
-
}),
|
|
115149
|
-
role: roleOf(row.id, some$1(row))
|
|
115150
|
-
});
|
|
115151
|
-
}
|
|
115152
115254
|
const currentOwner = fnUntraced(function* (owner) {
|
|
115153
115255
|
const row = member(owner.user.id, yield* get(state));
|
|
115154
115256
|
if (local && owner.user.id === DEVELOPER.id && owner.incarnation === developer.incarnation) return row;
|
|
@@ -115162,7 +115264,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
115162
115264
|
return row;
|
|
115163
115265
|
});
|
|
115164
115266
|
const allowed = fnUntraced(function* (owner) {
|
|
115165
|
-
if (roleOf(owner.user.id, yield* currentOwner(owner)) === "Waiting") return yield* AuthError.make({
|
|
115267
|
+
if (roleOf(admins, owner.user.id, yield* currentOwner(owner)) === "Waiting") return yield* AuthError.make({
|
|
115166
115268
|
error: "access_denied",
|
|
115167
115269
|
message: "An admin has not allowed this GitHub account yet"
|
|
115168
115270
|
});
|
|
@@ -115180,14 +115282,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
115180
115282
|
});
|
|
115181
115283
|
const list = fn("People.list")(function* (user) {
|
|
115182
115284
|
yield* admin(user);
|
|
115183
|
-
|
|
115184
|
-
const knownIds = fromIterable(map$8(known, (person) => person.id));
|
|
115185
|
-
return sort([...map$8(filter$6(admins, (id) => !has(knownIds, `github:${id}`)), (id) => Person.make({
|
|
115186
|
-
id: `github:${id}`,
|
|
115187
|
-
name: `GitHub ${id}`,
|
|
115188
|
-
role: "Admin",
|
|
115189
|
-
since: 0
|
|
115190
|
-
})), ...known], mapInput(Order$4, (person) => ROLE_ORDER[person.role]));
|
|
115285
|
+
return listPeople(yield* get(state), admins);
|
|
115191
115286
|
}, rejected("Cannot read people"));
|
|
115192
115287
|
yield* pipe(forEach$1(admins, fnUntraced(function* (id) {
|
|
115193
115288
|
if (isSome(member(`github:${id}`, yield* get(state)))) return;
|
|
@@ -115195,10 +115290,17 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
115195
115290
|
const since = yield* currentTimeMillis;
|
|
115196
115291
|
yield* transact((current) => {
|
|
115197
115292
|
if (isSome(member(`github:${profile.id}`, current))) return succeed$5([void 0, current]);
|
|
115198
|
-
return succeed$5([void 0, [...current,
|
|
115199
|
-
|
|
115200
|
-
|
|
115201
|
-
|
|
115293
|
+
return succeed$5([void 0, [...current, {
|
|
115294
|
+
fullName: profile.name ?? "",
|
|
115295
|
+
id: `github:${profile.id}`,
|
|
115296
|
+
incarnation: match$1(local, {
|
|
115297
|
+
onFalse: () => "legacy",
|
|
115298
|
+
onTrue: () => "local"
|
|
115299
|
+
}),
|
|
115300
|
+
name: profile.login,
|
|
115301
|
+
since,
|
|
115302
|
+
status: "Allowed"
|
|
115303
|
+
}]]);
|
|
115202
115304
|
});
|
|
115203
115305
|
}), {
|
|
115204
115306
|
concurrency: 1,
|
|
@@ -115213,11 +115315,11 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
115213
115315
|
return match$8(yield* currentOwner(session.owner), {
|
|
115214
115316
|
onNone: () => SignedAccount.make({
|
|
115215
115317
|
...session.owner.user,
|
|
115216
|
-
role: roleOf(session.owner.user.id, none()),
|
|
115318
|
+
role: roleOf(admins, session.owner.user.id, none()),
|
|
115217
115319
|
via: session.via
|
|
115218
115320
|
}),
|
|
115219
115321
|
onSome: (row) => SignedAccount.make({
|
|
115220
|
-
...omit(personOf(row), ["since"]),
|
|
115322
|
+
...omit(personOf(admins, row), ["since"]),
|
|
115221
115323
|
via: session.via
|
|
115222
115324
|
})
|
|
115223
115325
|
});
|
|
@@ -115226,30 +115328,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
115226
115328
|
admit: fn("People.admit")(function* (params, user) {
|
|
115227
115329
|
yield* admin(user);
|
|
115228
115330
|
const now = yield* currentTimeMillis;
|
|
115229
|
-
const result = yield* transact((current) =>
|
|
115230
|
-
const row = yield* fromOption(member(params.id, current));
|
|
115231
|
-
const found = personOf(row);
|
|
115232
|
-
if (found.role !== "Waiting") return yield* AuthError.make({ message: "This account is not asking for access" });
|
|
115233
|
-
if (!params.allow) return [{
|
|
115234
|
-
owner: ownerOf(row),
|
|
115235
|
-
person: found
|
|
115236
|
-
}, filter$6(current, (stored) => stored.id !== params.id)];
|
|
115237
|
-
return [{
|
|
115238
|
-
owner: ownerOf(row),
|
|
115239
|
-
person: Person.make({
|
|
115240
|
-
...found,
|
|
115241
|
-
role: "Member",
|
|
115242
|
-
since: now
|
|
115243
|
-
})
|
|
115244
|
-
}, map$8(current, (stored) => {
|
|
115245
|
-
if (stored.id !== params.id) return stored;
|
|
115246
|
-
return {
|
|
115247
|
-
...stored,
|
|
115248
|
-
since: now,
|
|
115249
|
-
status: "Allowed"
|
|
115250
|
-
};
|
|
115251
|
-
})];
|
|
115252
|
-
}));
|
|
115331
|
+
const result = yield* transact((current) => fromResult(admission(current, admins, params, now)));
|
|
115253
115332
|
if (!params.allow) {
|
|
115254
115333
|
yield* tokens.forget(result.owner);
|
|
115255
115334
|
yield* passkeys.forget(result.owner);
|
|
@@ -115262,40 +115341,24 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
|
|
|
115262
115341
|
register: fn("People.register")(function* (profile) {
|
|
115263
115342
|
const since = yield* currentTimeMillis;
|
|
115264
115343
|
return yield* transact((current) => gen(function* () {
|
|
115265
|
-
|
|
115266
|
-
const incarnation = match$8(existing, {
|
|
115344
|
+
return registerMember(current, admins, profile, since, yield* match$8(member(`github:${profile.id}`, current), {
|
|
115267
115345
|
onNone: () => {
|
|
115268
115346
|
if (local && profile.id === 0) return succeed$5("local");
|
|
115269
115347
|
return map$5(random.randomBytes(32), encode$3);
|
|
115270
115348
|
},
|
|
115271
115349
|
onSome: (row) => succeed$5(row.incarnation)
|
|
115272
|
-
});
|
|
115273
|
-
const row = memberOf(profile, since, match$1(roleOf(`github:${profile.id}`, none()) === "Admin", {
|
|
115274
|
-
onFalse: () => "Waiting",
|
|
115275
|
-
onTrue: () => "Allowed"
|
|
115276
|
-
}), yield* incarnation);
|
|
115277
|
-
return [ownerOf(row), match$8(existing, {
|
|
115278
|
-
onNone: () => [...current, row],
|
|
115279
|
-
onSome: () => map$8(current, (stored) => {
|
|
115280
|
-
if (stored.id !== row.id) return stored;
|
|
115281
|
-
return {
|
|
115282
|
-
...stored,
|
|
115283
|
-
fullName: row.fullName,
|
|
115284
|
-
name: row.name
|
|
115285
|
-
};
|
|
115286
|
-
})
|
|
115287
|
-
})];
|
|
115350
|
+
}));
|
|
115288
115351
|
}));
|
|
115289
115352
|
}, rejected("Cannot record the GitHub account")),
|
|
115290
115353
|
remove: fn("People.remove")(function* (id, user) {
|
|
115291
115354
|
yield* admin(user);
|
|
115292
|
-
if (roleOf(id, none()) === "Admin") return yield* AuthError.make({ message: "Admins come from GITHUB_ADMINS, so they cannot be removed here" });
|
|
115355
|
+
if (roleOf(admins, id, none()) === "Admin") return yield* AuthError.make({ message: "Admins come from GITHUB_ADMINS, so they cannot be removed here" });
|
|
115293
115356
|
const removed = yield* transact((current) => gen(function* () {
|
|
115294
115357
|
return [yield* fromOption(member(id, current)), filter$6(current, (row) => row.id !== id)];
|
|
115295
115358
|
}));
|
|
115296
115359
|
yield* tokens.forget(ownerOf(removed));
|
|
115297
115360
|
yield* passkeys.forget(ownerOf(removed));
|
|
115298
|
-
return personOf(removed);
|
|
115361
|
+
return personOf(admins, removed);
|
|
115299
115362
|
}, rejected("Cannot remove this account"))
|
|
115300
115363
|
});
|
|
115301
115364
|
return pipe(make$85(People, people), add$1(RpcOwner, RpcOwner.of((effect, request) => flatMap$2(sessionOwner(request.headers), (owner) => provideService(effect, CurrentOwner, owner)))));
|