@better-auth/sso 1.5.2 → 1.5.3
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.mjs +12 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -270,31 +270,16 @@ const requestDomainVerification = (options) => {
|
|
|
270
270
|
code: "DOMAIN_VERIFIED"
|
|
271
271
|
});
|
|
272
272
|
const identifier = getVerificationIdentifier(options, provider.providerId);
|
|
273
|
-
const activeVerification = await ctx.context.
|
|
274
|
-
|
|
275
|
-
where: [{
|
|
276
|
-
field: "identifier",
|
|
277
|
-
value: identifier
|
|
278
|
-
}, {
|
|
279
|
-
field: "expiresAt",
|
|
280
|
-
value: /* @__PURE__ */ new Date(),
|
|
281
|
-
operator: "gt"
|
|
282
|
-
}]
|
|
283
|
-
});
|
|
284
|
-
if (activeVerification) {
|
|
273
|
+
const activeVerification = await ctx.context.internalAdapter.findVerificationValue(identifier);
|
|
274
|
+
if (activeVerification && new Date(activeVerification.expiresAt) > /* @__PURE__ */ new Date()) {
|
|
285
275
|
ctx.setStatus(201);
|
|
286
276
|
return ctx.json({ domainVerificationToken: activeVerification.value });
|
|
287
277
|
}
|
|
288
278
|
const domainVerificationToken = generateRandomString(24);
|
|
289
|
-
await ctx.context.
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
294
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
295
|
-
value: domainVerificationToken,
|
|
296
|
-
expiresAt: new Date(Date.now() + 3600 * 24 * 7 * 1e3)
|
|
297
|
-
}
|
|
279
|
+
await ctx.context.internalAdapter.createVerificationValue({
|
|
280
|
+
identifier,
|
|
281
|
+
value: domainVerificationToken,
|
|
282
|
+
expiresAt: new Date(Date.now() + 3600 * 24 * 7 * 1e3)
|
|
298
283
|
});
|
|
299
284
|
ctx.setStatus(201);
|
|
300
285
|
return ctx.json({ domainVerificationToken });
|
|
@@ -353,18 +338,8 @@ const verifyDomain = (options) => {
|
|
|
353
338
|
message: `Verification identifier exceeds the DNS label limit of ${DNS_LABEL_MAX_LENGTH} characters`,
|
|
354
339
|
code: "IDENTIFIER_TOO_LONG"
|
|
355
340
|
});
|
|
356
|
-
const activeVerification = await ctx.context.
|
|
357
|
-
|
|
358
|
-
where: [{
|
|
359
|
-
field: "identifier",
|
|
360
|
-
value: identifier
|
|
361
|
-
}, {
|
|
362
|
-
field: "expiresAt",
|
|
363
|
-
value: /* @__PURE__ */ new Date(),
|
|
364
|
-
operator: "gt"
|
|
365
|
-
}]
|
|
366
|
-
});
|
|
367
|
-
if (!activeVerification) throw new APIError("NOT_FOUND", {
|
|
341
|
+
const activeVerification = await ctx.context.internalAdapter.findVerificationValue(identifier);
|
|
342
|
+
if (!activeVerification || new Date(activeVerification.expiresAt) <= /* @__PURE__ */ new Date()) throw new APIError("NOT_FOUND", {
|
|
368
343
|
message: "No pending domain verification exists",
|
|
369
344
|
code: "NO_PENDING_VERIFICATION"
|
|
370
345
|
});
|
|
@@ -2030,15 +2005,10 @@ const registerSSOProvider = (options) => {
|
|
|
2030
2005
|
if (options?.domainVerification?.enabled) {
|
|
2031
2006
|
domainVerified = false;
|
|
2032
2007
|
domainVerificationToken = generateRandomString(24);
|
|
2033
|
-
await ctx.context.
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
2038
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
2039
|
-
value: domainVerificationToken,
|
|
2040
|
-
expiresAt: new Date(Date.now() + 3600 * 24 * 7 * 1e3)
|
|
2041
|
-
}
|
|
2008
|
+
await ctx.context.internalAdapter.createVerificationValue({
|
|
2009
|
+
identifier: getVerificationIdentifier(options, provider.providerId),
|
|
2010
|
+
value: domainVerificationToken,
|
|
2011
|
+
expiresAt: new Date(Date.now() + 3600 * 24 * 7 * 1e3)
|
|
2042
2012
|
});
|
|
2043
2013
|
}
|
|
2044
2014
|
const result = {
|