@intuitionrobotics/user-account 0.46.0 → 0.47.0
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/app-backend/api/_user-account.js +20 -2
- package/app-backend/api/_user-account.js.map +1 -1
- package/app-backend/api/v1/account/_assert.d.ts +2 -3
- package/app-backend/api/v1/account/_assert.js +24 -6
- package/app-backend/api/v1/account/_assert.js.map +1 -1
- package/app-backend/api/v1/account/_imports.d.ts +4 -0
- package/app-backend/api/v1/account/_imports.js +40 -0
- package/app-backend/api/v1/account/_imports.js.map +1 -0
- package/app-backend/api/v1/account/create.js +24 -6
- package/app-backend/api/v1/account/create.js.map +1 -1
- package/app-backend/api/v1/account/list.js +24 -6
- package/app-backend/api/v1/account/list.js.map +1 -1
- package/app-backend/api/v1/account/login-saml.js +22 -4
- package/app-backend/api/v1/account/login-saml.js.map +1 -1
- package/app-backend/api/v1/account/login.js +24 -12
- package/app-backend/api/v1/account/login.js.map +1 -1
- package/app-backend/api/v1/account/logout.js +26 -9
- package/app-backend/api/v1/account/logout.js.map +1 -1
- package/app-backend/api/v1/account/upsert.js +9 -10
- package/app-backend/api/v1/account/upsert.js.map +1 -1
- package/app-backend/api/v1/account/validate.js +24 -6
- package/app-backend/api/v1/account/validate.js.map +1 -1
- package/app-backend/apis/add-new-account.d.ts +3 -3
- package/app-backend/apis/add-new-account.js +24 -12
- package/app-backend/apis/add-new-account.js.map +1 -1
- package/app-backend/core/module-pack.d.ts +2 -0
- package/app-backend/core/module-pack.js +34 -0
- package/app-backend/core/module-pack.js.map +1 -1
- package/app-backend/modules/AccountModule.d.ts +8 -11
- package/app-backend/modules/AccountModule.js +85 -61
- package/app-backend/modules/AccountModule.js.map +1 -1
- package/app-backend/modules/JWTBuilder.d.ts +1 -1
- package/app-backend/modules/JWTBuilder.js +6 -7
- package/app-backend/modules/JWTBuilder.js.map +1 -1
- package/app-backend/modules/SamlModule.d.ts +4 -5
- package/app-backend/modules/SamlModule.js +23 -7
- package/app-backend/modules/SamlModule.js.map +1 -1
- package/app-backend/modules/SecretsModule.d.ts +4 -6
- package/app-backend/modules/SecretsModule.js +27 -30
- package/app-backend/modules/SecretsModule.js.map +1 -1
- package/app-backend/modules/{types.d.ts → _imports.d.ts} +4 -3
- package/app-backend/modules/_imports.js +36 -0
- package/app-backend/modules/_imports.js.map +1 -0
- package/app-frontend/core/module-pack.d.ts +1 -0
- package/app-frontend/core/module-pack.js +33 -0
- package/app-frontend/core/module-pack.js.map +1 -1
- package/app-frontend/modules/AccountModule.d.ts +4 -5
- package/app-frontend/modules/AccountModule.js +54 -42
- package/app-frontend/modules/AccountModule.js.map +1 -1
- package/app-frontend/ui/Component_Login.d.ts +21 -0
- package/app-frontend/ui/Component_Login.js +86 -0
- package/app-frontend/ui/Component_Login.js.map +1 -0
- package/app-frontend/ui/Component_Register.d.ts +17 -0
- package/app-frontend/ui/Component_Register.js +92 -0
- package/app-frontend/ui/Component_Register.js.map +1 -0
- package/backend.d.ts +2 -0
- package/backend.js +37 -0
- package/backend.js.map +1 -0
- package/frontend.d.ts +3 -0
- package/frontend.js +38 -0
- package/frontend.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.js +35 -0
- package/index.js.map +1 -1
- package/package.json +8 -7
- package/shared/api.d.ts +25 -25
- package/shared/api.js +19 -1
- package/shared/api.js.map +1 -1
- package/shared/types.d.ts +0 -0
- package/shared/types.js +20 -0
- package/shared/types.js.map +1 -0
- package/shared/utils/AuthenticationConsts.js.map +1 -1
- package/app-backend/modules/types.js +0 -3
- package/app-backend/modules/types.js.map +0 -1
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
2
20
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
21
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
22
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,18 +28,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
28
|
};
|
|
11
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
30
|
exports.SamlModule = exports.SamlModule_Class = void 0;
|
|
13
|
-
const exceptions_1 = require("@intuitionrobotics/ts-common/core/exceptions");
|
|
14
|
-
const module_1 = require("@intuitionrobotics/ts-common/core/module");
|
|
15
|
-
const tools_1 = require("@intuitionrobotics/ts-common/utils/tools");
|
|
16
31
|
const saml2_js_1 = require("saml2-js");
|
|
17
|
-
|
|
32
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
33
|
+
class SamlModule_Class extends ts_common_1.Module {
|
|
18
34
|
constructor() {
|
|
19
35
|
super("SamlModule");
|
|
20
36
|
this.loginRequest = (loginContext) => __awaiter(this, void 0, void 0, function* () {
|
|
21
37
|
return new Promise((resolve, rejected) => {
|
|
22
38
|
const sp = new saml2_js_1.ServiceProvider(this.config.spConfig);
|
|
23
39
|
const options = {
|
|
24
|
-
relay_state:
|
|
40
|
+
relay_state: (0, ts_common_1.__stringify)(loginContext)
|
|
25
41
|
};
|
|
26
42
|
sp.create_login_request_url(this.identityProvider, options, (error, loginUrl, requestId) => {
|
|
27
43
|
if (error)
|
|
@@ -51,9 +67,9 @@ class SamlModule_Class extends module_1.Module {
|
|
|
51
67
|
}
|
|
52
68
|
init() {
|
|
53
69
|
if (!this.config.idConfig)
|
|
54
|
-
throw new
|
|
70
|
+
throw new ts_common_1.ImplementationMissingException("Config must contain idConfig");
|
|
55
71
|
if (!this.config.spConfig)
|
|
56
|
-
throw new
|
|
72
|
+
throw new ts_common_1.ImplementationMissingException("Config must contain spConfig");
|
|
57
73
|
this.identityProvider = new saml2_js_1.IdentityProvider(this.config.idConfig);
|
|
58
74
|
}
|
|
59
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SamlModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/SamlModule.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"SamlModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/SamlModule.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;AAEH,uCAMkB;AAClB,4DAIsC;AAgCtC,MAAa,gBACZ,SAAQ,kBAAkB;IAI1B;QACC,KAAK,CAAC,YAAY,CAAC,CAAC;QAarB,iBAAY,GAAG,CAAO,YAAqC,EAAE,EAAE;YAC9D,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;gBAChD,MAAM,EAAE,GAAG,IAAI,0BAAe,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACrD,MAAM,OAAO,GAAG;oBACf,WAAW,EAAE,IAAA,uBAAW,EAAC,YAAY,CAAC;iBACtC,CAAC;gBACF,EAAE,CAAC,wBAAwB,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE;oBAC1F,IAAI,KAAK;wBACR,OAAO,QAAQ,CAAC,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AQ,CAAC,CAAC;IACpE,CAAC;CAoCD;AArDD,4CAqDC;AAEY,QAAA,UAAU,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ExpressRequest } from "@intuitionrobotics/thunderstorm/
|
|
3
|
-
import { Module } from "@intuitionrobotics/ts-common/core/module";
|
|
4
|
-
import { ObjectTS } from "@intuitionrobotics/ts-common/utils/types";
|
|
1
|
+
import { Module, ObjectTS } from "@intuitionrobotics/ts-common";
|
|
2
|
+
import { ApiException, ExpressRequest } from "@intuitionrobotics/thunderstorm/backend";
|
|
5
3
|
import * as jws from "jws";
|
|
6
4
|
import { Algorithm, Signature } from "jws";
|
|
7
5
|
export declare class TokenExpiredException extends ApiException {
|
|
8
6
|
constructor(message: string, cause?: Error);
|
|
9
7
|
}
|
|
10
|
-
|
|
8
|
+
type Config = {
|
|
11
9
|
secrets?: {
|
|
12
10
|
[k: string]: any;
|
|
13
11
|
};
|
|
14
12
|
validateKeyId: string;
|
|
15
13
|
issuer?: string;
|
|
16
14
|
};
|
|
17
|
-
|
|
15
|
+
type Secret = {
|
|
18
16
|
kid: string;
|
|
19
17
|
value: string;
|
|
20
18
|
};
|
|
@@ -1,44 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SecretsModule = exports.SecretsModule_Class = exports.TokenExpiredException = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const module_1 = require("@intuitionrobotics/ts-common/core/module");
|
|
7
|
-
const date_time_tools_1 = require("@intuitionrobotics/ts-common/utils/date-time-tools");
|
|
8
|
-
const tools_1 = require("@intuitionrobotics/ts-common/utils/tools");
|
|
4
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
5
|
+
const backend_1 = require("@intuitionrobotics/thunderstorm/backend");
|
|
9
6
|
const jws = require("jws");
|
|
10
|
-
const AuthenticationConsts_1 = require("../../shared/utils/AuthenticationConsts");
|
|
11
7
|
const JWTBuilder_1 = require("./JWTBuilder");
|
|
12
|
-
|
|
8
|
+
const __1 = require("../..");
|
|
9
|
+
class TokenExpiredException extends backend_1.ApiException {
|
|
13
10
|
constructor(message, cause) {
|
|
14
11
|
super(401, message, cause);
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
14
|
exports.TokenExpiredException = TokenExpiredException;
|
|
18
|
-
class SecretsModule_Class extends
|
|
15
|
+
class SecretsModule_Class extends ts_common_1.Module {
|
|
19
16
|
constructor() {
|
|
20
17
|
super("SecretsModule");
|
|
21
18
|
this.DEFAULT_ISS = "TOOLS";
|
|
22
|
-
this.AUTHENTICATION_PREFIX =
|
|
23
|
-
this.AUTHENTICATION_KEY =
|
|
19
|
+
this.AUTHENTICATION_PREFIX = __1.AUTHENTICATION_PREFIX;
|
|
20
|
+
this.AUTHENTICATION_KEY = __1.AUTHENTICATION_KEY;
|
|
24
21
|
this.getAuthSecret = (kid) => {
|
|
25
22
|
return this.getSecret(kid);
|
|
26
23
|
};
|
|
27
24
|
this.getConfig = () => {
|
|
28
25
|
if (!this.config)
|
|
29
|
-
throw new
|
|
26
|
+
throw new ts_common_1.BadImplementationException(`Missing config, check SecretsModule's config`);
|
|
30
27
|
if (!this.config.secrets)
|
|
31
|
-
throw new
|
|
28
|
+
throw new ts_common_1.BadImplementationException(`Missing 'secrets' key in config, check SecretsModule's config`);
|
|
32
29
|
return this.config.secrets;
|
|
33
30
|
};
|
|
34
31
|
this.isExpired = (token) => {
|
|
35
|
-
return this.getExpiration(token) <
|
|
32
|
+
return this.getExpiration(token) < (0, ts_common_1.currentTimeMillies)();
|
|
36
33
|
};
|
|
37
34
|
this.generateJwt = (payload, kid, algorithm = "HS256") => {
|
|
38
35
|
const secret = this.getAuthSecret(kid);
|
|
39
36
|
return new JWTBuilder_1.JWTBuilder(algorithm)
|
|
40
37
|
// This is a default that can be overwritten by the claims
|
|
41
|
-
.setExpiration(Math.floor((
|
|
38
|
+
.setExpiration(Math.floor(((0, ts_common_1.currentTimeMillies)() + ts_common_1.Day) / 1000))
|
|
42
39
|
.addClaims(payload)
|
|
43
40
|
.setIssuer(this.getIss())
|
|
44
41
|
.setKeyID(secret.kid)
|
|
@@ -53,13 +50,13 @@ class SecretsModule_Class extends module_1.Module {
|
|
|
53
50
|
this.decodeJwt = (jwt) => {
|
|
54
51
|
return jws.decode(jwt);
|
|
55
52
|
};
|
|
56
|
-
this.
|
|
53
|
+
this.setDefaultConfig({ validateKeyId: "AUTH_SECRET" });
|
|
57
54
|
}
|
|
58
55
|
getSecret(k) {
|
|
59
56
|
var _a, _b;
|
|
60
57
|
const secret = ((_a = process.env) === null || _a === void 0 ? void 0 : _a[k]) || ((_b = this.getConfig()) === null || _b === void 0 ? void 0 : _b[k]);
|
|
61
58
|
if (!secret)
|
|
62
|
-
throw new
|
|
59
|
+
throw new ts_common_1.BadImplementationException(`Missing secret with key ${k} in SecretsModule`);
|
|
63
60
|
return {
|
|
64
61
|
kid: k,
|
|
65
62
|
value: secret
|
|
@@ -68,7 +65,7 @@ class SecretsModule_Class extends module_1.Module {
|
|
|
68
65
|
validateRequestAndCheckExpiration(request, scopes) {
|
|
69
66
|
const token = this.validateRequest(request, scopes);
|
|
70
67
|
if (this.isExpired(token)) {
|
|
71
|
-
const cause = `The JWT passed is not valid, check. With payload: ${
|
|
68
|
+
const cause = `The JWT passed is not valid, check. With payload: ${(0, ts_common_1.__stringify)(token.payload)}. The JWT passed is expired`;
|
|
72
69
|
throw new TokenExpiredException(cause);
|
|
73
70
|
}
|
|
74
71
|
return token.payload;
|
|
@@ -79,18 +76,18 @@ class SecretsModule_Class extends module_1.Module {
|
|
|
79
76
|
const authToken = this.extractAuthToken(request);
|
|
80
77
|
const token = this.decodeJwt(authToken);
|
|
81
78
|
if (!token)
|
|
82
|
-
throw new
|
|
79
|
+
throw new backend_1.ApiException(401, "Could not decode token " + authToken);
|
|
83
80
|
const kid = token.header.kid || this.config.validateKeyId;
|
|
84
81
|
if (!kid)
|
|
85
|
-
throw new
|
|
82
|
+
throw new backend_1.ApiException(401, "Could not deduce which key to use in order to verify the token, please specify a key ID");
|
|
86
83
|
const secret = this.getAuthSecret(kid);
|
|
87
84
|
const verified = jws.verify(authToken, token.header.alg, secret.value);
|
|
88
|
-
let cause = `The JWT passed is not valid, check. With payload: ${
|
|
85
|
+
let cause = `The JWT passed is not valid, check. With payload: ${(0, ts_common_1.__stringify)(token.payload)} and header ${(0, ts_common_1.__stringify)(token.header)}.`;
|
|
89
86
|
if (!verified)
|
|
90
|
-
throw new
|
|
87
|
+
throw new backend_1.ApiException(401, cause);
|
|
91
88
|
if (!((_a = token.payload) === null || _a === void 0 ? void 0 : _a[JWTBuilder_1.EXPIRES_AT])) {
|
|
92
89
|
cause += ` The JWT is missing the expiration claim`;
|
|
93
|
-
throw new
|
|
90
|
+
throw new backend_1.ApiException(401, cause);
|
|
94
91
|
}
|
|
95
92
|
const scopesToValidate = (_b = token.payload) === null || _b === void 0 ? void 0 : _b.scopes;
|
|
96
93
|
if (scopesToValidate)
|
|
@@ -101,36 +98,36 @@ class SecretsModule_Class extends module_1.Module {
|
|
|
101
98
|
const scopesToValidate = _scopesToValidate.split(",");
|
|
102
99
|
const isValidScope = scopesToValidate.some(s => scopes.includes(s));
|
|
103
100
|
if (!isValidScope)
|
|
104
|
-
throw new
|
|
101
|
+
throw new backend_1.ApiException(403, `User doesn't have valid scopes. It needs ${scopes.join(",")} but it has ${_scopesToValidate}`);
|
|
105
102
|
}
|
|
106
103
|
extractAuthToken(request) {
|
|
107
104
|
const authHead = request.header(this.AUTHENTICATION_KEY);
|
|
108
105
|
if (authHead === undefined)
|
|
109
|
-
throw new
|
|
106
|
+
throw new ts_common_1.BadImplementationException("Missing Authorization header");
|
|
110
107
|
if (!authHead)
|
|
111
|
-
throw new
|
|
108
|
+
throw new ts_common_1.BadImplementationException('The Authorization header is empty');
|
|
112
109
|
const parts = authHead.split(" ");
|
|
113
110
|
if (parts.length !== 2 || parts[0] !== this.AUTHENTICATION_PREFIX)
|
|
114
|
-
throw new
|
|
111
|
+
throw new ts_common_1.BadImplementationException(`The Authorization header is malformed` + "\n"
|
|
115
112
|
+ `Value: ${authHead}` + "\n"
|
|
116
113
|
+ `Expected Value: ${this.AUTHENTICATION_PREFIX} [token]`);
|
|
117
114
|
const authToken = parts[1].trim();
|
|
118
115
|
if (!authToken)
|
|
119
|
-
throw new
|
|
116
|
+
throw new ts_common_1.BadImplementationException(`The token provided is empty`);
|
|
120
117
|
return authToken;
|
|
121
118
|
}
|
|
122
119
|
getExpiration(token) {
|
|
123
120
|
let exp = token.payload[JWTBuilder_1.EXPIRES_AT];
|
|
124
121
|
if (!exp)
|
|
125
122
|
return exp;
|
|
126
|
-
const now =
|
|
123
|
+
const now = (0, ts_common_1.currentTimeMillies)();
|
|
127
124
|
const cutOff = 1000000000000; // 3-3-1973 in milliseconds
|
|
128
125
|
const isInSeconds = exp < cutOff;
|
|
129
126
|
if (isInSeconds)
|
|
130
127
|
exp = exp * 1000;
|
|
131
|
-
const year = 365 *
|
|
128
|
+
const year = 365 * ts_common_1.Day;
|
|
132
129
|
if (exp < now - year || exp > now + (year))
|
|
133
|
-
throw new
|
|
130
|
+
throw new ts_common_1.BadImplementationException(`The JWT passed is not valid. Payload: ${(0, ts_common_1.__stringify)(token.payload)}.` +
|
|
134
131
|
`Malformed JWT, expiry date is not valid, check the exp format, assumed to be in ${isInSeconds ? "seconds" : "milliseconds"}`);
|
|
135
132
|
return exp;
|
|
136
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecretsModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/SecretsModule.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"SecretsModule.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/SecretsModule.ts"],"names":[],"mappings":";;;AAAA,4DAOsC;AACtC,qEAAqF;AACrF,2BAA2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CAAC,6BAA6B,CAAC,CAAC;QAExE,OAAO,SAAS,CAAC;IACrB,CAAC;IAMM,aAAa,CAAC,KAAgB;QACjC,IAAI,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,uBAAU,CAAC,CAAC;QACpC,IAAI,CAAC,GAAG;YACJ,OAAO,GAAG,CAAC;QAEf,MAAM,GAAG,GAAG,IAAA,8BAAkB,GAAE,CAAC;QACjC,MAAM,MAAM,GAAG,aAAa,CAAC,CAAA,2BAA2B;QACxD,MAAM,WAAW,GAAG,GAAG,GAAG,MAAM,CAAC;QACjC,IAAI,WAAW;YACX,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;QAErB,MAAM,IAAI,GAAG,GAAG,GAAG,eAAG,CAAC;QACvB,IAAI,GAAG,GAAG,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC;YACtC,MAAM,IAAI,sCAA0B,CAAC,yCAAyC,IAAA,uBAAW,EAAC,KAAK,CAAC,OAAO,CAAC,GAAG;gBACvG,mFAAmF,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC;QACvI,OAAO,GAAG,CAAC;IACf,CAAC;CAuBJ;AAvJD,kDAuJC;AAEY,QAAA,aAAa,GAAG,IAAI,mBAAmB,EAAE,CAAA"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { AuditBy, DB_Object } from "@intuitionrobotics/ts-common
|
|
2
|
-
export
|
|
1
|
+
import { AuditBy, DB_Object } from "@intuitionrobotics/ts-common";
|
|
2
|
+
export * from "../../index";
|
|
3
|
+
export type RequestBody_SamlAssertOptions = {
|
|
3
4
|
request_body: {
|
|
4
5
|
SAMLResponse: string;
|
|
5
6
|
RelayState: string;
|
|
6
7
|
};
|
|
7
8
|
allow_unencrypted_assertion?: boolean;
|
|
8
9
|
};
|
|
9
|
-
export
|
|
10
|
+
export type DB_Account = DB_Object & {
|
|
10
11
|
email: string;
|
|
11
12
|
_audit: AuditBy;
|
|
12
13
|
salt?: string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
32
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
__exportStar(require("../../index"), exports);
|
|
36
|
+
//# sourceMappingURL=_imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_imports.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/_imports.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;AAIH,8CAA4B"}
|
|
@@ -1,8 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
32
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
|
+
};
|
|
2
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
35
|
exports.Frontend_ModulePack_Users = void 0;
|
|
4
36
|
const AccountModule_1 = require("../modules/AccountModule");
|
|
5
37
|
exports.Frontend_ModulePack_Users = [
|
|
6
38
|
AccountModule_1.AccountModule,
|
|
7
39
|
];
|
|
40
|
+
__exportStar(require("../modules/AccountModule"), exports);
|
|
8
41
|
//# sourceMappingURL=module-pack.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-pack.js","sourceRoot":"","sources":["../../../src/main/app-frontend/core/module-pack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module-pack.js","sourceRoot":"","sources":["../../../src/main/app-frontend/core/module-pack.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;AAEH,4DAAuD;AAE1C,QAAA,yBAAyB,GAAG;IACxC,6BAAa;CACb,CAAC;AAEF,2DAAwC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OnUnauthenticatedResponse } from "@intuitionrobotics/thunderstorm/
|
|
1
|
+
import { Module } from "@intuitionrobotics/ts-common";
|
|
2
|
+
import { OnUnauthenticatedResponse, StorageKey } from "@intuitionrobotics/thunderstorm/frontend";
|
|
3
3
|
import { Request_CreateAccount, Request_LoginAccount, RequestParams_LoginSAML, UI_Account } from "../../shared/api";
|
|
4
|
-
import { Module } from "@intuitionrobotics/ts-common/core/module";
|
|
5
4
|
export declare const StorageKey_UserEmail: StorageKey<string>;
|
|
6
5
|
export declare const StorageKey_JWT: StorageKey<string>;
|
|
7
6
|
export declare const RequestKey_AccountCreate = "account-create";
|
|
@@ -16,7 +15,7 @@ export declare enum LoggedStatus {
|
|
|
16
15
|
LOGGED_OUT = 1,
|
|
17
16
|
LOGGED_IN = 2
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
type Config = {};
|
|
20
19
|
export interface OnAccountsLoaded {
|
|
21
20
|
__onAccountsLoaded: () => void;
|
|
22
21
|
}
|
|
@@ -36,7 +35,7 @@ export declare class AccountModule_Class extends Module<Config> implements OnUna
|
|
|
36
35
|
private setLoginInfo;
|
|
37
36
|
loginSAML(request: RequestParams_LoginSAML): void;
|
|
38
37
|
private validateToken;
|
|
39
|
-
logout: (url?: string
|
|
38
|
+
logout: (url?: string) => string | undefined;
|
|
40
39
|
listUsers: () => void;
|
|
41
40
|
}
|
|
42
41
|
export declare const AccountModule: AccountModule_Class;
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Permissions management system, define access level for each of
|
|
4
|
+
* your server apis, and restrict users by giving them access levels
|
|
5
|
+
*
|
|
6
|
+
* Copyright (C) 2020 Intuition Robotics
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/
|
|
2
20
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
21
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
22
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,19 +28,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
28
|
};
|
|
11
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
30
|
exports.AccountModule = exports.AccountModule_Class = exports.LoggedStatus = exports.RequestKey_ValidateSession = exports.RequestKey_AccountLoginSAML = exports.RequestKey_AccountLogin = exports.RequestKey_AccountCreate = exports.StorageKey_JWT = exports.StorageKey_UserEmail = void 0;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const ToasterModule_1 = require("@intuitionrobotics/thunderstorm/app-frontend/modules/toaster/ToasterModule");
|
|
16
|
-
const HistoryModule_1 = require("@intuitionrobotics/thunderstorm/app-frontend/modules/HistoryModule");
|
|
17
|
-
const thunder_dispatcher_1 = require("@intuitionrobotics/thunderstorm/app-frontend/core/thunder-dispatcher");
|
|
31
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
32
|
+
const frontend_1 = require("@intuitionrobotics/thunderstorm/frontend");
|
|
18
33
|
const api_1 = require("../../shared/api");
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const date_time_tools_1 = require("@intuitionrobotics/ts-common/utils/date-time-tools");
|
|
24
|
-
exports.StorageKey_UserEmail = new StorageModule_1.StorageKey(`storage-${api_1.QueryParam_Email}`);
|
|
25
|
-
exports.StorageKey_JWT = new StorageModule_1.StorageKey(`storage-${api_1.QueryParam_JWT}`);
|
|
34
|
+
const thunderstorm_1 = require("@intuitionrobotics/thunderstorm");
|
|
35
|
+
const __1 = require("../..");
|
|
36
|
+
exports.StorageKey_UserEmail = new frontend_1.StorageKey(`storage-${api_1.QueryParam_Email}`);
|
|
37
|
+
exports.StorageKey_JWT = new frontend_1.StorageKey(`storage-${api_1.QueryParam_JWT}`);
|
|
26
38
|
exports.RequestKey_AccountCreate = "account-create";
|
|
27
39
|
exports.RequestKey_AccountLogin = "account-login";
|
|
28
40
|
exports.RequestKey_AccountLoginSAML = "account-login-saml";
|
|
@@ -32,9 +44,9 @@ var LoggedStatus;
|
|
|
32
44
|
LoggedStatus[LoggedStatus["VALIDATING"] = 0] = "VALIDATING";
|
|
33
45
|
LoggedStatus[LoggedStatus["LOGGED_OUT"] = 1] = "LOGGED_OUT";
|
|
34
46
|
LoggedStatus[LoggedStatus["LOGGED_IN"] = 2] = "LOGGED_IN";
|
|
35
|
-
})(LoggedStatus
|
|
36
|
-
const dispatch_onAccountsLoaded = new
|
|
37
|
-
class AccountModule_Class extends
|
|
47
|
+
})(LoggedStatus || (exports.LoggedStatus = LoggedStatus = {}));
|
|
48
|
+
const dispatch_onAccountsLoaded = new frontend_1.ThunderDispatcher("__onAccountsLoaded");
|
|
49
|
+
class AccountModule_Class extends ts_common_1.Module {
|
|
38
50
|
constructor() {
|
|
39
51
|
super("AccountModule");
|
|
40
52
|
this.status = LoggedStatus.VALIDATING;
|
|
@@ -50,18 +62,18 @@ class AccountModule_Class extends module_1.Module {
|
|
|
50
62
|
const pervStatus = this.status;
|
|
51
63
|
this.status = newStatus;
|
|
52
64
|
this.logInfo(`Login status changes: ${LoggedStatus[pervStatus]} => ${LoggedStatus[newStatus]}`);
|
|
53
|
-
this.dispatchUI_loginChanged.dispatchUI(
|
|
54
|
-
this.dispatchUI_loginChanged.dispatchModule(
|
|
65
|
+
this.dispatchUI_loginChanged.dispatchUI();
|
|
66
|
+
this.dispatchUI_loginChanged.dispatchModule();
|
|
55
67
|
};
|
|
56
68
|
this.validateToken = () => {
|
|
57
|
-
|
|
58
|
-
.createRequest(
|
|
69
|
+
frontend_1.XhrHttpModule
|
|
70
|
+
.createRequest(thunderstorm_1.HttpMethod.GET, exports.RequestKey_ValidateSession)
|
|
59
71
|
.setLabel(`Validate token...`)
|
|
60
72
|
.setRelativeUrl("/v1/account/validate")
|
|
61
73
|
.setOnError((request, resError) => {
|
|
62
74
|
if (request.getStatus() === 0) {
|
|
63
|
-
|
|
64
|
-
setTimeout(() => exports.AccountModule.validateToken(), 30 *
|
|
75
|
+
frontend_1.ToastModule.toastError("Cannot reach Server... trying in 30 sec");
|
|
76
|
+
setTimeout(() => exports.AccountModule.validateToken(), 30 * ts_common_1.Second);
|
|
65
77
|
return;
|
|
66
78
|
}
|
|
67
79
|
exports.StorageKey_JWT.delete();
|
|
@@ -78,29 +90,29 @@ class AccountModule_Class extends module_1.Module {
|
|
|
78
90
|
this.setLoggedStatus(LoggedStatus.LOGGED_OUT);
|
|
79
91
|
};
|
|
80
92
|
this.listUsers = () => {
|
|
81
|
-
|
|
82
|
-
.createRequest(
|
|
93
|
+
frontend_1.XhrHttpModule
|
|
94
|
+
.createRequest(thunderstorm_1.HttpMethod.GET, exports.RequestKey_ValidateSession)
|
|
83
95
|
.setLabel(`Fetching users...`)
|
|
84
96
|
.setRelativeUrl("/v1/account/query")
|
|
85
97
|
.execute((res) => __awaiter(this, void 0, void 0, function* () {
|
|
86
98
|
this.accounts = res.accounts.filter(account => account._id);
|
|
87
|
-
dispatch_onAccountsLoaded.dispatchUI(
|
|
99
|
+
dispatch_onAccountsLoaded.dispatchUI();
|
|
88
100
|
}));
|
|
89
101
|
};
|
|
90
|
-
|
|
102
|
+
frontend_1.XhrHttpModule.addDefaultResponseHandler((request) => {
|
|
91
103
|
var _a;
|
|
92
104
|
const status = request.getStatus();
|
|
93
105
|
if (status < 200 || status >= 300)
|
|
94
106
|
return false;
|
|
95
107
|
try {
|
|
96
|
-
const
|
|
108
|
+
const functionExecutionId = (_a = request === null || request === void 0 ? void 0 : request.getResponseHeader) === null || _a === void 0 ? void 0 : _a.call(request, thunderstorm_1.HeaderKey_FunctionExecutionId);
|
|
109
|
+
frontend_1.XhrHttpModule.logDebug(`${request.key} Function execution id: ${functionExecutionId}`);
|
|
110
|
+
const jwt = request.getResponseHeader(thunderstorm_1.HeaderKey_JWT);
|
|
97
111
|
if (jwt)
|
|
98
112
|
exports.StorageKey_JWT.set(jwt);
|
|
99
|
-
const functionExecutionId = (_a = request === null || request === void 0 ? void 0 : request.getResponseHeader) === null || _a === void 0 ? void 0 : _a.call(request, consts_1.HeaderKey_FunctionExecutionId);
|
|
100
|
-
XhrHttpModule_1.XhrHttpModule.logDebug(`${request.key} Function execution id: ${functionExecutionId}`);
|
|
101
113
|
}
|
|
102
114
|
catch (e) {
|
|
103
|
-
|
|
115
|
+
frontend_1.XhrHttpModule.logError(`${request.key} - Failed to retrieve headers from xhr call`, e);
|
|
104
116
|
}
|
|
105
117
|
return false;
|
|
106
118
|
});
|
|
@@ -109,15 +121,15 @@ class AccountModule_Class extends module_1.Module {
|
|
|
109
121
|
return this.accounts;
|
|
110
122
|
}
|
|
111
123
|
init() {
|
|
112
|
-
|
|
113
|
-
this.dispatchUI_loginChanged = new
|
|
114
|
-
const email =
|
|
115
|
-
const jwt =
|
|
124
|
+
frontend_1.XhrHttpModule.addDefaultHeader(__1.AUTHENTICATION_KEY, () => `${__1.AUTHENTICATION_PREFIX} ${exports.StorageKey_JWT.get()}`);
|
|
125
|
+
this.dispatchUI_loginChanged = new frontend_1.ThunderDispatcher("onLoginStatusUpdated");
|
|
126
|
+
const email = frontend_1.BaseComponent.getQueryParameter(api_1.QueryParam_Email);
|
|
127
|
+
const jwt = frontend_1.BaseComponent.getQueryParameter(api_1.QueryParam_JWT);
|
|
116
128
|
if (email && jwt) {
|
|
117
129
|
exports.StorageKey_JWT.set(jwt);
|
|
118
130
|
exports.StorageKey_UserEmail.set(email);
|
|
119
|
-
|
|
120
|
-
|
|
131
|
+
frontend_1.BrowserHistoryModule.removeQueryParam(api_1.QueryParam_Email);
|
|
132
|
+
frontend_1.BrowserHistoryModule.removeQueryParam(api_1.QueryParam_JWT);
|
|
121
133
|
}
|
|
122
134
|
if (exports.StorageKey_JWT.get())
|
|
123
135
|
return exports.AccountModule.validateToken();
|
|
@@ -125,19 +137,19 @@ class AccountModule_Class extends module_1.Module {
|
|
|
125
137
|
this.setLoggedStatus(LoggedStatus.LOGGED_OUT);
|
|
126
138
|
}
|
|
127
139
|
create(request) {
|
|
128
|
-
|
|
129
|
-
.createRequest(
|
|
140
|
+
frontend_1.XhrHttpModule
|
|
141
|
+
.createRequest(thunderstorm_1.HttpMethod.POST, exports.RequestKey_AccountCreate)
|
|
130
142
|
.setRelativeUrl("/v1/account/create")
|
|
131
143
|
.setJsonBody(request)
|
|
132
144
|
.setLabel(`User register...`)
|
|
133
145
|
.setOnError("Error registering user")
|
|
134
146
|
.execute((response) => __awaiter(this, void 0, void 0, function* () {
|
|
135
|
-
|
|
147
|
+
frontend_1.ToastModule.toastSuccess(`Account successfully created with email: ${response.email}`);
|
|
136
148
|
}));
|
|
137
149
|
}
|
|
138
150
|
login(request) {
|
|
139
|
-
|
|
140
|
-
.createRequest(
|
|
151
|
+
frontend_1.XhrHttpModule
|
|
152
|
+
.createRequest(thunderstorm_1.HttpMethod.POST, exports.RequestKey_AccountLogin)
|
|
141
153
|
.setRelativeUrl("/v1/account/login")
|
|
142
154
|
.setJsonBody(request)
|
|
143
155
|
.setLabel(`User login with password...`)
|
|
@@ -152,8 +164,8 @@ class AccountModule_Class extends module_1.Module {
|
|
|
152
164
|
this.setLoggedStatus(LoggedStatus.LOGGED_IN);
|
|
153
165
|
}
|
|
154
166
|
loginSAML(request) {
|
|
155
|
-
|
|
156
|
-
.createRequest(
|
|
167
|
+
frontend_1.XhrHttpModule
|
|
168
|
+
.createRequest(thunderstorm_1.HttpMethod.GET, exports.RequestKey_AccountLoginSAML)
|
|
157
169
|
.setRelativeUrl("/v1/account/login-saml")
|
|
158
170
|
.setUrlParams(request)
|
|
159
171
|
.setLabel(`User login SAML...`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountModule.js","sourceRoot":"","sources":["../../../src/main/app-frontend/modules/AccountModule.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"AccountModule.js","sourceRoot":"","sources":["../../../src/main/app-frontend/modules/AccountModule.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;AAEH,4DAA4D;AAC5D,uEAQkD;AAClD,0CAe0B;AAC1B,kEAKyC;AACzC,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