@auth0/auth0-server-js 1.11.0 → 1.12.0

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.cjs CHANGED
@@ -262,7 +262,7 @@ function getTelemetryConfig(config) {
262
262
  return {
263
263
  enabled: true,
264
264
  name: config?.name ?? "@auth0/auth0-server-js",
265
- version: config?.version ?? "1.11.0"
265
+ version: config?.version ?? "1.12.0"
266
266
  };
267
267
  }
268
268
 
@@ -1455,16 +1455,24 @@ var ServerClient = class {
1455
1455
  * on the result — it only appears on the target session's tokens once the STT is redeemed.
1456
1456
  *
1457
1457
  * An actor is mandatory for an STT (this is what makes it auditable impersonation). It is
1458
- * resolved in this order: an explicit `options.actor` wins; otherwise the current agent
1459
- * session's ID token is used, refreshed when it has expired; if neither is available the method
1460
- * throws before any network call.
1458
+ * resolved in this order: an explicit `options.actor` wins, in which case the session is not
1459
+ * read at all; otherwise the current agent session's ID token is used, refreshed when it has
1460
+ * expired; if neither is available the method throws before any network call. An explicit actor
1461
+ * token carrying the default ID token type must satisfy Auth0's own validation — see
1462
+ * {@link SessionTransferActor.token}.
1463
+ *
1464
+ * When `organization` is provided it is sent on the exchange, so the tenant validates it while
1465
+ * minting. This is a separate parameter from the `organization` passed to
1466
+ * {@link ServerClient.buildSessionTransferRedirect}, which is forwarded to the target's
1467
+ * `/authorize` on the redirect.
1461
1468
  *
1462
1469
  * @param options Options including the developer-supplied `subjectToken`/`subjectTokenType` and an optional explicit `actor`.
1463
1470
  * @param storeOptions Optional options used to read the agent session (for the actor) and resolve the request domain.
1464
1471
  *
1465
- * @throws {TokenExchangeError} With code `actor_unavailable` when no explicit actor is given and no usable session ID token can be resolved — no logged-in agent, a session that belongs to a different domain in resolver mode, or an expired ID token that cannot be refreshed (raised client-side, before any network call). With the default code when the exchange itself fails; a server-side `setactor_required` or `session_transfer_disabled` condition is surfaced via `cause.error` / `cause.error_description`.
1472
+ * @throws {TokenExchangeError} With code `actor_unavailable` when no explicit actor is given and no usable session ID token can be resolved — no logged-in agent, a session that belongs to a different domain in resolver mode, or an expired ID token that cannot be refreshed (raised client-side, before any network call). With the default code when the exchange itself fails; a server-side `setactor_required` or `session_transfer_disabled` condition is surfaced via `cause.error` / `cause.error_description`. An organization the tenant rejects also surfaces here.
1466
1473
  * @throws {MissingClientAuthError} When client credentials are not configured (STT requires a confidential client).
1467
1474
  * @throws {MissingRequiredArgumentError} When `subjectToken` or `subjectTokenType` is missing or blank (raised before any session read or network call).
1475
+ * @throws {OrganizationValidationError} When `organization` is provided but blank (raised before any session read or network call).
1468
1476
  *
1469
1477
  * @returns A promise resolving to a {@link SessionTransferTokenResult} containing the STT and its metadata.
1470
1478
  */
@@ -1475,6 +1483,9 @@ var ServerClient = class {
1475
1483
  if (!options.subjectTokenType || !options.subjectTokenType.trim()) {
1476
1484
  throw new MissingRequiredArgumentError("subjectTokenType");
1477
1485
  }
1486
+ if (options.organization !== void 0 && !options.organization.trim()) {
1487
+ throw new import_auth0_auth_js.OrganizationValidationError("organization must not be blank");
1488
+ }
1478
1489
  const domain = await this.#resolveDomain(storeOptions);
1479
1490
  const actor = await this.#resolveSessionTransferActor(options.actor, domain, storeOptions);
1480
1491
  const authClient = this.#getAuthClient(domain);
@@ -1485,6 +1496,11 @@ var ServerClient = class {
1485
1496
  scope: options.scope,
1486
1497
  actorToken: actor.token,
1487
1498
  actorTokenType: actor.type,
1499
+ // Forwarded so the tenant validates the organization against the client's organization
1500
+ // settings while minting, rather than the STT being issued without it. Separate from the
1501
+ // `organization` on `buildSessionTransferRedirect`, which goes to the target's
1502
+ // `/authorize`; neither implies the other.
1503
+ organization: options.organization,
1488
1504
  extra: options.extra
1489
1505
  });
1490
1506
  return {