@minimaltech/node-infra 0.5.9-22 → 0.5.9-24
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/base/applications/base.application.js +40 -28
- package/dist/base/applications/default.application.js +8 -2
- package/dist/base/base.component.js +2 -2
- package/dist/base/base.helper.js +3 -4
- package/dist/base/base.provider.js +2 -2
- package/dist/base/base.sequence.js +26 -17
- package/dist/base/controllers/common.js +9 -8
- package/dist/base/controllers/crud.controller.js +67 -55
- package/dist/base/controllers/express-request-handler.js +0 -2
- package/dist/base/controllers/kv.controller.js +18 -7
- package/dist/base/controllers/relational.controller.d.ts +3 -1
- package/dist/base/controllers/relational.controller.js +57 -40
- package/dist/base/controllers/service-crud.controller.js +46 -46
- package/dist/base/datasources/base.datasource.js +0 -1
- package/dist/base/loopback/@lb/core/index.js +1 -0
- package/dist/base/loopback/@lb/repository/index.js +1 -0
- package/dist/base/loopback/authentication/index.js +2 -0
- package/dist/base/loopback/filter/index.js +2 -0
- package/dist/base/loopback/http-server/index.js +2 -0
- package/dist/base/models/base.model.d.ts +7 -0
- package/dist/base/models/base.model.js +23 -5
- package/dist/base/repositories/base.repository.d.ts +3 -0
- package/dist/base/repositories/base.repository.js +24 -5
- package/dist/base/repositories/relations/has-many-polymorphic/decorator.d.ts +8 -0
- package/dist/base/repositories/relations/has-many-polymorphic/decorator.js +10 -11
- package/dist/base/repositories/relations/has-many-polymorphic/factory.d.ts +9 -0
- package/dist/base/repositories/relations/has-many-polymorphic/factory.js +30 -12
- package/dist/base/repositories/searchable-tz-crud.repository.js +160 -129
- package/dist/base/repositories/tz-crud.repository.js +58 -23
- package/dist/base/services/base-crud.service.js +9 -6
- package/dist/base/services/base.service.js +2 -2
- package/dist/common/constants.js +89 -81
- package/dist/common/environments.js +25 -25
- package/dist/common/keys.js +2 -2
- package/dist/common/statuses.js +31 -28
- package/dist/common/types.d.ts +3 -0
- package/dist/components/authenticate/common/constants.js +13 -11
- package/dist/components/authenticate/common/keys.js +7 -7
- package/dist/components/authenticate/common/types.js +3 -11
- package/dist/components/authenticate/component.js +28 -20
- package/dist/components/authenticate/controllers/auth.controller.js +11 -13
- package/dist/components/authenticate/controllers/oauth2.controller.js +20 -18
- package/dist/components/authenticate/middleware.js +35 -25
- package/dist/components/authenticate/models/oauth2-client.model.js +3 -8
- package/dist/components/authenticate/models/oauth2-scope.model.js +0 -4
- package/dist/components/authenticate/models/oauth2-token.model.js +0 -7
- package/dist/components/authenticate/oauth2-handlers/authorization-code.handler.js +5 -4
- package/dist/components/authenticate/oauth2-handlers/base.js +110 -95
- package/dist/components/authenticate/oauth2-handlers/client-credential.handler.js +3 -2
- package/dist/components/authenticate/oauth2-handlers/oauth2.js +2 -3
- package/dist/components/authenticate/repositories/oauth2.repository.js +0 -2
- package/dist/components/authenticate/services/basic-token.service.js +29 -18
- package/dist/components/authenticate/services/basic.strategy.js +17 -7
- package/dist/components/authenticate/services/jwt-token.service.js +40 -27
- package/dist/components/authenticate/services/jwt.strategy.js +1 -2
- package/dist/components/authenticate/services/oauth2.service.js +110 -98
- package/dist/components/authenticate/services/oauth2.strategy.js +31 -19
- package/dist/components/authorize/adapters/adapter-builder.js +0 -1
- package/dist/components/authorize/adapters/base.adapter.js +9 -2
- package/dist/components/authorize/adapters/casbin-postgres-adapter.helper.js +55 -37
- package/dist/components/authorize/adapters/casbin-redis-adapter.helper.js +1 -0
- package/dist/components/authorize/common/constants.js +12 -10
- package/dist/components/authorize/common/keys.js +15 -15
- package/dist/components/authorize/common/types.js +2 -2
- package/dist/components/authorize/component.js +59 -44
- package/dist/components/authorize/decorators/index.d.ts +11 -0
- package/dist/components/authorize/decorators/index.js +14 -1
- package/dist/components/authorize/interceptor.js +80 -76
- package/dist/components/authorize/migrations/0000-create-view-policy.js +14 -3
- package/dist/components/authorize/models/defs.js +5 -24
- package/dist/components/authorize/models/role.model.js +1 -1
- package/dist/components/authorize/models/user-role.model.js +1 -0
- package/dist/components/authorize/models/view-authorize-policy.model.js +1 -4
- package/dist/components/authorize/provider.js +96 -81
- package/dist/components/authorize/repositories/authorize.repository.js +6 -3
- package/dist/components/authorize/services/enforcer.service.js +27 -20
- package/dist/components/authorize/services/generator.service.d.ts +20 -0
- package/dist/components/authorize/services/generator.service.js +96 -62
- package/dist/components/crash-report/common/keys.js +10 -8
- package/dist/components/crash-report/component.js +44 -31
- package/dist/components/crash-report/providers/provider.js +0 -1
- package/dist/components/crash-report/providers/third-parties/base.js +2 -2
- package/dist/components/crash-report/services/mt-crash-report.service.js +5 -5
- package/dist/components/grpc/common/keys.js +4 -4
- package/dist/components/grpc/components/server.component.js +8 -8
- package/dist/components/grpc/controllers/base.js +0 -1
- package/dist/components/grpc/helpers/grpc-client.js +3 -9
- package/dist/components/grpc/helpers/grpc-server.js +17 -14
- package/dist/components/grpc/persistents/grpc.connector.js +2 -8
- package/dist/components/grpc/persistents/grpc.datasource.js +3 -2
- package/dist/components/grpc/persistents/grpc.repository.js +2 -3
- package/dist/components/health-check/component.js +0 -1
- package/dist/components/migration/common/keys.js +3 -3
- package/dist/components/migration/component.js +8 -5
- package/dist/components/migration/models/migration.model.js +0 -2
- package/dist/components/socket-io/common/constants.js +10 -10
- package/dist/components/socket-io/common/keys.js +6 -6
- package/dist/components/socket-io/component.js +8 -9
- package/dist/components/socket-io/helpers/socket-io-client.helper.js +11 -7
- package/dist/components/socket-io/helpers/socket-io-server.helper.js +41 -26
- package/dist/components/static-asset/common/keys.js +4 -4
- package/dist/components/static-asset/component.js +8 -9
- package/dist/components/static-asset/controllers/asset.controller.d.ts +8 -0
- package/dist/components/static-asset/controllers/asset.controller.js +93 -71
- package/dist/components/static-asset/controllers/resource.controller.js +9 -8
- package/dist/datasources/memory/datasource.js +3 -3
- package/dist/datasources/postgres/datasource.js +10 -10
- package/dist/datasources/redis/connector.js +7 -18
- package/dist/datasources/redis/datasource.js +7 -7
- package/dist/helpers/application-environment.helper.js +3 -3
- package/dist/helpers/cron.helper.js +14 -9
- package/dist/helpers/crypto/algorithms/aes.algorithm.js +7 -8
- package/dist/helpers/crypto/algorithms/base.algorithm.js +4 -3
- package/dist/helpers/crypto/algorithms/rsa.algorithm.js +5 -4
- package/dist/helpers/database/query-builder.helper.js +5 -2
- package/dist/helpers/logger/application-logger.js +17 -7
- package/dist/helpers/logger/common/types.js +22 -20
- package/dist/helpers/logger/default-logger.js +12 -2
- package/dist/helpers/logger/factory.js +1 -1
- package/dist/helpers/logger/transports/dgram.transport.js +25 -16
- package/dist/helpers/network/http-request/base-network-request.helper.js +34 -36
- package/dist/helpers/network/http-request/fetcher/axios-fetcher.js +22 -10
- package/dist/helpers/network/http-request/fetcher/base-fetcher.js +36 -13
- package/dist/helpers/network/http-request/fetcher/node-fetcher.js +59 -37
- package/dist/helpers/network/tcp-socket/base-tcp-client.helper.js +27 -30
- package/dist/helpers/network/tcp-socket/base-tcp-server.helper.js +19 -21
- package/dist/helpers/network/tcp-socket/network-tcp-client.helper.js +1 -5
- package/dist/helpers/network/tcp-socket/network-tcp-server.helper.js +1 -5
- package/dist/helpers/network/tcp-socket/network-tls-tcp-client.helper.js +1 -5
- package/dist/helpers/network/tcp-socket/network-tls-tcp-server.helper.js +1 -5
- package/dist/helpers/network/udp-socket/network-udp-client.helper.js +18 -21
- package/dist/helpers/queue/bullmq.helper.js +22 -21
- package/dist/helpers/queue/mqtt.helper.js +17 -15
- package/dist/helpers/queue/queue.helper.js +145 -74
- package/dist/helpers/redis/default.helper.js +162 -117
- package/dist/helpers/redis/redis-cluster.helper.js +2 -7
- package/dist/helpers/redis/redis.helper.js +5 -8
- package/dist/helpers/storage/di-container.helper.js +0 -2
- package/dist/helpers/storage/minio.helper.js +128 -88
- package/dist/helpers/testing/common.js +3 -3
- package/dist/helpers/testing/describe.js +21 -14
- package/dist/helpers/testing/test-case.js +0 -5
- package/dist/helpers/testing/test-handler.js +30 -23
- package/dist/helpers/testing/test-plan/base.js +6 -9
- package/dist/helpers/worker-thread/base.js +20 -10
- package/dist/helpers/worker-thread/worker-bus.js +12 -11
- package/dist/helpers/worker-thread/worker-pool.js +25 -17
- package/dist/interceptors/content-range.interceptor.js +132 -115
- package/dist/middlewares/request-body-parser.middleware.js +16 -4
- package/dist/middlewares/request-spy.middleware.js +5 -4
- package/dist/migrations/handler.js +22 -13
- package/dist/mixins/data-type.mixin.js +0 -5
- package/dist/mixins/deprecated/user-audit.mixin.d.ts +3 -0
- package/dist/mixins/deprecated/user-audit.mixin.js +5 -2
- package/dist/mixins/duplicatable.mixin.js +0 -1
- package/dist/mixins/object-search.mixin.js +0 -1
- package/dist/mixins/principal.mixin.js +0 -2
- package/dist/mixins/soft-delete.mixin.js +0 -1
- package/dist/mixins/soft-persistent.mixin.js +0 -1
- package/dist/mixins/text-search.mixin.js +0 -1
- package/dist/mixins/tz.mixin.js +0 -2
- package/dist/mixins/user-audit.mixin.js +3 -5
- package/dist/mixins/vector.mixin.js +6 -9
- package/dist/tsconfig.base.json +6 -5
- package/dist/utilities/date.utility.js +23 -5
- package/dist/utilities/error.utility.js +0 -2
- package/dist/utilities/model.utility.js +6 -2
- package/dist/utilities/parse.utility.d.ts +16 -0
- package/dist/utilities/parse.utility.js +41 -6
- package/dist/utilities/performance.utility.js +2 -1
- package/dist/utilities/promise.utility.d.ts +17 -0
- package/dist/utilities/promise.utility.js +31 -5
- package/dist/utilities/query.utility.js +16 -8
- package/dist/utilities/request.utility.js +8 -2
- package/package.json +2 -3
package/dist/common/constants.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a, _b;
|
|
3
|
+
var _c, _d, _e;
|
|
2
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
5
|
exports.MimeTypes = exports.UserTypes = exports.ConfigurationDataTypes = exports.EntityRelations = exports.ApplicationRunModes = exports.Sorts = exports.ResultCodes = exports.ApplicationRoles = exports.Formatters = exports.ConstantValidator = exports.App = void 0;
|
|
4
6
|
class App {
|
|
5
|
-
static APPLICATION_NAME = process.env.APP_ENV_APPLICATION_NAME ?? 'APP';
|
|
6
|
-
static APPLICATION_SECRET = process.env.APP_ENV_APPLICATION_SECRET ?? 'application.secret';
|
|
7
|
-
static DEFAULT_LOCALE = 'en.UTF-8';
|
|
8
|
-
static DEFAULT_EXPLORER_PATH = '/explorer';
|
|
9
|
-
static DEFAULT_QUERY_LIMIT = 50;
|
|
10
7
|
}
|
|
11
8
|
exports.App = App;
|
|
9
|
+
App.APPLICATION_NAME = (_a = process.env.APP_ENV_APPLICATION_NAME) !== null && _a !== void 0 ? _a : 'APP';
|
|
10
|
+
App.APPLICATION_SECRET = (_b = process.env.APP_ENV_APPLICATION_SECRET) !== null && _b !== void 0 ? _b : 'application.secret';
|
|
11
|
+
App.DEFAULT_LOCALE = 'en.UTF-8';
|
|
12
|
+
App.DEFAULT_EXPLORER_PATH = '/explorer';
|
|
13
|
+
App.DEFAULT_QUERY_LIMIT = 50;
|
|
12
14
|
class ConstantValidator {
|
|
13
|
-
schemeSet;
|
|
14
15
|
constructor(opts) {
|
|
15
|
-
|
|
16
|
+
var _a;
|
|
17
|
+
this.schemeSet = new Set([...((_a = opts === null || opts === void 0 ? void 0 : opts.values) !== null && _a !== void 0 ? _a : [])]);
|
|
16
18
|
}
|
|
17
19
|
static fromValues(opts) {
|
|
18
20
|
return new ConstantValidator(opts);
|
|
@@ -23,112 +25,118 @@ class ConstantValidator {
|
|
|
23
25
|
}
|
|
24
26
|
exports.ConstantValidator = ConstantValidator;
|
|
25
27
|
class Formatters {
|
|
26
|
-
static DATE_TIME_1 = 'YYYY-MM-DD HH:mm:ss';
|
|
27
|
-
static DATE_TIME_2 = 'YYYYMMDDHHmmss';
|
|
28
|
-
static DATE_TIME_3 = 'YYYY-MM-DD HH:mm:ss.SSS';
|
|
29
|
-
static DATE_TIME_4 = 'YYYYMMDDHHmmssSSS';
|
|
30
|
-
static DATE_1 = 'YYYY-MM-DD';
|
|
31
|
-
static DATE_2 = 'YYYYMMDD';
|
|
32
|
-
static TIME_1 = 'HH:mm:ss';
|
|
33
|
-
static TIME_2 = 'HHmmssSSS';
|
|
34
|
-
static YEAR_MONTH_1 = 'YYYY-MM';
|
|
35
|
-
static YEAR_MONTH_2 = 'YYYYMM';
|
|
36
28
|
}
|
|
37
29
|
exports.Formatters = Formatters;
|
|
30
|
+
Formatters.DATE_TIME_1 = 'YYYY-MM-DD HH:mm:ss';
|
|
31
|
+
Formatters.DATE_TIME_2 = 'YYYYMMDDHHmmss';
|
|
32
|
+
Formatters.DATE_TIME_3 = 'YYYY-MM-DD HH:mm:ss.SSS';
|
|
33
|
+
Formatters.DATE_TIME_4 = 'YYYYMMDDHHmmssSSS';
|
|
34
|
+
Formatters.DATE_1 = 'YYYY-MM-DD';
|
|
35
|
+
Formatters.DATE_2 = 'YYYYMMDD';
|
|
36
|
+
Formatters.TIME_1 = 'HH:mm:ss';
|
|
37
|
+
Formatters.TIME_2 = 'HHmmssSSS';
|
|
38
|
+
Formatters.YEAR_MONTH_1 = 'YYYY-MM';
|
|
39
|
+
Formatters.YEAR_MONTH_2 = 'YYYYMM';
|
|
38
40
|
class ApplicationRoles {
|
|
39
|
-
static API = 'api';
|
|
40
41
|
}
|
|
41
42
|
exports.ApplicationRoles = ApplicationRoles;
|
|
43
|
+
ApplicationRoles.API = 'api';
|
|
42
44
|
class ResultCodes {
|
|
43
|
-
static RS_FAIL = 0;
|
|
44
|
-
static RS_SUCCESS = 1;
|
|
45
|
-
static RS_UNKNOWN_ERROR = -199;
|
|
46
|
-
static RS_2 = {
|
|
47
|
-
Ok: 200,
|
|
48
|
-
Created: 201,
|
|
49
|
-
Accepted: 202,
|
|
50
|
-
NonAuthoritativeInformation: 203,
|
|
51
|
-
NoContent: 204,
|
|
52
|
-
ResetContent: 205,
|
|
53
|
-
PartialContent: 206,
|
|
54
|
-
};
|
|
55
|
-
static RS_4 = {
|
|
56
|
-
BadRequest: 400,
|
|
57
|
-
Unauthorized: 401,
|
|
58
|
-
PaymentRequired: 402,
|
|
59
|
-
Forbidden: 403,
|
|
60
|
-
NotFound: 404,
|
|
61
|
-
MethodNotAllowed: 405,
|
|
62
|
-
RequestTimeout: 408,
|
|
63
|
-
UnsupportedMediaType: 415,
|
|
64
|
-
UnprocessableEntity: 422,
|
|
65
|
-
};
|
|
66
|
-
static RS_5 = {
|
|
67
|
-
InternalServerError: 500,
|
|
68
|
-
NotImplemented: 501,
|
|
69
|
-
};
|
|
70
45
|
}
|
|
71
46
|
exports.ResultCodes = ResultCodes;
|
|
47
|
+
ResultCodes.RS_FAIL = 0;
|
|
48
|
+
ResultCodes.RS_SUCCESS = 1;
|
|
49
|
+
ResultCodes.RS_UNKNOWN_ERROR = -199;
|
|
50
|
+
// 2xx successful – the request was successfully received, understood, and accepted
|
|
51
|
+
ResultCodes.RS_2 = {
|
|
52
|
+
Ok: 200,
|
|
53
|
+
Created: 201,
|
|
54
|
+
Accepted: 202,
|
|
55
|
+
NonAuthoritativeInformation: 203,
|
|
56
|
+
NoContent: 204,
|
|
57
|
+
ResetContent: 205,
|
|
58
|
+
PartialContent: 206,
|
|
59
|
+
};
|
|
60
|
+
// 4xx client error – the request contains bad syntax or cannot be fulfilled
|
|
61
|
+
ResultCodes.RS_4 = {
|
|
62
|
+
BadRequest: 400,
|
|
63
|
+
Unauthorized: 401,
|
|
64
|
+
PaymentRequired: 402,
|
|
65
|
+
Forbidden: 403,
|
|
66
|
+
NotFound: 404,
|
|
67
|
+
MethodNotAllowed: 405,
|
|
68
|
+
RequestTimeout: 408,
|
|
69
|
+
UnsupportedMediaType: 415,
|
|
70
|
+
UnprocessableEntity: 422,
|
|
71
|
+
};
|
|
72
|
+
// 5xx server error – the server failed to fulfil an apparently valid request
|
|
73
|
+
ResultCodes.RS_5 = {
|
|
74
|
+
InternalServerError: 500,
|
|
75
|
+
NotImplemented: 501,
|
|
76
|
+
};
|
|
72
77
|
class Sorts {
|
|
73
|
-
static DESC = 'desc';
|
|
74
|
-
static ASC = 'asc';
|
|
75
78
|
}
|
|
76
79
|
exports.Sorts = Sorts;
|
|
80
|
+
Sorts.DESC = 'desc';
|
|
81
|
+
Sorts.ASC = 'asc';
|
|
77
82
|
class ApplicationRunModes {
|
|
78
|
-
static MODE_START_UP = 'startup';
|
|
79
|
-
static MODE_MIGRATE = 'migrate';
|
|
80
|
-
static MODE_SEED = 'seed';
|
|
81
83
|
}
|
|
82
84
|
exports.ApplicationRunModes = ApplicationRunModes;
|
|
85
|
+
ApplicationRunModes.MODE_START_UP = 'startup';
|
|
86
|
+
ApplicationRunModes.MODE_MIGRATE = 'migrate';
|
|
87
|
+
ApplicationRunModes.MODE_SEED = 'seed';
|
|
83
88
|
class EntityRelations {
|
|
84
|
-
static BELONGS_TO = 'belongsTo';
|
|
85
|
-
static HAS_ONE = 'hasOne';
|
|
86
|
-
static HAS_MANY = 'hasMany';
|
|
87
|
-
static HAS_MANY_THROUGH = 'hasManyThrough';
|
|
88
|
-
static HAS_MANY_POLYMORPHIC = 'hasManyPolymorphic';
|
|
89
|
-
static SCHEME_SET = new Set([
|
|
90
|
-
this.BELONGS_TO,
|
|
91
|
-
this.HAS_ONE,
|
|
92
|
-
this.HAS_MANY,
|
|
93
|
-
this.HAS_MANY_THROUGH,
|
|
94
|
-
this.HAS_MANY_POLYMORPHIC,
|
|
95
|
-
]);
|
|
96
89
|
static isValid(type) {
|
|
97
90
|
return this.SCHEME_SET.has(type);
|
|
98
91
|
}
|
|
99
92
|
}
|
|
100
93
|
exports.EntityRelations = EntityRelations;
|
|
94
|
+
_c = EntityRelations;
|
|
95
|
+
EntityRelations.BELONGS_TO = 'belongsTo';
|
|
96
|
+
EntityRelations.HAS_ONE = 'hasOne';
|
|
97
|
+
EntityRelations.HAS_MANY = 'hasMany';
|
|
98
|
+
EntityRelations.HAS_MANY_THROUGH = 'hasManyThrough';
|
|
99
|
+
EntityRelations.HAS_MANY_POLYMORPHIC = 'hasManyPolymorphic';
|
|
100
|
+
EntityRelations.SCHEME_SET = new Set([
|
|
101
|
+
_c.BELONGS_TO,
|
|
102
|
+
_c.HAS_ONE,
|
|
103
|
+
_c.HAS_MANY,
|
|
104
|
+
_c.HAS_MANY_THROUGH,
|
|
105
|
+
_c.HAS_MANY_POLYMORPHIC,
|
|
106
|
+
]);
|
|
101
107
|
class ConfigurationDataTypes {
|
|
102
|
-
static NUMBER = 'NUMBER';
|
|
103
|
-
static TEXT = 'TEXT';
|
|
104
|
-
static BYTE = 'BYTE';
|
|
105
|
-
static JSON = 'JSON';
|
|
106
|
-
static BOOLEAN = 'BOOLEAN';
|
|
107
|
-
static SCHEME_SET = new Set([
|
|
108
|
-
this.NUMBER,
|
|
109
|
-
this.TEXT,
|
|
110
|
-
this.BYTE,
|
|
111
|
-
this.JSON,
|
|
112
|
-
this.BOOLEAN,
|
|
113
|
-
]);
|
|
114
108
|
static isValid(orgType) {
|
|
115
109
|
return this.SCHEME_SET.has(orgType);
|
|
116
110
|
}
|
|
117
111
|
}
|
|
118
112
|
exports.ConfigurationDataTypes = ConfigurationDataTypes;
|
|
113
|
+
_d = ConfigurationDataTypes;
|
|
114
|
+
ConfigurationDataTypes.NUMBER = 'NUMBER';
|
|
115
|
+
ConfigurationDataTypes.TEXT = 'TEXT';
|
|
116
|
+
ConfigurationDataTypes.BYTE = 'BYTE';
|
|
117
|
+
ConfigurationDataTypes.JSON = 'JSON';
|
|
118
|
+
ConfigurationDataTypes.BOOLEAN = 'BOOLEAN';
|
|
119
|
+
ConfigurationDataTypes.SCHEME_SET = new Set([
|
|
120
|
+
_d.NUMBER,
|
|
121
|
+
_d.TEXT,
|
|
122
|
+
_d.BYTE,
|
|
123
|
+
_d.JSON,
|
|
124
|
+
_d.BOOLEAN,
|
|
125
|
+
]);
|
|
119
126
|
class UserTypes {
|
|
120
|
-
static SYSTEM = 'SYSTEM';
|
|
121
|
-
static LINKED = 'LINKED';
|
|
122
|
-
static SCHEME_SET = new Set([this.SYSTEM, this.LINKED]);
|
|
123
127
|
static isValid(orgType) {
|
|
124
128
|
return this.SCHEME_SET.has(orgType);
|
|
125
129
|
}
|
|
126
130
|
}
|
|
127
131
|
exports.UserTypes = UserTypes;
|
|
132
|
+
_e = UserTypes;
|
|
133
|
+
UserTypes.SYSTEM = 'SYSTEM';
|
|
134
|
+
UserTypes.LINKED = 'LINKED';
|
|
135
|
+
UserTypes.SCHEME_SET = new Set([_e.SYSTEM, _e.LINKED]);
|
|
128
136
|
class MimeTypes {
|
|
129
|
-
static UNKNOWN = 'unknown';
|
|
130
|
-
static IMAGE = 'image';
|
|
131
|
-
static VIDEO = 'video';
|
|
132
|
-
static TEXT = 'text';
|
|
133
137
|
}
|
|
134
138
|
exports.MimeTypes = MimeTypes;
|
|
139
|
+
MimeTypes.UNKNOWN = 'unknown';
|
|
140
|
+
MimeTypes.IMAGE = 'image';
|
|
141
|
+
MimeTypes.VIDEO = 'video';
|
|
142
|
+
MimeTypes.TEXT = 'text';
|
|
@@ -2,33 +2,33 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnvironmentKeys = exports.Environments = void 0;
|
|
4
4
|
class Environments {
|
|
5
|
-
static LOCAL = 'local';
|
|
6
|
-
static DEBUG = 'debug';
|
|
7
|
-
static DEVELOPMENT = 'development';
|
|
8
|
-
static ALPHA = 'alpha';
|
|
9
|
-
static BETA = 'beta';
|
|
10
|
-
static STAGING = 'staging';
|
|
11
|
-
static PRODUCTION = 'production';
|
|
12
5
|
}
|
|
13
6
|
exports.Environments = Environments;
|
|
7
|
+
Environments.LOCAL = 'local';
|
|
8
|
+
Environments.DEBUG = 'debug';
|
|
9
|
+
Environments.DEVELOPMENT = 'development';
|
|
10
|
+
Environments.ALPHA = 'alpha';
|
|
11
|
+
Environments.BETA = 'beta';
|
|
12
|
+
Environments.STAGING = 'staging';
|
|
13
|
+
Environments.PRODUCTION = 'production';
|
|
14
14
|
class EnvironmentKeys {
|
|
15
|
-
static APP_ENV_APPLICATION_NAME = 'APP_ENV_APPLICATION_NAME';
|
|
16
|
-
static APP_ENV_APPLICATION_TIMEZONE = 'APP_ENV_APPLICATION_TIMEZONE';
|
|
17
|
-
static APP_ENV_APPLICATION_SECRET = 'APP_ENV_APPLICATION_SECRET';
|
|
18
|
-
static APP_ENV_LOGGER_FOLDER_PATH = 'APP_ENV_LOGGER_FOLDER_PATH';
|
|
19
|
-
static APP_ENV_APPLICATION_ROLES = 'APP_ENV_APPLICATION_ROLES';
|
|
20
|
-
static APP_ENV_APPLICATION_DS_MIGRATION = 'APP_ENV_APPLICATION_DS_MIGRATION';
|
|
21
|
-
static APP_ENV_APPLICATION_DS_AUTHORIZE = 'APP_ENV_APPLICATION_DS_AUTHORIZE';
|
|
22
|
-
static APP_ENV_APPLICATION_DS_OAUTH2 = 'APP_ENV_APPLICATION_DS_OAUTH2';
|
|
23
|
-
static APP_ENV_OAUTH2_VIEW_FOLDER = 'APP_ENV_OAUTH2_VIEW_FOLDER';
|
|
24
|
-
static APP_ENV_SERVER_HOST = 'APP_ENV_SERVER_HOST';
|
|
25
|
-
static APP_ENV_SERVER_PORT = 'APP_ENV_SERVER_PORT';
|
|
26
|
-
static APP_ENV_SERVER_BASE_PATH = 'APP_ENV_SERVER_BASE_PATH';
|
|
27
|
-
static APP_ENV_DATASOURCE_NAME = 'APP_ENV_DATASOURCE_NAME';
|
|
28
|
-
static APP_ENV_POSTGRES_HOST = 'APP_ENV_POSTGRES_HOST';
|
|
29
|
-
static APP_ENV_POSTGRES_PORT = 'APP_ENV_POSTGRES_PORT';
|
|
30
|
-
static APP_ENV_POSTGRES_USERNAME = 'APP_ENV_POSTGRES_USERNAME';
|
|
31
|
-
static APP_ENV_POSTGRES_PASSWORD = 'APP_ENV_POSTGRES_PASSWORD';
|
|
32
|
-
static APP_ENV_POSTGRES_DATABASE = 'APP_ENV_POSTGRES_DATABASE';
|
|
33
15
|
}
|
|
34
16
|
exports.EnvironmentKeys = EnvironmentKeys;
|
|
17
|
+
EnvironmentKeys.APP_ENV_APPLICATION_NAME = 'APP_ENV_APPLICATION_NAME';
|
|
18
|
+
EnvironmentKeys.APP_ENV_APPLICATION_TIMEZONE = 'APP_ENV_APPLICATION_TIMEZONE';
|
|
19
|
+
EnvironmentKeys.APP_ENV_APPLICATION_SECRET = 'APP_ENV_APPLICATION_SECRET';
|
|
20
|
+
EnvironmentKeys.APP_ENV_LOGGER_FOLDER_PATH = 'APP_ENV_LOGGER_FOLDER_PATH';
|
|
21
|
+
EnvironmentKeys.APP_ENV_APPLICATION_ROLES = 'APP_ENV_APPLICATION_ROLES';
|
|
22
|
+
EnvironmentKeys.APP_ENV_APPLICATION_DS_MIGRATION = 'APP_ENV_APPLICATION_DS_MIGRATION';
|
|
23
|
+
EnvironmentKeys.APP_ENV_APPLICATION_DS_AUTHORIZE = 'APP_ENV_APPLICATION_DS_AUTHORIZE';
|
|
24
|
+
EnvironmentKeys.APP_ENV_APPLICATION_DS_OAUTH2 = 'APP_ENV_APPLICATION_DS_OAUTH2';
|
|
25
|
+
EnvironmentKeys.APP_ENV_OAUTH2_VIEW_FOLDER = 'APP_ENV_OAUTH2_VIEW_FOLDER';
|
|
26
|
+
EnvironmentKeys.APP_ENV_SERVER_HOST = 'APP_ENV_SERVER_HOST';
|
|
27
|
+
EnvironmentKeys.APP_ENV_SERVER_PORT = 'APP_ENV_SERVER_PORT';
|
|
28
|
+
EnvironmentKeys.APP_ENV_SERVER_BASE_PATH = 'APP_ENV_SERVER_BASE_PATH';
|
|
29
|
+
EnvironmentKeys.APP_ENV_DATASOURCE_NAME = 'APP_ENV_DATASOURCE_NAME';
|
|
30
|
+
EnvironmentKeys.APP_ENV_POSTGRES_HOST = 'APP_ENV_POSTGRES_HOST';
|
|
31
|
+
EnvironmentKeys.APP_ENV_POSTGRES_PORT = 'APP_ENV_POSTGRES_PORT';
|
|
32
|
+
EnvironmentKeys.APP_ENV_POSTGRES_USERNAME = 'APP_ENV_POSTGRES_USERNAME';
|
|
33
|
+
EnvironmentKeys.APP_ENV_POSTGRES_PASSWORD = 'APP_ENV_POSTGRES_PASSWORD';
|
|
34
|
+
EnvironmentKeys.APP_ENV_POSTGRES_DATABASE = 'APP_ENV_POSTGRES_DATABASE';
|
package/dist/common/keys.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BindingKeys = void 0;
|
|
4
4
|
class BindingKeys {
|
|
5
|
-
static APPLICATION_ENVIRONMENTS = '@qt/application/environments';
|
|
6
|
-
static APPLICATION_MIDDLEWARE_OPTIONS = '@app/application/middleware_options';
|
|
7
5
|
}
|
|
8
6
|
exports.BindingKeys = BindingKeys;
|
|
7
|
+
BindingKeys.APPLICATION_ENVIRONMENTS = '@qt/application/environments';
|
|
8
|
+
BindingKeys.APPLICATION_MIDDLEWARE_OPTIONS = '@app/application/middleware_options';
|
package/dist/common/statuses.js
CHANGED
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a, _b;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.OAuth2TokenStatuses = exports.RoleStatuses = exports.UserStatuses = exports.CommonStatuses = exports.MigrationStatuses = exports.Statuses = void 0;
|
|
4
5
|
class Statuses {
|
|
5
|
-
static UNKNOWN = '000_UNKNOWN';
|
|
6
|
-
static ACTIVATED = '100_ACTIVATED';
|
|
7
|
-
static DEACTIVATED = '101_DEACTIVATED';
|
|
8
|
-
static BLOCKED = '102_BLOCKED';
|
|
9
|
-
static DRAFT = '103_DRAFT';
|
|
10
|
-
static ARCHIVE = '104_ARCHIVE';
|
|
11
|
-
static SUCCESS = '105_SUCCESS';
|
|
12
|
-
static FAIL = '106_FAIL';
|
|
13
|
-
static SENT = '107_SENT';
|
|
14
6
|
}
|
|
15
7
|
exports.Statuses = Statuses;
|
|
8
|
+
Statuses.UNKNOWN = '000_UNKNOWN';
|
|
9
|
+
Statuses.ACTIVATED = '100_ACTIVATED';
|
|
10
|
+
Statuses.DEACTIVATED = '101_DEACTIVATED';
|
|
11
|
+
Statuses.BLOCKED = '102_BLOCKED';
|
|
12
|
+
Statuses.DRAFT = '103_DRAFT';
|
|
13
|
+
Statuses.ARCHIVE = '104_ARCHIVE';
|
|
14
|
+
Statuses.SUCCESS = '105_SUCCESS';
|
|
15
|
+
Statuses.FAIL = '106_FAIL';
|
|
16
|
+
Statuses.SENT = '107_SENT';
|
|
16
17
|
class MigrationStatuses {
|
|
17
|
-
static UNKNOWN = Statuses.UNKNOWN;
|
|
18
|
-
static SUCCESS = Statuses.SUCCESS;
|
|
19
|
-
static FAIL = Statuses.FAIL;
|
|
20
18
|
}
|
|
21
19
|
exports.MigrationStatuses = MigrationStatuses;
|
|
20
|
+
MigrationStatuses.UNKNOWN = Statuses.UNKNOWN;
|
|
21
|
+
MigrationStatuses.SUCCESS = Statuses.SUCCESS;
|
|
22
|
+
MigrationStatuses.FAIL = Statuses.FAIL;
|
|
22
23
|
class CommonStatuses {
|
|
23
|
-
static UNKNOWN = Statuses.UNKNOWN;
|
|
24
|
-
static ACTIVATED = Statuses.ACTIVATED;
|
|
25
|
-
static DEACTIVATED = Statuses.DEACTIVATED;
|
|
26
|
-
static BLOCKED = Statuses.BLOCKED;
|
|
27
|
-
static ARCHIVE = Statuses.ARCHIVE;
|
|
28
|
-
static SCHEME_SET = new Set([
|
|
29
|
-
this.UNKNOWN,
|
|
30
|
-
this.ACTIVATED,
|
|
31
|
-
this.DEACTIVATED,
|
|
32
|
-
this.BLOCKED,
|
|
33
|
-
this.ARCHIVE,
|
|
34
|
-
]);
|
|
35
24
|
static isValid(scheme) {
|
|
36
25
|
return this.SCHEME_SET.has(scheme);
|
|
37
26
|
}
|
|
38
27
|
}
|
|
39
28
|
exports.CommonStatuses = CommonStatuses;
|
|
29
|
+
_a = CommonStatuses;
|
|
30
|
+
CommonStatuses.UNKNOWN = Statuses.UNKNOWN;
|
|
31
|
+
CommonStatuses.ACTIVATED = Statuses.ACTIVATED;
|
|
32
|
+
CommonStatuses.DEACTIVATED = Statuses.DEACTIVATED;
|
|
33
|
+
CommonStatuses.BLOCKED = Statuses.BLOCKED;
|
|
34
|
+
CommonStatuses.ARCHIVE = Statuses.ARCHIVE;
|
|
35
|
+
CommonStatuses.SCHEME_SET = new Set([
|
|
36
|
+
_a.UNKNOWN,
|
|
37
|
+
_a.ACTIVATED,
|
|
38
|
+
_a.DEACTIVATED,
|
|
39
|
+
_a.BLOCKED,
|
|
40
|
+
_a.ARCHIVE,
|
|
41
|
+
]);
|
|
40
42
|
class UserStatuses extends CommonStatuses {
|
|
41
43
|
}
|
|
42
44
|
exports.UserStatuses = UserStatuses;
|
|
@@ -44,12 +46,13 @@ class RoleStatuses extends CommonStatuses {
|
|
|
44
46
|
}
|
|
45
47
|
exports.RoleStatuses = RoleStatuses;
|
|
46
48
|
class OAuth2TokenStatuses {
|
|
47
|
-
static UNKNOWN = Statuses.UNKNOWN;
|
|
48
|
-
static ACTIVATED = Statuses.ACTIVATED;
|
|
49
|
-
static DEACTIVATED = Statuses.DEACTIVATED;
|
|
50
|
-
static SCHEME_SET = new Set([this.ACTIVATED, this.DEACTIVATED]);
|
|
51
49
|
static isValid(scheme) {
|
|
52
50
|
return this.SCHEME_SET.has(scheme);
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
53
|
exports.OAuth2TokenStatuses = OAuth2TokenStatuses;
|
|
54
|
+
_b = OAuth2TokenStatuses;
|
|
55
|
+
OAuth2TokenStatuses.UNKNOWN = Statuses.UNKNOWN;
|
|
56
|
+
OAuth2TokenStatuses.ACTIVATED = Statuses.ACTIVATED;
|
|
57
|
+
OAuth2TokenStatuses.DEACTIVATED = Statuses.DEACTIVATED;
|
|
58
|
+
OAuth2TokenStatuses.SCHEME_SET = new Set([_b.ACTIVATED, _b.DEACTIVATED]);
|
package/dist/common/types.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export type ValueOrPromise<T> = T | Promise<T>;
|
|
|
15
15
|
export type ValueOf<T> = T[keyof T];
|
|
16
16
|
export type ValueOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
17
17
|
export type ValueOptionalExcept<T, K extends keyof T> = Pick<T, K> & Partial<Omit<T, K>>;
|
|
18
|
+
/**
|
|
19
|
+
* Alias for {@link ValueOf<T>}
|
|
20
|
+
*/
|
|
18
21
|
export type ClassProps<T> = ValueOf<T>;
|
|
19
22
|
export type ClassType<T> = Function & {
|
|
20
23
|
prototype: T;
|
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AuthenticationTokenTypes = exports.Authentication = void 0;
|
|
4
4
|
class Authentication {
|
|
5
|
-
static ACCESS_TOKEN_SECRET = 'token.secret';
|
|
6
|
-
static ACCESS_TOKEN_EXPIRES_IN = 86400;
|
|
7
|
-
static REFRESH_TOKEN_SECRET = 'refresh.secret';
|
|
8
|
-
static REFRESH_TOKEN_EXPIRES_IN = 86400;
|
|
9
|
-
static TYPE_BASIC = 'Basic';
|
|
10
|
-
static TYPE_BEARER = 'Bearer';
|
|
11
|
-
static STRATEGY_BASIC = 'basic';
|
|
12
|
-
static STRATEGY_JWT = 'jwt';
|
|
13
5
|
}
|
|
14
6
|
exports.Authentication = Authentication;
|
|
7
|
+
Authentication.ACCESS_TOKEN_SECRET = 'token.secret';
|
|
8
|
+
Authentication.ACCESS_TOKEN_EXPIRES_IN = 86400;
|
|
9
|
+
Authentication.REFRESH_TOKEN_SECRET = 'refresh.secret';
|
|
10
|
+
Authentication.REFRESH_TOKEN_EXPIRES_IN = 86400;
|
|
11
|
+
// Jwt
|
|
12
|
+
Authentication.TYPE_BASIC = 'Basic';
|
|
13
|
+
Authentication.TYPE_BEARER = 'Bearer';
|
|
14
|
+
// Strategy
|
|
15
|
+
Authentication.STRATEGY_BASIC = 'basic';
|
|
16
|
+
Authentication.STRATEGY_JWT = 'jwt';
|
|
15
17
|
class AuthenticationTokenTypes {
|
|
16
|
-
static TYPE_AUTHORIZATION_CODE = '000_AUTHORIZATION_CODE';
|
|
17
|
-
static TYPE_ACCESS_TOKEN = '100_ACCESS_TOKEN';
|
|
18
|
-
static TYPE_REFRESH_TOKEN = '200_REFRESH_TOKEN';
|
|
19
18
|
}
|
|
20
19
|
exports.AuthenticationTokenTypes = AuthenticationTokenTypes;
|
|
20
|
+
AuthenticationTokenTypes.TYPE_AUTHORIZATION_CODE = '000_AUTHORIZATION_CODE';
|
|
21
|
+
AuthenticationTokenTypes.TYPE_ACCESS_TOKEN = '100_ACCESS_TOKEN';
|
|
22
|
+
AuthenticationTokenTypes.TYPE_REFRESH_TOKEN = '200_REFRESH_TOKEN';
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AuthenticateKeys = void 0;
|
|
4
4
|
class AuthenticateKeys {
|
|
5
|
-
static APPLICATION_SECRET = '@app/authenticate/application_secret';
|
|
6
|
-
static TOKEN_OPTIONS = '@app/authenticate/token_options';
|
|
7
|
-
static REST_OPTIONS = '@app/authenticate/rest_options';
|
|
8
|
-
static ALWAYS_ALLOW_PATHS = '@app/authenticate/always_allow_paths';
|
|
9
|
-
static GET_TOKEN_EXPIRES_FN = '@app/authenticate/get_token_expires_fn';
|
|
10
|
-
static OAUTH2_HANDLER = '@app/authenticate/oauth2_handler';
|
|
11
|
-
static OAUTH2_OPTIONS = '@app/authenticate/oauth2_options';
|
|
12
5
|
}
|
|
13
6
|
exports.AuthenticateKeys = AuthenticateKeys;
|
|
7
|
+
AuthenticateKeys.APPLICATION_SECRET = '@app/authenticate/application_secret';
|
|
8
|
+
AuthenticateKeys.TOKEN_OPTIONS = '@app/authenticate/token_options';
|
|
9
|
+
AuthenticateKeys.REST_OPTIONS = '@app/authenticate/rest_options';
|
|
10
|
+
AuthenticateKeys.ALWAYS_ALLOW_PATHS = '@app/authenticate/always_allow_paths';
|
|
11
|
+
AuthenticateKeys.GET_TOKEN_EXPIRES_FN = '@app/authenticate/get_token_expires_fn';
|
|
12
|
+
AuthenticateKeys.OAUTH2_HANDLER = '@app/authenticate/oauth2_handler';
|
|
13
|
+
AuthenticateKeys.OAUTH2_OPTIONS = '@app/authenticate/oauth2_options';
|
|
@@ -11,10 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.OAuth2Request = exports.SignUpRequest = exports.ChangePasswordRequest = exports.SignInRequest = void 0;
|
|
13
13
|
const repository_1 = require("@loopback/repository");
|
|
14
|
+
// ----------------------------------------------------------------------------------------------------------------------------------------
|
|
14
15
|
let SignInRequest = class SignInRequest {
|
|
15
|
-
identifier;
|
|
16
|
-
credential;
|
|
17
|
-
clientId;
|
|
18
16
|
};
|
|
19
17
|
exports.SignInRequest = SignInRequest;
|
|
20
18
|
__decorate([
|
|
@@ -59,9 +57,6 @@ exports.SignInRequest = SignInRequest = __decorate([
|
|
|
59
57
|
})
|
|
60
58
|
], SignInRequest);
|
|
61
59
|
let ChangePasswordRequest = class ChangePasswordRequest {
|
|
62
|
-
oldCredential;
|
|
63
|
-
newCredential;
|
|
64
|
-
userId;
|
|
65
60
|
};
|
|
66
61
|
exports.ChangePasswordRequest = ChangePasswordRequest;
|
|
67
62
|
__decorate([
|
|
@@ -96,9 +91,8 @@ exports.ChangePasswordRequest = ChangePasswordRequest = __decorate([
|
|
|
96
91
|
},
|
|
97
92
|
})
|
|
98
93
|
], ChangePasswordRequest);
|
|
94
|
+
// -------------------------------------------------------------------
|
|
99
95
|
let SignUpRequest = class SignUpRequest {
|
|
100
|
-
username;
|
|
101
|
-
credential;
|
|
102
96
|
};
|
|
103
97
|
exports.SignUpRequest = SignUpRequest;
|
|
104
98
|
__decorate([
|
|
@@ -118,10 +112,8 @@ exports.SignUpRequest = SignUpRequest = __decorate([
|
|
|
118
112
|
},
|
|
119
113
|
})
|
|
120
114
|
], SignUpRequest);
|
|
115
|
+
// -------------------------------------------------------------------
|
|
121
116
|
let OAuth2Request = class OAuth2Request {
|
|
122
|
-
clientId;
|
|
123
|
-
clientSecret;
|
|
124
|
-
redirectUrl;
|
|
125
117
|
};
|
|
126
118
|
exports.OAuth2Request = OAuth2Request;
|
|
127
119
|
__decorate([
|
|
@@ -28,27 +28,26 @@ const oauth2_handlers_1 = require("./oauth2-handlers");
|
|
|
28
28
|
const repositories_1 = require("./repositories");
|
|
29
29
|
const services_1 = require("./services");
|
|
30
30
|
let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponent extends base_component_1.BaseComponent {
|
|
31
|
-
application;
|
|
32
|
-
bindings = [
|
|
33
|
-
core_1.Binding.bind(common_2.AuthenticateKeys.APPLICATION_SECRET).to(common_1.App.APPLICATION_SECRET),
|
|
34
|
-
core_1.Binding.bind(common_2.AuthenticateKeys.TOKEN_OPTIONS).to({
|
|
35
|
-
tokenSecret: common_2.Authentication.ACCESS_TOKEN_SECRET,
|
|
36
|
-
tokenExpiresIn: common_2.Authentication.ACCESS_TOKEN_EXPIRES_IN,
|
|
37
|
-
refreshSecret: common_2.Authentication.REFRESH_TOKEN_SECRET,
|
|
38
|
-
refreshExpiresIn: common_2.Authentication.REFRESH_TOKEN_EXPIRES_IN,
|
|
39
|
-
}),
|
|
40
|
-
core_1.Binding.bind(common_2.AuthenticateKeys.REST_OPTIONS).to({
|
|
41
|
-
restPath: '/auth',
|
|
42
|
-
serviceKey: 'services.UserService',
|
|
43
|
-
requireAuthenticatedSignUp: false,
|
|
44
|
-
signInRequest: common_2.SignInRequest,
|
|
45
|
-
signUpRequest: common_2.SignUpRequest,
|
|
46
|
-
changePasswordRequest: common_2.ChangePasswordRequest,
|
|
47
|
-
}),
|
|
48
|
-
];
|
|
49
31
|
constructor(application) {
|
|
50
32
|
super({ scope: AuthenticateComponent_1.name });
|
|
51
33
|
this.application = application;
|
|
34
|
+
this.bindings = [
|
|
35
|
+
core_1.Binding.bind(common_2.AuthenticateKeys.APPLICATION_SECRET).to(common_1.App.APPLICATION_SECRET),
|
|
36
|
+
core_1.Binding.bind(common_2.AuthenticateKeys.TOKEN_OPTIONS).to({
|
|
37
|
+
tokenSecret: common_2.Authentication.ACCESS_TOKEN_SECRET,
|
|
38
|
+
tokenExpiresIn: common_2.Authentication.ACCESS_TOKEN_EXPIRES_IN,
|
|
39
|
+
refreshSecret: common_2.Authentication.REFRESH_TOKEN_SECRET,
|
|
40
|
+
refreshExpiresIn: common_2.Authentication.REFRESH_TOKEN_EXPIRES_IN,
|
|
41
|
+
}),
|
|
42
|
+
core_1.Binding.bind(common_2.AuthenticateKeys.REST_OPTIONS).to({
|
|
43
|
+
restPath: '/auth',
|
|
44
|
+
serviceKey: 'services.UserService',
|
|
45
|
+
requireAuthenticatedSignUp: false,
|
|
46
|
+
signInRequest: common_2.SignInRequest,
|
|
47
|
+
signUpRequest: common_2.SignUpRequest,
|
|
48
|
+
changePasswordRequest: common_2.ChangePasswordRequest,
|
|
49
|
+
}),
|
|
50
|
+
];
|
|
52
51
|
this.binding();
|
|
53
52
|
}
|
|
54
53
|
defineMiddlewares() {
|
|
@@ -68,6 +67,7 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
|
|
|
68
67
|
this.application.controller(authenticationController);
|
|
69
68
|
}
|
|
70
69
|
defineOAuth2() {
|
|
70
|
+
var _a, _b;
|
|
71
71
|
if (!this.application.isBound(common_2.AuthenticateKeys.OAUTH2_OPTIONS)) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
@@ -89,13 +89,21 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
|
|
|
89
89
|
`${1 * 24 * 60 * 60}`),
|
|
90
90
|
},
|
|
91
91
|
}));
|
|
92
|
+
/* const strategyName = '<some_name>';
|
|
93
|
+
const remoteOAuth2Strategy = defineOAuth2Strategy({
|
|
94
|
+
name: strategyName,
|
|
95
|
+
baseURL: 'https://domain.com',
|
|
96
|
+
authPath: '/auth/who-am-i',
|
|
97
|
+
});
|
|
98
|
+
registerAuthenticationStrategy(this.application, remoteOAuth2Strategy);
|
|
99
|
+
this.logger.info('[defineOAuth2] Registered auth strategy with name: %s', strategyName); */
|
|
92
100
|
this.application.repository(repositories_1.OAuth2ScopeRepository);
|
|
93
101
|
this.application.repository(repositories_1.OAuth2TokenRepository);
|
|
94
102
|
this.application.repository(repositories_1.OAuth2ClientRepository);
|
|
95
103
|
this.application.service(services_1.OAuth2Service);
|
|
96
104
|
const oauth2Controller = (0, controllers_1.defineOAuth2Controller)(oauth2Options.restOptions);
|
|
97
105
|
this.application.controller(oauth2Controller);
|
|
98
|
-
this.application.mountExpressRouter(oauth2Options.restOptions
|
|
106
|
+
this.application.mountExpressRouter((_b = (_a = oauth2Options.restOptions) === null || _a === void 0 ? void 0 : _a.restPath) !== null && _b !== void 0 ? _b : '/oauth2', controllers_1.DefaultOAuth2ExpressServer.getInstance({
|
|
99
107
|
context: this.application,
|
|
100
108
|
viewFolder,
|
|
101
109
|
authServiceKey: handler.authServiceKey,
|
|
@@ -114,7 +122,7 @@ let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponen
|
|
|
114
122
|
this.application.bind(authentication_jwt_1.RefreshTokenServiceBindings.REFRESH_SECRET).to(refreshSecret);
|
|
115
123
|
this.application
|
|
116
124
|
.bind(authentication_jwt_1.RefreshTokenServiceBindings.REFRESH_EXPIRES_IN)
|
|
117
|
-
.to(refreshExpiresIn
|
|
125
|
+
.to(refreshExpiresIn === null || refreshExpiresIn === void 0 ? void 0 : refreshExpiresIn.toString());
|
|
118
126
|
this.defineOAuth2();
|
|
119
127
|
}
|
|
120
128
|
binding() {
|
|
@@ -21,27 +21,29 @@ const rest_1 = require("@loopback/rest");
|
|
|
21
21
|
const security_1 = require("@loopback/security");
|
|
22
22
|
const common_1 = require("../common");
|
|
23
23
|
const defineAuthController = (opts) => {
|
|
24
|
+
var _a, _b, _c;
|
|
24
25
|
var BaseAuthController_1;
|
|
25
26
|
const { restPath = '/auth', requireAuthenticatedSignUp = false, serviceKey = 'services.UserService', } = opts;
|
|
26
27
|
let BaseAuthController = BaseAuthController_1 = class BaseAuthController extends controllers_1.BaseController {
|
|
27
|
-
requestContext;
|
|
28
|
-
service;
|
|
29
|
-
getCurrentUser;
|
|
30
28
|
constructor(requestContext, authService, getCurrentUser) {
|
|
31
29
|
super({ scope: BaseAuthController_1.name });
|
|
32
30
|
this.service = authService;
|
|
33
31
|
this.getCurrentUser = getCurrentUser;
|
|
34
32
|
this.requestContext = requestContext;
|
|
35
33
|
}
|
|
34
|
+
// ------------------------------------------------------------------------------
|
|
36
35
|
whoami() {
|
|
37
36
|
return this.getCurrentUser();
|
|
38
37
|
}
|
|
38
|
+
// ------------------------------------------------------------------------------
|
|
39
39
|
signIn(payload) {
|
|
40
|
-
return this.service.signIn({
|
|
40
|
+
return this.service.signIn(Object.assign(Object.assign({}, payload), { requestContext: this.requestContext }));
|
|
41
41
|
}
|
|
42
|
+
// ------------------------------------------------------------------------------
|
|
42
43
|
signUp(payload) {
|
|
43
|
-
return this.service.signUp({
|
|
44
|
+
return this.service.signUp(Object.assign(Object.assign({}, payload), { requestContext: this.requestContext }));
|
|
44
45
|
}
|
|
46
|
+
//-------------------------------------------------------------------------------
|
|
45
47
|
changePassword(payload) {
|
|
46
48
|
return new Promise((resolve, reject) => {
|
|
47
49
|
this.getCurrentUser()
|
|
@@ -54,11 +56,7 @@ const defineAuthController = (opts) => {
|
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
58
|
this.service
|
|
57
|
-
.changePassword({
|
|
58
|
-
...payload,
|
|
59
|
-
userId: currentUser.userId,
|
|
60
|
-
requestContext: this.requestContext,
|
|
61
|
-
})
|
|
59
|
+
.changePassword(Object.assign(Object.assign({}, payload), { userId: currentUser.userId, requestContext: this.requestContext }))
|
|
62
60
|
.then(resolve)
|
|
63
61
|
.catch(reject);
|
|
64
62
|
})
|
|
@@ -79,7 +77,7 @@ const defineAuthController = (opts) => {
|
|
|
79
77
|
required: true,
|
|
80
78
|
content: {
|
|
81
79
|
'application/json': {
|
|
82
|
-
schema: (0, utilities_1.getSchemaObject)(opts
|
|
80
|
+
schema: (0, utilities_1.getSchemaObject)((_a = opts === null || opts === void 0 ? void 0 : opts.signInRequest) !== null && _a !== void 0 ? _a : common_1.SignInRequest),
|
|
83
81
|
},
|
|
84
82
|
},
|
|
85
83
|
})),
|
|
@@ -93,7 +91,7 @@ const defineAuthController = (opts) => {
|
|
|
93
91
|
__param(0, (0, rest_1.requestBody)({
|
|
94
92
|
content: {
|
|
95
93
|
'application/json': {
|
|
96
|
-
schema: (0, utilities_1.getSchemaObject)(opts
|
|
94
|
+
schema: (0, utilities_1.getSchemaObject)((_b = opts === null || opts === void 0 ? void 0 : opts.signUpRequest) !== null && _b !== void 0 ? _b : common_1.SignUpRequest),
|
|
97
95
|
},
|
|
98
96
|
},
|
|
99
97
|
})),
|
|
@@ -108,7 +106,7 @@ const defineAuthController = (opts) => {
|
|
|
108
106
|
required: true,
|
|
109
107
|
content: {
|
|
110
108
|
'application/json': {
|
|
111
|
-
schema: (0, utilities_1.getSchemaObject)(opts
|
|
109
|
+
schema: (0, utilities_1.getSchemaObject)((_c = opts === null || opts === void 0 ? void 0 : opts.changePasswordRequest) !== null && _c !== void 0 ? _c : common_1.ChangePasswordRequest),
|
|
112
110
|
},
|
|
113
111
|
},
|
|
114
112
|
})),
|