fastify-siwe-middleware 1.0.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.
@@ -0,0 +1,40 @@
1
+ import { preHandlerHookHandler } from 'fastify';
2
+
3
+ type AuthUser = {
4
+ address: string;
5
+ sessionId: string;
6
+ };
7
+ type AuthJwtPayload = {
8
+ sub: string;
9
+ sessionId: string;
10
+ jti?: string;
11
+ };
12
+
13
+ declare module "@fastify/jwt" {
14
+ interface FastifyJWT {
15
+ payload: AuthJwtPayload;
16
+ user: AuthUser;
17
+ }
18
+ }
19
+
20
+ type JwtGuardOptions = {
21
+ secret?: string;
22
+ verifyToken?: (token: string) => AuthUser;
23
+ issuer?: string;
24
+ isSessionActive?: (sessionId: string) => Promise<boolean>;
25
+ };
26
+ declare function jwtGuard(options: JwtGuardOptions): preHandlerHookHandler;
27
+
28
+ type OnChainGuardOptions = {
29
+ rpcUrl: string;
30
+ contractAddress: string;
31
+ minBalance: bigint;
32
+ };
33
+ declare function onChainGuard(options: OnChainGuardOptions): preHandlerHookHandler;
34
+
35
+ type RoleGuardOptions = {
36
+ allowlist: Iterable<string>;
37
+ };
38
+ declare function roleGuard(options: RoleGuardOptions): preHandlerHookHandler;
39
+
40
+ export { type AuthJwtPayload, type AuthUser, type JwtGuardOptions, type OnChainGuardOptions, type RoleGuardOptions, jwtGuard, onChainGuard, roleGuard };
@@ -0,0 +1,40 @@
1
+ import { preHandlerHookHandler } from 'fastify';
2
+
3
+ type AuthUser = {
4
+ address: string;
5
+ sessionId: string;
6
+ };
7
+ type AuthJwtPayload = {
8
+ sub: string;
9
+ sessionId: string;
10
+ jti?: string;
11
+ };
12
+
13
+ declare module "@fastify/jwt" {
14
+ interface FastifyJWT {
15
+ payload: AuthJwtPayload;
16
+ user: AuthUser;
17
+ }
18
+ }
19
+
20
+ type JwtGuardOptions = {
21
+ secret?: string;
22
+ verifyToken?: (token: string) => AuthUser;
23
+ issuer?: string;
24
+ isSessionActive?: (sessionId: string) => Promise<boolean>;
25
+ };
26
+ declare function jwtGuard(options: JwtGuardOptions): preHandlerHookHandler;
27
+
28
+ type OnChainGuardOptions = {
29
+ rpcUrl: string;
30
+ contractAddress: string;
31
+ minBalance: bigint;
32
+ };
33
+ declare function onChainGuard(options: OnChainGuardOptions): preHandlerHookHandler;
34
+
35
+ type RoleGuardOptions = {
36
+ allowlist: Iterable<string>;
37
+ };
38
+ declare function roleGuard(options: RoleGuardOptions): preHandlerHookHandler;
39
+
40
+ export { type AuthJwtPayload, type AuthUser, type JwtGuardOptions, type OnChainGuardOptions, type RoleGuardOptions, jwtGuard, onChainGuard, roleGuard };