@aeriajs/builtins 0.0.64 → 0.0.66
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/collections/user/activate.js +25 -5
- package/dist/collections/user/activate.mjs +1 -1
- package/dist/collections/user/authenticate.d.ts +3 -5
- package/dist/collections/user/authenticate.js +32 -5
- package/dist/collections/user/authenticate.mjs +7 -5
- package/dist/collections/user/createAccount.js +24 -4
- package/dist/collections/user/createAccount.mjs +1 -1
- package/dist/collections/user/getActivationLink.js +24 -4
- package/dist/collections/user/getActivationLink.mjs +1 -1
- package/dist/collections/user/getInfo.js +24 -4
- package/dist/collections/user/getInfo.mjs +1 -1
- package/dist/collections/user/index.d.ts +4 -8
- package/dist/collections/user/insert.js +1 -1
- package/dist/collections/user/insert.mjs +1 -1
- package/dist/functions/describe.d.ts +1 -4
- package/dist/index.d.ts +4 -8
- package/package.json +13 -13
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.activate = exports.ActivationErrors = void 0;
|
|
7
27
|
const core_1 = require("@aeriajs/core");
|
|
8
28
|
const common_1 = require("@aeriajs/common");
|
|
9
|
-
const bcrypt_1 = __importDefault(require("bcrypt"));
|
|
10
29
|
var ActivationErrors;
|
|
11
30
|
(function (ActivationErrors) {
|
|
12
31
|
ActivationErrors["UserNotFound"] = "USER_NOT_FOUND";
|
|
@@ -31,7 +50,8 @@ const activate = async (payload, context) => {
|
|
|
31
50
|
if (user.active) {
|
|
32
51
|
return (0, common_1.left)(ActivationErrors.AlreadyActiveUser);
|
|
33
52
|
}
|
|
34
|
-
const
|
|
53
|
+
const bcrypt = await Promise.resolve().then(() => __importStar(require('bcrypt')));
|
|
54
|
+
const equal = await bcrypt.compare(user._id.toString(), token);
|
|
35
55
|
if (!equal) {
|
|
36
56
|
return (0, common_1.left)(ActivationErrors.InvalidLink);
|
|
37
57
|
}
|
|
@@ -46,7 +66,7 @@ const activate = async (payload, context) => {
|
|
|
46
66
|
}, {
|
|
47
67
|
$set: {
|
|
48
68
|
active: true,
|
|
49
|
-
password: await
|
|
69
|
+
password: await bcrypt.hash(payload.password, 10),
|
|
50
70
|
},
|
|
51
71
|
});
|
|
52
72
|
return (0, common_1.right)(true);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { ObjectId } from "@aeriajs/core";
|
|
3
3
|
import { left, right } from "@aeriajs/common";
|
|
4
|
-
import bcrypt from "bcrypt";
|
|
5
4
|
export var ActivationErrors = /* @__PURE__ */ ((ActivationErrors2) => {
|
|
6
5
|
ActivationErrors2["UserNotFound"] = "USER_NOT_FOUND";
|
|
7
6
|
ActivationErrors2["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
|
|
@@ -29,6 +28,7 @@ export const activate = async (payload, context) => {
|
|
|
29
28
|
if (user.active) {
|
|
30
29
|
return left("ALREADY_ACTIVE_USER" /* AlreadyActiveUser */);
|
|
31
30
|
}
|
|
31
|
+
const bcrypt = await import("bcrypt");
|
|
32
32
|
const equal = await bcrypt.compare(user._id.toString(), token);
|
|
33
33
|
if (!equal) {
|
|
34
34
|
return left("INVALID_LINK" /* InvalidLink */);
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import type { Context, SchemaWithId } from '@aeriajs/types';
|
|
1
|
+
import type { Context, SchemaWithId, TokenRecipient } from '@aeriajs/types';
|
|
2
2
|
import type { description } from './description.js';
|
|
3
3
|
import type { ObjectId } from '@aeriajs/core';
|
|
4
4
|
type Props = {
|
|
5
5
|
email: string;
|
|
6
6
|
password: string;
|
|
7
7
|
} | {
|
|
8
|
+
token?: TokenRecipient;
|
|
8
9
|
revalidate: true;
|
|
9
10
|
};
|
|
10
11
|
type Return = {
|
|
11
12
|
user: Pick<SchemaWithId<typeof description>, 'name' | 'email' | 'roles' | 'active'> & {
|
|
12
13
|
_id: ObjectId | null;
|
|
13
14
|
};
|
|
14
|
-
token:
|
|
15
|
-
type: 'bearer';
|
|
16
|
-
content: string;
|
|
17
|
-
};
|
|
15
|
+
token: TokenRecipient;
|
|
18
16
|
};
|
|
19
17
|
export declare enum AuthenticationErrors {
|
|
20
18
|
Unauthenticated = "UNAUTHENTICATED",
|
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.authenticate = exports.getDefaultUser = exports.AuthenticationErrors = void 0;
|
|
4
|
-
const bcrypt_1 = require("bcrypt");
|
|
5
27
|
const core_1 = require("@aeriajs/core");
|
|
6
28
|
const common_1 = require("@aeriajs/common");
|
|
7
29
|
var AuthenticationErrors;
|
|
@@ -81,11 +103,15 @@ const getDefaultUser = async () => {
|
|
|
81
103
|
exports.getDefaultUser = getDefaultUser;
|
|
82
104
|
const authenticate = async (props, context) => {
|
|
83
105
|
if ('revalidate' in props) {
|
|
84
|
-
|
|
106
|
+
const { token } = props;
|
|
107
|
+
if (!token && !context.token.authenticated) {
|
|
85
108
|
return (0, common_1.left)(AuthenticationErrors.Unauthenticated);
|
|
86
109
|
}
|
|
87
|
-
|
|
88
|
-
? await
|
|
110
|
+
const decodedToken = token
|
|
111
|
+
? await (0, core_1.decodeToken)(token.content)
|
|
112
|
+
: context.token;
|
|
113
|
+
return (0, common_1.right)(decodedToken.sub
|
|
114
|
+
? await getUser(decodedToken.sub, context)
|
|
89
115
|
: await (0, exports.getDefaultUser)());
|
|
90
116
|
}
|
|
91
117
|
if (typeof props.email !== 'string') {
|
|
@@ -105,7 +131,8 @@ const authenticate = async (props, context) => {
|
|
|
105
131
|
active: 1,
|
|
106
132
|
},
|
|
107
133
|
});
|
|
108
|
-
|
|
134
|
+
const bcrypt = await Promise.resolve().then(() => __importStar(require('bcrypt')));
|
|
135
|
+
if (!user || !user.password || !await bcrypt.compare(props.password, user.password)) {
|
|
109
136
|
return (0, common_1.left)(AuthenticationErrors.InvalidCredentials);
|
|
110
137
|
}
|
|
111
138
|
if (!user.active) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import {
|
|
3
|
-
import { signToken } from "@aeriajs/core";
|
|
2
|
+
import { signToken, decodeToken } from "@aeriajs/core";
|
|
4
3
|
import { left, right } from "@aeriajs/common";
|
|
5
4
|
export var AuthenticationErrors = /* @__PURE__ */ ((AuthenticationErrors2) => {
|
|
6
5
|
AuthenticationErrors2["Unauthenticated"] = "UNAUTHENTICATED";
|
|
@@ -77,10 +76,12 @@ export const getDefaultUser = async () => {
|
|
|
77
76
|
};
|
|
78
77
|
export const authenticate = async (props, context) => {
|
|
79
78
|
if ("revalidate" in props) {
|
|
80
|
-
|
|
79
|
+
const { token } = props;
|
|
80
|
+
if (!token && !context.token.authenticated) {
|
|
81
81
|
return left("UNAUTHENTICATED" /* Unauthenticated */);
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
const decodedToken = token ? await decodeToken(token.content) : context.token;
|
|
84
|
+
return right(decodedToken.sub ? await getUser(decodedToken.sub, context) : await getDefaultUser());
|
|
84
85
|
}
|
|
85
86
|
if (typeof props.email !== "string") {
|
|
86
87
|
return left("INVALID_CREDENTIALS" /* InvalidCredentials */);
|
|
@@ -102,7 +103,8 @@ export const authenticate = async (props, context) => {
|
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
);
|
|
105
|
-
|
|
106
|
+
const bcrypt = await import("bcrypt");
|
|
107
|
+
if (!user || !user.password || !await bcrypt.compare(props.password, user.password)) {
|
|
106
108
|
return left("INVALID_CREDENTIALS" /* InvalidCredentials */);
|
|
107
109
|
}
|
|
108
110
|
if (!user.active) {
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.createAccount = void 0;
|
|
7
27
|
const common_1 = require("@aeriajs/common");
|
|
8
28
|
const validation_1 = require("@aeriajs/validation");
|
|
9
|
-
const bcrypt_1 = __importDefault(require("bcrypt"));
|
|
10
29
|
const createAccount = async (payload, context) => {
|
|
11
30
|
const user = Object.assign({}, payload);
|
|
12
31
|
if (!context.config.allowSignup) {
|
|
@@ -47,7 +66,8 @@ const createAccount = async (payload, context) => {
|
|
|
47
66
|
Object.assign(user, context.config.signupDefaults);
|
|
48
67
|
}
|
|
49
68
|
if (user.password) {
|
|
50
|
-
|
|
69
|
+
const bcrypt = await Promise.resolve().then(() => __importStar(require('bcrypt')));
|
|
70
|
+
user.password = await bcrypt.hash(user.password, 10);
|
|
51
71
|
}
|
|
52
72
|
if (!context.token.authenticated) {
|
|
53
73
|
Object.assign(user, {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { isLeft, unwrapEither, left, right } from "@aeriajs/common";
|
|
3
3
|
import { validate } from "@aeriajs/validation";
|
|
4
|
-
import bcrypt from "bcrypt";
|
|
5
4
|
export const createAccount = async (payload, context) => {
|
|
6
5
|
const user = Object.assign({}, payload);
|
|
7
6
|
if (!context.config.allowSignup) {
|
|
@@ -42,6 +41,7 @@ export const createAccount = async (payload, context) => {
|
|
|
42
41
|
Object.assign(user, context.config.signupDefaults);
|
|
43
42
|
}
|
|
44
43
|
if (user.password) {
|
|
44
|
+
const bcrypt = await import("bcrypt");
|
|
45
45
|
user.password = await bcrypt.hash(user.password, 10);
|
|
46
46
|
}
|
|
47
47
|
if (!context.token.authenticated) {
|
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.getActivationLink = void 0;
|
|
7
27
|
const entrypoint_1 = require("@aeriajs/entrypoint");
|
|
8
|
-
const bcrypt_1 = __importDefault(require("bcrypt"));
|
|
9
28
|
const getActivationLink = async (userId) => {
|
|
10
29
|
const config = await (0, entrypoint_1.getConfig)();
|
|
11
|
-
const
|
|
30
|
+
const bcrypt = await Promise.resolve().then(() => __importStar(require('bcrypt')));
|
|
31
|
+
const activationToken = await bcrypt.hash(userId.toString(), 10);
|
|
12
32
|
const link = `${config.publicUrl}/user/activate?u=${userId.toString()}&t=${activationToken}`;
|
|
13
33
|
return link;
|
|
14
34
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { getConfig } from "@aeriajs/entrypoint";
|
|
3
|
-
import bcrypt from "bcrypt";
|
|
4
3
|
export const getActivationLink = async (userId) => {
|
|
5
4
|
const config = await getConfig();
|
|
5
|
+
const bcrypt = await import("bcrypt");
|
|
6
6
|
const activationToken = await bcrypt.hash(userId.toString(), 10);
|
|
7
7
|
const link = `${config.publicUrl}/user/activate?u=${userId.toString()}&t=${activationToken}`;
|
|
8
8
|
return link;
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
exports.getInfo = exports.ActivationErrors = void 0;
|
|
7
27
|
const core_1 = require("@aeriajs/core");
|
|
8
28
|
const common_1 = require("@aeriajs/common");
|
|
9
|
-
const bcrypt_1 = __importDefault(require("bcrypt"));
|
|
10
29
|
var ActivationErrors;
|
|
11
30
|
(function (ActivationErrors) {
|
|
12
31
|
ActivationErrors["UserNotFound"] = "USER_NOT_FOUND";
|
|
@@ -27,7 +46,8 @@ const getInfo = async (payload, context) => {
|
|
|
27
46
|
if (user.active) {
|
|
28
47
|
return (0, common_1.left)(ActivationErrors.AlreadyActiveUser);
|
|
29
48
|
}
|
|
30
|
-
const
|
|
49
|
+
const bcrypt = await Promise.resolve().then(() => __importStar(require('bcrypt')));
|
|
50
|
+
const equal = await bcrypt.compare(user._id.toString(), token);
|
|
31
51
|
if (!equal) {
|
|
32
52
|
return (0, common_1.left)(ActivationErrors.InvalidLink);
|
|
33
53
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { ObjectId } from "@aeriajs/core";
|
|
3
3
|
import { left, right } from "@aeriajs/common";
|
|
4
|
-
import bcrypt from "bcrypt";
|
|
5
4
|
export var ActivationErrors = /* @__PURE__ */ ((ActivationErrors2) => {
|
|
6
5
|
ActivationErrors2["UserNotFound"] = "USER_NOT_FOUND";
|
|
7
6
|
ActivationErrors2["AlreadyActiveUser"] = "ALREADY_ACTIVE_USER";
|
|
@@ -25,6 +24,7 @@ export const getInfo = async (payload, context) => {
|
|
|
25
24
|
if (user.active) {
|
|
26
25
|
return left("ALREADY_ACTIVE_USER" /* AlreadyActiveUser */);
|
|
27
26
|
}
|
|
27
|
+
const bcrypt = await import("bcrypt");
|
|
28
28
|
const equal = await bcrypt.compare(user._id.toString(), token);
|
|
29
29
|
if (!equal) {
|
|
30
30
|
return left("INVALID_LINK" /* InvalidLink */);
|
|
@@ -415,6 +415,7 @@ export declare const user: Omit<import("@aeriajs/types").Collection<{
|
|
|
415
415
|
email: string;
|
|
416
416
|
password: string;
|
|
417
417
|
} | {
|
|
418
|
+
token?: import("@aeriajs/types").TokenRecipient | undefined;
|
|
418
419
|
revalidate: true;
|
|
419
420
|
}, context: import("@aeriajs/types").Context<{
|
|
420
421
|
readonly $id: "user";
|
|
@@ -620,10 +621,7 @@ export declare const user: Omit<import("@aeriajs/types").Collection<{
|
|
|
620
621
|
}>, "name" | "roles" | "email" | "active"> & {
|
|
621
622
|
_id: any;
|
|
622
623
|
};
|
|
623
|
-
token:
|
|
624
|
-
type: "bearer";
|
|
625
|
-
content: string;
|
|
626
|
-
};
|
|
624
|
+
token: import("@aeriajs/types").TokenRecipient;
|
|
627
625
|
} | {
|
|
628
626
|
user: {
|
|
629
627
|
_id: null;
|
|
@@ -1713,6 +1711,7 @@ export declare const user: Omit<import("@aeriajs/types").Collection<{
|
|
|
1713
1711
|
email: string;
|
|
1714
1712
|
password: string;
|
|
1715
1713
|
} | {
|
|
1714
|
+
token?: import("@aeriajs/types").TokenRecipient | undefined;
|
|
1716
1715
|
revalidate: true;
|
|
1717
1716
|
}, context: import("@aeriajs/types").Context<{
|
|
1718
1717
|
readonly $id: "user";
|
|
@@ -1918,10 +1917,7 @@ export declare const user: Omit<import("@aeriajs/types").Collection<{
|
|
|
1918
1917
|
}>, "name" | "roles" | "email" | "active"> & {
|
|
1919
1918
|
_id: any;
|
|
1920
1919
|
};
|
|
1921
|
-
token:
|
|
1922
|
-
type: "bearer";
|
|
1923
|
-
content: string;
|
|
1924
|
-
};
|
|
1920
|
+
token: import("@aeriajs/types").TokenRecipient;
|
|
1925
1921
|
} | {
|
|
1926
1922
|
user: {
|
|
1927
1923
|
_id: null;
|
|
@@ -24,10 +24,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.insert = void 0;
|
|
27
|
-
const bcrypt = __importStar(require("bcrypt"));
|
|
28
27
|
const core_1 = require("@aeriajs/core");
|
|
29
28
|
const insert = async (payload, context) => {
|
|
30
29
|
if (payload.what.password) {
|
|
30
|
+
const bcrypt = await Promise.resolve().then(() => __importStar(require('bcrypt')));
|
|
31
31
|
payload.what.password = await bcrypt.hash(payload.what.password, 10);
|
|
32
32
|
}
|
|
33
33
|
return core_1.functions.insert(payload, context);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
import * as bcrypt from "bcrypt";
|
|
3
2
|
import { functions } from "@aeriajs/core";
|
|
4
3
|
export const insert = async (payload, context) => {
|
|
5
4
|
if (payload.what.password) {
|
|
5
|
+
const bcrypt = await import("bcrypt");
|
|
6
6
|
payload.what.password = await bcrypt.hash(payload.what.password, 10);
|
|
7
7
|
}
|
|
8
8
|
return functions.insert(payload, context);
|
|
@@ -114,10 +114,7 @@ export declare const describe: (contextOrPayload: RouteContext | Payload) => Pro
|
|
|
114
114
|
}>, "name" | "roles" | "email" | "active"> & {
|
|
115
115
|
_id: any;
|
|
116
116
|
};
|
|
117
|
-
token:
|
|
118
|
-
type: "bearer";
|
|
119
|
-
content: string;
|
|
120
|
-
};
|
|
117
|
+
token: import("@aeriajs/types").TokenRecipient;
|
|
121
118
|
} | {
|
|
122
119
|
user: {
|
|
123
120
|
_id: null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1600,6 +1600,7 @@ export declare const collections: {
|
|
|
1600
1600
|
email: string;
|
|
1601
1601
|
password: string;
|
|
1602
1602
|
} | {
|
|
1603
|
+
token?: import("@aeriajs/types").TokenRecipient | undefined;
|
|
1603
1604
|
revalidate: true;
|
|
1604
1605
|
}, context: import("@aeriajs/types").Context<{
|
|
1605
1606
|
readonly $id: "user";
|
|
@@ -1805,10 +1806,7 @@ export declare const collections: {
|
|
|
1805
1806
|
}>, "name" | "roles" | "email" | "active"> & {
|
|
1806
1807
|
_id: any;
|
|
1807
1808
|
};
|
|
1808
|
-
token:
|
|
1809
|
-
type: "bearer";
|
|
1810
|
-
content: string;
|
|
1811
|
-
};
|
|
1809
|
+
token: import("@aeriajs/types").TokenRecipient;
|
|
1812
1810
|
} | {
|
|
1813
1811
|
user: {
|
|
1814
1812
|
_id: null;
|
|
@@ -2898,6 +2896,7 @@ export declare const collections: {
|
|
|
2898
2896
|
email: string;
|
|
2899
2897
|
password: string;
|
|
2900
2898
|
} | {
|
|
2899
|
+
token?: import("@aeriajs/types").TokenRecipient | undefined;
|
|
2901
2900
|
revalidate: true;
|
|
2902
2901
|
}, context: import("@aeriajs/types").Context<{
|
|
2903
2902
|
readonly $id: "user";
|
|
@@ -3103,10 +3102,7 @@ export declare const collections: {
|
|
|
3103
3102
|
}>, "name" | "roles" | "email" | "active"> & {
|
|
3104
3103
|
_id: any;
|
|
3105
3104
|
};
|
|
3106
|
-
token:
|
|
3107
|
-
type: "bearer";
|
|
3108
|
-
content: string;
|
|
3109
|
-
};
|
|
3105
|
+
token: import("@aeriajs/types").TokenRecipient;
|
|
3110
3106
|
} | {
|
|
3111
3107
|
user: {
|
|
3112
3108
|
_id: null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/builtins",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.66",
|
|
4
4
|
"description": "## Installation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
"bcrypt": "^5.1.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@aeriajs/access-control": "^0.0.
|
|
40
|
-
"@aeriajs/core": "^0.0.
|
|
41
|
-
"@aeriajs/common": "^0.0.
|
|
42
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
43
|
-
"@aeriajs/types": "^0.0.
|
|
44
|
-
"@aeriajs/validation": "^0.0.
|
|
39
|
+
"@aeriajs/access-control": "^0.0.36",
|
|
40
|
+
"@aeriajs/core": "^0.0.66",
|
|
41
|
+
"@aeriajs/common": "^0.0.36",
|
|
42
|
+
"@aeriajs/entrypoint": "^0.0.36",
|
|
43
|
+
"@aeriajs/types": "^0.0.33",
|
|
44
|
+
"@aeriajs/validation": "^0.0.39",
|
|
45
45
|
"@types/bcrypt": "^5.0.2",
|
|
46
46
|
"mongodb": "^6.5.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@aeriajs/access-control": "^0.0.
|
|
50
|
-
"@aeriajs/core": "^0.0.
|
|
51
|
-
"@aeriajs/common": "^0.0.
|
|
52
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
53
|
-
"@aeriajs/types": "^0.0.
|
|
54
|
-
"@aeriajs/validation": "^0.0.
|
|
49
|
+
"@aeriajs/access-control": "^0.0.36",
|
|
50
|
+
"@aeriajs/core": "^0.0.66",
|
|
51
|
+
"@aeriajs/common": "^0.0.36",
|
|
52
|
+
"@aeriajs/entrypoint": "^0.0.36",
|
|
53
|
+
"@aeriajs/types": "^0.0.33",
|
|
54
|
+
"@aeriajs/validation": "^0.0.39"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"test": "echo skipping",
|