@aeriajs/builtins 0.0.231 → 0.0.233
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/authentication.d.ts +4 -4
- package/dist/authentication.js +4 -5
- package/dist/authentication.mjs +4 -5
- package/dist/collections/file/download.d.ts +7 -8
- package/dist/collections/file/download.js +4 -5
- package/dist/collections/file/download.mjs +4 -5
- package/dist/collections/file/index.d.ts +18 -18
- package/dist/collections/file/remove.d.ts +12 -12
- package/dist/collections/file/removeAll.d.ts +2 -2
- package/dist/collections/user/activate.d.ts +17 -17
- package/dist/collections/user/activate.js +10 -11
- package/dist/collections/user/activate.mjs +10 -11
- package/dist/collections/user/authenticate.d.ts +7 -8
- package/dist/collections/user/createAccount.d.ts +10 -10
- package/dist/collections/user/createAccount.js +4 -5
- package/dist/collections/user/createAccount.mjs +4 -5
- package/dist/collections/user/description.d.ts +1 -0
- package/dist/collections/user/description.js +1 -0
- package/dist/collections/user/description.mjs +2 -1
- package/dist/collections/user/editProfile.d.ts +4 -3
- package/dist/collections/user/getActivationLink.d.ts +13 -14
- package/dist/collections/user/getCurrentUser.d.ts +6 -5
- package/dist/collections/user/getCurrentUser.js +5 -6
- package/dist/collections/user/getCurrentUser.mjs +5 -6
- package/dist/collections/user/getInfo.d.ts +13 -13
- package/dist/collections/user/getInfo.js +9 -10
- package/dist/collections/user/getInfo.mjs +9 -10
- package/dist/collections/user/getRedefinePasswordLink.d.ts +11 -12
- package/dist/collections/user/index.d.ts +85 -78
- package/dist/collections/user/insert.d.ts +8 -9
- package/dist/collections/user/redefinePassword.d.ts +17 -17
- package/dist/collections/user/redefinePassword.js +10 -11
- package/dist/collections/user/redefinePassword.mjs +10 -11
- package/dist/functions/describe.d.ts +9 -9
- package/dist/index.d.ts +103 -96
- package/package.json +15 -15
|
@@ -68,6 +68,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
68
68
|
readonly picture: "picture_file";
|
|
69
69
|
readonly information: "email";
|
|
70
70
|
readonly active: "active";
|
|
71
|
+
readonly translateBadge: true;
|
|
71
72
|
};
|
|
72
73
|
};
|
|
73
74
|
readonly individualActions: {
|
|
@@ -173,6 +174,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
173
174
|
readonly picture: "picture_file";
|
|
174
175
|
readonly information: "email";
|
|
175
176
|
readonly active: "active";
|
|
177
|
+
readonly translateBadge: true;
|
|
176
178
|
};
|
|
177
179
|
};
|
|
178
180
|
readonly individualActions: {
|
|
@@ -218,19 +220,19 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
218
220
|
readonly error: undefined;
|
|
219
221
|
readonly result: import("mongodb").WithId<Omit<import("@aeriajs/types").PackReferences<import("@aeriajs/types").SchemaWithId<import("@aeriajs/types").Description>>, "_id">> | null;
|
|
220
222
|
} | import("@aeriajs/types").Result.Error<{
|
|
221
|
-
readonly code:
|
|
223
|
+
readonly code: "RESOURCE_NOT_FOUND";
|
|
222
224
|
} & {
|
|
223
|
-
httpStatus:
|
|
225
|
+
httpStatus: 404;
|
|
224
226
|
}> | import("@aeriajs/types").Result.Error<{
|
|
225
|
-
readonly code:
|
|
227
|
+
readonly code: "OWNERSHIP_ERROR";
|
|
226
228
|
} & {
|
|
227
|
-
httpStatus:
|
|
229
|
+
httpStatus: 403;
|
|
228
230
|
}>>;
|
|
229
231
|
readonly upload: (payload: unknown, context: Omit<Context, "token">) => Promise<import("@aeriajs/types").Result.Error<{
|
|
230
|
-
readonly code:
|
|
232
|
+
readonly code: "MALFORMED_INPUT";
|
|
231
233
|
readonly details: import("@aeriajs/types").ValidationError | import("@aeriajs/types").PropertyValidationError;
|
|
232
234
|
} & {
|
|
233
|
-
httpStatus:
|
|
235
|
+
httpStatus: 400;
|
|
234
236
|
}> | {
|
|
235
237
|
readonly _tag: "Result";
|
|
236
238
|
readonly error: undefined;
|
|
@@ -243,29 +245,29 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
243
245
|
readonly error: undefined;
|
|
244
246
|
readonly result: any;
|
|
245
247
|
} | import("@aeriajs/types").Result.Error<{
|
|
246
|
-
readonly code:
|
|
248
|
+
readonly code: "OWNERSHIP_ERROR";
|
|
247
249
|
} & {
|
|
248
|
-
httpStatus:
|
|
250
|
+
httpStatus: 403;
|
|
249
251
|
}>>;
|
|
250
252
|
readonly insert: (payload: NoInfer<import("@aeriajs/types").InsertPayload<import("@aeriajs/types").SchemaWithId<import("@aeriajs/types").Description>>>, context: Omit<Context, "token">) => Promise<import("@aeriajs/types").Result.Error<{
|
|
251
|
-
readonly code:
|
|
253
|
+
readonly code: "AUTHORIZATION_ERROR";
|
|
252
254
|
readonly message: "user is not allowed to edit other users roles";
|
|
253
255
|
} & {
|
|
254
|
-
httpStatus:
|
|
256
|
+
httpStatus: 403;
|
|
255
257
|
}> | import("@aeriajs/types").Result.Error<{
|
|
256
|
-
readonly code:
|
|
258
|
+
readonly code: "AUTHORIZATION_ERROR";
|
|
257
259
|
readonly message: "tried to set unallowed roles";
|
|
258
260
|
} & {
|
|
259
|
-
httpStatus:
|
|
261
|
+
httpStatus: 403;
|
|
260
262
|
}> | import("@aeriajs/types").Result.Error<{
|
|
261
|
-
readonly code:
|
|
263
|
+
readonly code: "RESOURCE_NOT_FOUND";
|
|
262
264
|
} & {
|
|
263
|
-
httpStatus:
|
|
265
|
+
httpStatus: 404;
|
|
264
266
|
}> | import("@aeriajs/types").Result.Error<{
|
|
265
|
-
readonly code:
|
|
267
|
+
readonly code: "AUTHORIZATION_ERROR";
|
|
266
268
|
readonly message: "tried to edit an user with a role higher in the hierarchy";
|
|
267
269
|
} & {
|
|
268
|
-
httpStatus:
|
|
270
|
+
httpStatus: 403;
|
|
269
271
|
}> | import("@aeriajs/types").InsertReturnType<import("@aeriajs/types").SchemaWithId<import("@aeriajs/types").Description>>>;
|
|
270
272
|
readonly editProfile: (payload: Partial<import("@aeriajs/types").PackReferences<import("@aeriajs/types").SchemaWithId<{
|
|
271
273
|
readonly $id: "user";
|
|
@@ -335,6 +337,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
335
337
|
readonly picture: "picture_file";
|
|
336
338
|
readonly information: "email";
|
|
337
339
|
readonly active: "active";
|
|
340
|
+
readonly translateBadge: true;
|
|
338
341
|
};
|
|
339
342
|
};
|
|
340
343
|
readonly individualActions: {
|
|
@@ -439,6 +442,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
439
442
|
readonly picture: "picture_file";
|
|
440
443
|
readonly information: "email";
|
|
441
444
|
readonly active: "active";
|
|
445
|
+
readonly translateBadge: true;
|
|
442
446
|
};
|
|
443
447
|
};
|
|
444
448
|
readonly individualActions: {
|
|
@@ -476,9 +480,9 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
476
480
|
};
|
|
477
481
|
};
|
|
478
482
|
}>> | import("@aeriajs/types").Result.Error<{
|
|
479
|
-
readonly code:
|
|
483
|
+
readonly code: "TARGET_IMMUTABLE";
|
|
480
484
|
} & {
|
|
481
|
-
httpStatus:
|
|
485
|
+
httpStatus: 403;
|
|
482
486
|
}>>;
|
|
483
487
|
readonly authenticate: (payload: {
|
|
484
488
|
email: string;
|
|
@@ -487,9 +491,9 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
487
491
|
token?: import("@aeriajs/types").TokenRecipient;
|
|
488
492
|
revalidate: true;
|
|
489
493
|
}, context: Omit<Context, "token">) => Promise<import("@aeriajs/types").Result.Error<{
|
|
490
|
-
readonly code:
|
|
494
|
+
readonly code: "AUTHORIZATION_ERROR";
|
|
491
495
|
} & {
|
|
492
|
-
httpStatus:
|
|
496
|
+
httpStatus: 401;
|
|
493
497
|
}> | {
|
|
494
498
|
readonly _tag: "Result";
|
|
495
499
|
readonly error: undefined;
|
|
@@ -511,38 +515,38 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
511
515
|
readonly error: undefined;
|
|
512
516
|
readonly result: import("../../authentication.js").SuccessfulAuthentication;
|
|
513
517
|
} | import("@aeriajs/types").Result.Error<{
|
|
514
|
-
readonly code:
|
|
518
|
+
readonly code: "INVALID_CREDENTIALS";
|
|
515
519
|
} & {
|
|
516
|
-
httpStatus:
|
|
520
|
+
httpStatus: 401;
|
|
517
521
|
}> | import("@aeriajs/types").Result.Error<{
|
|
518
|
-
readonly code:
|
|
522
|
+
readonly code: "INACTIVE_USER";
|
|
519
523
|
} & {
|
|
520
|
-
httpStatus:
|
|
524
|
+
httpStatus: 401;
|
|
521
525
|
}>>;
|
|
522
526
|
readonly activate: (payload: {
|
|
523
527
|
password?: string;
|
|
524
528
|
userId?: string;
|
|
525
529
|
token?: string;
|
|
526
530
|
}, context: Omit<Context, "token">) => Promise<import("@aeriajs/types").Result.Error<{
|
|
527
|
-
readonly code:
|
|
531
|
+
readonly code: "INVALID_LINK";
|
|
528
532
|
} & {
|
|
529
|
-
httpStatus:
|
|
533
|
+
httpStatus: 404;
|
|
530
534
|
}> | import("@aeriajs/types").Result.Error<{
|
|
531
|
-
readonly code:
|
|
535
|
+
readonly code: "USER_NOT_FOUND";
|
|
532
536
|
} & {
|
|
533
|
-
httpStatus:
|
|
537
|
+
httpStatus: 404;
|
|
534
538
|
}> | import("@aeriajs/types").Result.Error<{
|
|
535
|
-
readonly code:
|
|
539
|
+
readonly code: "ALREADY_ACTIVE_USER";
|
|
536
540
|
} & {
|
|
537
|
-
httpStatus:
|
|
541
|
+
httpStatus: 403;
|
|
538
542
|
}> | import("@aeriajs/types").Result.Error<{
|
|
539
|
-
readonly code:
|
|
543
|
+
readonly code: "INVALID_TOKEN";
|
|
540
544
|
} & {
|
|
541
|
-
httpStatus:
|
|
545
|
+
httpStatus: 401;
|
|
542
546
|
}> | import("@aeriajs/types").Result.Error<{
|
|
543
|
-
readonly code:
|
|
547
|
+
readonly code: "MALFORMED_INPUT";
|
|
544
548
|
} & {
|
|
545
|
-
httpStatus:
|
|
549
|
+
httpStatus: 422;
|
|
546
550
|
}> | {
|
|
547
551
|
readonly _tag: "Result";
|
|
548
552
|
readonly error: undefined;
|
|
@@ -618,6 +622,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
618
622
|
readonly picture: "picture_file";
|
|
619
623
|
readonly information: "email";
|
|
620
624
|
readonly active: "active";
|
|
625
|
+
readonly translateBadge: true;
|
|
621
626
|
};
|
|
622
627
|
};
|
|
623
628
|
readonly individualActions: {
|
|
@@ -655,18 +660,18 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
655
660
|
};
|
|
656
661
|
};
|
|
657
662
|
}>>> & Record<string, unknown>, context: Omit<Context, "token">) => Promise<import("@aeriajs/types").Result.Error<{
|
|
658
|
-
readonly code:
|
|
663
|
+
readonly code: "SIGNUP_DISALLOWED";
|
|
659
664
|
} & {
|
|
660
|
-
httpStatus:
|
|
665
|
+
httpStatus: 403;
|
|
661
666
|
}> | import("@aeriajs/types").Result.Error<{
|
|
662
|
-
readonly code:
|
|
667
|
+
readonly code: "MALFORMED_INPUT";
|
|
663
668
|
readonly details: import("@aeriajs/types").PropertyValidationError | import("@aeriajs/types").ValidationError;
|
|
664
669
|
} & {
|
|
665
|
-
httpStatus:
|
|
670
|
+
httpStatus: 400;
|
|
666
671
|
}> | import("@aeriajs/types").Result.Error<{
|
|
667
|
-
readonly code:
|
|
672
|
+
readonly code: "OWNERSHIP_ERROR";
|
|
668
673
|
} & {
|
|
669
|
-
httpStatus:
|
|
674
|
+
httpStatus: 403;
|
|
670
675
|
}> | import("@aeriajs/types").InsertReturnType<import("@aeriajs/types").SchemaWithId<{
|
|
671
676
|
readonly $id: "user";
|
|
672
677
|
readonly icon: "users";
|
|
@@ -735,6 +740,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
735
740
|
readonly picture: "picture_file";
|
|
736
741
|
readonly information: "email";
|
|
737
742
|
readonly active: "active";
|
|
743
|
+
readonly translateBadge: true;
|
|
738
744
|
};
|
|
739
745
|
};
|
|
740
746
|
readonly individualActions: {
|
|
@@ -776,17 +782,17 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
776
782
|
userId: string;
|
|
777
783
|
token: string;
|
|
778
784
|
}, context: Omit<Context, "token">) => Promise<import("@aeriajs/types").Result.Error<{
|
|
779
|
-
readonly code:
|
|
785
|
+
readonly code: "INVALID_LINK";
|
|
780
786
|
} & {
|
|
781
|
-
httpStatus:
|
|
787
|
+
httpStatus: 404;
|
|
782
788
|
}> | import("@aeriajs/types").Result.Error<{
|
|
783
|
-
readonly code:
|
|
789
|
+
readonly code: "USER_NOT_FOUND";
|
|
784
790
|
} & {
|
|
785
|
-
httpStatus:
|
|
791
|
+
httpStatus: 404;
|
|
786
792
|
}> | import("@aeriajs/types").Result.Error<{
|
|
787
|
-
readonly code:
|
|
793
|
+
readonly code: "INVALID_TOKEN";
|
|
788
794
|
} & {
|
|
789
|
-
httpStatus:
|
|
795
|
+
httpStatus: 401;
|
|
790
796
|
}> | {
|
|
791
797
|
readonly _tag: "Result";
|
|
792
798
|
readonly error: undefined;
|
|
@@ -877,6 +883,7 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
877
883
|
readonly picture: "picture_file";
|
|
878
884
|
readonly information: "email";
|
|
879
885
|
readonly active: "active";
|
|
886
|
+
readonly translateBadge: true;
|
|
880
887
|
};
|
|
881
888
|
};
|
|
882
889
|
readonly individualActions: {
|
|
@@ -922,10 +929,10 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
922
929
|
readonly _tag: "Error";
|
|
923
930
|
readonly error: Pick<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
|
|
924
931
|
readonly httpStatus: {
|
|
925
|
-
readonly enum: [
|
|
932
|
+
readonly enum: [403, 404, 400];
|
|
926
933
|
};
|
|
927
934
|
readonly code: {
|
|
928
|
-
readonly enum: [
|
|
935
|
+
readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
|
|
929
936
|
};
|
|
930
937
|
readonly message: {
|
|
931
938
|
readonly type: "string";
|
|
@@ -935,16 +942,16 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
935
942
|
readonly additionalProperties: true;
|
|
936
943
|
};
|
|
937
944
|
}>> & {
|
|
938
|
-
code:
|
|
939
|
-
httpStatus:
|
|
945
|
+
code: "RESOURCE_NOT_FOUND" | "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "MALFORMED_INPUT";
|
|
946
|
+
httpStatus: 403 | 400 | 404;
|
|
940
947
|
message: string;
|
|
941
948
|
details: any;
|
|
942
949
|
}, never>, "code" | "httpStatus"> & Partial<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
|
|
943
950
|
readonly httpStatus: {
|
|
944
|
-
readonly enum: [
|
|
951
|
+
readonly enum: [403, 404, 400];
|
|
945
952
|
};
|
|
946
953
|
readonly code: {
|
|
947
|
-
readonly enum: [
|
|
954
|
+
readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
|
|
948
955
|
};
|
|
949
956
|
readonly message: {
|
|
950
957
|
readonly type: "string";
|
|
@@ -954,20 +961,20 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
954
961
|
readonly additionalProperties: true;
|
|
955
962
|
};
|
|
956
963
|
}>> & {
|
|
957
|
-
code:
|
|
958
|
-
httpStatus:
|
|
964
|
+
code: "RESOURCE_NOT_FOUND" | "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "MALFORMED_INPUT";
|
|
965
|
+
httpStatus: 403 | 400 | 404;
|
|
959
966
|
message: string;
|
|
960
967
|
details: any;
|
|
961
968
|
}, never>>;
|
|
962
969
|
readonly result: undefined;
|
|
963
970
|
} | import("@aeriajs/types").Result.Error<{
|
|
964
|
-
readonly code:
|
|
971
|
+
readonly code: "INVALID_LINK";
|
|
965
972
|
} & {
|
|
966
|
-
httpStatus:
|
|
973
|
+
httpStatus: 400;
|
|
967
974
|
}> | import("@aeriajs/types").Result.Error<{
|
|
968
|
-
readonly code:
|
|
975
|
+
readonly code: "ALREADY_ACTIVE_USER";
|
|
969
976
|
} & {
|
|
970
|
-
httpStatus:
|
|
977
|
+
httpStatus: 403;
|
|
971
978
|
}> | {
|
|
972
979
|
readonly _tag: "Result";
|
|
973
980
|
readonly error: undefined;
|
|
@@ -982,10 +989,10 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
982
989
|
readonly _tag: "Error";
|
|
983
990
|
readonly error: Pick<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
|
|
984
991
|
readonly httpStatus: {
|
|
985
|
-
readonly enum: [
|
|
992
|
+
readonly enum: [403, 404, 400];
|
|
986
993
|
};
|
|
987
994
|
readonly code: {
|
|
988
|
-
readonly enum: [
|
|
995
|
+
readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
|
|
989
996
|
};
|
|
990
997
|
readonly message: {
|
|
991
998
|
readonly type: "string";
|
|
@@ -995,16 +1002,16 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
995
1002
|
readonly additionalProperties: true;
|
|
996
1003
|
};
|
|
997
1004
|
}>> & {
|
|
998
|
-
code:
|
|
999
|
-
httpStatus:
|
|
1005
|
+
code: "RESOURCE_NOT_FOUND" | "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "MALFORMED_INPUT";
|
|
1006
|
+
httpStatus: 403 | 400 | 404;
|
|
1000
1007
|
message: string;
|
|
1001
1008
|
details: any;
|
|
1002
1009
|
}, never>, "code" | "httpStatus"> & Partial<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
|
|
1003
1010
|
readonly httpStatus: {
|
|
1004
|
-
readonly enum: [
|
|
1011
|
+
readonly enum: [403, 404, 400];
|
|
1005
1012
|
};
|
|
1006
1013
|
readonly code: {
|
|
1007
|
-
readonly enum: [
|
|
1014
|
+
readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
|
|
1008
1015
|
};
|
|
1009
1016
|
readonly message: {
|
|
1010
1017
|
readonly type: "string";
|
|
@@ -1014,16 +1021,16 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
1014
1021
|
readonly additionalProperties: true;
|
|
1015
1022
|
};
|
|
1016
1023
|
}>> & {
|
|
1017
|
-
code:
|
|
1018
|
-
httpStatus:
|
|
1024
|
+
code: "RESOURCE_NOT_FOUND" | "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "MALFORMED_INPUT";
|
|
1025
|
+
httpStatus: 403 | 400 | 404;
|
|
1019
1026
|
message: string;
|
|
1020
1027
|
details: any;
|
|
1021
1028
|
}, never>>;
|
|
1022
1029
|
readonly result: undefined;
|
|
1023
1030
|
} | import("@aeriajs/types").Result.Error<{
|
|
1024
|
-
readonly code:
|
|
1031
|
+
readonly code: "USER_NOT_ACTIVE";
|
|
1025
1032
|
} & {
|
|
1026
|
-
httpStatus:
|
|
1033
|
+
httpStatus: 403;
|
|
1027
1034
|
}> | {
|
|
1028
1035
|
readonly _tag: "Result";
|
|
1029
1036
|
readonly error: undefined;
|
|
@@ -1036,25 +1043,25 @@ export declare const user: Omit<Collection<never>, "functions" | "description" |
|
|
|
1036
1043
|
userId?: string;
|
|
1037
1044
|
token?: string;
|
|
1038
1045
|
}, context: Omit<Context, "token">) => Promise<import("@aeriajs/types").Result.Error<{
|
|
1039
|
-
readonly code:
|
|
1046
|
+
readonly code: "INVALID_LINK";
|
|
1040
1047
|
} & {
|
|
1041
|
-
httpStatus:
|
|
1048
|
+
httpStatus: 404;
|
|
1042
1049
|
}> | import("@aeriajs/types").Result.Error<{
|
|
1043
|
-
readonly code:
|
|
1050
|
+
readonly code: "USER_NOT_FOUND";
|
|
1044
1051
|
} & {
|
|
1045
|
-
httpStatus:
|
|
1052
|
+
httpStatus: 404;
|
|
1046
1053
|
}> | import("@aeriajs/types").Result.Error<{
|
|
1047
|
-
readonly code:
|
|
1054
|
+
readonly code: "USER_NOT_ACTIVE";
|
|
1048
1055
|
} & {
|
|
1049
|
-
httpStatus:
|
|
1056
|
+
httpStatus: 403;
|
|
1050
1057
|
}> | import("@aeriajs/types").Result.Error<{
|
|
1051
|
-
readonly code:
|
|
1058
|
+
readonly code: "INVALID_TOKEN";
|
|
1052
1059
|
} & {
|
|
1053
|
-
httpStatus:
|
|
1060
|
+
httpStatus: 401;
|
|
1054
1061
|
}> | import("@aeriajs/types").Result.Error<{
|
|
1055
|
-
readonly code:
|
|
1062
|
+
readonly code: "MALFORMED_INPUT";
|
|
1056
1063
|
} & {
|
|
1057
|
-
httpStatus:
|
|
1064
|
+
httpStatus: 422;
|
|
1058
1065
|
}> | {
|
|
1059
1066
|
readonly _tag: "Result";
|
|
1060
1067
|
readonly error: undefined;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import type { Context, SchemaWithId, InsertPayload, Description } from '@aeriajs/types';
|
|
2
|
-
import { HTTPStatus, ACError } from '@aeriajs/types';
|
|
3
2
|
export declare const insert: <TDescription extends Description, TInsertPayload extends InsertPayload<SchemaWithId<TDescription>>>(payload: NoInfer<TInsertPayload>, context: Context<TDescription>) => Promise<import("@aeriajs/types").Result.Error<{
|
|
4
|
-
readonly code:
|
|
3
|
+
readonly code: "AUTHORIZATION_ERROR";
|
|
5
4
|
readonly message: "user is not allowed to edit other users roles";
|
|
6
5
|
} & {
|
|
7
|
-
httpStatus:
|
|
6
|
+
httpStatus: 403;
|
|
8
7
|
}> | import("@aeriajs/types").Result.Error<{
|
|
9
|
-
readonly code:
|
|
8
|
+
readonly code: "AUTHORIZATION_ERROR";
|
|
10
9
|
readonly message: "tried to set unallowed roles";
|
|
11
10
|
} & {
|
|
12
|
-
httpStatus:
|
|
11
|
+
httpStatus: 403;
|
|
13
12
|
}> | import("@aeriajs/types").Result.Error<{
|
|
14
|
-
readonly code:
|
|
13
|
+
readonly code: "RESOURCE_NOT_FOUND";
|
|
15
14
|
} & {
|
|
16
|
-
httpStatus:
|
|
15
|
+
httpStatus: 404;
|
|
17
16
|
}> | import("@aeriajs/types").Result.Error<{
|
|
18
|
-
readonly code:
|
|
17
|
+
readonly code: "AUTHORIZATION_ERROR";
|
|
19
18
|
readonly message: "tried to edit an user with a role higher in the hierarchy";
|
|
20
19
|
} & {
|
|
21
|
-
httpStatus:
|
|
20
|
+
httpStatus: 403;
|
|
22
21
|
}> | import("@aeriajs/types").InsertReturnType<SchemaWithId<TDescription>>>;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import type { Context } from '@aeriajs/types';
|
|
2
2
|
import type { description } from './description.js';
|
|
3
3
|
import { ObjectId } from '@aeriajs/core';
|
|
4
|
-
import { Result
|
|
5
|
-
export declare
|
|
6
|
-
UserNotFound
|
|
7
|
-
UserNotActive
|
|
8
|
-
InvalidLink
|
|
9
|
-
InvalidToken
|
|
10
|
-
}
|
|
4
|
+
import { Result } from '@aeriajs/types';
|
|
5
|
+
export declare const ActivationError: {
|
|
6
|
+
readonly UserNotFound: "USER_NOT_FOUND";
|
|
7
|
+
readonly UserNotActive: "USER_NOT_ACTIVE";
|
|
8
|
+
readonly InvalidLink: "INVALID_LINK";
|
|
9
|
+
readonly InvalidToken: "INVALID_TOKEN";
|
|
10
|
+
};
|
|
11
11
|
export declare const redefinePassword: (payload: {
|
|
12
12
|
password?: string;
|
|
13
13
|
userId?: string;
|
|
14
14
|
token?: string;
|
|
15
15
|
}, context: Context<typeof description>) => Promise<Result.Error<{
|
|
16
|
-
readonly code:
|
|
16
|
+
readonly code: "INVALID_LINK";
|
|
17
17
|
} & {
|
|
18
|
-
httpStatus:
|
|
18
|
+
httpStatus: 404;
|
|
19
19
|
}> | Result.Error<{
|
|
20
|
-
readonly code:
|
|
20
|
+
readonly code: "USER_NOT_FOUND";
|
|
21
21
|
} & {
|
|
22
|
-
httpStatus:
|
|
22
|
+
httpStatus: 404;
|
|
23
23
|
}> | Result.Error<{
|
|
24
|
-
readonly code:
|
|
24
|
+
readonly code: "USER_NOT_ACTIVE";
|
|
25
25
|
} & {
|
|
26
|
-
httpStatus:
|
|
26
|
+
httpStatus: 403;
|
|
27
27
|
}> | Result.Error<{
|
|
28
|
-
readonly code:
|
|
28
|
+
readonly code: "INVALID_TOKEN";
|
|
29
29
|
} & {
|
|
30
|
-
httpStatus:
|
|
30
|
+
httpStatus: 401;
|
|
31
31
|
}> | Result.Error<{
|
|
32
|
-
readonly code:
|
|
32
|
+
readonly code: "MALFORMED_INPUT";
|
|
33
33
|
} & {
|
|
34
|
-
httpStatus:
|
|
34
|
+
httpStatus: 422;
|
|
35
35
|
}> | {
|
|
36
36
|
readonly _tag: "Result";
|
|
37
37
|
readonly error: undefined;
|
|
@@ -4,13 +4,12 @@ exports.redefinePassword = exports.ActivationError = void 0;
|
|
|
4
4
|
const core_1 = require("@aeriajs/core");
|
|
5
5
|
const types_1 = require("@aeriajs/types");
|
|
6
6
|
const bcrypt = require("bcrypt");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
})(ActivationError || (exports.ActivationError = ActivationError = {}));
|
|
7
|
+
exports.ActivationError = {
|
|
8
|
+
UserNotFound: 'USER_NOT_FOUND',
|
|
9
|
+
UserNotActive: 'USER_NOT_ACTIVE',
|
|
10
|
+
InvalidLink: 'INVALID_LINK',
|
|
11
|
+
InvalidToken: 'INVALID_TOKEN',
|
|
12
|
+
};
|
|
14
13
|
const redefinePassword = async (payload, context) => {
|
|
15
14
|
const { userId, token, password, } = payload;
|
|
16
15
|
if (!context.config.secret) {
|
|
@@ -18,7 +17,7 @@ const redefinePassword = async (payload, context) => {
|
|
|
18
17
|
}
|
|
19
18
|
if (!userId || !token) {
|
|
20
19
|
return context.error(types_1.HTTPStatus.NotFound, {
|
|
21
|
-
code: ActivationError.InvalidLink,
|
|
20
|
+
code: exports.ActivationError.InvalidLink,
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
23
|
const user = await context.collection.model.findOne({
|
|
@@ -31,18 +30,18 @@ const redefinePassword = async (payload, context) => {
|
|
|
31
30
|
});
|
|
32
31
|
if (!user) {
|
|
33
32
|
return context.error(types_1.HTTPStatus.NotFound, {
|
|
34
|
-
code: ActivationError.UserNotFound,
|
|
33
|
+
code: exports.ActivationError.UserNotFound,
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
36
|
if (!user.active) {
|
|
38
37
|
return context.error(types_1.HTTPStatus.Forbidden, {
|
|
39
|
-
code: ActivationError.UserNotActive,
|
|
38
|
+
code: exports.ActivationError.UserNotActive,
|
|
40
39
|
});
|
|
41
40
|
}
|
|
42
41
|
const decoded = await (0, core_1.decodeToken)(token, context.config.secret);
|
|
43
42
|
if (!decoded) {
|
|
44
43
|
return context.error(types_1.HTTPStatus.Unauthorized, {
|
|
45
|
-
code: ActivationError.InvalidToken,
|
|
44
|
+
code: exports.ActivationError.InvalidToken,
|
|
46
45
|
});
|
|
47
46
|
}
|
|
48
47
|
if (!password) {
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
import { decodeToken, ObjectId } from "@aeriajs/core";
|
|
3
3
|
import { Result, ACError, HTTPStatus } from "@aeriajs/types";
|
|
4
4
|
import * as bcrypt from "bcrypt";
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})(ActivationError || {});
|
|
5
|
+
export const ActivationError = {
|
|
6
|
+
UserNotFound: "USER_NOT_FOUND",
|
|
7
|
+
UserNotActive: "USER_NOT_ACTIVE",
|
|
8
|
+
InvalidLink: "INVALID_LINK",
|
|
9
|
+
InvalidToken: "INVALID_TOKEN"
|
|
10
|
+
};
|
|
12
11
|
export const redefinePassword = async (payload, context) => {
|
|
13
12
|
const {
|
|
14
13
|
userId,
|
|
@@ -20,7 +19,7 @@ export const redefinePassword = async (payload, context) => {
|
|
|
20
19
|
}
|
|
21
20
|
if (!userId || !token) {
|
|
22
21
|
return context.error(HTTPStatus.NotFound, {
|
|
23
|
-
code:
|
|
22
|
+
code: ActivationError.InvalidLink
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
25
|
const user = await context.collection.model.findOne({
|
|
@@ -33,18 +32,18 @@ export const redefinePassword = async (payload, context) => {
|
|
|
33
32
|
});
|
|
34
33
|
if (!user) {
|
|
35
34
|
return context.error(HTTPStatus.NotFound, {
|
|
36
|
-
code:
|
|
35
|
+
code: ActivationError.UserNotFound
|
|
37
36
|
});
|
|
38
37
|
}
|
|
39
38
|
if (!user.active) {
|
|
40
39
|
return context.error(HTTPStatus.Forbidden, {
|
|
41
|
-
code:
|
|
40
|
+
code: ActivationError.UserNotActive
|
|
42
41
|
});
|
|
43
42
|
}
|
|
44
43
|
const decoded = await decodeToken(token, context.config.secret);
|
|
45
44
|
if (!decoded) {
|
|
46
45
|
return context.error(HTTPStatus.Unauthorized, {
|
|
47
|
-
code:
|
|
46
|
+
code: ActivationError.InvalidToken
|
|
48
47
|
});
|
|
49
48
|
}
|
|
50
49
|
if (!password) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Description, RouteContext, RolesHierarchy, UserRole } from '@aeriajs/types';
|
|
2
|
-
import { Result
|
|
2
|
+
import { Result } from '@aeriajs/types';
|
|
3
3
|
import { authenticate } from '../collections/user/authenticate.js';
|
|
4
4
|
declare const Payload: Partial<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
|
|
5
5
|
readonly collections: {
|
|
@@ -30,25 +30,25 @@ declare const Payload: Partial<{} & Omit<Readonly<import("@aeriajs/types").Filte
|
|
|
30
30
|
export declare const describe: (contextOrPayload: RouteContext | typeof Payload) => Promise<import("@aeriajs/types").GenericResponse | {
|
|
31
31
|
readonly _tag: "Error";
|
|
32
32
|
readonly error: {
|
|
33
|
-
readonly httpStatus:
|
|
34
|
-
readonly code:
|
|
33
|
+
readonly httpStatus: 422;
|
|
34
|
+
readonly code: "MALFORMED_INPUT";
|
|
35
35
|
readonly details: import("@aeriajs/types").PropertyValidationError | import("@aeriajs/types").ValidationError;
|
|
36
36
|
};
|
|
37
37
|
readonly result: undefined;
|
|
38
38
|
} | {
|
|
39
39
|
readonly _tag: "Error";
|
|
40
40
|
readonly error: ({
|
|
41
|
-
readonly code:
|
|
41
|
+
readonly code: "AUTHORIZATION_ERROR";
|
|
42
42
|
} & {
|
|
43
|
-
httpStatus:
|
|
43
|
+
httpStatus: 401;
|
|
44
44
|
}) | ({
|
|
45
|
-
readonly code:
|
|
45
|
+
readonly code: "INVALID_CREDENTIALS";
|
|
46
46
|
} & {
|
|
47
|
-
httpStatus:
|
|
47
|
+
httpStatus: 401;
|
|
48
48
|
}) | ({
|
|
49
|
-
readonly code:
|
|
49
|
+
readonly code: "INACTIVE_USER";
|
|
50
50
|
} & {
|
|
51
|
-
httpStatus:
|
|
51
|
+
httpStatus: 401;
|
|
52
52
|
});
|
|
53
53
|
readonly result: undefined;
|
|
54
54
|
} | {
|