@sqrzro/server 4.0.0-alpha.30 → 4.0.0-alpha.31
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/chunk-BA3BC4CD.js +2 -0
- package/dist/chunk-BA3BC4CD.js.map +1 -0
- package/dist/database/index.d.ts +55 -93
- package/dist/database/index.js +1 -1
- package/dist/database/index.js.map +1 -1
- package/dist/forms/index.js +1 -1
- package/dist/forms/index.js.map +1 -1
- package/dist/mail/index.d.ts +6 -1
- package/dist/mail/index.js +2 -2
- package/dist/mail/index.js.map +1 -1
- package/dist/proxy/index.d.ts +1 -5
- package/dist/proxy/index.js +1 -1
- package/dist/proxy/index.js.map +1 -1
- package/dist/storage/index.d.ts +3 -1
- package/dist/storage/index.js +1 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/utility/index.d.ts +1 -1
- package/dist/utility/index.js +1 -1
- package/dist/utility/index.js.map +1 -1
- package/package.json +3 -27
- package/dist/auth/index.d.ts +0 -51
- package/dist/auth/index.js +0 -2
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/utility/schema.d.ts +0 -348
- package/dist/auth/utility/schema.js +0 -2
- package/dist/auth/utility/schema.js.map +0 -1
- package/dist/chunk-3A4JSFVE.js +0 -2
- package/dist/chunk-3A4JSFVE.js.map +0 -1
- package/dist/chunk-3JA7XHAG.js +0 -2
- package/dist/chunk-3JA7XHAG.js.map +0 -1
- package/dist/chunk-C2XLUXVN.js +0 -2
- package/dist/chunk-C2XLUXVN.js.map +0 -1
- package/dist/chunk-CESWDV42.js +0 -2
- package/dist/chunk-CESWDV42.js.map +0 -1
- package/dist/chunk-DOBAUBXG.js +0 -2
- package/dist/chunk-DOBAUBXG.js.map +0 -1
- package/dist/chunk-JI2U2EMD.js +0 -2
- package/dist/chunk-JI2U2EMD.js.map +0 -1
- package/dist/chunk-KC7SPWBL.js +0 -2
- package/dist/chunk-KC7SPWBL.js.map +0 -1
- package/dist/chunk-U27WABYY.js +0 -2
- package/dist/chunk-U27WABYY.js.map +0 -1
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +0 -3
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/scripts/db-generate.ts +0 -31
- package/dist/cli/scripts/db-reset.ts +0 -56
- package/dist/cli/scripts/db-seed.ts +0 -32
- package/dist/cli/static/drizzle.config.cjs +0 -19
- package/dist/interfaces-Gqu85VTW.d.ts +0 -7
package/dist/utility/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{b as ensureID,c as getIDFromParams,a as guardID}from'../chunk-BA3BC4CD.js';import {randomBytes}from'crypto';var i=16;function g(e,t=i){let r="abcdefghijklmnopqrstuvwxyz0123456789",n=randomBytes(t),s="";for(let o=0;o<t;o++)s+=r[n[o]%r.length];return `${e?e+"_":""}${s}`}var c=g;function d(e){return process.env.SZ_LOG==="true"?true:typeof process.env.SZ_LOG=="string"?process.env.SZ_LOG.split(",").includes(e):false}function p(e,t,r){d(e)&&console.log(`[${e}] ${t}: ${r}`);}var m=p;export{c as generateID,m as log};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/utility/generate-id.ts","../../src/utility/log.ts"],"names":["ID_LENGTH","generateID","prefix","length","chars","bytes","randomBytes","result","i","generate_id_default","shouldLog","alias","log","fnName","message","log_default"],"mappings":"mHAEA,IAAMA,EAAY,EAAA,CAElB,SAASC,EAAsCC,CAAAA,CAAwBC,CAAAA,CAASH,EAAc,CAC1F,IAAMI,EAAQ,sCAAA,CACRC,CAAAA,CAAQC,YAAYH,CAAM,CAAA,CAE5BI,EAAS,EAAA,CAEb,IAAA,IAASC,EAAI,CAAA,CAAGA,CAAAA,CAAIL,EAAQK,CAAAA,EAAAA,CACxBD,CAAAA,EAAUH,EAAMC,CAAAA,CAAMG,CAAC,EAAIJ,CAAAA,CAAM,MAAM,EAG3C,OAAO,CAAA,EAAGF,EAASA,CAAAA,CAAS,GAAA,CAAM,EAAE,CAAA,EAAGK,CAAM,CAAA,CACjD,CAEA,IAAOE,CAAAA,CAAQR,ECjBf,SAASS,CAAAA,CAAUC,EAAwB,CACvC,OAAI,QAAQ,GAAA,CAAI,MAAA,GAAW,OAChB,IAAA,CAGP,OAAO,QAAQ,GAAA,CAAI,MAAA,EAAW,SACX,OAAA,CAAQ,GAAA,CAAI,OAAO,KAAA,CAAM,GAAG,CAAA,CAC7B,QAAA,CAASA,CAAK,CAAA,CAG7B,KACX,CAEA,SAASC,EAAID,CAAAA,CAAeE,CAAAA,CAAgBC,EAAuB,CAC3DJ,CAAAA,CAAUC,CAAK,CAAA,EACf,OAAA,CAAQ,IAAI,CAAA,CAAA,EAAIA,CAAK,KAAKE,CAAM,CAAA,EAAA,EAAKC,CAAO,CAAA,CAAE,EAEtD,CAEA,IAAOC,CAAAA,CAAQH","file":"index.js","sourcesContent":["import { randomBytes } from 'crypto';\n\nconst ID_LENGTH = 16;\n\nfunction generateID<T extends string = string>(prefix?: string | null, length = ID_LENGTH): T {\n const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';\n const bytes = randomBytes(length);\n\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[bytes[i] % chars.length];\n }\n\n return `${prefix ? prefix + '_' : ''}${result}` as T;\n}\n\nexport default generateID;\n","function shouldLog(alias: string): boolean {\n if (process.env.SZ_LOG === 'true') {\n return true;\n }\n\n if (typeof process.env.SZ_LOG === 'string') {\n const logAliases = process.env.SZ_LOG.split(',');\n return logAliases.includes(alias);\n }\n\n return false;\n}\n\nfunction log(alias: string, fnName: string, message: string): void {\n if (shouldLog(alias)) {\n console.log(`[${alias}] ${fnName}: ${message}`); // eslint-disable-line no-console\n }\n}\n\nexport default log;\n"]}
|
package/package.json
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqrzro/server",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "ISC",
|
|
8
|
-
"bin": {
|
|
9
|
-
"szserver": "./dist/cli/index.js"
|
|
10
|
-
},
|
|
11
8
|
"exports": {
|
|
12
|
-
"./auth": {
|
|
13
|
-
"types": "./dist/auth/index.d.ts",
|
|
14
|
-
"default": "./dist/auth/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./auth/schema": {
|
|
17
|
-
"types": "./dist/auth/utility/schema.d.ts",
|
|
18
|
-
"default": "./dist/auth/utility/schema.js"
|
|
19
|
-
},
|
|
20
|
-
"./cli": {
|
|
21
|
-
"types": "./dist/cli/index.d.ts",
|
|
22
|
-
"default": "./dist/cli/index.js"
|
|
23
|
-
},
|
|
24
9
|
"./csv": {
|
|
25
10
|
"types": "./dist/csv/index.d.ts",
|
|
26
11
|
"default": "./dist/csv/index.js"
|
|
@@ -59,25 +44,16 @@
|
|
|
59
44
|
],
|
|
60
45
|
"dependencies": {
|
|
61
46
|
"@sendgrid/mail": "^8.1.6",
|
|
62
|
-
"bcryptjs": "^3.0.3",
|
|
63
|
-
"commander": "^14.0.3",
|
|
64
47
|
"csv": "^6.4.1",
|
|
65
|
-
"dotenv": "^17.3.1",
|
|
66
|
-
"drizzle-kit": "^0.31.9",
|
|
67
48
|
"drizzle-orm": "^0.45.1",
|
|
68
|
-
"joi": "^18.0.2",
|
|
69
49
|
"pg": "^8.19.0",
|
|
70
|
-
"qrcode": "^1.5.4",
|
|
71
50
|
"react-dom": "^19.2.4",
|
|
72
51
|
"redis": "^5.11.0",
|
|
73
|
-
"time2fa": "^1.4.2",
|
|
74
|
-
"tsx": "^4.21.0",
|
|
75
52
|
"zod": "^4.3.6",
|
|
76
|
-
"@sqrzro/utility": "^4.0.0-alpha.
|
|
53
|
+
"@sqrzro/utility": "^4.0.0-alpha.12"
|
|
77
54
|
},
|
|
78
55
|
"devDependencies": {
|
|
79
56
|
"@types/jest": "^29.5.14",
|
|
80
|
-
"@types/node": "^24.11.0",
|
|
81
57
|
"@types/pg": "^8.18.0",
|
|
82
58
|
"@types/react": "^19.2.14",
|
|
83
59
|
"@types/react-dom": "^19.2.3",
|
|
@@ -87,7 +63,7 @@
|
|
|
87
63
|
"ts-jest": "^29.4.6",
|
|
88
64
|
"tsup": "^8.5.1",
|
|
89
65
|
"typescript": "^5.9.3",
|
|
90
|
-
"@sqrzro/prettier-config": "^4.0.0-alpha.
|
|
66
|
+
"@sqrzro/prettier-config": "^4.0.0-alpha.3"
|
|
91
67
|
},
|
|
92
68
|
"peerDependencies": {
|
|
93
69
|
"next": "^16.1.6",
|
package/dist/auth/index.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { A as AuthSession } from '../interfaces-Gqu85VTW.js';
|
|
2
|
-
import { ResetType, AuthUserTable } from './utility/schema.js';
|
|
3
|
-
import { NextRequest } from 'next/server';
|
|
4
|
-
import { M as MakeNullOptional } from '../interfaces-DTUqy5Oj.js';
|
|
5
|
-
import 'drizzle-orm/pg-core';
|
|
6
|
-
|
|
7
|
-
interface MFAObject {
|
|
8
|
-
key: string;
|
|
9
|
-
url: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
declare function createMFA(name: string, email: string): Promise<MFAObject>;
|
|
13
|
-
|
|
14
|
-
declare function validateMFA(code: string): Promise<boolean>;
|
|
15
|
-
|
|
16
|
-
declare function updatePasswordWithPassword(): Promise<void>;
|
|
17
|
-
|
|
18
|
-
declare function updatePasswordWithToken(type: ResetType, token: string, newPassword: string): Promise<string>;
|
|
19
|
-
|
|
20
|
-
declare function createReset(type: ResetType, email: string, role?: number): Promise<string | null>;
|
|
21
|
-
|
|
22
|
-
declare function validateReset(type: ResetType, token: string): Promise<boolean>;
|
|
23
|
-
|
|
24
|
-
declare function createSession(userID: string, expiresIn?: number): Promise<void>;
|
|
25
|
-
|
|
26
|
-
declare function deleteSession(): Promise<void>;
|
|
27
|
-
|
|
28
|
-
declare function deleteUserSessions(): Promise<void>;
|
|
29
|
-
|
|
30
|
-
declare function uncached_validateSession(cookies?: NextRequest['cookies']): Promise<AuthSession | null>;
|
|
31
|
-
declare const validateSession: typeof uncached_validateSession;
|
|
32
|
-
|
|
33
|
-
type AuthUser = AuthUserTable;
|
|
34
|
-
type AuthUserDataWithID = MakeNullOptional<AuthUser>;
|
|
35
|
-
interface User {
|
|
36
|
-
email: string;
|
|
37
|
-
id: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
declare function createUser(data: AuthUserDataWithID): Promise<AuthUser | null>;
|
|
41
|
-
|
|
42
|
-
declare function deleteUser(): Promise<void>;
|
|
43
|
-
|
|
44
|
-
declare function ensureSessionUser(): Promise<User>;
|
|
45
|
-
|
|
46
|
-
declare function uncached_getSessionUser(): Promise<User | null>;
|
|
47
|
-
declare function getSessionUser(): ReturnType<typeof uncached_getSessionUser>;
|
|
48
|
-
|
|
49
|
-
declare function validateUser(email: string, password: string): Promise<string>;
|
|
50
|
-
|
|
51
|
-
export { AuthSession, createMFA, createReset, createSession, createUser, deleteSession, deleteUser, deleteUserSessions, ensureSessionUser, getSessionUser, updatePasswordWithPassword, updatePasswordWithToken, validateMFA, validateReset, validateSession, validateUser };
|
package/dist/auth/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export{a as createMFA,e as createReset,g as createSession,j as createUser,h as deleteSession,k as deleteUser,i as deleteUserSessions,c as updatePasswordWithPassword,d as updatePasswordWithToken,b as validateMFA,f as validateReset,l as validateUser}from'../chunk-U27WABYY.js';import'../chunk-CESWDV42.js';export{j as ensureSessionUser,i as getSessionUser,h as validateSession}from'../chunk-DOBAUBXG.js';import'../chunk-C2XLUXVN.js';import'../chunk-3A4JSFVE.js';import'../chunk-KC7SPWBL.js';import'../chunk-JI2U2EMD.js';import'../chunk-3JA7XHAG.js';//# sourceMappingURL=index.js.map
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/auth/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
|
|
2
|
-
|
|
3
|
-
declare const DEFAULT_ROLE = 10;
|
|
4
|
-
declare const mfaType: drizzle_orm_pg_core.PgEnum<["TOTP", "HARDWARE"]>;
|
|
5
|
-
declare const resetType: drizzle_orm_pg_core.PgEnum<["INVITE", "MFA", "PASSWORD"]>;
|
|
6
|
-
type MFAType = (typeof mfaType.enumValues)[number];
|
|
7
|
-
type ResetType = (typeof resetType.enumValues)[number];
|
|
8
|
-
declare const authSchema: drizzle_orm_pg_core.PgSchema<"auth">;
|
|
9
|
-
declare const authUserTable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
10
|
-
name: "user_credentials";
|
|
11
|
-
schema: "auth";
|
|
12
|
-
columns: {
|
|
13
|
-
id: drizzle_orm_pg_core.PgColumn<{
|
|
14
|
-
name: "id";
|
|
15
|
-
tableName: "user_credentials";
|
|
16
|
-
dataType: "string";
|
|
17
|
-
columnType: "PgText";
|
|
18
|
-
data: string;
|
|
19
|
-
driverParam: string;
|
|
20
|
-
notNull: true;
|
|
21
|
-
hasDefault: false;
|
|
22
|
-
isPrimaryKey: true;
|
|
23
|
-
isAutoincrement: false;
|
|
24
|
-
hasRuntimeDefault: false;
|
|
25
|
-
enumValues: [string, ...string[]];
|
|
26
|
-
baseColumn: never;
|
|
27
|
-
identity: undefined;
|
|
28
|
-
generated: undefined;
|
|
29
|
-
}, {}, {}>;
|
|
30
|
-
email: drizzle_orm_pg_core.PgColumn<{
|
|
31
|
-
name: "email";
|
|
32
|
-
tableName: "user_credentials";
|
|
33
|
-
dataType: "string";
|
|
34
|
-
columnType: "PgText";
|
|
35
|
-
data: string;
|
|
36
|
-
driverParam: string;
|
|
37
|
-
notNull: true;
|
|
38
|
-
hasDefault: false;
|
|
39
|
-
isPrimaryKey: false;
|
|
40
|
-
isAutoincrement: false;
|
|
41
|
-
hasRuntimeDefault: false;
|
|
42
|
-
enumValues: [string, ...string[]];
|
|
43
|
-
baseColumn: never;
|
|
44
|
-
identity: undefined;
|
|
45
|
-
generated: undefined;
|
|
46
|
-
}, {}, {}>;
|
|
47
|
-
password: drizzle_orm_pg_core.PgColumn<{
|
|
48
|
-
name: "password";
|
|
49
|
-
tableName: "user_credentials";
|
|
50
|
-
dataType: "string";
|
|
51
|
-
columnType: "PgText";
|
|
52
|
-
data: string;
|
|
53
|
-
driverParam: string;
|
|
54
|
-
notNull: false;
|
|
55
|
-
hasDefault: false;
|
|
56
|
-
isPrimaryKey: false;
|
|
57
|
-
isAutoincrement: false;
|
|
58
|
-
hasRuntimeDefault: false;
|
|
59
|
-
enumValues: [string, ...string[]];
|
|
60
|
-
baseColumn: never;
|
|
61
|
-
identity: undefined;
|
|
62
|
-
generated: undefined;
|
|
63
|
-
}, {}, {}>;
|
|
64
|
-
role: drizzle_orm_pg_core.PgColumn<{
|
|
65
|
-
name: "role";
|
|
66
|
-
tableName: "user_credentials";
|
|
67
|
-
dataType: "number";
|
|
68
|
-
columnType: "PgInteger";
|
|
69
|
-
data: number;
|
|
70
|
-
driverParam: string | number;
|
|
71
|
-
notNull: true;
|
|
72
|
-
hasDefault: true;
|
|
73
|
-
isPrimaryKey: false;
|
|
74
|
-
isAutoincrement: false;
|
|
75
|
-
hasRuntimeDefault: false;
|
|
76
|
-
enumValues: undefined;
|
|
77
|
-
baseColumn: never;
|
|
78
|
-
identity: undefined;
|
|
79
|
-
generated: undefined;
|
|
80
|
-
}, {}, {}>;
|
|
81
|
-
deletedAt: drizzle_orm_pg_core.PgColumn<{
|
|
82
|
-
name: "deletedAt";
|
|
83
|
-
tableName: "user_credentials";
|
|
84
|
-
dataType: "date";
|
|
85
|
-
columnType: "PgTimestamp";
|
|
86
|
-
data: Date;
|
|
87
|
-
driverParam: string;
|
|
88
|
-
notNull: false;
|
|
89
|
-
hasDefault: false;
|
|
90
|
-
isPrimaryKey: false;
|
|
91
|
-
isAutoincrement: false;
|
|
92
|
-
hasRuntimeDefault: false;
|
|
93
|
-
enumValues: undefined;
|
|
94
|
-
baseColumn: never;
|
|
95
|
-
identity: undefined;
|
|
96
|
-
generated: undefined;
|
|
97
|
-
}, {}, {}>;
|
|
98
|
-
};
|
|
99
|
-
dialect: "pg";
|
|
100
|
-
}>;
|
|
101
|
-
type AuthUserTable = typeof authUserTable.$inferSelect;
|
|
102
|
-
declare const authResetTable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
103
|
-
name: "resets";
|
|
104
|
-
schema: "auth";
|
|
105
|
-
columns: {
|
|
106
|
-
id: drizzle_orm_pg_core.PgColumn<{
|
|
107
|
-
name: "id";
|
|
108
|
-
tableName: "resets";
|
|
109
|
-
dataType: "string";
|
|
110
|
-
columnType: "PgText";
|
|
111
|
-
data: string;
|
|
112
|
-
driverParam: string;
|
|
113
|
-
notNull: true;
|
|
114
|
-
hasDefault: false;
|
|
115
|
-
isPrimaryKey: true;
|
|
116
|
-
isAutoincrement: false;
|
|
117
|
-
hasRuntimeDefault: false;
|
|
118
|
-
enumValues: [string, ...string[]];
|
|
119
|
-
baseColumn: never;
|
|
120
|
-
identity: undefined;
|
|
121
|
-
generated: undefined;
|
|
122
|
-
}, {}, {}>;
|
|
123
|
-
userID: drizzle_orm_pg_core.PgColumn<{
|
|
124
|
-
name: "userID";
|
|
125
|
-
tableName: "resets";
|
|
126
|
-
dataType: "string";
|
|
127
|
-
columnType: "PgText";
|
|
128
|
-
data: string;
|
|
129
|
-
driverParam: string;
|
|
130
|
-
notNull: true;
|
|
131
|
-
hasDefault: false;
|
|
132
|
-
isPrimaryKey: false;
|
|
133
|
-
isAutoincrement: false;
|
|
134
|
-
hasRuntimeDefault: false;
|
|
135
|
-
enumValues: [string, ...string[]];
|
|
136
|
-
baseColumn: never;
|
|
137
|
-
identity: undefined;
|
|
138
|
-
generated: undefined;
|
|
139
|
-
}, {}, {}>;
|
|
140
|
-
type: drizzle_orm_pg_core.PgColumn<{
|
|
141
|
-
name: "type";
|
|
142
|
-
tableName: "resets";
|
|
143
|
-
dataType: "string";
|
|
144
|
-
columnType: "PgEnumColumn";
|
|
145
|
-
data: "INVITE" | "MFA" | "PASSWORD";
|
|
146
|
-
driverParam: string;
|
|
147
|
-
notNull: true;
|
|
148
|
-
hasDefault: false;
|
|
149
|
-
isPrimaryKey: false;
|
|
150
|
-
isAutoincrement: false;
|
|
151
|
-
hasRuntimeDefault: false;
|
|
152
|
-
enumValues: ["INVITE", "MFA", "PASSWORD"];
|
|
153
|
-
baseColumn: never;
|
|
154
|
-
identity: undefined;
|
|
155
|
-
generated: undefined;
|
|
156
|
-
}, {}, {}>;
|
|
157
|
-
createdAt: drizzle_orm_pg_core.PgColumn<{
|
|
158
|
-
name: "createdAt";
|
|
159
|
-
tableName: "resets";
|
|
160
|
-
dataType: "date";
|
|
161
|
-
columnType: "PgTimestamp";
|
|
162
|
-
data: Date;
|
|
163
|
-
driverParam: string;
|
|
164
|
-
notNull: true;
|
|
165
|
-
hasDefault: true;
|
|
166
|
-
isPrimaryKey: false;
|
|
167
|
-
isAutoincrement: false;
|
|
168
|
-
hasRuntimeDefault: false;
|
|
169
|
-
enumValues: undefined;
|
|
170
|
-
baseColumn: never;
|
|
171
|
-
identity: undefined;
|
|
172
|
-
generated: undefined;
|
|
173
|
-
}, {}, {}>;
|
|
174
|
-
};
|
|
175
|
-
dialect: "pg";
|
|
176
|
-
}>;
|
|
177
|
-
type AuthResetTable = typeof authResetTable.$inferSelect;
|
|
178
|
-
declare const authMFATable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
179
|
-
name: "mfas";
|
|
180
|
-
schema: "auth";
|
|
181
|
-
columns: {
|
|
182
|
-
id: drizzle_orm_pg_core.PgColumn<{
|
|
183
|
-
name: "id";
|
|
184
|
-
tableName: "mfas";
|
|
185
|
-
dataType: "string";
|
|
186
|
-
columnType: "PgText";
|
|
187
|
-
data: string;
|
|
188
|
-
driverParam: string;
|
|
189
|
-
notNull: true;
|
|
190
|
-
hasDefault: false;
|
|
191
|
-
isPrimaryKey: true;
|
|
192
|
-
isAutoincrement: false;
|
|
193
|
-
hasRuntimeDefault: false;
|
|
194
|
-
enumValues: [string, ...string[]];
|
|
195
|
-
baseColumn: never;
|
|
196
|
-
identity: undefined;
|
|
197
|
-
generated: undefined;
|
|
198
|
-
}, {}, {}>;
|
|
199
|
-
name: drizzle_orm_pg_core.PgColumn<{
|
|
200
|
-
name: "name";
|
|
201
|
-
tableName: "mfas";
|
|
202
|
-
dataType: "string";
|
|
203
|
-
columnType: "PgText";
|
|
204
|
-
data: string;
|
|
205
|
-
driverParam: string;
|
|
206
|
-
notNull: true;
|
|
207
|
-
hasDefault: false;
|
|
208
|
-
isPrimaryKey: false;
|
|
209
|
-
isAutoincrement: false;
|
|
210
|
-
hasRuntimeDefault: false;
|
|
211
|
-
enumValues: [string, ...string[]];
|
|
212
|
-
baseColumn: never;
|
|
213
|
-
identity: undefined;
|
|
214
|
-
generated: undefined;
|
|
215
|
-
}, {}, {}>;
|
|
216
|
-
userID: drizzle_orm_pg_core.PgColumn<{
|
|
217
|
-
name: "userID";
|
|
218
|
-
tableName: "mfas";
|
|
219
|
-
dataType: "string";
|
|
220
|
-
columnType: "PgText";
|
|
221
|
-
data: string;
|
|
222
|
-
driverParam: string;
|
|
223
|
-
notNull: true;
|
|
224
|
-
hasDefault: false;
|
|
225
|
-
isPrimaryKey: false;
|
|
226
|
-
isAutoincrement: false;
|
|
227
|
-
hasRuntimeDefault: false;
|
|
228
|
-
enumValues: [string, ...string[]];
|
|
229
|
-
baseColumn: never;
|
|
230
|
-
identity: undefined;
|
|
231
|
-
generated: undefined;
|
|
232
|
-
}, {}, {}>;
|
|
233
|
-
type: drizzle_orm_pg_core.PgColumn<{
|
|
234
|
-
name: "type";
|
|
235
|
-
tableName: "mfas";
|
|
236
|
-
dataType: "string";
|
|
237
|
-
columnType: "PgEnumColumn";
|
|
238
|
-
data: "TOTP" | "HARDWARE";
|
|
239
|
-
driverParam: string;
|
|
240
|
-
notNull: true;
|
|
241
|
-
hasDefault: true;
|
|
242
|
-
isPrimaryKey: false;
|
|
243
|
-
isAutoincrement: false;
|
|
244
|
-
hasRuntimeDefault: false;
|
|
245
|
-
enumValues: ["TOTP", "HARDWARE"];
|
|
246
|
-
baseColumn: never;
|
|
247
|
-
identity: undefined;
|
|
248
|
-
generated: undefined;
|
|
249
|
-
}, {}, {}>;
|
|
250
|
-
secret: drizzle_orm_pg_core.PgColumn<{
|
|
251
|
-
name: "secret";
|
|
252
|
-
tableName: "mfas";
|
|
253
|
-
dataType: "string";
|
|
254
|
-
columnType: "PgText";
|
|
255
|
-
data: string;
|
|
256
|
-
driverParam: string;
|
|
257
|
-
notNull: true;
|
|
258
|
-
hasDefault: false;
|
|
259
|
-
isPrimaryKey: false;
|
|
260
|
-
isAutoincrement: false;
|
|
261
|
-
hasRuntimeDefault: false;
|
|
262
|
-
enumValues: [string, ...string[]];
|
|
263
|
-
baseColumn: never;
|
|
264
|
-
identity: undefined;
|
|
265
|
-
generated: undefined;
|
|
266
|
-
}, {}, {}>;
|
|
267
|
-
verifiedAt: drizzle_orm_pg_core.PgColumn<{
|
|
268
|
-
name: "verifiedAt";
|
|
269
|
-
tableName: "mfas";
|
|
270
|
-
dataType: "date";
|
|
271
|
-
columnType: "PgTimestamp";
|
|
272
|
-
data: Date;
|
|
273
|
-
driverParam: string;
|
|
274
|
-
notNull: false;
|
|
275
|
-
hasDefault: false;
|
|
276
|
-
isPrimaryKey: false;
|
|
277
|
-
isAutoincrement: false;
|
|
278
|
-
hasRuntimeDefault: false;
|
|
279
|
-
enumValues: undefined;
|
|
280
|
-
baseColumn: never;
|
|
281
|
-
identity: undefined;
|
|
282
|
-
generated: undefined;
|
|
283
|
-
}, {}, {}>;
|
|
284
|
-
};
|
|
285
|
-
dialect: "pg";
|
|
286
|
-
}>;
|
|
287
|
-
type AuthMFATable = typeof authMFATable.$inferSelect;
|
|
288
|
-
declare const authClientTable: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
289
|
-
name: "client_credentials";
|
|
290
|
-
schema: "auth";
|
|
291
|
-
columns: {
|
|
292
|
-
id: drizzle_orm_pg_core.PgColumn<{
|
|
293
|
-
name: "id";
|
|
294
|
-
tableName: "client_credentials";
|
|
295
|
-
dataType: "string";
|
|
296
|
-
columnType: "PgText";
|
|
297
|
-
data: string;
|
|
298
|
-
driverParam: string;
|
|
299
|
-
notNull: true;
|
|
300
|
-
hasDefault: false;
|
|
301
|
-
isPrimaryKey: true;
|
|
302
|
-
isAutoincrement: false;
|
|
303
|
-
hasRuntimeDefault: false;
|
|
304
|
-
enumValues: [string, ...string[]];
|
|
305
|
-
baseColumn: never;
|
|
306
|
-
identity: undefined;
|
|
307
|
-
generated: undefined;
|
|
308
|
-
}, {}, {}>;
|
|
309
|
-
alias: drizzle_orm_pg_core.PgColumn<{
|
|
310
|
-
name: "alias";
|
|
311
|
-
tableName: "client_credentials";
|
|
312
|
-
dataType: "string";
|
|
313
|
-
columnType: "PgText";
|
|
314
|
-
data: string;
|
|
315
|
-
driverParam: string;
|
|
316
|
-
notNull: true;
|
|
317
|
-
hasDefault: false;
|
|
318
|
-
isPrimaryKey: false;
|
|
319
|
-
isAutoincrement: false;
|
|
320
|
-
hasRuntimeDefault: false;
|
|
321
|
-
enumValues: [string, ...string[]];
|
|
322
|
-
baseColumn: never;
|
|
323
|
-
identity: undefined;
|
|
324
|
-
generated: undefined;
|
|
325
|
-
}, {}, {}>;
|
|
326
|
-
secret: drizzle_orm_pg_core.PgColumn<{
|
|
327
|
-
name: "secret";
|
|
328
|
-
tableName: "client_credentials";
|
|
329
|
-
dataType: "string";
|
|
330
|
-
columnType: "PgText";
|
|
331
|
-
data: string;
|
|
332
|
-
driverParam: string;
|
|
333
|
-
notNull: true;
|
|
334
|
-
hasDefault: false;
|
|
335
|
-
isPrimaryKey: false;
|
|
336
|
-
isAutoincrement: false;
|
|
337
|
-
hasRuntimeDefault: false;
|
|
338
|
-
enumValues: [string, ...string[]];
|
|
339
|
-
baseColumn: never;
|
|
340
|
-
identity: undefined;
|
|
341
|
-
generated: undefined;
|
|
342
|
-
}, {}, {}>;
|
|
343
|
-
};
|
|
344
|
-
dialect: "pg";
|
|
345
|
-
}>;
|
|
346
|
-
type AuthClientTable = typeof authClientTable.$inferSelect;
|
|
347
|
-
|
|
348
|
-
export { type AuthClientTable, type AuthMFATable, type AuthResetTable, type AuthUserTable, DEFAULT_ROLE, type MFAType, type ResetType, authClientTable, authMFATable, authResetTable, authSchema, authUserTable, mfaType, resetType };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"schema.js"}
|
package/dist/chunk-3A4JSFVE.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {filterNull}from'@sqrzro/utility';function i(n,t){return Array.isArray(n)?filterNull(n.map(r=>i(r,t))):n?.startsWith(t)?n:null}var e=i;function l(n,t){let r=e(n,t);if(!r)throw new Error(`Could not ensure ID. '${n}' is not a valid ID with prefix '${t}'.`);return r}var a=l;async function d(n,t,r){if(!r)return null;let u=r instanceof Promise?await r:r;return e(u[n],t)}var m=d;export{e as a,a as b,m as c};//# sourceMappingURL=chunk-3A4JSFVE.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-3A4JSFVE.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utility/guard-id.ts","../src/utility/ensure-id.ts","../src/utility/get-id-from-params.ts"],"names":["guardID","id","prefix","filterNull","item","guard_id_default","ensureID","guardedID","ensure_id_default","getIDFromParams","key","params","awaitedParams","get_id_from_params_default"],"mappings":"yCAKA,SAASA,CAAAA,CACLC,CAAAA,CACAC,EACc,CACd,OAAI,MAAM,OAAA,CAAQD,CAAE,EACTE,UAAAA,CAAWF,CAAAA,CAAG,IAAKG,CAAAA,EAASJ,CAAAA,CAAWI,EAAMF,CAAM,CAAC,CAAC,CAAA,CAG3DD,GAAI,UAAA,CAAWC,CAAM,EAInBD,CAAAA,CAHI,IAIf,CAEA,IAAOI,CAAAA,CAAQL,EClBf,SAASM,CAAAA,CAA2BL,EAA+BC,CAAAA,CAAmB,CAClF,IAAMK,CAAAA,CAAYF,CAAAA,CAAWJ,EAAIC,CAAM,CAAA,CAEvC,GAAI,CAACK,EACD,MAAM,IAAI,MAAM,CAAA,sBAAA,EAAyBN,CAAE,oCAAoCC,CAAM,CAAA,EAAA,CAAI,EAG7F,OAAOK,CACX,CAEA,IAAOC,CAAAA,CAAQF,ECVf,eAAeG,CAAAA,CACXC,EACAR,CAAAA,CACAS,CAAAA,CACiB,CACjB,GAAI,CAACA,EACD,OAAO,IAAA,CAGX,IAAMC,CAAAA,CAAgBD,CAAAA,YAAkB,QAAU,MAAMA,CAAAA,CAASA,EACjE,OAAON,CAAAA,CAAWO,EAAcF,CAAG,CAAA,CAAGR,CAAM,CAChD,KAEOW,CAAAA,CAAQJ","file":"chunk-3A4JSFVE.js","sourcesContent":["import { filterNull } from '@sqrzro/utility';\n\nfunction guardID<T extends string>(id: (string | null | undefined)[], prefix: string): T[];\nfunction guardID<T extends string>(id: string | null | undefined, prefix: string): T | null;\n\nfunction guardID<T extends string>(\n id: (string | null | undefined)[] | string | null | undefined,\n prefix: string\n): T[] | T | null {\n if (Array.isArray(id)) {\n return filterNull(id.map((item) => guardID<T>(item, prefix)));\n }\n\n if (!id?.startsWith(prefix)) {\n return null;\n }\n\n return id as T;\n}\n\nexport default guardID;\n","import guardID from './guard-id';\n\nfunction ensureID<T extends string>(id: string | null | undefined, prefix: string): T {\n const guardedID = guardID<T>(id, prefix);\n\n if (!guardedID) {\n throw new Error(`Could not ensure ID. '${id}' is not a valid ID with prefix '${prefix}'.`);\n }\n\n return guardedID;\n}\n\nexport default ensureID;\n","import guardID from './guard-id';\n\nasync function getIDFromParams<T extends string>(\n key: string,\n prefix: string,\n params?: Promise<Record<string, string>> | Record<string, string> | null\n): Promise<T | null> {\n if (!params) {\n return null;\n }\n\n const awaitedParams = params instanceof Promise ? await params : params;\n return guardID<T>(awaitedParams[key], prefix);\n}\n\nexport default getIDFromParams;\n"]}
|
package/dist/chunk-3JA7XHAG.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/forms/ValidationError.ts"],"names":["ValidationError","messages","ValidationError_default"],"mappings":"AAMA,IAAMA,CAAAA,CAAN,cAA8B,KAAM,CACzB,SAEA,WAAA,CAAYC,CAAAA,CAAkC,CACjD,KAAA,CAAM,IAAA,CAAK,SAAA,CAAUA,CAAQ,CAAC,CAAA,CAE9B,KAAK,QAAA,CAAWA,CAAAA,CAChB,KAAK,IAAA,CAAO,kBAChB,CACJ,CAAA,CAEOC,CAAAA,CAAQF","file":"chunk-3JA7XHAG.js","sourcesContent":["/**\n * Custom error class to represent validation errors in form processing.\n * \n * It extends the built-in Error class and includes a messages property\n * that holds a record of validation error messages.\n */\nclass ValidationError extends Error {\n public messages: Record<string, string>;\n\n public constructor(messages: Record<string, string>) {\n super(JSON.stringify(messages));\n\n this.messages = messages;\n this.name = 'ValidationError';\n }\n}\n\nexport default ValidationError;\n"]}
|
package/dist/chunk-C2XLUXVN.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a}from'./chunk-KC7SPWBL.js';import {createClient}from'redis';var i=null;async function o(){if(!process.env.REDIS_URL)throw new Error("REDIS_URL is not defined. Access to the cache is not possible.");return i||(i=createClient({url:process.env.REDIS_URL}),await i.connect(),i)}var n=o;var c={async getItem(t,r){let e=await(await n()).get(`[${t}]:${r}`);if(!e)return null;try{return JSON.parse(e)}catch{return null}},async getArray(t,r){return await(await n()).sMembers(`[${t}]:${r}`)},async addToArray(t,r,e){await(await n()).sAdd(`[${t}]:${r}`,e);},async removeFromArray(t,r,e){await(await n()).sRem(`[${t}]:${r}`,e);},async setItem(t,r,e){a("[storage]","setItem",`[${t}]:${r} - {${JSON.stringify(e)}}`),await(await n()).set(`[${t}]:${r}`,JSON.stringify(e));},async removeItem(t,r){a("[storage]","removeItem",`[${t}]:${r}`),await(await n()).del(`[${t}]:${r}`);}},w=c;export{w as a};//# sourceMappingURL=chunk-C2XLUXVN.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-C2XLUXVN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/storage/utility/get-client.ts","../src/storage/index.ts"],"names":["client","getClient","createClient","get_client_default","serverStorage","prefix","key","value","log_default","storage_default"],"mappings":"qEAIA,IAAIA,EAAiD,IAAA,CAQrD,eAAeC,GAAsD,CACjE,GAAI,CAAC,OAAA,CAAQ,GAAA,CAAI,UACb,MAAM,IAAI,MAAM,gEAAgE,CAAA,CAGpF,OAAID,CAAAA,GAIJA,CAAAA,CAASE,YAAAA,CAAa,CAClB,GAAA,CAAK,OAAA,CAAQ,IAAI,SACrB,CAAC,EAED,MAAMF,CAAAA,CAAO,SAAQ,CACdA,CAAAA,CACX,CAEA,IAAOG,CAAAA,CAAQF,ECtBf,IAAMG,CAAAA,CAAgB,CAOlB,MAAM,OAAA,CAAQC,CAAAA,CAAgBC,CAAAA,CAAsD,CAChF,IAAMC,EAAQ,KAAA,CAAO,MAAMJ,GAAU,EAAG,GAAA,CAAI,IAAIE,CAAM,CAAA,EAAA,EAAKC,CAAG,CAAA,CAAE,CAAA,CAEhE,GAAI,CAACC,CAAAA,CACD,OAAO,IAAA,CAGX,GAAI,CACA,OAAO,IAAA,CAAK,KAAA,CAAMA,CAAK,CAC3B,CAAA,KAAQ,CACJ,OAAO,IACX,CACJ,CAAA,CAEA,MAAM,SAASF,CAAAA,CAAgBC,CAAAA,CAAgC,CAE3D,OADe,KAAA,CAAO,MAAMH,CAAAA,EAAU,EAAG,SAAS,CAAA,CAAA,EAAIE,CAAM,KAAKC,CAAG,CAAA,CAAE,CAE1E,CAAA,CAEA,MAAM,UAAA,CAAWD,EAAgBC,CAAAA,CAAaC,CAAAA,CAA8B,CACxE,KAAA,CAAO,MAAMJ,GAAU,EAAG,IAAA,CAAK,IAAIE,CAAM,CAAA,EAAA,EAAKC,CAAG,CAAA,CAAA,CAAIC,CAAK,EAC9D,CAAA,CAEA,MAAM,gBAAgBF,CAAAA,CAAgBC,CAAAA,CAAaC,CAAAA,CAA8B,CAC7E,KAAA,CAAO,MAAMJ,GAAU,EAAG,IAAA,CAAK,IAAIE,CAAM,CAAA,EAAA,EAAKC,CAAG,CAAA,CAAA,CAAIC,CAAK,EAC9D,CAAA,CAQA,MAAM,QAAQF,CAAAA,CAAgBC,CAAAA,CAAaC,EAA+C,CACtFC,CAAAA,CAAI,YAAa,SAAA,CAAW,CAAA,CAAA,EAAIH,CAAM,CAAA,EAAA,EAAKC,CAAG,CAAA,IAAA,EAAO,KAAK,SAAA,CAAUC,CAAK,CAAC,CAAA,CAAA,CAAG,CAAA,CAC7E,MAAO,MAAMJ,CAAAA,IAAa,GAAA,CAAI,CAAA,CAAA,EAAIE,CAAM,CAAA,EAAA,EAAKC,CAAG,GAAI,IAAA,CAAK,SAAA,CAAUC,CAAK,CAAC,EAC7E,CAAA,CAOA,MAAM,UAAA,CAAWF,CAAAA,CAAgBC,EAA4B,CACzDE,CAAAA,CAAI,YAAa,YAAA,CAAc,CAAA,CAAA,EAAIH,CAAM,CAAA,EAAA,EAAKC,CAAG,CAAA,CAAE,CAAA,CACnD,KAAA,CAAO,MAAMH,GAAU,EAAG,GAAA,CAAI,IAAIE,CAAM,CAAA,EAAA,EAAKC,CAAG,CAAA,CAAE,EACtD,CACJ,CAAA,CAEOG,CAAAA,CAAQL","file":"chunk-C2XLUXVN.js","sourcesContent":["import { createClient } from 'redis';\n\nimport isLocalhost from './is-localhost.js';\n\nlet client: ReturnType<typeof createClient> | null = null;\n\n/**\n * Get a Redis client instance. If the client does not exist, it creates a new one and connects to the Redis server.\n * If the client already exists, it returns the existing instance.\n *\n * @returns A promise that resolves to a Redis client instance.\n */\nasync function getClient(): Promise<ReturnType<typeof createClient>> {\n if (!process.env.REDIS_URL) {\n throw new Error('REDIS_URL is not defined. Access to the cache is not possible.');\n }\n\n if (client) {\n return client;\n }\n\n client = createClient({\n url: process.env.REDIS_URL,\n });\n\n await client.connect();\n return client;\n}\n\nexport default getClient;\n","import log from '../utility/log';\n\nimport getClient from './utility/get-client';\n\n/**\n * Server-side storage utility for caching data using Redis. It is designed to match the interface of localStorage, but operates on the server side.\n */\nconst serverStorage = {\n /**\n * Get an item from the cache.\n * @param prefix The prefix to use for the cache key.\n * @param key The key of the item to retrieve.\n * @returns The cached item, or null if not found.\n */\n async getItem(prefix: string, key: string): Promise<Record<string, unknown> | null> {\n const value = await (await getClient()).get(`[${prefix}]:${key}`);\n\n if (!value) {\n return null;\n }\n\n try {\n return JSON.parse(value);\n } catch {\n return null;\n }\n },\n\n async getArray(prefix: string, key: string): Promise<string[]> {\n const values = await (await getClient()).sMembers(`[${prefix}]:${key}`);\n return values;\n },\n\n async addToArray(prefix: string, key: string, value: string): Promise<void> {\n await (await getClient()).sAdd(`[${prefix}]:${key}`, value);\n },\n\n async removeFromArray(prefix: string, key: string, value: string): Promise<void> {\n await (await getClient()).sRem(`[${prefix}]:${key}`, value);\n },\n\n /**\n * Set an item in the cache.\n * @param prefix The prefix to use for the cache key.\n * @param key The key of the item to set.\n * @param value The value of the item to set.\n */\n async setItem(prefix: string, key: string, value: Record<string, unknown>): Promise<void> {\n log('[storage]', 'setItem', `[${prefix}]:${key} - {${JSON.stringify(value)}}`);\n await (await getClient()).set(`[${prefix}]:${key}`, JSON.stringify(value));\n },\n\n /**\n * Remove an item from the cache.\n * @param prefix The prefix to use for the cache key.\n * @param key The key of the item to remove.\n */\n async removeItem(prefix: string, key: string): Promise<void> {\n log('[storage]', 'removeItem', `[${prefix}]:${key}`);\n await (await getClient()).del(`[${prefix}]:${key}`);\n },\n};\n\nexport default serverStorage;\n"]}
|
package/dist/chunk-CESWDV42.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {randomBytes}from'crypto';var f=16;function l(e,r=f){let o="abcdefghijklmnopqrstuvwxyz0123456789",s=randomBytes(r),a="";for(let t=0;t<r;t++)a+=o[s[t]%o.length];return `${e?e+"_":""}${a}`}var u=l;export{u as a};//# sourceMappingURL=chunk-CESWDV42.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-CESWDV42.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utility/generate-id.ts"],"names":["ID_LENGTH","generateID","prefix","length","chars","bytes","randomBytes","result","i","generate_id_default"],"mappings":"iCAEA,IAAMA,EAAY,EAAA,CAElB,SAASC,EAAsCC,CAAAA,CAAwBC,CAAAA,CAASH,EAAc,CAC1F,IAAMI,EAAQ,sCAAA,CACRC,CAAAA,CAAQC,YAAYH,CAAM,CAAA,CAE5BI,CAAAA,CAAS,EAAA,CAEb,IAAA,IAASC,CAAAA,CAAI,EAAGA,CAAAA,CAAIL,CAAAA,CAAQK,IACxBD,CAAAA,EAAUH,CAAAA,CAAMC,EAAMG,CAAC,CAAA,CAAIJ,EAAM,MAAM,CAAA,CAG3C,OAAO,CAAA,EAAGF,CAAAA,CAASA,EAAS,GAAA,CAAM,EAAE,GAAGK,CAAM,CAAA,CACjD,CAEA,IAAOE,CAAAA,CAAQR","file":"chunk-CESWDV42.js","sourcesContent":["import { randomBytes } from 'crypto';\n\nconst ID_LENGTH = 16;\n\nfunction generateID<T extends string = string>(prefix?: string | null, length = ID_LENGTH): T {\n const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';\n const bytes = randomBytes(length);\n\n let result = '';\n\n for (let i = 0; i < length; i++) {\n result += chars[bytes[i] % chars.length];\n }\n\n return `${prefix ? prefix + '_' : ''}${result}` as T;\n}\n\nexport default generateID;\n"]}
|
package/dist/chunk-DOBAUBXG.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-C2XLUXVN.js';import {a}from'./chunk-KC7SPWBL.js';import {e}from'./chunk-JI2U2EMD.js';import R from'bcryptjs';import {cache}from'react';import {cookies}from'next/headers';import {and,eq,isNull}from'drizzle-orm';import {drizzle}from'drizzle-orm/node-postgres';function g(){let s=process.env.AUTH_ROLE;if(!s)throw new Error("AUTH_ROLE environment variable is not set.");let e=parseInt(s,10);if(isNaN(e))throw new Error("AUTH_ROLE environment variable is not a valid number.");return e}var u=g;var l=process.env.AUTH_COOKIE_NAME??"session",C=process.env.AUTH_INVITE_EXPIRY_HOURS?Number(process.env.AUTH_INVITE_EXPIRY_HOURS):24,X=process.env.AUTH_RESET_EXPIRY_HOURS?Number(process.env.AUTH_RESET_EXPIRY_HOURS):2;async function y(s){let e=(s??await cookies()).get(l)?.value;if(!e)return null;let o=e.split(".");if(o.length!==2)return null;let[t,n]=o;return {id:t,secret:n}}var m=y;function _(s){let{expires:e,secret:o,userID:t}=s;if(typeof e!="string"||typeof o!="string"||typeof t!="string")return null;let n=new Date(e);return isNaN(n.getTime())?null:{expires:n,secret:o,userID:t}}var f=_;async function I(s){a("[auth:session]","validateSession","Validating session...");let e=await m(s);if(!e)return a("[auth:session]","validateSession","No session cookie found"),null;a("[auth:session]","validateSession",`Session cookie found with ID: ${e.id}`);let o=u(),t=await a$1.getItem("session",e.id);return t?.role!==o?(a("[auth:session]","validateSession",`Session role ${t?.role} does not match expected role ${o}`),null):typeof t?.secret!="string"?(a("[auth:session]","validateSession","Session secret is not a string"),null):await R.compare(e.secret,t.secret)?f(t):(a("[auth:session]","validateSession","Session secret does not match"),null)}var v=cache(I),c=v;var p=drizzle(process.env.DATABASE_URL??"");async function w(s,e$1,o){let t=o??u();return (await p.select().from(e).where(and(eq(e[s],e$1),eq(e.role,t),isNull(e.deletedAt))).limit(1))[0]??null}var U=w;async function H(s,e){return U("id",s,e)}var S=H;async function b(){a("[auth:users]","getSessionUser","Attempting to retrieve session user...");let s=await c();if(!s)return a("[auth:users]","getSessionUser","No valid session found"),null;a("[auth:users]","getSessionUser",`Valid session found for user ID: ${s.userID}`);let e=await S(s.userID);return e?(a("[auth:users]","getSessionUser",`User found for session user ID: ${e.id}`),{email:e.email,id:e.id}):(a("[auth:users]","getSessionUser",`No user found for session user ID: ${s.userID}`),null)}async function k(){return cache(b)()}var h=k;async function D(){let s=await h();if(!s)throw new Error("Could not ensure session user. No session user found.");return s}var ce=D;export{p as a,u as b,U as c,l as d,C as e,X as f,m as g,c as h,h as i,ce as j};//# sourceMappingURL=chunk-DOBAUBXG.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-DOBAUBXG.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auth/utility/ensure-role.ts","../src/auth/utility/config.ts","../src/auth/sessions/utility/get-session-cookie.ts","../src/auth/sessions/utility/parse-session.ts","../src/auth/sessions/validate-session.ts","../src/utility/db.ts","../src/auth/users/utility/get-user-by.ts","../src/auth/users/utility/get-user-by-id.ts","../src/auth/users/get-session-user.ts","../src/auth/users/ensure-session-user.ts"],"names":["ensureRole","role","roleNumber","ensure_role_default","AUTH_COOKIE_NAME","AUTH_INVITE_EXPIRY_HOURS","AUTH_RESET_EXPIRY_HOURS","getSessionCookie","cookies","cookie","cookieFn","parts","id","secret","get_session_cookie_default","parseSession","session","expires","userID","expiresDate","parse_session_default","uncached_validateSession","log_default","storage_default","bcrypt","validateSession","cache","validate_session_default","db_default","drizzle","getUserBy","key","value","userRole","authUserTable","and","eq","isNull","get_user_by_default","getUserByID","get_user_by_id_default","uncached_getSessionUser","authUser","getSessionUser","get_session_user_default","ensureSessionUser","user","ensure_session_user_default"],"mappings":"gSAAA,SAASA,CAAAA,EAAqB,CAC1B,IAAMC,CAAAA,CAAO,OAAA,CAAQ,IAAI,SAAA,CAEzB,GAAI,CAACA,CAAAA,CACD,MAAM,IAAI,MAAM,4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LpB,CAAAA,CAAI,cAAA,CAAgB,gBAAA,CAAkB,mCAAmCoB,CAAAA,CAAS,EAAE,CAAA,CAAE,CAAA,CAE/E,CACH,KAAA,CAAOA,EAAS,KAAA,CAChB,EAAA,CAAIA,CAAAA,CAAS,EACjB,CAAA,GAbIpB,CAAAA,CACI,eACA,gBAAA,CACA,CAAA,mCAAA,EAAsCN,CAAAA,CAAQ,MAAM,CAAA,CACxD,CAAA,CACO,KASf,CAEA,eAAe2B,CAAAA,EAA6D,CACxE,OAAOjB,KAAAA,CAAMe,CAAuB,CAAA,EACxC,CAEA,IAAOG,CAAAA,CAAQD,ECzCf,eAAeE,CAAAA,EAAmC,CAC9C,IAAMC,CAAAA,CAAO,MAAMF,CAAAA,GAEnB,GAAI,CAACE,CAAAA,CACD,MAAM,IAAI,KAAA,CAAM,uDAAuD,CAAA,CAG3E,OAAOA,CACX,CAEA,IAAOC,EAAAA,CAAQF","file":"chunk-DOBAUBXG.js","sourcesContent":["function ensureRole(): number {\n const role = process.env.AUTH_ROLE;\n\n if (!role) {\n throw new Error('AUTH_ROLE environment variable is not set.');\n }\n\n const roleNumber = parseInt(role, 10);\n\n if (isNaN(roleNumber)) {\n throw new Error('AUTH_ROLE environment variable is not a valid number.');\n }\n\n return roleNumber;\n}\n\nexport default ensureRole;\n","export const AUTH_COOKIE_NAME = process.env.AUTH_COOKIE_NAME ?? 'session';\n\nexport const AUTH_INVITE_EXPIRY_HOURS = process.env.AUTH_INVITE_EXPIRY_HOURS\n ? Number(process.env.AUTH_INVITE_EXPIRY_HOURS)\n : 24;\n\nexport const AUTH_RESET_EXPIRY_HOURS = process.env.AUTH_RESET_EXPIRY_HOURS\n ? Number(process.env.AUTH_RESET_EXPIRY_HOURS)\n : 2;\n","import { cookies as cookieFn } from 'next/headers';\nimport { NextRequest } from 'next/server';\n\nimport { AUTH_COOKIE_NAME } from '../../utility/config';\n\nimport type { AuthSessionCookie } from './interfaces';\n\nasync function getSessionCookie(\n cookies?: NextRequest['cookies']\n): Promise<AuthSessionCookie | null> {\n const cookie = (cookies ?? (await cookieFn())).get(AUTH_COOKIE_NAME)?.value;\n\n if (!cookie) {\n return null;\n }\n\n const parts = cookie.split('.');\n\n if (parts.length !== 2) {\n return null;\n }\n\n const [id, secret] = parts;\n return { id, secret };\n}\n\nexport default getSessionCookie;\n","import type { AuthSession } from './interfaces';\n\nfunction parseSession(session: Record<string, unknown>): AuthSession | null {\n const { expires, secret, userID } = session;\n\n if (typeof expires !== 'string' || typeof secret !== 'string' || typeof userID !== 'string') {\n return null;\n }\n\n const expiresDate = new Date(expires);\n\n if (isNaN(expiresDate.getTime())) {\n return null;\n }\n\n return {\n expires: expiresDate,\n secret,\n userID,\n };\n}\n\nexport default parseSession;\n","import bcrypt from 'bcryptjs';\nimport { NextRequest } from 'next/server';\nimport { cache } from 'react';\n\nimport serverStorage from '../../storage';\nimport log from '../../utility/log';\n\nimport ensureRole from '../utility/ensure-role';\nimport getSessionCookie from './utility/get-session-cookie';\nimport type { AuthSession } from './utility/interfaces';\nimport parseSession from './utility/parse-session';\n\nasync function uncached_validateSession(\n cookies?: NextRequest['cookies']\n): Promise<AuthSession | null> {\n log('[auth:session]', 'validateSession', 'Validating session...');\n\n const cookie = await getSessionCookie(cookies);\n\n if (!cookie) {\n log('[auth:session]', 'validateSession', 'No session cookie found');\n return null;\n }\n\n log('[auth:session]', 'validateSession', `Session cookie found with ID: ${cookie.id}`);\n\n const role = ensureRole();\n const session = await serverStorage.getItem('session', cookie.id);\n\n if (session?.role !== role) {\n log(\n '[auth:session]',\n 'validateSession',\n `Session role ${session?.role} does not match expected role ${role}`\n );\n return null;\n }\n\n if (typeof session?.secret !== 'string') {\n log('[auth:session]', 'validateSession', 'Session secret is not a string');\n return null;\n }\n\n if (!(await bcrypt.compare(cookie.secret, session.secret))) {\n log('[auth:session]', 'validateSession', 'Session secret does not match');\n return null;\n }\n\n return parseSession(session);\n}\n\nconst validateSession = cache(uncached_validateSession);\n\nexport default validateSession;\n","import { drizzle } from 'drizzle-orm/node-postgres';\n\nexport default drizzle(process.env.DATABASE_URL ?? '');\n","import { and, eq, isNull } from 'drizzle-orm';\n\nimport db from '../../../utility/db';\n\nimport ensureRole from '../../utility/ensure-role';\nimport { authUserTable } from '../../utility/schema';\nimport type { AuthUserTable } from '../../utility/schema';\n\nimport type { AuthUser } from './interfaces';\n\nasync function getUserBy(\n key: keyof AuthUserTable,\n value: string,\n role?: number\n): Promise<AuthUser | null> {\n const userRole = role ?? ensureRole();\n\n const results = await db\n .select()\n .from(authUserTable)\n .where(\n and(\n eq(authUserTable[key], value),\n eq(authUserTable.role, userRole),\n isNull(authUserTable.deletedAt)\n )\n )\n .limit(1);\n\n return results[0] ?? null;\n}\n\nexport default getUserBy;\n","import getUserBy from './get-user-by';\nimport type { AuthUser } from './interfaces';\n\nasync function getUserByID(id: string, role?: number): Promise<AuthUser | null> {\n return getUserBy('id', id, role);\n}\n\nexport default getUserByID;\n","import { cache } from 'react';\n\nimport log from '../../utility/log';\n\nimport validateSession from '../sessions/validate-session';\n\nimport getUserByID from './utility/get-user-by-id';\nimport type { User } from './utility/interfaces';\n\nasync function uncached_getSessionUser(): Promise<User | null> {\n log('[auth:users]', 'getSessionUser', 'Attempting to retrieve session user...');\n\n const session = await validateSession();\n\n if (!session) {\n log('[auth:users]', 'getSessionUser', 'No valid session found');\n return null;\n }\n\n log('[auth:users]', 'getSessionUser', `Valid session found for user ID: ${session.userID}`);\n\n const authUser = await getUserByID(session.userID);\n\n if (!authUser) {\n log(\n '[auth:users]',\n 'getSessionUser',\n `No user found for session user ID: ${session.userID}`\n );\n return null;\n }\n\n log('[auth:users]', 'getSessionUser', `User found for session user ID: ${authUser.id}`);\n\n return {\n email: authUser.email,\n id: authUser.id,\n };\n}\n\nasync function getSessionUser(): ReturnType<typeof uncached_getSessionUser> {\n return cache(uncached_getSessionUser)();\n}\n\nexport default getSessionUser;\n","import getSessionUser from './get-session-user';\nimport type { User } from './utility/interfaces';\n\nasync function ensureSessionUser(): Promise<User> {\n const user = await getSessionUser();\n\n if (!user) {\n throw new Error('Could not ensure session user. No session user found.');\n }\n\n return user;\n}\n\nexport default ensureSessionUser;\n"]}
|
package/dist/chunk-JI2U2EMD.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {sql}from'drizzle-orm';import {pgEnum,pgSchema,timestamp,integer,text}from'drizzle-orm/pg-core';var u=10,n=pgEnum("mfaType",["TOTP","HARDWARE"]),i=pgEnum("resetType",["INVITE","MFA","PASSWORD"]),t=pgSchema("auth"),a=t.table("user_credentials",{id:text("id").primaryKey(),email:text("email").notNull(),password:text("password"),role:integer("role").notNull().default(u),deletedAt:timestamp("deletedAt")}),T=t.table("resets",{id:text("id").primaryKey(),userID:text("userID").notNull().references(()=>a.id,{onDelete:"cascade"}),type:i("type").notNull(),createdAt:timestamp("createdAt").notNull().default(sql`CURRENT_TIMESTAMP`)}),d=t.table("mfas",{id:text("id").primaryKey(),name:text("name").notNull(),userID:text("userID").notNull().references(()=>a.id,{onDelete:"cascade"}),type:n("type").notNull().default("TOTP"),secret:text("secret").notNull(),verifiedAt:timestamp("verifiedAt")}),m=t.table("client_credentials",{id:text("id").primaryKey(),alias:text("alias").notNull().unique(),secret:text("secret").notNull().unique()});export{u as a,n as b,i as c,t as d,a as e,T as f,d as g,m as h};//# sourceMappingURL=chunk-JI2U2EMD.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-JI2U2EMD.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auth/utility/schema.ts"],"names":["DEFAULT_ROLE","mfaType","pgEnum","resetType","authSchema","pgSchema","authUserTable","text","integer","timestamp","authResetTable","sql","authMFATable","authClientTable"],"mappings":"uGAKO,IAAMA,EAAe,EAAA,CAEfC,CAAAA,CAAUC,MAAAA,CAAO,SAAA,CAAW,CAAC,MAAA,CAAQ,UAAU,CAAC,CAAA,CAChDC,EAAYD,MAAAA,CAAO,WAAA,CAAa,CAAC,QA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AE,OAAA,GACvB,UAAA,CAAYE,SAAAA,CAAU,YAAY,CACtC,CAAC,CAAA,CAIYI,CAAAA,CAAkBT,CAAAA,CAAW,KAAA,CAAM,qBAAsB,CAClE,EAAA,CAAIG,KAAK,IAAI,CAAA,CAAE,YAAW,CAC1B,KAAA,CAAOA,IAAAA,CAAK,OAAO,CAAA,CAAE,OAAA,GAAU,MAAA,EAAO,CACtC,OAAQA,IAAAA,CAAK,QAAQ,EAAE,OAAA,EAAQ,CAAE,MAAA,EACrC,CAAC","file":"chunk-JI2U2EMD.js","sourcesContent":["/* istanbul ignore file */\n\nimport { sql } from 'drizzle-orm';\nimport { integer, pgEnum, pgSchema, text, timestamp } from 'drizzle-orm/pg-core';\n\nexport const DEFAULT_ROLE = 10;\n\nexport const mfaType = pgEnum('mfaType', ['TOTP', 'HARDWARE']);\nexport const resetType = pgEnum('resetType', ['INVITE', 'MFA', 'PASSWORD']);\n\nexport type MFAType = (typeof mfaType.enumValues)[number];\nexport type ResetType = (typeof resetType.enumValues)[number];\n\nexport const authSchema = pgSchema('auth');\n\nexport const authUserTable = authSchema.table('user_credentials', {\n id: text('id').primaryKey(),\n email: text('email').notNull(),\n password: text('password'),\n role: integer('role').notNull().default(DEFAULT_ROLE),\n deletedAt: timestamp('deletedAt'),\n});\n\nexport type AuthUserTable = typeof authUserTable.$inferSelect;\n\nexport const authResetTable = authSchema.table('resets', {\n id: text('id').primaryKey(),\n userID: text('userID')\n .notNull()\n .references(() => authUserTable.id, { onDelete: 'cascade' }),\n type: resetType('type').notNull(),\n createdAt: timestamp('createdAt')\n .notNull()\n .default(sql`CURRENT_TIMESTAMP`),\n});\n\nexport type AuthResetTable = typeof authResetTable.$inferSelect;\n\nexport const authMFATable = authSchema.table('mfas', {\n id: text('id').primaryKey(),\n name: text('name').notNull(),\n userID: text('userID')\n .notNull()\n .references(() => authUserTable.id, { onDelete: 'cascade' }),\n type: mfaType('type').notNull().default('TOTP'),\n secret: text('secret').notNull(),\n verifiedAt: timestamp('verifiedAt'),\n});\n\nexport type AuthMFATable = typeof authMFATable.$inferSelect;\n\nexport const authClientTable = authSchema.table('client_credentials', {\n id: text('id').primaryKey(),\n alias: text('alias').notNull().unique(),\n secret: text('secret').notNull().unique(),\n});\n\nexport type AuthClientTable = typeof authClientTable.$inferSelect;\n"]}
|
package/dist/chunk-KC7SPWBL.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function o(e){return process.env.SZ_LOG==="true"?true:typeof process.env.SZ_LOG=="string"?process.env.SZ_LOG.split(",").includes(e):false}function r(e,s,n){o(e)&&console.log(`[${e}] ${s}: ${n}`);}var t=r;export{t as a};//# sourceMappingURL=chunk-KC7SPWBL.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-KC7SPWBL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utility/log.ts"],"names":["shouldLog","alias","log","fnName","message","log_default"],"mappings":"AAAA,SAASA,CAAAA,CAAUC,EAAwB,CACvC,OAAI,QAAQ,GAAA,CAAI,MAAA,GAAW,OAChB,IAAA,CAGP,OAAO,QAAQ,GAAA,CAAI,MAAA,EAAW,SACX,OAAA,CAAQ,GAAA,CAAI,OAAO,KAAA,CAAM,GAAG,CAAA,CAC7B,QAAA,CAASA,CAAK,CAAA,CAG7B,KACX,CAEA,SAASC,EAAID,CAAAA,CAAeE,CAAAA,CAAgBC,EAAuB,CAC3DJ,CAAAA,CAAUC,CAAK,CAAA,EACf,OAAA,CAAQ,IAAI,CAAA,CAAA,EAAIA,CAAK,KAAKE,CAAM,CAAA,EAAA,EAAKC,CAAO,CAAA,CAAE,EAEtD,CAEA,IAAOC,CAAAA,CAAQH","file":"chunk-KC7SPWBL.js","sourcesContent":["function shouldLog(alias: string): boolean {\n if (process.env.SZ_LOG === 'true') {\n return true;\n }\n\n if (typeof process.env.SZ_LOG === 'string') {\n const logAliases = process.env.SZ_LOG.split(',');\n return logAliases.includes(alias);\n }\n\n return false;\n}\n\nfunction log(alias: string, fnName: string, message: string): void {\n if (shouldLog(alias)) {\n console.log(`[${alias}] ${fnName}: ${message}`); // eslint-disable-line no-console\n }\n}\n\nexport default log;\n"]}
|
package/dist/chunk-U27WABYY.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-CESWDV42.js';import {a,j,b,d,g as g$1,c,f as f$2,e as e$1}from'./chunk-DOBAUBXG.js';import {a as a$3}from'./chunk-C2XLUXVN.js';import {a as a$2}from'./chunk-KC7SPWBL.js';import {g,e,f as f$1}from'./chunk-JI2U2EMD.js';import {a as a$4}from'./chunk-3JA7XHAG.js';import {and,eq,isNull,gte}from'drizzle-orm';import N from'qrcode';import {Totp}from'time2fa';import Z from'bcryptjs';import {cookies}from'next/headers';async function M(e,t){return c("email",e,t)}var f=M;async function q(e,t){if(!t)throw new Error("Email is required to generate MFA secret.");let o=await f(t);if(!o)throw new Error("User not found. Cannot generate MFA secret.");let r=Totp.generateKey({issuer:e,user:t});return await a.delete(g).where(and(eq(g.userID,o.id),isNull(g.verifiedAt))),await a.insert(g).values({id:a$1(),name:"Default",secret:r.secret,userID:o.id}),new Promise((a,c)=>{N.toDataURL(r.url,{rendererOpts:{quality:1},margin:0,scale:6},(u,F)=>{u&&c(u),a({key:r.secret,url:F});});})}var B=q;async function K(e){let t=await j(),[o]=await a.select().from(g).where(eq(g.userID,t.id)).limit(1);return o?Totp.validate({passcode:e,secret:o.secret}):false}var L=K;function V(){throw new Error("Function not implemented.")}var X=V;async function Y(e,t){await a.delete(f$1).where(and(eq(f$1.userID,t),eq(f$1.type,e)));}var R=Y;var J={INVITE:e$1,MFA:f$2,PASSWORD:f$2};async function Q(e$1,t){let o=b(),r=new Date;r.setHours(r.getHours()-J[e$1]);let a$1=await a.select().from(f$1).innerJoin(e,and(eq(e.id,f$1.userID),eq(e.role,o),isNull(e.deletedAt))).where(and(eq(f$1.id,t),eq(f$1.type,e$1),gte(f$1.createdAt,r))).limit(1);return a$1[0]?{...a$1[0].resets,user:a$1[0].user_credentials}:null}var A=Q;var ee=12;async function te(e){return Z.hash(e,ee)}var p=te;async function oe(e$1,t,o){let r=await A(e$1,t);if(!r)throw new Error("RESET_TOKEN_INVALID");return await a.update(e).set({password:await p(o)}).where(eq(e.id,r.userID)),await R(e$1,r.userID),r.userID}var se=oe;var ie=48;async function ae(e,t,o){let r=await f(t,o);if(!r)return null;await R(e,r.id);let a$2=a$1(null,ie);return await a.insert(f$1).values({createdAt:new Date,id:a$2,type:e,userID:r.id}),a$2}var ne=ae;async function me(e,t){return !!await A(e,t)}var ue=me;function fe(){let e="abcdefghijkmnpqrstuvwxyz23456789",t=new Uint8Array(24);crypto.getRandomValues(t);let o="";for(let r=0;r<t.length;r++)o+=e[t[r]>>3];return o}var E=fe;var le=24,de=3600*1e3;async function ce(e,t=le){a$2("auth:session","createSession",`Creating session for user ${e} with expiration of ${t} hours`);let o=b();a$2("auth:session","createSession",`Assigned role ${o} to session for user ${e}`);let r=E(),a=E(),c=`${r}.${a}`,u=new Date(Date.now()+t*de);await a$3.setItem("session",r,{expires:u,role:o,secret:await p(a),userID:e}),a$2("auth:session","createSession",`Set session ID ${r} and secret for user ${e} (role ${o}) in storage with expiration at ${u.toISOString()}`),(await cookies()).set(d,c,{expires:u,httpOnly:true,path:"/",sameSite:"lax",secure:true}),a$2("auth:session","createSession",`Set cookie '${d}' for user ${e} with token ${c} and expiration at ${u.toISOString()}`);}var we=ce;async function ye(){let e=await g$1();e&&(await a$3.removeItem("session",e.id),(await cookies()).delete(d));}var ge=ye;function Re(){throw new Error("Function not implemented.")}var Se=Re;async function Ae(e$1){let[t]=await a.insert(e).values({...e$1,password:e$1.password?await p(e$1.password):null}).returning();return t??null}var Ue=Ae;function xe(){throw new Error("Function not implemented.")}var Ee=xe;async function be(e,t){let o=await f(e);if(!o?.password||!await Z.compare(t,o.password))throw new a$4({email:"",password:""});return o.id}var Ie=be;export{B as a,L as b,X as c,se as d,ne as e,ue as f,we as g,ge as h,Se as i,Ue as j,Ee as k,Ie as l};//# sourceMappingURL=chunk-U27WABYY.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-U27WABYY.js.map
|