@sixb/server 0.1.13 → 0.1.14

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