dn-react-router-toolkit 0.5.1 → 0.5.2
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/api/create_handler.d.mts +1 -1
- package/dist/api/create_handler.d.ts +1 -1
- package/dist/auth/index.js +9 -22
- package/dist/auth/index.mjs +9 -22
- package/dist/auth/with_auth.d.mts +2 -4
- package/dist/auth/with_auth.d.ts +2 -4
- package/dist/auth/with_auth.js +9 -22
- package/dist/auth/with_auth.mjs +9 -22
- package/dist/table/loader.d.mts +1 -1
- package/dist/table/loader.d.ts +1 -1
- package/package.json +3 -3
|
@@ -8,6 +8,6 @@ declare const createAPIHandler: <TFile>({ authService, fileService, passwordReco
|
|
|
8
8
|
passwordRecoveryService: PasswordRecoveryService;
|
|
9
9
|
getThirdPartyAuth: (provider: string) => ThirdpartyAuth;
|
|
10
10
|
signupTokenManager: JWTManager<ThirdpartySignupTokenPayload>;
|
|
11
|
-
}) => (args: LoaderFunctionArgs | ActionFunctionArgs) => Promise<(({ request }:
|
|
11
|
+
}) => (args: LoaderFunctionArgs | ActionFunctionArgs) => Promise<Response | (({ request }: ActionFunctionArgs<any> | LoaderFunctionArgs<any>) => Promise<Response>)>;
|
|
12
12
|
|
|
13
13
|
export { createAPIHandler };
|
|
@@ -8,6 +8,6 @@ declare const createAPIHandler: <TFile>({ authService, fileService, passwordReco
|
|
|
8
8
|
passwordRecoveryService: PasswordRecoveryService;
|
|
9
9
|
getThirdPartyAuth: (provider: string) => ThirdpartyAuth;
|
|
10
10
|
signupTokenManager: JWTManager<ThirdpartySignupTokenPayload>;
|
|
11
|
-
}) => (args: LoaderFunctionArgs | ActionFunctionArgs) => Promise<(({ request }:
|
|
11
|
+
}) => (args: LoaderFunctionArgs | ActionFunctionArgs) => Promise<Response | (({ request }: ActionFunctionArgs<any> | LoaderFunctionArgs<any>) => Promise<Response>)>;
|
|
12
12
|
|
|
13
13
|
export { createAPIHandler };
|
package/dist/auth/index.js
CHANGED
|
@@ -83,9 +83,7 @@ function createWithStrictAuthHandler({ authService }) {
|
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
function createWithAuthHandler({
|
|
86
|
-
authService
|
|
87
|
-
tempUserTokenManager,
|
|
88
|
-
tempUserCookieManager
|
|
86
|
+
authService
|
|
89
87
|
}) {
|
|
90
88
|
return function(fn) {
|
|
91
89
|
const withAuthHandler = createWithStrictAuthHandler({
|
|
@@ -105,30 +103,19 @@ function createWithAuthHandler({
|
|
|
105
103
|
});
|
|
106
104
|
return res;
|
|
107
105
|
};
|
|
108
|
-
const tempUserToken = await tempUserCookieManager.parse(
|
|
109
|
-
args.request
|
|
110
|
-
);
|
|
111
|
-
if (tempUserToken) {
|
|
112
|
-
const tempUserPayload = await tempUserTokenManager.verify(tempUserToken);
|
|
113
|
-
if (tempUserPayload) {
|
|
114
|
-
return respond(tempUserPayload);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
106
|
const user = await authService.authRepository.createUser({
|
|
118
107
|
id: (0, import_uuid.v4)(),
|
|
119
|
-
role: "
|
|
108
|
+
role: "guest",
|
|
120
109
|
name: "\uC775\uBA85"
|
|
121
110
|
});
|
|
122
|
-
const
|
|
123
|
-
userId: user.id,
|
|
124
|
-
name: user.name,
|
|
125
|
-
role: user.role
|
|
126
|
-
});
|
|
111
|
+
const { accessToken, refreshToken } = await authService.issueTokenPair(user);
|
|
127
112
|
const headers = new Headers();
|
|
128
|
-
const
|
|
129
|
-
headers.append("Set-Cookie",
|
|
130
|
-
const
|
|
131
|
-
|
|
113
|
+
const accessTokenSetCookie = await authService.getAccessTokenSetCookie(accessToken);
|
|
114
|
+
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
115
|
+
const refreshTokenSetCookie = await authService.getRefreshTokenSetCookie(refreshToken);
|
|
116
|
+
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
117
|
+
const payload = authService.accessTokenManager.decode(accessToken);
|
|
118
|
+
return respond(payload, headers);
|
|
132
119
|
});
|
|
133
120
|
return handler;
|
|
134
121
|
};
|
package/dist/auth/index.mjs
CHANGED
|
@@ -55,9 +55,7 @@ function createWithStrictAuthHandler({ authService }) {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
function createWithAuthHandler({
|
|
58
|
-
authService
|
|
59
|
-
tempUserTokenManager,
|
|
60
|
-
tempUserCookieManager
|
|
58
|
+
authService
|
|
61
59
|
}) {
|
|
62
60
|
return function(fn) {
|
|
63
61
|
const withAuthHandler = createWithStrictAuthHandler({
|
|
@@ -77,30 +75,19 @@ function createWithAuthHandler({
|
|
|
77
75
|
});
|
|
78
76
|
return res;
|
|
79
77
|
};
|
|
80
|
-
const tempUserToken = await tempUserCookieManager.parse(
|
|
81
|
-
args.request
|
|
82
|
-
);
|
|
83
|
-
if (tempUserToken) {
|
|
84
|
-
const tempUserPayload = await tempUserTokenManager.verify(tempUserToken);
|
|
85
|
-
if (tempUserPayload) {
|
|
86
|
-
return respond(tempUserPayload);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
78
|
const user = await authService.authRepository.createUser({
|
|
90
79
|
id: v4(),
|
|
91
|
-
role: "
|
|
80
|
+
role: "guest",
|
|
92
81
|
name: "\uC775\uBA85"
|
|
93
82
|
});
|
|
94
|
-
const
|
|
95
|
-
userId: user.id,
|
|
96
|
-
name: user.name,
|
|
97
|
-
role: user.role
|
|
98
|
-
});
|
|
83
|
+
const { accessToken, refreshToken } = await authService.issueTokenPair(user);
|
|
99
84
|
const headers = new Headers();
|
|
100
|
-
const
|
|
101
|
-
headers.append("Set-Cookie",
|
|
102
|
-
const
|
|
103
|
-
|
|
85
|
+
const accessTokenSetCookie = await authService.getAccessTokenSetCookie(accessToken);
|
|
86
|
+
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
87
|
+
const refreshTokenSetCookie = await authService.getRefreshTokenSetCookie(refreshToken);
|
|
88
|
+
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
89
|
+
const payload = authService.accessTokenManager.decode(accessToken);
|
|
90
|
+
return respond(payload, headers);
|
|
104
91
|
});
|
|
105
92
|
return handler;
|
|
106
93
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AccessTokenPayload } from 'dn-react-toolkit/auth';
|
|
2
|
-
import { AuthService
|
|
2
|
+
import { AuthService } from 'dn-react-toolkit/auth/server';
|
|
3
3
|
import { LoaderFunctionArgs, ActionFunctionArgs } from 'react-router';
|
|
4
4
|
|
|
5
5
|
type Handler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (arg: T) => Promise<unknown> | unknown;
|
|
@@ -8,10 +8,8 @@ type WithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (fn: I
|
|
|
8
8
|
declare function createWithStrictAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ authService }: {
|
|
9
9
|
authService: AuthService;
|
|
10
10
|
}): <THandler extends Handler<T>>(fn: (auth?: AccessTokenPayload) => THandler) => THandler;
|
|
11
|
-
declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ authService,
|
|
11
|
+
declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ authService, }: {
|
|
12
12
|
authService: AuthService;
|
|
13
|
-
tempUserTokenManager: JWTManager<AccessTokenPayload>;
|
|
14
|
-
tempUserCookieManager: CookieManager;
|
|
15
13
|
}): <THandler extends Handler<T>>(fn: (auth: AccessTokenPayload) => THandler) => THandler;
|
|
16
14
|
|
|
17
15
|
export { type WithAuthHandler, createWithAuthHandler, createWithStrictAuthHandler };
|
package/dist/auth/with_auth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AccessTokenPayload } from 'dn-react-toolkit/auth';
|
|
2
|
-
import { AuthService
|
|
2
|
+
import { AuthService } from 'dn-react-toolkit/auth/server';
|
|
3
3
|
import { LoaderFunctionArgs, ActionFunctionArgs } from 'react-router';
|
|
4
4
|
|
|
5
5
|
type Handler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (arg: T) => Promise<unknown> | unknown;
|
|
@@ -8,10 +8,8 @@ type WithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs> = (fn: I
|
|
|
8
8
|
declare function createWithStrictAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ authService }: {
|
|
9
9
|
authService: AuthService;
|
|
10
10
|
}): <THandler extends Handler<T>>(fn: (auth?: AccessTokenPayload) => THandler) => THandler;
|
|
11
|
-
declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ authService,
|
|
11
|
+
declare function createWithAuthHandler<T extends LoaderFunctionArgs | ActionFunctionArgs>({ authService, }: {
|
|
12
12
|
authService: AuthService;
|
|
13
|
-
tempUserTokenManager: JWTManager<AccessTokenPayload>;
|
|
14
|
-
tempUserCookieManager: CookieManager;
|
|
15
13
|
}): <THandler extends Handler<T>>(fn: (auth: AccessTokenPayload) => THandler) => THandler;
|
|
16
14
|
|
|
17
15
|
export { type WithAuthHandler, createWithAuthHandler, createWithStrictAuthHandler };
|
package/dist/auth/with_auth.js
CHANGED
|
@@ -80,9 +80,7 @@ function createWithStrictAuthHandler({ authService }) {
|
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
function createWithAuthHandler({
|
|
83
|
-
authService
|
|
84
|
-
tempUserTokenManager,
|
|
85
|
-
tempUserCookieManager
|
|
83
|
+
authService
|
|
86
84
|
}) {
|
|
87
85
|
return function(fn) {
|
|
88
86
|
const withAuthHandler = createWithStrictAuthHandler({
|
|
@@ -102,30 +100,19 @@ function createWithAuthHandler({
|
|
|
102
100
|
});
|
|
103
101
|
return res;
|
|
104
102
|
};
|
|
105
|
-
const tempUserToken = await tempUserCookieManager.parse(
|
|
106
|
-
args.request
|
|
107
|
-
);
|
|
108
|
-
if (tempUserToken) {
|
|
109
|
-
const tempUserPayload = await tempUserTokenManager.verify(tempUserToken);
|
|
110
|
-
if (tempUserPayload) {
|
|
111
|
-
return respond(tempUserPayload);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
103
|
const user = await authService.authRepository.createUser({
|
|
115
104
|
id: (0, import_uuid.v4)(),
|
|
116
|
-
role: "
|
|
105
|
+
role: "guest",
|
|
117
106
|
name: "\uC775\uBA85"
|
|
118
107
|
});
|
|
119
|
-
const
|
|
120
|
-
userId: user.id,
|
|
121
|
-
name: user.name,
|
|
122
|
-
role: user.role
|
|
123
|
-
});
|
|
108
|
+
const { accessToken, refreshToken } = await authService.issueTokenPair(user);
|
|
124
109
|
const headers = new Headers();
|
|
125
|
-
const
|
|
126
|
-
headers.append("Set-Cookie",
|
|
127
|
-
const
|
|
128
|
-
|
|
110
|
+
const accessTokenSetCookie = await authService.getAccessTokenSetCookie(accessToken);
|
|
111
|
+
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
112
|
+
const refreshTokenSetCookie = await authService.getRefreshTokenSetCookie(refreshToken);
|
|
113
|
+
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
114
|
+
const payload = authService.accessTokenManager.decode(accessToken);
|
|
115
|
+
return respond(payload, headers);
|
|
129
116
|
});
|
|
130
117
|
return handler;
|
|
131
118
|
};
|
package/dist/auth/with_auth.mjs
CHANGED
|
@@ -55,9 +55,7 @@ function createWithStrictAuthHandler({ authService }) {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
function createWithAuthHandler({
|
|
58
|
-
authService
|
|
59
|
-
tempUserTokenManager,
|
|
60
|
-
tempUserCookieManager
|
|
58
|
+
authService
|
|
61
59
|
}) {
|
|
62
60
|
return function(fn) {
|
|
63
61
|
const withAuthHandler = createWithStrictAuthHandler({
|
|
@@ -77,30 +75,19 @@ function createWithAuthHandler({
|
|
|
77
75
|
});
|
|
78
76
|
return res;
|
|
79
77
|
};
|
|
80
|
-
const tempUserToken = await tempUserCookieManager.parse(
|
|
81
|
-
args.request
|
|
82
|
-
);
|
|
83
|
-
if (tempUserToken) {
|
|
84
|
-
const tempUserPayload = await tempUserTokenManager.verify(tempUserToken);
|
|
85
|
-
if (tempUserPayload) {
|
|
86
|
-
return respond(tempUserPayload);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
78
|
const user = await authService.authRepository.createUser({
|
|
90
79
|
id: v4(),
|
|
91
|
-
role: "
|
|
80
|
+
role: "guest",
|
|
92
81
|
name: "\uC775\uBA85"
|
|
93
82
|
});
|
|
94
|
-
const
|
|
95
|
-
userId: user.id,
|
|
96
|
-
name: user.name,
|
|
97
|
-
role: user.role
|
|
98
|
-
});
|
|
83
|
+
const { accessToken, refreshToken } = await authService.issueTokenPair(user);
|
|
99
84
|
const headers = new Headers();
|
|
100
|
-
const
|
|
101
|
-
headers.append("Set-Cookie",
|
|
102
|
-
const
|
|
103
|
-
|
|
85
|
+
const accessTokenSetCookie = await authService.getAccessTokenSetCookie(accessToken);
|
|
86
|
+
headers.append("Set-Cookie", accessTokenSetCookie);
|
|
87
|
+
const refreshTokenSetCookie = await authService.getRefreshTokenSetCookie(refreshToken);
|
|
88
|
+
headers.append("Set-Cookie", refreshTokenSetCookie);
|
|
89
|
+
const payload = authService.accessTokenManager.decode(accessToken);
|
|
90
|
+
return respond(payload, headers);
|
|
104
91
|
});
|
|
105
92
|
return handler;
|
|
106
93
|
};
|
package/dist/table/loader.d.mts
CHANGED
|
@@ -20,7 +20,7 @@ declare function tableLoader<T extends Table, TSelect>({ repository, tableOption
|
|
|
20
20
|
limit: number;
|
|
21
21
|
offset: number;
|
|
22
22
|
orderBy: keyof T["_"]["columns"] & string;
|
|
23
|
-
direction: "
|
|
23
|
+
direction: "asc" | "desc";
|
|
24
24
|
searchKey: ColumnOf<T> | undefined;
|
|
25
25
|
};
|
|
26
26
|
}>;
|
package/dist/table/loader.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ declare function tableLoader<T extends Table, TSelect>({ repository, tableOption
|
|
|
20
20
|
limit: number;
|
|
21
21
|
offset: number;
|
|
22
22
|
orderBy: keyof T["_"]["columns"] & string;
|
|
23
|
-
direction: "
|
|
23
|
+
direction: "asc" | "desc";
|
|
24
24
|
searchKey: ColumnOf<T> | undefined;
|
|
25
25
|
};
|
|
26
26
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dn-react-router-toolkit",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@react-router/dev": "^7.11.0",
|
|
74
|
-
"dn-react-toolkit": "0.2.
|
|
74
|
+
"dn-react-toolkit": "0.2.36",
|
|
75
75
|
"pg": "^8.16.3",
|
|
76
76
|
"uuid": "^13.0.0"
|
|
77
77
|
},
|
|
@@ -81,4 +81,4 @@
|
|
|
81
81
|
"react-dom": "^19",
|
|
82
82
|
"react-router": "^7"
|
|
83
83
|
}
|
|
84
|
-
}
|
|
84
|
+
}
|