@sqrzro/server 2.0.0-bz.10 → 2.0.0-bz.11
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/auth.d.ts +100 -0
- package/dist/auth.js +891 -0
- package/dist/cache.d.ts +4 -0
- package/dist/cache.js +46 -0
- package/dist/forms.d.ts +46 -0
- package/dist/forms.js +327 -0
- package/dist/{lists/ListService.d.ts → lists.d.ts} +5 -3
- package/dist/lists.js +61 -0
- package/dist/mail.d.ts +12 -0
- package/dist/mail.js +97 -0
- package/dist/middleware.d.ts +5 -3
- package/dist/middleware.js +58 -22
- package/dist/{database/schema.d.ts → schema.d.ts} +38 -34
- package/dist/schema.js +77 -0
- package/dist/{url/URLService.d.ts → url.d.ts} +4 -2
- package/dist/url.js +56 -0
- package/package.json +10 -11
- package/database.d.ts +0 -1
- package/database.js +0 -1
- package/dist/auth/AuthService.d.ts +0 -14
- package/dist/auth/AuthService.js +0 -135
- package/dist/auth/ClientService.d.ts +0 -11
- package/dist/auth/ClientService.js +0 -47
- package/dist/auth/LoginRequest.d.ts +0 -4
- package/dist/auth/LoginRequest.js +0 -8
- package/dist/auth/MFARequest.d.ts +0 -4
- package/dist/auth/MFARequest.js +0 -9
- package/dist/auth/MFAService.d.ts +0 -6
- package/dist/auth/MFAService.js +0 -105
- package/dist/auth/PasswordRequest.d.ts +0 -4
- package/dist/auth/PasswordRequest.js +0 -12
- package/dist/auth/PasswordResetRequest.d.ts +0 -4
- package/dist/auth/PasswordResetRequest.js +0 -13
- package/dist/auth/PasswordService.d.ts +0 -8
- package/dist/auth/PasswordService.js +0 -54
- package/dist/auth/SessionService.d.ts +0 -42
- package/dist/auth/SessionService.js +0 -127
- package/dist/auth/index.d.ts +0 -6
- package/dist/auth/index.js +0 -6
- package/dist/auth/interfaces.d.ts +0 -20
- package/dist/auth/interfaces.js +0 -1
- package/dist/cache/CacheService.d.ts +0 -2
- package/dist/cache/CacheService.js +0 -14
- package/dist/cache/index.d.ts +0 -1
- package/dist/cache/index.js +0 -1
- package/dist/database/DatabaseService.d.ts +0 -7
- package/dist/database/DatabaseService.js +0 -12
- package/dist/database/schema.js +0 -42
- package/dist/forms/FormService.d.ts +0 -16
- package/dist/forms/FormService.js +0 -78
- package/dist/forms/ImageService.d.ts +0 -7
- package/dist/forms/ImageService.js +0 -19
- package/dist/forms/ValidationError.d.ts +0 -4
- package/dist/forms/ValidationError.js +0 -7
- package/dist/forms/ValidationService.d.ts +0 -20
- package/dist/forms/ValidationService.js +0 -59
- package/dist/forms/index.d.ts +0 -3
- package/dist/forms/index.js +0 -3
- package/dist/forms/lang.d.ts +0 -2
- package/dist/forms/lang.js +0 -115
- package/dist/lists/ListService.js +0 -28
- package/dist/lists/index.d.ts +0 -1
- package/dist/lists/index.js +0 -1
- package/dist/mail/MailService.d.ts +0 -12
- package/dist/mail/MailService.js +0 -55
- package/dist/mail/index.d.ts +0 -1
- package/dist/mail/index.js +0 -1
- package/dist/url/URLService.js +0 -48
- package/dist/url/index.d.ts +0 -1
- package/dist/url/index.js +0 -1
package/dist/middleware.js
CHANGED
|
@@ -1,30 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/middleware.ts
|
|
20
|
+
var middleware_exports = {};
|
|
21
|
+
__export(middleware_exports, {
|
|
22
|
+
handleMiddleware: () => handleMiddleware
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(middleware_exports);
|
|
25
|
+
var import_server = require("next/server");
|
|
26
|
+
var DEFAULT_REDIRECT = "/auth/login";
|
|
3
27
|
function applyHeaders(request, response) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
28
|
+
response.headers.set("x-origin", request.nextUrl.origin);
|
|
29
|
+
response.headers.set("x-search-params", request.nextUrl.searchParams.toString());
|
|
30
|
+
return response;
|
|
7
31
|
}
|
|
8
32
|
function getRelativeUrl(url) {
|
|
9
|
-
|
|
33
|
+
return url.toString().replace(url.origin, "");
|
|
10
34
|
}
|
|
11
35
|
function redirect(request, pathname = DEFAULT_REDIRECT) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
36
|
+
if (request.nextUrl.pathname === pathname) {
|
|
37
|
+
return applyHeaders(request, import_server.NextResponse.next());
|
|
38
|
+
}
|
|
39
|
+
return applyHeaders(
|
|
40
|
+
request,
|
|
41
|
+
import_server.NextResponse.redirect(
|
|
42
|
+
`${request.nextUrl.origin}${pathname}?r=${encodeURIComponent(
|
|
43
|
+
getRelativeUrl(request.nextUrl)
|
|
44
|
+
)}`
|
|
45
|
+
)
|
|
46
|
+
);
|
|
16
47
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
return redirect(request);
|
|
48
|
+
async function handleMiddleware(request, nextFn) {
|
|
49
|
+
const sessionID = request.cookies.get(process.env.AUTH_COOKIE_NAME || "auth_session")?.value || "";
|
|
50
|
+
try {
|
|
51
|
+
const session = await fetch(
|
|
52
|
+
`${request.nextUrl.origin}/api/session?id=${sessionID}&pathname=${request.nextUrl.pathname}`
|
|
53
|
+
);
|
|
54
|
+
const json = await session.json();
|
|
55
|
+
if (json.redirect === null) {
|
|
56
|
+
return applyHeaders(request, nextFn ? nextFn() : import_server.NextResponse.next());
|
|
29
57
|
}
|
|
58
|
+
return redirect(request, json.redirect);
|
|
59
|
+
} catch (err) {
|
|
60
|
+
return redirect(request);
|
|
61
|
+
}
|
|
30
62
|
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
handleMiddleware
|
|
66
|
+
});
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
|
|
2
|
+
|
|
3
|
+
declare const mfaType: drizzle_orm_pg_core.PgEnum<["TOTP", "HARDWARE"]>;
|
|
4
|
+
declare const scope: drizzle_orm_pg_core.PgEnum<["ANON", "MFA", "AUTHED"]>;
|
|
5
|
+
type Scope = (typeof scope.enumValues)[number];
|
|
6
|
+
declare const authSchema: drizzle_orm_pg_core.PgSchema<"auth">;
|
|
7
|
+
declare const authUserTable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
6
8
|
name: "user_credentials";
|
|
7
9
|
schema: "auth";
|
|
8
10
|
columns: {
|
|
9
|
-
id:
|
|
11
|
+
id: drizzle_orm_pg_core.PgColumn<{
|
|
10
12
|
name: "id";
|
|
11
13
|
tableName: "user_credentials";
|
|
12
14
|
dataType: "string";
|
|
@@ -18,7 +20,7 @@ export declare const authUserTable: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
18
20
|
enumValues: [string, ...string[]];
|
|
19
21
|
baseColumn: never;
|
|
20
22
|
}, {}, {}>;
|
|
21
|
-
email:
|
|
23
|
+
email: drizzle_orm_pg_core.PgColumn<{
|
|
22
24
|
name: "email";
|
|
23
25
|
tableName: "user_credentials";
|
|
24
26
|
dataType: "string";
|
|
@@ -30,7 +32,7 @@ export declare const authUserTable: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
30
32
|
enumValues: [string, ...string[]];
|
|
31
33
|
baseColumn: never;
|
|
32
34
|
}, {}, {}>;
|
|
33
|
-
password:
|
|
35
|
+
password: drizzle_orm_pg_core.PgColumn<{
|
|
34
36
|
name: "password";
|
|
35
37
|
tableName: "user_credentials";
|
|
36
38
|
dataType: "string";
|
|
@@ -42,7 +44,7 @@ export declare const authUserTable: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
42
44
|
enumValues: [string, ...string[]];
|
|
43
45
|
baseColumn: never;
|
|
44
46
|
}, {}, {}>;
|
|
45
|
-
role:
|
|
47
|
+
role: drizzle_orm_pg_core.PgColumn<{
|
|
46
48
|
name: "role";
|
|
47
49
|
tableName: "user_credentials";
|
|
48
50
|
dataType: "number";
|
|
@@ -57,12 +59,12 @@ export declare const authUserTable: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
57
59
|
};
|
|
58
60
|
dialect: "pg";
|
|
59
61
|
}>;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
type AuthUser = typeof authUserTable.$inferSelect;
|
|
63
|
+
declare const authSessionTable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
62
64
|
name: "sessions";
|
|
63
65
|
schema: "auth";
|
|
64
66
|
columns: {
|
|
65
|
-
id:
|
|
67
|
+
id: drizzle_orm_pg_core.PgColumn<{
|
|
66
68
|
name: "id";
|
|
67
69
|
tableName: "sessions";
|
|
68
70
|
dataType: "string";
|
|
@@ -74,7 +76,7 @@ export declare const authSessionTable: import("drizzle-orm/pg-core").PgTableWith
|
|
|
74
76
|
enumValues: [string, ...string[]];
|
|
75
77
|
baseColumn: never;
|
|
76
78
|
}, {}, {}>;
|
|
77
|
-
userId:
|
|
79
|
+
userId: drizzle_orm_pg_core.PgColumn<{
|
|
78
80
|
name: "userId";
|
|
79
81
|
tableName: "sessions";
|
|
80
82
|
dataType: "string";
|
|
@@ -86,7 +88,7 @@ export declare const authSessionTable: import("drizzle-orm/pg-core").PgTableWith
|
|
|
86
88
|
enumValues: [string, ...string[]];
|
|
87
89
|
baseColumn: never;
|
|
88
90
|
}, {}, {}>;
|
|
89
|
-
scope:
|
|
91
|
+
scope: drizzle_orm_pg_core.PgColumn<{
|
|
90
92
|
name: "scope";
|
|
91
93
|
tableName: "sessions";
|
|
92
94
|
dataType: "string";
|
|
@@ -98,7 +100,7 @@ export declare const authSessionTable: import("drizzle-orm/pg-core").PgTableWith
|
|
|
98
100
|
enumValues: ["ANON", "MFA", "AUTHED"];
|
|
99
101
|
baseColumn: never;
|
|
100
102
|
}, {}, {}>;
|
|
101
|
-
expiresAt:
|
|
103
|
+
expiresAt: drizzle_orm_pg_core.PgColumn<{
|
|
102
104
|
name: "expiresAt";
|
|
103
105
|
tableName: "sessions";
|
|
104
106
|
dataType: "date";
|
|
@@ -113,12 +115,12 @@ export declare const authSessionTable: import("drizzle-orm/pg-core").PgTableWith
|
|
|
113
115
|
};
|
|
114
116
|
dialect: "pg";
|
|
115
117
|
}>;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
type AuthSession = typeof authSessionTable.$inferSelect;
|
|
119
|
+
declare const authResetTable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
118
120
|
name: "resets";
|
|
119
121
|
schema: "auth";
|
|
120
122
|
columns: {
|
|
121
|
-
id:
|
|
123
|
+
id: drizzle_orm_pg_core.PgColumn<{
|
|
122
124
|
name: "id";
|
|
123
125
|
tableName: "resets";
|
|
124
126
|
dataType: "string";
|
|
@@ -130,7 +132,7 @@ export declare const authResetTable: import("drizzle-orm/pg-core").PgTableWithCo
|
|
|
130
132
|
enumValues: [string, ...string[]];
|
|
131
133
|
baseColumn: never;
|
|
132
134
|
}, {}, {}>;
|
|
133
|
-
userId:
|
|
135
|
+
userId: drizzle_orm_pg_core.PgColumn<{
|
|
134
136
|
name: "userId";
|
|
135
137
|
tableName: "resets";
|
|
136
138
|
dataType: "string";
|
|
@@ -142,7 +144,7 @@ export declare const authResetTable: import("drizzle-orm/pg-core").PgTableWithCo
|
|
|
142
144
|
enumValues: [string, ...string[]];
|
|
143
145
|
baseColumn: never;
|
|
144
146
|
}, {}, {}>;
|
|
145
|
-
expiresAt:
|
|
147
|
+
expiresAt: drizzle_orm_pg_core.PgColumn<{
|
|
146
148
|
name: "expiresAt";
|
|
147
149
|
tableName: "resets";
|
|
148
150
|
dataType: "date";
|
|
@@ -157,12 +159,12 @@ export declare const authResetTable: import("drizzle-orm/pg-core").PgTableWithCo
|
|
|
157
159
|
};
|
|
158
160
|
dialect: "pg";
|
|
159
161
|
}>;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
+
type AuthReset = typeof authResetTable.$inferSelect;
|
|
163
|
+
declare const authMFATable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
162
164
|
name: "mfas";
|
|
163
165
|
schema: "auth";
|
|
164
166
|
columns: {
|
|
165
|
-
id:
|
|
167
|
+
id: drizzle_orm_pg_core.PgColumn<{
|
|
166
168
|
name: "id";
|
|
167
169
|
tableName: "mfas";
|
|
168
170
|
dataType: "string";
|
|
@@ -174,7 +176,7 @@ export declare const authMFATable: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
174
176
|
enumValues: [string, ...string[]];
|
|
175
177
|
baseColumn: never;
|
|
176
178
|
}, {}, {}>;
|
|
177
|
-
name:
|
|
179
|
+
name: drizzle_orm_pg_core.PgColumn<{
|
|
178
180
|
name: "name";
|
|
179
181
|
tableName: "mfas";
|
|
180
182
|
dataType: "string";
|
|
@@ -186,7 +188,7 @@ export declare const authMFATable: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
186
188
|
enumValues: [string, ...string[]];
|
|
187
189
|
baseColumn: never;
|
|
188
190
|
}, {}, {}>;
|
|
189
|
-
userId:
|
|
191
|
+
userId: drizzle_orm_pg_core.PgColumn<{
|
|
190
192
|
name: "userId";
|
|
191
193
|
tableName: "mfas";
|
|
192
194
|
dataType: "string";
|
|
@@ -198,7 +200,7 @@ export declare const authMFATable: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
198
200
|
enumValues: [string, ...string[]];
|
|
199
201
|
baseColumn: never;
|
|
200
202
|
}, {}, {}>;
|
|
201
|
-
type:
|
|
203
|
+
type: drizzle_orm_pg_core.PgColumn<{
|
|
202
204
|
name: "type";
|
|
203
205
|
tableName: "mfas";
|
|
204
206
|
dataType: "string";
|
|
@@ -210,7 +212,7 @@ export declare const authMFATable: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
210
212
|
enumValues: ["TOTP", "HARDWARE"];
|
|
211
213
|
baseColumn: never;
|
|
212
214
|
}, {}, {}>;
|
|
213
|
-
secret:
|
|
215
|
+
secret: drizzle_orm_pg_core.PgColumn<{
|
|
214
216
|
name: "secret";
|
|
215
217
|
tableName: "mfas";
|
|
216
218
|
dataType: "string";
|
|
@@ -222,7 +224,7 @@ export declare const authMFATable: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
222
224
|
enumValues: [string, ...string[]];
|
|
223
225
|
baseColumn: never;
|
|
224
226
|
}, {}, {}>;
|
|
225
|
-
verifiedAt:
|
|
227
|
+
verifiedAt: drizzle_orm_pg_core.PgColumn<{
|
|
226
228
|
name: "verifiedAt";
|
|
227
229
|
tableName: "mfas";
|
|
228
230
|
dataType: "date";
|
|
@@ -237,12 +239,12 @@ export declare const authMFATable: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
237
239
|
};
|
|
238
240
|
dialect: "pg";
|
|
239
241
|
}>;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
type AuthMFA = typeof authMFATable.$inferSelect;
|
|
243
|
+
declare const authClientTable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
242
244
|
name: "client_credentials";
|
|
243
245
|
schema: "auth";
|
|
244
246
|
columns: {
|
|
245
|
-
id:
|
|
247
|
+
id: drizzle_orm_pg_core.PgColumn<{
|
|
246
248
|
name: "id";
|
|
247
249
|
tableName: "client_credentials";
|
|
248
250
|
dataType: "string";
|
|
@@ -254,7 +256,7 @@ export declare const authClientTable: import("drizzle-orm/pg-core").PgTableWithC
|
|
|
254
256
|
enumValues: [string, ...string[]];
|
|
255
257
|
baseColumn: never;
|
|
256
258
|
}, {}, {}>;
|
|
257
|
-
alias:
|
|
259
|
+
alias: drizzle_orm_pg_core.PgColumn<{
|
|
258
260
|
name: "alias";
|
|
259
261
|
tableName: "client_credentials";
|
|
260
262
|
dataType: "string";
|
|
@@ -266,7 +268,7 @@ export declare const authClientTable: import("drizzle-orm/pg-core").PgTableWithC
|
|
|
266
268
|
enumValues: [string, ...string[]];
|
|
267
269
|
baseColumn: never;
|
|
268
270
|
}, {}, {}>;
|
|
269
|
-
secret:
|
|
271
|
+
secret: drizzle_orm_pg_core.PgColumn<{
|
|
270
272
|
name: "secret";
|
|
271
273
|
tableName: "client_credentials";
|
|
272
274
|
dataType: "string";
|
|
@@ -281,4 +283,6 @@ export declare const authClientTable: import("drizzle-orm/pg-core").PgTableWithC
|
|
|
281
283
|
};
|
|
282
284
|
dialect: "pg";
|
|
283
285
|
}>;
|
|
284
|
-
|
|
286
|
+
type AuthClient = typeof authClientTable.$inferSelect;
|
|
287
|
+
|
|
288
|
+
export { type AuthClient, type AuthMFA, type AuthReset, type AuthSession, type AuthUser, type Scope, authClientTable, authMFATable, authResetTable, authSchema, authSessionTable, authUserTable, mfaType, scope };
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/database/schema.ts
|
|
20
|
+
var schema_exports = {};
|
|
21
|
+
__export(schema_exports, {
|
|
22
|
+
authClientTable: () => authClientTable,
|
|
23
|
+
authMFATable: () => authMFATable,
|
|
24
|
+
authResetTable: () => authResetTable,
|
|
25
|
+
authSchema: () => authSchema,
|
|
26
|
+
authSessionTable: () => authSessionTable,
|
|
27
|
+
authUserTable: () => authUserTable,
|
|
28
|
+
mfaType: () => mfaType,
|
|
29
|
+
scope: () => scope
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(schema_exports);
|
|
32
|
+
var import_pg_core = require("drizzle-orm/pg-core");
|
|
33
|
+
var DEFAULT_ROLE = 10;
|
|
34
|
+
var mfaType = (0, import_pg_core.pgEnum)("mfaType", ["TOTP", "HARDWARE"]);
|
|
35
|
+
var scope = (0, import_pg_core.pgEnum)("scope", ["ANON", "MFA", "AUTHED"]);
|
|
36
|
+
var authSchema = (0, import_pg_core.pgSchema)("auth");
|
|
37
|
+
var authUserTable = authSchema.table("user_credentials", {
|
|
38
|
+
id: (0, import_pg_core.text)("id").primaryKey(),
|
|
39
|
+
email: (0, import_pg_core.text)("email").notNull().unique(),
|
|
40
|
+
password: (0, import_pg_core.text)("password"),
|
|
41
|
+
role: (0, import_pg_core.integer)("role").notNull().default(DEFAULT_ROLE)
|
|
42
|
+
});
|
|
43
|
+
var authSessionTable = authSchema.table("sessions", {
|
|
44
|
+
id: (0, import_pg_core.text)("id").primaryKey(),
|
|
45
|
+
userId: (0, import_pg_core.text)("userId").notNull().references(() => authUserTable.id),
|
|
46
|
+
scope: scope("scope").notNull().default("ANON"),
|
|
47
|
+
expiresAt: (0, import_pg_core.timestamp)("expiresAt").notNull()
|
|
48
|
+
});
|
|
49
|
+
var authResetTable = authSchema.table("resets", {
|
|
50
|
+
id: (0, import_pg_core.text)("id").primaryKey(),
|
|
51
|
+
userId: (0, import_pg_core.text)("userId").notNull().references(() => authUserTable.id),
|
|
52
|
+
expiresAt: (0, import_pg_core.timestamp)("expiresAt").notNull()
|
|
53
|
+
});
|
|
54
|
+
var authMFATable = authSchema.table("mfas", {
|
|
55
|
+
id: (0, import_pg_core.text)("id").primaryKey(),
|
|
56
|
+
name: (0, import_pg_core.text)("name").notNull(),
|
|
57
|
+
userId: (0, import_pg_core.text)("userId").notNull().references(() => authUserTable.id),
|
|
58
|
+
type: mfaType("type").notNull().default("TOTP"),
|
|
59
|
+
secret: (0, import_pg_core.text)("secret").notNull(),
|
|
60
|
+
verifiedAt: (0, import_pg_core.timestamp)("verifiedAt")
|
|
61
|
+
});
|
|
62
|
+
var authClientTable = authSchema.table("client_credentials", {
|
|
63
|
+
id: (0, import_pg_core.text)("id").primaryKey(),
|
|
64
|
+
alias: (0, import_pg_core.text)("alias").notNull().unique(),
|
|
65
|
+
secret: (0, import_pg_core.text)("secret").notNull().unique()
|
|
66
|
+
});
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
authClientTable,
|
|
70
|
+
authMFATable,
|
|
71
|
+
authResetTable,
|
|
72
|
+
authSchema,
|
|
73
|
+
authSessionTable,
|
|
74
|
+
authUserTable,
|
|
75
|
+
mfaType,
|
|
76
|
+
scope
|
|
77
|
+
});
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* @returns The origin of the current request.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
declare function getOrigin(): string;
|
|
18
18
|
/**
|
|
19
19
|
* Builds a URL from the current origin and a given pathname. For more information on how the origin
|
|
20
20
|
* is determined, see the `getOrigin` function. This function then just concatenates the origin and
|
|
@@ -23,4 +23,6 @@ export declare function getOrigin(): string;
|
|
|
23
23
|
* @param pathname
|
|
24
24
|
* @returns The URL, with the origin and pathname combined.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
declare function getURL(pathname?: string): string;
|
|
27
|
+
|
|
28
|
+
export { getOrigin, getURL };
|
package/dist/url.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/url/index.ts
|
|
20
|
+
var url_exports = {};
|
|
21
|
+
__export(url_exports, {
|
|
22
|
+
getOrigin: () => getOrigin,
|
|
23
|
+
getURL: () => getURL
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(url_exports);
|
|
26
|
+
|
|
27
|
+
// src/url/URLService.ts
|
|
28
|
+
var import_headers = require("next/headers");
|
|
29
|
+
function getOrigin() {
|
|
30
|
+
const origin = (0, import_headers.headers)().get("x-origin");
|
|
31
|
+
if (origin) {
|
|
32
|
+
return origin;
|
|
33
|
+
}
|
|
34
|
+
const proto = (0, import_headers.headers)().get("x-forwarded-proto");
|
|
35
|
+
const host = (0, import_headers.headers)().get("x-forwarded-host");
|
|
36
|
+
if (proto && host) {
|
|
37
|
+
return `${proto}://${host}`;
|
|
38
|
+
}
|
|
39
|
+
throw new Error("No origin could be determined");
|
|
40
|
+
}
|
|
41
|
+
function getURL(pathname) {
|
|
42
|
+
const origin = getOrigin();
|
|
43
|
+
if (!pathname) {
|
|
44
|
+
return origin;
|
|
45
|
+
}
|
|
46
|
+
const isSecure = origin.startsWith("https://");
|
|
47
|
+
const protocol = isSecure ? "https://" : "http://";
|
|
48
|
+
const originWithoutProtocol = origin.replace(/^https?:\/\//u, "");
|
|
49
|
+
const cleanURL = `${originWithoutProtocol}/${pathname}`.replace(/\/+/gu, "/");
|
|
50
|
+
return `${protocol}${cleanURL}`;
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
getOrigin,
|
|
55
|
+
getURL
|
|
56
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqrzro/server",
|
|
3
|
-
"version": "2.0.0-bz.
|
|
3
|
+
"version": "2.0.0-bz.11",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "ISC",
|
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
"auth.js",
|
|
11
11
|
"cache.d.ts",
|
|
12
12
|
"cache.js",
|
|
13
|
-
"database.d.ts",
|
|
14
|
-
"database.js",
|
|
15
13
|
"forms.d.ts",
|
|
16
14
|
"forms.js",
|
|
17
15
|
"lists.d.ts",
|
|
@@ -30,16 +28,16 @@
|
|
|
30
28
|
"@sqrzro/interfaces": "bz",
|
|
31
29
|
"@sqrzro/utility": "bz",
|
|
32
30
|
"bcryptjs": "^2.4.3",
|
|
33
|
-
"drizzle-orm": "^0.29.
|
|
31
|
+
"drizzle-orm": "^0.29.5",
|
|
34
32
|
"joi": "^17.12.2",
|
|
35
33
|
"jsonwebtoken": "^9.0.2",
|
|
36
34
|
"lucia": "^3.0.1",
|
|
37
|
-
"next": "^14.
|
|
35
|
+
"next": "^14.1.3",
|
|
38
36
|
"otplib": "^12.0.1",
|
|
39
37
|
"path-to-regexp": "^6.2.1",
|
|
40
38
|
"postgres": "^3.4.3",
|
|
41
39
|
"qrcode": "^1.5.3",
|
|
42
|
-
"react-dom": "
|
|
40
|
+
"react-dom": "18.3.0-canary-98b8359f6-20240223",
|
|
43
41
|
"redis": "^4.6.13"
|
|
44
42
|
},
|
|
45
43
|
"devDependencies": {
|
|
@@ -48,17 +46,18 @@
|
|
|
48
46
|
"@types/bcryptjs": "^2.4.6",
|
|
49
47
|
"@types/jest": "^29.5.12",
|
|
50
48
|
"@types/qrcode": "^1.5.5",
|
|
51
|
-
"@types/react-dom": "^18.2.
|
|
52
|
-
"eslint": "^8.
|
|
49
|
+
"@types/react-dom": "^18.2.21",
|
|
50
|
+
"eslint": "^8.57.0",
|
|
53
51
|
"jest": "^29.7.0",
|
|
54
52
|
"prettier": "^3.2.5",
|
|
55
|
-
"rimraf": "^4.1
|
|
53
|
+
"rimraf": "^4.4.1",
|
|
56
54
|
"ts-jest": "^29.1.2",
|
|
57
55
|
"tslib": "^2.6.2",
|
|
58
|
-
"
|
|
56
|
+
"tsup": "^8.0.2",
|
|
57
|
+
"typescript": "^5.4.2"
|
|
59
58
|
},
|
|
60
59
|
"scripts": {
|
|
61
|
-
"build": "pnpm clean &&
|
|
60
|
+
"build": "pnpm clean && tsup --entry.auth src/auth/index.ts --entry.cache src/cache/index.ts --entry.forms src/forms/index.ts --entry.lists src/lists/index.ts --entry.mail src/mail/index.ts --entry.middleware src/middleware.ts --entry.schema src/database/schema.ts --entry.url src/url/index.ts --dts",
|
|
62
61
|
"clean": "rimraf ./dist",
|
|
63
62
|
"dev": "tsc -p tsconfig.build.json -w",
|
|
64
63
|
"lint": "tsc --noEmit && eslint \"./src/**/*.ts\"",
|
package/database.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/database/index';
|
package/database.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('./dist/database/index');
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Errorable } from '@sqrzro/interfaces';
|
|
2
|
-
import type { LoginFormFields, PasswordFormFields, PasswordResetFormFields, UserObject } from './interfaces';
|
|
3
|
-
export declare function handleLogout(): Promise<void>;
|
|
4
|
-
export declare function getAllowedRoles(): number[];
|
|
5
|
-
export declare function handleLoginForm(formData: LoginFormFields): Promise<Errorable<string>>;
|
|
6
|
-
interface RegisterUserArgs {
|
|
7
|
-
email: string;
|
|
8
|
-
password?: string;
|
|
9
|
-
role?: number;
|
|
10
|
-
}
|
|
11
|
-
export declare function registerUser({ email, password, role, }: RegisterUserArgs): Promise<UserObject | null>;
|
|
12
|
-
export declare function handlePasswordForm(formData: PasswordFormFields, mailFn: (email: string, token: string) => Promise<boolean>): Promise<Errorable<boolean>>;
|
|
13
|
-
export declare function handlePasswordResetForm(formData: PasswordResetFormFields): Promise<Errorable<string | null>>;
|
|
14
|
-
export {};
|