1 | import type { Application, Id, NullableId, Paginated, Params, Query } from '@feathersjs/feathers';
|
2 | export interface User {
|
3 | isVerified: boolean;
|
4 | verifyToken: string;
|
5 | verifyShortToken: string;
|
6 | verifyExpires: Date | number;
|
7 | verifyChanges: VerifyChanges;
|
8 | resetToken: string;
|
9 | resetShortToken: string;
|
10 | resetExpires: Date | number;
|
11 | resetAttempts: number;
|
12 | password: string;
|
13 | [key: string]: any;
|
14 | [key: number]: any;
|
15 | }
|
16 | export type ArrayOrPaginated<T> = T[] | Paginated<T>;
|
17 | export type UsersArrayOrPaginated = ArrayOrPaginated<User>;
|
18 | export type NotifierOptions = Record<string, any>;
|
19 | export type VerifyChanges = Record<string, any>;
|
20 | export interface Tokens {
|
21 | resetToken?: string;
|
22 | resetShortToken?: string;
|
23 | verifyShortToken?: string;
|
24 | verifyToken?: string;
|
25 | }
|
26 | export type IdentifyUser = Query;
|
27 | export type Notifier = (type: NotificationType, user: Partial<User>, notifierOptions?: NotifierOptions) => any;
|
28 | export type SanitizeUserForClient = (user: Partial<User>) => SanitizedUser;
|
29 | export type SanitizedUser = Partial<User>;
|
30 | export type NotificationType = 'resendVerifySignup' | 'verifySignup' | 'verifySignupSetPassword' | 'sendResetPwd' | 'resetPwd' | 'passwordChange' | 'identityChange';
|
31 | export type AuthenticationManagementAction = 'checkUnique' | 'resendVerifySignup' | 'verifySignupLong' | 'verifySignupShort' | 'verifySignupSetPasswordLong' | 'verifySignupSetPasswordShort' | 'sendResetPwd' | 'resetPwdLong' | 'resetPwdShort' | 'passwordChange' | 'identityChange' | 'options';
|
32 | export type ActionPathMap<T> = {
|
33 | [key in Exclude<AuthenticationManagementAction, 'options'>]: T;
|
34 | };
|
35 | export type GetUserDataCheckProps = Array<'isNotVerified' | 'isNotVerifiedOrHasVerifyChanges' | 'isVerified' | 'verifyNotExpired' | 'resetNotExpired'>;
|
36 | export interface AuthenticationManagementServiceOptions {
|
37 | |
38 |
|
39 | service: string;
|
40 | |
41 |
|
42 | skipIsVerifiedCheck: boolean;
|
43 | |
44 |
|
45 | notifier: Notifier;
|
46 | |
47 |
|
48 | longTokenLen: number;
|
49 | |
50 |
|
51 | shortTokenLen: number;
|
52 | |
53 |
|
54 | shortTokenDigits: boolean;
|
55 | |
56 |
|
57 | resetDelay: number;
|
58 | |
59 |
|
60 |
|
61 | delay: number;
|
62 | |
63 |
|
64 | resetAttempts: number;
|
65 | |
66 |
|
67 | reuseResetToken: boolean;
|
68 | |
69 |
|
70 |
|
71 | identifyUserProps: string[];
|
72 | |
73 |
|
74 |
|
75 | sanitizeUserForClient: (user: User) => Partial<User>;
|
76 | |
77 |
|
78 | passwordField: string;
|
79 |
|
80 | skipPasswordHash: boolean;
|
81 |
|
82 | passParams: (params: any) => Params | Promise<Params>;
|
83 | }
|
84 | export type AuthenticationManagementSetupOptions = AuthenticationManagementServiceOptions & {
|
85 | path: string;
|
86 | };
|
87 | export type VerifySignupLongServiceOptions = Pick<AuthenticationManagementServiceOptions, 'service' | 'notifier' | 'sanitizeUserForClient' | 'passParams'>;
|
88 | export type VerifySignupOptions = VerifySignupLongServiceOptions & {
|
89 | app: Application;
|
90 | };
|
91 | export type VerifySignupShortServiceOptions = VerifySignupLongServiceOptions & {
|
92 | identifyUserProps: string[];
|
93 | };
|
94 | export type VerifySignupWithShortTokenOptions = VerifySignupShortServiceOptions & {
|
95 | app: Application;
|
96 | };
|
97 | export type VerifySignupSetPasswordLongServiceOptions = Pick<AuthenticationManagementServiceOptions, 'service' | 'sanitizeUserForClient' | 'notifier' | 'passwordField' | 'skipPasswordHash' | 'passParams'>;
|
98 | export type VerifySignupSetPasswordOptions = VerifySignupSetPasswordLongServiceOptions & {
|
99 | app: Application;
|
100 | };
|
101 | export type PasswordChangeServiceOptions = Pick<AuthenticationManagementServiceOptions, 'service' | 'identifyUserProps' | 'notifier' | 'sanitizeUserForClient' | 'passwordField' | 'skipPasswordHash' | 'passParams'>;
|
102 | export type PasswordChangeOptions = PasswordChangeServiceOptions & {
|
103 | app: Application;
|
104 | };
|
105 | export type VerifySignupSetPasswordShortServiceOptions = VerifySignupSetPasswordLongServiceOptions & Pick<AuthenticationManagementServiceOptions, 'identifyUserProps'>;
|
106 | export type VerifySignupSetPasswordWithShortTokenOptions = VerifySignupSetPasswordShortServiceOptions & {
|
107 | app: Application;
|
108 | };
|
109 | export type ResetPasswordServiceOptions = Pick<AuthenticationManagementServiceOptions, 'service' | 'skipIsVerifiedCheck' | 'reuseResetToken' | 'notifier' | 'sanitizeUserForClient' | 'passwordField' | 'skipPasswordHash' | 'passParams'>;
|
110 | export type ResetPasswordOptions = ResetPasswordServiceOptions & {
|
111 | app: Application;
|
112 | };
|
113 | export type ResetPwdWithShortServiceOptions = ResetPasswordServiceOptions & {
|
114 | identifyUserProps: string[];
|
115 | };
|
116 | export type ResetPwdWithShortTokenOptions = ResetPwdWithShortServiceOptions & {
|
117 | app: Application;
|
118 | };
|
119 | export type ResendVerifySignupServiceOptions = Pick<AuthenticationManagementServiceOptions, 'service' | 'identifyUserProps' | 'delay' | 'longTokenLen' | 'shortTokenLen' | 'shortTokenDigits' | 'notifier' | 'sanitizeUserForClient' | 'passParams'>;
|
120 | export type ResendVerifySignupOptions = ResendVerifySignupServiceOptions & {
|
121 | app: Application;
|
122 | };
|
123 | export type IdentityChangeServiceOptions = Pick<AuthenticationManagementServiceOptions, 'service' | 'identifyUserProps' | 'delay' | 'longTokenLen' | 'shortTokenLen' | 'shortTokenDigits' | 'notifier' | 'sanitizeUserForClient' | 'passwordField' | 'passParams'>;
|
124 | export type IdentityChangeOptions = IdentityChangeServiceOptions & {
|
125 | app: Application;
|
126 | };
|
127 | export type CheckUniqueServiceOptions = Pick<AuthenticationManagementServiceOptions, 'service' | 'passParams'>;
|
128 | export type CheckUniqueOptions = CheckUniqueServiceOptions & {
|
129 | app: Application;
|
130 | };
|
131 | export type SendResetPwdServiceOptions = Pick<AuthenticationManagementServiceOptions, 'service' | 'identifyUserProps' | 'skipIsVerifiedCheck' | 'reuseResetToken' | 'resetDelay' | 'sanitizeUserForClient' | 'resetAttempts' | 'shortTokenLen' | 'longTokenLen' | 'shortTokenDigits' | 'notifier' | 'passwordField' | 'passParams'>;
|
132 | export type SendResetPwdOptions = SendResetPwdServiceOptions & {
|
133 | app: Application;
|
134 | };
|
135 | export interface AuthenticationManagementClient {
|
136 | checkUnique: (identifyUser: IdentifyUser, ownId?: NullableId, ifErrMsg?: boolean) => Promise<void>;
|
137 | resendVerifySignup: (identifyUser: IdentifyUser, notifierOptions: NotifierOptions) => Promise<void>;
|
138 | verifySignupLong: (verifyToken: string) => Promise<void>;
|
139 | verifySignupShort: (verifyToken: string, identifyUser: IdentifyUser) => Promise<void>;
|
140 | sendResetPwd: (IdentifyUser: IdentifyUser, notifierOptions: NotifierOptions) => Promise<void>;
|
141 | resetPwdLong: (resetToken: string, password: string) => Promise<void>;
|
142 | resetPwdShort: (resetShortToken: string, identifyUser: IdentifyUser, password: string) => Promise<void>;
|
143 | passwordChange: (oldPassword: string, password: string, identifyUser: IdentifyUser) => Promise<void>;
|
144 | identityChange: (password: string, changesIdentifyUser: NotifierOptions, identifyUser: IdentifyUser) => Promise<void>;
|
145 | authenticate: (email: string, password: string, cb?: (err: Error | null, user?: Partial<User>) => void) => Promise<any>;
|
146 | }
|
147 | export interface WithNotifierOptions {
|
148 | notifierOptions?: NotifierOptions;
|
149 | }
|
150 | export type AuthenticationManagementData = DataCheckUniqueWithAction | DataIdentityChangeWithAction | DataOptions | DataPasswordChangeWithAction | DataResendVerifySignupWithAction | DataResetPwdLongWithAction | DataResetPwdShortWithAction | DataSendResetPwdWithAction | DataVerifySignupLongWithAction | DataVerifySignupSetPasswordLongWithAction | DataVerifySignupSetPasswordShortWithAction | DataVerifySignupShortWithAction;
|
151 | export interface DataCheckUnique {
|
152 | user: IdentifyUser;
|
153 | ownId?: Id;
|
154 | meta?: {
|
155 | noErrMsg: boolean;
|
156 | };
|
157 | }
|
158 | export interface DataCheckUniqueWithAction {
|
159 | action: 'checkUnique';
|
160 | value: IdentifyUser;
|
161 | ownId?: Id;
|
162 | meta?: {
|
163 | noErrMsg: boolean;
|
164 | };
|
165 | }
|
166 | export interface DataIdentityChange extends WithNotifierOptions {
|
167 | changes: Record<string, any>;
|
168 | password: string;
|
169 | user: IdentifyUser;
|
170 | }
|
171 | export interface DataIdentityChangeWithAction extends WithNotifierOptions {
|
172 | action: 'identityChange';
|
173 | value: {
|
174 | changes: Record<string, any>;
|
175 | password: string;
|
176 | user: IdentifyUser;
|
177 | };
|
178 | }
|
179 | export interface DataPasswordChange extends WithNotifierOptions {
|
180 | oldPassword: string;
|
181 | password: string;
|
182 | user: IdentifyUser;
|
183 | }
|
184 | export interface DataPasswordChangeWithAction extends WithNotifierOptions {
|
185 | action: 'passwordChange';
|
186 | value: {
|
187 | oldPassword: string;
|
188 | password: string;
|
189 | user: IdentifyUser;
|
190 | };
|
191 | }
|
192 | export interface DataResendVerifySignup extends WithNotifierOptions {
|
193 | user: IdentifyUser;
|
194 | }
|
195 | export interface DataResendVerifySignupWithAction extends WithNotifierOptions {
|
196 | action: 'resendVerifySignup';
|
197 | value: IdentifyUser;
|
198 | }
|
199 | export interface DataResetPwdLong extends WithNotifierOptions {
|
200 | password: string;
|
201 | token: string;
|
202 | }
|
203 | export interface DataResetPwdLongWithAction extends WithNotifierOptions {
|
204 | action: 'resetPwdLong';
|
205 | value: {
|
206 | password: string;
|
207 | token: string;
|
208 | };
|
209 | }
|
210 | export interface DataResetPwdShort extends WithNotifierOptions {
|
211 | password: string;
|
212 | token: string;
|
213 | user: IdentifyUser;
|
214 | }
|
215 | export interface DataResetPwdShortWithAction extends WithNotifierOptions {
|
216 | action: 'resetPwdShort';
|
217 | value: {
|
218 | password: string;
|
219 | token: string;
|
220 | user: IdentifyUser;
|
221 | };
|
222 | }
|
223 | export interface DataSendResetPwd extends WithNotifierOptions {
|
224 | user: IdentifyUser;
|
225 | }
|
226 | export interface DataSendResetPwdWithAction extends WithNotifierOptions {
|
227 | action: 'sendResetPwd';
|
228 | value: IdentifyUser;
|
229 | }
|
230 | export interface DataVerifySignupLong extends WithNotifierOptions {
|
231 | token: string;
|
232 | }
|
233 | export interface DataVerifySignupLongWithAction extends WithNotifierOptions {
|
234 | action: 'verifySignupLong';
|
235 | value: string;
|
236 | }
|
237 | export interface DataVerifySignupSetPasswordLong extends WithNotifierOptions {
|
238 | password: string;
|
239 | token: string;
|
240 | }
|
241 | export interface DataVerifySignupSetPasswordLongWithAction extends WithNotifierOptions {
|
242 | action: 'verifySignupSetPasswordLong';
|
243 | value: {
|
244 | password: string;
|
245 | token: string;
|
246 | };
|
247 | }
|
248 | export interface DataVerifySignupSetPasswordShort extends WithNotifierOptions {
|
249 | password: string;
|
250 | token: string;
|
251 | user: IdentifyUser;
|
252 | }
|
253 | export interface DataVerifySignupSetPasswordShortWithAction extends WithNotifierOptions {
|
254 | action: 'verifySignupSetPasswordShort';
|
255 | value: {
|
256 | password: string;
|
257 | token: string;
|
258 | user: IdentifyUser;
|
259 | };
|
260 | }
|
261 | export interface DataVerifySignupShort extends WithNotifierOptions {
|
262 | token: string;
|
263 | user: IdentifyUser;
|
264 | }
|
265 | export interface DataVerifySignupShortWithAction extends WithNotifierOptions {
|
266 | action: 'verifySignupShort';
|
267 | value: {
|
268 | token: string;
|
269 | user: IdentifyUser;
|
270 | };
|
271 | }
|
272 | export interface DataOptions {
|
273 | action: 'options';
|
274 | }
|
275 | export interface ClientOptions {
|
276 | path: string;
|
277 | }
|