@auth0/auth0-server-js 1.11.0 → 1.12.1

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.1"
266
266
  };
267
267
  }
268
268
 
@@ -368,6 +368,12 @@ var ServerPasskeyClient = class {
368
368
  *
369
369
  * This method does not create a session; no state is persisted.
370
370
  *
371
+ * On a confidential client this endpoint accepts `client_secret` as its only
372
+ * credential, so configure `clientSecret` on the `ServerClient`. It does not
373
+ * accept a private key JWT and is not served on the mTLS endpoint aliases, so a
374
+ * client configured with only `clientAssertionSigningKey` or only `useMtls` is
375
+ * rejected by Auth0. Public clients authenticate with `clientId` alone.
376
+ *
371
377
  * @param options User profile data and optional realm/organization.
372
378
  * @param storeOptions Optional options used to resolve the domain (resolver mode).
373
379
  *
@@ -390,6 +396,9 @@ var ServerPasskeyClient = class {
390
396
  *
391
397
  * This method does not create a session; no state is persisted.
392
398
  *
399
+ * Client authentication works the same way as {@link ServerPasskeyClient.register}:
400
+ * on a confidential client, only a `clientSecret` is accepted here.
401
+ *
393
402
  * @param options Optional realm/organization configuration.
394
403
  * @param storeOptions Optional options used to resolve the domain (resolver mode).
395
404
  *
@@ -1455,16 +1464,24 @@ var ServerClient = class {
1455
1464
  * on the result — it only appears on the target session's tokens once the STT is redeemed.
1456
1465
  *
1457
1466
  * 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.
1467
+ * resolved in this order: an explicit `options.actor` wins, in which case the session is not
1468
+ * read at all; otherwise the current agent session's ID token is used, refreshed when it has
1469
+ * expired; if neither is available the method throws before any network call. An explicit actor
1470
+ * token carrying the default ID token type must satisfy Auth0's own validation — see
1471
+ * {@link SessionTransferActor.token}.
1472
+ *
1473
+ * When `organization` is provided it is sent on the exchange, so the tenant validates it while
1474
+ * minting. This is a separate parameter from the `organization` passed to
1475
+ * {@link ServerClient.buildSessionTransferRedirect}, which is forwarded to the target's
1476
+ * `/authorize` on the redirect.
1461
1477
  *
1462
1478
  * @param options Options including the developer-supplied `subjectToken`/`subjectTokenType` and an optional explicit `actor`.
1463
1479
  * @param storeOptions Optional options used to read the agent session (for the actor) and resolve the request domain.
1464
1480
  *
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`.
1481
+ * @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
1482
  * @throws {MissingClientAuthError} When client credentials are not configured (STT requires a confidential client).
1467
1483
  * @throws {MissingRequiredArgumentError} When `subjectToken` or `subjectTokenType` is missing or blank (raised before any session read or network call).
1484
+ * @throws {OrganizationValidationError} When `organization` is provided but blank (raised before any session read or network call).
1468
1485
  *
1469
1486
  * @returns A promise resolving to a {@link SessionTransferTokenResult} containing the STT and its metadata.
1470
1487
  */
@@ -1475,6 +1492,9 @@ var ServerClient = class {
1475
1492
  if (!options.subjectTokenType || !options.subjectTokenType.trim()) {
1476
1493
  throw new MissingRequiredArgumentError("subjectTokenType");
1477
1494
  }
1495
+ if (options.organization !== void 0 && !options.organization.trim()) {
1496
+ throw new import_auth0_auth_js.OrganizationValidationError("organization must not be blank");
1497
+ }
1478
1498
  const domain = await this.#resolveDomain(storeOptions);
1479
1499
  const actor = await this.#resolveSessionTransferActor(options.actor, domain, storeOptions);
1480
1500
  const authClient = this.#getAuthClient(domain);
@@ -1485,6 +1505,11 @@ var ServerClient = class {
1485
1505
  scope: options.scope,
1486
1506
  actorToken: actor.token,
1487
1507
  actorTokenType: actor.type,
1508
+ // Forwarded so the tenant validates the organization against the client's organization
1509
+ // settings while minting, rather than the STT being issued without it. Separate from the
1510
+ // `organization` on `buildSessionTransferRedirect`, which goes to the target's
1511
+ // `/authorize`; neither implies the other.
1512
+ organization: options.organization,
1488
1513
  extra: options.extra
1489
1514
  });
1490
1515
  return {