@witchcraft/nuxt-auth 0.5.2 → 0.6.0-beta.1
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 +188 -336
- package/dist/module.d.mts +64 -41
- package/dist/module.json +1 -1
- package/dist/module.mjs +25 -35
- package/dist/runtime/components/ExternalCallback.vue +11 -11
- package/dist/runtime/components/LoginProviderButtons.client.d.vue.ts +10 -15
- package/dist/runtime/components/LoginProviderButtons.client.vue +4 -10
- package/dist/runtime/components/LoginProviderButtons.client.vue.d.ts +10 -15
- package/dist/runtime/components/MockBypassRegistrationFields.d.vue.ts +13 -0
- package/dist/runtime/components/MockBypassRegistrationFields.vue +18 -0
- package/dist/runtime/components/MockBypassRegistrationFields.vue.d.ts +13 -0
- package/dist/runtime/components/Mocker.d.vue.ts +5 -1
- package/dist/runtime/components/Mocker.vue +7 -10
- package/dist/runtime/components/Mocker.vue.d.ts +5 -1
- package/dist/runtime/components/SessionStatus.d.vue.ts +86 -42
- package/dist/runtime/components/SessionStatus.vue +29 -8
- package/dist/runtime/components/SessionStatus.vue.d.ts +86 -42
- package/dist/runtime/components/UserRegistration.d.vue.ts +5 -0
- package/dist/runtime/components/UserRegistration.vue +2 -0
- package/dist/runtime/components/UserRegistration.vue.d.ts +5 -0
- package/dist/runtime/composables/useAuth.d.ts +382 -19
- package/dist/runtime/composables/useAuth.js +191 -28
- package/dist/runtime/composables/useAuthExternalCallback.d.ts +13 -6
- package/dist/runtime/composables/useAuthExternalCallback.js +27 -16
- package/dist/runtime/composables/useAuthExternalCode.d.ts +2 -2
- package/dist/runtime/composables/useAuthExternalCode.js +19 -18
- package/dist/runtime/composables/useAuthMocker.d.ts +11 -1
- package/dist/runtime/composables/useAuthMocker.js +21 -11
- package/dist/runtime/composables/useAuthUserRegistration.d.ts +5 -10
- package/dist/runtime/composables/useAuthUserRegistration.js +12 -25
- package/dist/runtime/core/providerStyles.js +12 -4
- package/dist/runtime/electron/index.d.ts +1 -0
- package/dist/runtime/electron/index.js +1 -0
- package/dist/runtime/electron/main/ElectronAuth.d.ts +123 -0
- package/dist/runtime/electron/main/ElectronAuth.js +200 -0
- package/dist/runtime/electron/main/index.d.ts +2 -0
- package/dist/runtime/electron/main/index.js +2 -0
- package/dist/runtime/electron/main/setupElectronAuthMain.d.ts +665 -0
- package/dist/runtime/electron/main/setupElectronAuthMain.js +137 -0
- package/dist/runtime/electron/preload/createElectronAuthApi.d.ts +7 -0
- package/dist/runtime/electron/preload/createElectronAuthApi.js +15 -0
- package/dist/runtime/electron/preload/index.d.ts +2 -0
- package/dist/runtime/electron/preload/index.js +2 -0
- package/dist/runtime/electron/types.d.ts +54 -0
- package/dist/runtime/electron/types.js +2 -0
- package/dist/runtime/middleware/authGlobal.js +30 -14
- package/dist/runtime/middleware/authProtected.js +2 -2
- package/dist/runtime/plugins/client/electronNuxtAuthPlugin.d.ts +48 -0
- package/dist/runtime/plugins/client/electronNuxtAuthPlugin.js +86 -0
- package/dist/runtime/plugins/client/localOnlyUsers.d.ts +25 -0
- package/dist/runtime/plugins/client/localOnlyUsers.js +110 -0
- package/dist/runtime/plugins/server/devMock.d.ts +51 -0
- package/dist/runtime/plugins/server/devMock.js +162 -0
- package/dist/runtime/server/utils/assertEventWithAuthorizedUser.d.ts +11 -0
- package/dist/runtime/server/utils/assertEventWithAuthorizedUser.js +10 -0
- package/dist/runtime/server/utils/createAuthMiddleware.d.ts +4 -4
- package/dist/runtime/server/utils/createAuthMiddleware.js +16 -23
- package/dist/runtime/server/utils/createAuthSchema.d.ts +391 -94
- package/dist/runtime/server/utils/createAuthSchema.js +43 -13
- package/dist/runtime/server/utils/createBetterAuth.d.ts +34 -0
- package/dist/runtime/server/utils/createBetterAuth.js +160 -0
- package/dist/runtime/server/utils/getBetterAuthInstance.d.ts +3 -0
- package/dist/runtime/server/utils/getBetterAuthInstance.js +10 -0
- package/dist/runtime/types.d.ts +358 -248
- package/dist/runtime/types.js +48 -25
- package/dist/runtime/utils/deserializeAuthLocalUser.d.ts +2 -0
- package/dist/runtime/utils/deserializeAuthLocalUser.js +9 -0
- package/package.json +44 -19
- package/dist/runtime/core/providers/github.d.ts +0 -84
- package/dist/runtime/core/providers/github.js +0 -55
- package/dist/runtime/core/providers/google.d.ts +0 -65
- package/dist/runtime/core/providers/google.js +0 -49
- package/dist/runtime/server/helpers/getSafeSecretsInfo.d.ts +0 -4
- package/dist/runtime/server/helpers/getSafeSecretsInfo.js +0 -10
- package/dist/runtime/server/helpers/logSafeRoute.d.ts +0 -1
- package/dist/runtime/server/helpers/logSafeRoute.js +0 -3
- package/dist/runtime/server/helpers/signJwt.d.ts +0 -3
- package/dist/runtime/server/helpers/signJwt.js +0 -16
- package/dist/runtime/server/helpers/verifyJwt.d.ts +0 -5
- package/dist/runtime/server/helpers/verifyJwt.js +0 -19
- package/dist/runtime/server/utils/Auth.d.ts +0 -85
- package/dist/runtime/server/utils/Auth.js +0 -671
- package/dist/runtime/server/utils/SessionManager.d.ts +0 -26
- package/dist/runtime/server/utils/SessionManager.js +0 -94
- package/dist/runtime/server/utils/createAuthHandler.d.ts +0 -9
- package/dist/runtime/server/utils/createAuthHandler.js +0 -29
- package/dist/runtime/utils/createExternalAuthLoginHandler.d.ts +0 -37
- package/dist/runtime/utils/createExternalAuthLoginHandler.js +0 -23
- package/dist/runtime/utils/getAuthApiRoute.d.ts +0 -6
- package/dist/runtime/utils/getAuthApiRoute.js +0 -14
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,267 +1,377 @@
|
|
|
1
|
-
import type { EnumLike } from "@alanscodelog/utils";
|
|
2
|
-
import type { OAuth2Tokens } from "arctic";
|
|
3
|
-
import type { H3Event, Router } from "h3";
|
|
4
|
-
import type { StringValue } from "ms";
|
|
5
1
|
import type { InjectionKey } from "vue";
|
|
6
2
|
import { z } from "zod";
|
|
7
|
-
import type { AuthAccount, AuthSession as DbAuthSession, AuthUserFields as DbAuthUser } from "./server/utils/createAuthSchema.js";
|
|
8
|
-
import type { ModulePublicRuntimeConfig } from "../module.js";
|
|
9
3
|
export type * from "./server/utils/createAuthSchema.js";
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
export declare const authUsersDbSchema: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
5
|
+
name: "users";
|
|
6
|
+
schema: undefined;
|
|
7
|
+
columns: {
|
|
8
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
9
|
+
name: "id";
|
|
10
|
+
tableName: "users";
|
|
11
|
+
dataType: "string";
|
|
12
|
+
columnType: "PgUUID";
|
|
13
|
+
data: string;
|
|
14
|
+
driverParam: string;
|
|
15
|
+
notNull: true;
|
|
16
|
+
hasDefault: false;
|
|
17
|
+
isPrimaryKey: true;
|
|
18
|
+
isAutoincrement: false;
|
|
19
|
+
hasRuntimeDefault: false;
|
|
20
|
+
enumValues: undefined;
|
|
21
|
+
baseColumn: never;
|
|
22
|
+
identity: undefined;
|
|
23
|
+
generated: undefined;
|
|
24
|
+
}, {}, {}>;
|
|
25
|
+
email: import("drizzle-orm/pg-core").PgColumn<{
|
|
26
|
+
name: "email";
|
|
27
|
+
tableName: "users";
|
|
28
|
+
dataType: "string";
|
|
29
|
+
columnType: "PgText";
|
|
30
|
+
data: string;
|
|
31
|
+
driverParam: string;
|
|
32
|
+
notNull: true;
|
|
33
|
+
hasDefault: false;
|
|
34
|
+
isPrimaryKey: false;
|
|
35
|
+
isAutoincrement: false;
|
|
36
|
+
hasRuntimeDefault: false;
|
|
37
|
+
enumValues: [string, ...string[]];
|
|
38
|
+
baseColumn: never;
|
|
39
|
+
identity: undefined;
|
|
40
|
+
generated: undefined;
|
|
41
|
+
}, {}, {}>;
|
|
42
|
+
emailVerified: import("drizzle-orm/pg-core").PgColumn<{
|
|
43
|
+
name: "emailVerified";
|
|
44
|
+
tableName: "users";
|
|
45
|
+
dataType: "boolean";
|
|
46
|
+
columnType: "PgBoolean";
|
|
47
|
+
data: boolean;
|
|
48
|
+
driverParam: boolean;
|
|
49
|
+
notNull: true;
|
|
50
|
+
hasDefault: true;
|
|
51
|
+
isPrimaryKey: false;
|
|
52
|
+
isAutoincrement: false;
|
|
53
|
+
hasRuntimeDefault: false;
|
|
54
|
+
enumValues: undefined;
|
|
55
|
+
baseColumn: never;
|
|
56
|
+
identity: undefined;
|
|
57
|
+
generated: undefined;
|
|
58
|
+
}, {}, {}>;
|
|
59
|
+
name: import("drizzle-orm/pg-core").PgColumn<{
|
|
60
|
+
name: "name";
|
|
61
|
+
tableName: "users";
|
|
62
|
+
dataType: "string";
|
|
63
|
+
columnType: "PgText";
|
|
64
|
+
data: string;
|
|
65
|
+
driverParam: string;
|
|
66
|
+
notNull: true;
|
|
67
|
+
hasDefault: false;
|
|
68
|
+
isPrimaryKey: false;
|
|
69
|
+
isAutoincrement: false;
|
|
70
|
+
hasRuntimeDefault: false;
|
|
71
|
+
enumValues: [string, ...string[]];
|
|
72
|
+
baseColumn: never;
|
|
73
|
+
identity: undefined;
|
|
74
|
+
generated: undefined;
|
|
75
|
+
}, {}, {}>;
|
|
76
|
+
image: import("drizzle-orm/pg-core").PgColumn<{
|
|
77
|
+
name: "image";
|
|
78
|
+
tableName: "users";
|
|
79
|
+
dataType: "string";
|
|
80
|
+
columnType: "PgText";
|
|
81
|
+
data: string;
|
|
82
|
+
driverParam: string;
|
|
83
|
+
notNull: false;
|
|
84
|
+
hasDefault: false;
|
|
85
|
+
isPrimaryKey: false;
|
|
86
|
+
isAutoincrement: false;
|
|
87
|
+
hasRuntimeDefault: false;
|
|
88
|
+
enumValues: [string, ...string[]];
|
|
89
|
+
baseColumn: never;
|
|
90
|
+
identity: undefined;
|
|
91
|
+
generated: undefined;
|
|
92
|
+
}, {}, {}>;
|
|
93
|
+
username: import("drizzle-orm/pg-core").PgColumn<{
|
|
94
|
+
name: "username";
|
|
95
|
+
tableName: "users";
|
|
96
|
+
dataType: "string";
|
|
97
|
+
columnType: "PgText";
|
|
98
|
+
data: string;
|
|
99
|
+
driverParam: string;
|
|
100
|
+
notNull: false;
|
|
101
|
+
hasDefault: false;
|
|
102
|
+
isPrimaryKey: false;
|
|
103
|
+
isAutoincrement: false;
|
|
104
|
+
hasRuntimeDefault: false;
|
|
105
|
+
enumValues: [string, ...string[]];
|
|
106
|
+
baseColumn: never;
|
|
107
|
+
identity: undefined;
|
|
108
|
+
generated: undefined;
|
|
109
|
+
}, {}, {}>;
|
|
110
|
+
isRegistered: import("drizzle-orm/pg-core").PgColumn<{
|
|
111
|
+
name: "isRegistered";
|
|
112
|
+
tableName: "users";
|
|
113
|
+
dataType: "boolean";
|
|
114
|
+
columnType: "PgBoolean";
|
|
115
|
+
data: boolean;
|
|
116
|
+
driverParam: boolean;
|
|
117
|
+
notNull: true;
|
|
118
|
+
hasDefault: true;
|
|
119
|
+
isPrimaryKey: false;
|
|
120
|
+
isAutoincrement: false;
|
|
121
|
+
hasRuntimeDefault: false;
|
|
122
|
+
enumValues: undefined;
|
|
123
|
+
baseColumn: never;
|
|
124
|
+
identity: undefined;
|
|
125
|
+
generated: undefined;
|
|
126
|
+
}, {}, {}>;
|
|
127
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
128
|
+
name: "createdAt";
|
|
129
|
+
tableName: "users";
|
|
130
|
+
dataType: "date";
|
|
131
|
+
columnType: "PgTimestamp";
|
|
132
|
+
data: Date;
|
|
133
|
+
driverParam: string;
|
|
134
|
+
notNull: true;
|
|
135
|
+
hasDefault: true;
|
|
136
|
+
isPrimaryKey: false;
|
|
137
|
+
isAutoincrement: false;
|
|
138
|
+
hasRuntimeDefault: false;
|
|
139
|
+
enumValues: undefined;
|
|
140
|
+
baseColumn: never;
|
|
141
|
+
identity: undefined;
|
|
142
|
+
generated: undefined;
|
|
143
|
+
}, {}, {}>;
|
|
144
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
145
|
+
name: "updatedAt";
|
|
146
|
+
tableName: "users";
|
|
147
|
+
dataType: "date";
|
|
148
|
+
columnType: "PgTimestamp";
|
|
149
|
+
data: Date;
|
|
150
|
+
driverParam: string;
|
|
151
|
+
notNull: true;
|
|
152
|
+
hasDefault: true;
|
|
153
|
+
isPrimaryKey: false;
|
|
154
|
+
isAutoincrement: false;
|
|
155
|
+
hasRuntimeDefault: false;
|
|
156
|
+
enumValues: undefined;
|
|
157
|
+
baseColumn: never;
|
|
158
|
+
identity: undefined;
|
|
159
|
+
generated: undefined;
|
|
160
|
+
}, {}, {}>;
|
|
161
|
+
};
|
|
162
|
+
dialect: "pg";
|
|
163
|
+
}>;
|
|
164
|
+
export type AuthUserFields = typeof authUsersDbSchema.$inferSelect;
|
|
165
|
+
export declare const zAdditionalLocalUserProperties: z.ZodObject<{
|
|
166
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
167
|
+
local: "local";
|
|
168
|
+
external: "external";
|
|
14
169
|
}>>;
|
|
15
|
-
|
|
170
|
+
createdAt: z.ZodDate;
|
|
171
|
+
updatedAt: z.ZodDate;
|
|
16
172
|
}, z.core.$strip>;
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
173
|
+
export declare const zAdditionalLocalStoredUserProperties: z.ZodObject<{
|
|
174
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
175
|
+
local: "local";
|
|
176
|
+
external: "external";
|
|
177
|
+
}>>;
|
|
178
|
+
createdAt: z.ZodString;
|
|
179
|
+
updatedAt: z.ZodString;
|
|
180
|
+
}, z.core.$strip>;
|
|
181
|
+
/** Local-only user. Always has a username, it is the name it was created with. */
|
|
182
|
+
export declare const zAuthUserLocal: z.ZodObject<{
|
|
183
|
+
id: z.ZodUUID;
|
|
184
|
+
email: z.ZodString;
|
|
185
|
+
emailVerified: z.ZodBoolean;
|
|
186
|
+
name: z.ZodString;
|
|
187
|
+
image: z.ZodNullable<z.ZodString>;
|
|
188
|
+
isRegistered: z.ZodBoolean;
|
|
189
|
+
createdAt: z.ZodDate;
|
|
190
|
+
updatedAt: z.ZodDate;
|
|
191
|
+
type: z.ZodLiteral<"local">;
|
|
192
|
+
username: z.ZodString;
|
|
193
|
+
}, {
|
|
194
|
+
out: {};
|
|
195
|
+
in: {};
|
|
196
|
+
}>;
|
|
197
|
+
/** User the server resolved. Username is optional, better-auth's column is nullable. */
|
|
198
|
+
export declare const zAuthUserExternal: z.ZodObject<{
|
|
199
|
+
id: z.ZodUUID;
|
|
200
|
+
email: z.ZodString;
|
|
201
|
+
emailVerified: z.ZodBoolean;
|
|
202
|
+
name: z.ZodString;
|
|
203
|
+
image: z.ZodNullable<z.ZodString>;
|
|
204
|
+
isRegistered: z.ZodBoolean;
|
|
205
|
+
createdAt: z.ZodDate;
|
|
206
|
+
updatedAt: z.ZodDate;
|
|
207
|
+
type: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
208
|
+
username: z.ZodNullable<z.ZodString>;
|
|
209
|
+
}, {
|
|
210
|
+
out: {};
|
|
211
|
+
in: {};
|
|
212
|
+
}>;
|
|
213
|
+
/** Any user the client holds, local or external. */
|
|
214
|
+
export declare const zAuthUser: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
215
|
+
id: z.ZodUUID;
|
|
216
|
+
email: z.ZodString;
|
|
217
|
+
emailVerified: z.ZodBoolean;
|
|
218
|
+
name: z.ZodString;
|
|
219
|
+
image: z.ZodNullable<z.ZodString>;
|
|
220
|
+
isRegistered: z.ZodBoolean;
|
|
221
|
+
createdAt: z.ZodDate;
|
|
222
|
+
updatedAt: z.ZodDate;
|
|
223
|
+
type: z.ZodLiteral<"local">;
|
|
224
|
+
username: z.ZodString;
|
|
225
|
+
}, {
|
|
226
|
+
out: {};
|
|
227
|
+
in: {};
|
|
228
|
+
}>, z.ZodObject<{
|
|
229
|
+
id: z.ZodUUID;
|
|
230
|
+
email: z.ZodString;
|
|
231
|
+
emailVerified: z.ZodBoolean;
|
|
232
|
+
name: z.ZodString;
|
|
233
|
+
image: z.ZodNullable<z.ZodString>;
|
|
234
|
+
isRegistered: z.ZodBoolean;
|
|
235
|
+
createdAt: z.ZodDate;
|
|
236
|
+
updatedAt: z.ZodDate;
|
|
237
|
+
type: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
238
|
+
username: z.ZodNullable<z.ZodString>;
|
|
239
|
+
}, {
|
|
240
|
+
out: {};
|
|
241
|
+
in: {};
|
|
242
|
+
}>], "type">;
|
|
243
|
+
export declare const zAuthUserLocalStored: z.ZodObject<{
|
|
244
|
+
id: z.ZodUUID;
|
|
245
|
+
email: z.ZodString;
|
|
246
|
+
emailVerified: z.ZodBoolean;
|
|
247
|
+
name: z.ZodString;
|
|
248
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
249
|
+
isRegistered: z.ZodBoolean;
|
|
250
|
+
createdAt: z.ZodString;
|
|
251
|
+
updatedAt: z.ZodString;
|
|
252
|
+
type: z.ZodLiteral<"local">;
|
|
253
|
+
username: z.ZodString;
|
|
254
|
+
}, {
|
|
255
|
+
out: {};
|
|
256
|
+
in: {};
|
|
257
|
+
}>;
|
|
258
|
+
export declare const zAuthUserExternalStored: z.ZodObject<{
|
|
259
|
+
id: z.ZodUUID;
|
|
260
|
+
email: z.ZodString;
|
|
261
|
+
emailVerified: z.ZodBoolean;
|
|
262
|
+
name: z.ZodString;
|
|
263
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
264
|
+
isRegistered: z.ZodBoolean;
|
|
265
|
+
createdAt: z.ZodString;
|
|
266
|
+
updatedAt: z.ZodString;
|
|
267
|
+
type: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
268
|
+
username: z.ZodNullable<z.ZodString>;
|
|
269
|
+
}, {
|
|
270
|
+
out: {};
|
|
271
|
+
in: {};
|
|
272
|
+
}>;
|
|
273
|
+
/** Any user the client holds, as it is stored, i.e. dates are ISO strings. */
|
|
274
|
+
export declare const zAuthUserStored: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
275
|
+
id: z.ZodUUID;
|
|
276
|
+
email: z.ZodString;
|
|
277
|
+
emailVerified: z.ZodBoolean;
|
|
278
|
+
name: z.ZodString;
|
|
279
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
280
|
+
isRegistered: z.ZodBoolean;
|
|
281
|
+
createdAt: z.ZodString;
|
|
282
|
+
updatedAt: z.ZodString;
|
|
283
|
+
type: z.ZodLiteral<"local">;
|
|
284
|
+
username: z.ZodString;
|
|
285
|
+
}, {
|
|
286
|
+
out: {};
|
|
287
|
+
in: {};
|
|
288
|
+
}>, z.ZodObject<{
|
|
289
|
+
id: z.ZodUUID;
|
|
290
|
+
email: z.ZodString;
|
|
291
|
+
emailVerified: z.ZodBoolean;
|
|
292
|
+
name: z.ZodString;
|
|
293
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
294
|
+
isRegistered: z.ZodBoolean;
|
|
295
|
+
createdAt: z.ZodString;
|
|
296
|
+
updatedAt: z.ZodString;
|
|
297
|
+
type: z.ZodOptional<z.ZodLiteral<"external">>;
|
|
298
|
+
username: z.ZodNullable<z.ZodString>;
|
|
299
|
+
}, {
|
|
300
|
+
out: {};
|
|
301
|
+
in: {};
|
|
302
|
+
}>], "type">;
|
|
303
|
+
export type AuthUser = z.infer<typeof zAuthUser>;
|
|
304
|
+
export type AuthUserStored = z.infer<typeof zAuthUserStored>;
|
|
305
|
+
export type AuthLocalUser = z.infer<typeof zAuthUserLocal>;
|
|
306
|
+
export type AuthLocalUserStored = z.infer<typeof zAuthUserLocalStored>;
|
|
119
307
|
export type SessionCookieOptions = {
|
|
120
308
|
secure?: boolean;
|
|
121
309
|
path?: string;
|
|
122
|
-
domain?: string;
|
|
123
310
|
sameSite?: "lax" | "strict" | "none";
|
|
124
|
-
httpOnly?: boolean;
|
|
125
311
|
maxAge?: number;
|
|
126
312
|
expires?: Date;
|
|
313
|
+
partitioned?: boolean;
|
|
127
314
|
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
export
|
|
134
|
-
|
|
135
|
-
export
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
*
|
|
141
|
-
* Each provider defines it in a different way, so you'd need to specify this function for each provider you're interested in.
|
|
142
|
-
*
|
|
143
|
-
* You can type the return by declaration merging with the `AuthExtendedUserInfo` interface.
|
|
144
|
-
*
|
|
145
|
-
* This is set only once per provider account creation and the info column can just be cleared after the information is no longer needed.
|
|
146
|
-
*/
|
|
147
|
-
getAdditionalAccountInfo?: (user: TProviderAccountInfo) => Promise<AdditionalAccountInfo>;
|
|
148
|
-
};
|
|
149
|
-
export type AuthOptions = {
|
|
150
|
-
/** The url for the site (e.g. http:/localhost:3000 during dev), required for the redirectUri. */
|
|
151
|
-
appUrl?: string;
|
|
152
|
-
runtimeConfig: ModulePublicRuntimeConfig;
|
|
153
|
-
handlers: {
|
|
154
|
-
[k in ProviderNames]: ProviderHandlerClass<k>;
|
|
155
|
-
};
|
|
156
|
-
enabledProviders: ProviderNames[];
|
|
157
|
-
} & Partial<Omit<AuthHandlerOptions, "customProviders">>;
|
|
158
|
-
export type AuthHandlerOptions<T = any> = {
|
|
159
|
-
/**
|
|
160
|
-
* For the short lived access tokens used for external logins.
|
|
161
|
-
*
|
|
162
|
-
* Uses vercel/ms package to parse durations.
|
|
163
|
-
*
|
|
164
|
-
* @default 10m
|
|
165
|
-
*/
|
|
166
|
-
externalAccessTokenExpiresIn?: StringValue;
|
|
167
|
-
/**
|
|
168
|
-
* Modify the callback redirect url AFTER the provider has redirected to the app and an account has been created / user has been logged in.
|
|
169
|
-
*
|
|
170
|
-
* Useful, to, fore example, redirect instead to a special schema / deep link (e.g. from the browser to a desktop app).
|
|
171
|
-
*/
|
|
172
|
-
modifyCallbackRedirect: (event: H3Event,
|
|
173
|
-
/** The url here does not yet have the deeplink query param. This is because it's relative and can get complicated to parse. So it's added afterwards, only if the link wasn't modified. */
|
|
174
|
-
redirectUrl: string, userId: string, isRegistered: boolean, additionalState: T, deeplink?: string) => string | undefined;
|
|
175
|
-
/**
|
|
176
|
-
* Store additional state in the callback url.
|
|
177
|
-
*
|
|
178
|
-
* Is later available in the `modifyCallbackRedirect` option.
|
|
179
|
-
*/
|
|
180
|
-
additionalState?: (event: H3Event) => T;
|
|
181
|
-
customProviders?: {
|
|
182
|
-
[k in ProviderNames]: ProviderHandlerClass<k>;
|
|
183
|
-
};
|
|
184
|
-
providerOptions?: {
|
|
185
|
-
[k in ProviderNames]: ProviderOptions<k>;
|
|
186
|
-
};
|
|
187
|
-
appUrl: string;
|
|
188
|
-
/**
|
|
189
|
-
* Is called on user registration. User is guaranteed to be authenticated and not already registered.
|
|
190
|
-
*
|
|
191
|
-
* Return something and it will be returned as the response.
|
|
192
|
-
*
|
|
193
|
-
* If you return `false` or `undefined`, the handler will redirect to `authRoutes.postRegisteredLogin`.
|
|
194
|
-
*/
|
|
195
|
-
onRegister?: (event: H3Event) => Promise<any>;
|
|
196
|
-
/**
|
|
197
|
-
* Extend the router with your own routes.
|
|
198
|
-
*
|
|
199
|
-
* This is useful for adding custom endpoints like `/api/auth/public/users/:username/valid`.
|
|
200
|
-
*/
|
|
201
|
-
extendRouter?: (router: Router) => void;
|
|
202
|
-
/**
|
|
203
|
-
* A mapping of deeplink type to a scheme (e.g. electron => `app-name-electron:`).
|
|
204
|
-
*
|
|
205
|
-
* This is used to generate the redirect url for the external auth handler, see the readme for more info.
|
|
206
|
-
*/
|
|
207
|
-
deeplinkSchemes?: Record<string, string>;
|
|
208
|
-
devBypassAuth?: boolean;
|
|
209
|
-
/**
|
|
210
|
-
* When bypassing auth, this function is called to create the mock user info. Note that it's called whether the user exists or not. If seeding you database with test users, you should attempt to fetch any existing users here.
|
|
211
|
-
*
|
|
212
|
-
* Any missing fields will be filled in with the defualt generator. Same thing if you return undefined.
|
|
213
|
-
*/
|
|
214
|
-
createMockUser?: (username: string | undefined, id: string | undefined, provider: string) => MockUser | Promise<MockUser> | undefined | Promise<undefined>;
|
|
215
|
-
/** Should return any additional fields non-nullable fields without defaults that are needed to be able to add a user. */
|
|
216
|
-
generateUser?: () => any;
|
|
217
|
-
};
|
|
218
|
-
/**
|
|
219
|
-
* A zod username schema to use for validating usernames.
|
|
220
|
-
*/
|
|
315
|
+
/** Where the window keeps the expiry electron main put on the session cookie, in ms. External users only. */
|
|
316
|
+
export declare const externalExpiryStorageKey = "auth:external:expiresAt";
|
|
317
|
+
/** Signed-in user, shared by `useState` and `localStorage`, the two must stay the same string. */
|
|
318
|
+
export declare const userStorageKey = "auth:user";
|
|
319
|
+
/** Local-only users list, see the local-users client plugin. */
|
|
320
|
+
export declare const localOnlyUsersStorageKey = "auth:localOnlyUsers";
|
|
321
|
+
/** Expired flag, shared by state. */
|
|
322
|
+
export declare const isExpiredStateKey = "auth:isExpired";
|
|
323
|
+
/** Fetch gate, shared by state. */
|
|
324
|
+
export declare const fetchStateKey = "auth:_fetch";
|
|
325
|
+
/** Username validation id. */
|
|
326
|
+
export declare const usernameValidFetchKey = "auth:username:valid";
|
|
221
327
|
export declare const defaultZodUsernameSchema: z.ZodString;
|
|
222
|
-
export type ProviderNames = keyof InternalProviders | (AdditionalProviders extends never ? never : keyof AdditionalProviders);
|
|
223
|
-
export type Secrets = Partial<Record<`auth${Capitalize<ProviderNames>}ClientId`, string> & Record<`auth${Capitalize<ProviderNames>}ClientSecret`, string>>;
|
|
224
|
-
export interface BaseProviderAccountInfo extends AuthAccount, InitialAccountInfo {
|
|
225
|
-
}
|
|
226
328
|
export type ProviderStyle = {
|
|
227
329
|
name: string;
|
|
228
330
|
logo: any;
|
|
229
331
|
class?: string;
|
|
230
332
|
};
|
|
231
|
-
export declare const providerStylesInjectionKey: InjectionKey<Partial<Record<
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
*/
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
333
|
+
export declare const providerStylesInjectionKey: InjectionKey<Partial<Record<string, Partial<ProviderStyle>>>>;
|
|
334
|
+
/** An external platform's api, exposed on the auth client by a better-auth client plugin under its `externalApiActionsKey`. */
|
|
335
|
+
export type ExternalPlugin = {
|
|
336
|
+
/** Should return true when the plugin is on it's platform (e.g. `isElectron()`). `useAuth` uses the first active one. */
|
|
337
|
+
isActive: () => boolean;
|
|
338
|
+
/** Starts a login outside the app. Should take over the external branch of `login`. */
|
|
339
|
+
login: (options: {
|
|
340
|
+
provider?: string;
|
|
341
|
+
/** If a devBypass login was requested you need to handle it. */
|
|
342
|
+
isDevBypass?: boolean;
|
|
343
|
+
/**
|
|
344
|
+
* If a devBypassRegistration login was requested you need to handle it.
|
|
345
|
+
*
|
|
346
|
+
* Typically the external app should mock the entire browser side flow by bypassing it (see the electron diagram in the readme). Relying on the browser side mock is complicated because the testing app must be installed to be able to handle the deeplink.
|
|
347
|
+
*
|
|
348
|
+
* So the first approach is easier but it does mean you cannot mock without bypassing registration. This is because the real flow is app => browser (login => register) => app. Registration is a browser page always and should not be included in the app.
|
|
349
|
+
*
|
|
350
|
+
* If you tried to not handle this you would find yourself including the registration page on the app which is nothing like the real production flow.
|
|
351
|
+
*/
|
|
352
|
+
isDevBypassRegistration?: boolean;
|
|
353
|
+
/** The user the mock signs in as. */
|
|
354
|
+
username?: string;
|
|
355
|
+
}) => Promise<void>;
|
|
356
|
+
/** Records an external profile change in the platform registry. */
|
|
357
|
+
onUserUpdate: (id: string, patch: {
|
|
358
|
+
username?: string;
|
|
359
|
+
name?: string;
|
|
360
|
+
image?: string;
|
|
361
|
+
}) => Promise<void> | void;
|
|
362
|
+
/** For overriding how local users are stored/created only when the plugin is active. Absent means the default store handles local users. */
|
|
363
|
+
local?: {
|
|
364
|
+
list: () => Promise<AuthUser[]> | AuthUser[];
|
|
365
|
+
create: (user: {
|
|
366
|
+
id: string;
|
|
367
|
+
username: string;
|
|
368
|
+
}) => Promise<void> | void;
|
|
369
|
+
activate: (id: string) => Promise<void> | void;
|
|
370
|
+
update: (id: string, patch: {
|
|
371
|
+
username?: string;
|
|
372
|
+
name?: string;
|
|
373
|
+
image?: string;
|
|
374
|
+
}) => Promise<void> | void;
|
|
375
|
+
delete: (id: string) => Promise<void> | void;
|
|
376
|
+
};
|
|
266
377
|
};
|
|
267
|
-
export type AuthError = EnumLike<typeof AUTH_ERROR>;
|