@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 +21 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -9
- package/dist/index.d.ts +39 -9
- package/dist/index.js +21 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -425,11 +425,19 @@ interface LoginWithCustomTokenExchangeResult {
|
|
|
425
425
|
* An explicit actor (the acting party) for a Session Transfer Token request.
|
|
426
426
|
*
|
|
427
427
|
* Supplying this overrides the default behaviour of sourcing the actor from the
|
|
428
|
-
* current agent session's ID token.
|
|
428
|
+
* current agent session's ID token. The session is not read at all when this is
|
|
429
|
+
* given, so it also works where there is no logged-in agent.
|
|
429
430
|
*/
|
|
430
431
|
interface SessionTransferActor {
|
|
431
432
|
/**
|
|
432
433
|
* The actor token — for the default flow this is the agent's ID token.
|
|
434
|
+
*
|
|
435
|
+
* When {@link SessionTransferActor.type} is the ID token URN (the default), Auth0
|
|
436
|
+
* validates this token and requires an unexpired, asymmetrically-signed Auth0 ID
|
|
437
|
+
* token: signed with `RS256` or `PS256` (`HS256` is rejected, as it uses a shared
|
|
438
|
+
* secret), carrying `sub`, `iss`, `exp` and `iat`, issued to the same client making
|
|
439
|
+
* the exchange, and belonging to a user who still exists and is not blocked. A token
|
|
440
|
+
* failing any of these fails the exchange with a `TokenExchangeError`.
|
|
433
441
|
*/
|
|
434
442
|
token: string;
|
|
435
443
|
/**
|
|
@@ -462,16 +470,30 @@ interface RequestSessionTransferTokenOptions {
|
|
|
462
470
|
/**
|
|
463
471
|
* An explicit actor to override the default (the agent session's ID token).
|
|
464
472
|
*
|
|
465
|
-
* Resolution order: this explicit `actor` wins
|
|
466
|
-
* token is used (refreshed when expired); if neither
|
|
467
|
-
* client-side with a `TokenExchangeError` whose code is
|
|
468
|
-
* any network call.
|
|
473
|
+
* Resolution order: this explicit `actor` wins, and the session is not read at all;
|
|
474
|
+
* otherwise the agent session's ID token is used (refreshed when expired); if neither
|
|
475
|
+
* is available the request fails client-side with a `TokenExchangeError` whose code is
|
|
476
|
+
* `actor_unavailable`, before any network call.
|
|
469
477
|
*/
|
|
470
478
|
actor?: SessionTransferActor;
|
|
471
479
|
/**
|
|
472
480
|
* Space-separated list of OAuth 2.0 scopes to request for the session's tokens.
|
|
473
481
|
*/
|
|
474
482
|
scope?: string;
|
|
483
|
+
/**
|
|
484
|
+
* The organization (ID or name) to mint the STT in the context of.
|
|
485
|
+
*
|
|
486
|
+
* Sending it here has the tenant validate the organization against the client's
|
|
487
|
+
* organization settings while minting, so an organization the client is not allowed
|
|
488
|
+
* to use fails at this call instead of the STT being issued without it.
|
|
489
|
+
*
|
|
490
|
+
* This is a separate parameter from {@link BuildSessionTransferRedirectOptions.organization},
|
|
491
|
+
* which is forwarded to the target's `/authorize` on the redirect. They are sent on
|
|
492
|
+
* different requests and neither implies the other. The one on the redirect is what
|
|
493
|
+
* org-scopes the session the target establishes, so setting only this one validates the
|
|
494
|
+
* organization without scoping that session.
|
|
495
|
+
*/
|
|
496
|
+
organization?: string;
|
|
475
497
|
/**
|
|
476
498
|
* Additional custom parameters forwarded to the token endpoint (and thus to your
|
|
477
499
|
* Action via `event.request.body`). Cannot override reserved OAuth parameters.
|
|
@@ -1104,16 +1126,24 @@ declare class ServerClient<TStoreOptions = unknown> {
|
|
|
1104
1126
|
* on the result — it only appears on the target session's tokens once the STT is redeemed.
|
|
1105
1127
|
*
|
|
1106
1128
|
* An actor is mandatory for an STT (this is what makes it auditable impersonation). It is
|
|
1107
|
-
* resolved in this order: an explicit `options.actor` wins
|
|
1108
|
-
* session's ID token is used, refreshed when it has
|
|
1109
|
-
* throws before any network call.
|
|
1129
|
+
* resolved in this order: an explicit `options.actor` wins, in which case the session is not
|
|
1130
|
+
* read at all; otherwise the current agent session's ID token is used, refreshed when it has
|
|
1131
|
+
* expired; if neither is available the method throws before any network call. An explicit actor
|
|
1132
|
+
* token carrying the default ID token type must satisfy Auth0's own validation — see
|
|
1133
|
+
* {@link SessionTransferActor.token}.
|
|
1134
|
+
*
|
|
1135
|
+
* When `organization` is provided it is sent on the exchange, so the tenant validates it while
|
|
1136
|
+
* minting. This is a separate parameter from the `organization` passed to
|
|
1137
|
+
* {@link ServerClient.buildSessionTransferRedirect}, which is forwarded to the target's
|
|
1138
|
+
* `/authorize` on the redirect.
|
|
1110
1139
|
*
|
|
1111
1140
|
* @param options Options including the developer-supplied `subjectToken`/`subjectTokenType` and an optional explicit `actor`.
|
|
1112
1141
|
* @param storeOptions Optional options used to read the agent session (for the actor) and resolve the request domain.
|
|
1113
1142
|
*
|
|
1114
|
-
* @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`.
|
|
1143
|
+
* @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.
|
|
1115
1144
|
* @throws {MissingClientAuthError} When client credentials are not configured (STT requires a confidential client).
|
|
1116
1145
|
* @throws {MissingRequiredArgumentError} When `subjectToken` or `subjectTokenType` is missing or blank (raised before any session read or network call).
|
|
1146
|
+
* @throws {OrganizationValidationError} When `organization` is provided but blank (raised before any session read or network call).
|
|
1117
1147
|
*
|
|
1118
1148
|
* @returns A promise resolving to a {@link SessionTransferTokenResult} containing the STT and its metadata.
|
|
1119
1149
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -425,11 +425,19 @@ interface LoginWithCustomTokenExchangeResult {
|
|
|
425
425
|
* An explicit actor (the acting party) for a Session Transfer Token request.
|
|
426
426
|
*
|
|
427
427
|
* Supplying this overrides the default behaviour of sourcing the actor from the
|
|
428
|
-
* current agent session's ID token.
|
|
428
|
+
* current agent session's ID token. The session is not read at all when this is
|
|
429
|
+
* given, so it also works where there is no logged-in agent.
|
|
429
430
|
*/
|
|
430
431
|
interface SessionTransferActor {
|
|
431
432
|
/**
|
|
432
433
|
* The actor token — for the default flow this is the agent's ID token.
|
|
434
|
+
*
|
|
435
|
+
* When {@link SessionTransferActor.type} is the ID token URN (the default), Auth0
|
|
436
|
+
* validates this token and requires an unexpired, asymmetrically-signed Auth0 ID
|
|
437
|
+
* token: signed with `RS256` or `PS256` (`HS256` is rejected, as it uses a shared
|
|
438
|
+
* secret), carrying `sub`, `iss`, `exp` and `iat`, issued to the same client making
|
|
439
|
+
* the exchange, and belonging to a user who still exists and is not blocked. A token
|
|
440
|
+
* failing any of these fails the exchange with a `TokenExchangeError`.
|
|
433
441
|
*/
|
|
434
442
|
token: string;
|
|
435
443
|
/**
|
|
@@ -462,16 +470,30 @@ interface RequestSessionTransferTokenOptions {
|
|
|
462
470
|
/**
|
|
463
471
|
* An explicit actor to override the default (the agent session's ID token).
|
|
464
472
|
*
|
|
465
|
-
* Resolution order: this explicit `actor` wins
|
|
466
|
-
* token is used (refreshed when expired); if neither
|
|
467
|
-
* client-side with a `TokenExchangeError` whose code is
|
|
468
|
-
* any network call.
|
|
473
|
+
* Resolution order: this explicit `actor` wins, and the session is not read at all;
|
|
474
|
+
* otherwise the agent session's ID token is used (refreshed when expired); if neither
|
|
475
|
+
* is available the request fails client-side with a `TokenExchangeError` whose code is
|
|
476
|
+
* `actor_unavailable`, before any network call.
|
|
469
477
|
*/
|
|
470
478
|
actor?: SessionTransferActor;
|
|
471
479
|
/**
|
|
472
480
|
* Space-separated list of OAuth 2.0 scopes to request for the session's tokens.
|
|
473
481
|
*/
|
|
474
482
|
scope?: string;
|
|
483
|
+
/**
|
|
484
|
+
* The organization (ID or name) to mint the STT in the context of.
|
|
485
|
+
*
|
|
486
|
+
* Sending it here has the tenant validate the organization against the client's
|
|
487
|
+
* organization settings while minting, so an organization the client is not allowed
|
|
488
|
+
* to use fails at this call instead of the STT being issued without it.
|
|
489
|
+
*
|
|
490
|
+
* This is a separate parameter from {@link BuildSessionTransferRedirectOptions.organization},
|
|
491
|
+
* which is forwarded to the target's `/authorize` on the redirect. They are sent on
|
|
492
|
+
* different requests and neither implies the other. The one on the redirect is what
|
|
493
|
+
* org-scopes the session the target establishes, so setting only this one validates the
|
|
494
|
+
* organization without scoping that session.
|
|
495
|
+
*/
|
|
496
|
+
organization?: string;
|
|
475
497
|
/**
|
|
476
498
|
* Additional custom parameters forwarded to the token endpoint (and thus to your
|
|
477
499
|
* Action via `event.request.body`). Cannot override reserved OAuth parameters.
|
|
@@ -1104,16 +1126,24 @@ declare class ServerClient<TStoreOptions = unknown> {
|
|
|
1104
1126
|
* on the result — it only appears on the target session's tokens once the STT is redeemed.
|
|
1105
1127
|
*
|
|
1106
1128
|
* An actor is mandatory for an STT (this is what makes it auditable impersonation). It is
|
|
1107
|
-
* resolved in this order: an explicit `options.actor` wins
|
|
1108
|
-
* session's ID token is used, refreshed when it has
|
|
1109
|
-
* throws before any network call.
|
|
1129
|
+
* resolved in this order: an explicit `options.actor` wins, in which case the session is not
|
|
1130
|
+
* read at all; otherwise the current agent session's ID token is used, refreshed when it has
|
|
1131
|
+
* expired; if neither is available the method throws before any network call. An explicit actor
|
|
1132
|
+
* token carrying the default ID token type must satisfy Auth0's own validation — see
|
|
1133
|
+
* {@link SessionTransferActor.token}.
|
|
1134
|
+
*
|
|
1135
|
+
* When `organization` is provided it is sent on the exchange, so the tenant validates it while
|
|
1136
|
+
* minting. This is a separate parameter from the `organization` passed to
|
|
1137
|
+
* {@link ServerClient.buildSessionTransferRedirect}, which is forwarded to the target's
|
|
1138
|
+
* `/authorize` on the redirect.
|
|
1110
1139
|
*
|
|
1111
1140
|
* @param options Options including the developer-supplied `subjectToken`/`subjectTokenType` and an optional explicit `actor`.
|
|
1112
1141
|
* @param storeOptions Optional options used to read the agent session (for the actor) and resolve the request domain.
|
|
1113
1142
|
*
|
|
1114
|
-
* @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`.
|
|
1143
|
+
* @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.
|
|
1115
1144
|
* @throws {MissingClientAuthError} When client credentials are not configured (STT requires a confidential client).
|
|
1116
1145
|
* @throws {MissingRequiredArgumentError} When `subjectToken` or `subjectTokenType` is missing or blank (raised before any session read or network call).
|
|
1146
|
+
* @throws {OrganizationValidationError} When `organization` is provided but blank (raised before any session read or network call).
|
|
1117
1147
|
*
|
|
1118
1148
|
* @returns A promise resolving to a {@link SessionTransferTokenResult} containing the STT and its metadata.
|
|
1119
1149
|
*/
|
package/dist/index.js
CHANGED
|
@@ -211,7 +211,7 @@ function getTelemetryConfig(config) {
|
|
|
211
211
|
return {
|
|
212
212
|
enabled: true,
|
|
213
213
|
name: config?.name ?? "@auth0/auth0-server-js",
|
|
214
|
-
version: config?.version ?? "1.
|
|
214
|
+
version: config?.version ?? "1.12.0"
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
217
|
|
|
@@ -1404,16 +1404,24 @@ var ServerClient = class {
|
|
|
1404
1404
|
* on the result — it only appears on the target session's tokens once the STT is redeemed.
|
|
1405
1405
|
*
|
|
1406
1406
|
* An actor is mandatory for an STT (this is what makes it auditable impersonation). It is
|
|
1407
|
-
* resolved in this order: an explicit `options.actor` wins
|
|
1408
|
-
* session's ID token is used, refreshed when it has
|
|
1409
|
-
* throws before any network call.
|
|
1407
|
+
* resolved in this order: an explicit `options.actor` wins, in which case the session is not
|
|
1408
|
+
* read at all; otherwise the current agent session's ID token is used, refreshed when it has
|
|
1409
|
+
* expired; if neither is available the method throws before any network call. An explicit actor
|
|
1410
|
+
* token carrying the default ID token type must satisfy Auth0's own validation — see
|
|
1411
|
+
* {@link SessionTransferActor.token}.
|
|
1412
|
+
*
|
|
1413
|
+
* When `organization` is provided it is sent on the exchange, so the tenant validates it while
|
|
1414
|
+
* minting. This is a separate parameter from the `organization` passed to
|
|
1415
|
+
* {@link ServerClient.buildSessionTransferRedirect}, which is forwarded to the target's
|
|
1416
|
+
* `/authorize` on the redirect.
|
|
1410
1417
|
*
|
|
1411
1418
|
* @param options Options including the developer-supplied `subjectToken`/`subjectTokenType` and an optional explicit `actor`.
|
|
1412
1419
|
* @param storeOptions Optional options used to read the agent session (for the actor) and resolve the request domain.
|
|
1413
1420
|
*
|
|
1414
|
-
* @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`.
|
|
1421
|
+
* @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.
|
|
1415
1422
|
* @throws {MissingClientAuthError} When client credentials are not configured (STT requires a confidential client).
|
|
1416
1423
|
* @throws {MissingRequiredArgumentError} When `subjectToken` or `subjectTokenType` is missing or blank (raised before any session read or network call).
|
|
1424
|
+
* @throws {OrganizationValidationError} When `organization` is provided but blank (raised before any session read or network call).
|
|
1417
1425
|
*
|
|
1418
1426
|
* @returns A promise resolving to a {@link SessionTransferTokenResult} containing the STT and its metadata.
|
|
1419
1427
|
*/
|
|
@@ -1424,6 +1432,9 @@ var ServerClient = class {
|
|
|
1424
1432
|
if (!options.subjectTokenType || !options.subjectTokenType.trim()) {
|
|
1425
1433
|
throw new MissingRequiredArgumentError("subjectTokenType");
|
|
1426
1434
|
}
|
|
1435
|
+
if (options.organization !== void 0 && !options.organization.trim()) {
|
|
1436
|
+
throw new OrganizationValidationError("organization must not be blank");
|
|
1437
|
+
}
|
|
1427
1438
|
const domain = await this.#resolveDomain(storeOptions);
|
|
1428
1439
|
const actor = await this.#resolveSessionTransferActor(options.actor, domain, storeOptions);
|
|
1429
1440
|
const authClient = this.#getAuthClient(domain);
|
|
@@ -1434,6 +1445,11 @@ var ServerClient = class {
|
|
|
1434
1445
|
scope: options.scope,
|
|
1435
1446
|
actorToken: actor.token,
|
|
1436
1447
|
actorTokenType: actor.type,
|
|
1448
|
+
// Forwarded so the tenant validates the organization against the client's organization
|
|
1449
|
+
// settings while minting, rather than the STT being issued without it. Separate from the
|
|
1450
|
+
// `organization` on `buildSessionTransferRedirect`, which goes to the target's
|
|
1451
|
+
// `/authorize`; neither implies the other.
|
|
1452
|
+
organization: options.organization,
|
|
1437
1453
|
extra: options.extra
|
|
1438
1454
|
});
|
|
1439
1455
|
return {
|