@better-auth/sso 1.6.25 → 1.6.27
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
package/dist/client.mjs
CHANGED
|
@@ -457,7 +457,7 @@ declare const requestDomainVerification: (options: SSOOptions) => import("better
|
|
|
457
457
|
};
|
|
458
458
|
};
|
|
459
459
|
};
|
|
460
|
-
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
460
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
461
461
|
session: {
|
|
462
462
|
session: Record<string, any> & {
|
|
463
463
|
id: string;
|
|
@@ -479,7 +479,7 @@ declare const requestDomainVerification: (options: SSOOptions) => import("better
|
|
|
479
479
|
image?: string | null | undefined;
|
|
480
480
|
};
|
|
481
481
|
};
|
|
482
|
-
}
|
|
482
|
+
}>>[];
|
|
483
483
|
}, {
|
|
484
484
|
domainVerificationToken: string;
|
|
485
485
|
}>;
|
|
@@ -508,7 +508,7 @@ declare const verifyDomain: (options: SSOOptions) => import("better-call").Stric
|
|
|
508
508
|
};
|
|
509
509
|
};
|
|
510
510
|
};
|
|
511
|
-
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
511
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
512
512
|
session: {
|
|
513
513
|
session: Record<string, any> & {
|
|
514
514
|
id: string;
|
|
@@ -530,13 +530,13 @@ declare const verifyDomain: (options: SSOOptions) => import("better-call").Stric
|
|
|
530
530
|
image?: string | null | undefined;
|
|
531
531
|
};
|
|
532
532
|
};
|
|
533
|
-
}
|
|
533
|
+
}>>[];
|
|
534
534
|
}, void>;
|
|
535
535
|
//#endregion
|
|
536
536
|
//#region src/routes/providers.d.ts
|
|
537
537
|
declare const listSSOProviders: () => import("better-call").StrictEndpoint<"/sso/providers", {
|
|
538
538
|
method: "GET";
|
|
539
|
-
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
539
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
540
540
|
session: {
|
|
541
541
|
session: Record<string, any> & {
|
|
542
542
|
id: string;
|
|
@@ -558,7 +558,7 @@ declare const listSSOProviders: () => import("better-call").StrictEndpoint<"/sso
|
|
|
558
558
|
image?: string | null | undefined;
|
|
559
559
|
};
|
|
560
560
|
};
|
|
561
|
-
}
|
|
561
|
+
}>>[];
|
|
562
562
|
metadata: {
|
|
563
563
|
openapi: {
|
|
564
564
|
operationId: string;
|
|
@@ -614,7 +614,7 @@ declare const listSSOProviders: () => import("better-call").StrictEndpoint<"/sso
|
|
|
614
614
|
}>;
|
|
615
615
|
declare const getSSOProvider: () => import("better-call").StrictEndpoint<"/sso/get-provider", {
|
|
616
616
|
method: "GET";
|
|
617
|
-
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
617
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
618
618
|
session: {
|
|
619
619
|
session: Record<string, any> & {
|
|
620
620
|
id: string;
|
|
@@ -636,7 +636,7 @@ declare const getSSOProvider: () => import("better-call").StrictEndpoint<"/sso/g
|
|
|
636
636
|
image?: string | null | undefined;
|
|
637
637
|
};
|
|
638
638
|
};
|
|
639
|
-
}
|
|
639
|
+
}>>[];
|
|
640
640
|
query: z.ZodObject<{
|
|
641
641
|
providerId: z.ZodString;
|
|
642
642
|
}, z.core.$strip>;
|
|
@@ -699,7 +699,7 @@ declare const getSSOProvider: () => import("better-call").StrictEndpoint<"/sso/g
|
|
|
699
699
|
}>;
|
|
700
700
|
declare const updateSSOProvider: (options: SSOOptions) => import("better-call").StrictEndpoint<"/sso/update-provider", {
|
|
701
701
|
method: "POST";
|
|
702
|
-
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
702
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
703
703
|
session: {
|
|
704
704
|
session: Record<string, any> & {
|
|
705
705
|
id: string;
|
|
@@ -721,7 +721,7 @@ declare const updateSSOProvider: (options: SSOOptions) => import("better-call").
|
|
|
721
721
|
image?: string | null | undefined;
|
|
722
722
|
};
|
|
723
723
|
};
|
|
724
|
-
}
|
|
724
|
+
}>>[];
|
|
725
725
|
body: z.ZodObject<{
|
|
726
726
|
issuer: z.ZodOptional<z.ZodString>;
|
|
727
727
|
domain: z.ZodOptional<z.ZodString>;
|
|
@@ -858,7 +858,7 @@ declare const updateSSOProvider: (options: SSOOptions) => import("better-call").
|
|
|
858
858
|
}>;
|
|
859
859
|
declare const deleteSSOProvider: () => import("better-call").StrictEndpoint<"/sso/delete-provider", {
|
|
860
860
|
method: "POST";
|
|
861
|
-
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
861
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
862
862
|
session: {
|
|
863
863
|
session: Record<string, any> & {
|
|
864
864
|
id: string;
|
|
@@ -880,7 +880,7 @@ declare const deleteSSOProvider: () => import("better-call").StrictEndpoint<"/ss
|
|
|
880
880
|
image?: string | null | undefined;
|
|
881
881
|
};
|
|
882
882
|
};
|
|
883
|
-
}
|
|
883
|
+
}>>[];
|
|
884
884
|
body: z.ZodObject<{
|
|
885
885
|
providerId: z.ZodString;
|
|
886
886
|
}, z.core.$strip>;
|
|
@@ -1030,7 +1030,7 @@ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => import(
|
|
|
1030
1030
|
organizationId: z.ZodOptional<z.ZodString>;
|
|
1031
1031
|
overrideUserInfo: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
1032
1032
|
}, z.core.$strip>;
|
|
1033
|
-
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1033
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1034
1034
|
session: {
|
|
1035
1035
|
session: Record<string, any> & {
|
|
1036
1036
|
id: string;
|
|
@@ -1052,7 +1052,7 @@ declare const registerSSOProvider: <O extends SSOOptions>(options: O) => import(
|
|
|
1052
1052
|
image?: string | null | undefined;
|
|
1053
1053
|
};
|
|
1054
1054
|
};
|
|
1055
|
-
}
|
|
1055
|
+
}>>[];
|
|
1056
1056
|
metadata: {
|
|
1057
1057
|
openapi: {
|
|
1058
1058
|
operationId: string;
|
|
@@ -1450,7 +1450,7 @@ declare const initiateSLO: (options?: SSOOptions) => import("better-call").Stric
|
|
|
1450
1450
|
body: z.ZodObject<{
|
|
1451
1451
|
callbackURL: z.ZodOptional<z.ZodString>;
|
|
1452
1452
|
}, z.core.$strip>;
|
|
1453
|
-
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1453
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
1454
1454
|
session: {
|
|
1455
1455
|
session: Record<string, any> & {
|
|
1456
1456
|
id: string;
|
|
@@ -1472,7 +1472,7 @@ declare const initiateSLO: (options?: SSOOptions) => import("better-call").Stric
|
|
|
1472
1472
|
image?: string | null | undefined;
|
|
1473
1473
|
};
|
|
1474
1474
|
};
|
|
1475
|
-
}
|
|
1475
|
+
}>>[];
|
|
1476
1476
|
metadata: {
|
|
1477
1477
|
readonly scope: "server";
|
|
1478
1478
|
};
|
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-LIqblgm9.mjs";
|
|
2
2
|
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { t as PACKAGE_VERSION } from "./version-B4oCeoTU.mjs";
|
|
2
2
|
import { APIError, createAuthEndpoint, createAuthMiddleware, getSessionFromCtx, sessionMiddleware } from "better-auth/api";
|
|
3
3
|
import { XMLParser, XMLValidator } from "fast-xml-parser";
|
|
4
4
|
import { X509Certificate } from "node:crypto";
|
|
@@ -147,98 +147,127 @@ function maskClientId(clientId) {
|
|
|
147
147
|
}
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/linking/org-assignment.ts
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
if (!
|
|
157
|
-
|
|
158
|
-
|
|
150
|
+
function getEmailDomain(email) {
|
|
151
|
+
const parts = email.trim().toLowerCase().split("@");
|
|
152
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) return null;
|
|
153
|
+
const domain = parts[1];
|
|
154
|
+
if (domain.includes("/") || domain.includes("\\") || domain.includes(":")) return null;
|
|
155
|
+
const normalizedDomains = parseProviderDomains(domain);
|
|
156
|
+
if (!normalizedDomains || normalizedDomains.length !== 1) return null;
|
|
157
|
+
return normalizedDomains[0] ?? null;
|
|
158
|
+
}
|
|
159
|
+
async function findVerifiedDomainProviders(ctx, domain) {
|
|
160
|
+
return (await ctx.context.adapter.findMany({
|
|
161
|
+
model: "ssoProvider",
|
|
162
|
+
where: [{
|
|
163
|
+
field: "domainVerified",
|
|
164
|
+
value: true
|
|
165
|
+
}]
|
|
166
|
+
})).filter((provider) => domainMatches(domain, provider.domain));
|
|
167
|
+
}
|
|
168
|
+
async function assignOrganization(ctx, options) {
|
|
169
|
+
if (options.provisioningOptions?.disabled) return "provisioning-disabled";
|
|
170
|
+
if (!ctx.context.hasPlugin("organization")) return "ineligible-source";
|
|
171
|
+
let user;
|
|
172
|
+
let provider;
|
|
173
|
+
let organizationId;
|
|
174
|
+
let userInfo;
|
|
175
|
+
let token;
|
|
176
|
+
if (options.reason === "provider-bound") {
|
|
177
|
+
if (!options.provider.organizationId) return "no-target";
|
|
178
|
+
user = options.user;
|
|
179
|
+
provider = options.provider;
|
|
180
|
+
organizationId = options.provider.organizationId;
|
|
181
|
+
userInfo = options.profile.rawAttributes || {};
|
|
182
|
+
token = options.token;
|
|
183
|
+
} else {
|
|
184
|
+
if (!options.domainVerification?.enabled) return "provisioning-disabled";
|
|
185
|
+
const canonicalUser = await ctx.context.internalAdapter.findUserById(options.user.id);
|
|
186
|
+
if (!canonicalUser) {
|
|
187
|
+
ctx.context.logger.error("Unable to assign SSO organization membership because the canonical user was not found", { userId: options.user.id });
|
|
188
|
+
return "ineligible-source";
|
|
189
|
+
}
|
|
190
|
+
if (!canonicalUser.emailVerified) return "unverified-identity";
|
|
191
|
+
const domain = getEmailDomain(canonicalUser.email);
|
|
192
|
+
if (!domain) return "unverified-identity";
|
|
193
|
+
const matchingProviders = (await findVerifiedDomainProviders(ctx, domain)).filter((matchingProvider) => Boolean(matchingProvider.organizationId));
|
|
194
|
+
if (new Set(matchingProviders.map((matchingProvider) => matchingProvider.organizationId)).size > 1) {
|
|
195
|
+
ctx.context.logger.warn("Skipped SSO organization provisioning because a verified domain maps to multiple organizations", {
|
|
196
|
+
domain,
|
|
197
|
+
userId: canonicalUser.id
|
|
198
|
+
});
|
|
199
|
+
return "ambiguous-target";
|
|
200
|
+
}
|
|
201
|
+
if (matchingProviders.length === 0) return "no-target";
|
|
202
|
+
matchingProviders.sort((left, right) => left.providerId.localeCompare(right.providerId));
|
|
203
|
+
const selectedProvider = matchingProviders[0];
|
|
204
|
+
if (!selectedProvider) return "no-target";
|
|
205
|
+
user = canonicalUser;
|
|
206
|
+
provider = selectedProvider;
|
|
207
|
+
organizationId = selectedProvider.organizationId;
|
|
208
|
+
userInfo = {};
|
|
209
|
+
token = void 0;
|
|
210
|
+
}
|
|
159
211
|
if (await ctx.context.adapter.findOne({
|
|
160
212
|
model: "member",
|
|
161
213
|
where: [{
|
|
162
214
|
field: "organizationId",
|
|
163
|
-
value:
|
|
215
|
+
value: organizationId
|
|
164
216
|
}, {
|
|
165
217
|
field: "userId",
|
|
166
218
|
value: user.id
|
|
167
219
|
}]
|
|
168
|
-
})) return;
|
|
169
|
-
|
|
220
|
+
})) return "already-member";
|
|
221
|
+
if (await ctx.context.adapter.findOne({
|
|
222
|
+
model: "invitation",
|
|
223
|
+
where: [
|
|
224
|
+
{
|
|
225
|
+
field: "organizationId",
|
|
226
|
+
value: organizationId
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
field: "email",
|
|
230
|
+
value: user.email.toLowerCase()
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
field: "status",
|
|
234
|
+
value: "pending"
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
})) return "invitation-pending";
|
|
238
|
+
const role = options.provisioningOptions?.getRole ? await options.provisioningOptions.getRole({
|
|
170
239
|
user,
|
|
171
|
-
userInfo
|
|
240
|
+
userInfo,
|
|
172
241
|
token,
|
|
173
242
|
provider
|
|
174
|
-
}) : provisioningOptions?.defaultRole || "member";
|
|
243
|
+
}) : options.provisioningOptions?.defaultRole || "member";
|
|
175
244
|
await ctx.context.adapter.create({
|
|
176
245
|
model: "member",
|
|
177
246
|
data: {
|
|
178
|
-
organizationId
|
|
247
|
+
organizationId,
|
|
179
248
|
userId: user.id,
|
|
180
249
|
role,
|
|
181
250
|
createdAt: /* @__PURE__ */ new Date()
|
|
182
251
|
}
|
|
183
252
|
});
|
|
253
|
+
return "assigned";
|
|
184
254
|
}
|
|
185
255
|
/**
|
|
186
|
-
* Assigns a user to
|
|
187
|
-
* Looks up SSO providers that match the user's email domain and assigns
|
|
188
|
-
* the user to the associated organization.
|
|
189
|
-
*
|
|
190
|
-
* This enables domain-based org assignment for non-SSO sign-in methods
|
|
191
|
-
* (e.g., Google OAuth with @acme.com email gets added to Acme's org).
|
|
256
|
+
* Assigns a user to the organization explicitly bound to an SSO provider.
|
|
192
257
|
*/
|
|
193
|
-
async function
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const domain = user.email.split("@")[1];
|
|
198
|
-
if (!domain) return;
|
|
199
|
-
const whereClause = [{
|
|
200
|
-
field: "domain",
|
|
201
|
-
value: domain
|
|
202
|
-
}];
|
|
203
|
-
if (domainVerification?.enabled) whereClause.push({
|
|
204
|
-
field: "domainVerified",
|
|
205
|
-
value: true
|
|
206
|
-
});
|
|
207
|
-
let ssoProvider = await ctx.context.adapter.findOne({
|
|
208
|
-
model: "ssoProvider",
|
|
209
|
-
where: whereClause
|
|
258
|
+
async function assignOrganizationFromProvider(ctx, options) {
|
|
259
|
+
await assignOrganization(ctx, {
|
|
260
|
+
reason: "provider-bound",
|
|
261
|
+
...options
|
|
210
262
|
});
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (await ctx.context.adapter.findOne({
|
|
220
|
-
model: "member",
|
|
221
|
-
where: [{
|
|
222
|
-
field: "organizationId",
|
|
223
|
-
value: ssoProvider.organizationId
|
|
224
|
-
}, {
|
|
225
|
-
field: "userId",
|
|
226
|
-
value: user.id
|
|
227
|
-
}]
|
|
228
|
-
})) return;
|
|
229
|
-
const role = provisioningOptions?.getRole ? await provisioningOptions.getRole({
|
|
230
|
-
user,
|
|
231
|
-
userInfo: {},
|
|
232
|
-
provider: ssoProvider
|
|
233
|
-
}) : provisioningOptions?.defaultRole || "member";
|
|
234
|
-
await ctx.context.adapter.create({
|
|
235
|
-
model: "member",
|
|
236
|
-
data: {
|
|
237
|
-
organizationId: ssoProvider.organizationId,
|
|
238
|
-
userId: user.id,
|
|
239
|
-
role,
|
|
240
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
241
|
-
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Assigns a verified user to the organization for their verified email domain.
|
|
266
|
+
*/
|
|
267
|
+
async function assignOrganizationByDomain(ctx, options) {
|
|
268
|
+
await assignOrganization(ctx, {
|
|
269
|
+
reason: "verified-domain",
|
|
270
|
+
...options
|
|
242
271
|
});
|
|
243
272
|
}
|
|
244
273
|
//#endregion
|
|
@@ -1555,6 +1584,23 @@ const deleteSSOProvider = () => {
|
|
|
1555
1584
|
const DNS_LABEL_MAX_LENGTH = 63;
|
|
1556
1585
|
const DEFAULT_TOKEN_PREFIX = "better-auth-token";
|
|
1557
1586
|
const domainVerificationBodySchema = z.object({ providerId: z.string() });
|
|
1587
|
+
async function completeDomainVerification(adapter, provider) {
|
|
1588
|
+
if (!await adapter.incrementOne({
|
|
1589
|
+
model: "ssoProvider",
|
|
1590
|
+
where: [{
|
|
1591
|
+
field: "id",
|
|
1592
|
+
value: provider.id
|
|
1593
|
+
}, {
|
|
1594
|
+
field: "domain",
|
|
1595
|
+
value: provider.domain
|
|
1596
|
+
}],
|
|
1597
|
+
increment: {},
|
|
1598
|
+
set: { domainVerified: true }
|
|
1599
|
+
})) throw new APIError("CONFLICT", {
|
|
1600
|
+
code: "SSO_PROVIDER_CHANGED",
|
|
1601
|
+
message: "SSO provider changed while domain verification was in progress. Reload the provider and try again"
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1558
1604
|
function getVerificationIdentifier(options, providerId) {
|
|
1559
1605
|
return `_${options.domainVerification?.tokenPrefix || DEFAULT_TOKEN_PREFIX}-${providerId}`;
|
|
1560
1606
|
}
|
|
@@ -1604,7 +1650,7 @@ const verifyDomain = (options) => {
|
|
|
1604
1650
|
description: "Verify the provider domain ownership via DNS records",
|
|
1605
1651
|
responses: {
|
|
1606
1652
|
"404": { description: "Provider not found" },
|
|
1607
|
-
"409": { description: "Domain has already been verified or
|
|
1653
|
+
"409": { description: "Domain has already been verified, or the provider changed while verification was in progress" },
|
|
1608
1654
|
"502": { description: "Unable to verify domain ownership due to upstream validator error" },
|
|
1609
1655
|
"204": { description: "Domain ownership was verified" }
|
|
1610
1656
|
}
|
|
@@ -1659,14 +1705,7 @@ const verifyDomain = (options) => {
|
|
|
1659
1705
|
code: "DOMAIN_VERIFICATION_FAILED"
|
|
1660
1706
|
});
|
|
1661
1707
|
}
|
|
1662
|
-
await ctx.context.adapter
|
|
1663
|
-
model: "ssoProvider",
|
|
1664
|
-
where: [{
|
|
1665
|
-
field: "providerId",
|
|
1666
|
-
value: provider.providerId
|
|
1667
|
-
}],
|
|
1668
|
-
update: { domainVerified: true }
|
|
1669
|
-
});
|
|
1708
|
+
await completeDomainVerification(ctx.context.adapter, provider);
|
|
1670
1709
|
ctx.setStatus(204);
|
|
1671
1710
|
});
|
|
1672
1711
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/sso",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.27",
|
|
4
4
|
"description": "SSO plugin for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -65,20 +65,20 @@
|
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/body-parser": "^1.19.6",
|
|
67
67
|
"@types/express": "^5.0.6",
|
|
68
|
-
"better-call": "1.
|
|
69
|
-
"body-parser": "^2.
|
|
68
|
+
"better-call": "1.4.0",
|
|
69
|
+
"body-parser": "^2.3.0",
|
|
70
70
|
"express": "^5.2.1",
|
|
71
71
|
"oauth2-mock-server": "^8.2.2",
|
|
72
72
|
"tsdown": "0.22.7",
|
|
73
|
-
"@better-auth/core": "1.6.
|
|
74
|
-
"better-auth": "1.6.
|
|
73
|
+
"@better-auth/core": "1.6.27",
|
|
74
|
+
"better-auth": "1.6.27"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@better-auth/utils": "0.4.2",
|
|
78
78
|
"@better-fetch/fetch": "1.3.1",
|
|
79
|
-
"better-call": "1.
|
|
80
|
-
"better-auth": "^1.6.
|
|
81
|
-
"
|
|
79
|
+
"better-call": "1.4.0",
|
|
80
|
+
"@better-auth/core": "^1.6.27",
|
|
81
|
+
"better-auth": "^1.6.27"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"build": "tsdown",
|