@simulacrum/auth0-simulator 0.2.2 → 0.4.1
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 +35 -0
- package/README.md +6 -6
- package/dist/auth/date.js +1 -1
- package/dist/auth/date.js.map +1 -1
- package/dist/auth/jwt.d.ts +1 -1
- package/dist/auth/jwt.d.ts.map +1 -1
- package/dist/auth/jwt.js +5 -4
- package/dist/auth/jwt.js.map +1 -1
- 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 +86 -35
- package/dist/handlers/auth0-handlers.js.map +1 -1
- package/dist/handlers/get-service-url.js +1 -1
- package/dist/handlers/get-service-url.js.map +1 -1
- package/dist/handlers/login-redirect.js +1 -1
- package/dist/handlers/login-redirect.js.map +1 -1
- package/dist/handlers/openid-handlers.js +2 -2
- package/dist/handlers/openid-handlers.js.map +1 -1
- package/dist/handlers/web-message.js +4 -4
- package/dist/handlers/web-message.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -24
- package/dist/index.js.map +1 -1
- package/dist/middleware/create-cors.js +1 -1
- package/dist/middleware/create-cors.js.map +1 -1
- package/dist/middleware/session.js +1 -1
- package/dist/middleware/session.js.map +1 -1
- package/dist/rules/parse-rules-files.js +2 -2
- package/dist/rules/parse-rules-files.js.map +1 -1
- package/dist/rules/rules-runner.js +3 -3
- package/dist/rules/rules-runner.js.map +1 -1
- package/dist/start.js +4 -4
- package/dist/start.js.map +1 -1
- package/dist/types.d.ts +22 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/views/login.d.ts +2 -2
- package/dist/views/login.js +3 -3
- package/dist/views/username-password.js +1 -1
- package/dist/views/username-password.js.map +1 -1
- package/dist/views/web-message.js +1 -1
- package/dist/views/web-message.js.map +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## \[0.4.1]
|
|
4
|
+
|
|
5
|
+
- Simplify createSimulation and destroySimulation by removing them from the effects.
|
|
6
|
+
- Bumped due to a bump in @simulacrum/server.
|
|
7
|
+
- [04d5aaf](https://github.com/thefrontside/simulacrum/commit/04d5aaf0077d744badd8739936aad328156d64e2) Simplify createSimulation and destroySimulation ([#174](https://github.com/thefrontside/simulacrum/pull/174)) on 2022-01-19
|
|
8
|
+
- wait for simulation to be destroyed before creating a new one
|
|
9
|
+
- Bumped due to a bump in @simulacrum/server.
|
|
10
|
+
- [b1412da](https://github.com/thefrontside/simulacrum/commit/b1412daa2d7846ec4c8eefeea2dfbf94e19b7261) wait for simulation to be destroyed before creating a new one ([#171](https://github.com/thefrontside/simulacrum/pull/171)) on 2022-01-18
|
|
11
|
+
|
|
12
|
+
## \[0.4.0]
|
|
13
|
+
|
|
14
|
+
- Enable @simulacrum/auth0-cypress to run against nextjs-auth0.
|
|
15
|
+
- [79a6f11](https://github.com/thefrontside/simulacrum/commit/79a6f11e6a5d516314182d5466f0d9657465c92e) Get user tokens ([#162](https://github.com/thefrontside/simulacrum/pull/162)) on 2022-01-04
|
|
16
|
+
- Update eslint-config and typescript versions
|
|
17
|
+
- [f852573](https://github.com/thefrontside/simulacrum/commit/f852573daefaf3da2675b1233c3c2db38a2b43ba) update eslint-config and typescript on 2021-10-26
|
|
18
|
+
|
|
19
|
+
## \[0.3.0]
|
|
20
|
+
|
|
21
|
+
- Add @simulacrum/auth0-cypress package
|
|
22
|
+
- [cb1ce68](https://github.com/thefrontside/simulacrum/commit/cb1ce68e6892532e1a4da82f736baaefe5ea2c09) update config.json on 2021-08-04
|
|
23
|
+
- [d0d2b33](https://github.com/thefrontside/simulacrum/commit/d0d2b33be40aaec3c2496a2439f9b3539df3b081) fix changes file auth0 reference on 2021-08-09
|
|
24
|
+
- [5ddc11e](https://github.com/thefrontside/simulacrum/commit/5ddc11e8a533241b4db3883595e0b2badcd05a9c) rename remaining cypress-auth0 => auth0-cypress on 2021-08-12
|
|
25
|
+
- Upgrade to effection 2.0
|
|
26
|
+
- [993857e](https://github.com/thefrontside/simulacrum/commit/993857e98b2d74a2cfbca255c5b82573f2db7a80) Upgrade to Effection 2.0 on 2021-10-12
|
|
27
|
+
- - [d0f1cc1](https://github.com/thefrontside/simulacrum/commit/d0f1cc192fd1266bbb1eef2e644f8042546e060b) Upgrade effection to latest buffer / stream APIs on 2021-09-30
|
|
28
|
+
- Upgrade effection to 2.0.0-beta.15
|
|
29
|
+
- [938e9bf](https://github.com/thefrontside/simulacrum/commit/938e9bfcabfcdc5806ecba01a909432b3de29971) Upgrade effection on 2021-09-07
|
|
30
|
+
|
|
31
|
+
## \[0.2.3]
|
|
32
|
+
|
|
33
|
+
- Increment all of the `effection` and related `@effection` packages. There was an issue in `@effection/core` with `dist` assets and this ensures it won't exist in the user's lock file.
|
|
34
|
+
- [30d575b](https://github.com/thefrontside/simulacrum/commit/30d575bc652a5329d67568b013f657691d1d86b6) upgrade past @effection/core dist issue on 2021-08-13
|
|
35
|
+
- Add bin script to auth0-simulator so it can be started via npx.
|
|
36
|
+
- [88292f4](https://github.com/thefrontside/simulacrum/commit/88292f4f7f0f73ad8832943abcf342d7756fa2b5) add bin script to enable npx auth0-simulator via [#113](https://github.com/thefrontside/simulacrum/pull/113) on 2021-08-16
|
|
37
|
+
|
|
3
38
|
## \[0.2.2]
|
|
4
39
|
|
|
5
40
|
- Fix bug where person scenario was not passing parameters down
|
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ mutation CreateSimulation {
|
|
|
44
44
|
options:{
|
|
45
45
|
audience: "[your audience]",
|
|
46
46
|
scope: "[your scope]",
|
|
47
|
-
|
|
47
|
+
clientID: "[your client-id]"
|
|
48
48
|
},
|
|
49
49
|
services:{
|
|
50
50
|
auth0:{
|
|
@@ -71,7 +71,7 @@ Use the values returned from the query to update your configuration in the clien
|
|
|
71
71
|
```json
|
|
72
72
|
{
|
|
73
73
|
"domain": "localhost:4400",
|
|
74
|
-
"
|
|
74
|
+
"clientID": "00000000000000000000000000000000",
|
|
75
75
|
"audience": "https://your-audience/"
|
|
76
76
|
}
|
|
77
77
|
```
|
|
@@ -128,7 +128,7 @@ main(function* () {
|
|
|
128
128
|
options: {
|
|
129
129
|
audience: "[your audience]",
|
|
130
130
|
scope: "[your scope]",
|
|
131
|
-
|
|
131
|
+
clientID: "[your client-id]",
|
|
132
132
|
},
|
|
133
133
|
services: {
|
|
134
134
|
auth0: {
|
|
@@ -182,8 +182,8 @@ async function setupClient({ url }) {
|
|
|
182
182
|
let simulation = await client.createSimulation("auth0", {
|
|
183
183
|
options: {
|
|
184
184
|
audience: "https://your-audience/",
|
|
185
|
-
scope: "openid profile
|
|
186
|
-
|
|
185
|
+
scope: "openid profile email offline_access",
|
|
186
|
+
clientID: "YOUR_AUTH0_CLIENT_ID",
|
|
187
187
|
},
|
|
188
188
|
services: {
|
|
189
189
|
auth0: {
|
|
@@ -213,7 +213,7 @@ let simulation = yield client.createSimulation("auth0", {
|
|
|
213
213
|
options: {
|
|
214
214
|
audience: "[your audience]",
|
|
215
215
|
scope: "[your scope]",
|
|
216
|
-
|
|
216
|
+
clientID: "[your client-id]",
|
|
217
217
|
rulesDirectory: "test/rules",
|
|
218
218
|
},
|
|
219
219
|
services: {
|
package/dist/auth/date.js
CHANGED
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.expiresAt = exports.epochTime = void 0;
|
|
4
4
|
const epochTime = (date = Date.now()) => Math.floor(date / 1000);
|
|
5
5
|
exports.epochTime = epochTime;
|
|
6
|
-
const expiresAt = (hours = 1) => exports.epochTime() + hours * 60 * 60 * 1000;
|
|
6
|
+
const expiresAt = (hours = 1) => (0, exports.epochTime)() + hours * 60 * 60 * 1000;
|
|
7
7
|
exports.expiresAt = expiresAt;
|
|
8
8
|
//# sourceMappingURL=date.js.map
|
package/dist/auth/date.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/auth/date.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAAnE,QAAA,SAAS,aAA0D;AAEzE,MAAM,SAAS,GAAG,CAAC,KAAK,GAAG,CAAC,EAAU,EAAE,CAC7C,iBAAS,
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/auth/date.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;AAAnE,QAAA,SAAS,aAA0D;AAEzE,MAAM,SAAS,GAAG,CAAC,KAAK,GAAG,CAAC,EAAU,EAAE,CAC7C,IAAA,iBAAS,GAAE,GAAG,KAAK,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAD1B,QAAA,SAAS,aACiB"}
|
package/dist/auth/jwt.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SignOptions } from "jsonwebtoken";
|
|
2
2
|
export declare const parseKey: (key: string) => string;
|
|
3
3
|
export declare const createJsonWebToken: (payload: Record<string, unknown>, privateKey?: string, options?: SignOptions) => string;
|
|
4
|
-
export declare function createAuthJWT(authNamespace: string, audience: string): string;
|
|
4
|
+
export declare function createAuthJWT(authNamespace: string, audience: string, sub: string): string;
|
|
5
5
|
//# sourceMappingURL=jwt.d.ts.map
|
package/dist/auth/jwt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/auth/jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,WAAW,EAAE,MAAM,cAAc,CAAC;AAGjD,eAAO,MAAM,QAAQ,QAAS,MAAM,KAAG,MAAoC,CAAC;AAE5E,eAAO,MAAM,kBAAkB,YACpB,OAAO,MAAM,EAAE,OAAO,CAAC,iCAEvB,WAAW,KAInB,MAEF,CAAC;AAEF,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../../src/auth/jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,WAAW,EAAE,MAAM,cAAc,CAAC;AAGjD,eAAO,MAAM,QAAQ,QAAS,MAAM,KAAG,MAAoC,CAAC;AAE5E,eAAO,MAAM,kBAAkB,YACpB,OAAO,MAAM,EAAE,OAAO,CAAC,iCAEvB,WAAW,KAInB,MAEF,CAAC;AAEF,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAO1F"}
|
package/dist/auth/jwt.js
CHANGED
|
@@ -5,18 +5,19 @@ const jsonwebtoken_1 = require("jsonwebtoken");
|
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
const parseKey = (key) => key.split("~~").join("\n");
|
|
7
7
|
exports.parseKey = parseKey;
|
|
8
|
-
const createJsonWebToken = (payload, privateKey = exports.parseKey(constants_1.PRIVATE_KEY), options = {
|
|
8
|
+
const createJsonWebToken = (payload, privateKey = (0, exports.parseKey)(constants_1.PRIVATE_KEY), options = {
|
|
9
9
|
algorithm: "RS256",
|
|
10
10
|
keyid: constants_1.JWKS.keys[0].kid,
|
|
11
11
|
}) => {
|
|
12
|
-
return jsonwebtoken_1.sign(payload, privateKey, options);
|
|
12
|
+
return (0, jsonwebtoken_1.sign)(payload, privateKey, options);
|
|
13
13
|
};
|
|
14
14
|
exports.createJsonWebToken = createJsonWebToken;
|
|
15
|
-
function createAuthJWT(authNamespace, audience) {
|
|
16
|
-
return exports.createJsonWebToken({
|
|
15
|
+
function createAuthJWT(authNamespace, audience, sub) {
|
|
16
|
+
return (0, exports.createJsonWebToken)({
|
|
17
17
|
[`${authNamespace}`]: 'decorate token',
|
|
18
18
|
aud: audience,
|
|
19
19
|
iss: authNamespace,
|
|
20
|
+
sub,
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
exports.createAuthJWT = createAuthJWT;
|
package/dist/auth/jwt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../src/auth/jwt.ts"],"names":[],"mappings":";;;AAAA,+CAAiD;AACjD,2CAAgD;AAEzC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAA/D,QAAA,QAAQ,YAAuD;AAErE,MAAM,kBAAkB,GAAG,CAChC,OAAgC,EAChC,UAAU,GAAG,gBAAQ,
|
|
1
|
+
{"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../src/auth/jwt.ts"],"names":[],"mappings":";;;AAAA,+CAAiD;AACjD,2CAAgD;AAEzC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAA/D,QAAA,QAAQ,YAAuD;AAErE,MAAM,kBAAkB,GAAG,CAChC,OAAgC,EAChC,UAAU,GAAG,IAAA,gBAAQ,EAAC,uBAAW,CAAC,EAClC,UAAuB;IACrB,SAAS,EAAE,OAAO;IAClB,KAAK,EAAE,gBAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG;CACxB,EACO,EAAE;IACV,OAAO,IAAA,mBAAI,EAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC,CAAC;AATW,QAAA,kBAAkB,sBAS7B;AAEF,SAAgB,aAAa,CAAC,aAAqB,EAAE,QAAgB,EAAE,GAAW;IAChF,OAAO,IAAA,0BAAkB,EAAC;QACxB,CAAC,GAAG,aAAa,EAAE,CAAC,EAAE,gBAAgB;QACtC,GAAG,EAAE,QAAQ;QACb,GAAG,EAAE,aAAa;QAClB,GAAG;KACJ,CAAC,CAAC;AACL,CAAC;AAPD,sCAOC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpHandler } from '@simulacrum/server';
|
|
2
2
|
import { Options } from '../types';
|
|
3
|
-
export declare type Routes = '/heartbeat' | '/authorize' | '/login' | '/usernamepassword/login' | '/login/callback' | '/oauth/token' | '/v2/logout';
|
|
3
|
+
export declare type Routes = '/heartbeat' | '/authorize' | '/login' | '/usernamepassword/login' | '/login/callback' | '/oauth/token' | '/v2/logout' | '/userinfo';
|
|
4
4
|
export declare const createAuth0Handlers: (options: Options) => Record<Routes, HttpHandler>;
|
|
5
5
|
//# 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,EAAE,WAAW,EAA6B,MAAM,oBAAoB,CAAC;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"auth0-handlers.d.ts","sourceRoot":"","sources":["../../src/handlers/auth0-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA6B,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAe,OAAO,EAA8B,MAAM,UAAU,CAAC;AAe5E,oBAAY,MAAM,GACd,YAAY,GACZ,YAAY,GACZ,QAAQ,GACR,yBAAyB,GACzB,iBAAiB,GACjB,cAAc,GACd,YAAY,GACZ,WAAW,CAAA;AAyBf,eAAO,MAAM,mBAAmB,YAAa,OAAO,KAAG,OAAO,MAAM,EAAE,WAAW,CA0OhF,CAAC"}
|
|
@@ -12,9 +12,10 @@ const date_1 = require("../auth/date");
|
|
|
12
12
|
const jwt_1 = require("../auth/jwt");
|
|
13
13
|
const get_service_url_1 = require("./get-service-url");
|
|
14
14
|
const rules_runner_1 = require("../rules/rules-runner");
|
|
15
|
+
const jsonwebtoken_1 = require("jsonwebtoken");
|
|
15
16
|
const getServiceUrlFromOptions = (options) => {
|
|
16
17
|
let service = options.services.get().find(({ name }) => name === 'auth0');
|
|
17
|
-
assert_ts_1.assert(!!service, `did not find auth0 service in set of running services`);
|
|
18
|
+
(0, assert_ts_1.assert)(!!service, `did not find auth0 service in set of running services`);
|
|
18
19
|
return new URL(service.url);
|
|
19
20
|
};
|
|
20
21
|
const createPersonQuery = (store) => (predicate) => {
|
|
@@ -30,12 +31,12 @@ const createPersonQuery = (store) => (predicate) => {
|
|
|
30
31
|
}
|
|
31
32
|
};
|
|
32
33
|
const createAuth0Handlers = (options) => {
|
|
33
|
-
let { audience, scope, store,
|
|
34
|
+
let { audience, scope, store, clientID, rulesDirectory } = options;
|
|
34
35
|
let personQuery = createPersonQuery(store);
|
|
35
|
-
let rulesRunner = rules_runner_1.createRulesRunner(rulesDirectory);
|
|
36
|
+
let rulesRunner = (0, rules_runner_1.createRulesRunner)(rulesDirectory);
|
|
36
37
|
let authorizeHandlers = {
|
|
37
|
-
query: login_redirect_1.createLoginRedirectHandler(options),
|
|
38
|
-
web_message: web_message_1.createWebMessageHandler()
|
|
38
|
+
query: (0, login_redirect_1.createLoginRedirectHandler)(options),
|
|
39
|
+
web_message: (0, web_message_1.createWebMessageHandler)()
|
|
39
40
|
};
|
|
40
41
|
return {
|
|
41
42
|
['/heartbeat']: function* (_, res) {
|
|
@@ -43,21 +44,28 @@ const createAuth0Handlers = (options) => {
|
|
|
43
44
|
},
|
|
44
45
|
['/authorize']: function* (req, res) {
|
|
45
46
|
var _a;
|
|
47
|
+
let currentUser = req.query.currentUser;
|
|
48
|
+
(0, assert_ts_1.assert)(!!req.session, "no session");
|
|
49
|
+
if (currentUser) {
|
|
50
|
+
// the request is a silent login.
|
|
51
|
+
// We fake an existing login by
|
|
52
|
+
// adding the user to the session
|
|
53
|
+
req.session.username = currentUser;
|
|
54
|
+
}
|
|
46
55
|
let responseMode = ((_a = req.query.response_mode) !== null && _a !== void 0 ? _a : 'query');
|
|
47
|
-
assert_ts_1.assert(['query', 'web_message'].includes(responseMode), `unknown response_mode ${responseMode}`);
|
|
56
|
+
(0, assert_ts_1.assert)(['query', 'web_message'].includes(responseMode), `unknown response_mode ${responseMode}`);
|
|
48
57
|
let handler = authorizeHandlers[responseMode];
|
|
49
58
|
yield handler(req, res);
|
|
50
|
-
return;
|
|
51
59
|
},
|
|
52
60
|
['/login']: function* (req, res) {
|
|
53
61
|
let { redirect_uri } = req.query;
|
|
54
|
-
let url = get_service_url_1.getServiceUrl(options);
|
|
55
|
-
assert_ts_1.assert(!!
|
|
56
|
-
let html = login_1.loginView({
|
|
62
|
+
let url = (0, get_service_url_1.getServiceUrl)(options);
|
|
63
|
+
(0, assert_ts_1.assert)(!!clientID, `no clientID assigned`);
|
|
64
|
+
let html = (0, login_1.loginView)({
|
|
57
65
|
domain: url.host,
|
|
58
66
|
scope,
|
|
59
67
|
redirectUri: redirect_uri,
|
|
60
|
-
|
|
68
|
+
clientID,
|
|
61
69
|
audience,
|
|
62
70
|
loginFailed: false
|
|
63
71
|
});
|
|
@@ -66,19 +74,19 @@ const createAuth0Handlers = (options) => {
|
|
|
66
74
|
},
|
|
67
75
|
['/usernamepassword/login']: function* (req, res) {
|
|
68
76
|
let { username, nonce, password } = req.body;
|
|
69
|
-
assert_ts_1.assert(!!username, 'no username in /usernamepassword/login');
|
|
70
|
-
assert_ts_1.assert(!!nonce, 'no nonce in /usernamepassword/login');
|
|
71
|
-
assert_ts_1.assert(!!req.session, "no session");
|
|
77
|
+
(0, assert_ts_1.assert)(!!username, 'no username in /usernamepassword/login');
|
|
78
|
+
(0, assert_ts_1.assert)(!!nonce, 'no nonce in /usernamepassword/login');
|
|
79
|
+
(0, assert_ts_1.assert)(!!req.session, "no session");
|
|
72
80
|
let user = personQuery(([, person]) => { var _a; return ((_a = person.email) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === username.toLowerCase() && person.password === password; });
|
|
73
81
|
if (!user) {
|
|
74
82
|
let { redirect_uri } = req.query;
|
|
75
83
|
let url = getServiceUrlFromOptions(options);
|
|
76
|
-
assert_ts_1.assert(!!
|
|
77
|
-
let html = login_1.loginView({
|
|
84
|
+
(0, assert_ts_1.assert)(!!clientID, `no clientID assigned`);
|
|
85
|
+
let html = (0, login_1.loginView)({
|
|
78
86
|
domain: url.host,
|
|
79
87
|
scope,
|
|
80
88
|
redirectUri: redirect_uri,
|
|
81
|
-
|
|
89
|
+
clientID,
|
|
82
90
|
audience,
|
|
83
91
|
loginFailed: true
|
|
84
92
|
});
|
|
@@ -93,27 +101,44 @@ const createAuth0Handlers = (options) => {
|
|
|
93
101
|
nonce
|
|
94
102
|
}
|
|
95
103
|
});
|
|
96
|
-
res.status(200).send(username_password_1.userNamePasswordForm(req.body));
|
|
104
|
+
res.status(200).send((0, username_password_1.userNamePasswordForm)(req.body));
|
|
97
105
|
},
|
|
98
106
|
['/login/callback']: function* (req, res) {
|
|
99
107
|
let wctx = JSON.parse(req.body.wctx);
|
|
100
108
|
let { redirect_uri, state, nonce } = wctx;
|
|
101
109
|
let { username } = store.slice('auth0', nonce).get();
|
|
102
|
-
let encodedNonce = base64_url_1.encode(`${nonce}:${username}`);
|
|
103
|
-
let qs = querystring_1.stringify({ code: encodedNonce, state, nonce });
|
|
110
|
+
let encodedNonce = (0, base64_url_1.encode)(`${nonce}:${username}`);
|
|
111
|
+
let qs = (0, querystring_1.stringify)({ code: encodedNonce, state, nonce });
|
|
104
112
|
let routerUrl = `${redirect_uri}?${qs}`;
|
|
105
|
-
|
|
113
|
+
res.status(302).redirect(routerUrl);
|
|
106
114
|
},
|
|
107
115
|
['/oauth/token']: function* (req, res) {
|
|
108
|
-
let { code } = req.body;
|
|
109
|
-
let
|
|
116
|
+
let { code, grant_type } = req.body;
|
|
117
|
+
let user;
|
|
118
|
+
let nonce;
|
|
119
|
+
let username;
|
|
120
|
+
let password;
|
|
121
|
+
if (grant_type === 'password') {
|
|
122
|
+
username = req.body.username;
|
|
123
|
+
password = req.body.password;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
(0, assert_ts_1.assert)(typeof code !== 'undefined', 'no code in /oauth/token');
|
|
127
|
+
[nonce, username] = (0, base64_url_1.decode)(code).split(":");
|
|
128
|
+
}
|
|
110
129
|
if (!username) {
|
|
111
130
|
res.status(400).send(`no nonce in store for ${code}`);
|
|
112
131
|
return;
|
|
113
132
|
}
|
|
114
|
-
|
|
115
|
-
assert_ts_1.assert(!!person.email, `no email defined on person scenario`);
|
|
116
|
-
|
|
133
|
+
user = personQuery(([, person]) => {
|
|
134
|
+
(0, assert_ts_1.assert)(!!person.email, `no email defined on person scenario`);
|
|
135
|
+
let valid = person.email.toLowerCase() === username.toLowerCase();
|
|
136
|
+
if (typeof password === 'undefined') {
|
|
137
|
+
return valid;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
return valid && password === person.password;
|
|
141
|
+
}
|
|
117
142
|
});
|
|
118
143
|
if (!user) {
|
|
119
144
|
res.status(401).send('Unauthorized');
|
|
@@ -124,32 +149,58 @@ const createAuth0Handlers = (options) => {
|
|
|
124
149
|
alg: "RS256",
|
|
125
150
|
typ: "JWT",
|
|
126
151
|
iss: url,
|
|
127
|
-
exp: date_1.expiresAt(),
|
|
152
|
+
exp: (0, date_1.expiresAt)(),
|
|
128
153
|
iat: Date.now(),
|
|
129
154
|
email: username,
|
|
130
|
-
aud:
|
|
155
|
+
aud: clientID,
|
|
131
156
|
sub: user.id,
|
|
132
|
-
nonce,
|
|
133
157
|
};
|
|
134
|
-
|
|
158
|
+
if (typeof nonce !== 'undefined') {
|
|
159
|
+
idTokenData.nonce = nonce;
|
|
160
|
+
}
|
|
161
|
+
(0, assert_ts_1.assert)(!!clientID, 'no clientID in options');
|
|
135
162
|
let accessToken = {
|
|
136
163
|
scope,
|
|
137
164
|
};
|
|
138
165
|
let userData = {};
|
|
139
|
-
let context = { clientID
|
|
166
|
+
let context = { clientID, accessToken, idToken: idTokenData };
|
|
140
167
|
rulesRunner(userData, context);
|
|
141
|
-
let idToken = jwt_1.createJsonWebToken({ ...userData, ...context.idToken, ...context.accessToken });
|
|
168
|
+
let idToken = (0, jwt_1.createJsonWebToken)({ ...userData, ...context.idToken, ...context.accessToken });
|
|
142
169
|
res.status(200).json({
|
|
143
|
-
access_token: jwt_1.createAuthJWT(url, audience),
|
|
170
|
+
access_token: (0, jwt_1.createAuthJWT)(url, audience, idTokenData.sub),
|
|
144
171
|
id_token: idToken,
|
|
145
172
|
expires_in: 86400,
|
|
146
173
|
token_type: "Bearer",
|
|
147
174
|
});
|
|
148
175
|
},
|
|
149
176
|
['/v2/logout']: function* (req, res) {
|
|
150
|
-
|
|
177
|
+
var _a;
|
|
151
178
|
req.session = null;
|
|
152
|
-
|
|
179
|
+
let returnToUrl = (_a = req.query.returnTo) !== null && _a !== void 0 ? _a : req.headers.referer;
|
|
180
|
+
(0, assert_ts_1.assert)(typeof returnToUrl === 'string', `no logical returnTo url`);
|
|
181
|
+
res.redirect(returnToUrl);
|
|
182
|
+
},
|
|
183
|
+
['/userinfo']: function* (req, res) {
|
|
184
|
+
let authorizationHeader = req.headers.authorization;
|
|
185
|
+
(0, assert_ts_1.assert)(!!authorizationHeader, 'no authorization header');
|
|
186
|
+
let [, token] = authorizationHeader.split(' ');
|
|
187
|
+
let { sub } = (0, jsonwebtoken_1.decode)(token, { json: true });
|
|
188
|
+
let user = personQuery(([, person]) => {
|
|
189
|
+
(0, assert_ts_1.assert)(!!person.id, `no email defined on person scenario`);
|
|
190
|
+
return person.id === sub;
|
|
191
|
+
});
|
|
192
|
+
(0, assert_ts_1.assert)(!!user, 'no user in /userinfo');
|
|
193
|
+
let userinfo = {
|
|
194
|
+
sub,
|
|
195
|
+
name: user.name,
|
|
196
|
+
given_name: user.name,
|
|
197
|
+
family_name: user.name,
|
|
198
|
+
email: user.email,
|
|
199
|
+
email_verified: true,
|
|
200
|
+
locale: 'en',
|
|
201
|
+
hd: 'okta.com'
|
|
202
|
+
};
|
|
203
|
+
res.status(200).json(userinfo);
|
|
153
204
|
}
|
|
154
205
|
};
|
|
155
206
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0-handlers.js","sourceRoot":"","sources":["../../src/handlers/auth0-handlers.ts"],"names":[],"mappings":";;;AAEA,qDAA8D;AAC9D,+CAAwD;AACxD,0CAA2C;AAC3C,yCAAmC;AACnC,6CAAwC;AACxC,2CAA4C;AAC5C,kEAAkE;AAClE,uCAAyC;AACzC,qCAAgE;AAChE,uDAAkD;AAClD,wDAA0D;
|
|
1
|
+
{"version":3,"file":"auth0-handlers.js","sourceRoot":"","sources":["../../src/handlers/auth0-handlers.ts"],"names":[],"mappings":";;;AAEA,qDAA8D;AAC9D,+CAAwD;AACxD,0CAA2C;AAC3C,yCAAmC;AACnC,6CAAwC;AACxC,2CAA4C;AAC5C,kEAAkE;AAClE,uCAAyC;AACzC,qCAAgE;AAChE,uDAAkD;AAClD,wDAA0D;AAE1D,+CAAqD;AAcrD,MAAM,wBAAwB,GAAG,CAAC,OAAgB,EAAE,EAAE;IACpD,IAAI,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,OAAO,CAAE,CAAC;IAC3E,IAAA,kBAAM,EAAC,CAAC,CAAC,OAAO,EAAE,uDAAuD,CAAC,CAAC;IAE3E,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,KAAY,EAAE,EAAE,CAAC,CAAC,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,IAAI,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC;YAEpD,IAAA,kBAAM,EAAC,CAAC,CAAC,mBAAmB,EAAE,yBAAyB,CAAC,CAAC;YAEzD,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,mBAAmB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAE/C,IAAI,EAAE,GAAG,EAAE,GAAG,IAAA,qBAAW,EAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAoB,CAAC;YAEpE,IAAI,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE;gBACpC,IAAA,kBAAM,EAAC,CAAC,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;aACd,CAAC;YAEH,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AA1OW,QAAA,mBAAmB,uBA0O9B"}
|
|
@@ -4,7 +4,7 @@ exports.getServiceUrl = void 0;
|
|
|
4
4
|
const assert_ts_1 = require("assert-ts");
|
|
5
5
|
const getServiceUrl = (options) => {
|
|
6
6
|
let service = options.services.get().find(({ name }) => name === 'auth0');
|
|
7
|
-
assert_ts_1.assert(!!service, `did not find auth0 service in set of running services`);
|
|
7
|
+
(0, assert_ts_1.assert)(!!service, `did not find auth0 service in set of running services`);
|
|
8
8
|
return new URL(service.url);
|
|
9
9
|
};
|
|
10
10
|
exports.getServiceUrl = getServiceUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-service-url.js","sourceRoot":"","sources":["../../src/handlers/get-service-url.ts"],"names":[],"mappings":";;;AACA,yCAAmC;AAE5B,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAO,EAAE;IACrD,IAAI,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,OAAO,CAAE,CAAC;IAE3E,kBAAM,
|
|
1
|
+
{"version":3,"file":"get-service-url.js","sourceRoot":"","sources":["../../src/handlers/get-service-url.ts"],"names":[],"mappings":";;;AACA,yCAAmC;AAE5B,MAAM,aAAa,GAAG,CAAC,OAAgB,EAAO,EAAE;IACrD,IAAI,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,OAAO,CAAE,CAAC;IAE3E,IAAA,kBAAM,EAAC,CAAC,CAAC,OAAO,EAAE,uDAAuD,CAAC,CAAC;IAE3E,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAC;AANW,QAAA,aAAa,iBAMxB"}
|
|
@@ -4,7 +4,7 @@ exports.createLoginRedirectHandler = void 0;
|
|
|
4
4
|
const querystring_1 = require("querystring");
|
|
5
5
|
const createLoginRedirectHandler = (options) => function* loginRedirect(req, res) {
|
|
6
6
|
let { client_id, redirect_uri, scope, state, nonce, response_mode, code_challenge, code_challenge_method, auth0Client, response_type, } = req.query;
|
|
7
|
-
res.status(302).redirect(`/login?${querystring_1.stringify({
|
|
7
|
+
res.status(302).redirect(`/login?${(0, querystring_1.stringify)({
|
|
8
8
|
state,
|
|
9
9
|
redirect_uri,
|
|
10
10
|
client: client_id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-redirect.js","sourceRoot":"","sources":["../../src/handlers/login-redirect.ts"],"names":[],"mappings":";;;AAEA,6CAAwC;AAGjC,MAAM,0BAA0B,GAAG,CAAC,OAAgB,EAAc,EAAE,CACzE,QAAQ,CAAC,CAAC,aAAa,CAAE,GAAY,EAAE,GAAa;IAClD,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,uBAAS,
|
|
1
|
+
{"version":3,"file":"login-redirect.js","sourceRoot":"","sources":["../../src/handlers/login-redirect.ts"],"names":[],"mappings":";;;AAEA,6CAAwC;AAGjC,MAAM,0BAA0B,GAAG,CAAC,OAAgB,EAAc,EAAE,CACzE,QAAQ,CAAC,CAAC,aAAa,CAAE,GAAY,EAAE,GAAa;IAClD,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;QACjB,QAAQ,EAAE,QAAQ;QAClB,KAAK;QACL,aAAa;QACb,aAAa;QACb,KAAK;QACL,cAAc;QACd,qBAAqB;QACrB,WAAW;QACX,QAAQ,EAAE,OAAO,CAAC,QAAQ;KAC3B,CAAC,EAAE,CACL,CAAC;AACJ,CAAC,CAAC;AA/BS,QAAA,0BAA0B,8BA+BnC"}
|
|
@@ -10,7 +10,7 @@ const createOpenIdHandlers = (options) => {
|
|
|
10
10
|
res.json(constants_1.JWKS);
|
|
11
11
|
},
|
|
12
12
|
['/.well-known/openid-configuration']: function* (_, res) {
|
|
13
|
-
let url = url_1.removeTrailingSlash(get_service_url_1.getServiceUrl(options).toString());
|
|
13
|
+
let url = (0, url_1.removeTrailingSlash)((0, get_service_url_1.getServiceUrl)(options).toString());
|
|
14
14
|
res.json({
|
|
15
15
|
issuer: `${url}/`,
|
|
16
16
|
authorization_endpoint: [url, "authorize"].join('/'),
|
|
@@ -18,7 +18,7 @@ const createOpenIdHandlers = (options) => {
|
|
|
18
18
|
userinfo_endpoint: [url, "userinfo"].join('/'),
|
|
19
19
|
jwks_uri: [url, ".well-known", "jwks.json"].join('/'),
|
|
20
20
|
});
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
exports.createOpenIdHandlers = createOpenIdHandlers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openid-handlers.js","sourceRoot":"","sources":["../../src/handlers/openid-handlers.ts"],"names":[],"mappings":";;;AAEA,iDAAyC;AACzC,uDAAkD;AAClD,+BAA4C;AAgBrC,MAAM,oBAAoB,GAAG,CAAC,OAAgB,EAAqC,EAAE;IAC1F,OAAO;QACL,CAAC,wBAAwB,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,GAAG;YAC3C,GAAG,CAAC,IAAI,CAAC,gBAAI,CAAC,CAAC;QACjB,CAAC;QAED,CAAC,mCAAmC,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,GAAG;YACtD,IAAI,GAAG,GAAG,yBAAmB,
|
|
1
|
+
{"version":3,"file":"openid-handlers.js","sourceRoot":"","sources":["../../src/handlers/openid-handlers.ts"],"names":[],"mappings":";;;AAEA,iDAAyC;AACzC,uDAAkD;AAClD,+BAA4C;AAgBrC,MAAM,oBAAoB,GAAG,CAAC,OAAgB,EAAqC,EAAE;IAC1F,OAAO;QACL,CAAC,wBAAwB,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,GAAG;YAC3C,GAAG,CAAC,IAAI,CAAC,gBAAI,CAAC,CAAC;QACjB,CAAC;QAED,CAAC,mCAAmC,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,GAAG;YACtD,IAAI,GAAG,GAAG,IAAA,yBAAmB,EAAC,IAAA,+BAAa,EAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEjE,GAAG,CAAC,IAAI,CAAC;gBACP,MAAM,EAAE,GAAG,GAAG,GAAG;gBACjB,sBAAsB,EAAE,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBACpD,cAAc,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBACjD,iBAAiB,EAAE,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBAC9C,QAAQ,EAAE,CAAC,GAAG,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;aACtD,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,oBAAoB,wBAkB/B"}
|
|
@@ -5,13 +5,13 @@ const assert_ts_1 = require("assert-ts");
|
|
|
5
5
|
const base64_url_1 = require("base64-url");
|
|
6
6
|
const web_message_1 = require("../views/web-message");
|
|
7
7
|
const createWebMessageHandler = () => function* (req, res) {
|
|
8
|
-
assert_ts_1.assert(!!req.session, "no session");
|
|
8
|
+
(0, assert_ts_1.assert)(!!req.session, "no session");
|
|
9
9
|
let username = req.session.username;
|
|
10
|
-
assert_ts_1.assert(!!username, `no username in authorise`);
|
|
10
|
+
(0, assert_ts_1.assert)(!!username, `no username in authorise`);
|
|
11
11
|
let { redirect_uri, state, nonce } = req.query;
|
|
12
12
|
res.set("Content-Type", "text/html");
|
|
13
|
-
let message = web_message_1.webMessage({
|
|
14
|
-
code: base64_url_1.encode(`${nonce}:${username}`),
|
|
13
|
+
let message = (0, web_message_1.webMessage)({
|
|
14
|
+
code: (0, base64_url_1.encode)(`${nonce}:${username}`),
|
|
15
15
|
state,
|
|
16
16
|
redirect_uri,
|
|
17
17
|
nonce,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-message.js","sourceRoot":"","sources":["../../src/handlers/web-message.ts"],"names":[],"mappings":";;;AACA,yCAAmC;AACnC,2CAAoC;AAEpC,sDAAkD;AAE3C,MAAM,uBAAuB,GAAG,GAAe,EAAE,CACtD,QAAQ,CAAC,EAAE,GAAG,EAAE,GAAG;IACjB,kBAAM,
|
|
1
|
+
{"version":3,"file":"web-message.js","sourceRoot":"","sources":["../../src/handlers/web-message.ts"],"names":[],"mappings":";;;AACA,yCAAmC;AACnC,2CAAoC;AAEpC,sDAAkD;AAE3C,MAAM,uBAAuB,GAAG,GAAe,EAAE,CACtD,QAAQ,CAAC,EAAE,GAAG,EAAE,GAAG;IACjB,IAAA,kBAAM,EAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAEpC,IAAI,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IAEpC,IAAA,kBAAM,EAAC,CAAC,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC;IAE/C,IAAI,EACF,YAAY,EACZ,KAAK,EACL,KAAK,EACN,GAAG,GAAG,CAAC,KAAoB,CAAC;IAE7B,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAErC,IAAI,OAAO,GAAG,IAAA,wBAAU,EAAC;QACvB,IAAI,EAAE,IAAA,mBAAM,EAAC,GAAG,KAAK,IAAI,QAAQ,EAAE,CAAC;QACpC,KAAK;QACL,YAAY;QACZ,KAAK;KACN,CAAC,CAAC;IAEH,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AAC7C,CAAC,CAAC;AAxBS,QAAA,uBAAuB,2BAwBhC"}
|
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,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAwB,MAAM,oBAAoB,CAAC;AAS1E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AA2ClC,eAAO,MAAM,KAAK,EAAE,SAAS,CAAC,OAAO,CAsBpC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,9 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.auth0 = void 0;
|
|
7
7
|
const server_1 = require("@simulacrum/server");
|
|
8
|
+
const server_2 = require("@simulacrum/server");
|
|
8
9
|
const express_1 = require("express");
|
|
9
10
|
const auth0_handlers_1 = require("./handlers/auth0-handlers");
|
|
10
|
-
const
|
|
11
|
+
const server_3 = require("@simulacrum/server");
|
|
11
12
|
const session_1 = require("./middleware/session");
|
|
12
13
|
const path_1 = __importDefault(require("path"));
|
|
13
14
|
const express_2 = __importDefault(require("express"));
|
|
@@ -16,40 +17,46 @@ const no_cache_1 = require("./middleware/no-cache");
|
|
|
16
17
|
const openid_handlers_1 = require("./handlers/openid-handlers");
|
|
17
18
|
const publicDir = path_1.default.join(__dirname, 'views', 'public');
|
|
18
19
|
const DefaultOptions = {
|
|
19
|
-
|
|
20
|
+
clientID: '00000000000000000000000000000000',
|
|
20
21
|
audience: 'https://thefrontside.auth0.com/api/v1/',
|
|
21
22
|
scope: "openid profile email offline_access",
|
|
22
23
|
};
|
|
23
|
-
const createAuth0Service = (handlers) => {
|
|
24
|
+
const createAuth0Service = (handlers, debug) => {
|
|
25
|
+
let app = (0, server_2.createHttpApp)()
|
|
26
|
+
.use(express_2.default.static(publicDir))
|
|
27
|
+
.use((0, session_1.createSession)())
|
|
28
|
+
.use((0, create_cors_1.createCors)())
|
|
29
|
+
.use((0, no_cache_1.noCache)())
|
|
30
|
+
.use((0, express_1.json)())
|
|
31
|
+
.use((0, express_1.urlencoded)({ extended: true }))
|
|
32
|
+
.get('/heartbeat', handlers['/heartbeat'])
|
|
33
|
+
.get('/authorize', handlers['/authorize'])
|
|
34
|
+
.get('/login', handlers['/login'])
|
|
35
|
+
.get('/u/login', handlers['/usernamepassword/login'])
|
|
36
|
+
.post('/usernamepassword/login', handlers['/usernamepassword/login'])
|
|
37
|
+
.post('/login/callback', handlers['/login/callback'])
|
|
38
|
+
.post('/oauth/token', handlers['/oauth/token'])
|
|
39
|
+
.get('/userinfo', handlers['/userinfo'])
|
|
40
|
+
.get('/v2/logout', handlers['/v2/logout'])
|
|
41
|
+
.get('/.well-known/jwks.json', handlers['/.well-known/jwks.json'])
|
|
42
|
+
.get('/.well-known/openid-configuration', handlers['/.well-known/openid-configuration']);
|
|
43
|
+
if (debug) {
|
|
44
|
+
app = app.use(server_1.consoleLogger);
|
|
45
|
+
}
|
|
24
46
|
return {
|
|
25
47
|
protocol: 'https',
|
|
26
|
-
app
|
|
27
|
-
.use(express_2.default.static(publicDir))
|
|
28
|
-
.use(session_1.createSession())
|
|
29
|
-
.use(create_cors_1.createCors())
|
|
30
|
-
.use(no_cache_1.noCache())
|
|
31
|
-
.use(express_1.json())
|
|
32
|
-
.use(express_1.urlencoded({ extended: true }))
|
|
33
|
-
.get('/heartbeat', handlers['/heartbeat'])
|
|
34
|
-
.get('/authorize', handlers['/authorize'])
|
|
35
|
-
.get('/login', handlers['/login'])
|
|
36
|
-
.get('/u/login', handlers['/usernamepassword/login'])
|
|
37
|
-
.post('/usernamepassword/login', handlers['/usernamepassword/login'])
|
|
38
|
-
.post('/login/callback', handlers['/login/callback'])
|
|
39
|
-
.post('/oauth/token', handlers['/oauth/token'])
|
|
40
|
-
.get('/v2/logout', handlers['/v2/logout'])
|
|
41
|
-
.get('/.well-known/jwks.json', handlers['/.well-known/jwks.json'])
|
|
42
|
-
.get('/.well-known/openid-configuration', handlers['/.well-known/openid-configuration'])
|
|
48
|
+
app
|
|
43
49
|
};
|
|
44
50
|
};
|
|
45
51
|
const auth0 = (slice, options) => {
|
|
46
52
|
let store = slice.slice('store');
|
|
47
53
|
let services = slice.slice('services');
|
|
54
|
+
let debug = !!slice.slice('debug').get();
|
|
48
55
|
let handlersOptions = { ...DefaultOptions, ...options, store, services };
|
|
49
|
-
let auth0Handlers = auth0_handlers_1.createAuth0Handlers(handlersOptions);
|
|
50
|
-
let openIdHandlers = openid_handlers_1.createOpenIdHandlers(handlersOptions);
|
|
56
|
+
let auth0Handlers = (0, auth0_handlers_1.createAuth0Handlers)(handlersOptions);
|
|
57
|
+
let openIdHandlers = (0, openid_handlers_1.createOpenIdHandlers)(handlersOptions);
|
|
51
58
|
return {
|
|
52
|
-
services: { auth0: createAuth0Service({ ...auth0Handlers, ...openIdHandlers }) },
|
|
59
|
+
services: { auth0: createAuth0Service({ ...auth0Handlers, ...openIdHandlers }, debug) },
|
|
53
60
|
scenarios: {
|
|
54
61
|
/**
|
|
55
62
|
* Here we just export the internal `person` scenario so that it can be
|
|
@@ -57,7 +64,7 @@ const auth0 = (slice, options) => {
|
|
|
57
64
|
* what we really need to have some way to _react_ to the person
|
|
58
65
|
* having been created and augment the record at that point.
|
|
59
66
|
*/
|
|
60
|
-
person:
|
|
67
|
+
person: server_3.person
|
|
61
68
|
}
|
|
62
69
|
};
|
|
63
70
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,+CAAmD;AACnD,qCAA2C;AAC3C,8DAAgE;AAChE,+CAA4C;AAC5C,kDAAqD;AACrD,gDAAwB;AACxB,sDAA8B;AAE9B,0DAAsD;AACtD,oDAAgD;AAChD,gEAAkE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,+CAAmD;AACnD,+CAAmD;AACnD,qCAA2C;AAC3C,8DAAgE;AAChE,+CAA4C;AAC5C,kDAAqD;AACrD,gDAAwB;AACxB,sDAA8B;AAE9B,0DAAsD;AACtD,oDAAgD;AAChD,gEAAkE;AAElE,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAE1D,MAAM,cAAc,GAAG;IACrB,QAAQ,EAAE,kCAAkC;IAC5C,QAAQ,EAAE,wCAAwC;IAClD,KAAK,EAAE,qCAAqC;CAC7C,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,QAA0F,EAAE,KAAc,EAAwB,EAAE;IAC9J,IAAI,GAAG,GAAG,IAAA,sBAAa,GAAE;SACtB,GAAG,CAAC,iBAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;SAC9B,GAAG,CAAC,IAAA,uBAAa,GAAE,CAAC;SACpB,GAAG,CAAC,IAAA,wBAAU,GAAE,CAAC;SACjB,GAAG,CAAC,IAAA,kBAAO,GAAE,CAAC;SACd,GAAG,CAAC,IAAA,cAAI,GAAE,CAAC;SACX,GAAG,CAAC,IAAA,oBAAU,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;SACnC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;SACzC,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,YA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,cAAc,GAAG,IAAA,sCAAoB,EAAC,eAAe,CAAC,CAAC;IAE3D,OAAO;QACL,QAAQ,EAAE,EAAE,KAAK,EAAE,kBAAkB,CAAC,EAAE,GAAG,aAAa,EAAE,GAAG,cAAc,EAAE,EAAE,KAAK,CAAC,EAAE;QACvF,SAAS,EAAE;YACT;;;;;eAKG;YACH,MAAM,EAAN,eAAM;SACP;KACF,CAAC;AACJ,CAAC,CAAC;AAtBW,QAAA,KAAK,SAsBhB"}
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createCors = void 0;
|
|
7
7
|
const cors_1 = __importDefault(require("cors"));
|
|
8
|
-
const createCors = () => cors_1.default({
|
|
8
|
+
const createCors = () => (0, cors_1.default)({
|
|
9
9
|
origin: (origin, cb) => {
|
|
10
10
|
if (typeof origin === "string") {
|
|
11
11
|
return cb(null, [origin]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-cors.js","sourceRoot":"","sources":["../../src/middleware/create-cors.ts"],"names":[],"mappings":";;;;;;AACA,gDAAwB;AAEjB,MAAM,UAAU,GAAG,GAAmB,EAAE,CAC7C,cAAI,
|
|
1
|
+
{"version":3,"file":"create-cors.js","sourceRoot":"","sources":["../../src/middleware/create-cors.ts"],"names":[],"mappings":";;;;;;AACA,gDAAwB;AAEjB,MAAM,UAAU,GAAG,GAAmB,EAAE,CAC7C,IAAA,cAAI,EAAC;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE;QACrB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;SAC3B;QAED,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAChB,CAAC;IACD,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC;AAVQ,QAAA,UAAU,cAUlB"}
|
|
@@ -7,7 +7,7 @@ exports.createSession = void 0;
|
|
|
7
7
|
const cookie_session_1 = __importDefault(require("cookie-session"));
|
|
8
8
|
const twentyFourHours = 24 * 60 * 60 * 1000;
|
|
9
9
|
const createSession = () => {
|
|
10
|
-
return cookie_session_1.default({
|
|
10
|
+
return (0, cookie_session_1.default)({
|
|
11
11
|
name: "session",
|
|
12
12
|
keys: ["shhh"],
|
|
13
13
|
secure: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/middleware/session.ts"],"names":[],"mappings":";;;;;;AACA,oEAA2C;AAC3C,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAErC,MAAM,aAAa,GAAG,GAAmB,EAAE;IAChD,OAAO,wBAAa,
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/middleware/session.ts"],"names":[],"mappings":";;;;;;AACA,oEAA2C;AAC3C,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAErC,MAAM,aAAa,GAAG,GAAmB,EAAE;IAChD,OAAO,IAAA,wBAAa,EAAC;QACnB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,CAAC,MAAM,CAAC;QACd,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE,eAAe;QACvB,QAAQ,EAAE,MAAM;KAClB,CAAC,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,aAAa,iBASxB"}
|
|
@@ -16,8 +16,8 @@ function parseRulesFiles(rulesPath) {
|
|
|
16
16
|
return (_a = ruleFiles
|
|
17
17
|
.map((r) => {
|
|
18
18
|
let filename = path_1.default.join(rulesPath, r);
|
|
19
|
-
let jsonFile = `${extensionless_file_name_1.extensionlessFileName(filename)}.json`;
|
|
20
|
-
assert_ts_1.assert(!!jsonFile, `no corresponding rule file for ${r}`);
|
|
19
|
+
let jsonFile = `${(0, extensionless_file_name_1.extensionlessFileName)(filename)}.json`;
|
|
20
|
+
(0, assert_ts_1.assert)(!!jsonFile, `no corresponding rule file for ${r}`);
|
|
21
21
|
let rawRule = fs_1.default.readFileSync(jsonFile, 'utf8');
|
|
22
22
|
let { enabled, order = 0, stage = "login_success", } = JSON.parse(rawRule);
|
|
23
23
|
if (!enabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-rules-files.js","sourceRoot":"","sources":["../../src/rules/parse-rules-files.ts"],"names":[],"mappings":";;;;;;AAAA,uEAAkE;AAClE,yCAAmC;AACnC,4CAAoB;AACpB,gDAAwB;AAGxB,SAAgB,eAAe,CAAC,SAAiB;;IAC/C,IAAI,SAAS,GAAG,YAAE;SACjB,WAAW,CAAC,SAAS,CAAC;SACtB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAI,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;IAE1C,OAAO,MAAA,SAAS;SACb,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,IAAI,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAEvC,IAAI,QAAQ,GAAG,GAAG,+CAAqB,
|
|
1
|
+
{"version":3,"file":"parse-rules-files.js","sourceRoot":"","sources":["../../src/rules/parse-rules-files.ts"],"names":[],"mappings":";;;;;;AAAA,uEAAkE;AAClE,yCAAmC;AACnC,4CAAoB;AACpB,gDAAwB;AAGxB,SAAgB,eAAe,CAAC,SAAiB;;IAC/C,IAAI,SAAS,GAAG,YAAE;SACjB,WAAW,CAAC,SAAS,CAAC;SACtB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAI,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;IAE1C,OAAO,MAAA,SAAS;SACb,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,IAAI,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAEvC,IAAI,QAAQ,GAAG,GAAG,IAAA,+CAAqB,EAAC,QAAQ,CAAC,OAAO,CAAC;QAEzD,IAAA,kBAAM,EAAC,CAAC,CAAC,QAAQ,EAAE,kCAAkC,CAAC,EAAE,CAAC,CAAC;QAE1D,IAAI,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAEhD,IAAI,EACF,OAAO,EACP,KAAK,GAAG,CAAC,EACT,KAAK,GAAG,eAAe,GACxB,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAExB,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,SAAS,CAAC;SAClB;QAED,IAAI,IAAI,GAAG,YAAE,CAAC,YAAY,CAAC,QAAQ,EAAE;YACnC,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;QAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1C,CAAC,CAAC;SACD,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1B,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,mCAAI,EAAE,CAAC;AAC3D,CAAC;AAjCD,0CAiCC"}
|
|
@@ -16,8 +16,8 @@ function createRulesRunner(rulesPath) {
|
|
|
16
16
|
return callback;
|
|
17
17
|
}
|
|
18
18
|
let fullPath = path_1.default.join(process.cwd(), rulesPath);
|
|
19
|
-
assert_ts_1.assert(fs_1.default.existsSync(fullPath), `no rules directory at ${fullPath}`);
|
|
20
|
-
let rules = parse_rules_files_1.parseRulesFiles(rulesPath);
|
|
19
|
+
(0, assert_ts_1.assert)(fs_1.default.existsSync(fullPath), `no rules directory at ${fullPath}`);
|
|
20
|
+
let rules = (0, parse_rules_files_1.parseRulesFiles)(rulesPath);
|
|
21
21
|
if (rules.length === 0) {
|
|
22
22
|
return callback;
|
|
23
23
|
}
|
|
@@ -44,7 +44,7 @@ function createRulesRunner(rulesPath) {
|
|
|
44
44
|
},
|
|
45
45
|
});
|
|
46
46
|
for (let rule of rules) {
|
|
47
|
-
assert_ts_1.assert(typeof rule !== "undefined", "undefined rule");
|
|
47
|
+
(0, assert_ts_1.assert)(typeof rule !== "undefined", "undefined rule");
|
|
48
48
|
let { code, filename } = rule;
|
|
49
49
|
console.debug(`executing rule ${path_1.default.basename(filename)}`);
|
|
50
50
|
let script = new vm_1.default.Script(`(function(exports) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules-runner.js","sourceRoot":"","sources":["../../src/rules/rules-runner.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AACpB,4CAAoB;AACpB,yCAAmC;AACnC,2DAAsD;AAKtD,SAAgB,iBAAiB,CAAE,SAAkB;IACnD,6DAA6D;IAC7D,IAAI,QAAQ,GAAG,CAAC,KAAe,EAAE,QAAuC,EAAE,EAAE,GAAE,CAAC,CAAC;IAEhF,IAAG,OAAO,SAAS,KAAK,WAAW,EAAE;QACnC,OAAO,QAAQ,CAAC;KACjB;IAED,IAAI,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;IAEnD,kBAAM,
|
|
1
|
+
{"version":3,"file":"rules-runner.js","sourceRoot":"","sources":["../../src/rules/rules-runner.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,4CAAoB;AACpB,4CAAoB;AACpB,yCAAmC;AACnC,2DAAsD;AAKtD,SAAgB,iBAAiB,CAAE,SAAkB;IACnD,6DAA6D;IAC7D,IAAI,QAAQ,GAAG,CA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I;;;SAGV,CACF,CAAC;YAEF,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE;gBAC7B,QAAQ;aACT,CAAC,CAAC;SACJ;IACH,CAAC,CAAC;AACJ,CAAC;AA9DD,8CA8DC"}
|
package/dist/start.js
CHANGED
|
@@ -8,15 +8,15 @@ const server_1 = require("@simulacrum/server");
|
|
|
8
8
|
const _1 = require(".");
|
|
9
9
|
const dedent_1 = __importDefault(require("dedent"));
|
|
10
10
|
const port = process.env.PORT ? parseInt(process.env.PORT) : undefined;
|
|
11
|
-
effection_1.main(function* () {
|
|
12
|
-
let server = yield server_1.createSimulationServer({
|
|
11
|
+
(0, effection_1.main)(function* () {
|
|
12
|
+
let server = yield (0, server_1.createSimulationServer)({
|
|
13
13
|
debug: true,
|
|
14
14
|
seed: 1,
|
|
15
15
|
port,
|
|
16
16
|
simulators: { auth0: _1.auth0 }
|
|
17
17
|
});
|
|
18
18
|
let url = `http://localhost:${server.address.port}`;
|
|
19
|
-
console.log(dedent_1.default `Started Simulacrum simulation server on ${url}.
|
|
19
|
+
console.log((0, dedent_1.default) `Started Simulacrum simulation server on ${url}.
|
|
20
20
|
GraphiQL interface is running on ${url}/graphql.
|
|
21
21
|
|
|
22
22
|
To start auth0 simulator send the following mutation to GraphQL server.
|
|
@@ -27,7 +27,7 @@ effection_1.main(function* () {
|
|
|
27
27
|
options:{
|
|
28
28
|
audience: "[your audience]",
|
|
29
29
|
scope: "[your scope]",
|
|
30
|
-
|
|
30
|
+
clientID: "[your client-id]"
|
|
31
31
|
},
|
|
32
32
|
services:{
|
|
33
33
|
auth0:{
|
package/dist/start.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":";;;;;AAAA,yCAAiC;AACjC,+CAAoE;AACpE,wBAA0B;AAC1B,oDAA4B;AAE5B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAEvE,gBAAI,
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":";;;;;AAAA,yCAAiC;AACjC,+CAAoE;AACpE,wBAA0B;AAC1B,oDAA4B;AAE5B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAEvE,IAAA,gBAAI,EAAC,QAAQ,CAAC;IACZ,IAAI,MAAM,GAAW,MAAM,IAAA,+BAAsB,EAAC;QAChD,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,CAAC;QACP,IAAI;QACJ,UAAU,EAAE,EAAE,KAAK,EAAL,QAAK,EAAE;KACtB,CAAC,CAAC;IAEH,IAAI,GAAG,GAAG,oBAAoB,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAEpD,OAAO,CAAC,GAAG,CAAC,IAAA,gBAAM,EAAA,2CAA2C,GAAG;qCAC7B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BtC,CAAC,CAAC;IAEF,KAAK,CAAC;AACR,CAAC,CAAC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface Options {
|
|
|
4
4
|
scope: string;
|
|
5
5
|
port?: number;
|
|
6
6
|
audience: string;
|
|
7
|
-
|
|
7
|
+
clientID: string;
|
|
8
8
|
store: Store;
|
|
9
9
|
services: Slice<SimulationState['services']>;
|
|
10
10
|
rulesDirectory?: string;
|
|
@@ -24,4 +24,25 @@ export declare type QueryParams = {
|
|
|
24
24
|
auth0Client: string;
|
|
25
25
|
audience: string;
|
|
26
26
|
};
|
|
27
|
+
export interface TokenSet {
|
|
28
|
+
access_token?: string;
|
|
29
|
+
token_type?: string;
|
|
30
|
+
id_token?: string;
|
|
31
|
+
refresh_token?: string;
|
|
32
|
+
scope?: string;
|
|
33
|
+
expires_at?: number;
|
|
34
|
+
session_state?: string;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
export interface IdTokenData {
|
|
38
|
+
alg: string;
|
|
39
|
+
typ: string;
|
|
40
|
+
iss: string;
|
|
41
|
+
exp: number;
|
|
42
|
+
iat: number;
|
|
43
|
+
email: string;
|
|
44
|
+
aud: string;
|
|
45
|
+
sub: string;
|
|
46
|
+
nonce?: string;
|
|
47
|
+
}
|
|
27
48
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7C,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,oBAAY,aAAa,GAAG,OAAO,GAAG,aAAa,CAAC;AAEpD,oBAAY,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB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ClB,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"}
|
package/dist/views/login.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ interface LoginViewProps {
|
|
|
2
2
|
domain: string;
|
|
3
3
|
scope: string;
|
|
4
4
|
redirectUri: string;
|
|
5
|
-
|
|
5
|
+
clientID: string;
|
|
6
6
|
audience: string;
|
|
7
7
|
loginFailed: boolean;
|
|
8
8
|
}
|
|
9
|
-
export declare const loginView: ({ domain, scope, redirectUri,
|
|
9
|
+
export declare const loginView: ({ domain, scope, redirectUri, clientID, audience, loginFailed }: LoginViewProps) => string;
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=login.d.ts.map
|
package/dist/views/login.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loginView = void 0;
|
|
4
4
|
const html = String.raw;
|
|
5
|
-
const loginView = ({ domain, scope, redirectUri,
|
|
5
|
+
const loginView = ({ domain, scope, redirectUri, clientID, audience, loginFailed = false }) => {
|
|
6
6
|
return html `
|
|
7
7
|
<html lang="en">
|
|
8
8
|
<head>
|
|
@@ -22,7 +22,7 @@ const loginView = ({ domain, scope, redirectUri, clientId, audience, loginFailed
|
|
|
22
22
|
<img alt="frontside" class="bg-transparent object-contain h-16" src="/img/frontside-logo.png" />
|
|
23
23
|
</div>
|
|
24
24
|
<h1 class="flex justify-center text-4xl">Welcome</h1>
|
|
25
|
-
<h2 class="flex justify-center">
|
|
25
|
+
<h2 class="flex justify-center">Login to continue to frontside</h2>
|
|
26
26
|
<form id="the-form" class="mt-8 space-y-6">
|
|
27
27
|
<div class="rounded-md shadow-sm -space-y-px">
|
|
28
28
|
<div>
|
|
@@ -53,7 +53,7 @@ const loginView = ({ domain, scope, redirectUri, clientId, audience, loginFailed
|
|
|
53
53
|
document.addEventListener('DOMContentLoaded', function(){
|
|
54
54
|
var webAuth = new window.auth0.default.WebAuth({
|
|
55
55
|
domain: '${domain}',
|
|
56
|
-
clientID: '${
|
|
56
|
+
clientID: '${clientID}',
|
|
57
57
|
redirectUri: '${redirectUri}',
|
|
58
58
|
audience: '${audience}',
|
|
59
59
|
responseType: 'token id_token',
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.userNamePasswordForm = void 0;
|
|
4
4
|
const html_entities_1 = require("html-entities");
|
|
5
5
|
const userNamePasswordForm = ({ auth0Domain = "/login/callback", redirect_uri, state, nonce, client_id, scope, audience, connection, response_type, tenant, }) => {
|
|
6
|
-
let wctx = html_entities_1.encode(JSON.stringify({
|
|
6
|
+
let wctx = (0, html_entities_1.encode)(JSON.stringify({
|
|
7
7
|
strategy: "auth0",
|
|
8
8
|
tenant,
|
|
9
9
|
connection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"username-password.js","sourceRoot":"","sources":["../../src/views/username-password.ts"],"names":[],"mappings":";;;AAAA,iDAAuC;AAWhC,MAAM,oBAAoB,GAAG,CAAC,EACnC,WAAW,GAAG,iBAAiB,EAC/B,YAAY,EACZ,KAAK,EACL,KAAK,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,UAAU,EACV,aAAa,EACb,MAAM,GACe,EAAU,EAAE;IACjC,IAAI,IAAI,GAAG,sBAAM,
|
|
1
|
+
{"version":3,"file":"username-password.js","sourceRoot":"","sources":["../../src/views/username-password.ts"],"names":[],"mappings":";;;AAAA,iDAAuC;AAWhC,MAAM,oBAAoB,GAAG,CAAC,EACnC,WAAW,GAAG,iBAAiB,EAC/B,YAAY,EACZ,KAAK,EACL,KAAK,EACL,SAAS,EACT,KAAK,EACL,QAAQ,EACR,UAAU,EACV,aAAa,EACb,MAAM,GACe,EAAU,EAAE;IACjC,IAAI,IAAI,GAAG,IAAA,sBAAM,EACf,IAAI,CAAC,SAAS,CAAC;QACb,QAAQ,EAAE,OAAO;QACjB,MAAM;QACN,UAAU;QACV,SAAS;QACT,aAAa;QACb,KAAK;QACL,YAAY;QACZ,KAAK;QACL,KAAK;QACL,QAAQ;QACR,KAAK,EAAE,UAAU;KAClB,CAAC,CACH,CAAC;IAEF,OAAO;kDACyC,WAAW;;;;;8CAKf,IAAI;;;;;;;UAOxC,CAAC;AACX,CAAC,CAAC;AA1CW,QAAA,oBAAoB,wBA0C/B"}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.webMessage = void 0;
|
|
7
7
|
const jsesc_1 = __importDefault(require("jsesc"));
|
|
8
8
|
const webMessage = ({ state, code, redirect_uri, nonce, }) => {
|
|
9
|
-
let data = jsesc_1.default({
|
|
9
|
+
let data = (0, jsesc_1.default)({
|
|
10
10
|
redirect_uri,
|
|
11
11
|
}, { json: true, isScriptContext: true });
|
|
12
12
|
return `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-message.js","sourceRoot":"","sources":["../../src/views/web-message.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAGnB,MAAM,UAAU,GAAG,CAAC,EACzB,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,KAAK,GAIN,EAAU,EAAE;IACX,IAAI,IAAI,GAAG,eAAK,
|
|
1
|
+
{"version":3,"file":"web-message.js","sourceRoot":"","sources":["../../src/views/web-message.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAGnB,MAAM,UAAU,GAAG,CAAC,EACzB,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,KAAK,GAIN,EAAU,EAAE;IACX,IAAI,IAAI,GAAG,IAAA,eAAK,EACd;QACE,YAAY;KACb,EACD,EAAE,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CACtC,CAAC;IAEF,OAAO;;;;;;;gBAOO,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE;;uBAExB,IAAI;;;;;;;wBAOH,IAAI;yBACH,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkC3B,CAAC;AACJ,CAAC,CAAC;AApEW,QAAA,UAAU,cAoErB"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simulacrum/auth0-simulator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Simulate Auth0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"bin": "bin/index.js",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"clean": "rimraf *.tsbuildinfo dist",
|
|
8
9
|
"test": "NODE_EXTRA_CA_CERTS=\"$(mkcert -CAROOT)/rootCA.pem\" mocha -r ts-node/register --timeout 10000 test/**/*.test.ts",
|
|
9
|
-
"prepack": "tsc --build tsconfig.dist.json && copy \"./src/views/**/*.png\" ./dist/views/",
|
|
10
|
+
"prepack": "tsc --build tsconfig.dist.json && copy-cli \"./src/views/**/*.png\" ./dist/views/",
|
|
10
11
|
"build": "npm run prepack",
|
|
11
12
|
"lint": "eslint src bin test",
|
|
12
13
|
"start": "node dist/start.js",
|
|
@@ -33,28 +34,28 @@
|
|
|
33
34
|
},
|
|
34
35
|
"homepage": "https://github.com/thefrontside/simulacrum#readme",
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@effection/process": "^2.0.
|
|
37
|
-
"@simulacrum/server": "0.
|
|
37
|
+
"@effection/process": "^2.0.1",
|
|
38
|
+
"@simulacrum/server": "0.5.0",
|
|
38
39
|
"@types/faker": "^5.1.7",
|
|
39
40
|
"assert-ts": "^0.3.2",
|
|
40
41
|
"base64-url": "^2.3.3",
|
|
41
42
|
"cookie-session": "^1.4.0",
|
|
42
43
|
"dedent": "^0.7.0",
|
|
43
|
-
"effection": "^2.0.
|
|
44
|
+
"effection": "^2.0.1",
|
|
44
45
|
"html-entities": "^2.3.2",
|
|
45
46
|
"jsesc": "^3.0.2",
|
|
46
47
|
"jsonwebtoken": "^8.5.1"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@effection/atom": "^2.0.
|
|
50
|
-
"@effection/mocha": "^2.0.
|
|
51
|
-
"@frontside/eslint-config": "^
|
|
52
|
-
"@frontside/tsconfig": "^
|
|
53
|
-
"@frontside/typescript": "^
|
|
54
|
-
"@simulacrum/client": "0.5.
|
|
55
|
-
"@types/dedent": "^0.7.0",
|
|
50
|
+
"@effection/atom": "^2.0.1",
|
|
51
|
+
"@effection/mocha": "^2.0.1",
|
|
52
|
+
"@frontside/eslint-config": "^3.0.0",
|
|
53
|
+
"@frontside/tsconfig": "^3.0.0",
|
|
54
|
+
"@frontside/typescript": "^3.0.0",
|
|
55
|
+
"@simulacrum/client": "0.5.3",
|
|
56
56
|
"@types/base64-url": "^2.2.0",
|
|
57
57
|
"@types/cookie-session": "^2.0.42",
|
|
58
|
+
"@types/dedent": "^0.7.0",
|
|
58
59
|
"@types/jsesc": "^2.5.1",
|
|
59
60
|
"@types/jsonwebtoken": "^8.5.1",
|
|
60
61
|
"@types/mocha": "^8.2.1",
|
|
@@ -65,7 +66,6 @@
|
|
|
65
66
|
"mocha": "^8.0.0",
|
|
66
67
|
"rimraf": "^3.0.2",
|
|
67
68
|
"ts-node": "^9.1.1",
|
|
68
|
-
"typescript": "^4.2.3",
|
|
69
69
|
"ws": "^7.4.4"
|
|
70
70
|
},
|
|
71
71
|
"volta": {
|