better-auth-studio 1.0.59-beta.12 → 1.0.59-beta.13
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/routes.d.ts.map +1 -1
- package/dist/routes.js +30 -17
- package/dist/routes.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/{main-D8TfeX_y.js → main-sbtbb6Py.js} +64 -16
- package/public/index.html +1 -1
package/dist/routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAeA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAS9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA+D9C,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAqLhG;AAeD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAeA,OAAO,EAA+B,MAAM,EAAE,MAAM,SAAS,CAAC;AAS9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA+D9C,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAqLhG;AAeD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAyxLR"}
|
package/dist/routes.js
CHANGED
|
@@ -5291,7 +5291,6 @@ export const authClient = createAuthClient({
|
|
|
5291
5291
|
});
|
|
5292
5292
|
}
|
|
5293
5293
|
});
|
|
5294
|
-
// Apply org invitation email template into examples auth.ts
|
|
5295
5294
|
router.post('/api/tools/apply-email-template', async (req, res) => {
|
|
5296
5295
|
try {
|
|
5297
5296
|
const { subject, html, templateId } = req.body || {};
|
|
@@ -5307,13 +5306,10 @@ export const authClient = createAuthClient({
|
|
|
5307
5306
|
let fileContent = readFileSync(authPath, 'utf-8');
|
|
5308
5307
|
const escapedSubject = subject.replace(/`/g, '\\`').replace(/\${/g, '\\${');
|
|
5309
5308
|
const escapedHtml = html.replace(/`/g, '\\`').replace(/\${/g, '\\${');
|
|
5310
|
-
// Ensure Resend import
|
|
5311
5309
|
if (!fileContent.includes("from 'resend'")) {
|
|
5312
5310
|
fileContent = `import { Resend } from 'resend';\n` + fileContent;
|
|
5313
5311
|
}
|
|
5314
|
-
// Ensure resend instance
|
|
5315
5312
|
if (!fileContent.includes('const resend = new Resend(')) {
|
|
5316
|
-
// place after imports
|
|
5317
5313
|
const importBlockEnd = fileContent.indexOf('\n', fileContent.lastIndexOf('import'));
|
|
5318
5314
|
if (importBlockEnd > -1) {
|
|
5319
5315
|
fileContent =
|
|
@@ -5358,31 +5354,50 @@ export const authClient = createAuthClient({
|
|
|
5358
5354
|
},
|
|
5359
5355
|
'org-invitation': {
|
|
5360
5356
|
regex: /sendInvitationEmail\s*:\s*async\s*\([^)]*\)\s*=>\s*\{[\s\S]*?\},?/,
|
|
5361
|
-
fn: `sendInvitationEmail: async ({ data, request }
|
|
5357
|
+
fn: `sendInvitationEmail: async ({ data, request }: {
|
|
5358
|
+
data: {
|
|
5359
|
+
invitation: {
|
|
5360
|
+
id: string;
|
|
5361
|
+
organizationId: string;
|
|
5362
|
+
email: string;
|
|
5363
|
+
role: string;
|
|
5364
|
+
status: "pending" | "accepted" | "rejected" | "canceled";
|
|
5365
|
+
inviterId: string;
|
|
5366
|
+
expiresAt: Date;
|
|
5367
|
+
createdAt: Date;
|
|
5368
|
+
teamId?: string | null | undefined;
|
|
5369
|
+
};
|
|
5370
|
+
organization: { name?: string; slug?: string };
|
|
5371
|
+
inviter: { user: { name?: string; email?: string } };
|
|
5372
|
+
};
|
|
5373
|
+
request?: Request;
|
|
5374
|
+
}) => {
|
|
5362
5375
|
const { invitation, organization, inviter } = data;
|
|
5363
|
-
const
|
|
5364
|
-
|
|
5365
|
-
(invitation as any)?.link ||
|
|
5366
|
-
request?.url ||
|
|
5367
|
-
invitation.id;
|
|
5376
|
+
const baseUrl = process.env.BETTER_AUTH_URL || 'http://localhost:3000';
|
|
5377
|
+
const url = \\\`\\\${baseUrl}/accept-invitation?id=\\\${invitation.id}\\\`;
|
|
5368
5378
|
|
|
5369
5379
|
const subject = \\\`${escapedSubject}\\\`
|
|
5370
5380
|
.replace(/{{organization.name}}/g, organization?.name || '')
|
|
5371
5381
|
.replace(/{{invitation.role}}/g, invitation.role || '')
|
|
5372
5382
|
.replace(/{{inviter.user.name}}/g, inviter?.user?.name || '')
|
|
5373
|
-
.replace(/{{inviter.user.email}}/g, inviter?.user?.email || '')
|
|
5383
|
+
.replace(/{{inviter.user.email}}/g, inviter?.user?.email || '')
|
|
5384
|
+
.replace(/{{invitation.email}}/g, invitation.email || '');
|
|
5374
5385
|
|
|
5375
5386
|
const html = \\\`${escapedHtml}\\\`
|
|
5376
5387
|
.replace(/{{invitation.url}}/g, url)
|
|
5377
5388
|
.replace(/{{invitation.role}}/g, invitation.role || '')
|
|
5378
5389
|
.replace(/{{organization.name}}/g, organization?.name || '')
|
|
5390
|
+
.replace(/{{organization.slug}}/g, organization?.slug || '')
|
|
5379
5391
|
.replace(/{{inviter.user.name}}/g, inviter?.user?.name || '')
|
|
5380
|
-
.replace(/{{inviter.user.email}}/g, inviter?.user?.email || '')
|
|
5392
|
+
.replace(/{{inviter.user.email}}/g, inviter?.user?.email || '')
|
|
5393
|
+
.replace(/{{invitation.email}}/g, invitation.email || '')
|
|
5394
|
+
.replace(/{{invitation.expiresAt}}/g, invitation.expiresAt?.toLocaleString() || '')
|
|
5395
|
+
.replace(/{{expiresIn}}/g, invitation.expiresAt ? \\\`\\\${Math.ceil((invitation.expiresAt.getTime() - Date.now()) / (1000 * 60 * 60 * 24))} days\\\` : '');
|
|
5381
5396
|
|
|
5382
|
-
|
|
5397
|
+
void sendEmail({
|
|
5383
5398
|
to: invitation.email,
|
|
5384
5399
|
subject,
|
|
5385
|
-
|
|
5400
|
+
html,
|
|
5386
5401
|
});
|
|
5387
5402
|
}`,
|
|
5388
5403
|
},
|
|
@@ -5393,19 +5408,17 @@ export const authClient = createAuthClient({
|
|
|
5393
5408
|
.status(400)
|
|
5394
5409
|
.json({ success: false, message: 'Unsupported templateId for apply' });
|
|
5395
5410
|
}
|
|
5396
|
-
// ensure sendEmail helper exists
|
|
5397
5411
|
if (!fileContent.includes('const sendEmail = async')) {
|
|
5398
5412
|
const insertPoint = fileContent.indexOf('export const auth');
|
|
5399
5413
|
fileContent =
|
|
5400
5414
|
fileContent.slice(0, insertPoint) +
|
|
5401
|
-
`const sendEmail = async ({ to, subject, text }: { to: string; subject: string; text
|
|
5415
|
+
`const sendEmail = async ({ to, subject, text, html }: { to: string; subject: string; text?: string; html?: string }) => {\n console.log(\`Sending email to \${to} | \${subject}\`);\n if (text) console.log('Text content:', text);\n if (html) console.log('HTML content:', html);\n};\n\n` +
|
|
5402
5416
|
fileContent.slice(insertPoint);
|
|
5403
5417
|
}
|
|
5404
5418
|
if (handler.regex.test(fileContent)) {
|
|
5405
5419
|
fileContent = fileContent.replace(handler.regex, `${handler.fn},`);
|
|
5406
5420
|
}
|
|
5407
5421
|
else {
|
|
5408
|
-
// try to inject into emailAndPassword or organization plugin based on template
|
|
5409
5422
|
if (templateId === 'org-invitation') {
|
|
5410
5423
|
const orgPluginRegex = /organization\(\s*\{\s*/;
|
|
5411
5424
|
if (!orgPluginRegex.test(fileContent)) {
|