@sixb/server 0.1.13 → 0.1.15

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/index.js CHANGED
@@ -8227,7 +8227,8 @@ var ProjectionRunStatusSchema = z22.enum([
8227
8227
  "running",
8228
8228
  "succeeded",
8229
8229
  "failed",
8230
- "cancelled"
8230
+ "cancelled",
8231
+ "superseded"
8231
8232
  ]);
8232
8233
  var ProjectionRunIdentityBaseSchema = z22.object({
8233
8234
  projectionId: z22.string(),
@@ -11010,6 +11011,7 @@ import {
11010
11011
  getRequestClientAddress,
11011
11012
  isMagicLinkAuthStrategy,
11012
11013
  isOidcAuthStrategy,
11014
+ SignInRefusedError,
11013
11015
  shouldUseSecureCookies,
11014
11016
  verifyCsrfToken,
11015
11017
  verifyDoubleSubmitCsrf as verifyDoubleSubmitCsrf3
@@ -11258,7 +11260,8 @@ var AuthMemberUserSchema = z32.object({
11258
11260
  });
11259
11261
  var AuthManagedMemberSchema = z32.object({
11260
11262
  user: AuthMemberUserSchema,
11261
- groupIds: z32.array(z32.string())
11263
+ groupIds: z32.array(z32.string()),
11264
+ managedGroupIds: z32.array(z32.string())
11262
11265
  });
11263
11266
  var AuthMemberCapabilitiesSchema = z32.object({
11264
11267
  assignGroups: z32.boolean(),
@@ -12315,7 +12318,7 @@ function registerAuthRoutes(app, host, options) {
12315
12318
  userId: parsedParams.userId,
12316
12319
  groupIds: parsed.groupIds
12317
12320
  });
12318
- return jsonResponse2({ member: serializeManagedMember(result.user, result.groupIds) }, 200);
12321
+ return jsonResponse2({ member: serializeManagedMember(result) }, 200);
12319
12322
  } catch (error) {
12320
12323
  return authRouteErrorResponse(error);
12321
12324
  }
@@ -12341,7 +12344,7 @@ function registerAuthRoutes(app, host, options) {
12341
12344
  const caller = requireUserCaller(context);
12342
12345
  const parsed = AuthMemberParamsSchema.parse(params);
12343
12346
  const result = await host.auth.suspendMember(caller, { userId: parsed.userId });
12344
- return jsonResponse2({ member: serializeManagedMember(result.user, result.groupIds) }, 200);
12347
+ return jsonResponse2({ member: serializeManagedMember(result) }, 200);
12345
12348
  } catch (error) {
12346
12349
  return authRouteErrorResponse(error);
12347
12350
  }
@@ -12365,7 +12368,7 @@ function registerAuthRoutes(app, host, options) {
12365
12368
  const caller = requireUserCaller(context);
12366
12369
  const parsed = AuthMemberParamsSchema.parse(params);
12367
12370
  const result = await host.auth.reactivateMember(caller, { userId: parsed.userId });
12368
- return jsonResponse2({ member: serializeManagedMember(result.user, result.groupIds) }, 200);
12371
+ return jsonResponse2({ member: serializeManagedMember(result) }, 200);
12369
12372
  } catch (error) {
12370
12373
  return authRouteErrorResponse(error);
12371
12374
  }
@@ -12538,6 +12541,9 @@ function registerAuthRoutes(app, host, options) {
12538
12541
  });
12539
12542
  } catch (error) {
12540
12543
  logAuthCallbackError("OIDC", error);
12544
+ if (error instanceof SignInRefusedError) {
12545
+ return htmlMessageResponse(signInRefusalMessage(error), 403, "You can't sign in");
12546
+ }
12541
12547
  return htmlMessageResponse("This sign-in attempt could not be completed.", 400);
12542
12548
  }
12543
12549
  }
@@ -13187,14 +13193,15 @@ function serializeInvitationDelivery(delivery) {
13187
13193
  }
13188
13194
  function serializeMemberSummary(member) {
13189
13195
  return {
13190
- ...serializeManagedMember(member.user, member.groupIds),
13196
+ ...serializeManagedMember(member),
13191
13197
  capabilities: member.capabilities
13192
13198
  };
13193
13199
  }
13194
- function serializeManagedMember(user, groupIds) {
13200
+ function serializeManagedMember(member) {
13195
13201
  return {
13196
- user: serializeMemberUser(user),
13197
- groupIds: [...groupIds]
13202
+ user: serializeMemberUser(member.user),
13203
+ groupIds: [...member.groupIds],
13204
+ managedGroupIds: [...member.managedGroupIds]
13198
13205
  };
13199
13206
  }
13200
13207
  function serializeMemberUser(user) {
@@ -13242,11 +13249,25 @@ function authRouteErrorResponse(error) {
13242
13249
  }
13243
13250
  return jsonResponse2({ error: String(error) }, 500);
13244
13251
  }
13252
+ function signInRefusalMessage(error) {
13253
+ const who = error.email ?? "This account";
13254
+ switch (error.reason) {
13255
+ case "not_invited":
13256
+ return `${who} hasn't been invited. Ask an administrator to invite this address.`;
13257
+ case "suspended":
13258
+ return `${who} has been suspended. Ask an administrator to reactivate it.`;
13259
+ case "domain_not_allowed":
13260
+ return `${who} isn't on a domain that can sign in here.`;
13261
+ case "no_trusted_address":
13262
+ return "Your identity provider didn't share an email address this app trusts. Ask an administrator to check the sign-in setup.";
13263
+ }
13264
+ }
13245
13265
  function logAuthCallbackError(kind, error) {
13246
- if (process.env.SIXB_AUTH_DEBUG !== "1") {
13266
+ const setupMistake = error instanceof SignInRefusedError && error.reason === "no_trusted_address";
13267
+ if (!setupMistake && true && process.env.SIXB_AUTH_DEBUG !== "1") {
13247
13268
  return;
13248
13269
  }
13249
- const detail = error instanceof AuthStorageError ? `${error.name}(${error.code}): ${error.message}` : error instanceof Error ? `${error.name}: ${error.message}` : String(error);
13270
+ const detail = error instanceof AuthStorageError ? `${error.name}(${error.code}): ${error.message}` : error instanceof SignInRefusedError ? `${error.name}(${error.reason}): ${error.message}` : error instanceof Error ? `${error.name}: ${error.message}` : String(error);
13250
13271
  console.error(`[SixbServer] ${kind} auth callback failed: ${detail}`);
13251
13272
  }
13252
13273
  function jsonResponse2(body, status, headersInit) {
@@ -14926,4 +14947,4 @@ export {
14926
14947
  createSixbServer
14927
14948
  };
14928
14949
 
14929
- //# debugId=FAAE157E14B4AD2064756E2164756E21
14950
+ //# debugId=EB0D514324A9872464756E2164756E21