@better-auth/sso 1.5.0 → 1.5.1-beta.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/client.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIError } from "better-auth/api";
|
|
2
2
|
import * as z$1 from "zod/v4";
|
|
3
3
|
import z from "zod/v4";
|
|
4
|
-
import { Awaitable, OAuth2Tokens, User } from "better-auth";
|
|
4
|
+
import { Awaitable, BetterAuthPlugin, OAuth2Tokens, User } from "better-auth";
|
|
5
5
|
import * as better_call0 from "better-call";
|
|
6
6
|
|
|
7
7
|
//#region src/saml/algorithms.d.ts
|
|
@@ -1721,5 +1721,56 @@ declare function selectTokenEndpointAuthMethod(doc: OIDCDiscoveryDocument, exist
|
|
|
1721
1721
|
*/
|
|
1722
1722
|
declare function needsRuntimeDiscovery(config: Partial<HydratedOIDCConfig> | undefined): boolean;
|
|
1723
1723
|
//#endregion
|
|
1724
|
-
|
|
1725
|
-
|
|
1724
|
+
//#region src/index.d.ts
|
|
1725
|
+
declare module "@better-auth/core" {
|
|
1726
|
+
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
1727
|
+
sso: {
|
|
1728
|
+
creator: typeof sso;
|
|
1729
|
+
};
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
type DomainVerificationEndpoints = {
|
|
1733
|
+
requestDomainVerification: ReturnType<typeof requestDomainVerification>;
|
|
1734
|
+
verifyDomain: ReturnType<typeof verifyDomain>;
|
|
1735
|
+
};
|
|
1736
|
+
type SSOEndpoints<O extends SSOOptions> = {
|
|
1737
|
+
spMetadata: ReturnType<typeof spMetadata>;
|
|
1738
|
+
registerSSOProvider: ReturnType<typeof registerSSOProvider<O>>;
|
|
1739
|
+
signInSSO: ReturnType<typeof signInSSO>;
|
|
1740
|
+
callbackSSO: ReturnType<typeof callbackSSO>;
|
|
1741
|
+
callbackSSOShared: ReturnType<typeof callbackSSOShared>;
|
|
1742
|
+
callbackSSOSAML: ReturnType<typeof callbackSSOSAML>;
|
|
1743
|
+
acsEndpoint: ReturnType<typeof acsEndpoint>;
|
|
1744
|
+
sloEndpoint: ReturnType<typeof sloEndpoint>;
|
|
1745
|
+
initiateSLO: ReturnType<typeof initiateSLO>;
|
|
1746
|
+
listSSOProviders: ReturnType<typeof listSSOProviders>;
|
|
1747
|
+
getSSOProvider: ReturnType<typeof getSSOProvider>;
|
|
1748
|
+
updateSSOProvider: ReturnType<typeof updateSSOProvider>;
|
|
1749
|
+
deleteSSOProvider: ReturnType<typeof deleteSSOProvider>;
|
|
1750
|
+
};
|
|
1751
|
+
type SSOPlugin<O extends SSOOptions> = {
|
|
1752
|
+
id: "sso";
|
|
1753
|
+
endpoints: SSOEndpoints<O> & (O extends {
|
|
1754
|
+
domainVerification: {
|
|
1755
|
+
enabled: true;
|
|
1756
|
+
};
|
|
1757
|
+
} ? DomainVerificationEndpoints : {});
|
|
1758
|
+
};
|
|
1759
|
+
declare function sso<O extends SSOOptions & {
|
|
1760
|
+
domainVerification?: {
|
|
1761
|
+
enabled: true;
|
|
1762
|
+
};
|
|
1763
|
+
}>(options?: O | undefined): {
|
|
1764
|
+
id: "sso";
|
|
1765
|
+
endpoints: SSOEndpoints<O> & DomainVerificationEndpoints;
|
|
1766
|
+
schema: NonNullable<BetterAuthPlugin["schema"]>;
|
|
1767
|
+
options: O;
|
|
1768
|
+
};
|
|
1769
|
+
declare function sso<O extends SSOOptions>(options?: O | undefined): {
|
|
1770
|
+
id: "sso";
|
|
1771
|
+
endpoints: SSOEndpoints<O>;
|
|
1772
|
+
options: O;
|
|
1773
|
+
};
|
|
1774
|
+
//#endregion
|
|
1775
|
+
export { DataEncryptionAlgorithm as A, TimestampValidationOptions as C, SSOOptions as D, SAMLConfig as E, DigestAlgorithm as M, KeyEncryptionAlgorithm as N, SSOProvider as O, SignatureAlgorithm as P, SAMLConditions as S, OIDCConfig as T, REQUIRED_DISCOVERY_FIELDS as _, fetchDiscoveryDocument as a, DEFAULT_MAX_SAML_METADATA_SIZE as b, normalizeUrl as c, validateDiscoveryUrl as d, DiscoverOIDCConfigParams as f, OIDCDiscoveryDocument as g, HydratedOIDCConfig as h, discoverOIDCConfig as i, DeprecatedAlgorithmBehavior as j, AlgorithmValidationOptions as k, selectTokenEndpointAuthMethod as l, DiscoveryErrorCode as m, sso as n, needsRuntimeDiscovery as o, DiscoveryError as p, computeDiscoveryUrl as r, normalizeDiscoveryUrls as s, SSOPlugin as t, validateDiscoveryDocument as u, RequiredDiscoveryField as v, validateSAMLTimestamp as w, DEFAULT_MAX_SAML_RESPONSE_SIZE as x, DEFAULT_CLOCK_SKEW_MS as y };
|
|
1776
|
+
//# sourceMappingURL=index-DHITQH_m.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,56 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//#region src/index.d.ts
|
|
5
|
-
declare module "@better-auth/core" {
|
|
6
|
-
interface BetterAuthPluginRegistry<AuthOptions, Options> {
|
|
7
|
-
sso: {
|
|
8
|
-
creator: typeof sso;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
type DomainVerificationEndpoints = {
|
|
13
|
-
requestDomainVerification: ReturnType<typeof requestDomainVerification>;
|
|
14
|
-
verifyDomain: ReturnType<typeof verifyDomain>;
|
|
15
|
-
};
|
|
16
|
-
type SSOEndpoints<O extends SSOOptions> = {
|
|
17
|
-
spMetadata: ReturnType<typeof spMetadata>;
|
|
18
|
-
registerSSOProvider: ReturnType<typeof registerSSOProvider<O>>;
|
|
19
|
-
signInSSO: ReturnType<typeof signInSSO>;
|
|
20
|
-
callbackSSO: ReturnType<typeof callbackSSO>;
|
|
21
|
-
callbackSSOShared: ReturnType<typeof callbackSSOShared>;
|
|
22
|
-
callbackSSOSAML: ReturnType<typeof callbackSSOSAML>;
|
|
23
|
-
acsEndpoint: ReturnType<typeof acsEndpoint>;
|
|
24
|
-
sloEndpoint: ReturnType<typeof sloEndpoint>;
|
|
25
|
-
initiateSLO: ReturnType<typeof initiateSLO>;
|
|
26
|
-
listSSOProviders: ReturnType<typeof listSSOProviders>;
|
|
27
|
-
getSSOProvider: ReturnType<typeof getSSOProvider>;
|
|
28
|
-
updateSSOProvider: ReturnType<typeof updateSSOProvider>;
|
|
29
|
-
deleteSSOProvider: ReturnType<typeof deleteSSOProvider>;
|
|
30
|
-
};
|
|
31
|
-
type SSOPlugin<O extends SSOOptions> = {
|
|
32
|
-
id: "sso";
|
|
33
|
-
endpoints: SSOEndpoints<O> & (O extends {
|
|
34
|
-
domainVerification: {
|
|
35
|
-
enabled: true;
|
|
36
|
-
};
|
|
37
|
-
} ? DomainVerificationEndpoints : {});
|
|
38
|
-
};
|
|
39
|
-
declare function sso<O extends SSOOptions & {
|
|
40
|
-
domainVerification?: {
|
|
41
|
-
enabled: true;
|
|
42
|
-
};
|
|
43
|
-
}>(options?: O | undefined): {
|
|
44
|
-
id: "sso";
|
|
45
|
-
endpoints: SSOEndpoints<O> & DomainVerificationEndpoints;
|
|
46
|
-
schema: NonNullable<BetterAuthPlugin["schema"]>;
|
|
47
|
-
options: O;
|
|
48
|
-
};
|
|
49
|
-
declare function sso<O extends SSOOptions>(options?: O | undefined): {
|
|
50
|
-
id: "sso";
|
|
51
|
-
endpoints: SSOEndpoints<O>;
|
|
52
|
-
options: O;
|
|
53
|
-
};
|
|
54
|
-
//#endregion
|
|
55
|
-
export { type AlgorithmValidationOptions, DEFAULT_CLOCK_SKEW_MS, DEFAULT_MAX_SAML_METADATA_SIZE, DEFAULT_MAX_SAML_RESPONSE_SIZE, DataEncryptionAlgorithm, type DeprecatedAlgorithmBehavior, DigestAlgorithm, type DiscoverOIDCConfigParams, DiscoveryError, type DiscoveryErrorCode, type HydratedOIDCConfig, KeyEncryptionAlgorithm, type OIDCConfig, type OIDCDiscoveryDocument, REQUIRED_DISCOVERY_FIELDS, type RequiredDiscoveryField, type SAMLConditions, type SAMLConfig, type SSOOptions, SSOPlugin, type SSOProvider, SignatureAlgorithm, type TimestampValidationOptions, computeDiscoveryUrl, discoverOIDCConfig, fetchDiscoveryDocument, needsRuntimeDiscovery, normalizeDiscoveryUrls, normalizeUrl, selectTokenEndpointAuthMethod, sso, validateDiscoveryDocument, validateDiscoveryUrl, validateSAMLTimestamp };
|
|
56
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import { A as DataEncryptionAlgorithm, C as TimestampValidationOptions, D as SSOOptions, E as SAMLConfig, M as DigestAlgorithm, N as KeyEncryptionAlgorithm, O as SSOProvider, P as SignatureAlgorithm, S as SAMLConditions, T as OIDCConfig, _ as REQUIRED_DISCOVERY_FIELDS, a as fetchDiscoveryDocument, b as DEFAULT_MAX_SAML_METADATA_SIZE, c as normalizeUrl, d as validateDiscoveryUrl, f as DiscoverOIDCConfigParams, g as OIDCDiscoveryDocument, h as HydratedOIDCConfig, i as discoverOIDCConfig, j as DeprecatedAlgorithmBehavior, k as AlgorithmValidationOptions, l as selectTokenEndpointAuthMethod, m as DiscoveryErrorCode, n as sso, o as needsRuntimeDiscovery, p as DiscoveryError, r as computeDiscoveryUrl, s as normalizeDiscoveryUrls, t as SSOPlugin, u as validateDiscoveryDocument, v as RequiredDiscoveryField, w as validateSAMLTimestamp, x as DEFAULT_MAX_SAML_RESPONSE_SIZE, y as DEFAULT_CLOCK_SKEW_MS } from "./index-DHITQH_m.mjs";
|
|
2
|
+
export { AlgorithmValidationOptions, DEFAULT_CLOCK_SKEW_MS, DEFAULT_MAX_SAML_METADATA_SIZE, DEFAULT_MAX_SAML_RESPONSE_SIZE, DataEncryptionAlgorithm, DeprecatedAlgorithmBehavior, DigestAlgorithm, DiscoverOIDCConfigParams, DiscoveryError, DiscoveryErrorCode, HydratedOIDCConfig, KeyEncryptionAlgorithm, OIDCConfig, OIDCDiscoveryDocument, REQUIRED_DISCOVERY_FIELDS, RequiredDiscoveryField, SAMLConditions, SAMLConfig, SSOOptions, SSOPlugin, SSOProvider, SignatureAlgorithm, TimestampValidationOptions, computeDiscoveryUrl, discoverOIDCConfig, fetchDiscoveryDocument, needsRuntimeDiscovery, normalizeDiscoveryUrls, normalizeUrl, selectTokenEndpointAuthMethod, sso, validateDiscoveryDocument, validateDiscoveryUrl, validateSAMLTimestamp };
|
package/dist/index.mjs
CHANGED
|
@@ -3161,7 +3161,7 @@ async function handleLogoutResponse(ctx, sp, idp, relayState, providerId) {
|
|
|
3161
3161
|
if (inResponseTo) {
|
|
3162
3162
|
const key = `${LOGOUT_REQUEST_KEY_PREFIX}${inResponseTo}`;
|
|
3163
3163
|
if (!await ctx.context.internalAdapter.findVerificationValue(key)) ctx.context.logger.warn("LogoutResponse references unknown or expired request", { inResponseTo });
|
|
3164
|
-
await ctx.context.internalAdapter.
|
|
3164
|
+
await ctx.context.internalAdapter.deleteVerificationByIdentifier(key).catch((e) => ctx.context.logger.warn("Failed to delete logout request verification value", e));
|
|
3165
3165
|
}
|
|
3166
3166
|
deleteSessionCookie(ctx);
|
|
3167
3167
|
const appOrigin = new URL(ctx.context.baseURL).origin;
|
|
@@ -3189,13 +3189,13 @@ async function handleLogoutRequest(ctx, sp, idp, relayState, providerId) {
|
|
|
3189
3189
|
const data = safeJsonParse(stored.value);
|
|
3190
3190
|
if (data) if (!sessionIndex || !data.sessionIndex || sessionIndex === data.sessionIndex) {
|
|
3191
3191
|
await ctx.context.internalAdapter.deleteSession(data.sessionId).catch((e) => ctx.context.logger.warn("Failed to delete session during SLO", { error: e }));
|
|
3192
|
-
await ctx.context.internalAdapter.
|
|
3192
|
+
await ctx.context.internalAdapter.deleteVerificationByIdentifier(`${SAML_SESSION_BY_ID_PREFIX}${data.sessionId}`).catch((e) => ctx.context.logger.warn("Failed to delete SAML session lookup during SLO", e));
|
|
3193
3193
|
} else ctx.context.logger.warn("SessionIndex mismatch in LogoutRequest - skipping session deletion", {
|
|
3194
3194
|
providerId,
|
|
3195
3195
|
requestedSessionIndex: sessionIndex,
|
|
3196
3196
|
storedSessionIndex: data.sessionIndex
|
|
3197
3197
|
});
|
|
3198
|
-
await ctx.context.internalAdapter.
|
|
3198
|
+
await ctx.context.internalAdapter.deleteVerificationByIdentifier(key).catch((e) => ctx.context.logger.warn("Failed to delete SAML session key during SLO", e));
|
|
3199
3199
|
}
|
|
3200
3200
|
const currentSession = await getSessionFromCtx(ctx);
|
|
3201
3201
|
if (currentSession?.session) await ctx.context.internalAdapter.deleteSession(currentSession.session.id);
|
|
@@ -3252,8 +3252,8 @@ const initiateSLO = (options) => {
|
|
|
3252
3252
|
value: providerId,
|
|
3253
3253
|
expiresAt: new Date(Date.now() + ttl)
|
|
3254
3254
|
});
|
|
3255
|
-
if (samlSessionKey) await ctx.context.internalAdapter.
|
|
3256
|
-
await ctx.context.internalAdapter.
|
|
3255
|
+
if (samlSessionKey) await ctx.context.internalAdapter.deleteVerificationByIdentifier(samlSessionKey).catch((e) => ctx.context.logger.warn("Failed to delete SAML session key during logout", e));
|
|
3256
|
+
await ctx.context.internalAdapter.deleteVerificationByIdentifier(sessionLookupKey).catch((e) => ctx.context.logger.warn("Failed to delete session lookup key during logout", e));
|
|
3257
3257
|
await ctx.context.internalAdapter.deleteSession(session.session.id);
|
|
3258
3258
|
deleteSessionCookie(ctx);
|
|
3259
3259
|
throw ctx.redirect(logoutRequest.context);
|
|
@@ -3323,8 +3323,8 @@ function sso(options) {
|
|
|
3323
3323
|
const sessionLookupKey = `${SAML_SESSION_BY_ID_PREFIX}${session.session.id}`;
|
|
3324
3324
|
const sessionLookup = await ctx.context.internalAdapter.findVerificationValue(sessionLookupKey);
|
|
3325
3325
|
if (sessionLookup?.value) {
|
|
3326
|
-
await ctx.context.internalAdapter.
|
|
3327
|
-
await ctx.context.internalAdapter.
|
|
3326
|
+
await ctx.context.internalAdapter.deleteVerificationByIdentifier(sessionLookup.value).catch(() => {});
|
|
3327
|
+
await ctx.context.internalAdapter.deleteVerificationByIdentifier(sessionLookupKey).catch(() => {});
|
|
3328
3328
|
}
|
|
3329
3329
|
})
|
|
3330
3330
|
}],
|