sa2kit 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/llm/ui/miniapp/index.d.mts +2 -2
- package/dist/ai/llm/ui/miniapp/index.d.ts +2 -2
- package/dist/ai/llm/ui/rn/index.d.mts +2 -2
- package/dist/ai/llm/ui/rn/index.d.ts +2 -2
- package/dist/ai/llm/ui/web/index.d.mts +3 -3
- package/dist/ai/llm/ui/web/index.d.ts +3 -3
- package/dist/analytics/index.d.mts +1 -1
- package/dist/analytics/index.d.ts +1 -1
- package/dist/{chunk-QP5N3ER6.js → chunk-3CSCIRQY.js} +5 -6
- package/dist/chunk-3CSCIRQY.js.map +1 -0
- package/dist/{chunk-RJP2BRJD.mjs → chunk-4OOANEJV.mjs} +2 -2
- package/dist/{chunk-RJP2BRJD.mjs.map → chunk-4OOANEJV.mjs.map} +1 -1
- package/dist/chunk-5FUAQLGC.mjs +14 -0
- package/dist/chunk-5FUAQLGC.mjs.map +1 -0
- package/dist/{chunk-S732H246.js → chunk-6PMXAK7F.js} +2 -2
- package/dist/{chunk-S732H246.js.map → chunk-6PMXAK7F.js.map} +1 -1
- package/dist/chunk-6YLCRWKM.mjs +8 -0
- package/dist/chunk-6YLCRWKM.mjs.map +1 -0
- package/dist/{chunk-IBWDBBX5.mjs → chunk-7B5SI4OF.mjs} +3 -4
- package/dist/chunk-7B5SI4OF.mjs.map +1 -0
- package/dist/chunk-EQXPL7TN.mjs +78 -0
- package/dist/chunk-EQXPL7TN.mjs.map +1 -0
- package/dist/{chunk-GQZHGSRR.js → chunk-GSNGCENJ.js} +39 -2
- package/dist/chunk-GSNGCENJ.js.map +1 -0
- package/dist/chunk-HQLKOXG7.js +16 -0
- package/dist/chunk-HQLKOXG7.js.map +1 -0
- package/dist/{chunk-S3PUP7N4.js → chunk-PA4ELVGI.js} +2 -2
- package/dist/{chunk-S3PUP7N4.js.map → chunk-PA4ELVGI.js.map} +1 -1
- package/dist/{chunk-WZDTNDYR.js → chunk-QSKLQX6H.js} +11 -11
- package/dist/{chunk-WZDTNDYR.js.map → chunk-QSKLQX6H.js.map} +1 -1
- package/dist/{chunk-LHJKLUM7.mjs → chunk-TNJ6LYX7.mjs} +2 -2
- package/dist/{chunk-LHJKLUM7.mjs.map → chunk-TNJ6LYX7.mjs.map} +1 -1
- package/dist/{chunk-J77KR2EV.mjs → chunk-WJ7IMUEJ.mjs} +3 -3
- package/dist/{chunk-J77KR2EV.mjs.map → chunk-WJ7IMUEJ.mjs.map} +1 -1
- package/dist/chunk-YTGUIRRH.js +10 -0
- package/dist/chunk-YTGUIRRH.js.map +1 -0
- package/dist/common/auth/client/index.d.mts +1 -31
- package/dist/common/auth/client/index.d.ts +1 -31
- package/dist/common/auth/client/index.js +2 -15
- package/dist/common/auth/client/index.mjs +1 -2
- package/dist/common/auth/components/index.d.mts +14 -248
- package/dist/common/auth/components/index.d.ts +14 -248
- package/dist/common/auth/components/index.js +878 -49
- package/dist/common/auth/components/index.js.map +1 -1
- package/dist/common/auth/components/index.mjs +871 -5
- package/dist/common/auth/components/index.mjs.map +1 -1
- package/dist/common/auth/hooks/index.d.mts +2 -29
- package/dist/common/auth/hooks/index.d.ts +2 -29
- package/dist/common/auth/hooks/index.js +2 -11
- package/dist/common/auth/hooks/index.mjs +1 -2
- package/dist/common/auth/index.d.mts +5 -9
- package/dist/common/auth/index.d.ts +5 -9
- package/dist/common/auth/index.js +7 -28
- package/dist/common/auth/index.mjs +3 -4
- package/dist/common/auth/react/index.d.mts +3 -3
- package/dist/common/auth/react/index.d.ts +3 -3
- package/dist/common/auth/rn/index.d.mts +3 -19
- package/dist/common/auth/rn/index.d.ts +3 -19
- package/dist/common/auth/rn/index.js +0 -32
- package/dist/common/auth/rn/index.js.map +1 -1
- package/dist/common/auth/rn/index.mjs +1 -30
- package/dist/common/auth/rn/index.mjs.map +1 -1
- package/dist/common/auth/server/index.d.mts +81 -2
- package/dist/common/auth/server/index.d.ts +81 -2
- package/dist/common/auth/server/index.js +128 -37
- package/dist/common/auth/server/index.js.map +1 -1
- package/dist/common/auth/server/index.mjs +124 -1
- package/dist/common/auth/server/index.mjs.map +1 -1
- package/dist/common/auth/services/index.js +12 -9
- package/dist/common/auth/services/index.js.map +1 -1
- package/dist/common/auth/services/index.mjs +10 -1
- package/dist/common/auth/services/index.mjs.map +1 -1
- package/dist/common/file/server/index.js +32 -32
- package/dist/common/file/server/index.mjs +3 -3
- package/dist/common/index.d.mts +5 -8
- package/dist/common/index.d.ts +5 -8
- package/dist/common/index.js +12 -14
- package/dist/common/index.mjs +6 -8
- package/dist/common/request/index.js +4 -5
- package/dist/common/request/index.mjs +2 -3
- package/dist/i18n/index.d.mts +1 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/imageCrop/index.d.mts +3 -3
- package/dist/imageCrop/index.d.ts +3 -3
- package/dist/index-Bd7cKF1j.d.mts +50 -0
- package/dist/{index-CLB80GCP.d.ts → index-D0cqaQEH.d.mts} +5 -5
- package/dist/{index-CLB80GCP.d.mts → index-D0cqaQEH.d.ts} +5 -5
- package/dist/index-DRQxtCDw.d.ts +50 -0
- package/dist/{index-BxZauNN_.d.mts → index-DoUo8IrU.d.mts} +8 -8
- package/dist/{index-BxZauNN_.d.ts → index-DoUo8IrU.d.ts} +8 -8
- package/dist/index.d.mts +152 -131
- package/dist/index.d.ts +152 -131
- package/dist/index.js +105 -554
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -555
- package/dist/index.mjs.map +1 -1
- package/dist/ossFile/server/index.js +32 -32
- package/dist/ossFile/server/index.mjs +3 -3
- package/dist/request/index.js +3 -4
- package/dist/request/index.mjs +1 -2
- package/dist/universalExport/index.d.mts +3 -3
- package/dist/universalExport/index.d.ts +3 -3
- package/dist/universalFile/index.d.mts +5 -5
- package/dist/universalFile/index.d.ts +5 -5
- package/dist/universalFile/server/index.js +62 -62
- package/dist/universalFile/server/index.mjs +2 -2
- package/package.json +1 -36
- package/dist/auth/client/index.d.mts +0 -13
- package/dist/auth/client/index.d.ts +0 -13
- package/dist/auth/client/index.js +0 -26
- package/dist/auth/client/index.js.map +0 -1
- package/dist/auth/client/index.mjs +0 -5
- package/dist/auth/client/index.mjs.map +0 -1
- package/dist/auth/components/index.d.mts +0 -10
- package/dist/auth/components/index.d.ts +0 -10
- package/dist/auth/components/index.js +0 -70
- package/dist/auth/components/index.js.map +0 -1
- package/dist/auth/components/index.mjs +0 -9
- package/dist/auth/components/index.mjs.map +0 -1
- package/dist/auth/hooks/index.d.mts +0 -13
- package/dist/auth/hooks/index.d.ts +0 -13
- package/dist/auth/hooks/index.js +0 -28
- package/dist/auth/hooks/index.js.map +0 -1
- package/dist/auth/hooks/index.mjs +0 -7
- package/dist/auth/hooks/index.mjs.map +0 -1
- package/dist/auth/index.d.mts +0 -21
- package/dist/auth/index.d.ts +0 -21
- package/dist/auth/index.js +0 -112
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/index.mjs +0 -11
- package/dist/auth/index.mjs.map +0 -1
- package/dist/auth/rn/index.d.mts +0 -3133
- package/dist/auth/rn/index.d.ts +0 -3133
- package/dist/auth/rn/index.js +0 -684
- package/dist/auth/rn/index.js.map +0 -1
- package/dist/auth/rn/index.mjs +0 -663
- package/dist/auth/rn/index.mjs.map +0 -1
- package/dist/auth/schema/index.d.mts +0 -4
- package/dist/auth/schema/index.d.ts +0 -4
- package/dist/auth/schema/index.js +0 -49
- package/dist/auth/schema/index.js.map +0 -1
- package/dist/auth/schema/index.mjs +0 -4
- package/dist/auth/schema/index.mjs.map +0 -1
- package/dist/auth/services/index.d.mts +0 -1
- package/dist/auth/services/index.d.ts +0 -1
- package/dist/auth/services/index.js +0 -17
- package/dist/auth/services/index.js.map +0 -1
- package/dist/auth/services/index.mjs +0 -4
- package/dist/auth/services/index.mjs.map +0 -1
- package/dist/base-api-client-BpmcQt4Q.d.ts +0 -103
- package/dist/base-api-client-CFIhZK4C.d.mts +0 -277
- package/dist/base-api-client-CFIhZK4C.d.ts +0 -277
- package/dist/base-api-client-DXLsq2yz.d.mts +0 -103
- package/dist/chunk-7E3J7VAD.mjs +0 -3
- package/dist/chunk-7E3J7VAD.mjs.map +0 -1
- package/dist/chunk-B3CZ3HXJ.mjs +0 -126
- package/dist/chunk-B3CZ3HXJ.mjs.map +0 -1
- package/dist/chunk-FOQEQWX5.js +0 -4
- package/dist/chunk-FOQEQWX5.js.map +0 -1
- package/dist/chunk-G4NFB2QA.mjs +0 -212
- package/dist/chunk-G4NFB2QA.mjs.map +0 -1
- package/dist/chunk-G5HJGXGC.mjs +0 -39
- package/dist/chunk-G5HJGXGC.mjs.map +0 -1
- package/dist/chunk-GQZHGSRR.js.map +0 -1
- package/dist/chunk-GS7XLKET.js +0 -41
- package/dist/chunk-GS7XLKET.js.map +0 -1
- package/dist/chunk-IBWDBBX5.mjs.map +0 -1
- package/dist/chunk-MWSAH7ZG.mjs +0 -42
- package/dist/chunk-MWSAH7ZG.mjs.map +0 -1
- package/dist/chunk-MZOGYD4N.mjs +0 -186
- package/dist/chunk-MZOGYD4N.mjs.map +0 -1
- package/dist/chunk-QDUBO567.js +0 -1148
- package/dist/chunk-QDUBO567.js.map +0 -1
- package/dist/chunk-QP5N3ER6.js.map +0 -1
- package/dist/chunk-RWCD2CAD.mjs +0 -1132
- package/dist/chunk-RWCD2CAD.mjs.map +0 -1
- package/dist/chunk-S37OK2QG.js +0 -216
- package/dist/chunk-S37OK2QG.js.map +0 -1
- package/dist/chunk-SFDJNKWC.js +0 -22
- package/dist/chunk-SFDJNKWC.js.map +0 -1
- package/dist/chunk-TXMX6PZR.js +0 -190
- package/dist/chunk-TXMX6PZR.js.map +0 -1
- package/dist/chunk-VHN7PF5I.js +0 -20
- package/dist/chunk-VHN7PF5I.js.map +0 -1
- package/dist/chunk-XBZIS3MV.mjs +0 -13
- package/dist/chunk-XBZIS3MV.mjs.map +0 -1
- package/dist/chunk-XFOZ56FB.mjs +0 -20
- package/dist/chunk-XFOZ56FB.mjs.map +0 -1
- package/dist/chunk-Z23HAXHL.js +0 -136
- package/dist/chunk-Z23HAXHL.js.map +0 -1
- package/dist/index-BcjDRcKp.d.mts +0 -40
- package/dist/index-BlpXrrTy.d.ts +0 -40
- package/dist/session-BCXvGCnm.d.mts +0 -81
- package/dist/session-BCXvGCnm.d.ts +0 -81
- package/dist/types-C_W_CoUD.d.ts +0 -99
- package/dist/types-DCRvasyH.d.mts +0 -99
- package/dist/types.legacy-J-j-_ig_.d.mts +0 -25
- package/dist/types.legacy-J-j-_ig_.d.ts +0 -25
|
@@ -1,47 +1,129 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var chunkZ23HAXHL_js = require('../../../chunk-Z23HAXHL.js');
|
|
4
3
|
var chunkLGHUCQIU_js = require('../../../chunk-LGHUCQIU.js');
|
|
5
4
|
require('../../../chunk-NSBPE2FW.js');
|
|
5
|
+
var betterAuth = require('better-auth');
|
|
6
|
+
var drizzleAdapter = require('@better-auth/drizzle-adapter');
|
|
7
|
+
var plugins = require('better-auth/plugins');
|
|
8
|
+
var nextJs = require('better-auth/next-js');
|
|
6
9
|
|
|
10
|
+
// src/common/auth/server/plugins/dev-otp.ts
|
|
11
|
+
function createDevOtpLogger(enabled) {
|
|
12
|
+
if (!enabled || process.env.NODE_ENV === "production") {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
return (channel, target, code) => {
|
|
16
|
+
console.info(`[sa2kit/auth][dev-otp][${channel}] ${target} => ${code}`);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
var defaultPhoneValidator = (phoneNumber2) => /^1\d{10}$/.test(phoneNumber2);
|
|
20
|
+
var defaultTempEmailFromPhone = (phoneNumber2) => `${phoneNumber2.replace(/\D/g, "")}@phone.sa2kit.local`;
|
|
7
21
|
|
|
22
|
+
// src/common/auth/server/create-auth.ts
|
|
23
|
+
function createSa2kitAuth(config) {
|
|
24
|
+
if (!config.secret || config.secret.length < 32) {
|
|
25
|
+
throw new Error("createSa2kitAuth: secret \u81F3\u5C11 32 \u5B57\u7B26");
|
|
26
|
+
}
|
|
27
|
+
const devLog = createDevOtpLogger(config.logOtpInDev ?? process.env.NODE_ENV !== "production");
|
|
28
|
+
const phoneValidator = config.phoneNumberValidator ?? defaultPhoneValidator;
|
|
29
|
+
const auth = betterAuth.betterAuth({
|
|
30
|
+
appName: "sa2kit",
|
|
31
|
+
baseURL: config.baseURL,
|
|
32
|
+
basePath: config.basePath ?? "/api/auth",
|
|
33
|
+
secret: config.secret,
|
|
34
|
+
trustedOrigins: config.trustedOrigins,
|
|
35
|
+
database: drizzleAdapter.drizzleAdapter(config.db, {
|
|
36
|
+
provider: "pg",
|
|
37
|
+
schema: chunkLGHUCQIU_js.authDrizzleSchema
|
|
38
|
+
}),
|
|
39
|
+
emailAndPassword: {
|
|
40
|
+
enabled: true
|
|
41
|
+
},
|
|
42
|
+
user: {
|
|
43
|
+
additionalFields: {
|
|
44
|
+
role: {
|
|
45
|
+
type: "string",
|
|
46
|
+
required: false,
|
|
47
|
+
defaultValue: "USER",
|
|
48
|
+
input: false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
plugins: [
|
|
53
|
+
plugins.bearer(),
|
|
54
|
+
plugins.emailOTP({
|
|
55
|
+
async sendVerificationOTP({ email, otp, type }) {
|
|
56
|
+
devLog?.("email", `${email} (${type})`, otp);
|
|
57
|
+
if (config.email?.sendVerificationOTP) {
|
|
58
|
+
await config.email.sendVerificationOTP(email, otp, type);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
plugins.phoneNumber({
|
|
63
|
+
allowedAttempts: 5,
|
|
64
|
+
phoneNumberValidator: phoneValidator,
|
|
65
|
+
async sendOTP({ phoneNumber: phone, code }) {
|
|
66
|
+
devLog?.("sms", phone, code);
|
|
67
|
+
if (config.sms?.sendOTP) {
|
|
68
|
+
void config.sms.sendOTP(phone, code);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
signUpOnVerification: {
|
|
72
|
+
getTempEmail: defaultTempEmailFromPhone,
|
|
73
|
+
getTempName: (phone) => phone
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
]
|
|
77
|
+
});
|
|
78
|
+
return auth;
|
|
79
|
+
}
|
|
80
|
+
function mountNextAuthHandler(auth) {
|
|
81
|
+
return nextJs.toNextJsHandler(auth);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/common/auth/server/handler/hono.ts
|
|
85
|
+
function mountAuthHandler(auth) {
|
|
86
|
+
return (request) => auth.handler(request);
|
|
87
|
+
}
|
|
88
|
+
function createAuthRouteHandlers(auth) {
|
|
89
|
+
const handler = mountAuthHandler(auth);
|
|
90
|
+
return {
|
|
91
|
+
GET: handler,
|
|
92
|
+
POST: handler,
|
|
93
|
+
PUT: handler,
|
|
94
|
+
PATCH: handler,
|
|
95
|
+
DELETE: handler
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/common/auth/server/session.ts
|
|
100
|
+
async function getSessionUser(auth, request) {
|
|
101
|
+
const session2 = await auth.api.getSession({ headers: request.headers });
|
|
102
|
+
if (!session2?.user) return null;
|
|
103
|
+
const user2 = session2.user;
|
|
104
|
+
return {
|
|
105
|
+
id: user2.id,
|
|
106
|
+
email: user2.email,
|
|
107
|
+
name: user2.name,
|
|
108
|
+
role: user2.role,
|
|
109
|
+
phoneNumber: user2.phoneNumber ?? null
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
async function getSessionUserNumeric(auth, request) {
|
|
113
|
+
const user2 = await getSessionUser(auth, request);
|
|
114
|
+
if (!user2) return null;
|
|
115
|
+
const numericId = Number.parseInt(user2.id, 10);
|
|
116
|
+
if (Number.isNaN(numericId)) return null;
|
|
117
|
+
const { id: _id, ...rest } = user2;
|
|
118
|
+
return { ...rest, id: numericId };
|
|
119
|
+
}
|
|
120
|
+
function createSessionValidator(auth) {
|
|
121
|
+
return {
|
|
122
|
+
getSessionUser: (request) => getSessionUser(auth, request),
|
|
123
|
+
getSessionUserNumeric: (request) => getSessionUserNumeric(auth, request)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
8
126
|
|
|
9
|
-
Object.defineProperty(exports, "createAuthRouteHandlers", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () { return chunkZ23HAXHL_js.createAuthRouteHandlers; }
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "createSa2kitAuth", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () { return chunkZ23HAXHL_js.createSa2kitAuth; }
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "createSessionValidator", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () { return chunkZ23HAXHL_js.createSessionValidator; }
|
|
20
|
-
});
|
|
21
|
-
Object.defineProperty(exports, "defaultPhoneValidator", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () { return chunkZ23HAXHL_js.defaultPhoneValidator; }
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, "defaultTempEmailFromPhone", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () { return chunkZ23HAXHL_js.defaultTempEmailFromPhone; }
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(exports, "getSessionUser", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function () { return chunkZ23HAXHL_js.getSessionUser; }
|
|
32
|
-
});
|
|
33
|
-
Object.defineProperty(exports, "getSessionUserNumeric", {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function () { return chunkZ23HAXHL_js.getSessionUserNumeric; }
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(exports, "mountAuthHandler", {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () { return chunkZ23HAXHL_js.mountAuthHandler; }
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(exports, "mountNextAuthHandler", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function () { return chunkZ23HAXHL_js.mountNextAuthHandler; }
|
|
44
|
-
});
|
|
45
127
|
Object.defineProperty(exports, "account", {
|
|
46
128
|
enumerable: true,
|
|
47
129
|
get: function () { return chunkLGHUCQIU_js.account; }
|
|
@@ -82,5 +164,14 @@ Object.defineProperty(exports, "verifications", {
|
|
|
82
164
|
enumerable: true,
|
|
83
165
|
get: function () { return chunkLGHUCQIU_js.verifications; }
|
|
84
166
|
});
|
|
167
|
+
exports.createAuthRouteHandlers = createAuthRouteHandlers;
|
|
168
|
+
exports.createSa2kitAuth = createSa2kitAuth;
|
|
169
|
+
exports.createSessionValidator = createSessionValidator;
|
|
170
|
+
exports.defaultPhoneValidator = defaultPhoneValidator;
|
|
171
|
+
exports.defaultTempEmailFromPhone = defaultTempEmailFromPhone;
|
|
172
|
+
exports.getSessionUser = getSessionUser;
|
|
173
|
+
exports.getSessionUserNumeric = getSessionUserNumeric;
|
|
174
|
+
exports.mountAuthHandler = mountAuthHandler;
|
|
175
|
+
exports.mountNextAuthHandler = mountNextAuthHandler;
|
|
85
176
|
//# sourceMappingURL=index.js.map
|
|
86
177
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/common/auth/server/plugins/dev-otp.ts","../../../../src/common/auth/server/create-auth.ts","../../../../src/common/auth/server/handler/next.ts","../../../../src/common/auth/server/handler/hono.ts","../../../../src/common/auth/server/session.ts"],"names":["phoneNumber","betterAuth","drizzleAdapter","authDrizzleSchema","bearer","emailOTP","toNextJsHandler","session","user"],"mappings":";;;;;;;;;;AAGO,SAAS,mBAAmB,OAAA,EAAkB;AACnD,EAAA,IAAI,CAAC,OAAA,IAAW,OAAA,CAAQ,GAAA,CAAI,aAAa,YAAA,EAAc;AACrD,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,CAAC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,EAAI,SAAA,EAAU;AAClC;AAEO,SAAS,uBAAuB,IAAA,EAA0B;AAC/D,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,CAAC,OAAA,KAAqB,cAAA,CAAe,MAAM,OAAO,CAAA;AAAA,IAClE,qBAAA,EAAuB,CAAC,OAAA,KAAqB,qBAAA,CAAsB,MAAM,OAAO;AAAA,GAClF;AACF","file":"index.js","sourcesContent":["/**\n * 开发 / 测试环境 OTP 输出(禁止生产依赖)\n */\nexport function createDevOtpLogger(enabled: boolean) {\n if (!enabled || process.env.NODE_ENV === 'production') {\n return undefined;\n }\n return (channel: 'sms' | 'email', target: string, code: string) => {\n console.info(`[sa2kit/auth][dev-otp][${channel}] ${target} => ${code}`);\n };\n}\n\nexport const defaultPhoneValidator = (phoneNumber: string) => /^1\\d{10}$/.test(phoneNumber);\n\nexport const defaultTempEmailFromPhone = (phoneNumber: string) =>\n `${phoneNumber.replace(/\\D/g, '')}@phone.sa2kit.local`;\n","/**\n * Better Auth 服务端工厂(sa2kit 3.0 SSOT)\n */\nimport { betterAuth } from 'better-auth';\nimport { drizzleAdapter } from '@better-auth/drizzle-adapter';\nimport { emailOTP } from 'better-auth/plugins';\nimport { phoneNumber } from 'better-auth/plugins';\nimport { bearer } from 'better-auth/plugins';\nimport { authDrizzleSchema } from '../schema';\nimport type { Sa2kitAuthConfig, Sa2kitAuthInstance } from './types';\nimport {\n createDevOtpLogger,\n defaultPhoneValidator,\n defaultTempEmailFromPhone,\n} from './plugins/dev-otp';\n\nexport type { Sa2kitAuthInstance } from './types';\n\nexport function createSa2kitAuth(config: Sa2kitAuthConfig): Sa2kitAuthInstance {\n if (!config.secret || config.secret.length < 32) {\n throw new Error('createSa2kitAuth: secret 至少 32 字符');\n }\n\n const devLog = createDevOtpLogger(config.logOtpInDev ?? process.env.NODE_ENV !== 'production');\n const phoneValidator = config.phoneNumberValidator ?? defaultPhoneValidator;\n\n const auth = betterAuth({\n appName: 'sa2kit',\n baseURL: config.baseURL,\n basePath: config.basePath ?? '/api/auth',\n secret: config.secret,\n trustedOrigins: config.trustedOrigins,\n database: drizzleAdapter(config.db as never, {\n provider: 'pg',\n schema: authDrizzleSchema,\n }),\n emailAndPassword: {\n enabled: true,\n },\n user: {\n additionalFields: {\n role: {\n type: 'string',\n required: false,\n defaultValue: 'USER',\n input: false,\n },\n },\n },\n plugins: [\n bearer(),\n emailOTP({\n async sendVerificationOTP({ email, otp, type }) {\n devLog?.('email', `${email} (${type})`, otp);\n if (config.email?.sendVerificationOTP) {\n await config.email.sendVerificationOTP(email, otp, type);\n }\n },\n }),\n phoneNumber({\n allowedAttempts: 5,\n phoneNumberValidator: phoneValidator,\n async sendOTP({ phoneNumber: phone, code }) {\n devLog?.('sms', phone, code);\n if (config.sms?.sendOTP) {\n void config.sms.sendOTP(phone, code);\n }\n },\n signUpOnVerification: {\n getTempEmail: defaultTempEmailFromPhone,\n getTempName: (phone) => phone,\n },\n }),\n ],\n }) as unknown as Sa2kitAuthInstance;\n\n return auth;\n}\n","/**\n * Next.js App Router handler 挂载\n */\nimport { toNextJsHandler } from 'better-auth/next-js';\nimport type { Sa2kitAuthInstance } from '../create-auth';\n\nexport function mountNextAuthHandler(auth: Sa2kitAuthInstance) {\n return toNextJsHandler(auth);\n}\n","/**\n * Hono / 通用 fetch handler\n */\nimport type { Sa2kitAuthInstance } from '../create-auth';\n\nexport function mountAuthHandler(auth: Sa2kitAuthInstance) {\n return (request: Request) => auth.handler(request);\n}\n\nexport function createAuthRouteHandlers(auth: Sa2kitAuthInstance) {\n const handler = mountAuthHandler(auth);\n return {\n GET: handler,\n POST: handler,\n PUT: handler,\n PATCH: handler,\n DELETE: handler,\n };\n}\n","/**\n * 从 Request 解析 Better Auth session(替代自研 JWT validateApiAuth)\n */\nimport type { Sa2kitAuthInstance } from './types';\n\nexport type SessionUser = {\n id: string;\n email: string;\n name: string;\n role?: string;\n phoneNumber?: string | null;\n};\n\nexport async function getSessionUser(\n auth: Sa2kitAuthInstance,\n request: Request,\n): Promise<SessionUser | null> {\n const session = await auth.api.getSession({ headers: request.headers });\n if (!session?.user) return null;\n\n const user = session.user as SessionUser & { role?: string };\n return {\n id: user.id,\n email: user.email,\n name: user.name,\n role: user.role,\n phoneNumber: (user as { phoneNumber?: string | null }).phoneNumber ?? null,\n };\n}\n\nexport type SessionUserNumeric = Omit<SessionUser, 'id'> & { id: number };\n\n/** 兼容 numeric id 消费方(legacy calendar 等) */\nexport async function getSessionUserNumeric(\n auth: Sa2kitAuthInstance,\n request: Request,\n): Promise<SessionUserNumeric | null> {\n const user = await getSessionUser(auth, request);\n if (!user) return null;\n const numericId = Number.parseInt(user.id, 10);\n if (Number.isNaN(numericId)) return null;\n const { id: _id, ...rest } = user;\n return { ...rest, id: numericId };\n}\n\nexport function createSessionValidator(auth: Sa2kitAuthInstance) {\n return {\n getSessionUser: (request: Request) => getSessionUser(auth, request),\n getSessionUserNumeric: (request: Request) => getSessionUserNumeric(auth, request),\n };\n}\n"]}
|
|
@@ -1,5 +1,128 @@
|
|
|
1
|
-
|
|
1
|
+
import { authDrizzleSchema } from '../../../chunk-EBHPTFG6.mjs';
|
|
2
2
|
export { account, accountRelations, authDrizzleSchema, session, sessionRelations, user, userRelations, userRole, verification, verifications } from '../../../chunk-EBHPTFG6.mjs';
|
|
3
3
|
import '../../../chunk-MAI35PU6.mjs';
|
|
4
|
+
import { betterAuth } from 'better-auth';
|
|
5
|
+
import { drizzleAdapter } from '@better-auth/drizzle-adapter';
|
|
6
|
+
import { bearer, emailOTP, phoneNumber } from 'better-auth/plugins';
|
|
7
|
+
import { toNextJsHandler } from 'better-auth/next-js';
|
|
8
|
+
|
|
9
|
+
// src/common/auth/server/plugins/dev-otp.ts
|
|
10
|
+
function createDevOtpLogger(enabled) {
|
|
11
|
+
if (!enabled || process.env.NODE_ENV === "production") {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
return (channel, target, code) => {
|
|
15
|
+
console.info(`[sa2kit/auth][dev-otp][${channel}] ${target} => ${code}`);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
var defaultPhoneValidator = (phoneNumber2) => /^1\d{10}$/.test(phoneNumber2);
|
|
19
|
+
var defaultTempEmailFromPhone = (phoneNumber2) => `${phoneNumber2.replace(/\D/g, "")}@phone.sa2kit.local`;
|
|
20
|
+
|
|
21
|
+
// src/common/auth/server/create-auth.ts
|
|
22
|
+
function createSa2kitAuth(config) {
|
|
23
|
+
if (!config.secret || config.secret.length < 32) {
|
|
24
|
+
throw new Error("createSa2kitAuth: secret \u81F3\u5C11 32 \u5B57\u7B26");
|
|
25
|
+
}
|
|
26
|
+
const devLog = createDevOtpLogger(config.logOtpInDev ?? process.env.NODE_ENV !== "production");
|
|
27
|
+
const phoneValidator = config.phoneNumberValidator ?? defaultPhoneValidator;
|
|
28
|
+
const auth = betterAuth({
|
|
29
|
+
appName: "sa2kit",
|
|
30
|
+
baseURL: config.baseURL,
|
|
31
|
+
basePath: config.basePath ?? "/api/auth",
|
|
32
|
+
secret: config.secret,
|
|
33
|
+
trustedOrigins: config.trustedOrigins,
|
|
34
|
+
database: drizzleAdapter(config.db, {
|
|
35
|
+
provider: "pg",
|
|
36
|
+
schema: authDrizzleSchema
|
|
37
|
+
}),
|
|
38
|
+
emailAndPassword: {
|
|
39
|
+
enabled: true
|
|
40
|
+
},
|
|
41
|
+
user: {
|
|
42
|
+
additionalFields: {
|
|
43
|
+
role: {
|
|
44
|
+
type: "string",
|
|
45
|
+
required: false,
|
|
46
|
+
defaultValue: "USER",
|
|
47
|
+
input: false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
plugins: [
|
|
52
|
+
bearer(),
|
|
53
|
+
emailOTP({
|
|
54
|
+
async sendVerificationOTP({ email, otp, type }) {
|
|
55
|
+
devLog?.("email", `${email} (${type})`, otp);
|
|
56
|
+
if (config.email?.sendVerificationOTP) {
|
|
57
|
+
await config.email.sendVerificationOTP(email, otp, type);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
phoneNumber({
|
|
62
|
+
allowedAttempts: 5,
|
|
63
|
+
phoneNumberValidator: phoneValidator,
|
|
64
|
+
async sendOTP({ phoneNumber: phone, code }) {
|
|
65
|
+
devLog?.("sms", phone, code);
|
|
66
|
+
if (config.sms?.sendOTP) {
|
|
67
|
+
void config.sms.sendOTP(phone, code);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
signUpOnVerification: {
|
|
71
|
+
getTempEmail: defaultTempEmailFromPhone,
|
|
72
|
+
getTempName: (phone) => phone
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
return auth;
|
|
78
|
+
}
|
|
79
|
+
function mountNextAuthHandler(auth) {
|
|
80
|
+
return toNextJsHandler(auth);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/common/auth/server/handler/hono.ts
|
|
84
|
+
function mountAuthHandler(auth) {
|
|
85
|
+
return (request) => auth.handler(request);
|
|
86
|
+
}
|
|
87
|
+
function createAuthRouteHandlers(auth) {
|
|
88
|
+
const handler = mountAuthHandler(auth);
|
|
89
|
+
return {
|
|
90
|
+
GET: handler,
|
|
91
|
+
POST: handler,
|
|
92
|
+
PUT: handler,
|
|
93
|
+
PATCH: handler,
|
|
94
|
+
DELETE: handler
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// src/common/auth/server/session.ts
|
|
99
|
+
async function getSessionUser(auth, request) {
|
|
100
|
+
const session2 = await auth.api.getSession({ headers: request.headers });
|
|
101
|
+
if (!session2?.user) return null;
|
|
102
|
+
const user2 = session2.user;
|
|
103
|
+
return {
|
|
104
|
+
id: user2.id,
|
|
105
|
+
email: user2.email,
|
|
106
|
+
name: user2.name,
|
|
107
|
+
role: user2.role,
|
|
108
|
+
phoneNumber: user2.phoneNumber ?? null
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async function getSessionUserNumeric(auth, request) {
|
|
112
|
+
const user2 = await getSessionUser(auth, request);
|
|
113
|
+
if (!user2) return null;
|
|
114
|
+
const numericId = Number.parseInt(user2.id, 10);
|
|
115
|
+
if (Number.isNaN(numericId)) return null;
|
|
116
|
+
const { id: _id, ...rest } = user2;
|
|
117
|
+
return { ...rest, id: numericId };
|
|
118
|
+
}
|
|
119
|
+
function createSessionValidator(auth) {
|
|
120
|
+
return {
|
|
121
|
+
getSessionUser: (request) => getSessionUser(auth, request),
|
|
122
|
+
getSessionUserNumeric: (request) => getSessionUserNumeric(auth, request)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { createAuthRouteHandlers, createSa2kitAuth, createSessionValidator, defaultPhoneValidator, defaultTempEmailFromPhone, getSessionUser, getSessionUserNumeric, mountAuthHandler, mountNextAuthHandler };
|
|
4
127
|
//# sourceMappingURL=index.mjs.map
|
|
5
128
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/common/auth/server/plugins/dev-otp.ts","../../../../src/common/auth/server/create-auth.ts","../../../../src/common/auth/server/handler/next.ts","../../../../src/common/auth/server/handler/hono.ts","../../../../src/common/auth/server/session.ts"],"names":["phoneNumber","session","user"],"mappings":";;;;;;;;;AAGO,SAAS,mBAAmB,OAAA,EAAkB;AACnD,EAAA,IAAI,CAAC,OAAA,IAAW,OAAA,CAAQ,GAAA,CAAI,aAAa,YAAA,EAAc;AACrD,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,CAAC,OAAA,EAA0B,MAAA,EAAgB,IAAA,KAAiB;AACjE,IAAA,OAAA,CAAQ,KAAK,CAAA,uBAAA,EAA0B,OAAO,KAAK,MAAM,CAAA,IAAA,EAAO,IAAI,CAAA,CAAE,CAAA;AAAA,EACxE,CAAA;AACF;AAEO,IAAM,qBAAA,G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sB,MAAM,OAAO;AAAA,GAClF;AACF","file":"index.mjs","sourcesContent":["/**\n * 开发 / 测试环境 OTP 输出(禁止生产依赖)\n */\nexport function createDevOtpLogger(enabled: boolean) {\n if (!enabled || process.env.NODE_ENV === 'production') {\n return undefined;\n }\n return (channel: 'sms' | 'email', target: string, code: string) => {\n console.info(`[sa2kit/auth][dev-otp][${channel}] ${target} => ${code}`);\n };\n}\n\nexport const defaultPhoneValidator = (phoneNumber: string) => /^1\\d{10}$/.test(phoneNumber);\n\nexport const defaultTempEmailFromPhone = (phoneNumber: string) =>\n `${phoneNumber.replace(/\\D/g, '')}@phone.sa2kit.local`;\n","/**\n * Better Auth 服务端工厂(sa2kit 3.0 SSOT)\n */\nimport { betterAuth } from 'better-auth';\nimport { drizzleAdapter } from '@better-auth/drizzle-adapter';\nimport { emailOTP } from 'better-auth/plugins';\nimport { phoneNumber } from 'better-auth/plugins';\nimport { bearer } from 'better-auth/plugins';\nimport { authDrizzleSchema } from '../schema';\nimport type { Sa2kitAuthConfig, Sa2kitAuthInstance } from './types';\nimport {\n createDevOtpLogger,\n defaultPhoneValidator,\n defaultTempEmailFromPhone,\n} from './plugins/dev-otp';\n\nexport type { Sa2kitAuthInstance } from './types';\n\nexport function createSa2kitAuth(config: Sa2kitAuthConfig): Sa2kitAuthInstance {\n if (!config.secret || config.secret.length < 32) {\n throw new Error('createSa2kitAuth: secret 至少 32 字符');\n }\n\n const devLog = createDevOtpLogger(config.logOtpInDev ?? process.env.NODE_ENV !== 'production');\n const phoneValidator = config.phoneNumberValidator ?? defaultPhoneValidator;\n\n const auth = betterAuth({\n appName: 'sa2kit',\n baseURL: config.baseURL,\n basePath: config.basePath ?? '/api/auth',\n secret: config.secret,\n trustedOrigins: config.trustedOrigins,\n database: drizzleAdapter(config.db as never, {\n provider: 'pg',\n schema: authDrizzleSchema,\n }),\n emailAndPassword: {\n enabled: true,\n },\n user: {\n additionalFields: {\n role: {\n type: 'string',\n required: false,\n defaultValue: 'USER',\n input: false,\n },\n },\n },\n plugins: [\n bearer(),\n emailOTP({\n async sendVerificationOTP({ email, otp, type }) {\n devLog?.('email', `${email} (${type})`, otp);\n if (config.email?.sendVerificationOTP) {\n await config.email.sendVerificationOTP(email, otp, type);\n }\n },\n }),\n phoneNumber({\n allowedAttempts: 5,\n phoneNumberValidator: phoneValidator,\n async sendOTP({ phoneNumber: phone, code }) {\n devLog?.('sms', phone, code);\n if (config.sms?.sendOTP) {\n void config.sms.sendOTP(phone, code);\n }\n },\n signUpOnVerification: {\n getTempEmail: defaultTempEmailFromPhone,\n getTempName: (phone) => phone,\n },\n }),\n ],\n }) as unknown as Sa2kitAuthInstance;\n\n return auth;\n}\n","/**\n * Next.js App Router handler 挂载\n */\nimport { toNextJsHandler } from 'better-auth/next-js';\nimport type { Sa2kitAuthInstance } from '../create-auth';\n\nexport function mountNextAuthHandler(auth: Sa2kitAuthInstance) {\n return toNextJsHandler(auth);\n}\n","/**\n * Hono / 通用 fetch handler\n */\nimport type { Sa2kitAuthInstance } from '../create-auth';\n\nexport function mountAuthHandler(auth: Sa2kitAuthInstance) {\n return (request: Request) => auth.handler(request);\n}\n\nexport function createAuthRouteHandlers(auth: Sa2kitAuthInstance) {\n const handler = mountAuthHandler(auth);\n return {\n GET: handler,\n POST: handler,\n PUT: handler,\n PATCH: handler,\n DELETE: handler,\n };\n}\n","/**\n * 从 Request 解析 Better Auth session(替代自研 JWT validateApiAuth)\n */\nimport type { Sa2kitAuthInstance } from './types';\n\nexport type SessionUser = {\n id: string;\n email: string;\n name: string;\n role?: string;\n phoneNumber?: string | null;\n};\n\nexport async function getSessionUser(\n auth: Sa2kitAuthInstance,\n request: Request,\n): Promise<SessionUser | null> {\n const session = await auth.api.getSession({ headers: request.headers });\n if (!session?.user) return null;\n\n const user = session.user as SessionUser & { role?: string };\n return {\n id: user.id,\n email: user.email,\n name: user.name,\n role: user.role,\n phoneNumber: (user as { phoneNumber?: string | null }).phoneNumber ?? null,\n };\n}\n\nexport type SessionUserNumeric = Omit<SessionUser, 'id'> & { id: number };\n\n/** 兼容 numeric id 消费方(legacy calendar 等) */\nexport async function getSessionUserNumeric(\n auth: Sa2kitAuthInstance,\n request: Request,\n): Promise<SessionUserNumeric | null> {\n const user = await getSessionUser(auth, request);\n if (!user) return null;\n const numericId = Number.parseInt(user.id, 10);\n if (Number.isNaN(numericId)) return null;\n const { id: _id, ...rest } = user;\n return { ...rest, id: numericId };\n}\n\nexport function createSessionValidator(auth: Sa2kitAuthInstance) {\n return {\n getSessionUser: (request: Request) => getSessionUser(auth, request),\n getSessionUserNumeric: (request: Request) => getSessionUserNumeric(auth, request),\n };\n}\n"]}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var chunkVHN7PF5I_js = require('../../../chunk-VHN7PF5I.js');
|
|
4
3
|
require('../../../chunk-NSBPE2FW.js');
|
|
4
|
+
var bcrypt = require('bcryptjs');
|
|
5
5
|
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
7
|
|
|
8
|
+
var bcrypt__default = /*#__PURE__*/_interopDefault(bcrypt);
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
async function hashPassword(password, saltRounds = 12) {
|
|
11
|
+
return bcrypt__default.default.hash(password, saltRounds);
|
|
12
|
+
}
|
|
13
|
+
async function verifyPassword(password, hashedPassword) {
|
|
14
|
+
return bcrypt__default.default.compare(password, hashedPassword);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.hashPassword = hashPassword;
|
|
18
|
+
exports.verifyPassword = verifyPassword;
|
|
16
19
|
//# sourceMappingURL=index.js.map
|
|
17
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/common/auth/services/password-utils.ts"],"names":["bcrypt"],"mappings":";;;;;;;;;AAUA,eAAsB,YAAA,CAAa,QAAA,EAAkB,UAAA,GAAqB,EAAA,EAAqB;AAC7F,EAAA,OAAOA,uBAAA,CAAO,IAAA,CAAK,QAAA,EAAU,UAAU,CAAA;AACzC;AAKA,eAAsB,cAAA,CAAe,UAAkB,cAAA,EAA0C;AAC/F,EAAA,OAAOA,uBAAA,CAAO,OAAA,CAAQ,QAAA,EAAU,cAAc,CAAA;AAChD","file":"index.js","sourcesContent":["/**\n * Auth Services - Password Utilities\n * 密码哈希相关工具函数\n */\n\nimport bcrypt from 'bcryptjs';\n\n/**\n * 哈希密码\n */\nexport async function hashPassword(password: string, saltRounds: number = 12): Promise<string> {\n return bcrypt.hash(password, saltRounds);\n}\n\n/**\n * 验证密码\n */\nexport async function verifyPassword(password: string, hashedPassword: string): Promise<boolean> {\n return bcrypt.compare(password, hashedPassword);\n}\n\n"]}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
export { hashPassword, verifyPassword } from '../../../chunk-XBZIS3MV.mjs';
|
|
2
1
|
import '../../../chunk-MAI35PU6.mjs';
|
|
2
|
+
import bcrypt from 'bcryptjs';
|
|
3
|
+
|
|
4
|
+
async function hashPassword(password, saltRounds = 12) {
|
|
5
|
+
return bcrypt.hash(password, saltRounds);
|
|
6
|
+
}
|
|
7
|
+
async function verifyPassword(password, hashedPassword) {
|
|
8
|
+
return bcrypt.compare(password, hashedPassword);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { hashPassword, verifyPassword };
|
|
3
12
|
//# sourceMappingURL=index.mjs.map
|
|
4
13
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/common/auth/services/password-utils.ts"],"names":[],"mappings":";;;AAUA,eAAsB,YAAA,CAAa,QAAA,EAAkB,UAAA,GAAqB,EAAA,EAAqB;AAC7F,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,QAAA,EAAU,UAAU,CAAA;AACzC;AAKA,eAAsB,cAAA,CAAe,UAAkB,cAAA,EAA0C;AAC/F,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,QAAA,EAAU,cAAc,CAAA;AAChD","file":"index.mjs","sourcesContent":["/**\n * Auth Services - Password Utilities\n * 密码哈希相关工具函数\n */\n\nimport bcrypt from 'bcryptjs';\n\n/**\n * 哈希密码\n */\nexport async function hashPassword(password: string, saltRounds: number = 12): Promise<string> {\n return bcrypt.hash(password, saltRounds);\n}\n\n/**\n * 验证密码\n */\nexport async function verifyPassword(password: string, hashedPassword: string): Promise<boolean> {\n return bcrypt.compare(password, hashedPassword);\n}\n\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var chunkHJ6MH7J7_js = require('../../../chunk-HJ6MH7J7.js');
|
|
3
|
+
var chunkQSKLQX6H_js = require('../../../chunk-QSKLQX6H.js');
|
|
4
|
+
var chunk6PMXAK7F_js = require('../../../chunk-6PMXAK7F.js');
|
|
6
5
|
require('../../../chunk-Q5EDCKQA.js');
|
|
6
|
+
var chunkHJ6MH7J7_js = require('../../../chunk-HJ6MH7J7.js');
|
|
7
7
|
require('../../../chunk-KH6RQ4J5.js');
|
|
8
8
|
require('../../../chunk-ZRAW3HXA.js');
|
|
9
9
|
var chunkATUCZXJY_js = require('../../../chunk-ATUCZXJY.js');
|
|
@@ -15,119 +15,119 @@ require('../../../chunk-NSBPE2FW.js');
|
|
|
15
15
|
|
|
16
16
|
Object.defineProperty(exports, "createFileUrlResolver", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkQSKLQX6H_js.createFileUrlResolver; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "createOssFileBootstrap", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkQSKLQX6H_js.createOssFileBootstrap; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "createOssFileConfigManager", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkQSKLQX6H_js.createOssFileConfigManager; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "createOssFileConfigManagerFromEnv", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkQSKLQX6H_js.createOssFileConfigManagerFromEnv; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "createOssFileService", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkQSKLQX6H_js.createOssFileService; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "createOssFileServiceWithDrizzlePersistence", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkQSKLQX6H_js.createOssFileServiceWithDrizzlePersistence; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "createUniversalFileServiceFromConfigManager", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkQSKLQX6H_js.createUniversalFileServiceFromConfigManager; }
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "getFileUrlByFileId", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkQSKLQX6H_js.getFileUrlByFileId; }
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "getOssStorageModeLabel", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkQSKLQX6H_js.getOssStorageModeLabel; }
|
|
51
51
|
});
|
|
52
52
|
Object.defineProperty(exports, "isOssEnabledInConfig", {
|
|
53
53
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkQSKLQX6H_js.isOssEnabledInConfig; }
|
|
55
55
|
});
|
|
56
56
|
Object.defineProperty(exports, "resolveFileUrlMap", {
|
|
57
57
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkQSKLQX6H_js.resolveFileUrlMap; }
|
|
59
59
|
});
|
|
60
60
|
Object.defineProperty(exports, "resolveUploadAccessUrl", {
|
|
61
61
|
enumerable: true,
|
|
62
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunkQSKLQX6H_js.resolveUploadAccessUrl; }
|
|
63
63
|
});
|
|
64
64
|
Object.defineProperty(exports, "uploadFileAndResolveAccessUrl", {
|
|
65
65
|
enumerable: true,
|
|
66
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunkQSKLQX6H_js.uploadFileAndResolveAccessUrl; }
|
|
67
67
|
});
|
|
68
68
|
Object.defineProperty(exports, "ApiErrorFactory", {
|
|
69
69
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunk6PMXAK7F_js.ApiErrorFactory; }
|
|
71
71
|
});
|
|
72
72
|
Object.defineProperty(exports, "ApiResponseHelper", {
|
|
73
73
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunk6PMXAK7F_js.ApiResponseHelper; }
|
|
75
75
|
});
|
|
76
76
|
Object.defineProperty(exports, "CacheManager", {
|
|
77
77
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunk6PMXAK7F_js.CacheManager; }
|
|
79
79
|
});
|
|
80
80
|
Object.defineProperty(exports, "FileDbService", {
|
|
81
81
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunk6PMXAK7F_js.FileDbService; }
|
|
83
83
|
});
|
|
84
84
|
Object.defineProperty(exports, "PerformanceMonitor", {
|
|
85
85
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunk6PMXAK7F_js.PerformanceMonitor; }
|
|
87
87
|
});
|
|
88
88
|
Object.defineProperty(exports, "QueryOptimizer", {
|
|
89
89
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunk6PMXAK7F_js.QueryOptimizer; }
|
|
91
91
|
});
|
|
92
92
|
Object.defineProperty(exports, "UniversalFileService", {
|
|
93
93
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunk6PMXAK7F_js.UniversalFileService; }
|
|
95
95
|
});
|
|
96
96
|
Object.defineProperty(exports, "ValidationHelper", {
|
|
97
97
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunk6PMXAK7F_js.ValidationHelper; }
|
|
99
99
|
});
|
|
100
100
|
Object.defineProperty(exports, "cacheManager", {
|
|
101
101
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunk6PMXAK7F_js.cacheManager; }
|
|
103
103
|
});
|
|
104
104
|
Object.defineProperty(exports, "createDrizzleFileRepository", {
|
|
105
105
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
106
|
+
get: function () { return chunk6PMXAK7F_js.createDrizzleFileRepository; }
|
|
107
107
|
});
|
|
108
108
|
Object.defineProperty(exports, "createFileServiceWithFactory", {
|
|
109
109
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunk6PMXAK7F_js.createFileServiceWithFactory; }
|
|
111
111
|
});
|
|
112
112
|
Object.defineProperty(exports, "createUniversalFileServiceWithConfigManager", {
|
|
113
113
|
enumerable: true,
|
|
114
|
-
get: function () { return
|
|
114
|
+
get: function () { return chunk6PMXAK7F_js.createUniversalFileServiceWithConfigManager; }
|
|
115
115
|
});
|
|
116
116
|
Object.defineProperty(exports, "loadConfigFromEnv", {
|
|
117
117
|
enumerable: true,
|
|
118
|
-
get: function () { return
|
|
118
|
+
get: function () { return chunk6PMXAK7F_js.loadConfigFromEnv; }
|
|
119
119
|
});
|
|
120
120
|
Object.defineProperty(exports, "loadOSSConfigFromEnv", {
|
|
121
121
|
enumerable: true,
|
|
122
|
-
get: function () { return
|
|
122
|
+
get: function () { return chunk6PMXAK7F_js.loadOSSConfigFromEnv; }
|
|
123
123
|
});
|
|
124
124
|
Object.defineProperty(exports, "performanceMonitor", {
|
|
125
125
|
enumerable: true,
|
|
126
|
-
get: function () { return
|
|
126
|
+
get: function () { return chunk6PMXAK7F_js.performanceMonitor; }
|
|
127
127
|
});
|
|
128
128
|
Object.defineProperty(exports, "queryOptimizer", {
|
|
129
129
|
enumerable: true,
|
|
130
|
-
get: function () { return
|
|
130
|
+
get: function () { return chunk6PMXAK7F_js.queryOptimizer; }
|
|
131
131
|
});
|
|
132
132
|
Object.defineProperty(exports, "AliyunOSSProvider", {
|
|
133
133
|
enumerable: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { createFileUrlResolver, createOssFileBootstrap, createOssFileConfigManager, createOssFileConfigManagerFromEnv, createOssFileService, createOssFileServiceWithDrizzlePersistence, createUniversalFileServiceFromConfigManager, getFileUrlByFileId, getOssStorageModeLabel, isOssEnabledInConfig, resolveFileUrlMap, resolveUploadAccessUrl, uploadFileAndResolveAccessUrl } from '../../../chunk-
|
|
2
|
-
export { ApiErrorFactory, ApiResponseHelper, CacheManager, FileDbService, PerformanceMonitor, QueryOptimizer, UniversalFileService, ValidationHelper, cacheManager, createDrizzleFileRepository, createFileServiceWithFactory, createUniversalFileServiceWithConfigManager, loadConfigFromEnv, loadOSSConfigFromEnv, performanceMonitor, queryOptimizer } from '../../../chunk-
|
|
3
|
-
export { AliyunOSSProvider } from '../../../chunk-HDMIOOZY.mjs';
|
|
1
|
+
export { createFileUrlResolver, createOssFileBootstrap, createOssFileConfigManager, createOssFileConfigManagerFromEnv, createOssFileService, createOssFileServiceWithDrizzlePersistence, createUniversalFileServiceFromConfigManager, getFileUrlByFileId, getOssStorageModeLabel, isOssEnabledInConfig, resolveFileUrlMap, resolveUploadAccessUrl, uploadFileAndResolveAccessUrl } from '../../../chunk-WJ7IMUEJ.mjs';
|
|
2
|
+
export { ApiErrorFactory, ApiResponseHelper, CacheManager, FileDbService, PerformanceMonitor, QueryOptimizer, UniversalFileService, ValidationHelper, cacheManager, createDrizzleFileRepository, createFileServiceWithFactory, createUniversalFileServiceWithConfigManager, loadConfigFromEnv, loadOSSConfigFromEnv, performanceMonitor, queryOptimizer } from '../../../chunk-4OOANEJV.mjs';
|
|
4
3
|
import '../../../chunk-YOTQG4NP.mjs';
|
|
4
|
+
export { AliyunOSSProvider } from '../../../chunk-HDMIOOZY.mjs';
|
|
5
5
|
import '../../../chunk-ZGVB35L2.mjs';
|
|
6
6
|
import '../../../chunk-CIVO4R6N.mjs';
|
|
7
7
|
export { STANDARD_ALIYUN_OSS_KEYS, buildModuleUploadPath, parseAliyunOssConfigFromMap } from '../../../chunk-DIF5VRL3.mjs';
|
package/dist/common/index.d.mts
CHANGED
|
@@ -4,10 +4,10 @@ export { i as storage } from '../index-DLnfKN-a.mjs';
|
|
|
4
4
|
export { i as request } from '../index-Bjem5rWn.mjs';
|
|
5
5
|
export { i as file } from '../index-CYuUB8aF.mjs';
|
|
6
6
|
export { i as dataExport } from '../index-qcOvRVuN.mjs';
|
|
7
|
-
export { i as auth } from '../index-
|
|
7
|
+
export { i as auth } from '../index-Bd7cKF1j.mjs';
|
|
8
8
|
export { i as platform } from '../index-DgWOO9I3.mjs';
|
|
9
|
-
export { i as i18n } from '../index-
|
|
10
|
-
export { i as analytics } from '../index-
|
|
9
|
+
export { i as i18n } from '../index-D0cqaQEH.mjs';
|
|
10
|
+
export { i as analytics } from '../index-DoUo8IrU.mjs';
|
|
11
11
|
export { i as config } from '../index-CIRO-7ub.mjs';
|
|
12
12
|
export { i as api } from '../index-CDqhODgC.mjs';
|
|
13
13
|
export { U as UniversalFileClient, a as UniversalFileClientConfig, c as createFileClient, u as universalFileClient } from '../client-jTaR5LGF.mjs';
|
|
@@ -31,12 +31,9 @@ import 'better-auth/plugins/email-otp';
|
|
|
31
31
|
import 'better-auth/plugins/phone-number';
|
|
32
32
|
import 'better-auth/client';
|
|
33
33
|
import 'better-auth';
|
|
34
|
-
import '../base-api-client-DXLsq2yz.mjs';
|
|
35
|
-
import '../types-DCRvasyH.mjs';
|
|
36
|
-
import '../enums-Dume-V5Y.mjs';
|
|
37
|
-
import 'drizzle-orm/pg-core';
|
|
38
34
|
import './auth/hooks/index.mjs';
|
|
39
35
|
import './auth/react/index.mjs';
|
|
40
36
|
import '../useAuthActions-7S5dL7Oh.mjs';
|
|
41
|
-
import '../
|
|
37
|
+
import '../enums-Dume-V5Y.mjs';
|
|
38
|
+
import 'drizzle-orm/pg-core';
|
|
42
39
|
import '../types-BFn0BeTp.mjs';
|
package/dist/common/index.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ export { i as storage } from '../index-C5U-2hJq.js';
|
|
|
4
4
|
export { i as request } from '../index-CifSBBP2.js';
|
|
5
5
|
export { i as file } from '../index-WrR57hKT.js';
|
|
6
6
|
export { i as dataExport } from '../index-2G9Dxjvt.js';
|
|
7
|
-
export { i as auth } from '../index-
|
|
7
|
+
export { i as auth } from '../index-DRQxtCDw.js';
|
|
8
8
|
export { i as platform } from '../index-DoZVZBrN.js';
|
|
9
|
-
export { i as i18n } from '../index-
|
|
10
|
-
export { i as analytics } from '../index-
|
|
9
|
+
export { i as i18n } from '../index-D0cqaQEH.js';
|
|
10
|
+
export { i as analytics } from '../index-DoUo8IrU.js';
|
|
11
11
|
export { i as config } from '../index-CIRO-7ub.js';
|
|
12
12
|
export { i as api } from '../index-BoZL0QD6.js';
|
|
13
13
|
export { U as UniversalFileClient, a as UniversalFileClientConfig, c as createFileClient, u as universalFileClient } from '../client-BPQS6bKB.js';
|
|
@@ -31,12 +31,9 @@ import 'better-auth/plugins/email-otp';
|
|
|
31
31
|
import 'better-auth/plugins/phone-number';
|
|
32
32
|
import 'better-auth/client';
|
|
33
33
|
import 'better-auth';
|
|
34
|
-
import '../base-api-client-BpmcQt4Q.js';
|
|
35
|
-
import '../types-C_W_CoUD.js';
|
|
36
|
-
import '../enums-Dume-V5Y.js';
|
|
37
|
-
import 'drizzle-orm/pg-core';
|
|
38
34
|
import './auth/hooks/index.js';
|
|
39
35
|
import './auth/react/index.js';
|
|
40
36
|
import '../useAuthActions-7S5dL7Oh.js';
|
|
41
|
-
import '../
|
|
37
|
+
import '../enums-Dume-V5Y.js';
|
|
38
|
+
import 'drizzle-orm/pg-core';
|
|
42
39
|
import '../types-BAyMVqnL.js';
|