@better-auth/sso 1.5.4 → 1.5.6
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,6 +1,5 @@
|
|
|
1
1
|
import { APIError } from "better-auth/api";
|
|
2
|
-
import * as z
|
|
3
|
-
import z from "zod/v4";
|
|
2
|
+
import * as z from "zod";
|
|
4
3
|
import { Awaitable, BetterAuthPlugin, OAuth2Tokens, User } from "better-auth";
|
|
5
4
|
import * as better_call0 from "better-call";
|
|
6
5
|
|
|
@@ -418,9 +417,9 @@ interface SSOOptions {
|
|
|
418
417
|
//#region src/routes/domain-verification.d.ts
|
|
419
418
|
declare const requestDomainVerification: (options: SSOOptions) => better_call0.StrictEndpoint<"/sso/request-domain-verification", {
|
|
420
419
|
method: "POST";
|
|
421
|
-
body: z
|
|
422
|
-
providerId: z
|
|
423
|
-
}, z
|
|
420
|
+
body: z.ZodObject<{
|
|
421
|
+
providerId: z.ZodString;
|
|
422
|
+
}, z.core.$strip>;
|
|
424
423
|
metadata: {
|
|
425
424
|
openapi: {
|
|
426
425
|
summary: string;
|
|
@@ -466,9 +465,9 @@ declare const requestDomainVerification: (options: SSOOptions) => better_call0.S
|
|
|
466
465
|
}>;
|
|
467
466
|
declare const verifyDomain: (options: SSOOptions) => better_call0.StrictEndpoint<"/sso/verify-domain", {
|
|
468
467
|
method: "POST";
|
|
469
|
-
body: z
|
|
470
|
-
providerId: z
|
|
471
|
-
}, z
|
|
468
|
+
body: z.ZodObject<{
|
|
469
|
+
providerId: z.ZodString;
|
|
470
|
+
}, z.core.$strip>;
|
|
472
471
|
metadata: {
|
|
473
472
|
openapi: {
|
|
474
473
|
summary: string;
|
|
@@ -1773,4 +1772,4 @@ declare function sso<O extends SSOOptions>(options?: O | undefined): {
|
|
|
1773
1772
|
};
|
|
1774
1773
|
//#endregion
|
|
1775
1774
|
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-
|
|
1775
|
+
//# sourceMappingURL=index-DoxMd-mL.d.mts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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-
|
|
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-DoxMd-mL.mjs";
|
|
2
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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { APIError, createAuthEndpoint, createAuthMiddleware, getSessionFromCtx, sessionMiddleware } from "better-auth/api";
|
|
2
2
|
import { XMLParser, XMLValidator } from "fast-xml-parser";
|
|
3
|
-
import saml from "samlify";
|
|
3
|
+
import * as saml from "samlify";
|
|
4
4
|
import { X509Certificate } from "node:crypto";
|
|
5
|
+
import { getHostname } from "tldts";
|
|
5
6
|
import { generateRandomString } from "better-auth/crypto";
|
|
6
|
-
import * as z
|
|
7
|
-
import z from "zod/v4";
|
|
7
|
+
import * as z from "zod";
|
|
8
8
|
import { base64 } from "@better-auth/utils/base64";
|
|
9
9
|
import { BetterFetchError, betterFetch } from "@better-fetch/fetch";
|
|
10
10
|
import { HIDE_METADATA, createAuthorizationURL, generateGenericState, generateState, parseGenericState, parseState, validateAuthorizationCode, validateToken } from "better-auth";
|
|
@@ -112,6 +112,9 @@ function parseCertificate(certPem) {
|
|
|
112
112
|
publicKeyAlgorithm: cert.publicKey.asymmetricKeyType?.toUpperCase() || "UNKNOWN"
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
+
function getHostnameFromDomain(domain) {
|
|
116
|
+
return getHostname(domain) || null;
|
|
117
|
+
}
|
|
115
118
|
function maskClientId(clientId) {
|
|
116
119
|
if (clientId.length <= 4) return "****";
|
|
117
120
|
return `****${clientId.slice(-4)}`;
|
|
@@ -218,7 +221,7 @@ async function assignOrganizationByDomain(ctx, options) {
|
|
|
218
221
|
//#region src/routes/domain-verification.ts
|
|
219
222
|
const DNS_LABEL_MAX_LENGTH = 63;
|
|
220
223
|
const DEFAULT_TOKEN_PREFIX = "better-auth-token";
|
|
221
|
-
const domainVerificationBodySchema = z
|
|
224
|
+
const domainVerificationBodySchema = z.object({ providerId: z.string() });
|
|
222
225
|
function getVerificationIdentifier(options, providerId) {
|
|
223
226
|
return `_${options.domainVerification?.tokenPrefix || DEFAULT_TOKEN_PREFIX}-${providerId}`;
|
|
224
227
|
}
|
|
@@ -354,8 +357,12 @@ const verifyDomain = (options) => {
|
|
|
354
357
|
code: "DOMAIN_VERIFICATION_FAILED"
|
|
355
358
|
});
|
|
356
359
|
}
|
|
360
|
+
const hostname = getHostnameFromDomain(provider.domain);
|
|
361
|
+
if (!hostname) throw new APIError("BAD_REQUEST", {
|
|
362
|
+
message: "Invalid domain",
|
|
363
|
+
code: "INVALID_DOMAIN"
|
|
364
|
+
});
|
|
357
365
|
try {
|
|
358
|
-
const hostname = new URL(provider.domain).hostname;
|
|
359
366
|
records = (await dns.resolveTxt(`${identifier}.${hostname}`)).flat();
|
|
360
367
|
} catch (error) {
|
|
361
368
|
ctx.context.logger.warn("DNS resolution failure while validating domain ownership", error);
|