@windrun-huaiin/backend-core 14.4.0 → 14.6.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/app/api/user/anonymous/init/route.d.ts.map +1 -1
- package/dist/app/api/user/anonymous/init/route.js +8 -6
- package/dist/app/api/user/anonymous/init/route.mjs +4 -2
- package/dist/auth/auth-utils.d.ts +11 -1
- package/dist/auth/auth-utils.d.ts.map +1 -1
- package/dist/auth/auth-utils.js +53 -0
- package/dist/auth/auth-utils.mjs +52 -1
- package/dist/lib/money-price-helper.d.ts.map +1 -1
- package/dist/lib/money-price-helper.js +6 -4
- package/dist/lib/money-price-helper.mjs +4 -2
- package/dist/prisma/index.d.ts +0 -1
- package/dist/prisma/index.d.ts.map +1 -1
- package/package.json +4 -9
- package/src/app/api/user/anonymous/init/route.ts +3 -2
- package/src/auth/auth-utils.ts +51 -1
- package/src/lib/money-price-helper.ts +3 -2
- package/src/prisma/index.ts +0 -1
- package/dist/lib/auth-utils.d.ts +0 -46
- package/dist/lib/auth-utils.d.ts.map +0 -1
- package/dist/lib/auth-utils.js +0 -107
- package/dist/lib/auth-utils.mjs +0 -102
- package/dist/prisma/client.d.ts +0 -2
- package/dist/prisma/client.d.ts.map +0 -1
- package/dist/prisma/client.js +0 -12
- package/dist/prisma/client.mjs +0 -1
- package/src/prisma/client.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/user/anonymous/init/route.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/user/anonymous/init/route.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA6rBxD;;;GAGG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,kCAE9C"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var tslib_es6 = require('../../../../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js');
|
|
4
4
|
var anonymous_aggregate_service = require('../../../../../services/aggregate/anonymous.aggregate.service.js');
|
|
5
|
+
var authUtils = require('../../../../../auth/auth-utils.js');
|
|
5
6
|
var server = require('@windrun-huaiin/third-ui/fingerprint/server');
|
|
6
|
-
var server$1 = require('
|
|
7
|
-
var server$2 = require('next/server');
|
|
7
|
+
var server$1 = require('next/server');
|
|
8
8
|
var userContextService = require('../../../../../services/context/user-context-service.js');
|
|
9
9
|
var userContextFinalizer = require('../../../../../services/context/user-context-finalizer.js');
|
|
10
10
|
|
|
@@ -22,7 +22,7 @@ function createSuccessResponse(params) {
|
|
|
22
22
|
/** 创建错误响应 */
|
|
23
23
|
function createErrorResponse(message, status = 400) {
|
|
24
24
|
const errorResponse = { error: message };
|
|
25
|
-
return server$
|
|
25
|
+
return server$1.NextResponse.json(errorResponse, { status });
|
|
26
26
|
}
|
|
27
27
|
const SOURCE_REF_MAX_LENGTH = 2048;
|
|
28
28
|
const QUERY_PARAM_MAX_LENGTH = 512;
|
|
@@ -494,6 +494,7 @@ function getUserByFingerprintId(fingerprintId) {
|
|
|
494
494
|
*/
|
|
495
495
|
function handleFingerprintRequest(request_1) {
|
|
496
496
|
return tslib_es6.__awaiter(this, arguments, void 0, function* (request, options = {}) {
|
|
497
|
+
var _a;
|
|
497
498
|
// 从请求中提取fingerprint ID
|
|
498
499
|
const fingerprintId = server.extractFingerprintFromNextRequest(request);
|
|
499
500
|
// 验证fingerprint ID
|
|
@@ -501,7 +502,8 @@ function handleFingerprintRequest(request_1) {
|
|
|
501
502
|
return createErrorResponse('Invalid or missing fingerprint ID');
|
|
502
503
|
}
|
|
503
504
|
console.log('Received fingerprintId:', fingerprintId);
|
|
504
|
-
const
|
|
505
|
+
const authIdentity = yield authUtils.getOptionalServerAuthIdentity();
|
|
506
|
+
const clerkUserId = (_a = authIdentity === null || authIdentity === void 0 ? void 0 : authIdentity.providerUserId) !== null && _a !== void 0 ? _a : null;
|
|
505
507
|
try {
|
|
506
508
|
// 优先根据 Clerk ID 查询(如果已登录)
|
|
507
509
|
let existingUserResult = null;
|
|
@@ -521,7 +523,7 @@ function handleFingerprintRequest(request_1) {
|
|
|
521
523
|
existingUserResult = yield getUserByFingerprintId(fingerprintId);
|
|
522
524
|
}
|
|
523
525
|
if (existingUserResult) {
|
|
524
|
-
return server$
|
|
526
|
+
return server$1.NextResponse.json(existingUserResult);
|
|
525
527
|
}
|
|
526
528
|
// 如果不存在用户且不允许创建,返回404
|
|
527
529
|
if (!options.createIfNotExists) {
|
|
@@ -545,7 +547,7 @@ function handleFingerprintRequest(request_1) {
|
|
|
545
547
|
hasAnonymousUser: anonymousInitResult.hasAnonymousUser,
|
|
546
548
|
},
|
|
547
549
|
});
|
|
548
|
-
return server$
|
|
550
|
+
return server$1.NextResponse.json(response);
|
|
549
551
|
}
|
|
550
552
|
catch (error) {
|
|
551
553
|
console.error('Fingerprint request error:', error);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter, __rest } from '../../../../../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.mjs';
|
|
2
2
|
import { anonymousAggregateService } from '../../../../../services/aggregate/anonymous.aggregate.service.mjs';
|
|
3
|
+
import { getOptionalServerAuthIdentity } from '../../../../../auth/auth-utils.mjs';
|
|
3
4
|
import { extractFingerprintFromNextRequest } from '@windrun-huaiin/third-ui/fingerprint/server';
|
|
4
|
-
import { auth } from '@clerk/nextjs/server';
|
|
5
5
|
import { NextResponse } from 'next/server';
|
|
6
6
|
import { fetchUserContextByClerkUserId, fetchLatestUserContextByFingerprintId, mapSubscriptionToXSubscription, mapCreditToXCredit, mapUserToXUser } from '../../../../../services/context/user-context-service.mjs';
|
|
7
7
|
import { finalizeUserContext } from '../../../../../services/context/user-context-finalizer.mjs';
|
|
@@ -492,6 +492,7 @@ function getUserByFingerprintId(fingerprintId) {
|
|
|
492
492
|
*/
|
|
493
493
|
function handleFingerprintRequest(request_1) {
|
|
494
494
|
return __awaiter(this, arguments, void 0, function* (request, options = {}) {
|
|
495
|
+
var _a;
|
|
495
496
|
// 从请求中提取fingerprint ID
|
|
496
497
|
const fingerprintId = extractFingerprintFromNextRequest(request);
|
|
497
498
|
// 验证fingerprint ID
|
|
@@ -499,7 +500,8 @@ function handleFingerprintRequest(request_1) {
|
|
|
499
500
|
return createErrorResponse('Invalid or missing fingerprint ID');
|
|
500
501
|
}
|
|
501
502
|
console.log('Received fingerprintId:', fingerprintId);
|
|
502
|
-
const
|
|
503
|
+
const authIdentity = yield getOptionalServerAuthIdentity();
|
|
504
|
+
const clerkUserId = (_a = authIdentity === null || authIdentity === void 0 ? void 0 : authIdentity.providerUserId) !== null && _a !== void 0 ? _a : null;
|
|
503
505
|
try {
|
|
504
506
|
// 优先根据 Clerk ID 查询(如果已登录)
|
|
505
507
|
let existingUserResult = null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server';
|
|
2
2
|
import { User } from '../services/database/prisma-model-type';
|
|
3
|
-
import { type AuthProvider } from './auth-shared';
|
|
3
|
+
import { type AuthProvider, type ProviderIdentity } from './auth-shared';
|
|
4
4
|
/**
|
|
5
5
|
* 认证结果类型
|
|
6
6
|
*/
|
|
@@ -22,6 +22,16 @@ export declare function requireAuth(req: NextRequest): Promise<string>;
|
|
|
22
22
|
* 要求用户必须已认证,返回完整用户信息
|
|
23
23
|
*/
|
|
24
24
|
export declare function requireAuthWithUser(req: NextRequest): Promise<AuthResult>;
|
|
25
|
+
/**
|
|
26
|
+
* 服务端场景下获取当前已认证身份(如果存在)
|
|
27
|
+
* 适用于只依赖登录态、不需要查询业务用户的逻辑
|
|
28
|
+
*/
|
|
29
|
+
export declare function getOptionalServerAuthIdentity(): Promise<ProviderIdentity | null>;
|
|
30
|
+
/**
|
|
31
|
+
* 服务端场景下获取当前已认证用户(如果存在)
|
|
32
|
+
* 适用于 Server Component / Server Action 中基于登录态控制展示的逻辑
|
|
33
|
+
*/
|
|
34
|
+
export declare function getOptionalServerAuthUser(): Promise<AuthResult | null>;
|
|
25
35
|
/**
|
|
26
36
|
* API Route版本的认证工具函数
|
|
27
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-utils.d.ts","sourceRoot":"","sources":["../../src/auth/auth-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-utils.d.ts","sourceRoot":"","sources":["../../src/auth/auth-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,IAAI,EAAE,MAAM,wCAAwC,CAAC;AAC9D,OAAO,EAA6B,KAAK,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEpG;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAuBhF;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnE;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAE/E;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAetF;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAsB5E;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,GAAG,CAAc;gBAEb,GAAG,EAAE,WAAW;IAI5B;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,UAAU,CAAC;IAIhD;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IASzC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAO5C"}
|
package/dist/auth/auth-utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var tslib_es6 = require('../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js');
|
|
4
|
+
var server = require('@clerk/nextjs/server');
|
|
4
5
|
var user_service = require('../services/database/user.service.js');
|
|
5
6
|
require('../prisma/prisma.js');
|
|
6
7
|
require('../services/database/credit.service.js');
|
|
@@ -52,6 +53,56 @@ function requireAuthWithUser(req) {
|
|
|
52
53
|
return yield getAuthenticatedUser(req);
|
|
53
54
|
});
|
|
54
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* 服务端场景下获取当前已认证身份(如果存在)
|
|
58
|
+
* 适用于只依赖登录态、不需要查询业务用户的逻辑
|
|
59
|
+
*/
|
|
60
|
+
function getOptionalServerAuthIdentity() {
|
|
61
|
+
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
try {
|
|
63
|
+
const { userId: providerUserId } = yield server.auth();
|
|
64
|
+
if (!providerUserId) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
provider: 'clerk',
|
|
69
|
+
providerUserId,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
console.error('Error getting optional server auth identity:', error);
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 服务端场景下获取当前已认证用户(如果存在)
|
|
80
|
+
* 适用于 Server Component / Server Action 中基于登录态控制展示的逻辑
|
|
81
|
+
*/
|
|
82
|
+
function getOptionalServerAuthUser() {
|
|
83
|
+
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
try {
|
|
85
|
+
const identity = yield getOptionalServerAuthIdentity();
|
|
86
|
+
if (!identity) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const user = yield user_service.userService.findByClerkUserId(identity.providerUserId);
|
|
90
|
+
if (!user) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
userId: user.userId,
|
|
95
|
+
user,
|
|
96
|
+
provider: identity.provider,
|
|
97
|
+
providerUserId: identity.providerUserId,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
console.error('Error getting optional server auth user:', error);
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
55
106
|
/**
|
|
56
107
|
* API Route版本的认证工具函数
|
|
57
108
|
*/
|
|
@@ -106,5 +157,7 @@ class ApiAuthUtils {
|
|
|
106
157
|
|
|
107
158
|
exports.ApiAuthUtils = ApiAuthUtils;
|
|
108
159
|
exports.getAuthenticatedUser = getAuthenticatedUser;
|
|
160
|
+
exports.getOptionalServerAuthIdentity = getOptionalServerAuthIdentity;
|
|
161
|
+
exports.getOptionalServerAuthUser = getOptionalServerAuthUser;
|
|
109
162
|
exports.requireAuth = requireAuth;
|
|
110
163
|
exports.requireAuthWithUser = requireAuthWithUser;
|
package/dist/auth/auth-utils.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from '../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.mjs';
|
|
2
|
+
import { auth } from '@clerk/nextjs/server';
|
|
2
3
|
import { userService } from '../services/database/user.service.mjs';
|
|
3
4
|
import '../prisma/prisma.mjs';
|
|
4
5
|
import '../services/database/credit.service.mjs';
|
|
@@ -50,6 +51,56 @@ function requireAuthWithUser(req) {
|
|
|
50
51
|
return yield getAuthenticatedUser(req);
|
|
51
52
|
});
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* 服务端场景下获取当前已认证身份(如果存在)
|
|
56
|
+
* 适用于只依赖登录态、不需要查询业务用户的逻辑
|
|
57
|
+
*/
|
|
58
|
+
function getOptionalServerAuthIdentity() {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
try {
|
|
61
|
+
const { userId: providerUserId } = yield auth();
|
|
62
|
+
if (!providerUserId) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
provider: 'clerk',
|
|
67
|
+
providerUserId,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.error('Error getting optional server auth identity:', error);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 服务端场景下获取当前已认证用户(如果存在)
|
|
78
|
+
* 适用于 Server Component / Server Action 中基于登录态控制展示的逻辑
|
|
79
|
+
*/
|
|
80
|
+
function getOptionalServerAuthUser() {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
try {
|
|
83
|
+
const identity = yield getOptionalServerAuthIdentity();
|
|
84
|
+
if (!identity) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const user = yield userService.findByClerkUserId(identity.providerUserId);
|
|
88
|
+
if (!user) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
userId: user.userId,
|
|
93
|
+
user,
|
|
94
|
+
provider: identity.provider,
|
|
95
|
+
providerUserId: identity.providerUserId,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.error('Error getting optional server auth user:', error);
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
53
104
|
/**
|
|
54
105
|
* API Route版本的认证工具函数
|
|
55
106
|
*/
|
|
@@ -102,4 +153,4 @@ class ApiAuthUtils {
|
|
|
102
153
|
}
|
|
103
154
|
}
|
|
104
155
|
|
|
105
|
-
export { ApiAuthUtils, getAuthenticatedUser, requireAuth, requireAuthWithUser };
|
|
156
|
+
export { ApiAuthUtils, getAuthenticatedUser, getOptionalServerAuthIdentity, getOptionalServerAuthUser, requireAuth, requireAuthWithUser };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"money-price-helper.d.ts","sourceRoot":"","sources":["../../src/lib/money-price-helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"money-price-helper.d.ts","sourceRoot":"","sources":["../../src/lib/money-price-helper.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAkB5E,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,eAAe,CAAC,CAuC7E"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var tslib_es6 = require('../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js');
|
|
4
|
-
var server = require('@clerk/nextjs/server');
|
|
5
4
|
var headers = require('next/headers');
|
|
6
|
-
var server
|
|
5
|
+
var server = require('@windrun-huaiin/third-ui/fingerprint/server');
|
|
6
|
+
var authUtils = require('../auth/auth-utils.js');
|
|
7
7
|
var userContextService = require('../services/context/user-context-service.js');
|
|
8
8
|
var userContextFinalizer = require('../services/context/user-context-finalizer.js');
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ function readFingerprintIdFromRequest() {
|
|
|
11
11
|
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
12
12
|
const cookieStore = yield headers.cookies();
|
|
13
13
|
const headerList = yield headers.headers();
|
|
14
|
-
return server
|
|
14
|
+
return server.extractFingerprintFromNextStores({
|
|
15
15
|
headers: headerList,
|
|
16
16
|
cookies: cookieStore,
|
|
17
17
|
});
|
|
@@ -19,7 +19,9 @@ function readFingerprintIdFromRequest() {
|
|
|
19
19
|
}
|
|
20
20
|
function getMoneyPriceInitUserContext() {
|
|
21
21
|
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
|
|
22
|
+
var _a;
|
|
23
|
+
const authIdentity = yield authUtils.getOptionalServerAuthIdentity();
|
|
24
|
+
const clerkUserId = (_a = authIdentity === null || authIdentity === void 0 ? void 0 : authIdentity.providerUserId) !== null && _a !== void 0 ? _a : null;
|
|
23
25
|
if (clerkUserId) {
|
|
24
26
|
const userContext = yield userContextService.fetchUserContextByClerkUserId(clerkUserId);
|
|
25
27
|
if (!userContext) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from '../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.mjs';
|
|
2
|
-
import { auth } from '@clerk/nextjs/server';
|
|
3
2
|
import { cookies, headers } from 'next/headers';
|
|
4
3
|
import { extractFingerprintFromNextStores } from '@windrun-huaiin/third-ui/fingerprint/server';
|
|
4
|
+
import { getOptionalServerAuthIdentity } from '../auth/auth-utils.mjs';
|
|
5
5
|
import { fetchUserContextByClerkUserId, buildInitUserContextFromEntities } from '../services/context/user-context-service.mjs';
|
|
6
6
|
import { finalizeUserContext } from '../services/context/user-context-finalizer.mjs';
|
|
7
7
|
|
|
@@ -17,7 +17,9 @@ function readFingerprintIdFromRequest() {
|
|
|
17
17
|
}
|
|
18
18
|
function getMoneyPriceInitUserContext() {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
|
|
20
|
+
var _a;
|
|
21
|
+
const authIdentity = yield getOptionalServerAuthIdentity();
|
|
22
|
+
const clerkUserId = (_a = authIdentity === null || authIdentity === void 0 ? void 0 : authIdentity.providerUserId) !== null && _a !== void 0 ? _a : null;
|
|
21
23
|
if (clerkUserId) {
|
|
22
24
|
const userContext = yield fetchUserContextByClerkUserId(clerkUserId);
|
|
23
25
|
if (!userContext) {
|
package/dist/prisma/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prisma/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prisma/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,+BAA+B,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windrun-huaiin/backend-core",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.6.0",
|
|
4
4
|
"description": "Shared backend primitives: Prisma schema/client, database services, routing helpers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,11 +17,6 @@
|
|
|
17
17
|
"import": "./dist/prisma/index.mjs",
|
|
18
18
|
"require": "./dist/prisma/index.js"
|
|
19
19
|
},
|
|
20
|
-
"./prisma/client": {
|
|
21
|
-
"types": "./dist/prisma/client.d.ts",
|
|
22
|
-
"import": "./dist/prisma/client.mjs",
|
|
23
|
-
"require": "./dist/prisma/client.js"
|
|
24
|
-
},
|
|
25
20
|
"./database": {
|
|
26
21
|
"types": "./dist/services/database/index.d.ts",
|
|
27
22
|
"import": "./dist/services/database/index.mjs",
|
|
@@ -110,7 +105,7 @@
|
|
|
110
105
|
"svix": "^1.86.0",
|
|
111
106
|
"zod": "^4.3.6",
|
|
112
107
|
"@windrun-huaiin/lib": "^14.0.1",
|
|
113
|
-
"@windrun-huaiin/third-ui": "^14.
|
|
108
|
+
"@windrun-huaiin/third-ui": "^14.5.0"
|
|
114
109
|
},
|
|
115
110
|
"devDependencies": {
|
|
116
111
|
"@rollup/plugin-alias": "^5.1.1",
|
|
@@ -133,8 +128,8 @@
|
|
|
133
128
|
"access": "public"
|
|
134
129
|
},
|
|
135
130
|
"scripts": {
|
|
136
|
-
"build": "rollup -c rollup.config.mjs",
|
|
137
|
-
"build:prod": "rollup -c rollup.config.mjs",
|
|
131
|
+
"build": "rm -rf dist && rollup -c rollup.config.mjs",
|
|
132
|
+
"build:prod": "rm -rf dist && rollup -c rollup.config.mjs",
|
|
138
133
|
"dev": "rollup -c rollup.config.mjs --watch",
|
|
139
134
|
"clean": "rm -rf dist",
|
|
140
135
|
"type-check": "tsc --noEmit"
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
import { anonymousAggregateService } from '@/aggregate/anonymous.aggregate.service';
|
|
9
|
+
import { getOptionalServerAuthIdentity } from '@/auth/auth-utils';
|
|
9
10
|
import type { XCredit, XSubscription, XUser } from '@windrun-huaiin/third-ui/fingerprint';
|
|
10
11
|
import { extractFingerprintFromNextRequest } from '@windrun-huaiin/third-ui/fingerprint/server';
|
|
11
|
-
import { auth } from '@clerk/nextjs/server';
|
|
12
12
|
import { NextRequest, NextResponse } from 'next/server';
|
|
13
13
|
import {
|
|
14
14
|
fetchLatestUserContextByFingerprintId,
|
|
@@ -650,7 +650,8 @@ async function handleFingerprintRequest(request: NextRequest, options: { createI
|
|
|
650
650
|
}
|
|
651
651
|
console.log('Received fingerprintId:', fingerprintId);
|
|
652
652
|
|
|
653
|
-
const
|
|
653
|
+
const authIdentity = await getOptionalServerAuthIdentity();
|
|
654
|
+
const clerkUserId = authIdentity?.providerUserId ?? null;
|
|
654
655
|
try {
|
|
655
656
|
// 优先根据 Clerk ID 查询(如果已登录)
|
|
656
657
|
let existingUserResult: XUserResponse | null = null;
|
package/src/auth/auth-utils.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server';
|
|
2
|
+
import { auth } from '@clerk/nextjs/server';
|
|
2
3
|
import { userService } from '../services/database/index';
|
|
3
4
|
import { User } from '../services/database/prisma-model-type';
|
|
4
|
-
import { AUTH_ERRORS, AUTH_HEADERS, type AuthProvider } from './auth-shared';
|
|
5
|
+
import { AUTH_ERRORS, AUTH_HEADERS, type AuthProvider, type ProviderIdentity } from './auth-shared';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* 认证结果类型
|
|
@@ -56,6 +57,55 @@ export async function requireAuthWithUser(req: NextRequest): Promise<AuthResult>
|
|
|
56
57
|
return await getAuthenticatedUser(req);
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
/**
|
|
61
|
+
* 服务端场景下获取当前已认证身份(如果存在)
|
|
62
|
+
* 适用于只依赖登录态、不需要查询业务用户的逻辑
|
|
63
|
+
*/
|
|
64
|
+
export async function getOptionalServerAuthIdentity(): Promise<ProviderIdentity | null> {
|
|
65
|
+
try {
|
|
66
|
+
const { userId: providerUserId } = await auth();
|
|
67
|
+
if (!providerUserId) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
provider: 'clerk',
|
|
73
|
+
providerUserId,
|
|
74
|
+
};
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error('Error getting optional server auth identity:', error);
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 服务端场景下获取当前已认证用户(如果存在)
|
|
83
|
+
* 适用于 Server Component / Server Action 中基于登录态控制展示的逻辑
|
|
84
|
+
*/
|
|
85
|
+
export async function getOptionalServerAuthUser(): Promise<AuthResult | null> {
|
|
86
|
+
try {
|
|
87
|
+
const identity = await getOptionalServerAuthIdentity();
|
|
88
|
+
if (!identity) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const user = await userService.findByClerkUserId(identity.providerUserId);
|
|
93
|
+
if (!user) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
userId: user.userId,
|
|
99
|
+
user,
|
|
100
|
+
provider: identity.provider,
|
|
101
|
+
providerUserId: identity.providerUserId,
|
|
102
|
+
};
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error('Error getting optional server auth user:', error);
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
59
109
|
/**
|
|
60
110
|
* API Route版本的认证工具函数
|
|
61
111
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { auth } from '@clerk/nextjs/server';
|
|
2
1
|
import { cookies, headers } from 'next/headers';
|
|
3
2
|
import {
|
|
4
3
|
extractFingerprintFromNextStores,
|
|
5
4
|
} from '@windrun-huaiin/third-ui/fingerprint/server';
|
|
6
5
|
import type { InitUserContext } from '@windrun-huaiin/third-ui/main/server';
|
|
6
|
+
import { getOptionalServerAuthIdentity } from '../auth/auth-utils';
|
|
7
7
|
import {
|
|
8
8
|
buildInitUserContextFromEntities,
|
|
9
9
|
fetchUserContextByClerkUserId,
|
|
@@ -21,7 +21,8 @@ async function readFingerprintIdFromRequest(): Promise<string | null> {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export async function getMoneyPriceInitUserContext(): Promise<InitUserContext> {
|
|
24
|
-
const
|
|
24
|
+
const authIdentity = await getOptionalServerAuthIdentity();
|
|
25
|
+
const clerkUserId = authIdentity?.providerUserId ?? null;
|
|
25
26
|
|
|
26
27
|
if (clerkUserId) {
|
|
27
28
|
const userContext = await fetchUserContextByClerkUserId(clerkUserId);
|
package/src/prisma/index.ts
CHANGED
package/dist/lib/auth-utils.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { NextRequest } from 'next/server';
|
|
2
|
-
import { User } from '../services/database/prisma-model-type';
|
|
3
|
-
/**
|
|
4
|
-
* 认证结果类型
|
|
5
|
-
*/
|
|
6
|
-
export interface AuthResult {
|
|
7
|
-
userId: string;
|
|
8
|
-
user: User;
|
|
9
|
-
clerkUserId: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* 从中间件设置的 Clerk ID 获取完整用户信息
|
|
13
|
-
*/
|
|
14
|
-
export declare function getAuthenticatedUser(req: NextRequest): Promise<AuthResult>;
|
|
15
|
-
/**
|
|
16
|
-
* 要求用户必须已认证,返回用户ID
|
|
17
|
-
*/
|
|
18
|
-
export declare function requireAuth(req: NextRequest): Promise<string>;
|
|
19
|
-
/**
|
|
20
|
-
* 要求用户必须已认证,返回完整用户信息
|
|
21
|
-
*/
|
|
22
|
-
export declare function requireAuthWithUser(req: NextRequest): Promise<AuthResult>;
|
|
23
|
-
/**
|
|
24
|
-
* API Route版本的认证工具函数
|
|
25
|
-
*/
|
|
26
|
-
export declare class ApiAuthUtils {
|
|
27
|
-
private req;
|
|
28
|
-
constructor(req: NextRequest);
|
|
29
|
-
/**
|
|
30
|
-
* 要求用户必须已认证,返回用户ID
|
|
31
|
-
*/
|
|
32
|
-
requireAuth(): Promise<string>;
|
|
33
|
-
/**
|
|
34
|
-
* 要求用户必须已认证,返回完整用户信息
|
|
35
|
-
*/
|
|
36
|
-
requireAuthWithUser(): Promise<AuthResult>;
|
|
37
|
-
/**
|
|
38
|
-
* 获取用户ID(如果已认证)
|
|
39
|
-
*/
|
|
40
|
-
getUserId(): Promise<string | null>;
|
|
41
|
-
/**
|
|
42
|
-
* 获取完整用户信息(如果已认证)
|
|
43
|
-
*/
|
|
44
|
-
getUser(): Promise<AuthResult | null>;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=auth-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-utils.d.ts","sourceRoot":"","sources":["../../src/lib/auth-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,wCAAwC,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAqBhF;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnE;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAE/E;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,GAAG,CAAc;gBAEb,GAAG,EAAE,WAAW;IAI5B;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAIpC;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,UAAU,CAAC;IAIhD;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IASzC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAO5C"}
|
package/dist/lib/auth-utils.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var tslib_es6 = require('../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js');
|
|
4
|
-
var user_service = require('../services/database/user.service.js');
|
|
5
|
-
require('../prisma/prisma.js');
|
|
6
|
-
require('../services/database/credit.service.js');
|
|
7
|
-
require('@prisma/client');
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 从中间件设置的 Clerk ID 获取完整用户信息
|
|
11
|
-
*/
|
|
12
|
-
function getAuthenticatedUser(req) {
|
|
13
|
-
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
try {
|
|
15
|
-
const clerkUserId = req.headers.get('x-clerk-user-id');
|
|
16
|
-
if (!clerkUserId) {
|
|
17
|
-
throw new Error('Authentication required');
|
|
18
|
-
}
|
|
19
|
-
const user = yield user_service.userService.findByClerkUserId(clerkUserId);
|
|
20
|
-
if (!user) {
|
|
21
|
-
throw new Error('User not found in database');
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
userId: user.userId,
|
|
25
|
-
user,
|
|
26
|
-
clerkUserId
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
console.error('Error getting authenticated user:', error);
|
|
31
|
-
throw error;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* 要求用户必须已认证,返回用户ID
|
|
37
|
-
*/
|
|
38
|
-
function requireAuth(req) {
|
|
39
|
-
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const auth = yield getAuthenticatedUser(req);
|
|
41
|
-
return auth.userId;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* 要求用户必须已认证,返回完整用户信息
|
|
46
|
-
*/
|
|
47
|
-
function requireAuthWithUser(req) {
|
|
48
|
-
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
return yield getAuthenticatedUser(req);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* API Route版本的认证工具函数
|
|
54
|
-
*/
|
|
55
|
-
class ApiAuthUtils {
|
|
56
|
-
constructor(req) {
|
|
57
|
-
this.req = req;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* 要求用户必须已认证,返回用户ID
|
|
61
|
-
*/
|
|
62
|
-
requireAuth() {
|
|
63
|
-
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
return yield requireAuth(this.req);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* 要求用户必须已认证,返回完整用户信息
|
|
69
|
-
*/
|
|
70
|
-
requireAuthWithUser() {
|
|
71
|
-
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
return yield requireAuthWithUser(this.req);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* 获取用户ID(如果已认证)
|
|
77
|
-
*/
|
|
78
|
-
getUserId() {
|
|
79
|
-
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
try {
|
|
81
|
-
const auth = yield getAuthenticatedUser(this.req);
|
|
82
|
-
return auth.userId;
|
|
83
|
-
}
|
|
84
|
-
catch (_a) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* 获取完整用户信息(如果已认证)
|
|
91
|
-
*/
|
|
92
|
-
getUser() {
|
|
93
|
-
return tslib_es6.__awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
try {
|
|
95
|
-
return yield getAuthenticatedUser(this.req);
|
|
96
|
-
}
|
|
97
|
-
catch (_a) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
exports.ApiAuthUtils = ApiAuthUtils;
|
|
105
|
-
exports.getAuthenticatedUser = getAuthenticatedUser;
|
|
106
|
-
exports.requireAuth = requireAuth;
|
|
107
|
-
exports.requireAuthWithUser = requireAuthWithUser;
|
package/dist/lib/auth-utils.mjs
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { __awaiter } from '../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.mjs';
|
|
2
|
-
import { userService } from '../services/database/user.service.mjs';
|
|
3
|
-
import '../prisma/prisma.mjs';
|
|
4
|
-
import '../services/database/credit.service.mjs';
|
|
5
|
-
import '@prisma/client';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 从中间件设置的 Clerk ID 获取完整用户信息
|
|
9
|
-
*/
|
|
10
|
-
function getAuthenticatedUser(req) {
|
|
11
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
-
try {
|
|
13
|
-
const clerkUserId = req.headers.get('x-clerk-user-id');
|
|
14
|
-
if (!clerkUserId) {
|
|
15
|
-
throw new Error('Authentication required');
|
|
16
|
-
}
|
|
17
|
-
const user = yield userService.findByClerkUserId(clerkUserId);
|
|
18
|
-
if (!user) {
|
|
19
|
-
throw new Error('User not found in database');
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
userId: user.userId,
|
|
23
|
-
user,
|
|
24
|
-
clerkUserId
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
console.error('Error getting authenticated user:', error);
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 要求用户必须已认证,返回用户ID
|
|
35
|
-
*/
|
|
36
|
-
function requireAuth(req) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const auth = yield getAuthenticatedUser(req);
|
|
39
|
-
return auth.userId;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 要求用户必须已认证,返回完整用户信息
|
|
44
|
-
*/
|
|
45
|
-
function requireAuthWithUser(req) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
return yield getAuthenticatedUser(req);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* API Route版本的认证工具函数
|
|
52
|
-
*/
|
|
53
|
-
class ApiAuthUtils {
|
|
54
|
-
constructor(req) {
|
|
55
|
-
this.req = req;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* 要求用户必须已认证,返回用户ID
|
|
59
|
-
*/
|
|
60
|
-
requireAuth() {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
return yield requireAuth(this.req);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* 要求用户必须已认证,返回完整用户信息
|
|
67
|
-
*/
|
|
68
|
-
requireAuthWithUser() {
|
|
69
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
return yield requireAuthWithUser(this.req);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* 获取用户ID(如果已认证)
|
|
75
|
-
*/
|
|
76
|
-
getUserId() {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
try {
|
|
79
|
-
const auth = yield getAuthenticatedUser(this.req);
|
|
80
|
-
return auth.userId;
|
|
81
|
-
}
|
|
82
|
-
catch (_a) {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* 获取完整用户信息(如果已认证)
|
|
89
|
-
*/
|
|
90
|
-
getUser() {
|
|
91
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
try {
|
|
93
|
-
return yield getAuthenticatedUser(this.req);
|
|
94
|
-
}
|
|
95
|
-
catch (_a) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export { ApiAuthUtils, getAuthenticatedUser, requireAuth, requireAuthWithUser };
|
package/dist/prisma/client.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/prisma/client.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC"}
|
package/dist/prisma/client.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var client = require('@prisma/client');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.keys(client).forEach(function (k) {
|
|
8
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function () { return client[k]; }
|
|
11
|
-
});
|
|
12
|
-
});
|
package/dist/prisma/client.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@prisma/client';
|
package/src/prisma/client.ts
DELETED