@aeriajs/builtins 0.0.126 → 0.0.128
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 +27 -0
- package/dist/authentication.js +77 -0
- package/dist/authentication.mjs +72 -0
- package/dist/collections/user/authenticate.d.ts +3 -26
- package/dist/collections/user/authenticate.js +9 -80
- package/dist/collections/user/authenticate.mjs +8 -77
- package/dist/collections/user/index.d.ts +6 -16
- package/dist/functions/describe.d.ts +2 -2
- package/dist/index.d.ts +7 -16
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RouteContext, SchemaWithId, TokenRecipient } from '@aeriajs/types';
|
|
2
|
+
import type { ObjectId } from '@aeriajs/core';
|
|
3
|
+
import type { description } from './collections/user/description.js';
|
|
4
|
+
export type SuccessfulAuthentication = {
|
|
5
|
+
user: Pick<SchemaWithId<typeof description>, 'name' | 'email' | 'roles' | 'active'> & {
|
|
6
|
+
_id: ObjectId | null;
|
|
7
|
+
};
|
|
8
|
+
token: TokenRecipient;
|
|
9
|
+
};
|
|
10
|
+
export declare enum AuthenticationError {
|
|
11
|
+
InvalidCredentials = "INVALID_CREDENTIALS",
|
|
12
|
+
InactiveUser = "INACTIVE_USER"
|
|
13
|
+
}
|
|
14
|
+
export declare const successfulAuthentication: (userId: ObjectId, context: RouteContext) => Promise<SuccessfulAuthentication>;
|
|
15
|
+
export declare const defaultSuccessfulAuthentication: () => Promise<{
|
|
16
|
+
user: {
|
|
17
|
+
_id: null;
|
|
18
|
+
name: string;
|
|
19
|
+
email: string;
|
|
20
|
+
roles: string[];
|
|
21
|
+
active: boolean;
|
|
22
|
+
};
|
|
23
|
+
token: {
|
|
24
|
+
type: string;
|
|
25
|
+
content: string;
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultSuccessfulAuthentication = exports.successfulAuthentication = exports.AuthenticationError = void 0;
|
|
4
|
+
const core_1 = require("@aeriajs/core");
|
|
5
|
+
var AuthenticationError;
|
|
6
|
+
(function (AuthenticationError) {
|
|
7
|
+
AuthenticationError["InvalidCredentials"] = "INVALID_CREDENTIALS";
|
|
8
|
+
AuthenticationError["InactiveUser"] = "INACTIVE_USER";
|
|
9
|
+
})(AuthenticationError || (exports.AuthenticationError = AuthenticationError = {}));
|
|
10
|
+
const successfulAuthentication = async (userId, context) => {
|
|
11
|
+
const { error, result: user } = await context.collections.user.functions.get({
|
|
12
|
+
filters: {
|
|
13
|
+
_id: userId,
|
|
14
|
+
},
|
|
15
|
+
populate: ['picture_file'],
|
|
16
|
+
});
|
|
17
|
+
if (error) {
|
|
18
|
+
throw new Error();
|
|
19
|
+
}
|
|
20
|
+
const tokenContent = {
|
|
21
|
+
sub: user._id,
|
|
22
|
+
roles: user.roles,
|
|
23
|
+
userinfo: {},
|
|
24
|
+
};
|
|
25
|
+
if (context.config.security.authenticationRateLimiting) {
|
|
26
|
+
//
|
|
27
|
+
}
|
|
28
|
+
if (context.config.security.logSuccessfulAuthentications) {
|
|
29
|
+
await context.log('successful authentication', {
|
|
30
|
+
email: user.email,
|
|
31
|
+
roles: user.roles,
|
|
32
|
+
_id: user._id,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (context.config.tokenUserProperties) {
|
|
36
|
+
const pick = (obj, properties) => properties.reduce((a, prop) => {
|
|
37
|
+
if ('prop' in obj) {
|
|
38
|
+
return a;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...a,
|
|
42
|
+
[prop]: obj[prop],
|
|
43
|
+
};
|
|
44
|
+
}, {});
|
|
45
|
+
tokenContent.userinfo = pick(user, context.config.tokenUserProperties);
|
|
46
|
+
}
|
|
47
|
+
const token = await (0, core_1.signToken)(tokenContent);
|
|
48
|
+
return {
|
|
49
|
+
user: user,
|
|
50
|
+
token: {
|
|
51
|
+
type: 'bearer',
|
|
52
|
+
content: token,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
exports.successfulAuthentication = successfulAuthentication;
|
|
57
|
+
const defaultSuccessfulAuthentication = async () => {
|
|
58
|
+
const token = await (0, core_1.signToken)({
|
|
59
|
+
_id: null,
|
|
60
|
+
roles: ['root'],
|
|
61
|
+
userinfo: {},
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
user: {
|
|
65
|
+
_id: null,
|
|
66
|
+
name: 'God Mode',
|
|
67
|
+
email: '',
|
|
68
|
+
roles: ['root'],
|
|
69
|
+
active: true,
|
|
70
|
+
},
|
|
71
|
+
token: {
|
|
72
|
+
type: 'bearer',
|
|
73
|
+
content: token,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
exports.defaultSuccessfulAuthentication = defaultSuccessfulAuthentication;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { signToken } from "@aeriajs/core";
|
|
3
|
+
export var AuthenticationError = /* @__PURE__ */ ((AuthenticationError2) => {
|
|
4
|
+
AuthenticationError2["InvalidCredentials"] = "INVALID_CREDENTIALS";
|
|
5
|
+
AuthenticationError2["InactiveUser"] = "INACTIVE_USER";
|
|
6
|
+
return AuthenticationError2;
|
|
7
|
+
})(AuthenticationError || {});
|
|
8
|
+
export const successfulAuthentication = async (userId, context) => {
|
|
9
|
+
const { error, result: user } = await context.collections.user.functions.get({
|
|
10
|
+
filters: {
|
|
11
|
+
_id: userId
|
|
12
|
+
},
|
|
13
|
+
populate: ["picture_file"]
|
|
14
|
+
});
|
|
15
|
+
if (error) {
|
|
16
|
+
throw new Error();
|
|
17
|
+
}
|
|
18
|
+
const tokenContent = {
|
|
19
|
+
sub: user._id,
|
|
20
|
+
roles: user.roles,
|
|
21
|
+
userinfo: {}
|
|
22
|
+
};
|
|
23
|
+
if (context.config.security.authenticationRateLimiting) {
|
|
24
|
+
}
|
|
25
|
+
if (context.config.security.logSuccessfulAuthentications) {
|
|
26
|
+
await context.log("successful authentication", {
|
|
27
|
+
email: user.email,
|
|
28
|
+
roles: user.roles,
|
|
29
|
+
_id: user._id
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (context.config.tokenUserProperties) {
|
|
33
|
+
const pick = (obj, properties) => properties.reduce((a, prop) => {
|
|
34
|
+
if ("prop" in obj) {
|
|
35
|
+
return a;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
...a,
|
|
39
|
+
[prop]: obj[prop]
|
|
40
|
+
};
|
|
41
|
+
}, {});
|
|
42
|
+
tokenContent.userinfo = pick(user, context.config.tokenUserProperties);
|
|
43
|
+
}
|
|
44
|
+
const token = await signToken(tokenContent);
|
|
45
|
+
return {
|
|
46
|
+
user,
|
|
47
|
+
token: {
|
|
48
|
+
type: "bearer",
|
|
49
|
+
content: token
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export const defaultSuccessfulAuthentication = async () => {
|
|
54
|
+
const token = await signToken({
|
|
55
|
+
_id: null,
|
|
56
|
+
roles: ["root"],
|
|
57
|
+
userinfo: {}
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
user: {
|
|
61
|
+
_id: null,
|
|
62
|
+
name: "God Mode",
|
|
63
|
+
email: "",
|
|
64
|
+
roles: ["root"],
|
|
65
|
+
active: true
|
|
66
|
+
},
|
|
67
|
+
token: {
|
|
68
|
+
type: "bearer",
|
|
69
|
+
content: token
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Context,
|
|
1
|
+
import type { Context, TokenRecipient } from '@aeriajs/types';
|
|
2
2
|
import type { description } from './description.js';
|
|
3
|
-
import type { ObjectId } from '@aeriajs/core';
|
|
4
3
|
import { Result, HTTPStatus, ACError } from '@aeriajs/types';
|
|
4
|
+
import { AuthenticationError } from '../../authentication.js';
|
|
5
5
|
type Props = {
|
|
6
6
|
email: string;
|
|
7
7
|
password: string;
|
|
@@ -9,29 +9,6 @@ type Props = {
|
|
|
9
9
|
token?: TokenRecipient;
|
|
10
10
|
revalidate: true;
|
|
11
11
|
};
|
|
12
|
-
type Return = {
|
|
13
|
-
user: Pick<SchemaWithId<typeof description>, 'name' | 'email' | 'roles' | 'active'> & {
|
|
14
|
-
_id: ObjectId | null;
|
|
15
|
-
};
|
|
16
|
-
token: TokenRecipient;
|
|
17
|
-
};
|
|
18
|
-
export declare enum AuthenticationError {
|
|
19
|
-
InvalidCredentials = "INVALID_CREDENTIALS",
|
|
20
|
-
InactiveUser = "INACTIVE_USER"
|
|
21
|
-
}
|
|
22
|
-
export declare const getDefaultUser: () => Promise<{
|
|
23
|
-
user: {
|
|
24
|
-
_id: null;
|
|
25
|
-
name: string;
|
|
26
|
-
email: string;
|
|
27
|
-
roles: string[];
|
|
28
|
-
active: boolean;
|
|
29
|
-
};
|
|
30
|
-
token: {
|
|
31
|
-
type: string;
|
|
32
|
-
content: string;
|
|
33
|
-
};
|
|
34
|
-
}>;
|
|
35
12
|
export declare const authenticate: (props: Props, context: Context<typeof description>) => Promise<Result.Error<{
|
|
36
13
|
readonly code: ACError.AuthorizationError;
|
|
37
14
|
} & {
|
|
@@ -39,7 +16,7 @@ export declare const authenticate: (props: Props, context: Context<typeof descri
|
|
|
39
16
|
}> | {
|
|
40
17
|
readonly _tag: "Result";
|
|
41
18
|
readonly error: undefined;
|
|
42
|
-
readonly result:
|
|
19
|
+
readonly result: import("../../authentication.js").SuccessfulAuthentication | {
|
|
43
20
|
user: {
|
|
44
21
|
_id: null;
|
|
45
22
|
name: string;
|
|
@@ -1,81 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.authenticate =
|
|
3
|
+
exports.authenticate = void 0;
|
|
4
4
|
const types_1 = require("@aeriajs/types");
|
|
5
5
|
const bcrypt_1 = require("bcrypt");
|
|
6
6
|
const core_1 = require("@aeriajs/core");
|
|
7
|
-
|
|
8
|
-
(function (AuthenticationError) {
|
|
9
|
-
AuthenticationError["InvalidCredentials"] = "INVALID_CREDENTIALS";
|
|
10
|
-
AuthenticationError["InactiveUser"] = "INACTIVE_USER";
|
|
11
|
-
})(AuthenticationError || (exports.AuthenticationError = AuthenticationError = {}));
|
|
12
|
-
const getUser = async (userId, context) => {
|
|
13
|
-
const { error, result: leanUser } = await context.collection.functions.get({
|
|
14
|
-
filters: {
|
|
15
|
-
_id: userId,
|
|
16
|
-
},
|
|
17
|
-
populate: ['picture_file'],
|
|
18
|
-
});
|
|
19
|
-
if (error) {
|
|
20
|
-
throw new Error();
|
|
21
|
-
}
|
|
22
|
-
const tokenContent = {
|
|
23
|
-
sub: leanUser._id,
|
|
24
|
-
roles: leanUser.roles,
|
|
25
|
-
userinfo: {},
|
|
26
|
-
};
|
|
27
|
-
if (context.config.security.authenticationRateLimiting) {
|
|
28
|
-
//
|
|
29
|
-
}
|
|
30
|
-
if (context.config.security.logSuccessfulAuthentications) {
|
|
31
|
-
await context.log('successful authentication', {
|
|
32
|
-
email: leanUser.email,
|
|
33
|
-
roles: leanUser.roles,
|
|
34
|
-
_id: leanUser._id,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
if (context.config.tokenUserProperties) {
|
|
38
|
-
const pick = (obj, properties) => properties.reduce((a, prop) => {
|
|
39
|
-
if ('prop' in obj) {
|
|
40
|
-
return a;
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
...a,
|
|
44
|
-
[prop]: obj[prop],
|
|
45
|
-
};
|
|
46
|
-
}, {});
|
|
47
|
-
tokenContent.userinfo = pick(leanUser, context.config.tokenUserProperties);
|
|
48
|
-
}
|
|
49
|
-
const token = await (0, core_1.signToken)(tokenContent);
|
|
50
|
-
return {
|
|
51
|
-
user: leanUser,
|
|
52
|
-
token: {
|
|
53
|
-
type: 'bearer',
|
|
54
|
-
content: token,
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
const getDefaultUser = async () => {
|
|
59
|
-
const token = await (0, core_1.signToken)({
|
|
60
|
-
_id: null,
|
|
61
|
-
roles: ['root'],
|
|
62
|
-
userinfo: {},
|
|
63
|
-
});
|
|
64
|
-
return {
|
|
65
|
-
user: {
|
|
66
|
-
_id: null,
|
|
67
|
-
name: 'God Mode',
|
|
68
|
-
email: '',
|
|
69
|
-
roles: ['root'],
|
|
70
|
-
active: true,
|
|
71
|
-
},
|
|
72
|
-
token: {
|
|
73
|
-
type: 'bearer',
|
|
74
|
-
content: token,
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
exports.getDefaultUser = getDefaultUser;
|
|
7
|
+
const authentication_js_1 = require("../../authentication.js");
|
|
79
8
|
const authenticate = async (props, context) => {
|
|
80
9
|
if ('revalidate' in props) {
|
|
81
10
|
const { token } = props;
|
|
@@ -88,17 +17,17 @@ const authenticate = async (props, context) => {
|
|
|
88
17
|
? await (0, core_1.decodeToken)(token.content)
|
|
89
18
|
: context.token;
|
|
90
19
|
return types_1.Result.result(decodedToken.sub
|
|
91
|
-
? await
|
|
92
|
-
: await (0,
|
|
20
|
+
? await (0, authentication_js_1.successfulAuthentication)(decodedToken.sub, context)
|
|
21
|
+
: await (0, authentication_js_1.defaultSuccessfulAuthentication)());
|
|
93
22
|
}
|
|
94
23
|
if (typeof props.email !== 'string') {
|
|
95
24
|
return context.error(types_1.HTTPStatus.Unauthorized, {
|
|
96
|
-
code: AuthenticationError.InvalidCredentials,
|
|
25
|
+
code: authentication_js_1.AuthenticationError.InvalidCredentials,
|
|
97
26
|
});
|
|
98
27
|
}
|
|
99
28
|
if (context.config.defaultUser) {
|
|
100
29
|
if (props.email === context.config.defaultUser.username && props.password === context.config.defaultUser.password) {
|
|
101
|
-
return types_1.Result.result(await (0,
|
|
30
|
+
return types_1.Result.result(await (0, authentication_js_1.defaultSuccessfulAuthentication)());
|
|
102
31
|
}
|
|
103
32
|
}
|
|
104
33
|
const user = await context.collection.model.findOne({
|
|
@@ -112,14 +41,14 @@ const authenticate = async (props, context) => {
|
|
|
112
41
|
});
|
|
113
42
|
if (!user || !user.password || !await (0, bcrypt_1.compare)(props.password, user.password)) {
|
|
114
43
|
return context.error(types_1.HTTPStatus.Unauthorized, {
|
|
115
|
-
code: AuthenticationError.InvalidCredentials,
|
|
44
|
+
code: authentication_js_1.AuthenticationError.InvalidCredentials,
|
|
116
45
|
});
|
|
117
46
|
}
|
|
118
47
|
if (!user.active) {
|
|
119
48
|
return context.error(types_1.HTTPStatus.Unauthorized, {
|
|
120
|
-
code: AuthenticationError.InactiveUser,
|
|
49
|
+
code: authentication_js_1.AuthenticationError.InactiveUser,
|
|
121
50
|
});
|
|
122
51
|
}
|
|
123
|
-
return types_1.Result.result(await
|
|
52
|
+
return types_1.Result.result(await (0, authentication_js_1.successfulAuthentication)(user._id, context));
|
|
124
53
|
};
|
|
125
54
|
exports.authenticate = authenticate;
|
|
@@ -1,77 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { Result, HTTPStatus, ACError } from "@aeriajs/types";
|
|
3
3
|
import { compare as bcryptCompare } from "bcrypt";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
AuthenticationError2["InvalidCredentials"] = "INVALID_CREDENTIALS";
|
|
7
|
-
AuthenticationError2["InactiveUser"] = "INACTIVE_USER";
|
|
8
|
-
return AuthenticationError2;
|
|
9
|
-
})(AuthenticationError || {});
|
|
10
|
-
const getUser = async (userId, context) => {
|
|
11
|
-
const { error, result: leanUser } = await context.collection.functions.get({
|
|
12
|
-
filters: {
|
|
13
|
-
_id: userId
|
|
14
|
-
},
|
|
15
|
-
populate: ["picture_file"]
|
|
16
|
-
});
|
|
17
|
-
if (error) {
|
|
18
|
-
throw new Error();
|
|
19
|
-
}
|
|
20
|
-
const tokenContent = {
|
|
21
|
-
sub: leanUser._id,
|
|
22
|
-
roles: leanUser.roles,
|
|
23
|
-
userinfo: {}
|
|
24
|
-
};
|
|
25
|
-
if (context.config.security.authenticationRateLimiting) {
|
|
26
|
-
}
|
|
27
|
-
if (context.config.security.logSuccessfulAuthentications) {
|
|
28
|
-
await context.log("successful authentication", {
|
|
29
|
-
email: leanUser.email,
|
|
30
|
-
roles: leanUser.roles,
|
|
31
|
-
_id: leanUser._id
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
if (context.config.tokenUserProperties) {
|
|
35
|
-
const pick = (obj, properties) => properties.reduce((a, prop) => {
|
|
36
|
-
if ("prop" in obj) {
|
|
37
|
-
return a;
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
...a,
|
|
41
|
-
[prop]: obj[prop]
|
|
42
|
-
};
|
|
43
|
-
}, {});
|
|
44
|
-
tokenContent.userinfo = pick(leanUser, context.config.tokenUserProperties);
|
|
45
|
-
}
|
|
46
|
-
const token = await signToken(tokenContent);
|
|
47
|
-
return {
|
|
48
|
-
user: leanUser,
|
|
49
|
-
token: {
|
|
50
|
-
type: "bearer",
|
|
51
|
-
content: token
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
export const getDefaultUser = async () => {
|
|
56
|
-
const token = await signToken({
|
|
57
|
-
_id: null,
|
|
58
|
-
roles: ["root"],
|
|
59
|
-
userinfo: {}
|
|
60
|
-
});
|
|
61
|
-
return {
|
|
62
|
-
user: {
|
|
63
|
-
_id: null,
|
|
64
|
-
name: "God Mode",
|
|
65
|
-
email: "",
|
|
66
|
-
roles: ["root"],
|
|
67
|
-
active: true
|
|
68
|
-
},
|
|
69
|
-
token: {
|
|
70
|
-
type: "bearer",
|
|
71
|
-
content: token
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
};
|
|
4
|
+
import { decodeToken } from "@aeriajs/core";
|
|
5
|
+
import { successfulAuthentication, defaultSuccessfulAuthentication, AuthenticationError } from "../../authentication.mjs";
|
|
75
6
|
export const authenticate = async (props, context) => {
|
|
76
7
|
if ("revalidate" in props) {
|
|
77
8
|
const { token } = props;
|
|
@@ -81,16 +12,16 @@ export const authenticate = async (props, context) => {
|
|
|
81
12
|
});
|
|
82
13
|
}
|
|
83
14
|
const decodedToken = token ? await decodeToken(token.content) : context.token;
|
|
84
|
-
return Result.result(decodedToken.sub ? await
|
|
15
|
+
return Result.result(decodedToken.sub ? await successfulAuthentication(decodedToken.sub, context) : await defaultSuccessfulAuthentication());
|
|
85
16
|
}
|
|
86
17
|
if (typeof props.email !== "string") {
|
|
87
18
|
return context.error(HTTPStatus.Unauthorized, {
|
|
88
|
-
code:
|
|
19
|
+
code: AuthenticationError.InvalidCredentials
|
|
89
20
|
});
|
|
90
21
|
}
|
|
91
22
|
if (context.config.defaultUser) {
|
|
92
23
|
if (props.email === context.config.defaultUser.username && props.password === context.config.defaultUser.password) {
|
|
93
|
-
return Result.result(await
|
|
24
|
+
return Result.result(await defaultSuccessfulAuthentication());
|
|
94
25
|
}
|
|
95
26
|
}
|
|
96
27
|
const user = await context.collection.model.findOne(
|
|
@@ -107,13 +38,13 @@ export const authenticate = async (props, context) => {
|
|
|
107
38
|
);
|
|
108
39
|
if (!user || !user.password || !await bcryptCompare(props.password, user.password)) {
|
|
109
40
|
return context.error(HTTPStatus.Unauthorized, {
|
|
110
|
-
code:
|
|
41
|
+
code: AuthenticationError.InvalidCredentials
|
|
111
42
|
});
|
|
112
43
|
}
|
|
113
44
|
if (!user.active) {
|
|
114
45
|
return context.error(HTTPStatus.Unauthorized, {
|
|
115
|
-
code:
|
|
46
|
+
code: AuthenticationError.InactiveUser
|
|
116
47
|
});
|
|
117
48
|
}
|
|
118
|
-
return Result.result(await
|
|
49
|
+
return Result.result(await successfulAuthentication(user._id, context));
|
|
119
50
|
};
|
|
@@ -252,12 +252,7 @@ export declare const user: {
|
|
|
252
252
|
}> | {
|
|
253
253
|
readonly _tag: "Result";
|
|
254
254
|
readonly error: undefined;
|
|
255
|
-
readonly result: {
|
|
256
|
-
user: Pick<import("@aeriajs/types").SchemaWithId<typeof description>, "name" | "email" | "roles" | "active"> & {
|
|
257
|
-
_id: import("@aeriajs/core").ObjectId | null;
|
|
258
|
-
};
|
|
259
|
-
token: import("@aeriajs/types").TokenRecipient;
|
|
260
|
-
} | {
|
|
255
|
+
readonly result: import("../../authentication.js").SuccessfulAuthentication | {
|
|
261
256
|
user: {
|
|
262
257
|
_id: null;
|
|
263
258
|
name: string;
|
|
@@ -271,11 +266,11 @@ export declare const user: {
|
|
|
271
266
|
};
|
|
272
267
|
};
|
|
273
268
|
} | import("@aeriajs/types").Result.Error<{
|
|
274
|
-
readonly code: import("
|
|
269
|
+
readonly code: import("../../authentication.js").AuthenticationError.InvalidCredentials;
|
|
275
270
|
} & {
|
|
276
271
|
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
277
272
|
}> | import("@aeriajs/types").Result.Error<{
|
|
278
|
-
readonly code: import("
|
|
273
|
+
readonly code: import("../../authentication.js").AuthenticationError.InactiveUser;
|
|
279
274
|
} & {
|
|
280
275
|
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
281
276
|
}>>;
|
|
@@ -834,12 +829,7 @@ export declare const user: {
|
|
|
834
829
|
}> | {
|
|
835
830
|
readonly _tag: "Result";
|
|
836
831
|
readonly error: undefined;
|
|
837
|
-
readonly result: {
|
|
838
|
-
user: Pick<import("@aeriajs/types").SchemaWithId<typeof description>, "name" | "email" | "roles" | "active"> & {
|
|
839
|
-
_id: import("@aeriajs/core").ObjectId | null;
|
|
840
|
-
};
|
|
841
|
-
token: import("@aeriajs/types").TokenRecipient;
|
|
842
|
-
} | {
|
|
832
|
+
readonly result: import("../../authentication.js").SuccessfulAuthentication | {
|
|
843
833
|
user: {
|
|
844
834
|
_id: null;
|
|
845
835
|
name: string;
|
|
@@ -853,11 +843,11 @@ export declare const user: {
|
|
|
853
843
|
};
|
|
854
844
|
};
|
|
855
845
|
} | import("@aeriajs/types").Result.Error<{
|
|
856
|
-
readonly code: import("
|
|
846
|
+
readonly code: import("../../authentication.js").AuthenticationError.InvalidCredentials;
|
|
857
847
|
} & {
|
|
858
848
|
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
859
849
|
}> | import("@aeriajs/types").Result.Error<{
|
|
860
|
-
readonly code: import("
|
|
850
|
+
readonly code: import("../../authentication.js").AuthenticationError.InactiveUser;
|
|
861
851
|
} & {
|
|
862
852
|
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
863
853
|
}>>;
|
|
@@ -15,11 +15,11 @@ export declare const describe: (contextOrPayload: RouteContext | Payload) => Pro
|
|
|
15
15
|
} & {
|
|
16
16
|
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
17
17
|
}) | ({
|
|
18
|
-
readonly code: import("../
|
|
18
|
+
readonly code: import("../authentication.js").AuthenticationError.InvalidCredentials;
|
|
19
19
|
} & {
|
|
20
20
|
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
21
21
|
}) | ({
|
|
22
|
-
readonly code: import("../
|
|
22
|
+
readonly code: import("../authentication.js").AuthenticationError.InactiveUser;
|
|
23
23
|
} & {
|
|
24
24
|
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
25
25
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './collections/index.js';
|
|
2
2
|
export * as builtinFunctions from './functions/index.js';
|
|
3
|
+
export * from './authentication.js';
|
|
3
4
|
import { file, tempFile, log, resourceUsage, user } from './collections/index.js';
|
|
4
5
|
type File = typeof file.item;
|
|
5
6
|
type TempFile = typeof tempFile.item;
|
|
@@ -918,12 +919,7 @@ export declare const collections: {
|
|
|
918
919
|
}> | {
|
|
919
920
|
readonly _tag: "Result";
|
|
920
921
|
readonly error: undefined;
|
|
921
|
-
readonly result: {
|
|
922
|
-
user: Pick<import("@aeriajs/types").SchemaWithId<typeof import("./collections/user/description.js").description>, "name" | "email" | "roles" | "active"> & {
|
|
923
|
-
_id: import("mongodb").ObjectId | null;
|
|
924
|
-
};
|
|
925
|
-
token: import("@aeriajs/types").TokenRecipient;
|
|
926
|
-
} | {
|
|
922
|
+
readonly result: import("./authentication.js").SuccessfulAuthentication | {
|
|
927
923
|
user: {
|
|
928
924
|
_id: null;
|
|
929
925
|
name: string;
|
|
@@ -937,11 +933,11 @@ export declare const collections: {
|
|
|
937
933
|
};
|
|
938
934
|
};
|
|
939
935
|
} | import("@aeriajs/types").Result.Error<{
|
|
940
|
-
readonly code: import("./
|
|
936
|
+
readonly code: import("./authentication.js").AuthenticationError.InvalidCredentials;
|
|
941
937
|
} & {
|
|
942
938
|
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
943
939
|
}> | import("@aeriajs/types").Result.Error<{
|
|
944
|
-
readonly code: import("./
|
|
940
|
+
readonly code: import("./authentication.js").AuthenticationError.InactiveUser;
|
|
945
941
|
} & {
|
|
946
942
|
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
947
943
|
}>>;
|
|
@@ -1500,12 +1496,7 @@ export declare const collections: {
|
|
|
1500
1496
|
}> | {
|
|
1501
1497
|
readonly _tag: "Result";
|
|
1502
1498
|
readonly error: undefined;
|
|
1503
|
-
readonly result: {
|
|
1504
|
-
user: Pick<import("@aeriajs/types").SchemaWithId<typeof import("./collections/user/description.js").description>, "name" | "email" | "roles" | "active"> & {
|
|
1505
|
-
_id: import("mongodb").ObjectId | null;
|
|
1506
|
-
};
|
|
1507
|
-
token: import("@aeriajs/types").TokenRecipient;
|
|
1508
|
-
} | {
|
|
1499
|
+
readonly result: import("./authentication.js").SuccessfulAuthentication | {
|
|
1509
1500
|
user: {
|
|
1510
1501
|
_id: null;
|
|
1511
1502
|
name: string;
|
|
@@ -1519,11 +1510,11 @@ export declare const collections: {
|
|
|
1519
1510
|
};
|
|
1520
1511
|
};
|
|
1521
1512
|
} | import("@aeriajs/types").Result.Error<{
|
|
1522
|
-
readonly code: import("./
|
|
1513
|
+
readonly code: import("./authentication.js").AuthenticationError.InvalidCredentials;
|
|
1523
1514
|
} & {
|
|
1524
1515
|
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
1525
1516
|
}> | import("@aeriajs/types").Result.Error<{
|
|
1526
|
-
readonly code: import("./
|
|
1517
|
+
readonly code: import("./authentication.js").AuthenticationError.InactiveUser;
|
|
1527
1518
|
} & {
|
|
1528
1519
|
httpStatus: import("@aeriajs/types").HTTPStatus.Unauthorized;
|
|
1529
1520
|
}>>;
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.collections = exports.builtinFunctions = void 0;
|
|
18
18
|
__exportStar(require("./collections/index.js"), exports);
|
|
19
19
|
exports.builtinFunctions = require("./functions/index.js");
|
|
20
|
+
__exportStar(require("./authentication.js"), exports);
|
|
20
21
|
const index_js_1 = require("./collections/index.js");
|
|
21
22
|
exports.collections = {
|
|
22
23
|
file: index_js_1.file,
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/builtins",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.128",
|
|
4
4
|
"description": "## Installation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"mongodb": "^6.5.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@aeriajs/core": "^0.0.
|
|
48
|
+
"@aeriajs/core": "^0.0.128",
|
|
49
49
|
"@aeriajs/common": "^0.0.80",
|
|
50
50
|
"@aeriajs/entrypoint": "^0.0.82",
|
|
51
51
|
"@aeriajs/types": "^0.0.68",
|