@contentgrowth/content-auth 0.4.9 → 0.5.0
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/README.md +68 -2
- package/dist/{chunk-CTASTCWI.js → chunk-3HNFZJ7S.js} +6 -6
- package/dist/chunk-CBNSTIX6.js +17 -0
- package/dist/chunk-F2G7XJIZ.js +17 -0
- package/dist/frontend/astro.d.ts +6 -0
- package/dist/frontend/astro.js +9 -0
- package/dist/frontend/client.d.ts +54 -18
- package/dist/frontend/clients/astro-client.d.ts +3134 -0
- package/dist/frontend/clients/astro-client.js +9 -0
- package/dist/frontend/clients/vue-client.d.ts +3520 -0
- package/dist/frontend/clients/vue-client.js +9 -0
- package/dist/frontend/components/astro/astro/AuthForm.astro +389 -0
- package/dist/frontend/components/astro/astro/ForgotPasswordForm.astro +127 -0
- package/dist/frontend/components/astro/astro/Organization.astro +254 -0
- package/dist/frontend/components/astro/astro/PasswordChanger.astro +128 -0
- package/dist/frontend/components/astro/astro/ProfileEditor.astro +133 -0
- package/dist/frontend/components/astro/astro/ResetPasswordForm.astro +172 -0
- package/dist/frontend/components/vue/vue/AuthForm.vue +337 -0
- package/dist/frontend/components/vue/vue/ForgotPasswordForm.vue +108 -0
- package/dist/frontend/components/vue/vue/Organization.vue +215 -0
- package/dist/frontend/components/vue/vue/PasswordChanger.vue +115 -0
- package/dist/frontend/components/vue/vue/ProfileEditor.vue +112 -0
- package/dist/frontend/components/vue/vue/ResetPasswordForm.vue +150 -0
- package/dist/frontend/index.js +1 -1
- package/dist/frontend/vue.d.ts +12 -0
- package/dist/frontend/vue.js +23 -0
- package/dist/index.js +1 -1
- package/package.json +32 -6
package/README.md
CHANGED
|
@@ -153,8 +153,6 @@ export default function App() {
|
|
|
153
153
|
You can also use the `authClient` directly for custom implementations:
|
|
154
154
|
|
|
155
155
|
```typescript
|
|
156
|
-
import { authClient } from '@contentgrowth/content-auth/client';
|
|
157
|
-
|
|
158
156
|
// Example: Sign in with email
|
|
159
157
|
await authClient.signIn.email({
|
|
160
158
|
email: "user@example.com",
|
|
@@ -162,6 +160,74 @@ await authClient.signIn.email({
|
|
|
162
160
|
});
|
|
163
161
|
```
|
|
164
162
|
|
|
163
|
+
### 3. Frontend Setup (Astro)
|
|
164
|
+
|
|
165
|
+
Import components directly in your Astro pages. They use standard HTML/JS and don't require any framework integrations.
|
|
166
|
+
|
|
167
|
+
```astro
|
|
168
|
+
---
|
|
169
|
+
import { AuthForm } from '@contentgrowth/content-auth/astro/components/AuthForm.astro';
|
|
170
|
+
import '@contentgrowth/content-auth/styles.css';
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
<div class="min-h-screen flex items-center justify-center bg-gray-50">
|
|
174
|
+
<div class="max-w-md w-full">
|
|
175
|
+
<h1 class="text-2xl font-bold text-center mb-6">Welcome Back</h1>
|
|
176
|
+
|
|
177
|
+
<AuthForm
|
|
178
|
+
view="signin"
|
|
179
|
+
baseUrl="http://localhost:8787" <!-- Your backend URL -->
|
|
180
|
+
redirectUrl="/dashboard"
|
|
181
|
+
/>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Client Usage (Vanilla JS):**
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import { authClient } from '@contentgrowth/content-auth/astro/client';
|
|
190
|
+
|
|
191
|
+
await authClient.signIn.email({ ... });
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### 4. Frontend Setup (Vue)
|
|
195
|
+
|
|
196
|
+
Import components in your Vue 3 application.
|
|
197
|
+
|
|
198
|
+
```vue
|
|
199
|
+
<script setup>
|
|
200
|
+
import { AuthForm } from '@contentgrowth/content-auth/vue';
|
|
201
|
+
import '@contentgrowth/content-auth/styles.css';
|
|
202
|
+
|
|
203
|
+
const handleSuccess = (data) => {
|
|
204
|
+
console.log('User authenticated!', data);
|
|
205
|
+
window.location.href = '/dashboard';
|
|
206
|
+
};
|
|
207
|
+
</script>
|
|
208
|
+
|
|
209
|
+
<template>
|
|
210
|
+
<div class="min-h-screen flex items-center justify-center bg-gray-50">
|
|
211
|
+
<div class="max-w-md w-full">
|
|
212
|
+
<h1 class="text-2xl font-bold text-center mb-6">Welcome Back</h1>
|
|
213
|
+
|
|
214
|
+
<AuthForm
|
|
215
|
+
view="signin"
|
|
216
|
+
@success="handleSuccess"
|
|
217
|
+
/>
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
</template>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Client Usage (Vue):**
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
import { authClient } from '@contentgrowth/content-auth/vue/client';
|
|
227
|
+
|
|
228
|
+
await authClient.signIn.email({ ... });
|
|
229
|
+
```
|
|
230
|
+
|
|
165
231
|
## Database Setup
|
|
166
232
|
|
|
167
233
|
This package requires specific database tables to function. We provide a **SQL schema template** that you copy into your project and extend with your own tables.
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
authClient
|
|
3
3
|
} from "./chunk-NKDKDBM2.js";
|
|
4
4
|
|
|
5
|
-
// src/frontend/components/AuthForm.tsx
|
|
5
|
+
// src/frontend/components/react/AuthForm.tsx
|
|
6
6
|
import { useState, useRef, useEffect } from "react";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
var AuthForm = ({
|
|
@@ -296,7 +296,7 @@ var AuthForm = ({
|
|
|
296
296
|
] });
|
|
297
297
|
};
|
|
298
298
|
|
|
299
|
-
// src/frontend/components/ForgotPasswordForm.tsx
|
|
299
|
+
// src/frontend/components/react/ForgotPasswordForm.tsx
|
|
300
300
|
import { useState as useState2 } from "react";
|
|
301
301
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
302
302
|
var ForgotPasswordForm = ({
|
|
@@ -378,7 +378,7 @@ var ForgotPasswordForm = ({
|
|
|
378
378
|
] });
|
|
379
379
|
};
|
|
380
380
|
|
|
381
|
-
// src/frontend/components/ResetPasswordForm.tsx
|
|
381
|
+
// src/frontend/components/react/ResetPasswordForm.tsx
|
|
382
382
|
import { useState as useState3 } from "react";
|
|
383
383
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
384
384
|
var ResetPasswordForm = ({
|
|
@@ -496,7 +496,7 @@ var ResetPasswordForm = ({
|
|
|
496
496
|
] });
|
|
497
497
|
};
|
|
498
498
|
|
|
499
|
-
// src/frontend/components/Organization.tsx
|
|
499
|
+
// src/frontend/components/react/Organization.tsx
|
|
500
500
|
import { useState as useState4, useEffect as useEffect2 } from "react";
|
|
501
501
|
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
502
502
|
var CreateOrganizationForm = ({
|
|
@@ -661,7 +661,7 @@ var InviteMemberForm = ({
|
|
|
661
661
|
] });
|
|
662
662
|
};
|
|
663
663
|
|
|
664
|
-
// src/frontend/components/ProfileEditor.tsx
|
|
664
|
+
// src/frontend/components/react/ProfileEditor.tsx
|
|
665
665
|
import { useState as useState5, useEffect as useEffect3 } from "react";
|
|
666
666
|
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
667
667
|
var ProfileEditor = ({
|
|
@@ -746,7 +746,7 @@ var ProfileEditor = ({
|
|
|
746
746
|
] });
|
|
747
747
|
};
|
|
748
748
|
|
|
749
|
-
// src/frontend/components/PasswordChanger.tsx
|
|
749
|
+
// src/frontend/components/react/PasswordChanger.tsx
|
|
750
750
|
import { useState as useState6 } from "react";
|
|
751
751
|
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
752
752
|
var PasswordChanger = ({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/frontend/clients/astro-client.ts
|
|
2
|
+
import { createAuthClient } from "better-auth/client";
|
|
3
|
+
import { organizationClient } from "better-auth/client/plugins";
|
|
4
|
+
var createClient = (baseUrl) => {
|
|
5
|
+
return createAuthClient({
|
|
6
|
+
baseURL: baseUrl,
|
|
7
|
+
plugins: [
|
|
8
|
+
organizationClient()
|
|
9
|
+
]
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var authClient = createClient();
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
createClient,
|
|
16
|
+
authClient
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/frontend/clients/vue-client.ts
|
|
2
|
+
import { createAuthClient } from "better-auth/vue";
|
|
3
|
+
import { organizationClient } from "better-auth/client/plugins";
|
|
4
|
+
var createClient = (baseUrl) => {
|
|
5
|
+
return createAuthClient({
|
|
6
|
+
baseURL: baseUrl,
|
|
7
|
+
plugins: [
|
|
8
|
+
organizationClient()
|
|
9
|
+
]
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var authClient = createClient();
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
createClient,
|
|
16
|
+
authClient
|
|
17
|
+
};
|
|
@@ -965,13 +965,13 @@ declare const createClient: (baseUrl?: string) => {
|
|
|
965
965
|
token: string | null;
|
|
966
966
|
user: {
|
|
967
967
|
id: string;
|
|
968
|
-
email: string;
|
|
969
|
-
name: string;
|
|
970
|
-
image: string | null | undefined;
|
|
971
|
-
emailVerified: boolean;
|
|
972
968
|
createdAt: Date;
|
|
973
969
|
updatedAt: Date;
|
|
974
|
-
|
|
970
|
+
email: string;
|
|
971
|
+
emailVerified: boolean;
|
|
972
|
+
name: string;
|
|
973
|
+
image?: string | null | undefined;
|
|
974
|
+
} & Record<string, any>;
|
|
975
975
|
}, {
|
|
976
976
|
code?: string | undefined;
|
|
977
977
|
message?: string | undefined;
|
|
@@ -1135,13 +1135,13 @@ declare const createClient: (baseUrl?: string) => {
|
|
|
1135
1135
|
query?: Record<string, any> | undefined;
|
|
1136
1136
|
fetchOptions?: FetchOptions | undefined;
|
|
1137
1137
|
}> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
1138
|
+
scopes: string[];
|
|
1138
1139
|
id: string;
|
|
1139
|
-
providerId: string;
|
|
1140
1140
|
createdAt: Date;
|
|
1141
1141
|
updatedAt: Date;
|
|
1142
|
-
accountId: string;
|
|
1143
1142
|
userId: string;
|
|
1144
|
-
|
|
1143
|
+
providerId: string;
|
|
1144
|
+
accountId: string;
|
|
1145
1145
|
}[], {
|
|
1146
1146
|
code?: string | undefined;
|
|
1147
1147
|
message?: string | undefined;
|
|
@@ -1444,6 +1444,7 @@ declare const createClient: (baseUrl?: string) => {
|
|
|
1444
1444
|
})[];
|
|
1445
1445
|
cache?: RequestCache | undefined;
|
|
1446
1446
|
method: string;
|
|
1447
|
+
window?: null | undefined;
|
|
1447
1448
|
headers?: (HeadersInit & (HeadersInit | {
|
|
1448
1449
|
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
1449
1450
|
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
@@ -1458,7 +1459,6 @@ declare const createClient: (baseUrl?: string) => {
|
|
|
1458
1459
|
referrer?: string | undefined;
|
|
1459
1460
|
referrerPolicy?: ReferrerPolicy | undefined;
|
|
1460
1461
|
signal?: (AbortSignal | null) | undefined;
|
|
1461
|
-
window?: null | undefined;
|
|
1462
1462
|
onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
|
|
1463
1463
|
hookOptions?: {
|
|
1464
1464
|
cloneResponse?: boolean;
|
|
@@ -1578,6 +1578,24 @@ declare const createClient: (baseUrl?: string) => {
|
|
|
1578
1578
|
readonly FAILED_TO_UNLINK_LAST_ACCOUNT: "You can't unlink your last account";
|
|
1579
1579
|
readonly ACCOUNT_NOT_FOUND: "Account not found";
|
|
1580
1580
|
readonly USER_ALREADY_HAS_PASSWORD: "User already has a password. Provide that to delete the account.";
|
|
1581
|
+
readonly CROSS_SITE_NAVIGATION_LOGIN_BLOCKED: "Cross-site navigation login blocked. This request appears to be a CSRF attack.";
|
|
1582
|
+
readonly VERIFICATION_EMAIL_NOT_ENABLED: "Verification email isn't enabled";
|
|
1583
|
+
readonly EMAIL_ALREADY_VERIFIED: "Email is already verified";
|
|
1584
|
+
readonly EMAIL_MISMATCH: "Email mismatch";
|
|
1585
|
+
readonly SESSION_NOT_FRESH: "Session is not fresh";
|
|
1586
|
+
readonly LINKED_ACCOUNT_ALREADY_EXISTS: "Linked account already exists";
|
|
1587
|
+
readonly INVALID_ORIGIN: "Invalid origin";
|
|
1588
|
+
readonly INVALID_CALLBACK_URL: "Invalid callbackURL";
|
|
1589
|
+
readonly INVALID_REDIRECT_URL: "Invalid redirectURL";
|
|
1590
|
+
readonly INVALID_ERROR_CALLBACK_URL: "Invalid errorCallbackURL";
|
|
1591
|
+
readonly INVALID_NEW_USER_CALLBACK_URL: "Invalid newUserCallbackURL";
|
|
1592
|
+
readonly MISSING_OR_NULL_ORIGIN: "Missing or null Origin";
|
|
1593
|
+
readonly CALLBACK_URL_REQUIRED: "callbackURL is required";
|
|
1594
|
+
readonly FAILED_TO_CREATE_VERIFICATION: "Unable to create verification";
|
|
1595
|
+
readonly FIELD_NOT_ALLOWED: "Field not allowed to be set";
|
|
1596
|
+
readonly ASYNC_VALIDATION_NOT_SUPPORTED: "Async validation is not supported";
|
|
1597
|
+
readonly VALIDATION_ERROR: "Validation Error";
|
|
1598
|
+
readonly MISSING_FIELD: "Field is required";
|
|
1581
1599
|
};
|
|
1582
1600
|
};
|
|
1583
1601
|
declare const authClient: {
|
|
@@ -2542,13 +2560,13 @@ declare const authClient: {
|
|
|
2542
2560
|
token: string | null;
|
|
2543
2561
|
user: {
|
|
2544
2562
|
id: string;
|
|
2545
|
-
email: string;
|
|
2546
|
-
name: string;
|
|
2547
|
-
image: string | null | undefined;
|
|
2548
|
-
emailVerified: boolean;
|
|
2549
2563
|
createdAt: Date;
|
|
2550
2564
|
updatedAt: Date;
|
|
2551
|
-
|
|
2565
|
+
email: string;
|
|
2566
|
+
emailVerified: boolean;
|
|
2567
|
+
name: string;
|
|
2568
|
+
image?: string | null | undefined;
|
|
2569
|
+
} & Record<string, any>;
|
|
2552
2570
|
}, {
|
|
2553
2571
|
code?: string | undefined;
|
|
2554
2572
|
message?: string | undefined;
|
|
@@ -2712,13 +2730,13 @@ declare const authClient: {
|
|
|
2712
2730
|
query?: Record<string, any> | undefined;
|
|
2713
2731
|
fetchOptions?: FetchOptions | undefined;
|
|
2714
2732
|
}> | undefined, data_1?: FetchOptions | undefined) => Promise<_better_fetch_fetch.BetterFetchResponse<{
|
|
2733
|
+
scopes: string[];
|
|
2715
2734
|
id: string;
|
|
2716
|
-
providerId: string;
|
|
2717
2735
|
createdAt: Date;
|
|
2718
2736
|
updatedAt: Date;
|
|
2719
|
-
accountId: string;
|
|
2720
2737
|
userId: string;
|
|
2721
|
-
|
|
2738
|
+
providerId: string;
|
|
2739
|
+
accountId: string;
|
|
2722
2740
|
}[], {
|
|
2723
2741
|
code?: string | undefined;
|
|
2724
2742
|
message?: string | undefined;
|
|
@@ -3021,6 +3039,7 @@ declare const authClient: {
|
|
|
3021
3039
|
})[];
|
|
3022
3040
|
cache?: RequestCache | undefined;
|
|
3023
3041
|
method: string;
|
|
3042
|
+
window?: null | undefined;
|
|
3024
3043
|
headers?: (HeadersInit & (HeadersInit | {
|
|
3025
3044
|
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
3026
3045
|
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
@@ -3035,7 +3054,6 @@ declare const authClient: {
|
|
|
3035
3054
|
referrer?: string | undefined;
|
|
3036
3055
|
referrerPolicy?: ReferrerPolicy | undefined;
|
|
3037
3056
|
signal?: (AbortSignal | null) | undefined;
|
|
3038
|
-
window?: null | undefined;
|
|
3039
3057
|
onRetry?: ((response: _better_fetch_fetch.ResponseContext) => Promise<void> | void) | undefined;
|
|
3040
3058
|
hookOptions?: {
|
|
3041
3059
|
cloneResponse?: boolean;
|
|
@@ -3155,6 +3173,24 @@ declare const authClient: {
|
|
|
3155
3173
|
readonly FAILED_TO_UNLINK_LAST_ACCOUNT: "You can't unlink your last account";
|
|
3156
3174
|
readonly ACCOUNT_NOT_FOUND: "Account not found";
|
|
3157
3175
|
readonly USER_ALREADY_HAS_PASSWORD: "User already has a password. Provide that to delete the account.";
|
|
3176
|
+
readonly CROSS_SITE_NAVIGATION_LOGIN_BLOCKED: "Cross-site navigation login blocked. This request appears to be a CSRF attack.";
|
|
3177
|
+
readonly VERIFICATION_EMAIL_NOT_ENABLED: "Verification email isn't enabled";
|
|
3178
|
+
readonly EMAIL_ALREADY_VERIFIED: "Email is already verified";
|
|
3179
|
+
readonly EMAIL_MISMATCH: "Email mismatch";
|
|
3180
|
+
readonly SESSION_NOT_FRESH: "Session is not fresh";
|
|
3181
|
+
readonly LINKED_ACCOUNT_ALREADY_EXISTS: "Linked account already exists";
|
|
3182
|
+
readonly INVALID_ORIGIN: "Invalid origin";
|
|
3183
|
+
readonly INVALID_CALLBACK_URL: "Invalid callbackURL";
|
|
3184
|
+
readonly INVALID_REDIRECT_URL: "Invalid redirectURL";
|
|
3185
|
+
readonly INVALID_ERROR_CALLBACK_URL: "Invalid errorCallbackURL";
|
|
3186
|
+
readonly INVALID_NEW_USER_CALLBACK_URL: "Invalid newUserCallbackURL";
|
|
3187
|
+
readonly MISSING_OR_NULL_ORIGIN: "Missing or null Origin";
|
|
3188
|
+
readonly CALLBACK_URL_REQUIRED: "callbackURL is required";
|
|
3189
|
+
readonly FAILED_TO_CREATE_VERIFICATION: "Unable to create verification";
|
|
3190
|
+
readonly FIELD_NOT_ALLOWED: "Field not allowed to be set";
|
|
3191
|
+
readonly ASYNC_VALIDATION_NOT_SUPPORTED: "Async validation is not supported";
|
|
3192
|
+
readonly VALIDATION_ERROR: "Validation Error";
|
|
3193
|
+
readonly MISSING_FIELD: "Field is required";
|
|
3158
3194
|
};
|
|
3159
3195
|
};
|
|
3160
3196
|
|