@simulacrum/auth0-simulator 0.8.1 → 0.8.3
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/CHANGELOG.md +21 -0
- package/README.md +2 -0
- package/dist/error-handling-middleware.d.ts +3 -0
- package/dist/error-handling-middleware.d.ts.map +1 -0
- package/dist/error-handling-middleware.js +34 -0
- package/dist/error-handling-middleware.js.map +1 -0
- package/dist/handlers/auth0-handlers.d.ts +1 -1
- package/dist/handlers/auth0-handlers.d.ts.map +1 -1
- package/dist/handlers/auth0-handlers.js +58 -90
- package/dist/handlers/auth0-handlers.js.map +1 -1
- package/dist/handlers/login-redirect.d.ts.map +1 -1
- package/dist/handlers/login-redirect.js +3 -3
- package/dist/handlers/login-redirect.js.map +1 -1
- package/dist/handlers/oauth-handlers.d.ts +36 -0
- package/dist/handlers/oauth-handlers.d.ts.map +1 -0
- package/dist/handlers/oauth-handlers.js +117 -0
- package/dist/handlers/oauth-handlers.js.map +1 -0
- package/dist/handlers/utils.d.ts +11 -0
- package/dist/handlers/utils.d.ts.map +1 -0
- package/dist/handlers/utils.js +28 -0
- package/dist/handlers/utils.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/rules/types.d.ts +8 -0
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/types.d.ts +29 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +14 -4
- package/dist/types.js.map +1 -1
- package/dist/views/login.d.ts +3 -2
- package/dist/views/login.d.ts.map +1 -1
- package/dist/views/login.js +7 -5
- package/dist/views/login.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## \[0.8.3]
|
|
4
|
+
|
|
5
|
+
- The auth0-simulator `/login/callback` is difficult to inspect. We need the `client_id` passed, but it seems safe to pass the whole `wctx` object as query strings.
|
|
6
|
+
- [6b18117](https://github.com/thefrontside/simulacrum/commit/6b18117093e650713fe00d5b0614ba085186db9f) /login/callback should pass all wctx ([#241](https://github.com/thefrontside/simulacrum/pull/241)) on 2022-11-30
|
|
7
|
+
- The auth0-simulator userData does not consider the Auth0 email verification functionality. Set it to `true` as a default to enable minimal functionality.
|
|
8
|
+
- [547ef7f](https://github.com/thefrontside/simulacrum/commit/547ef7f3a9f7d99023078ff18307bed2b30223af) default auth0 simulator userData email_verified to true on 2022-11-29
|
|
9
|
+
- The login form needs `event.preventDefault()` to allow the Auth0 library functions to run instead of default form functionality.
|
|
10
|
+
- [046f49f](https://github.com/thefrontside/simulacrum/commit/046f49f3603a7865f3e62c84d81851637971f97f) add event.preventDefault() to login form for submit event on 2022-11-29
|
|
11
|
+
- The auth0-simulator uses a logger that was refactored and broke the middleware logging. As a stopgap to the required, involved refactor, log out based on the debug flag.
|
|
12
|
+
- [67e2f7f](https://github.com/thefrontside/simulacrum/commit/67e2f7f18d90a2fa53f2f216291ee770aab60440) add stopgap debug in auth0-simulator ([#237](https://github.com/thefrontside/simulacrum/pull/237)) on 2022-11-30
|
|
13
|
+
|
|
14
|
+
## \[0.8.2]
|
|
15
|
+
|
|
16
|
+
- Added specific support for the `grant_type` `client_credentials` which is required for machine-to-machine tokens. This grant_type specifically does not run the rules. The `scope` option now accepts an array of objects to specify specific scopes for specific clients.
|
|
17
|
+
- [4ffde63](https://github.com/thefrontside/simulacrum/commit/4ffde63842c0984f7bf5d6b3bd0f3d98ad938799) support client_credentials grant_type on 2022-11-17
|
|
18
|
+
- [9bb1b43](https://github.com/thefrontside/simulacrum/commit/9bb1b43bb80332e5357123550d72eef8681ae416) update change file with note about scope adjustments on 2022-11-23
|
|
19
|
+
- Tweaks the login form so the button is a true form submission button. This allows the form to input validate, and enables all form submission options (enter primarily the addition).
|
|
20
|
+
- [fa4a9e2](https://github.com/thefrontside/simulacrum/commit/fa4a9e27f72b6609419ee93d3c55b620a5feb6bc) auth0 submit as form button on 2022-11-21
|
|
21
|
+
- The simulator should consider the audience and client_id passed in the request. The values may be important for logic in user defined rules, and is used in validating the token, e.g. in `auth0-react`.
|
|
22
|
+
- [86cd7d0](https://github.com/thefrontside/simulacrum/commit/86cd7d06d5747c81d31a241726999955425a8e65) consider client_id and audience in auth0 sim request on 2022-11-16
|
|
23
|
+
|
|
3
24
|
## \[0.8.1]
|
|
4
25
|
|
|
5
26
|
- Async rules were not properly processing and would run as a race condition mutating the `user` and `context` objects. This would mean part of the rule might be applied. This adds some additional wrappers in the rule running to properly handle and `await` on async code.
|
package/README.md
CHANGED
|
@@ -229,6 +229,8 @@ let simulation = yield client.createSimulation("auth0", {
|
|
|
229
229
|
|
|
230
230
|
The `options` field supports the [auth0 configuration fields](https://auth0.com/docs/quickstart/spa/vanillajs#configure-auth0). The option fields should match the fields in the client application that is calling the auth0 server.
|
|
231
231
|
|
|
232
|
+
The `scope` also accepts an array of objects containing `clientID`, `scope` and optionally `audience` to enable dynamic scopes from a single simulator. This should allow multiple clients to all use the same simulator. Additionally, setting the `clientID: "default"` will enable a default fallback scope so every client does not need to be included.
|
|
233
|
+
|
|
232
234
|
An optional [`rulesDirectory` field](#rules) can specify a directory of [auth0 rules](https://auth0.com/docs/rules) code files, more on this [below](#rules).
|
|
233
235
|
|
|
234
236
|
### Services
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handling-middleware.d.ts","sourceRoot":"","sources":["../src/error-handling-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE/D,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,QA8BjG"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultErrorHandler = void 0;
|
|
4
|
+
function defaultErrorHandler(error, _req, res, next) {
|
|
5
|
+
var _a;
|
|
6
|
+
if (res.headersSent) {
|
|
7
|
+
return next(error);
|
|
8
|
+
}
|
|
9
|
+
let assertCondition = 'Assert condition failed: ';
|
|
10
|
+
if ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.startsWith(assertCondition)) {
|
|
11
|
+
let errorCode = 500;
|
|
12
|
+
let errorResponse = error.message;
|
|
13
|
+
if (error.message.includes('::')) {
|
|
14
|
+
let errorMessage = error.message.slice(assertCondition.length);
|
|
15
|
+
errorCode = parseInt(errorMessage.slice(0, 3));
|
|
16
|
+
errorResponse = errorMessage.slice(5);
|
|
17
|
+
}
|
|
18
|
+
res.status(errorCode).send(errorResponse);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.error(error);
|
|
22
|
+
res
|
|
23
|
+
.status(500)
|
|
24
|
+
.json({
|
|
25
|
+
error: {
|
|
26
|
+
name: error.name,
|
|
27
|
+
message: error.message,
|
|
28
|
+
stack: error.stack,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.defaultErrorHandler = defaultErrorHandler;
|
|
34
|
+
//# sourceMappingURL=error-handling-middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handling-middleware.js","sourceRoot":"","sources":["../src/error-handling-middleware.ts"],"names":[],"mappings":";;;AAEA,SAAgB,mBAAmB,CAAC,KAAY,EAAE,IAAa,EAAE,GAAa,EAAE,IAAkB;;IAChG,IAAI,GAAG,CAAC,WAAW,EAAE;QACnB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;KACpB;IAED,IAAI,eAAe,GAAG,2BAA2B,CAAC;IAElD,IAAI,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAE,UAAU,CAAC,eAAe,CAAC,EAAE;QAC/C,IAAI,SAAS,GAAG,GAAG,CAAC;QACpB,IAAI,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC;QAElC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YAChC,IAAI,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YAC/D,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC/C,aAAa,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACvC;QAED,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;KAC3C;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,GAAG;aACA,MAAM,CAAC,GAAG,CAAC;aACX,IAAI,CAAC;YACJ,KAAK,EAAE;gBACL,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB;SACF,CAAC,CAAC;KACN;AACH,CAAC;AA9BD,kDA8BC"}
|
|
@@ -10,5 +10,5 @@ export interface Auth0Store {
|
|
|
10
10
|
get(nonce: string): AuthSession;
|
|
11
11
|
set(nonce: string, session: AuthSession): void;
|
|
12
12
|
}
|
|
13
|
-
export declare const createAuth0Handlers: (store: Auth0Store, people: Iterable<Person>, serviceURL: () => URL, options: Auth0Configuration) => Record<Routes, RequestHandler>;
|
|
13
|
+
export declare const createAuth0Handlers: (store: Auth0Store, people: Iterable<Person>, serviceURL: () => URL, options: Auth0Configuration, debug: boolean) => Record<Routes, RequestHandler>;
|
|
14
14
|
//# sourceMappingURL=auth0-handlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0-handlers.d.ts","sourceRoot":"","sources":["../../src/handlers/auth0-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"auth0-handlers.d.ts","sourceRoot":"","sources":["../../src/handlers/auth0-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAA8B,MAAM,UAAU,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAY9C,oBAAY,MAAM,GACd,YAAY,GACZ,YAAY,GACZ,QAAQ,GACR,yBAAyB,GACzB,iBAAiB,GACjB,cAAc,GACd,YAAY,GACZ,WAAW,CAAA;AAEf,oBAAY,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC;IAChC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;CAChD;AAcD,eAAO,MAAM,mBAAmB,UAAW,UAAU,UAAU,SAAS,MAAM,CAAC,cAAc,MAAM,GAAG,WAAW,kBAAkB,SAAS,OAAO,KAAG,OAAO,MAAM,EAAE,cAAc,CA+LlL,CAAC"}
|
|
@@ -4,31 +4,36 @@ exports.createAuth0Handlers = void 0;
|
|
|
4
4
|
const login_redirect_1 = require("./login-redirect");
|
|
5
5
|
const web_message_1 = require("./web-message");
|
|
6
6
|
const login_1 = require("../views/login");
|
|
7
|
+
const oauth_handlers_1 = require("./oauth-handlers");
|
|
7
8
|
const assert_ts_1 = require("assert-ts");
|
|
8
9
|
const querystring_1 = require("querystring");
|
|
9
10
|
const base64_url_1 = require("base64-url");
|
|
10
11
|
const username_password_1 = require("../views/username-password");
|
|
11
|
-
const date_1 = require("../auth/date");
|
|
12
|
-
const jwt_1 = require("../auth/jwt");
|
|
13
|
-
const rules_runner_1 = require("../rules/rules-runner");
|
|
14
12
|
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
const createLogger = (debug) => ({
|
|
15
|
+
log: (...args) => {
|
|
16
|
+
if (!debug) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
console.dir(...args);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const createAuth0Handlers = (store, people, serviceURL, options, debug) => {
|
|
19
23
|
let { audience, scope, clientID, rulesDirectory } = options;
|
|
20
|
-
let personQuery = createPersonQuery(people);
|
|
21
|
-
let rulesRunner = (0, rules_runner_1.createRulesRunner)(rulesDirectory);
|
|
24
|
+
let personQuery = (0, utils_1.createPersonQuery)(people);
|
|
22
25
|
let authorizeHandlers = {
|
|
23
26
|
query: (0, login_redirect_1.createLoginRedirectHandler)(options),
|
|
24
27
|
web_message: (0, web_message_1.createWebMessageHandler)()
|
|
25
28
|
};
|
|
29
|
+
let logger = createLogger(debug);
|
|
26
30
|
return {
|
|
27
31
|
['/heartbeat']: function (_, res) {
|
|
28
32
|
res.status(200).json({ ok: true });
|
|
29
33
|
},
|
|
30
34
|
['/authorize']: function (req, res, next) {
|
|
31
35
|
var _a;
|
|
36
|
+
logger.log({ '/authorize': { body: req.body, query: req.query, session: req.session } });
|
|
32
37
|
let currentUser = req.query.currentUser;
|
|
33
38
|
(0, assert_ts_1.assert)(!!req.session, "no session");
|
|
34
39
|
if (currentUser) {
|
|
@@ -43,34 +48,42 @@ const createAuth0Handlers = (store, people, serviceURL, options) => {
|
|
|
43
48
|
handler(req, res, next);
|
|
44
49
|
},
|
|
45
50
|
['/login']: function (req, res) {
|
|
46
|
-
|
|
47
|
-
(
|
|
51
|
+
var _a, _b;
|
|
52
|
+
logger.log({ '/login': { body: req.body, query: req.query } });
|
|
53
|
+
let query = req.query;
|
|
54
|
+
let responseClientId = (_a = query.client_id) !== null && _a !== void 0 ? _a : clientID;
|
|
55
|
+
let responseAudience = (_b = query.audience) !== null && _b !== void 0 ? _b : audience;
|
|
56
|
+
(0, assert_ts_1.assert)(!!responseClientId, `no clientID assigned`);
|
|
48
57
|
let html = (0, login_1.loginView)({
|
|
49
58
|
domain: serviceURL().host,
|
|
50
59
|
scope,
|
|
51
|
-
redirectUri: redirect_uri,
|
|
52
|
-
clientID,
|
|
53
|
-
audience,
|
|
60
|
+
redirectUri: query.redirect_uri,
|
|
61
|
+
clientID: responseClientId,
|
|
62
|
+
audience: responseAudience,
|
|
54
63
|
loginFailed: false
|
|
55
64
|
});
|
|
56
65
|
res.set("Content-Type", "text/html");
|
|
57
66
|
res.status(200).send(Buffer.from(html));
|
|
58
67
|
},
|
|
59
68
|
['/usernamepassword/login']: function (req, res) {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
logger.log({ '/usernamepassword/login': { body: req.body, query: req.query } });
|
|
60
71
|
let { username, nonce, password } = req.body;
|
|
61
72
|
(0, assert_ts_1.assert)(!!username, 'no username in /usernamepassword/login');
|
|
62
73
|
(0, assert_ts_1.assert)(!!nonce, 'no nonce in /usernamepassword/login');
|
|
63
74
|
(0, assert_ts_1.assert)(!!req.session, "no session");
|
|
64
75
|
let user = personQuery((person) => { var _a; return ((_a = person.email) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === username.toLowerCase() && person.password === password; });
|
|
65
76
|
if (!user) {
|
|
66
|
-
let
|
|
77
|
+
let query = req.query;
|
|
78
|
+
let responseClientId = (_a = query.client_id) !== null && _a !== void 0 ? _a : clientID;
|
|
79
|
+
let responseAudience = (_b = query.audience) !== null && _b !== void 0 ? _b : audience;
|
|
67
80
|
(0, assert_ts_1.assert)(!!clientID, `no clientID assigned`);
|
|
68
81
|
let html = (0, login_1.loginView)({
|
|
69
82
|
domain: serviceURL().host,
|
|
70
83
|
scope,
|
|
71
|
-
redirectUri: redirect_uri,
|
|
72
|
-
clientID,
|
|
73
|
-
audience,
|
|
84
|
+
redirectUri: query.redirect_uri,
|
|
85
|
+
clientID: responseClientId,
|
|
86
|
+
audience: responseAudience,
|
|
74
87
|
loginFailed: true
|
|
75
88
|
});
|
|
76
89
|
res.set("Content-Type", "text/html");
|
|
@@ -83,85 +96,40 @@ const createAuth0Handlers = (store, people, serviceURL, options) => {
|
|
|
83
96
|
},
|
|
84
97
|
['/login/callback']: function (req, res) {
|
|
85
98
|
let wctx = JSON.parse(req.body.wctx);
|
|
86
|
-
|
|
99
|
+
logger.log({ '/login/callback': { body: req.body, query: req.query, wctx } });
|
|
100
|
+
let { redirect_uri, nonce } = wctx;
|
|
87
101
|
let { username } = store.get(nonce);
|
|
88
102
|
let encodedNonce = (0, base64_url_1.encode)(`${nonce}:${username}`);
|
|
89
|
-
let qs = (0, querystring_1.stringify)({ code: encodedNonce,
|
|
103
|
+
let qs = (0, querystring_1.stringify)({ code: encodedNonce, ...wctx });
|
|
90
104
|
let routerUrl = `${redirect_uri}?${qs}`;
|
|
91
105
|
res.status(302).redirect(routerUrl);
|
|
92
106
|
},
|
|
93
|
-
['/oauth/token']: async function (req, res) {
|
|
94
|
-
var _a, _b, _c, _d
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (typeof password === 'undefined') {
|
|
116
|
-
return valid;
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
return valid && password === person.password;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
if (!user) {
|
|
123
|
-
res.status(401).send('Unauthorized');
|
|
124
|
-
return;
|
|
107
|
+
['/oauth/token']: async function (req, res, next) {
|
|
108
|
+
var _a, _b, _c, _d;
|
|
109
|
+
logger.log({ '/oauth/token': { body: req.body, query: req.query } });
|
|
110
|
+
try {
|
|
111
|
+
let iss = serviceURL().toString();
|
|
112
|
+
let responseClientId = (_b = (_a = req === null || req === void 0 ? void 0 : req.body) === null || _a === void 0 ? void 0 : _a.client_id) !== null && _b !== void 0 ? _b : clientID;
|
|
113
|
+
let responseAudience = (_d = (_c = req === null || req === void 0 ? void 0 : req.body) === null || _c === void 0 ? void 0 : _c.audience) !== null && _d !== void 0 ? _d : audience;
|
|
114
|
+
(0, assert_ts_1.assert)(!!responseClientId, '500::no clientID in options or request body');
|
|
115
|
+
let tokens = await (0, oauth_handlers_1.createTokens)({
|
|
116
|
+
body: req.body,
|
|
117
|
+
iss,
|
|
118
|
+
clientID: responseClientId,
|
|
119
|
+
audience: responseAudience,
|
|
120
|
+
rulesDirectory,
|
|
121
|
+
people,
|
|
122
|
+
scope
|
|
123
|
+
});
|
|
124
|
+
res.status(200).json({
|
|
125
|
+
...tokens,
|
|
126
|
+
expires_in: 86400,
|
|
127
|
+
token_type: "Bearer",
|
|
128
|
+
});
|
|
125
129
|
}
|
|
126
|
-
(
|
|
127
|
-
|
|
128
|
-
alg: "RS256",
|
|
129
|
-
typ: "JWT",
|
|
130
|
-
iss: serviceURL().toString(),
|
|
131
|
-
exp: (0, date_1.expiresAt)(),
|
|
132
|
-
iat: (0, date_1.epochTime)(),
|
|
133
|
-
email: username,
|
|
134
|
-
aud: clientID,
|
|
135
|
-
sub: user.id,
|
|
136
|
-
};
|
|
137
|
-
if (typeof nonce !== 'undefined') {
|
|
138
|
-
idTokenData.nonce = nonce;
|
|
130
|
+
catch (error) {
|
|
131
|
+
next(error);
|
|
139
132
|
}
|
|
140
|
-
let userData = {
|
|
141
|
-
name: (_a = req === null || req === void 0 ? void 0 : req.body) === null || _a === void 0 ? void 0 : _a.name,
|
|
142
|
-
email: (_b = req === null || req === void 0 ? void 0 : req.body) === null || _b === void 0 ? void 0 : _b.email,
|
|
143
|
-
user_id: (_c = req === null || req === void 0 ? void 0 : req.body) === null || _c === void 0 ? void 0 : _c.id,
|
|
144
|
-
nickname: (_d = req === null || req === void 0 ? void 0 : req.body) === null || _d === void 0 ? void 0 : _d.nickname,
|
|
145
|
-
picture: (_e = req === null || req === void 0 ? void 0 : req.body) === null || _e === void 0 ? void 0 : _e.picture,
|
|
146
|
-
identities: (_f = req === null || req === void 0 ? void 0 : req.body) === null || _f === void 0 ? void 0 : _f.identities,
|
|
147
|
-
};
|
|
148
|
-
let context = { clientID, accessToken: { scope }, idToken: idTokenData };
|
|
149
|
-
await rulesRunner(userData, context);
|
|
150
|
-
let idToken = (0, jwt_1.createJsonWebToken)({ ...userData, ...context.idToken });
|
|
151
|
-
let accessToken = {
|
|
152
|
-
aud: audience,
|
|
153
|
-
sub: idTokenData.sub,
|
|
154
|
-
iat: (0, date_1.epochTime)(),
|
|
155
|
-
iss: idTokenData.iss,
|
|
156
|
-
exp: idTokenData.exp,
|
|
157
|
-
...context.accessToken
|
|
158
|
-
};
|
|
159
|
-
res.status(200).json({
|
|
160
|
-
access_token: (0, jwt_1.createJsonWebToken)(accessToken),
|
|
161
|
-
id_token: idToken,
|
|
162
|
-
expires_in: 86400,
|
|
163
|
-
token_type: "Bearer",
|
|
164
|
-
});
|
|
165
133
|
},
|
|
166
134
|
['/v2/logout']: function (req, res) {
|
|
167
135
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0-handlers.js","sourceRoot":"","sources":["../../src/handlers/auth0-handlers.ts"],"names":[],"mappings":";;;AAGA,qDAA8D;AAC9D,+CAAwD;AACxD,0CAA2C;AAC3C,yCAAmC;AACnC,6CAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"auth0-handlers.js","sourceRoot":"","sources":["../../src/handlers/auth0-handlers.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AAC,CAAC,MAAM,CAAC,EAAE,EAAE,qCAAqC,CAAC,CAAC;gBAE3D,OAAO,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC;YAC3B,CAAC,CAAC,CAAC;YAEH,IAAA,kBAAM,EAAC,CAAC,CAAC,IAAI,EAAE,sBAAsB,CAAC,CAAC;YAEvC,IAAI,QAAQ,GAAG;gBACb,GAAG;gBACH,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,UAAU,EAAE,IAAI,CAAC,IAAI;gBACrB,WAAW,EAAE,IAAI,CAAC,IAAI;gBACtB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,cAAc,EAAE,IAAI;gBACpB,MAAM,EAAE,IAAI;gBACZ,EAAE,EAAE,UAAU;aACf,CAAC;YAEF,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AA/LW,QAAA,mBAAmB,uBA+L9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-redirect.d.ts","sourceRoot":"","sources":["../../src/handlers/login-redirect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,UAAU,CAAC;AAGhE,eAAO,MAAM,0BAA0B,YAAa,kBAAkB,KAAG,
|
|
1
|
+
{"version":3,"file":"login-redirect.d.ts","sourceRoot":"","sources":["../../src/handlers/login-redirect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,UAAU,CAAC;AAGhE,eAAO,MAAM,0BAA0B,YAAa,kBAAkB,KAAG,cAgCtE,CAAC"}
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createLoginRedirectHandler = void 0;
|
|
4
4
|
const querystring_1 = require("querystring");
|
|
5
5
|
const createLoginRedirectHandler = (options) => function loginRedirect(req, res) {
|
|
6
|
-
let { client_id, redirect_uri, scope, state, nonce, response_mode, code_challenge, code_challenge_method, auth0Client, response_type, } = req.query;
|
|
6
|
+
let { client_id, audience, redirect_uri, scope, state, nonce, response_mode, code_challenge, code_challenge_method, auth0Client, response_type, } = req.query;
|
|
7
7
|
res.status(302).redirect(`/login?${(0, querystring_1.stringify)({
|
|
8
8
|
state,
|
|
9
9
|
redirect_uri,
|
|
10
|
-
client: client_id,
|
|
10
|
+
client: client_id || options.clientID,
|
|
11
11
|
protocol: "oauth2",
|
|
12
12
|
scope,
|
|
13
13
|
response_type,
|
|
@@ -16,7 +16,7 @@ const createLoginRedirectHandler = (options) => function loginRedirect(req, res)
|
|
|
16
16
|
code_challenge,
|
|
17
17
|
code_challenge_method,
|
|
18
18
|
auth0Client,
|
|
19
|
-
audience: options.audience,
|
|
19
|
+
audience: audience || options.audience,
|
|
20
20
|
})}`);
|
|
21
21
|
};
|
|
22
22
|
exports.createLoginRedirectHandler = createLoginRedirectHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-redirect.js","sourceRoot":"","sources":["../../src/handlers/login-redirect.ts"],"names":[],"mappings":";;;AAEA,6CAAwC;AAEjC,MAAM,0BAA0B,GAAG,CAAC,OAA2B,EAAkB,EAAE,CACxF,SAAS,aAAa,CAAE,GAAY,EAAE,GAAa;IACjD,IAAI,EACF,SAAS,EACT,YAAY,EACZ,KAAK,EACL,KAAK,EACL,KAAK,EACL,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,aAAa,GACd,GAAG,GAAG,CAAC,KAAoB,CAAC;IAE7B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CACtB,UAAU,IAAA,uBAAS,EAAC;QAClB,KAAK;QACL,YAAY;QACZ,MAAM,EAAE,SAAS;
|
|
1
|
+
{"version":3,"file":"login-redirect.js","sourceRoot":"","sources":["../../src/handlers/login-redirect.ts"],"names":[],"mappings":";;;AAEA,6CAAwC;AAEjC,MAAM,0BAA0B,GAAG,CAAC,OAA2B,EAAkB,EAAE,CACxF,SAAS,aAAa,CAAE,GAAY,EAAE,GAAa;IACjD,IAAI,EACF,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,KAAK,EACL,KAAK,EACL,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,WAAW,EACX,aAAa,GACd,GAAG,GAAG,CAAC,KAAoB,CAAC;IAE7B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CACtB,UAAU,IAAA,uBAAS,EAAC;QAClB,KAAK;QACL,YAAY;QACZ,MAAM,EAAE,SAAS,IAAI,OAAO,CAAC,QAAQ;QACrC,QAAQ,EAAE,QAAQ;QAClB,KAAK;QACL,aAAa;QACb,aAAa;QACb,KAAK;QACL,cAAc;QACd,qBAAqB;QACrB,WAAW;QACX,QAAQ,EAAE,QAAQ,IAAI,OAAO,CAAC,QAAQ;KACvC,CAAC,EAAE,CACL,CAAC;AACJ,CAAC,CAAC;AAhCS,QAAA,0BAA0B,8BAgCnC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Request } from 'express';
|
|
2
|
+
import type { Person } from '@simulacrum/server';
|
|
3
|
+
import type { RuleUser } from '../rules/types';
|
|
4
|
+
import type { ScopeConfig, AccessTokenPayload, IdTokenData } from '../types';
|
|
5
|
+
export declare const createTokens: ({ body, iss, clientID, audience, rulesDirectory, people, scope: scopeConfig, }: {
|
|
6
|
+
body: Request['body'];
|
|
7
|
+
iss: string;
|
|
8
|
+
clientID: string;
|
|
9
|
+
audience: string;
|
|
10
|
+
rulesDirectory: string | undefined;
|
|
11
|
+
people: Iterable<Person>;
|
|
12
|
+
scope: ScopeConfig;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
access_token: string;
|
|
15
|
+
id_token?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
access_token: string;
|
|
18
|
+
id_token: string;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const getIdToken: ({ body, iss, user, clientID, nonce, }: {
|
|
21
|
+
body: Request['body'];
|
|
22
|
+
iss: string;
|
|
23
|
+
user: Person;
|
|
24
|
+
clientID: string;
|
|
25
|
+
nonce: string | undefined;
|
|
26
|
+
}) => {
|
|
27
|
+
userData: RuleUser;
|
|
28
|
+
idTokenData: IdTokenData;
|
|
29
|
+
};
|
|
30
|
+
export declare const getBaseAccessToken: ({ iss, grant_type, scope, audience, }: {
|
|
31
|
+
iss: string;
|
|
32
|
+
grant_type: string;
|
|
33
|
+
scope: string;
|
|
34
|
+
audience: string;
|
|
35
|
+
}) => Partial<AccessTokenPayload>;
|
|
36
|
+
//# sourceMappingURL=oauth-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-handlers.d.ts","sourceRoot":"","sources":["../../src/handlers/oauth-handlers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAElB,WAAW,EACZ,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,YAAY;UASjB,OAAO,CAAC,MAAM,CAAC;SAChB,MAAM;cACD,MAAM;cACN,MAAM;oBACA,MAAM,GAAG,SAAS;YAC1B,SAAS,MAAM,CAAC;WACjB,WAAW;;;;;;;EA2CnB,CAAC;AAEF,eAAO,MAAM,UAAU;UAOf,OAAO,CAAC,MAAM,CAAC;SAChB,MAAM;UACL,MAAM;cACF,MAAM;WACT,MAAM,GAAG,SAAS;;;;CA6B1B,CAAC;AAEF,eAAO,MAAM,kBAAkB;SAMxB,MAAM;gBACC,MAAM;WACX,MAAM;cACH,MAAM;MACd,QAAQ,kBAAkB,CAO5B,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBaseAccessToken = exports.getIdToken = exports.createTokens = void 0;
|
|
4
|
+
const assert_ts_1 = require("assert-ts");
|
|
5
|
+
const base64_url_1 = require("base64-url");
|
|
6
|
+
const date_1 = require("../auth/date");
|
|
7
|
+
const jwt_1 = require("../auth/jwt");
|
|
8
|
+
const rules_runner_1 = require("../rules/rules-runner");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
10
|
+
const createTokens = async ({ body, iss, clientID, audience, rulesDirectory, people, scope: scopeConfig, }) => {
|
|
11
|
+
let { grant_type } = body;
|
|
12
|
+
let scope = (0, utils_1.deriveScope)({ scopeConfig, clientID, audience });
|
|
13
|
+
let accessToken = (0, exports.getBaseAccessToken)({ iss, grant_type, scope, audience });
|
|
14
|
+
if (grant_type === 'client_credentials') {
|
|
15
|
+
return { access_token: (0, jwt_1.createJsonWebToken)(accessToken) };
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
let { user, nonce } = verifyUserExistsInStore({
|
|
19
|
+
people,
|
|
20
|
+
body,
|
|
21
|
+
grant_type,
|
|
22
|
+
});
|
|
23
|
+
let { idTokenData, userData } = (0, exports.getIdToken)({
|
|
24
|
+
body,
|
|
25
|
+
iss,
|
|
26
|
+
user,
|
|
27
|
+
clientID,
|
|
28
|
+
nonce,
|
|
29
|
+
});
|
|
30
|
+
let context = {
|
|
31
|
+
clientID,
|
|
32
|
+
accessToken: { scope, sub: idTokenData.sub },
|
|
33
|
+
idToken: idTokenData,
|
|
34
|
+
};
|
|
35
|
+
let rulesRunner = (0, rules_runner_1.createRulesRunner)(rulesDirectory);
|
|
36
|
+
// the rules mutate the values
|
|
37
|
+
await rulesRunner(userData, context);
|
|
38
|
+
return {
|
|
39
|
+
access_token: (0, jwt_1.createJsonWebToken)({
|
|
40
|
+
...accessToken,
|
|
41
|
+
...context.accessToken,
|
|
42
|
+
}),
|
|
43
|
+
id_token: (0, jwt_1.createJsonWebToken)({
|
|
44
|
+
...userData,
|
|
45
|
+
...context.idToken,
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.createTokens = createTokens;
|
|
51
|
+
const getIdToken = ({ body, iss, user, clientID, nonce, }) => {
|
|
52
|
+
let userData = {
|
|
53
|
+
name: body === null || body === void 0 ? void 0 : body.name,
|
|
54
|
+
email: body === null || body === void 0 ? void 0 : body.email,
|
|
55
|
+
email_verified: true,
|
|
56
|
+
user_id: body === null || body === void 0 ? void 0 : body.id,
|
|
57
|
+
nickname: body === null || body === void 0 ? void 0 : body.nickname,
|
|
58
|
+
picture: body === null || body === void 0 ? void 0 : body.picture,
|
|
59
|
+
identities: body === null || body === void 0 ? void 0 : body.identities,
|
|
60
|
+
};
|
|
61
|
+
(0, assert_ts_1.assert)(!!user.email, '500::User in store requires an email');
|
|
62
|
+
let idTokenData = {
|
|
63
|
+
alg: 'RS256',
|
|
64
|
+
typ: 'JWT',
|
|
65
|
+
iss,
|
|
66
|
+
exp: (0, date_1.expiresAt)(),
|
|
67
|
+
iat: (0, date_1.epochTime)(),
|
|
68
|
+
email: user.email,
|
|
69
|
+
aud: clientID,
|
|
70
|
+
sub: user.id,
|
|
71
|
+
};
|
|
72
|
+
if (typeof nonce !== 'undefined') {
|
|
73
|
+
idTokenData.nonce = nonce;
|
|
74
|
+
}
|
|
75
|
+
return { userData, idTokenData };
|
|
76
|
+
};
|
|
77
|
+
exports.getIdToken = getIdToken;
|
|
78
|
+
const getBaseAccessToken = ({ iss, grant_type, scope, audience, }) => ({
|
|
79
|
+
iss,
|
|
80
|
+
exp: (0, date_1.expiresAt)(),
|
|
81
|
+
iat: (0, date_1.epochTime)(),
|
|
82
|
+
aud: audience,
|
|
83
|
+
gty: grant_type,
|
|
84
|
+
scope,
|
|
85
|
+
});
|
|
86
|
+
exports.getBaseAccessToken = getBaseAccessToken;
|
|
87
|
+
const verifyUserExistsInStore = ({ people, body, grant_type, }) => {
|
|
88
|
+
let { code } = body;
|
|
89
|
+
let personQuery = (0, utils_1.createPersonQuery)(people);
|
|
90
|
+
let nonce;
|
|
91
|
+
let username;
|
|
92
|
+
let password;
|
|
93
|
+
if (grant_type === 'password') {
|
|
94
|
+
username = body.username;
|
|
95
|
+
password = body.password;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// specifically grant_type === 'authorization_code'
|
|
99
|
+
// but naively using it to handle other cases at the moment
|
|
100
|
+
(0, assert_ts_1.assert)(typeof code !== 'undefined', '400::no code in /oauth/token');
|
|
101
|
+
[nonce, username] = (0, base64_url_1.decode)(code).split(':');
|
|
102
|
+
}
|
|
103
|
+
(0, assert_ts_1.assert)(!!username, `400::no nonce in store for ${code}`);
|
|
104
|
+
let user = personQuery((person) => {
|
|
105
|
+
(0, assert_ts_1.assert)(!!person.email, `500::no email defined on person scenario`);
|
|
106
|
+
let valid = person.email.toLowerCase() === username.toLowerCase();
|
|
107
|
+
if (typeof password === 'undefined') {
|
|
108
|
+
return valid;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return valid && password === person.password;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
(0, assert_ts_1.assert)(!!user, '401::Unauthorized');
|
|
115
|
+
return { user, nonce };
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=oauth-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-handlers.js","sourceRoot":"","sources":["../../src/handlers/oauth-handlers.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AACnC,2CAAoD;AACpD,uCAAoD;AACpD,qCAAiD;AACjD,wDAA0D;AAC1D,mCAAyD;AAYlD,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,IAAI,E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C,OAAO,KAAK,CAAC;SACd;aAAM;YACL,OAAO,KAAK,IAAI,QAAQ,KAAK,MAAM,CAAC,QAAQ,CAAC;SAC9C;IACH,CAAC,CAAC,CAAC;IAEH,IAAA,kBAAM,EAAC,CAAC,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;IAEpC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Person } from '@simulacrum/server';
|
|
2
|
+
import type { ScopeConfig } from '../types';
|
|
3
|
+
declare type Predicate<T> = (this: void, value: T, index: number, obj: T[]) => boolean;
|
|
4
|
+
export declare const createPersonQuery: (people: Iterable<Person>) => (predicate: Predicate<Person>) => Person | undefined;
|
|
5
|
+
export declare const deriveScope: ({ scopeConfig, clientID, audience, }: {
|
|
6
|
+
scopeConfig: ScopeConfig;
|
|
7
|
+
clientID: string;
|
|
8
|
+
audience: string;
|
|
9
|
+
}) => string;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/handlers/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,aAAK,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,OAAO,CAAC;AAE/E,eAAO,MAAM,iBAAiB,WACnB,SAAS,MAAM,CAAC,iBAAiB,UAAU,MAAM,CAAC,uBAE1D,CAAC;AAEJ,eAAO,MAAM,WAAW;iBAKT,WAAW;cACd,MAAM;cACN,MAAM;YAwCjB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deriveScope = exports.createPersonQuery = void 0;
|
|
4
|
+
const assert_ts_1 = require("assert-ts");
|
|
5
|
+
const createPersonQuery = (people) => (predicate) => {
|
|
6
|
+
return [...people].find(predicate);
|
|
7
|
+
};
|
|
8
|
+
exports.createPersonQuery = createPersonQuery;
|
|
9
|
+
const deriveScope = ({ scopeConfig, clientID, audience, }) => {
|
|
10
|
+
if (typeof scopeConfig === 'string')
|
|
11
|
+
return scopeConfig;
|
|
12
|
+
let defaultScope = scopeConfig.find((application) => application.clientID === 'default');
|
|
13
|
+
(0, assert_ts_1.assert)(!!clientID, `500::Did not have a clientID to derive the scope`);
|
|
14
|
+
let application = scopeConfig.find((application) => application.clientID === clientID &&
|
|
15
|
+
(application.audience ? application.audience === audience : true));
|
|
16
|
+
if (!application) {
|
|
17
|
+
let ignoreAudience = scopeConfig.find((application) => application.clientID === clientID);
|
|
18
|
+
(0, assert_ts_1.assert)(ignoreAudience === undefined, `500::Found application matching clientID, ${ignoreAudience === null || ignoreAudience === void 0 ? void 0 : ignoreAudience.clientID}, but incorrect audience, configured: ${ignoreAudience === null || ignoreAudience === void 0 ? void 0 : ignoreAudience.audience} :: passed: ${audience}`);
|
|
19
|
+
}
|
|
20
|
+
if (!application && defaultScope) {
|
|
21
|
+
application = defaultScope;
|
|
22
|
+
}
|
|
23
|
+
(0, assert_ts_1.assert)(!!application, `500::Could not find application with clientID: ${clientID}`);
|
|
24
|
+
(0, assert_ts_1.assert)(!!application.scope, `500::${application.clientID} is expected to have a scope`);
|
|
25
|
+
return application.scope;
|
|
26
|
+
};
|
|
27
|
+
exports.deriveScope = deriveScope;
|
|
28
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/handlers/utils.ts"],"names":[],"mappings":";;;AAAA,yCA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AC,CAAC,WAAW,EACb,kDAAkD,QAAQ,EAAE,CAC7D,CAAC;IAEF,IAAA,kBAAM,EACJ,CAAC,CAAC,WAAW,CAAC,KAAK,EACnB,QAAQ,WAAW,CAAC,QAAQ,8BAA8B,CAC3D,CAAC;IAEF,OAAO,WAAW,CAAC,KAAK,CAAC;AAC3B,CAAC,CAAC;AA/CW,QAAA,WAAW,eA+CtB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Person, Simulator } from '@simulacrum/server';
|
|
2
|
-
import { Operation } from 'effection';
|
|
2
|
+
import type { Operation } from 'effection';
|
|
3
3
|
import type { Auth0Store } from './handlers/auth0-handlers';
|
|
4
4
|
import type { Auth0Configuration } from './types';
|
|
5
5
|
export { getConfig } from './config/get-config';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAErF,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAErF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAK3C,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,2BAA2B,CAAC;AAOzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIhD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AA4CD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,SAAS,CAAC,MAAM,CAAC,CAyChF;AAED,eAAO,MAAM,KAAK,EAAE,SAanB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ const server_1 = require("@simulacrum/server");
|
|
|
27
27
|
const express_1 = __importStar(require("express"));
|
|
28
28
|
const path_1 = __importDefault(require("path"));
|
|
29
29
|
const get_config_1 = require("./config/get-config");
|
|
30
|
+
const error_handling_middleware_1 = require("./error-handling-middleware");
|
|
30
31
|
const auth0_handlers_1 = require("./handlers/auth0-handlers");
|
|
31
32
|
const get_service_url_1 = require("./handlers/get-service-url");
|
|
32
33
|
const openid_handlers_1 = require("./handlers/openid-handlers");
|
|
@@ -74,7 +75,7 @@ const createAuth0Service = (slice, options) => ({
|
|
|
74
75
|
});
|
|
75
76
|
function createAuth0Server(options) {
|
|
76
77
|
let { config, serviceURL, store, people, port, debug = true } = options;
|
|
77
|
-
let auth0 = (0, auth0_handlers_1.createAuth0Handlers)(store, people, serviceURL, config);
|
|
78
|
+
let auth0 = (0, auth0_handlers_1.createAuth0Handlers)(store, people, serviceURL, config, debug);
|
|
78
79
|
let openid = (0, openid_handlers_1.createOpenIdHandlers)(serviceURL);
|
|
79
80
|
return {
|
|
80
81
|
name: 'Auth0Server',
|
|
@@ -100,6 +101,8 @@ function createAuth0Server(options) {
|
|
|
100
101
|
if (debug) {
|
|
101
102
|
app.use(server_1.consoleLogger);
|
|
102
103
|
}
|
|
104
|
+
// needs to be the last middleware added
|
|
105
|
+
app.use(error_handling_middleware_1.defaultErrorHandler);
|
|
103
106
|
let server = yield (0, server_1.createServer)(app, { protocol: 'https', port });
|
|
104
107
|
return {
|
|
105
108
|
port: server.address.port
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAyE;AAEzE,mDAAoD;AACpD,gDAAwB;AACxB,oDAAgD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,+CAAyE;AAEzE,mDAAoD;AACpD,gDAAwB;AACxB,oDAAgD;AAChD,2EAAkE;AAElE,8DAAgE;AAChE,gEAA2D;AAC3D,gEAAkE;AAClE,0DAAsD;AACtD,oDAAgD;AAChD,kDAAqD;AAGrD,kDAAgD;AAAvC,uGAAA,SAAS,OAAA;AAElB,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAe1D,MAAM,kBAAkB,GAA2B,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IACtE,IAAI,EAAE,cAAc;IACpB,CAAC,IAAI;QACH,IAAI,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;QACzC,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QACvB,IAAI,MAAM,GAAG,IAAA,sBAAS,EAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;QAEtE,IAAI,UAAU,GAAG,GAAG,EAAE,CAAC,IAAA,+BAAa,EAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QAElD,IAAI,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC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AG,CAAC,+CAAmB,CAAC,CAAC;YAE7B,IAAI,MAAM,GAAG,MAAM,IAAA,qBAAY,EAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YAElE,OAAO;gBACL,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI;aAC1B,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAzCD,8CAyCC;AAEM,MAAM,KAAK,GAAc,GAAG,EAAE;IACnC,OAAO;QACL,QAAQ,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE;QACvC,SAAS,EAAE;YACT;;;;;eAKG;YACH,MAAM,EAAN,eAAM;SACP;KACF,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,KAAK,SAahB"}
|
package/dist/rules/types.d.ts
CHANGED
|
@@ -13,7 +13,14 @@ export interface RuleUser {
|
|
|
13
13
|
given_name?: string | undefined;
|
|
14
14
|
family_name?: string | undefined;
|
|
15
15
|
name?: string | undefined;
|
|
16
|
+
identities: IdentityProvider[] | undefined;
|
|
16
17
|
}
|
|
18
|
+
declare type IdentityProvider = {
|
|
19
|
+
provider: string;
|
|
20
|
+
user_id: string;
|
|
21
|
+
connection: string;
|
|
22
|
+
isSocial: boolean;
|
|
23
|
+
};
|
|
17
24
|
export interface RuleContext<A, I> {
|
|
18
25
|
clientID: string;
|
|
19
26
|
accessToken: {
|
|
@@ -25,4 +32,5 @@ export interface Rule {
|
|
|
25
32
|
code: string;
|
|
26
33
|
filename: string;
|
|
27
34
|
}
|
|
35
|
+
export {};
|
|
28
36
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/rules/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CA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AC;IACrC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,EAAE,gBAAgB,EAAE,GAAG,SAAS,CAAC;CAC5C;AAED,aAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,WAAW,CAAC,CAAC,EAAE,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KAC1B,GAAG,CAAC,CAAC;IAEN,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,7 +4,19 @@ export declare const configurationSchema: z.ZodObject<{
|
|
|
4
4
|
domain: z.ZodOptional<z.ZodString>;
|
|
5
5
|
audience: z.ZodOptional<z.ZodString>;
|
|
6
6
|
clientID: z.ZodOptional<z.ZodString>;
|
|
7
|
-
scope: z.ZodString
|
|
7
|
+
scope: z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodObject<{
|
|
8
|
+
clientID: z.ZodString;
|
|
9
|
+
audience: z.ZodOptional<z.ZodString>;
|
|
10
|
+
scope: z.ZodString;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
audience?: string | undefined;
|
|
13
|
+
clientID: string;
|
|
14
|
+
scope: string;
|
|
15
|
+
}, {
|
|
16
|
+
audience?: string | undefined;
|
|
17
|
+
clientID: string;
|
|
18
|
+
scope: string;
|
|
19
|
+
}>, "many">]>;
|
|
8
20
|
clientSecret: z.ZodOptional<z.ZodString>;
|
|
9
21
|
rulesDirectory: z.ZodOptional<z.ZodString>;
|
|
10
22
|
auth0SessionCookieName: z.ZodOptional<z.ZodString>;
|
|
@@ -22,7 +34,11 @@ export declare const configurationSchema: z.ZodObject<{
|
|
|
22
34
|
auth0CookieSecret?: string | undefined;
|
|
23
35
|
connection?: string | undefined;
|
|
24
36
|
cookieSecret?: string | undefined;
|
|
25
|
-
scope: string
|
|
37
|
+
scope: string | {
|
|
38
|
+
audience?: string | undefined;
|
|
39
|
+
clientID: string;
|
|
40
|
+
scope: string;
|
|
41
|
+
}[];
|
|
26
42
|
}, {
|
|
27
43
|
port?: number | undefined;
|
|
28
44
|
domain?: string | undefined;
|
|
@@ -34,10 +50,20 @@ export declare const configurationSchema: z.ZodObject<{
|
|
|
34
50
|
auth0CookieSecret?: string | undefined;
|
|
35
51
|
connection?: string | undefined;
|
|
36
52
|
cookieSecret?: string | undefined;
|
|
37
|
-
scope: string
|
|
53
|
+
scope: string | {
|
|
54
|
+
audience?: string | undefined;
|
|
55
|
+
clientID: string;
|
|
56
|
+
scope: string;
|
|
57
|
+
}[];
|
|
38
58
|
}>;
|
|
39
59
|
export declare type Schema = z.infer<typeof configurationSchema>;
|
|
40
60
|
declare type ReadonlyFields = 'audience' | 'clientID' | 'scope' | 'port';
|
|
61
|
+
export declare type GrantType = 'password' | 'client_credentials' | 'authorization_code';
|
|
62
|
+
export declare type ScopeConfig = string | {
|
|
63
|
+
audience?: string;
|
|
64
|
+
clientID: string;
|
|
65
|
+
scope: string;
|
|
66
|
+
}[];
|
|
41
67
|
export declare type Auth0Configuration = Required<Pick<Schema, ReadonlyFields>> & Omit<Schema, ReadonlyFields>;
|
|
42
68
|
export declare type ResponseModes = 'query' | 'web_message';
|
|
43
69
|
export declare type QueryParams = {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.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IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IAEd,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,kBAAkB,CAAC;CAC7B"}
|
package/dist/types.js
CHANGED
|
@@ -4,11 +4,21 @@ exports.configurationSchema = void 0;
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
// TODO: better validation
|
|
6
6
|
exports.configurationSchema = zod_1.z.object({
|
|
7
|
-
port: zod_1.z.optional(zod_1.z
|
|
7
|
+
port: zod_1.z.optional(zod_1.z
|
|
8
|
+
.number()
|
|
9
|
+
.gt(2999, 'port must be greater than 2999')
|
|
10
|
+
.lt(10000, 'must be less than 10000')),
|
|
8
11
|
domain: zod_1.z.optional(zod_1.z.string().min(1, 'domain is required')),
|
|
9
|
-
audience: zod_1.z.optional(zod_1.z.string().min(1,
|
|
10
|
-
clientID: zod_1.z.optional(zod_1.z.string().max(32,
|
|
11
|
-
scope: zod_1.z.
|
|
12
|
+
audience: zod_1.z.optional(zod_1.z.string().min(1, 'audience is required')),
|
|
13
|
+
clientID: zod_1.z.optional(zod_1.z.string().max(32, 'must be 32 characters long')),
|
|
14
|
+
scope: zod_1.z.union([
|
|
15
|
+
zod_1.z.string().min(1, 'scope is required'),
|
|
16
|
+
zod_1.z.array(zod_1.z.object({
|
|
17
|
+
clientID: zod_1.z.string().max(32, 'must be 32 characters long'),
|
|
18
|
+
audience: zod_1.z.optional(zod_1.z.string().min(1, 'audience is required')),
|
|
19
|
+
scope: zod_1.z.string().min(1, 'scope is required'),
|
|
20
|
+
}))
|
|
21
|
+
]),
|
|
12
22
|
clientSecret: zod_1.z.optional(zod_1.z.string()),
|
|
13
23
|
rulesDirectory: zod_1.z.optional(zod_1.z.string()),
|
|
14
24
|
auth0SessionCookieName: zod_1.z.optional(zod_1.z.string()),
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,0BAA0B;AACb,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,OAAC,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,0BAA0B;AACb,QAAA,mBAAmB,GAAG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OAAC,CAAC,MAAM,EAAE,CAAC;IAC9C,iBAAiB,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;IACzC,UAAU,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;IAClC,YAAY,EAAE,OAAC,CAAC,QAAQ,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;CACrC,CAAC,CAAC"}
|
package/dist/views/login.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import type { ScopeConfig } from '../types';
|
|
1
2
|
interface LoginViewProps {
|
|
2
3
|
domain: string;
|
|
3
|
-
scope:
|
|
4
|
+
scope: ScopeConfig;
|
|
4
5
|
redirectUri: string;
|
|
5
6
|
clientID: string;
|
|
6
7
|
audience: string;
|
|
7
8
|
loginFailed: boolean;
|
|
8
9
|
}
|
|
9
|
-
export declare const loginView: ({ domain, scope, redirectUri, clientID, audience, loginFailed }: LoginViewProps) => string;
|
|
10
|
+
export declare const loginView: ({ domain, scope: scopeConfig, redirectUri, clientID, audience, loginFailed }: LoginViewProps) => string;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=login.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/views/login.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/views/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,WAAW,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,SAAS,iFAOnB,cAAc,KAAG,MAyFnB,CAAC"}
|
package/dist/views/login.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loginView = void 0;
|
|
4
|
+
const utils_1 = require("../handlers/utils");
|
|
4
5
|
const html = String.raw;
|
|
5
|
-
const loginView = ({ domain, scope, redirectUri, clientID, audience, loginFailed = false }) => {
|
|
6
|
+
const loginView = ({ domain, scope: scopeConfig, redirectUri, clientID, audience, loginFailed = false }) => {
|
|
6
7
|
return html `
|
|
7
8
|
<html lang="en">
|
|
8
9
|
<head>
|
|
@@ -37,7 +38,7 @@ const loginView = ({ domain, scope, redirectUri, clientID, audience, loginFailed
|
|
|
37
38
|
<div class="error bg-red-500 text-white p-3 ${loginFailed ? '' : 'hidden'}">Wrong email or password</div>
|
|
38
39
|
|
|
39
40
|
<div>
|
|
40
|
-
<button id="submit" type="
|
|
41
|
+
<button id="submit" type="submit" class="group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
|
41
42
|
<span class="absolute left-0 inset-y-0 flex items-center pl-3">
|
|
42
43
|
<svg class="h-5 w-5 text-blue-500 group-hover:text-blue-400" x-description="Heroicon name: solid/lock-closed" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
|
43
44
|
<path fill-rule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clip-rule="evenodd"></path>
|
|
@@ -59,9 +60,10 @@ const loginView = ({ domain, scope, redirectUri, clientID, audience, loginFailed
|
|
|
59
60
|
responseType: 'token id_token',
|
|
60
61
|
});
|
|
61
62
|
var form = document.querySelector('#the-form');
|
|
62
|
-
var button = document.querySelector('#sumbit');
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
form.addEventListener('submit', function(e) {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
event.stopPropagation()
|
|
65
67
|
let params = new URLSearchParams(window.location.search);
|
|
66
68
|
|
|
67
69
|
var username = document.querySelector('#username');
|
|
@@ -72,7 +74,7 @@ const loginView = ({ domain, scope, redirectUri, clientID, audience, loginFailed
|
|
|
72
74
|
username: username.value,
|
|
73
75
|
password: password.value,
|
|
74
76
|
realm: 'Username-Password-Authentication',
|
|
75
|
-
scope: '${
|
|
77
|
+
scope: '${(0, utils_1.deriveScope)({ scopeConfig, clientID, audience })}',
|
|
76
78
|
nonce: params.get('nonce'),
|
|
77
79
|
state: params.get('state')
|
|
78
80
|
},
|
package/dist/views/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/views/login.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/views/login.ts"],"names":[],"mappings":";;;AACA,6CAAgD;AAChD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC;AAWjB,MAAM,SAAS,GAAG,CAAC,EACxB,MAAM,EACN,KAAK,EAAE,WAAW,EAClB,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,WAAW,GAAG,KAAK,EACJ,EAAU,EAAE;IAC3B,OAAO,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;uHAwB0G,WAAW,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE;;;;iIAIzB,WAAW,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE;;;4DAGxG,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ;;;;;;;;;;;;;;;;;;yBAkB9D,MAAM;2BACJ,QAAQ;8BACL,WAAW;2BACd,QAAQ;;;;;;;;;;;;;;;;;;4BAkBP,IAAA,mBAAW,EAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;;;;;;;;;;;;;;;;;GAiBzE,CAAC;AACJ,CAAC,CAAC;AAhGW,QAAA,SAAS,aAgGpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simulacrum/auth0-simulator",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Run local instance of Auth0 API for local development and integration testing",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": "bin/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@effection/process": "^2.0.1",
|
|
42
42
|
"@simulacrum/client": "0.5.4",
|
|
43
|
-
"@simulacrum/server": "0.6.
|
|
43
|
+
"@simulacrum/server": "0.6.3",
|
|
44
44
|
"@types/faker": "^5.1.7",
|
|
45
45
|
"assert-ts": "^0.3.2",
|
|
46
46
|
"base64-url": "^2.3.3",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"keygrip": "^1.1.0",
|
|
73
73
|
"mocha": "^8.0.0",
|
|
74
74
|
"rimraf": "^3.0.2",
|
|
75
|
-
"ts-node": "^9.1
|
|
75
|
+
"ts-node": "^10.9.1",
|
|
76
76
|
"ws": "^7.4.4"
|
|
77
77
|
},
|
|
78
78
|
"volta": {
|