@aeriajs/builtins 0.0.231 → 0.0.232
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 +9 -10
- package/dist/collections/user/createAccount.js +4 -5
- package/dist/collections/user/createAccount.mjs +4 -5
- package/dist/collections/user/editProfile.d.ts +3 -3
- package/dist/collections/user/getActivationLink.d.ts +13 -14
- package/dist/collections/user/getCurrentUser.d.ts +5 -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 +78 -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 +96 -96
- package/package.json +15 -15
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Context } from '@aeriajs/types';
|
|
2
2
|
import { type ObjectId } from '@aeriajs/core';
|
|
3
|
-
import { Result
|
|
4
|
-
import { ActivationError } from './activate.js';
|
|
3
|
+
import { Result } from '@aeriajs/types';
|
|
5
4
|
export declare const getActivationToken: (strId: string, context: Context) => Promise<string>;
|
|
6
5
|
export declare const getActivationLink: (payload: {
|
|
7
6
|
userId: ObjectId | string;
|
|
@@ -10,10 +9,10 @@ export declare const getActivationLink: (payload: {
|
|
|
10
9
|
readonly _tag: "Error";
|
|
11
10
|
readonly error: Pick<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
|
|
12
11
|
readonly httpStatus: {
|
|
13
|
-
readonly enum: [
|
|
12
|
+
readonly enum: [403, 404, 400];
|
|
14
13
|
};
|
|
15
14
|
readonly code: {
|
|
16
|
-
readonly enum: [
|
|
15
|
+
readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
|
|
17
16
|
};
|
|
18
17
|
readonly message: {
|
|
19
18
|
readonly type: "string";
|
|
@@ -23,16 +22,16 @@ export declare const getActivationLink: (payload: {
|
|
|
23
22
|
readonly additionalProperties: true;
|
|
24
23
|
};
|
|
25
24
|
}>> & {
|
|
26
|
-
code:
|
|
27
|
-
httpStatus:
|
|
25
|
+
code: "RESOURCE_NOT_FOUND" | "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "MALFORMED_INPUT";
|
|
26
|
+
httpStatus: 403 | 400 | 404;
|
|
28
27
|
message: string;
|
|
29
28
|
details: any;
|
|
30
29
|
}, never>, "code" | "httpStatus"> & Partial<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
|
|
31
30
|
readonly httpStatus: {
|
|
32
|
-
readonly enum: [
|
|
31
|
+
readonly enum: [403, 404, 400];
|
|
33
32
|
};
|
|
34
33
|
readonly code: {
|
|
35
|
-
readonly enum: [
|
|
34
|
+
readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
|
|
36
35
|
};
|
|
37
36
|
readonly message: {
|
|
38
37
|
readonly type: "string";
|
|
@@ -42,20 +41,20 @@ export declare const getActivationLink: (payload: {
|
|
|
42
41
|
readonly additionalProperties: true;
|
|
43
42
|
};
|
|
44
43
|
}>> & {
|
|
45
|
-
code:
|
|
46
|
-
httpStatus:
|
|
44
|
+
code: "RESOURCE_NOT_FOUND" | "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "MALFORMED_INPUT";
|
|
45
|
+
httpStatus: 403 | 400 | 404;
|
|
47
46
|
message: string;
|
|
48
47
|
details: any;
|
|
49
48
|
}, never>>;
|
|
50
49
|
readonly result: undefined;
|
|
51
50
|
} | Result.Error<{
|
|
52
|
-
readonly code:
|
|
51
|
+
readonly code: "INVALID_LINK";
|
|
53
52
|
} & {
|
|
54
|
-
httpStatus:
|
|
53
|
+
httpStatus: 400;
|
|
55
54
|
}> | Result.Error<{
|
|
56
|
-
readonly code:
|
|
55
|
+
readonly code: "ALREADY_ACTIVE_USER";
|
|
57
56
|
} & {
|
|
58
|
-
httpStatus:
|
|
57
|
+
httpStatus: 403;
|
|
59
58
|
}> | {
|
|
60
59
|
readonly _tag: "Result";
|
|
61
60
|
readonly error: undefined;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Context } from '@aeriajs/types';
|
|
2
2
|
import type { description } from './description.js';
|
|
3
|
-
export declare
|
|
4
|
-
UserNotFound
|
|
5
|
-
AlreadyActiveUser
|
|
6
|
-
InvalidLink
|
|
7
|
-
}
|
|
3
|
+
export declare const ActivationError: {
|
|
4
|
+
readonly UserNotFound: "USER_NOT_FOUND";
|
|
5
|
+
readonly AlreadyActiveUser: "ALREADY_ACTIVE_USER";
|
|
6
|
+
readonly InvalidLink: "INVALID_LINK";
|
|
7
|
+
};
|
|
8
8
|
export declare const getCurrentUser: (_payload: undefined, context: Context<typeof description>) => Promise<{
|
|
9
9
|
readonly _tag: "Result";
|
|
10
10
|
readonly error: undefined;
|
|
@@ -4,12 +4,11 @@ exports.getCurrentUser = exports.ActivationError = void 0;
|
|
|
4
4
|
const types_1 = require("@aeriajs/types");
|
|
5
5
|
const core_1 = require("@aeriajs/core");
|
|
6
6
|
const authentication_js_1 = require("../../authentication.js");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})(ActivationError || (exports.ActivationError = ActivationError = {}));
|
|
7
|
+
exports.ActivationError = {
|
|
8
|
+
UserNotFound: 'USER_NOT_FOUND',
|
|
9
|
+
AlreadyActiveUser: 'ALREADY_ACTIVE_USER',
|
|
10
|
+
InvalidLink: 'INVALID_LINK',
|
|
11
|
+
};
|
|
13
12
|
const getCurrentUser = async (_payload, context) => {
|
|
14
13
|
if (!context.token.authenticated) {
|
|
15
14
|
throw new Error();
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
import { Result } from "@aeriajs/types";
|
|
3
3
|
import { get } from "@aeriajs/core";
|
|
4
4
|
import { defaultSuccessfulAuthentication } from "../../authentication.mjs";
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})(ActivationError || {});
|
|
5
|
+
export const ActivationError = {
|
|
6
|
+
UserNotFound: "USER_NOT_FOUND",
|
|
7
|
+
AlreadyActiveUser: "ALREADY_ACTIVE_USER",
|
|
8
|
+
InvalidLink: "INVALID_LINK"
|
|
9
|
+
};
|
|
11
10
|
export const getCurrentUser = async (_payload, context) => {
|
|
12
11
|
if (!context.token.authenticated) {
|
|
13
12
|
throw new Error();
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import type { Context } from '@aeriajs/types';
|
|
2
2
|
import type { description } from './description.js';
|
|
3
|
-
import { Result
|
|
4
|
-
export declare
|
|
5
|
-
UserNotFound
|
|
6
|
-
AlreadyActiveUser
|
|
7
|
-
InvalidLink
|
|
8
|
-
InvalidToken
|
|
9
|
-
}
|
|
3
|
+
import { Result } from '@aeriajs/types';
|
|
4
|
+
export declare const ActivationError: {
|
|
5
|
+
readonly UserNotFound: "USER_NOT_FOUND";
|
|
6
|
+
readonly AlreadyActiveUser: "ALREADY_ACTIVE_USER";
|
|
7
|
+
readonly InvalidLink: "INVALID_LINK";
|
|
8
|
+
readonly InvalidToken: "INVALID_TOKEN";
|
|
9
|
+
};
|
|
10
10
|
export declare const getInfo: (payload: {
|
|
11
11
|
userId: string;
|
|
12
12
|
token: string;
|
|
13
13
|
}, context: Context<typeof description>) => Promise<Result.Error<{
|
|
14
|
-
readonly code:
|
|
14
|
+
readonly code: "INVALID_LINK";
|
|
15
15
|
} & {
|
|
16
|
-
httpStatus:
|
|
16
|
+
httpStatus: 404;
|
|
17
17
|
}> | Result.Error<{
|
|
18
|
-
readonly code:
|
|
18
|
+
readonly code: "USER_NOT_FOUND";
|
|
19
19
|
} & {
|
|
20
|
-
httpStatus:
|
|
20
|
+
httpStatus: 404;
|
|
21
21
|
}> | Result.Error<{
|
|
22
|
-
readonly code:
|
|
22
|
+
readonly code: "INVALID_TOKEN";
|
|
23
23
|
} & {
|
|
24
|
-
httpStatus:
|
|
24
|
+
httpStatus: 401;
|
|
25
25
|
}> | {
|
|
26
26
|
readonly _tag: "Result";
|
|
27
27
|
readonly error: undefined;
|
|
@@ -3,18 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getInfo = exports.ActivationError = void 0;
|
|
4
4
|
const types_1 = require("@aeriajs/types");
|
|
5
5
|
const core_1 = require("@aeriajs/core");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})(ActivationError || (exports.ActivationError = ActivationError = {}));
|
|
6
|
+
exports.ActivationError = {
|
|
7
|
+
UserNotFound: 'USER_NOT_FOUND',
|
|
8
|
+
AlreadyActiveUser: 'ALREADY_ACTIVE_USER',
|
|
9
|
+
InvalidLink: 'INVALID_LINK',
|
|
10
|
+
InvalidToken: 'INVALID_TOKEN',
|
|
11
|
+
};
|
|
13
12
|
const getInfo = async (payload, context) => {
|
|
14
13
|
const { userId, token, } = payload;
|
|
15
14
|
if (!userId || !token) {
|
|
16
15
|
return context.error(types_1.HTTPStatus.NotFound, {
|
|
17
|
-
code: ActivationError.InvalidLink,
|
|
16
|
+
code: exports.ActivationError.InvalidLink,
|
|
18
17
|
});
|
|
19
18
|
}
|
|
20
19
|
const user = await context.collection.model.findOne({
|
|
@@ -22,13 +21,13 @@ const getInfo = async (payload, context) => {
|
|
|
22
21
|
});
|
|
23
22
|
if (!user) {
|
|
24
23
|
return context.error(types_1.HTTPStatus.NotFound, {
|
|
25
|
-
code: ActivationError.UserNotFound,
|
|
24
|
+
code: exports.ActivationError.UserNotFound,
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
27
|
const decoded = await (0, core_1.decodeToken)(token, context.config.secret).catch(console.trace);
|
|
29
28
|
if (!decoded) {
|
|
30
29
|
return context.error(types_1.HTTPStatus.Unauthorized, {
|
|
31
|
-
code: ActivationError.InvalidToken,
|
|
30
|
+
code: exports.ActivationError.InvalidToken,
|
|
32
31
|
});
|
|
33
32
|
}
|
|
34
33
|
return types_1.Result.result({
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { Result, HTTPStatus } from "@aeriajs/types";
|
|
3
3
|
import { decodeToken, ObjectId } from "@aeriajs/core";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})(ActivationError || {});
|
|
4
|
+
export const ActivationError = {
|
|
5
|
+
UserNotFound: "USER_NOT_FOUND",
|
|
6
|
+
AlreadyActiveUser: "ALREADY_ACTIVE_USER",
|
|
7
|
+
InvalidLink: "INVALID_LINK",
|
|
8
|
+
InvalidToken: "INVALID_TOKEN"
|
|
9
|
+
};
|
|
11
10
|
export const getInfo = async (payload, context) => {
|
|
12
11
|
const {
|
|
13
12
|
userId,
|
|
@@ -15,7 +14,7 @@ export const getInfo = async (payload, context) => {
|
|
|
15
14
|
} = payload;
|
|
16
15
|
if (!userId || !token) {
|
|
17
16
|
return context.error(HTTPStatus.NotFound, {
|
|
18
|
-
code:
|
|
17
|
+
code: ActivationError.InvalidLink
|
|
19
18
|
});
|
|
20
19
|
}
|
|
21
20
|
const user = await context.collection.model.findOne({
|
|
@@ -23,13 +22,13 @@ export const getInfo = async (payload, context) => {
|
|
|
23
22
|
});
|
|
24
23
|
if (!user) {
|
|
25
24
|
return context.error(HTTPStatus.NotFound, {
|
|
26
|
-
code:
|
|
25
|
+
code: ActivationError.UserNotFound
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
28
|
const decoded = await decodeToken(token, context.config.secret).catch(console.trace);
|
|
30
29
|
if (!decoded) {
|
|
31
30
|
return context.error(HTTPStatus.Unauthorized, {
|
|
32
|
-
code:
|
|
31
|
+
code: ActivationError.InvalidToken
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
34
|
return Result.result({
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Context } from '@aeriajs/types';
|
|
2
2
|
import type { ObjectId } from '@aeriajs/core';
|
|
3
|
-
import { Result
|
|
4
|
-
import { ActivationError } from './redefinePassword.js';
|
|
3
|
+
import { Result } from '@aeriajs/types';
|
|
5
4
|
export declare const getRedefinePasswordLink: (payload: {
|
|
6
5
|
userId: ObjectId | string;
|
|
7
6
|
redirect?: string;
|
|
@@ -9,10 +8,10 @@ export declare const getRedefinePasswordLink: (payload: {
|
|
|
9
8
|
readonly _tag: "Error";
|
|
10
9
|
readonly error: Pick<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
|
|
11
10
|
readonly httpStatus: {
|
|
12
|
-
readonly enum: [
|
|
11
|
+
readonly enum: [403, 404, 400];
|
|
13
12
|
};
|
|
14
13
|
readonly code: {
|
|
15
|
-
readonly enum: [
|
|
14
|
+
readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
|
|
16
15
|
};
|
|
17
16
|
readonly message: {
|
|
18
17
|
readonly type: "string";
|
|
@@ -22,16 +21,16 @@ export declare const getRedefinePasswordLink: (payload: {
|
|
|
22
21
|
readonly additionalProperties: true;
|
|
23
22
|
};
|
|
24
23
|
}>> & {
|
|
25
|
-
code:
|
|
26
|
-
httpStatus:
|
|
24
|
+
code: "RESOURCE_NOT_FOUND" | "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "MALFORMED_INPUT";
|
|
25
|
+
httpStatus: 403 | 400 | 404;
|
|
27
26
|
message: string;
|
|
28
27
|
details: any;
|
|
29
28
|
}, never>, "code" | "httpStatus"> & Partial<{} & Omit<Readonly<import("@aeriajs/types").FilterReadonlyProperties<{
|
|
30
29
|
readonly httpStatus: {
|
|
31
|
-
readonly enum: [
|
|
30
|
+
readonly enum: [403, 404, 400];
|
|
32
31
|
};
|
|
33
32
|
readonly code: {
|
|
34
|
-
readonly enum: [
|
|
33
|
+
readonly enum: ["RESOURCE_NOT_FOUND", "OWNERSHIP_ERROR", "INSECURE_OPERATOR", "MALFORMED_INPUT"];
|
|
35
34
|
};
|
|
36
35
|
readonly message: {
|
|
37
36
|
readonly type: "string";
|
|
@@ -41,16 +40,16 @@ export declare const getRedefinePasswordLink: (payload: {
|
|
|
41
40
|
readonly additionalProperties: true;
|
|
42
41
|
};
|
|
43
42
|
}>> & {
|
|
44
|
-
code:
|
|
45
|
-
httpStatus:
|
|
43
|
+
code: "RESOURCE_NOT_FOUND" | "INSECURE_OPERATOR" | "OWNERSHIP_ERROR" | "MALFORMED_INPUT";
|
|
44
|
+
httpStatus: 403 | 400 | 404;
|
|
46
45
|
message: string;
|
|
47
46
|
details: any;
|
|
48
47
|
}, never>>;
|
|
49
48
|
readonly result: undefined;
|
|
50
49
|
} | Result.Error<{
|
|
51
|
-
readonly code:
|
|
50
|
+
readonly code: "USER_NOT_ACTIVE";
|
|
52
51
|
} & {
|
|
53
|
-
httpStatus:
|
|
52
|
+
httpStatus: 403;
|
|
54
53
|
}> | {
|
|
55
54
|
readonly _tag: "Result";
|
|
56
55
|
readonly error: undefined;
|