@deslop/auth 0.1.1260 → 0.1.1261

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.
@@ -15,11 +15,11 @@
15
15
  <link rel="manifest" href="/manifest.webmanifest" />
16
16
 
17
17
  <title>Auth</title>
18
- <script type="module" crossorigin src="/assets/index-DhM_XKY3.js"></script>
18
+ <script type="module" crossorigin src="/assets/index-CW-CqO1U.js"></script>
19
19
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-WkwZ5CU-.js">
20
20
  <link rel="modulepreload" crossorigin href="/assets/effect-CarHrcH-.js">
21
21
  <link rel="modulepreload" crossorigin href="/assets/react-COyt-gOi.js">
22
- <link rel="modulepreload" crossorigin href="/assets/utils-C0__Xx0_.js">
22
+ <link rel="modulepreload" crossorigin href="/assets/utils-BepQ-yTS.js">
23
23
  <link rel="stylesheet" crossorigin href="/assets/index-SYuv6Jic.css">
24
24
  </head>
25
25
  <body>
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());
@@ -90278,6 +90313,9 @@ const AUTH_URL = "https://auth.mp281x.xyz";
90278
90313
  const ISSUER_PATH = "/api/auth";
90279
90314
  const APPS_PATH = "/api/apps";
90280
90315
  const SESSION_COOKIE = "__Host-session";
90316
+ function matchingSessions(saved, userId) {
90317
+ return sort(filter$6(getSomes(saved), (session) => session.value.user.id === userId), mapInput(flip$1(Number$6), (session) => session.value.expiresAt));
90318
+ }
90281
90319
  function bearerOf(headers) {
90282
90320
  return flatMapNullishOr(match$3(/^bearer +(?<token>\S+) *$/iu)(headers["authorization"] ?? ""), (found) => found.groups?.["token"]);
90283
90321
  }
@@ -91626,8 +91664,7 @@ var Sessions = class Sessions extends Service$1()("@deslop/runtime/auth/sessions
91626
91664
  key,
91627
91665
  value
91628
91666
  }))), { concurrency: "unbounded" });
