@node-c/domain-iam 1.0.0-alpha3
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/LICENSE +1 -0
- package/README.md +4 -0
- package/dist/common/definitions/common.constants.d.ts +3 -0
- package/dist/common/definitions/common.constants.js +8 -0
- package/dist/common/definitions/common.constants.js.map +1 -0
- package/dist/common/definitions/index.d.ts +1 -0
- package/dist/common/definitions/index.js +18 -0
- package/dist/common/definitions/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/module/iam.definitions.d.ts +13 -0
- package/dist/module/iam.definitions.js +3 -0
- package/dist/module/iam.definitions.js.map +1 -0
- package/dist/module/iam.module.d.ts +5 -0
- package/dist/module/iam.module.js +28 -0
- package/dist/module/iam.module.js.map +1 -0
- package/dist/module/index.d.ts +2 -0
- package/dist/module/index.js +19 -0
- package/dist/module/index.js.map +1 -0
- package/dist/services/authentication/iam.authentication.definitions.d.ts +20 -0
- package/dist/services/authentication/iam.authentication.definitions.js +12 -0
- package/dist/services/authentication/iam.authentication.definitions.js.map +1 -0
- package/dist/services/authentication/iam.authentication.service.d.ts +8 -0
- package/dist/services/authentication/iam.authentication.service.js +26 -0
- package/dist/services/authentication/iam.authentication.service.js.map +1 -0
- package/dist/services/authentication/index.d.ts +2 -0
- package/dist/services/authentication/index.js +19 -0
- package/dist/services/authentication/index.js.map +1 -0
- package/dist/services/authenticationLocal/iam.authenticationLocal.definitions.d.ts +11 -0
- package/dist/services/authenticationLocal/iam.authenticationLocal.definitions.js +3 -0
- package/dist/services/authenticationLocal/iam.authenticationLocal.definitions.js.map +1 -0
- package/dist/services/authenticationLocal/iam.authenticationLocal.service.d.ts +10 -0
- package/dist/services/authenticationLocal/iam.authenticationLocal.service.js +60 -0
- package/dist/services/authenticationLocal/iam.authenticationLocal.service.js.map +1 -0
- package/dist/services/authenticationLocal/index.d.ts +2 -0
- package/dist/services/authenticationLocal/index.js +19 -0
- package/dist/services/authenticationLocal/index.js.map +1 -0
- package/dist/services/authorization/iam.authorization.definitions.d.ts +37 -0
- package/dist/services/authorization/iam.authorization.definitions.js +3 -0
- package/dist/services/authorization/iam.authorization.definitions.js.map +1 -0
- package/dist/services/authorization/iam.authorization.service.d.ts +16 -0
- package/dist/services/authorization/iam.authorization.service.js +222 -0
- package/dist/services/authorization/iam.authorization.service.js.map +1 -0
- package/dist/services/authorization/index.d.ts +2 -0
- package/dist/services/authorization/index.js +19 -0
- package/dist/services/authorization/index.js.map +1 -0
- package/dist/services/index.d.ts +5 -0
- package/dist/services/index.js +22 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/tokenManager/iam.tokenManager.definitions.d.ts +34 -0
- package/dist/services/tokenManager/iam.tokenManager.definitions.js +9 -0
- package/dist/services/tokenManager/iam.tokenManager.definitions.js.map +1 -0
- package/dist/services/tokenManager/iam.tokenManager.service.d.ts +14 -0
- package/dist/services/tokenManager/iam.tokenManager.service.js +202 -0
- package/dist/services/tokenManager/iam.tokenManager.service.js.map +1 -0
- package/dist/services/tokenManager/index.d.ts +2 -0
- package/dist/services/tokenManager/index.js +19 -0
- package/dist/services/tokenManager/index.js.map +1 -0
- package/dist/services/users/iam.users.definitions.d.ts +36 -0
- package/dist/services/users/iam.users.definitions.js +8 -0
- package/dist/services/users/iam.users.definitions.js.map +1 -0
- package/dist/services/users/iam.users.service.d.ts +14 -0
- package/dist/services/users/iam.users.service.js +77 -0
- package/dist/services/users/iam.users.service.js.map +1 -0
- package/dist/services/users/index.d.ts +2 -0
- package/dist/services/users/index.js +19 -0
- package/dist/services/users/index.js.map +1 -0
- package/package.json +25 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MIT
|
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Constants = void 0;
|
|
4
|
+
var Constants;
|
|
5
|
+
(function (Constants) {
|
|
6
|
+
Constants["DOMAIN_MODULE_NAME"] = "DOMAIN_MODULE_NAME";
|
|
7
|
+
})(Constants || (exports.Constants = Constants = {}));
|
|
8
|
+
//# sourceMappingURL=common.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.constants.js","sourceRoot":"","sources":["../../../src/common/definitions/common.constants.ts"],"names":[],"mappings":";;;AAAA,IAAY,SAGX;AAHD,WAAY,SAAS;IAEnB,sDAAyC,CAAA;AAC3C,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './common.constants';
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./common.constants"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/definitions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./common/definitions"), exports);
|
|
18
|
+
__exportStar(require("./module"), exports);
|
|
19
|
+
__exportStar(require("./services"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,2CAAyB;AACzB,6CAA2B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModuleMetadata } from '@nestjs/common';
|
|
2
|
+
import { GenericObject } from '@node-c/core';
|
|
3
|
+
export interface DomainIAMModuleOptions {
|
|
4
|
+
exports?: ModuleMetadata['exports'];
|
|
5
|
+
folderData: GenericObject<unknown>;
|
|
6
|
+
imports?: {
|
|
7
|
+
atEnd?: ModuleMetadata['imports'];
|
|
8
|
+
atStart?: ModuleMetadata['imports'];
|
|
9
|
+
};
|
|
10
|
+
moduleClass: unknown;
|
|
11
|
+
moduleName: string;
|
|
12
|
+
providers?: ModuleMetadata['providers'];
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iam.definitions.js","sourceRoot":"","sources":["../../src/module/iam.definitions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DomainIAMModule = void 0;
|
|
4
|
+
const core_1 = require("@node-c/core");
|
|
5
|
+
const definitions_1 = require("../common/definitions");
|
|
6
|
+
class DomainIAMModule {
|
|
7
|
+
static register(options) {
|
|
8
|
+
const { folderData, imports: additionalImports, moduleClass } = options;
|
|
9
|
+
const { atEnd: importsAtEnd, atStart: importsAtStart } = additionalImports || {};
|
|
10
|
+
const { modules, services } = (0, core_1.loadDynamicModules)(folderData);
|
|
11
|
+
return {
|
|
12
|
+
global: true,
|
|
13
|
+
module: moduleClass,
|
|
14
|
+
imports: [...(importsAtStart || []), ...(modules || []), ...(importsAtEnd || [])],
|
|
15
|
+
providers: [
|
|
16
|
+
{
|
|
17
|
+
provide: definitions_1.Constants.DOMAIN_MODULE_NAME,
|
|
18
|
+
useValue: options.moduleName
|
|
19
|
+
},
|
|
20
|
+
...(options.providers || []),
|
|
21
|
+
...(services || [])
|
|
22
|
+
],
|
|
23
|
+
exports: [...(services || []), ...(options.exports || [])]
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.DomainIAMModule = DomainIAMModule;
|
|
28
|
+
//# sourceMappingURL=iam.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iam.module.js","sourceRoot":"","sources":["../../src/module/iam.module.ts"],"names":[],"mappings":";;;AAEA,uCAAkD;AAIlD,uDAAkD;AAIlD,MAAa,eAAe;IAC1B,MAAM,CAAC,QAAQ,CAAC,OAA+B;QAC7C,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QACxE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,iBAAiB,IAAI,EAAE,CAAC;QACjF,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAA,yBAAkB,EAAC,UAAU,CAAC,CAAC;QAC7D,OAAO;YACL,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,WAAsC;YAC9C,OAAO,EAAE,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;YACjF,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,uBAAS,CAAC,kBAAkB;oBACrC,QAAQ,EAAE,OAAO,CAAC,UAAU;iBAC7B;gBACD,GAAG,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;gBAC5B,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC;aACpB;YACD,OAAO,EAAE,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;SAC3D,CAAC;IACJ,CAAC;CACF;AApBD,0CAoBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./iam.definitions"), exports);
|
|
18
|
+
__exportStar(require("./iam.module"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/module/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,+CAA6B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type AuthenticateUserUserData<UserFields extends object> = {
|
|
2
|
+
mfaEnabled?: boolean;
|
|
3
|
+
} & UserFields;
|
|
4
|
+
export interface AuthenticateUserAuthData {
|
|
5
|
+
mfaCode?: string;
|
|
6
|
+
mfaType?: UserMFAType;
|
|
7
|
+
userIdentifierField?: string;
|
|
8
|
+
userMFAIdentifierField?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AuthenticateUserResult {
|
|
11
|
+
valid: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare enum UserAuthKnownType {
|
|
14
|
+
Local = "local"
|
|
15
|
+
}
|
|
16
|
+
export type UserAuthType = UserAuthKnownType & string;
|
|
17
|
+
export declare enum UserMFAKnownType {
|
|
18
|
+
Local = "local"
|
|
19
|
+
}
|
|
20
|
+
export type UserMFAType = UserMFAKnownType & string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserMFAKnownType = exports.UserAuthKnownType = void 0;
|
|
4
|
+
var UserAuthKnownType;
|
|
5
|
+
(function (UserAuthKnownType) {
|
|
6
|
+
UserAuthKnownType["Local"] = "local";
|
|
7
|
+
})(UserAuthKnownType || (exports.UserAuthKnownType = UserAuthKnownType = {}));
|
|
8
|
+
var UserMFAKnownType;
|
|
9
|
+
(function (UserMFAKnownType) {
|
|
10
|
+
UserMFAKnownType["Local"] = "local";
|
|
11
|
+
})(UserMFAKnownType || (exports.UserMFAKnownType = UserMFAKnownType = {}));
|
|
12
|
+
//# sourceMappingURL=iam.authentication.definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iam.authentication.definitions.js","sourceRoot":"","sources":["../../../src/services/authentication/iam.authentication.definitions.ts"],"names":[],"mappings":";;;AAeA,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAE3B,oCAAe,CAAA;AACjB,CAAC,EAHW,iBAAiB,iCAAjB,iBAAiB,QAG5B;AAID,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAE1B,mCAAe,CAAA;AACjB,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConfigProviderService } from '@node-c/core';
|
|
2
|
+
import { AuthenticateUserAuthData, AuthenticateUserResult, AuthenticateUserUserData } from './iam.authentication.definitions';
|
|
3
|
+
export declare class IAMAuthenticationService<UserFields extends object> {
|
|
4
|
+
protected configProvider: ConfigProviderService;
|
|
5
|
+
protected moduleName: string;
|
|
6
|
+
constructor(configProvider: ConfigProviderService, moduleName: string);
|
|
7
|
+
authenticateUser(_userData: AuthenticateUserUserData<UserFields>, _authData: AuthenticateUserAuthData): Promise<AuthenticateUserResult>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.IAMAuthenticationService = void 0;
|
|
13
|
+
const core_1 = require("@node-c/core");
|
|
14
|
+
class IAMAuthenticationService {
|
|
15
|
+
constructor(configProvider, moduleName) {
|
|
16
|
+
this.configProvider = configProvider;
|
|
17
|
+
this.moduleName = moduleName;
|
|
18
|
+
}
|
|
19
|
+
authenticateUser(_userData, _authData) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
throw new core_1.ApplicationError('[IAMAuthenticationService]: Method "authenticateUser" not implemented.');
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.IAMAuthenticationService = IAMAuthenticationService;
|
|
26
|
+
//# sourceMappingURL=iam.authentication.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iam.authentication.service.js","sourceRoot":"","sources":["../../../src/services/authentication/iam.authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAuE;AASvE,MAAa,wBAAwB;IACnC,YAEY,cAAqC,EAErC,UAAkB;QAFlB,mBAAc,GAAd,cAAc,CAAuB;QAErC,eAAU,GAAV,UAAU,CAAQ;IAC3B,CAAC;IAEE,gBAAgB,CAEpB,SAA+C,EAE/C,SAAmC;;YAEnC,MAAM,IAAI,uBAAgB,CAAC,wEAAwE,CAAC,CAAC;QACvG,CAAC;KAAA;CACF;AAhBD,4DAgBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./iam.authentication.definitions"), exports);
|
|
18
|
+
__exportStar(require("./iam.authentication.service"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/authentication/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAiD;AACjD,+DAA6C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AuthenticateUserAuthData, AuthenticateUserResult, AuthenticateUserUserData } from '../authentication';
|
|
2
|
+
export type LocalAuthenticateUserUserData<UserFields extends object> = AuthenticateUserUserData<{
|
|
3
|
+
password: string;
|
|
4
|
+
} & UserFields>;
|
|
5
|
+
export interface LocalAuthenticateUserAuthData extends AuthenticateUserAuthData {
|
|
6
|
+
password: string;
|
|
7
|
+
}
|
|
8
|
+
export type LocalAuthenticateUserResult = AuthenticateUserResult;
|
|
9
|
+
export type LocalAuthenticationUserMFAEntity<UserMFAFields extends object | undefined> = {
|
|
10
|
+
code: string;
|
|
11
|
+
} & UserMFAFields;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iam.authenticationLocal.definitions.js","sourceRoot":"","sources":["../../../src/services/authenticationLocal/iam.authenticationLocal.definitions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConfigProviderService, PersistanceEntityService } from '@node-c/core';
|
|
2
|
+
import { LocalAuthenticateUserAuthData, LocalAuthenticateUserResult, LocalAuthenticateUserUserData, LocalAuthenticationUserMFAEntity } from './iam.authenticationLocal.definitions';
|
|
3
|
+
import { IAMAuthenticationService } from '../authentication';
|
|
4
|
+
export declare class IAMAuthenticationLocalService<AuthenticationUserFields extends object, UserMFAEntityFields extends object | undefined = undefined> extends IAMAuthenticationService<AuthenticationUserFields> {
|
|
5
|
+
protected configProvider: ConfigProviderService;
|
|
6
|
+
protected moduleName: string;
|
|
7
|
+
protected persistanceUsersMFAService?: PersistanceEntityService<LocalAuthenticationUserMFAEntity<UserMFAEntityFields>> | undefined;
|
|
8
|
+
constructor(configProvider: ConfigProviderService, moduleName: string, persistanceUsersMFAService?: PersistanceEntityService<LocalAuthenticationUserMFAEntity<UserMFAEntityFields>> | undefined);
|
|
9
|
+
authenticateUser(userData: LocalAuthenticateUserUserData<AuthenticationUserFields>, authData: LocalAuthenticateUserAuthData): Promise<LocalAuthenticateUserResult>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.IAMAuthenticationLocalService = void 0;
|
|
16
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
17
|
+
const core_1 = require("@node-c/core");
|
|
18
|
+
const authentication_1 = require("../authentication");
|
|
19
|
+
class IAMAuthenticationLocalService extends authentication_1.IAMAuthenticationService {
|
|
20
|
+
constructor(configProvider, moduleName, persistanceUsersMFAService) {
|
|
21
|
+
super(configProvider, moduleName);
|
|
22
|
+
this.configProvider = configProvider;
|
|
23
|
+
this.moduleName = moduleName;
|
|
24
|
+
this.persistanceUsersMFAService = persistanceUsersMFAService;
|
|
25
|
+
}
|
|
26
|
+
authenticateUser(userData, authData) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const { configProvider, moduleName, persistanceUsersMFAService } = this;
|
|
29
|
+
const { defaultUserIdentifierField, userPasswordHMACAlgorithm, userPasswordSecret } = configProvider.config.domain[moduleName];
|
|
30
|
+
const { mfaEnabled, password: userPassword } = userData;
|
|
31
|
+
const { mfaCode, mfaType, password: authPassword } = authData;
|
|
32
|
+
const userIdentifierField = authData.userIdentifierField || defaultUserIdentifierField;
|
|
33
|
+
const userIdentifierValue = userData[userIdentifierField];
|
|
34
|
+
const userMFAIdentifierField = authData.userMFAIdentifierField || userIdentifierField;
|
|
35
|
+
if (!userPasswordHMACAlgorithm ||
|
|
36
|
+
!userPasswordSecret ||
|
|
37
|
+
!userPassword ||
|
|
38
|
+
crypto_1.default.createHmac(userPasswordHMACAlgorithm, userPasswordSecret).update(`${authPassword}`).digest().toString() !==
|
|
39
|
+
userPassword) {
|
|
40
|
+
console.info(`[IAMAuthenticationLocalService]: Login attempt failed for user ${userIdentifierValue} - wrong password.`);
|
|
41
|
+
throw new core_1.ApplicationError('Invalid identifier or password.');
|
|
42
|
+
}
|
|
43
|
+
if (mfaEnabled) {
|
|
44
|
+
if (!mfaCode || mfaType !== authentication_1.UserMFAKnownType.Local || !persistanceUsersMFAService) {
|
|
45
|
+
throw new core_1.ApplicationError('Invalid MFA code.');
|
|
46
|
+
}
|
|
47
|
+
const storedCodeData = yield persistanceUsersMFAService.findOne({
|
|
48
|
+
filters: { [userMFAIdentifierField]: userIdentifierValue }
|
|
49
|
+
});
|
|
50
|
+
if (!(storedCodeData === null || storedCodeData === void 0 ? void 0 : storedCodeData.code) || mfaCode !== (storedCodeData === null || storedCodeData === void 0 ? void 0 : storedCodeData.code)) {
|
|
51
|
+
console.info(`[IAMAuthenticationLocalService]: Login attempt failed for user ${userIdentifierValue} - missing or wrong mfa code.`);
|
|
52
|
+
throw new core_1.ApplicationError('Invalid MFA code.');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return { valid: true };
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.IAMAuthenticationLocalService = IAMAuthenticationLocalService;
|
|
60
|
+
//# sourceMappingURL=iam.authenticationLocal.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iam.authenticationLocal.service.js","sourceRoot":"","sources":["../../../src/services/authenticationLocal/iam.authenticationLocal.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAA4B;AAE5B,uCAAqH;AASrH,sDAA+E;AAE/E,MAAa,6BAGX,SAAQ,yCAAkD;IAC1D,YACY,cAAqC,EACrC,UAAkB,EAElB,0BAET;QAED,KAAK,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;QAPxB,mBAAc,GAAd,cAAc,CAAuB;QACrC,eAAU,GAAV,UAAU,CAAQ;QAElB,+BAA0B,GAA1B,0BAA0B,CAEnC;IAGH,CAAC;IAEK,gBAAgB,CACpB,QAAiE,EACjE,QAAuC;;YAEvC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,0BAA0B,EAAE,GAAG,IAAI,CAAC;YACxE,MAAM,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,GAAG,cAAc,CAAC,MAAM,CAAC,MAAM,CAChH,UAAU,CACW,CAAC;YACxB,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;YACxD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;YAC9D,MAAM,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,IAAI,0BAA0B,CAAC;YACvF,MAAM,mBAAmB,GAAG,QAAQ,CAAC,mBAAqD,CAAC,CAAC;YAC5F,MAAM,sBAAsB,GAAG,QAAQ,CAAC,sBAAsB,IAAI,mBAAmB,CAAC;YACtF,IACE,CAAC,yBAAyB;gBAC1B,CAAC,kBAAkB;gBACnB,CAAC,YAAY;gBACb,gBAAM,CAAC,UAAU,CAAC,yBAAyB,EAAE,kBAAkB,CAAC,CAAC,MAAM,CAAC,GAAG,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;oBAC5G,YAAY,EACd,CAAC;gBACD,OAAO,CAAC,IAAI,CACV,kEAAkE,mBAAmB,oBAAoB,CAC1G,CAAC;gBACF,MAAM,IAAI,uBAAgB,CAAC,iCAAiC,CAAC,CAAC;YAChE,CAAC;YAED,IAAI,UAAU,EAAE,CAAC;gBACf,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,iCAAgB,CAAC,KAAK,IAAI,CAAC,0BAA0B,EAAE,CAAC;oBAClF,MAAM,IAAI,uBAAgB,CAAC,mBAAmB,CAAC,CAAC;gBAClD,CAAC;gBACD,MAAM,cAAc,GAAG,MAAM,0BAA0B,CAAC,OAAO,CAAC;oBAC9D,OAAO,EAAE,EAAE,CAAC,sBAAsB,CAAC,EAAE,mBAAmB,EAAE;iBAC3D,CAAC,CAAC;gBACH,IAAI,CAAC,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,CAAA,IAAI,OAAO,MAAK,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,CAAA,EAAE,CAAC;oBAC9D,OAAO,CAAC,IAAI,CACV,kEAAkE,mBAAmB,+BAA+B,CACrH,CAAC;oBACF,MAAM,IAAI,uBAAgB,CAAC,mBAAmB,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;KAAA;CACF;AAzDD,sEAyDC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./iam.authenticationLocal.definitions"), exports);
|
|
18
|
+
__exportStar(require("./iam.authenticationLocal.service"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/authenticationLocal/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wEAAsD;AACtD,oEAAkD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { GenericObject } from '@node-c/core';
|
|
2
|
+
export interface AuthorizationPoint<Id> {
|
|
3
|
+
allowedInputData?: GenericObject;
|
|
4
|
+
controllerNames?: string[];
|
|
5
|
+
forbiddenInputData?: GenericObject;
|
|
6
|
+
handlerNames?: string[];
|
|
7
|
+
id: Id;
|
|
8
|
+
inputDataFieldName?: string;
|
|
9
|
+
moduleNames?: string[];
|
|
10
|
+
name: string;
|
|
11
|
+
requiredStaticData?: GenericObject;
|
|
12
|
+
userFieldName?: string;
|
|
13
|
+
userTypes: GenericObject[];
|
|
14
|
+
}
|
|
15
|
+
export interface AuthorizationData<AuthorizationPointId> {
|
|
16
|
+
__all: {
|
|
17
|
+
__all: {
|
|
18
|
+
[authorizationPointId: string | number]: AuthorizationPoint<AuthorizationPointId>;
|
|
19
|
+
};
|
|
20
|
+
[handlerName: string]: {
|
|
21
|
+
[authorizationPointId: string | number]: AuthorizationPoint<AuthorizationPointId>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
[controllerName: string]: {
|
|
25
|
+
__all: {
|
|
26
|
+
[authorizationPointId: string | number]: AuthorizationPoint<AuthorizationPointId>;
|
|
27
|
+
};
|
|
28
|
+
[handlerName: string]: {
|
|
29
|
+
[authorizationPointId: string | number]: AuthorizationPoint<AuthorizationPointId>;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface AuthorizationUser<AuthorizationPointId> {
|
|
34
|
+
currentAuthorizationPoints: {
|
|
35
|
+
[authorizationPointId: string | number]: AuthorizationPoint<AuthorizationPointId>;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iam.authorization.definitions.js","sourceRoot":"","sources":["../../../src/services/authorization/iam.authorization.definitions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GenericObject, PersistanceEntityService } from '@node-c/core';
|
|
2
|
+
import { AuthorizationData, AuthorizationUser, AuthorizationPoint as BaseAuthorizationPoint } from './iam.authorization.definitions';
|
|
3
|
+
export declare class IAMAuthorizationService<AuthorizationPoint extends BaseAuthorizationPoint<unknown>> {
|
|
4
|
+
protected persistanceAuthorizationPointsService: PersistanceEntityService<AuthorizationPoint>;
|
|
5
|
+
constructor(persistanceAuthorizationPointsService: PersistanceEntityService<AuthorizationPoint>);
|
|
6
|
+
static checkAccess(accessPoints: {
|
|
7
|
+
[id: number]: BaseAuthorizationPoint<unknown>;
|
|
8
|
+
}, inputData: GenericObject, user: AuthorizationUser<unknown>): {
|
|
9
|
+
hasAccess: boolean;
|
|
10
|
+
inputDataToBeMutated: GenericObject;
|
|
11
|
+
};
|
|
12
|
+
static getValuesForTesting(valueToTest: unknown): unknown[];
|
|
13
|
+
mapAuthorizationPoints(moduleName: string): Promise<AuthorizationData<unknown>>;
|
|
14
|
+
static matchInputValues(input: GenericObject, values: GenericObject): GenericObject;
|
|
15
|
+
static testValue(valueToTest: unknown, valueToTestAgainst: unknown): boolean;
|
|
16
|
+
}
|