@crossauth/fastify 0.0.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/LICENSE +203 -0
- package/README.md +12 -0
- package/dist/fastifyadminclientendpoints.d.ts +149 -0
- package/dist/fastifyadminendpoints.d.ts +126 -0
- package/dist/fastifyapikey.d.ts +42 -0
- package/dist/fastifyoauthclient.d.ts +429 -0
- package/dist/fastifyoauthserver.d.ts +248 -0
- package/dist/fastifyresserver.d.ts +93 -0
- package/dist/fastifyserver.d.ts +293 -0
- package/dist/fastifysession.d.ts +767 -0
- package/dist/fastifysessionadapter.d.ts +48 -0
- package/dist/fastifyuserclientendpoints.d.ts +61 -0
- package/dist/fastifyuserendpoints.d.ts +193 -0
- package/dist/index.cjs +9085 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +9085 -0
- package/dist/tests/admincommon.d.ts +20 -0
- package/dist/tests/fastifyadminapiendpoints.test.d.ts +13 -0
- package/dist/tests/fastifyadminclientapiendpoints.test.d.ts +13 -0
- package/dist/tests/fastifyadminclientendpoints.test.d.ts +13 -0
- package/dist/tests/fastifyadminendpoints.test.d.ts +13 -0
- package/dist/tests/fastifyapikeyserver.test.d.ts +13 -0
- package/dist/tests/fastifyapiserver.test.d.ts +11 -0
- package/dist/tests/fastifyapitwofactor.test.d.ts +11 -0
- package/dist/tests/fastifyauthserver.test.d.ts +17 -0
- package/dist/tests/fastifyclient.test.d.ts +1 -0
- package/dist/tests/fastifymfaclient.test.d.ts +4 -0
- package/dist/tests/fastifyresserver.test.d.ts +1 -0
- package/dist/tests/fastifysessionserver.test.d.ts +13 -0
- package/dist/tests/fastifytwofactorserver.test.d.ts +17 -0
- package/dist/tests/fastifyuserclientapiendpoints.test.d.ts +13 -0
- package/dist/tests/fastifyuserclientendpoints.test.d.ts +13 -0
- package/dist/tests/inmemorytestdata.d.ts +3 -0
- package/dist/tests/oauthcommon.d.ts +45 -0
- package/package.json +75 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FastifyRequest } from 'fastify';
|
|
2
|
+
import { User } from '@crossauth/common';
|
|
3
|
+
|
|
4
|
+
export declare abstract class FastifySessionAdapter {
|
|
5
|
+
abstract csrfProtectionEnabled(): boolean;
|
|
6
|
+
abstract getCsrfToken(request: FastifyRequest): string | undefined;
|
|
7
|
+
abstract getUser(request: FastifyRequest): User | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Updates a field in the session data in the key storage record,
|
|
10
|
+
*
|
|
11
|
+
* The `data` field is assumed to be JSON. Just the field with the given
|
|
12
|
+
* name is updated and the rest is unchanged.
|
|
13
|
+
* @param request the Fastifdy request
|
|
14
|
+
* @param name the field within `data` to update
|
|
15
|
+
* @param value the value to set it to
|
|
16
|
+
*/
|
|
17
|
+
abstract updateSessionData(request: FastifyRequest, name: string, value: any): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Same as `updateData` but updates many within same transaction
|
|
20
|
+
*
|
|
21
|
+
* The `data` field is assumed to be JSON. Just the field with the given
|
|
22
|
+
* name is updated and the rest is unchanged.
|
|
23
|
+
* @param request the Fastifdy request
|
|
24
|
+
* @param dataArray data to update
|
|
25
|
+
*/
|
|
26
|
+
abstract updateManySessionData(request: FastifyRequest, dataArray: {
|
|
27
|
+
dataName: string;
|
|
28
|
+
value: any;
|
|
29
|
+
}[]): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Deletes a field from the session data in the key storage record,
|
|
32
|
+
*
|
|
33
|
+
* The `data` field is assumed to be JSON. Just the field with the given
|
|
34
|
+
* name is updated and the rest is unchanged.
|
|
35
|
+
* @param request the Fastifdy request
|
|
36
|
+
* @param name the field within `data` to update
|
|
37
|
+
*/
|
|
38
|
+
abstract deleteSessionData(request: FastifyRequest, name: string): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Return data stored in the session with key `name` or undefined if not present
|
|
41
|
+
* @param request the Fastify request
|
|
42
|
+
* @param name name of the data to fetch
|
|
43
|
+
* @return an object of the data, or undefined
|
|
44
|
+
*/
|
|
45
|
+
abstract getSessionData(request: FastifyRequest, name: string): Promise<{
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
} | undefined>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { FastifySessionServer, FastifySessionServerOptions } from './fastifysession';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This class provides user endpoints for the Fastify server for manipulating
|
|
5
|
+
* OAuth clients.
|
|
6
|
+
*
|
|
7
|
+
* Endpoints include changeing password, editing the User record, etc.
|
|
8
|
+
*
|
|
9
|
+
* This class is not intended to be created directly. It is created
|
|
10
|
+
* by {@link FastifySessionServer}. For a description of the endpoints,
|
|
11
|
+
* and how to create templates for them, see that class.
|
|
12
|
+
*/
|
|
13
|
+
export declare class FastifyUserClientEndpoints {
|
|
14
|
+
private sessionServer;
|
|
15
|
+
private clientStorage;
|
|
16
|
+
private clientManager;
|
|
17
|
+
private prefix;
|
|
18
|
+
private clientSearchFn;
|
|
19
|
+
private validFlows;
|
|
20
|
+
private selectClientPage;
|
|
21
|
+
private createClientPage;
|
|
22
|
+
private updateClientPage;
|
|
23
|
+
private deleteClientPage;
|
|
24
|
+
/**
|
|
25
|
+
* Constructor
|
|
26
|
+
* @param sessionServer instance of the Fatify session server this is being added to
|
|
27
|
+
* @param options See {@link FastifySessionServerOptions}
|
|
28
|
+
*/
|
|
29
|
+
constructor(sessionServer: FastifySessionServer, options?: FastifySessionServerOptions);
|
|
30
|
+
/**
|
|
31
|
+
* Adds the `selectclient` GET endpoint.
|
|
32
|
+
*/
|
|
33
|
+
addSelectClientEndpoints(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Adds the `createclient` GET and POST endpoints.
|
|
36
|
+
*/
|
|
37
|
+
addCreateClientEndpoints(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Adds the `api/createclient` POST endpointss.
|
|
40
|
+
*/
|
|
41
|
+
addApiCreateClientEndpoints(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Adds the `updateclient` GET and POST endpoints.
|
|
44
|
+
*/
|
|
45
|
+
addUpdateClientEndpoints(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Adds the `api/updateclient` POST endpoints.
|
|
48
|
+
*/
|
|
49
|
+
addApiUpdateClientEndpoints(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Adds the `deleteclient` GET and POST endpoints.
|
|
52
|
+
*/
|
|
53
|
+
addDeleteClientEndpoints(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Adds the `api/deleteclient` POST endpoint.
|
|
56
|
+
*/
|
|
57
|
+
addApiDeleteClientEndpoints(): void;
|
|
58
|
+
private createClient;
|
|
59
|
+
private updateClient;
|
|
60
|
+
private deleteClient;
|
|
61
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { FastifySessionServer, FastifySessionServerOptions, CsrfBodyType } from './fastifysession';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type for Fastify request body when making an updateuser request.
|
|
5
|
+
* Allows any key value since developers can add fields to the User object.
|
|
6
|
+
*/
|
|
7
|
+
export interface UpdateUserBodyType extends CsrfBodyType {
|
|
8
|
+
[key: string]: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Query parameters for the changefactor2 GET endpoint
|
|
12
|
+
*/
|
|
13
|
+
export interface ChangeFactor2QueryType {
|
|
14
|
+
next?: string;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Body parameters for the changefactor2 POST endpoint
|
|
19
|
+
*/
|
|
20
|
+
export interface ChangeFactor2BodyType extends CsrfBodyType {
|
|
21
|
+
factor2: string;
|
|
22
|
+
next?: string;
|
|
23
|
+
required?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Query parameters for the changepassword GET endpoint
|
|
27
|
+
*/
|
|
28
|
+
export interface ChangePasswordQueryType {
|
|
29
|
+
next?: string;
|
|
30
|
+
required?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Body parameters for the changepassword POST endpoint
|
|
34
|
+
*/
|
|
35
|
+
export interface ChangePasswordBodyType extends CsrfBodyType {
|
|
36
|
+
oldPassword: string;
|
|
37
|
+
newPassword: string;
|
|
38
|
+
repeatPassword?: string;
|
|
39
|
+
next?: string;
|
|
40
|
+
required?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Query parameters for the configurefactor2 GET endpoingt
|
|
44
|
+
*/
|
|
45
|
+
export interface ConfigureFactor2QueryType {
|
|
46
|
+
next?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Body parameters for the configurefactor2 POST endpoint
|
|
50
|
+
*/
|
|
51
|
+
export interface ConfigureFactor2BodyType extends CsrfBodyType {
|
|
52
|
+
next?: string;
|
|
53
|
+
otp?: string;
|
|
54
|
+
token?: string;
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Query parameters for the requestpasswordreset GET endpoint
|
|
59
|
+
*/
|
|
60
|
+
export interface RequestPasswordResetQueryType {
|
|
61
|
+
next?: string;
|
|
62
|
+
required?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Body parameters for the requestpasswordreset POST endpoint
|
|
66
|
+
*/
|
|
67
|
+
export interface RequestPasswordResetBodyType extends CsrfBodyType {
|
|
68
|
+
email: string;
|
|
69
|
+
next?: string;
|
|
70
|
+
required?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Body parameters for the resetpassword POST endpoint
|
|
74
|
+
*/
|
|
75
|
+
export interface ResetPasswordBodyType extends CsrfBodyType {
|
|
76
|
+
token: string;
|
|
77
|
+
newPassword: string;
|
|
78
|
+
repeatPassword?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* URL parameter for the verifytoken endpoint
|
|
82
|
+
*/
|
|
83
|
+
export interface VerifyTokenParamType {
|
|
84
|
+
token: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* This class provides user endpoints for the Fastify server.
|
|
88
|
+
*
|
|
89
|
+
* Endpoints include changeing password, editing the User record, etc.
|
|
90
|
+
*
|
|
91
|
+
* This class is not intended to be created directly. It is created
|
|
92
|
+
* by {@link FastifySessionServer}. For a description of the endpoints,
|
|
93
|
+
* and how to create templates for them, see that class.
|
|
94
|
+
*/
|
|
95
|
+
export declare class FastifyUserEndpoints {
|
|
96
|
+
private sessionServer;
|
|
97
|
+
private enableEmailVerification;
|
|
98
|
+
private enablePasswordReset;
|
|
99
|
+
/**
|
|
100
|
+
* The app prefix that was set during construction,
|
|
101
|
+
*/
|
|
102
|
+
readonly prefix: string;
|
|
103
|
+
private updateUserPage;
|
|
104
|
+
private changeFactor2Page;
|
|
105
|
+
private configureFactor2Page;
|
|
106
|
+
private changePasswordPage;
|
|
107
|
+
private resetPasswordPage;
|
|
108
|
+
private requestPasswordResetPage;
|
|
109
|
+
private emailVerifiedPage;
|
|
110
|
+
private signupPage;
|
|
111
|
+
private deleteUserPage;
|
|
112
|
+
/**
|
|
113
|
+
* Constructor.
|
|
114
|
+
*
|
|
115
|
+
* @param sessionServer the instance of the Fastify session server this
|
|
116
|
+
* object belongs to
|
|
117
|
+
* @param options See {@link FastifySessionServerOptions}
|
|
118
|
+
*/
|
|
119
|
+
constructor(sessionServer: FastifySessionServer, options?: FastifySessionServerOptions);
|
|
120
|
+
/**
|
|
121
|
+
* Adds the `updateuser` GET and POST endpoints.
|
|
122
|
+
*/
|
|
123
|
+
addUpdateUserEndpoints(): void;
|
|
124
|
+
/**
|
|
125
|
+
* Adds the `api/updateuser` POST endpoint.
|
|
126
|
+
*/
|
|
127
|
+
addApiUpdateUserEndpoints(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Adds the `changefactor2` GET and POST endpoints.
|
|
130
|
+
*/
|
|
131
|
+
addChangeFactor2Endpoints(): void;
|
|
132
|
+
/**
|
|
133
|
+
* Adds the `api/changefactort2` POST endpoint.
|
|
134
|
+
*/
|
|
135
|
+
addApiChangeFactor2Endpoints(): void;
|
|
136
|
+
/**
|
|
137
|
+
* Adds the `changepassword` GET and POST endpoints.
|
|
138
|
+
*/
|
|
139
|
+
addChangePasswordEndpoints(): void;
|
|
140
|
+
/**
|
|
141
|
+
* Adds the `api/changepassword` POST endpoint.
|
|
142
|
+
*/
|
|
143
|
+
addApiChangePasswordEndpoints(): void;
|
|
144
|
+
/**
|
|
145
|
+
* Adds the `configurefactor2` GET and POST endpoints.
|
|
146
|
+
*/
|
|
147
|
+
addConfigureFactor2Endpoints(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Adds the `api/configurefactor2` POST endpoint.
|
|
150
|
+
*/
|
|
151
|
+
addApiConfigureFactor2Endpoints(prefix: string): void;
|
|
152
|
+
/**
|
|
153
|
+
* Adds the `requestpasswordreset` GET and POST endpoints.
|
|
154
|
+
*/
|
|
155
|
+
addRequestPasswordResetEndpoints(): void;
|
|
156
|
+
/**
|
|
157
|
+
* Adds the `api/requestpasswordreset`POST endpoint.
|
|
158
|
+
*/
|
|
159
|
+
addApiRequestPasswordResetEndpoints(): void;
|
|
160
|
+
/**
|
|
161
|
+
* Adds the `resetpassword` GET and POST endpoints.
|
|
162
|
+
*/
|
|
163
|
+
addResetPasswordEndpoints(): void;
|
|
164
|
+
/**
|
|
165
|
+
* Adds the `api/resetpassword` POST endpoint.
|
|
166
|
+
*/
|
|
167
|
+
addApiResetPasswordEndpoints(): void;
|
|
168
|
+
/**
|
|
169
|
+
* Adds the `verifyemail` GET and POST endpoints.
|
|
170
|
+
*/
|
|
171
|
+
addVerifyEmailEndpoints(): void;
|
|
172
|
+
/**
|
|
173
|
+
* Adds the `api/verifyemail` POST endpoint.
|
|
174
|
+
*/
|
|
175
|
+
addApiVerifyEmailEndpoints(): void;
|
|
176
|
+
/**
|
|
177
|
+
* Adds the `deleteuser` GET and POST endpoints.
|
|
178
|
+
*/
|
|
179
|
+
addDeleteUserEndpoints(): void;
|
|
180
|
+
/**
|
|
181
|
+
* Adds the `api/deleteuser` POST endpoint.
|
|
182
|
+
*/
|
|
183
|
+
addApiDeleteUserEndpoints(): void;
|
|
184
|
+
private updateUser;
|
|
185
|
+
private changeFactor2;
|
|
186
|
+
private changePassword;
|
|
187
|
+
private configureFactor2;
|
|
188
|
+
private reconfigureFactor2;
|
|
189
|
+
private requestPasswordReset;
|
|
190
|
+
private resetPassword;
|
|
191
|
+
private verifyEmail;
|
|
192
|
+
private deleteUser;
|
|
193
|
+
}
|