91629
- const candidates = sort(filter$6(getSomes(saved), (session) => session.value.user.id === userId), mapInput(flip$1(Number$6), (session) => session.value.expiresAt));
91630
- for (const session of candidates) {
91667
+ for (const session of matchingSessions(saved, userId)) {
91631
91668
  if (yield* fresh(session.value)) return session.value.access;
91632
91669
  const renewed = yield* result$1(pipe(refreshed(session.key), rejected("AI access is temporarily unavailable")));
91633
91670
  if (renewed._tag === "Success") return renewed.success.access;
@@ -92404,6 +92441,10 @@ const App = Struct({
92404
92441
  });
92405
92442
  const Catalog = ArraySchema(App);
92406
92443
  const AppParams = Struct({ origin: SecureOrigin });
92444
+ // src/services/apps/lib/utils.ts
92445
+ function registerApp(current, app) {
92446
+ return sort([...filter$6(current, (known) => known.origin !== app.origin), app], mapInput(Order$3, (known) => known.name));
92447
+ }
92407
92448
  // src/services/apps/service.ts
92408
92449
  var Apps = class Apps extends Service$1()("@deslop/auth/services/apps/service/Apps") {
92409
92450
  static layer = effect(this, gen(function* () {
@@ -92437,7 +92478,7 @@ var Apps = class Apps extends Service$1()("@deslop/auth/services/apps/service/Ap
92437
92478
  origin: new URL(origin).origin
92438
92479
  });
92439
92480
  yield* pipe(updateEffect(state, (current) => {
92440
- const next = sort([...filter$6(current, (known) => known.origin !== app.origin), app], mapInput(Order$3, (known) => known.name));
92481
+ const next = registerApp(current, app);
92441
92482
  return as(store.set("apps", next), next);
92442
92483
  }), uninterruptible, rejected("The app list could not be saved"));
92443
92484
  return app;
@@ -114315,6 +114356,26 @@ function browserToken(headers) {
114315
114356
  function sameOwner(left, right) {
114316
114357
  return left.user.id === right.user.id && left.incarnation === right.incarnation;
114317
114358
  }
114359
+ function live$1(grants, now) {
114360
+ const current = filter$7(grants, (grant) => grant.credential.expiresAt > now);
114361
+ return filter$7(current, (grant) => grant.parent === void 0 || exists(get$13(current, grant.parent), (parent) => parent.credential._tag === "Browser"));
114362
+ }
114363
+ function signedInApps(grants, now, owner) {
114364
+ return pipe(toEntries(live$1(grants, now)), filter$6((entry) => sameOwner(entry[1], owner)), map$8((entry) => ({
114365
+ client: entry[1].client,
114366
+ createdAt: entry[1].createdAt,
114367
+ device: entry[1].device,
114368
+ expiresAt: entry[1].credential.expiresAt,
114369
+ family: entry[0],
114370
+ kind: entry[1].credential._tag,
114371
+ lastActive: entry[1].lastActive,
114372
+ ...pick(entry[1], ["parent"]),
114373
+ ...match$8(fromUndefinedOr(entry[1].origin.address), {
114374
+ onNone: () => ({}),
114375
+ onSome: (address) => ({ address })
114376
+ })
114377
+ })), sort(flip$1(mapInput(Number$6, (app) => app.lastActive))));
114378
+ }
114318
114379
  function parsedAddress(address) {
114319
114380
  return pipe(getSuccess(ipFromString(address)), map$11((ip) => {
114320
114381
  if (isIpv6Address(ip)) return getOrElse(fromIpv4Mapped(ip), () => ip);
@@ -114471,7 +114532,7 @@ const owned = fnUntraced(function* (via) {
114471
114532
  const challengeOf = fnUntraced(function* (clientDataJSON) {
114472
114533
  return (yield* decodeEffect(fromJsonString(ClientData))(yield* fromResult(decodeString$2(clientDataJSON)))).challenge;
114473
114534
  });
114474
- function live$1(issued, now) {
114535
+ function live(issued, now) {
114475
114536
  return filter(issued, (entry) => entry.expiresAt > now);
114476
114537
  }
114477
114538
  function registrationKey(owner) {
@@ -114497,7 +114558,7 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
114497
114558
  const key = registrationKey(session.owner);
114498
114559
  const from = session.from;
114499
114560
  const now = yield* currentTimeMillis;
114500
- const challenge = yield* pipe(modify$5(registering, (issued) => [get$4(live$1(issued, now), key), remove$1(live$1(issued, now), key)]), flatMap$2(fromOption), mapError$2(() => AuthError.make({ message: "Adding the passkey took too long; start again" })));
114561
+ 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
114562
  const transports = filter$6(response.response.transports ?? [], is$2(Transport));
114502
114563
  const verified = yield* tryPromise({
114503
114564
  catch: invalid,
@@ -114567,7 +114628,7 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
114567
114628
  })
114568
114629
  });
114569
114630
  const now = yield* currentTimeMillis;
114570
- yield* update$3(registering, (issued) => set$1(live$1(issued, now), registrationKey(owner), {
114631
+ yield* update$3(registering, (issued) => set$1(live(issued, now), registrationKey(owner), {
114571
114632
  challenge: options.challenge,
114572
114633
  expiresAt: now + LIFETIME
114573
114634
  }));
@@ -114582,11 +114643,11 @@ var Passkeys = class Passkeys extends Service$1()("@deslop/auth/services/passkey
114582
114643
  rpID,
114583
114644
  userVerification: "required"
114584
114645
  })
114585
- }), 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("Cannot start a passkey sign-in"), withSpan("Passkeys.request")),
114646
+ }), 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
114647
  signIn: fn("Passkeys.signIn")(function* (response) {
114587
114648
  const challenge = yield* challengeOf(response.response.clientDataJSON);
114588
114649
  const now = yield* currentTimeMillis;
114589
- if (!(yield* modify$5(signingIn, (issued) => [has$2(live$1(issued, now), challenge), remove$1(live$1(issued, now), challenge)]))) return yield* AuthError.make({ message: "The sign-in took too long; start again" });
114650
+ 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
114651
  const found = yield* mapError$2(fromOption(findFirst(yield* get(state), (stored) => stored.id === response.id)), () => unknown);
114591
114652
  const publicKey = new Uint8Array(yield* fromResult(decode$1(found.publicKey)));
114592
114653
  const verified = yield* tryPromise({
@@ -114720,6 +114781,99 @@ var RpcContracts = class extends make$31(make$35("auth.lookup", {
114720
114781
  stream: true,
114721
114782
  success: AuthorizationStatus
114722
114783
  }))) {};
114784
+ // src/services/people/lib/utils.ts
114785
+ const ROLE_ORDER = {
114786
+ Admin: 0,
114787
+ Member: 2,
114788
+ Waiting: 1
114789
+ };
114790
+ function ownerOf(row) {
114791
+ return {
114792
+ incarnation: row.incarnation,
114793
+ user: {
114794
+ id: row.id,
114795
+ name: row.name
114796
+ }
114797
+ };
114798
+ }
114799
+ function roleOf(admins, id, row) {
114800
+ if (isAdmin(admins, id)) return "Admin";
114801
+ if (exists(row, (found) => found.status === "Allowed")) return "Member";
114802
+ return "Waiting";
114803
+ }
114804
+ function personOf(admins, row) {
114805
+ return Person.make({
114806
+ ...pick(row, [
114807
+ "id",
114808
+ "name",
114809
+ "since"
114810
+ ]),
114811
+ ...match$8(liftPredicate(row.fullName, isNonEmpty$1), {
114812
+ onNone: () => ({}),
114813
+ onSome: (fullName) => ({ fullName })
114814
+ }),
114815
+ role: roleOf(admins, row.id, some$1(row))
114816
+ });
114817
+ }
114818
+ function admission(current, admins, params, now) {
114819
+ return pipe(fromOption$2(findFirst(current, (row) => row.id === params.id), () => new NoSuchElementError()), flatMap$6((row) => {
114820
+ const found = personOf(admins, row);
114821
+ if (found.role !== "Waiting") return fail$13(AuthError.make({ message: "This account is not asking for access" }));
114822
+ if (!params.allow) return succeed$10([{
114823
+ owner: ownerOf(row),
114824
+ person: found
114825
+ }, filter$6(current, (stored) => stored.id !== params.id)]);
114826
+ return succeed$10([{
114827
+ owner: ownerOf(row),
114828
+ person: Person.make({
114829
+ ...found,
114830
+ role: "Member",
114831
+ since: now
114832
+ })
114833
+ }, map$8(current, (stored) => {
114834
+ if (stored.id !== params.id) return stored;
114835
+ return {
114836
+ ...stored,
114837
+ since: now,
114838
+ status: "Allowed"
114839
+ };
114840
+ })]);
114841
+ }));
114842
+ }
114843
+ function registerMember(current, admins, profile, since, incarnation) {
114844
+ const row = {
114845
+ fullName: profile.name ?? "",
114846
+ id: `github:${profile.id}`,
114847
+ incarnation,
114848
+ name: profile.login,
114849
+ since,
114850
+ status: match$1(isAdmin(admins, `github:${profile.id}`), {
114851
+ onFalse: () => "Waiting",
114852
+ onTrue: () => "Allowed"
114853
+ })
114854
+ };
114855
+ return [ownerOf(row), match$8(findFirst(current, (stored) => stored.id === row.id), {
114856
+ onNone: () => [...current, row],
114857
+ onSome: () => map$8(current, (stored) => {
114858
+ if (stored.id !== row.id) return stored;
114859
+ return {
114860
+ ...stored,
114861
+ fullName: row.fullName,
114862
+ name: row.name
114863
+ };
114864
+ })
114865
+ })];
114866
+ }
114867
+ function listPeople(current, admins) {
114868
+ const known = pipe(current, reverse, sort(flip$1(mapInput(Number$6, (row) => row.since))), map$8((row) => personOf(admins, row)));
114869
+ const knownIds = fromIterable(map$8(known, (person) => person.id));
114870
+ return sort([...map$8(filter$6(admins, (id) => !has(knownIds, `github:${id}`)), (id) => Person.make({
114871
+ id: `github:${id}`,
114872
+ name: `GitHub ${id}`,
114873
+ role: "Admin",
114874
+ since: 0
114875
+ })), ...known], mapInput(Order$4, (person) => ROLE_ORDER[person.role]));
114876
+ }
114723
114877
  // src/services/tokens/service.ts
114724
114878
  const expired$1 = AuthError.make({
114725
114879
  error: "invalid_grant",
@@ -114732,10 +114886,6 @@ function parts(token) {
114732
114886
  secret: found.groups?.["secret"] ?? ""
114733
114887
  }));
114734
114888
  }
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
114889
  function end(grants, family) {
114740
114890
  return filter$7(grants, (grant, key) => key !== family && grant.parent !== family);
114741
114891
  }
@@ -114773,7 +114923,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
114773
114923
  const change = fnUntraced(function* (update) {
114774
114924
  return yield* modifyEffect(grants, (current) => gen(function* () {
114775
114925
  const now = yield* currentTimeMillis;
114776
- const [result, next] = yield* update(live(current, now), now);
114926
+ const [result, next] = yield* update(live$1(current, now), now);
114777
114927
  yield* store.set("sign-ins", next);
114778
114928
  return [result, next];
114779
114929
  }));
@@ -114783,7 +114933,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
114783
114933
  const now = yield* currentTimeMillis;
114784
114934
  return {
114785
114935
  ...found,
114786
- grant: yield* fromOption(get$13(live(yield* get(grants), now), found.family)),
114936
+ grant: yield* fromOption(get$13(live$1(yield* get(grants), now), found.family)),
114787
114937
  hash: yield* hash(found.secret),
114788
114938
  now
114789
114939
  };
@@ -114813,7 +114963,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
114813
114963
  typ: "at+jwt"
114814
114964
  }), Signature, signature);
114815
114965
  const now = yield* currentTimeMillis;
114816
- const signedIn = yield* fromOption(get$13(live(yield* get(grants), now), verified.claims.sid));
114966
+ const signedIn = yield* fromOption(get$13(live$1(yield* get(grants), now), verified.claims.sid));
114817
114967
  if (signedIn.credential._tag !== "App" || signedIn.user.id !== verified.claims.sub) return yield* AuthError.make({ message: "Sign in first" });
114818
114968
  const found = {
114819
114969
  family: verified.claims.sid,
@@ -114954,20 +115104,7 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
114954
115104
  });
114955
115105
  const listApps = fnUntraced(function* (owner) {
114956
115106
  const now = yield* currentTimeMillis;
114957
- return pipe(toEntries(live(yield* get(grants), now)), filter$6((entry) => sameOwner(entry[1], owner)), map$8((entry) => ({
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))));
115107
+ return signedInApps(yield* get(grants), now, owner);
114971
115108
  });
114972
115109
  return Tokens.of({
114973
115110
  apps: (user) => pipe(merge$1(changes(grants), drop(tick("1 minute"), 1)), mapEffect$1(() => listApps(user))),
@@ -115086,30 +115223,6 @@ var Tokens = class Tokens extends Service$1()("@deslop/auth/services/tokens/serv
115086
115223
  }));
115087
115224
  };
115088
115225
  // 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
115226
  function member(id, current) {
115114
115227
  return findFirst(current, (row) => row.id === id);
115115
115228
  }
@@ -115130,25 +115243,6 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
115130
115243
  const transact = fnUntraced(function* (change) {
115131
115244
  return yield* modifyEffect(state, (current) => tap$1(change(current), (result) => store.set("members", result[1])));
115132
115245
  }, 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
115246
  const currentOwner = fnUntraced(function* (owner) {
115153
115247
  const row = member(owner.user.id, yield* get(state));
115154
115248
  if (local && owner.user.id === DEVELOPER.id && owner.incarnation === developer.incarnation) return row;
@@ -115162,7 +115256,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
115162
115256
  return row;
115163
115257
  });
115164
115258
  const allowed = fnUntraced(function* (owner) {
115165
- if (roleOf(owner.user.id, yield* currentOwner(owner)) === "Waiting") return yield* AuthError.make({
115259
+ if (roleOf(admins, owner.user.id, yield* currentOwner(owner)) === "Waiting") return yield* AuthError.make({
115166
115260
  error: "access_denied",
115167
115261
  message: "An admin has not allowed this GitHub account yet"
115168
115262
  });
@@ -115180,14 +115274,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
115180
115274
  });
115181
115275
  const list = fn("People.list")(function* (user) {
115182
115276
  yield* admin(user);
115183
- const known = pipe(yield* get(state), reverse, sort(flip$1(mapInput(Number$6, (row) => row.since))), map$8(personOf));
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]));
115277
+ return listPeople(yield* get(state), admins);
115191
115278
  }, rejected("Cannot read people"));
115192
115279
  yield* pipe(forEach$1(admins, fnUntraced(function* (id) {
115193
115280
  if (isSome(member(`github:${id}`, yield* get(state)))) return;
@@ -115195,10 +115282,17 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
115195
115282
  const since = yield* currentTimeMillis;
115196
115283
  yield* transact((current) => {
115197
115284
  if (isSome(member(`github:${profile.id}`, current))) return succeed$5([void 0, current]);
115198
- return succeed$5([void 0, [...current, memberOf(profile, since, "Allowed", match$1(local, {
115199
- onFalse: () => "legacy",
115200
- onTrue: () => "local"
115201
- }))]]);
115285
+ return succeed$5([void 0, [...current, {
115286
+ fullName: profile.name ?? "",
115287
+ id: `github:${profile.id}`,
115288
+ incarnation: match$1(local, {
115289
+ onFalse: () => "legacy",
115290
+ onTrue: () => "local"
115291
+ }),
115292
+ name: profile.login,
115293
+ since,
115294
+ status: "Allowed"
115295
+ }]]);
115202
115296
  });
115203
115297
  }), {
115204
115298
  concurrency: 1,
@@ -115213,11 +115307,11 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
115213
115307
  return match$8(yield* currentOwner(session.owner), {
115214
115308
  onNone: () => SignedAccount.make({
115215
115309
  ...session.owner.user,
115216
- role: roleOf(session.owner.user.id, none()),
115310
+ role: roleOf(admins, session.owner.user.id, none()),
115217
115311
  via: session.via
115218
115312
  }),
115219
115313
  onSome: (row) => SignedAccount.make({
115220
- ...omit(personOf(row), ["since"]),
115314
+ ...omit(personOf(admins, row), ["since"]),
115221
115315
  via: session.via
115222
115316
  })
115223
115317
  });
@@ -115226,30 +115320,7 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
115226
115320
  admit: fn("People.admit")(function* (params, user) {
115227
115321
  yield* admin(user);
115228
115322
  const now = yield* currentTimeMillis;
115229
- const result = yield* transact((current) => gen(function* () {
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
- }));
115323
+ const result = yield* transact((current) => fromResult(admission(current, admins, params, now)));
115253
115324
  if (!params.allow) {
115254
115325
  yield* tokens.forget(result.owner);
115255
115326
  yield* passkeys.forget(result.owner);
@@ -115262,40 +115333,24 @@ var People = class People extends Service$1()("@deslop/auth/services/people/serv
115262
115333
  register: fn("People.register")(function* (profile) {
115263
115334
  const since = yield* currentTimeMillis;
115264
115335
  return yield* transact((current) => gen(function* () {
115265
- const existing = member(`github:${profile.id}`, current);
115266
- const incarnation = match$8(existing, {
115336
+ return registerMember(current, admins, profile, since, yield* match$8(member(`github:${profile.id}`, current), {
115267
115337
  onNone: () => {
115268
115338
  if (local && profile.id === 0) return succeed$5("local");
115269
115339
  return map$5(random.randomBytes(32), encode$3);
115270
115340
  },
115271
115341
  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
- })];
115342
+ }));
115288
115343
  }));
115289
115344
  }, rejected("Cannot record the GitHub account")),
115290
115345
  remove: fn("People.remove")(function* (id, user) {
115291
115346
  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" });
115347
+ if (roleOf(admins, id, none()) === "Admin") return yield* AuthError.make({ message: "Admins come from GITHUB_ADMINS, so they cannot be removed here" });
115293
115348
  const removed = yield* transact((current) => gen(function* () {
115294
115349
  return [yield* fromOption(member(id, current)), filter$6(current, (row) => row.id !== id)];
115295
115350
  }));
115296
115351
  yield* tokens.forget(ownerOf(removed));
115297
115352
  yield* passkeys.forget(ownerOf(removed));
115298
- return personOf(removed);
115353
+ return personOf(admins, removed);
115299
115354
  }, rejected("Cannot remove this account"))
115300
115355
  });
115301
115356
  return pipe(make$85(People, people), add$1(RpcOwner, RpcOwner.of((effect, request) => flatMap$2(sessionOwner(request.headers), (owner) => provideService(effect, CurrentOwner, owner)))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deslop/auth",
3
- "version": "0.1.1260",
3
+ "version": "0.1.1261",
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": "916211bbb1927165ab4766455090060fa9056e80dcc2261ad2d4c1bf59a18d49"
36
+ "fingerprint": "752af47d59336a7fe7f0e0d21a3dfe41615d49ef01458c4dfb8026c7a185c5a9"
37
37
  }