@auth0/auth0-server-js 1.16.0 → 1.16.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 +60 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -23,47 +23,47 @@ __export(index_exports, {
|
|
|
23
23
|
AbstractAnonymousStore: () => AbstractAnonymousStore,
|
|
24
24
|
AbstractStateStore: () => AbstractStateStore,
|
|
25
25
|
AbstractTransactionStore: () => AbstractTransactionStore,
|
|
26
|
-
AnonymousSessionError: () =>
|
|
26
|
+
AnonymousSessionError: () => import_auth0_auth_js7.AnonymousSessionError,
|
|
27
27
|
AnonymousSessionExpiredError: () => AnonymousSessionExpiredError,
|
|
28
28
|
BackchannelLogoutError: () => BackchannelLogoutError,
|
|
29
|
-
ChangePasswordError: () =>
|
|
29
|
+
ChangePasswordError: () => import_auth0_auth_js6.ChangePasswordError,
|
|
30
30
|
CookieTransactionStore: () => CookieTransactionStore,
|
|
31
31
|
DEFAULT_ANONYMOUS_SESSION_LIFETIME: () => DEFAULT_ANONYMOUS_SESSION_LIFETIME,
|
|
32
|
-
EnterpriseConnectNotSupportedError: () =>
|
|
32
|
+
EnterpriseConnectNotSupportedError: () => import_auth0_auth_js8.EnterpriseConnectNotSupportedError,
|
|
33
33
|
InvalidConfigurationError: () => InvalidConfigurationError,
|
|
34
34
|
IssuerValidationError: () => IssuerValidationError,
|
|
35
|
-
MfaChallengeError: () =>
|
|
36
|
-
MfaEnrollmentError: () =>
|
|
37
|
-
MfaListAuthenticatorsError: () =>
|
|
38
|
-
MfaVerifyError: () =>
|
|
35
|
+
MfaChallengeError: () => import_auth0_auth_js4.MfaChallengeError,
|
|
36
|
+
MfaEnrollmentError: () => import_auth0_auth_js4.MfaEnrollmentError,
|
|
37
|
+
MfaListAuthenticatorsError: () => import_auth0_auth_js4.MfaListAuthenticatorsError,
|
|
38
|
+
MfaVerifyError: () => import_auth0_auth_js4.MfaVerifyError,
|
|
39
39
|
MissingAnonymousSessionError: () => MissingAnonymousSessionError,
|
|
40
|
-
MissingClientAuthError: () =>
|
|
40
|
+
MissingClientAuthError: () => import_auth0_auth_js8.MissingClientAuthError,
|
|
41
41
|
MissingRequiredArgumentError: () => MissingRequiredArgumentError,
|
|
42
42
|
MissingSessionError: () => MissingSessionError,
|
|
43
43
|
MissingTransactionError: () => MissingTransactionError,
|
|
44
|
-
OrganizationValidationError: () =>
|
|
45
|
-
PasskeyChallengeError: () =>
|
|
46
|
-
PasskeyGetTokenError: () =>
|
|
47
|
-
PasskeyRegisterError: () =>
|
|
48
|
-
PasswordlessStartError: () =>
|
|
49
|
-
PasswordlessVerifyError: () =>
|
|
44
|
+
OrganizationValidationError: () => import_auth0_auth_js8.OrganizationValidationError,
|
|
45
|
+
PasskeyChallengeError: () => import_auth0_auth_js5.PasskeyChallengeError,
|
|
46
|
+
PasskeyGetTokenError: () => import_auth0_auth_js5.PasskeyGetTokenError,
|
|
47
|
+
PasskeyRegisterError: () => import_auth0_auth_js5.PasskeyRegisterError,
|
|
48
|
+
PasswordlessStartError: () => import_auth0_auth_js8.PasswordlessStartError,
|
|
49
|
+
PasswordlessVerifyError: () => import_auth0_auth_js8.PasswordlessVerifyError,
|
|
50
50
|
ServerAnonymousClient: () => ServerAnonymousClient,
|
|
51
51
|
ServerClient: () => ServerClient,
|
|
52
52
|
ServerDatabaseClient: () => ServerDatabaseClient,
|
|
53
53
|
ServerMfaClient: () => ServerMfaClient,
|
|
54
54
|
ServerPasskeyClient: () => ServerPasskeyClient,
|
|
55
55
|
SessionExpiredError: () => SessionExpiredError,
|
|
56
|
-
SignUpError: () =>
|
|
56
|
+
SignUpError: () => import_auth0_auth_js6.SignUpError,
|
|
57
57
|
StartLinkUserError: () => StartLinkUserError,
|
|
58
58
|
StatefulStateStore: () => StatefulStateStore,
|
|
59
59
|
StatelessAnonymousStore: () => StatelessAnonymousStore,
|
|
60
60
|
StatelessStateStore: () => StatelessStateStore,
|
|
61
|
-
TokenExchangeError: () =>
|
|
61
|
+
TokenExchangeError: () => import_auth0_auth_js8.TokenExchangeError,
|
|
62
62
|
TokenExchangeErrorCode: () => TokenExchangeErrorCode,
|
|
63
|
-
TokenRevocationError: () =>
|
|
64
|
-
UserInfoError: () =>
|
|
65
|
-
isFederatedDomain: () =>
|
|
66
|
-
isMfaRequiredError: () =>
|
|
63
|
+
TokenRevocationError: () => import_auth0_auth_js8.TokenRevocationError,
|
|
64
|
+
UserInfoError: () => import_auth0_auth_js8.UserInfoError,
|
|
65
|
+
isFederatedDomain: () => import_auth0_auth_js8.isFederatedDomain,
|
|
66
|
+
isMfaRequiredError: () => import_auth0_auth_js8.isMfaRequiredError
|
|
67
67
|
});
|
|
68
68
|
module.exports = __toCommonJS(index_exports);
|
|
69
69
|
|
|
@@ -250,7 +250,7 @@ function updateStateDataForConnectionTokenSet(options, stateData, tokenEndpointR
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
// src/server-client.ts
|
|
253
|
-
var
|
|
253
|
+
var import_auth0_auth_js3 = require("@auth0/auth0-auth-js");
|
|
254
254
|
|
|
255
255
|
// src/utils.ts
|
|
256
256
|
var DEFAULT_SCOPES = "openid profile email offline_access";
|
|
@@ -288,7 +288,7 @@ function getTelemetryConfig(config) {
|
|
|
288
288
|
return {
|
|
289
289
|
enabled: true,
|
|
290
290
|
name: config?.name ?? "@auth0/auth0-server-js",
|
|
291
|
-
version: config?.version ?? "1.16.
|
|
291
|
+
version: config?.version ?? "1.16.1"
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
294
|
|
|
@@ -568,6 +568,7 @@ function applyEnterpriseConnectRestrictions(instance) {
|
|
|
568
568
|
|
|
569
569
|
// src/anonymous/server-anonymous-client.ts
|
|
570
570
|
var import_jose = require("jose");
|
|
571
|
+
var import_auth0_auth_js2 = require("@auth0/auth0-auth-js");
|
|
571
572
|
var DEFAULT_AUDIENCE_CACHE_KEY = "default";
|
|
572
573
|
var readAnonymousSub = (accessToken) => {
|
|
573
574
|
try {
|
|
@@ -699,14 +700,22 @@ var ServerAnonymousClient = class {
|
|
|
699
700
|
if (cachedTokenSet && cachedTokenSet.expiresAt > Date.now() / 1e3) {
|
|
700
701
|
return cachedTokenSet;
|
|
701
702
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
703
|
+
let renewed;
|
|
704
|
+
try {
|
|
705
|
+
renewed = await this.#options.getAuthClient(domain).anonymous.getAccessToken({
|
|
706
|
+
sessionToken: stateData.sessionToken,
|
|
707
|
+
...requestedAudience && { audience: requestedAudience },
|
|
708
|
+
...scope && { scope }
|
|
709
|
+
});
|
|
710
|
+
} catch (e) {
|
|
711
|
+
if (e instanceof import_auth0_auth_js2.AnonymousSessionError && e.code === "session_expired") {
|
|
712
|
+
await this.#options.anonymousStore.delete(this.#options.anonymousStoreIdentifier, storeOptions);
|
|
713
|
+
throw new AnonymousSessionExpiredError();
|
|
714
|
+
}
|
|
715
|
+
if (e instanceof import_auth0_auth_js2.AnonymousSessionError && e.code === "invalid_session_token") {
|
|
716
|
+
await this.#options.anonymousStore.delete(this.#options.anonymousStoreIdentifier, storeOptions);
|
|
717
|
+
}
|
|
718
|
+
throw e;
|
|
710
719
|
}
|
|
711
720
|
const tokenSet = {
|
|
712
721
|
audience,
|
|
@@ -802,7 +811,7 @@ var decodeIssuer = (token) => {
|
|
|
802
811
|
var ID_TOKEN_TYPE = "urn:ietf:params:oauth:token-type:id_token";
|
|
803
812
|
var ID_TOKEN_EXPIRY_SKEW_SECONDS = 30;
|
|
804
813
|
var actorUnavailableError = (message) => {
|
|
805
|
-
const error = new
|
|
814
|
+
const error = new import_auth0_auth_js3.TokenExchangeError(message);
|
|
806
815
|
error.code = TokenExchangeErrorCode.ACTOR_UNAVAILABLE;
|
|
807
816
|
return error;
|
|
808
817
|
};
|
|
@@ -977,7 +986,7 @@ var ServerClient = class {
|
|
|
977
986
|
if (typeof this.#options.domain === "string") {
|
|
978
987
|
const domain = normalizeDomain(this.#options.domain);
|
|
979
988
|
this.#staticDomain = domain;
|
|
980
|
-
this.#authClient = new
|
|
989
|
+
this.#authClient = new import_auth0_auth_js3.AuthClient({
|
|
981
990
|
domain,
|
|
982
991
|
...this.#authClientOptions,
|
|
983
992
|
telemetry: getTelemetryConfig(this.#options.telemetry)
|
|
@@ -1029,7 +1038,7 @@ var ServerClient = class {
|
|
|
1029
1038
|
return normalizeDomain(this.#options.domain);
|
|
1030
1039
|
}
|
|
1031
1040
|
#createAuthClient(domain) {
|
|
1032
|
-
return new
|
|
1041
|
+
return new import_auth0_auth_js3.AuthClient({
|
|
1033
1042
|
domain,
|
|
1034
1043
|
...this.#authClientOptions,
|
|
1035
1044
|
telemetry: getTelemetryConfig(this.#options.telemetry)
|
|
@@ -1080,7 +1089,7 @@ var ServerClient = class {
|
|
|
1080
1089
|
if (parts.length !== 2 || !parts[0] || !parts[1]) return null;
|
|
1081
1090
|
const emailDomain = parts[1].toLowerCase();
|
|
1082
1091
|
const domain = await this.#resolveDomain(storeOptions);
|
|
1083
|
-
const isFederated = await (0,
|
|
1092
|
+
const isFederated = await (0, import_auth0_auth_js3.isFederatedDomain)(domain, emailDomain, {
|
|
1084
1093
|
customFetch: this.#options.customFetch,
|
|
1085
1094
|
telemetry: getTelemetryConfig(this.#options.telemetry)
|
|
1086
1095
|
});
|
|
@@ -1168,7 +1177,7 @@ var ServerClient = class {
|
|
|
1168
1177
|
const clientAuthParamsOrganization = typeof this.#options.authorizationParams?.organization === "string" ? this.#options.authorizationParams.organization : void 0;
|
|
1169
1178
|
const resolvedOrganization = options?.organization ?? perLoginAuthParamsOrganization ?? this.#options.organization ?? clientAuthParamsOrganization;
|
|
1170
1179
|
if (resolvedOrganization !== void 0 && !resolvedOrganization.trim()) {
|
|
1171
|
-
throw new
|
|
1180
|
+
throw new import_auth0_auth_js3.OrganizationValidationError("organization must not be blank");
|
|
1172
1181
|
}
|
|
1173
1182
|
const hasInvitation = !!(options?.invitation || options?.authorizationParams?.invitation);
|
|
1174
1183
|
if (hasInvitation && !resolvedOrganization) {
|
|
@@ -1439,7 +1448,7 @@ var ServerClient = class {
|
|
|
1439
1448
|
};
|
|
1440
1449
|
if (options.fullResponse) {
|
|
1441
1450
|
if (!response) {
|
|
1442
|
-
throw new
|
|
1451
|
+
throw new import_auth0_auth_js3.MissingCapturedResponseError();
|
|
1443
1452
|
}
|
|
1444
1453
|
return { data: result, response };
|
|
1445
1454
|
}
|
|
@@ -1508,7 +1517,7 @@ var ServerClient = class {
|
|
|
1508
1517
|
return;
|
|
1509
1518
|
}
|
|
1510
1519
|
if (!options.redirectUri || typeof options.redirectUri !== "string") {
|
|
1511
|
-
throw new
|
|
1520
|
+
throw new import_auth0_auth_js3.PasswordlessStartError("redirectUri is required to start a passwordless magic-link login.");
|
|
1512
1521
|
}
|
|
1513
1522
|
const state = crypto.randomUUID();
|
|
1514
1523
|
const scope = ensureOpenIdScope(options.scope ?? this.#options.authorizationParams?.scope);
|
|
@@ -1586,7 +1595,7 @@ var ServerClient = class {
|
|
|
1586
1595
|
};
|
|
1587
1596
|
if (options.fullResponse) {
|
|
1588
1597
|
if (!response) {
|
|
1589
|
-
throw new
|
|
1598
|
+
throw new import_auth0_auth_js3.MissingCapturedResponseError();
|
|
1590
1599
|
}
|
|
1591
1600
|
return { data: result, response };
|
|
1592
1601
|
}
|
|
@@ -1621,7 +1630,7 @@ var ServerClient = class {
|
|
|
1621
1630
|
const expectedState = typeof transactionData.state === "string" ? transactionData.state : void 0;
|
|
1622
1631
|
const returnedState = url.searchParams.get("state");
|
|
1623
1632
|
if (!returnedState || !expectedState || returnedState !== expectedState) {
|
|
1624
|
-
throw new
|
|
1633
|
+
throw new import_auth0_auth_js3.PasswordlessVerifyError("State mismatch on magic-link callback");
|
|
1625
1634
|
}
|
|
1626
1635
|
const domain = transactionData.domain ?? await this.#resolveDomain(storeOptions);
|
|
1627
1636
|
const authClient = this.#getAuthClient(domain);
|
|
@@ -1779,7 +1788,7 @@ var ServerClient = class {
|
|
|
1779
1788
|
}
|
|
1780
1789
|
}
|
|
1781
1790
|
if (!stateData?.refreshToken) {
|
|
1782
|
-
throw new
|
|
1791
|
+
throw new import_auth0_auth_js3.TokenByRefreshTokenError(
|
|
1783
1792
|
"The access token has expired and a refresh token was not provided. The user needs to re-authenticate."
|
|
1784
1793
|
);
|
|
1785
1794
|
}
|
|
@@ -1818,7 +1827,7 @@ var ServerClient = class {
|
|
|
1818
1827
|
};
|
|
1819
1828
|
if (resolvedOptions?.fullResponse) {
|
|
1820
1829
|
if (!response) {
|
|
1821
|
-
throw new
|
|
1830
|
+
throw new import_auth0_auth_js3.MissingCapturedResponseError();
|
|
1822
1831
|
}
|
|
1823
1832
|
return { data: returnTokenSet, response };
|
|
1824
1833
|
}
|
|
@@ -1848,7 +1857,7 @@ var ServerClient = class {
|
|
|
1848
1857
|
}
|
|
1849
1858
|
}
|
|
1850
1859
|
if (!stateData?.refreshToken) {
|
|
1851
|
-
throw new
|
|
1860
|
+
throw new import_auth0_auth_js3.TokenForConnectionError(
|
|
1852
1861
|
"A refresh token was not found but is required to be able to retrieve an access token for a connection."
|
|
1853
1862
|
);
|
|
1854
1863
|
}
|
|
@@ -1889,7 +1898,7 @@ var ServerClient = class {
|
|
|
1889
1898
|
};
|
|
1890
1899
|
if (options.fullResponse) {
|
|
1891
1900
|
if (!response) {
|
|
1892
|
-
throw new
|
|
1901
|
+
throw new import_auth0_auth_js3.MissingCapturedResponseError();
|
|
1893
1902
|
}
|
|
1894
1903
|
return { data: returnConnectionTokenSet, response };
|
|
1895
1904
|
}
|
|
@@ -2038,7 +2047,7 @@ var ServerClient = class {
|
|
|
2038
2047
|
};
|
|
2039
2048
|
if (options.fullResponse) {
|
|
2040
2049
|
if (!response) {
|
|
2041
|
-
throw new
|
|
2050
|
+
throw new import_auth0_auth_js3.MissingCapturedResponseError();
|
|
2042
2051
|
}
|
|
2043
2052
|
return { data: result, response };
|
|
2044
2053
|
}
|
|
@@ -2102,7 +2111,7 @@ var ServerClient = class {
|
|
|
2102
2111
|
throw new MissingRequiredArgumentError("subjectTokenType");
|
|
2103
2112
|
}
|
|
2104
2113
|
if (options.organization !== void 0 && !options.organization.trim()) {
|
|
2105
|
-
throw new
|
|
2114
|
+
throw new import_auth0_auth_js3.OrganizationValidationError("organization must not be blank");
|
|
2106
2115
|
}
|
|
2107
2116
|
const domain = await this.#resolveDomain(storeOptions);
|
|
2108
2117
|
const actor = await this.#resolveSessionTransferActor(options.actor, domain, storeOptions);
|
|
@@ -2176,7 +2185,7 @@ var ServerClient = class {
|
|
|
2176
2185
|
url.searchParams.set("session_transfer_token", result.sessionTransferToken);
|
|
2177
2186
|
if (options?.organization !== void 0) {
|
|
2178
2187
|
if (!options.organization.trim()) {
|
|
2179
|
-
throw new
|
|
2188
|
+
throw new import_auth0_auth_js3.OrganizationValidationError("organization must not be blank");
|
|
2180
2189
|
}
|
|
2181
2190
|
url.searchParams.set("organization", options.organization);
|
|
2182
2191
|
}
|
|
@@ -2401,7 +2410,7 @@ var AbstractTransactionStore = class extends AbstractStore {
|
|
|
2401
2410
|
};
|
|
2402
2411
|
|
|
2403
2412
|
// src/index.ts
|
|
2404
|
-
var
|
|
2413
|
+
var import_auth0_auth_js8 = require("@auth0/auth0-auth-js");
|
|
2405
2414
|
|
|
2406
2415
|
// src/store/cookie-transaction-store.ts
|
|
2407
2416
|
var CookieTransactionStore = class extends AbstractTransactionStore {
|
|
@@ -2680,16 +2689,16 @@ var StatelessAnonymousStore = class extends AbstractAnonymousStore {
|
|
|
2680
2689
|
};
|
|
2681
2690
|
|
|
2682
2691
|
// src/mfa/index.ts
|
|
2683
|
-
var
|
|
2692
|
+
var import_auth0_auth_js4 = require("@auth0/auth0-auth-js");
|
|
2684
2693
|
|
|
2685
2694
|
// src/passkey/index.ts
|
|
2686
|
-
var
|
|
2695
|
+
var import_auth0_auth_js5 = require("@auth0/auth0-auth-js");
|
|
2687
2696
|
|
|
2688
2697
|
// src/database/index.ts
|
|
2689
|
-
var
|
|
2698
|
+
var import_auth0_auth_js6 = require("@auth0/auth0-auth-js");
|
|
2690
2699
|
|
|
2691
2700
|
// src/anonymous/index.ts
|
|
2692
|
-
var
|
|
2701
|
+
var import_auth0_auth_js7 = require("@auth0/auth0-auth-js");
|
|
2693
2702
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2694
2703
|
0 && (module.exports = {
|
|
2695
2704
|
AbstractAnonymousStore,
|