@simulacrum/auth0-simulator 0.9.0 → 0.10.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/README.md +28 -206
- package/bin/start.js +14 -0
- package/dist/auth/constants.d.ts.map +1 -1
- package/dist/auth/constants.js.map +1 -1
- package/dist/auth/date.d.ts.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 -5
- package/dist/auth/jwt.js.map +1 -1
- package/dist/auth/refresh-token.d.ts +2 -2
- package/dist/auth/refresh-token.d.ts.map +1 -1
- package/dist/auth/refresh-token.js +7 -8
- package/dist/auth/refresh-token.js.map +1 -1
- package/dist/config/get-config.d.ts +6 -6
- package/dist/config/get-config.d.ts.map +1 -1
- package/dist/config/get-config.js +10 -10
- package/dist/config/get-config.js.map +1 -1
- package/dist/handlers/auth0-handlers.d.ts +6 -10
- package/dist/handlers/auth0-handlers.d.ts.map +1 -1
- package/dist/handlers/auth0-handlers.js +96 -70
- package/dist/handlers/auth0-handlers.js.map +1 -1
- package/dist/handlers/index.d.ts +5 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +43 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/login-redirect.d.ts +2 -2
- package/dist/handlers/login-redirect.d.ts.map +1 -1
- package/dist/handlers/login-redirect.js.map +1 -1
- package/dist/handlers/oauth-handlers.d.ts +10 -9
- package/dist/handlers/oauth-handlers.d.ts.map +1 -1
- package/dist/handlers/oauth-handlers.js +56 -50
- package/dist/handlers/oauth-handlers.js.map +1 -1
- package/dist/handlers/openid-handlers.d.ts +4 -4
- package/dist/handlers/openid-handlers.d.ts.map +1 -1
- package/dist/handlers/openid-handlers.js +10 -10
- package/dist/handlers/openid-handlers.js.map +1 -1
- package/dist/handlers/url.d.ts.map +1 -1
- package/dist/handlers/url.js +1 -1
- package/dist/handlers/url.js.map +1 -1
- package/dist/handlers/utils.d.ts +11 -4
- package/dist/handlers/utils.d.ts.map +1 -1
- package/dist/handlers/utils.js +5 -4
- package/dist/handlers/utils.js.map +1 -1
- package/dist/handlers/web-message.d.ts +1 -1
- package/dist/handlers/web-message.d.ts.map +1 -1
- package/dist/handlers/web-message.js +3 -3
- package/dist/handlers/web-message.js.map +1 -1
- package/dist/index.d.ts +16 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -125
- package/dist/index.js.map +1 -1
- package/dist/middleware/create-cors.d.ts +1 -1
- package/dist/middleware/create-cors.js.map +1 -1
- package/dist/middleware/error-handling.d.ts +3 -0
- package/dist/middleware/error-handling.d.ts.map +1 -0
- package/dist/{error-handling-middleware.js → middleware/error-handling.js} +5 -8
- package/dist/middleware/error-handling.js.map +1 -0
- package/dist/middleware/no-cache.d.ts +1 -1
- package/dist/middleware/session.d.ts +1 -1
- package/dist/middleware/session.js.map +1 -1
- package/dist/rules/extensionless-file-name.d.ts.map +1 -1
- package/dist/rules/parse-rules-files.d.ts.map +1 -1
- package/dist/rules/parse-rules-files.js +7 -8
- package/dist/rules/parse-rules-files.js.map +1 -1
- package/dist/rules/rules-runner.d.ts +2 -2
- package/dist/rules/rules-runner.d.ts.map +1 -1
- package/dist/rules/rules-runner.js +49 -41
- package/dist/rules/rules-runner.js.map +1 -1
- package/dist/rules/types.d.ts +1 -1
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/store/entities.d.ts +111 -0
- package/dist/store/entities.d.ts.map +1 -0
- package/dist/store/entities.js +43 -0
- package/dist/store/entities.js.map +1 -0
- package/dist/store/index.d.ts +37 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +40 -0
- package/dist/store/index.js.map +1 -0
- package/dist/types.d.ts +20 -20
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -11
- package/dist/types.js.map +1 -1
- package/dist/views/login.d.ts +2 -2
- package/dist/views/login.d.ts.map +1 -1
- package/dist/views/login.js +81 -30
- package/dist/views/login.js.map +1 -1
- package/dist/views/username-password.d.ts +2 -2
- package/dist/views/username-password.d.ts.map +1 -1
- package/dist/views/web-message.d.ts +1 -1
- package/dist/views/web-message.d.ts.map +1 -1
- package/dist/views/web-message.js.map +1 -1
- package/package.json +26 -41
- package/CHANGELOG.md +0 -176
- package/bin/index.js +0 -2
- package/dist/error-handling-middleware.d.ts +0 -3
- package/dist/error-handling-middleware.d.ts.map +0 -1
- package/dist/error-handling-middleware.js.map +0 -1
- package/dist/handlers/get-service-url.d.ts +0 -3
- package/dist/handlers/get-service-url.d.ts.map +0 -1
- package/dist/handlers/get-service-url.js +0 -11
- package/dist/handlers/get-service-url.js.map +0 -1
- package/dist/start.d.ts +0 -2
- package/dist/start.d.ts.map +0 -1
- package/dist/start.js +0 -77
- package/dist/start.js.map +0 -1
|
@@ -1,41 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.getBaseAccessToken = exports.getIdToken = exports.createTokens = void 0;
|
|
4
13
|
const assert_ts_1 = require("assert-ts");
|
|
5
14
|
const base64_url_1 = require("base64-url");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const createTokens =
|
|
15
|
+
const date_ts_1 = require("../auth/date.js");
|
|
16
|
+
const jwt_ts_1 = require("../auth/jwt.js");
|
|
17
|
+
const rules_runner_ts_1 = require("../rules/rules-runner.js");
|
|
18
|
+
const utils_ts_1 = require("./utils.js");
|
|
19
|
+
const refresh_token_ts_1 = require("../auth/refresh-token.js");
|
|
20
|
+
const createTokens = (_a) => __awaiter(void 0, [_a], void 0, function* ({ body, iss, clientID, audience, rulesDirectory, scope: scopeConfig, simulationStore, }) {
|
|
12
21
|
let { grant_type } = body;
|
|
13
|
-
let scope = (0,
|
|
22
|
+
let scope = (0, utils_ts_1.deriveScope)({ scopeConfig, clientID, audience });
|
|
14
23
|
let accessToken = (0, exports.getBaseAccessToken)({ iss, grant_type, scope, audience });
|
|
15
24
|
let user;
|
|
16
25
|
let nonce;
|
|
17
|
-
if (grant_type ===
|
|
18
|
-
return { access_token: (0,
|
|
26
|
+
if (grant_type === "client_credentials") {
|
|
27
|
+
return { access_token: (0, jwt_ts_1.createJsonWebToken)(accessToken) };
|
|
19
28
|
}
|
|
20
29
|
// TODO: check refresh_token expiry date
|
|
21
|
-
else if (grant_type ===
|
|
30
|
+
else if (grant_type === "refresh_token") {
|
|
22
31
|
let { refresh_token: refreshTokenValue } = body;
|
|
23
32
|
let refreshToken = JSON.parse((0, base64_url_1.decode)(refreshTokenValue));
|
|
24
|
-
let findUser = (0,
|
|
33
|
+
let findUser = (0, utils_ts_1.createPersonQuery)(simulationStore);
|
|
25
34
|
user = findUser((person) => person.id === refreshToken.user.id);
|
|
26
35
|
nonce = refreshToken.nonce;
|
|
27
36
|
(0, assert_ts_1.assert)(!!nonce, `400::No nonce in request`);
|
|
28
37
|
}
|
|
29
38
|
else {
|
|
30
39
|
let result = verifyUserExistsInStore({
|
|
31
|
-
|
|
40
|
+
simulationStore,
|
|
32
41
|
body,
|
|
33
42
|
grant_type,
|
|
34
43
|
});
|
|
35
44
|
user = result.user;
|
|
36
45
|
nonce = result.nonce;
|
|
37
46
|
}
|
|
38
|
-
(0, assert_ts_1.assert)(!!user,
|
|
47
|
+
(0, assert_ts_1.assert)(!!user, "500::No user found");
|
|
39
48
|
let { idTokenData, userData } = (0, exports.getIdToken)({
|
|
40
49
|
body,
|
|
41
50
|
iss,
|
|
@@ -48,50 +57,47 @@ const createTokens = async ({ body, iss, clientID, audience, rulesDirectory, peo
|
|
|
48
57
|
accessToken: { scope, sub: idTokenData.sub },
|
|
49
58
|
idToken: idTokenData,
|
|
50
59
|
};
|
|
51
|
-
let rulesRunner = (0,
|
|
60
|
+
let rulesRunner = (0, rules_runner_ts_1.createRulesRunner)(rulesDirectory);
|
|
52
61
|
// the rules mutate the values
|
|
53
|
-
|
|
62
|
+
yield rulesRunner(userData, context);
|
|
54
63
|
return {
|
|
55
|
-
access_token: (0,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
scope,
|
|
67
|
-
user,
|
|
68
|
-
nonce
|
|
69
|
-
}) : undefined
|
|
64
|
+
access_token: (0, jwt_ts_1.createJsonWebToken)(Object.assign(Object.assign({}, accessToken), context.accessToken)),
|
|
65
|
+
id_token: (0, jwt_ts_1.createJsonWebToken)(Object.assign(Object.assign({}, userData), context.idToken)),
|
|
66
|
+
refresh_token: (0, refresh_token_ts_1.issueRefreshToken)(scope, grant_type)
|
|
67
|
+
? (0, refresh_token_ts_1.createRefreshToken)({
|
|
68
|
+
exp: idTokenData.exp,
|
|
69
|
+
rotations: 0,
|
|
70
|
+
scope,
|
|
71
|
+
user,
|
|
72
|
+
nonce,
|
|
73
|
+
})
|
|
74
|
+
: undefined,
|
|
70
75
|
};
|
|
71
|
-
};
|
|
76
|
+
});
|
|
72
77
|
exports.createTokens = createTokens;
|
|
73
78
|
const getIdToken = ({ body, iss, user, clientID, nonce, }) => {
|
|
79
|
+
var _a, _b, _c, _d;
|
|
74
80
|
let userData = {
|
|
75
|
-
name: body === null || body === void 0 ? void 0 : body.name,
|
|
76
|
-
email: body === null || body === void 0 ? void 0 : body.email,
|
|
81
|
+
name: (_a = body === null || body === void 0 ? void 0 : body.name) !== null && _a !== void 0 ? _a : user.name,
|
|
82
|
+
email: (_b = body === null || body === void 0 ? void 0 : body.email) !== null && _b !== void 0 ? _b : user.email,
|
|
77
83
|
email_verified: true,
|
|
78
|
-
user_id: body === null || body === void 0 ? void 0 : body.id,
|
|
84
|
+
user_id: (_c = body === null || body === void 0 ? void 0 : body.id) !== null && _c !== void 0 ? _c : user.id,
|
|
79
85
|
nickname: body === null || body === void 0 ? void 0 : body.nickname,
|
|
80
|
-
picture: body === null || body === void 0 ? void 0 : body.picture,
|
|
86
|
+
picture: (_d = body === null || body === void 0 ? void 0 : body.picture) !== null && _d !== void 0 ? _d : user.picture,
|
|
81
87
|
identities: body === null || body === void 0 ? void 0 : body.identities,
|
|
82
88
|
};
|
|
83
|
-
(0, assert_ts_1.assert)(!!user.email,
|
|
89
|
+
(0, assert_ts_1.assert)(!!user.email, "500::User in store requires an email");
|
|
84
90
|
let idTokenData = {
|
|
85
|
-
alg:
|
|
86
|
-
typ:
|
|
91
|
+
alg: "RS256",
|
|
92
|
+
typ: "JWT",
|
|
87
93
|
iss,
|
|
88
|
-
exp: (0,
|
|
89
|
-
iat: (0,
|
|
94
|
+
exp: (0, date_ts_1.expiresAt)(),
|
|
95
|
+
iat: (0, date_ts_1.epochTime)(),
|
|
90
96
|
email: user.email,
|
|
91
97
|
aud: clientID,
|
|
92
98
|
sub: user.id,
|
|
93
99
|
};
|
|
94
|
-
if (typeof nonce !==
|
|
100
|
+
if (typeof nonce !== "undefined") {
|
|
95
101
|
idTokenData.nonce = nonce;
|
|
96
102
|
}
|
|
97
103
|
return { userData, idTokenData };
|
|
@@ -99,41 +105,41 @@ const getIdToken = ({ body, iss, user, clientID, nonce, }) => {
|
|
|
99
105
|
exports.getIdToken = getIdToken;
|
|
100
106
|
const getBaseAccessToken = ({ iss, grant_type, scope, audience, }) => ({
|
|
101
107
|
iss,
|
|
102
|
-
exp: (0,
|
|
103
|
-
iat: (0,
|
|
108
|
+
exp: (0, date_ts_1.expiresAt)(),
|
|
109
|
+
iat: (0, date_ts_1.epochTime)(),
|
|
104
110
|
aud: audience,
|
|
105
111
|
gty: grant_type,
|
|
106
112
|
scope,
|
|
107
113
|
});
|
|
108
114
|
exports.getBaseAccessToken = getBaseAccessToken;
|
|
109
|
-
const verifyUserExistsInStore = ({
|
|
115
|
+
const verifyUserExistsInStore = ({ simulationStore, body, grant_type, }) => {
|
|
110
116
|
let { code } = body;
|
|
111
|
-
let personQuery = (0,
|
|
117
|
+
let personQuery = (0, utils_ts_1.createPersonQuery)(simulationStore);
|
|
112
118
|
let nonce;
|
|
113
119
|
let username;
|
|
114
120
|
let password;
|
|
115
|
-
if (grant_type ===
|
|
121
|
+
if (grant_type === "password") {
|
|
116
122
|
username = body.username;
|
|
117
123
|
password = body.password;
|
|
118
124
|
}
|
|
119
125
|
else {
|
|
120
126
|
// specifically grant_type === 'authorization_code'
|
|
121
127
|
// but naively using it to handle other cases at the moment
|
|
122
|
-
(0, assert_ts_1.assert)(typeof code !==
|
|
123
|
-
[nonce, username] = (0, base64_url_1.decode)(code).split(
|
|
128
|
+
(0, assert_ts_1.assert)(typeof code !== "undefined", "400::no code in /oauth/token");
|
|
129
|
+
[nonce, username] = (0, base64_url_1.decode)(code).split(":");
|
|
124
130
|
}
|
|
125
131
|
(0, assert_ts_1.assert)(!!username, `400::no nonce in store for ${code}`);
|
|
126
132
|
let user = personQuery((person) => {
|
|
127
133
|
(0, assert_ts_1.assert)(!!person.email, `500::no email defined on person scenario`);
|
|
128
134
|
let valid = person.email.toLowerCase() === username.toLowerCase();
|
|
129
|
-
if (typeof password ===
|
|
135
|
+
if (typeof password === "undefined") {
|
|
130
136
|
return valid;
|
|
131
137
|
}
|
|
132
138
|
else {
|
|
133
139
|
return valid && password === person.password;
|
|
134
140
|
}
|
|
135
141
|
});
|
|
136
|
-
(0, assert_ts_1.assert)(!!user,
|
|
142
|
+
(0, assert_ts_1.assert)(!!user, "401::Unauthorized");
|
|
137
143
|
return { user, nonce };
|
|
138
144
|
};
|
|
139
145
|
//# sourceMappingURL=oauth-handlers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-handlers.js","sourceRoot":"","sources":["../../src/handlers/oauth-handlers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"oauth-handlers.js","sourceRoot":"","sources":["../../src/handlers/oauth-handlers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAmC;AACnC,2CAA4D;AAC5D,6CAAuD;AACvD,2CAAoD;AACpD,8DAA6D;AAC7D,yCAA4D;AAW5D,+DAGkC;AAI3B,MAAM,YAAY,GAAG,KAgBzB,EAAE,4CAhB8B,EACjC,IAAI,EACJ,GAAG,EACH,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,KAAK,EAAE,WAAW,EAClB,eAAe,GAShB;IACC,IAAI,EAAE,UAAU,EAAE,GAA8B,IAAI,CAAC;IACrD,IAAI,KAAK,GAAG,IAAA,sBAAW,EAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE7D,IAAI,WAAW,GAAG,IAAA,0BAAkB,EAAC,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC3E,IAAI,IAA2B,CAAC;IAChC,IAAI,KAAyB,CAAC;IAE9B,IAAI,UAAU,KAAK,oBAAoB,EAAE,CAAC;QACxC,OAAO,EAAE,YAAY,EAAE,IAAA,2BAAkB,EAAC,WAAW,CAAC,EAAE,CAAC;IAC3D,CAAC;IACD,wCAAwC;SACnC,IAAI,UAAU,KAAK,eAAe,EAAE,CAAC;QACxC,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;QAChD,IAAI,YAAY,GAAiB,IAAI,CAAC,KAAK,CAA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;IACpD,CAAC;IAED,IAAA,kBAAM,EAAC,CAAC,CAAC,QAAQ,EAAE,8BAA8B,IAAI,EAAE,CAAC,CAAC;IAEzD,IAAI,IAAI,GAA0B,WAAW,CAAC,CAAC,MAAM,EAAE,EAAE;QACvD,IAAA,kBAAM,EAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,0CAA0C,CAAC,CAAC;QAEnE,IAAI,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,WAAW,EAAE,CAAC;QAElE,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACf,CAAC;aAAM,CAAC;YACN,OAAO,KAAK,IAAI,QAAQ,KAAK,MAAM,CAAC,QAAQ,CAAC;QAC/C,CAAC;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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { RequestHandler } from
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import type { Request, RequestHandler } from "express";
|
|
2
|
+
type Routes = "/jwks.json" | "/openid-configuration";
|
|
3
|
+
export type OpenIdRoutes = `${`/.well-known`}${Routes}`;
|
|
4
4
|
export interface OpenIdConfiguration {
|
|
5
5
|
issuer: string;
|
|
6
6
|
authorization_endpoint: string;
|
|
@@ -8,6 +8,6 @@ export interface OpenIdConfiguration {
|
|
|
8
8
|
userinfo_endpoint: string;
|
|
9
9
|
jwks_uri: string;
|
|
10
10
|
}
|
|
11
|
-
export declare const createOpenIdHandlers: (serviceURL: () =>
|
|
11
|
+
export declare const createOpenIdHandlers: (serviceURL: (request: Request) => string) => Record<OpenIdRoutes, RequestHandler>;
|
|
12
12
|
export {};
|
|
13
13
|
//# sourceMappingURL=openid-handlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openid-handlers.d.ts","sourceRoot":"","sources":["../../src/handlers/openid-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"openid-handlers.d.ts","sourceRoot":"","sources":["../../src/handlers/openid-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAIvD,KAAK,MAAM,GAAG,YAAY,GAAG,uBAAuB,CAAC;AAErD,MAAM,MAAM,YAAY,GAAG,GAAG,cAAc,GAAG,MAAM,EAAE,CAAC;AAExD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,oBAAoB,GAC/B,YAAY,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,KACvC,MAAM,CAAC,YAAY,EAAE,cAAc,CAkBrC,CAAC"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createOpenIdHandlers = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const constants_ts_1 = require("../auth/constants.js");
|
|
5
|
+
const url_ts_1 = require("./url.js");
|
|
6
6
|
const createOpenIdHandlers = (serviceURL) => {
|
|
7
7
|
return {
|
|
8
|
-
[
|
|
9
|
-
res.json(
|
|
8
|
+
["/.well-known/jwks.json"]: function (_, res) {
|
|
9
|
+
res.json(constants_ts_1.JWKS);
|
|
10
10
|
},
|
|
11
|
-
[
|
|
12
|
-
let url = (0,
|
|
11
|
+
["/.well-known/openid-configuration"]: function (req, res) {
|
|
12
|
+
let url = (0, url_ts_1.removeTrailingSlash)(serviceURL(req));
|
|
13
13
|
res.json({
|
|
14
14
|
issuer: `${url}/`,
|
|
15
|
-
authorization_endpoint: [url, "authorize"].join(
|
|
16
|
-
token_endpoint: [url, "oauth", "token"].join(
|
|
17
|
-
userinfo_endpoint: [url, "userinfo"].join(
|
|
18
|
-
jwks_uri: [url, ".well-known", "jwks.json"].join(
|
|
15
|
+
authorization_endpoint: [url, "authorize"].join("/"),
|
|
16
|
+
token_endpoint: [url, "oauth", "token"].join("/"),
|
|
17
|
+
userinfo_endpoint: [url, "userinfo"].join("/"),
|
|
18
|
+
jwks_uri: [url, ".well-known", "jwks.json"].join("/"),
|
|
19
19
|
});
|
|
20
20
|
},
|
|
21
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openid-handlers.js","sourceRoot":"","sources":["../../src/handlers/openid-handlers.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"openid-handlers.js","sourceRoot":"","sources":["../../src/handlers/openid-handlers.ts"],"names":[],"mappings":";;;AACA,uDAA4C;AAC5C,qCAA+C;AAcxC,MAAM,oBAAoB,GAAG,CAClC,UAAwC,EACF,EAAE;IACxC,OAAO;QACL,CAAC,wBAAwB,CAAC,EAAE,UAAU,CAAC,EAAE,GAAG;YAC1C,GAAG,CAAC,IAAI,CAAC,mBAAI,CAAC,CAAC;QACjB,CAAC;QAED,CAAC,mCAAmC,CAAC,EAAE,UAAU,GAAG,EAAE,GAAG;YACvD,IAAI,GAAG,GAAG,IAAA,4BAAmB,EAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;YAE/C,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;AApBW,QAAA,oBAAoB,wBAoB/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/handlers/url.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/handlers/url.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,KAAG,MAC1B,CAAC"}
|
package/dist/handlers/url.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.removeTrailingSlash = void 0;
|
|
4
|
-
const removeTrailingSlash = (url) => url.replace(/\/$/,
|
|
4
|
+
const removeTrailingSlash = (url) => url.replace(/\/$/, "");
|
|
5
5
|
exports.removeTrailingSlash = removeTrailingSlash;
|
|
6
6
|
//# sourceMappingURL=url.js.map
|
package/dist/handlers/url.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/handlers/url.ts"],"names":[],"mappings":";;;AAAO,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/handlers/url.ts"],"names":[],"mappings":";;;AAAO,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAU,EAAE,CACzD,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AADZ,QAAA,mBAAmB,uBACP"}
|
package/dist/handlers/utils.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { ScopeConfig } from "../types.ts";
|
|
2
|
+
import type { ExtendedSimulationStore } from "../store/index.ts";
|
|
3
|
+
import type { Auth0User } from "../store/entities.ts";
|
|
4
|
+
type Predicate<T> = (this: void, value: T, index: number, obj: T[]) => boolean;
|
|
5
|
+
export declare const createPersonQuery: (store: ExtendedSimulationStore) => (predicate: Predicate<Auth0User>) => {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
password: string;
|
|
9
|
+
email?: string | undefined;
|
|
10
|
+
picture?: string | undefined;
|
|
11
|
+
} | undefined;
|
|
5
12
|
export declare const deriveScope: ({ scopeConfig, clientID, audience, }: {
|
|
6
13
|
scopeConfig: ScopeConfig;
|
|
7
14
|
clientID: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/handlers/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/handlers/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,KAAK,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,GAC3B,OAAO,uBAAuB,MAAM,WAAW,SAAS,CAAC,SAAS,CAAC;;;;;;aAGnE,CAAC;AAEJ,eAAO,MAAM,WAAW,GAAI,sCAIzB;IACD,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,WAuCA,CAAC"}
|
package/dist/handlers/utils.js
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deriveScope = exports.createPersonQuery = void 0;
|
|
4
4
|
const assert_ts_1 = require("assert-ts");
|
|
5
|
-
const createPersonQuery = (
|
|
6
|
-
|
|
5
|
+
const createPersonQuery = (store) => (predicate) => {
|
|
6
|
+
const users = store.schema.users.selectTableAsList(store.store.getState());
|
|
7
|
+
return users.find(predicate);
|
|
7
8
|
};
|
|
8
9
|
exports.createPersonQuery = createPersonQuery;
|
|
9
10
|
const deriveScope = ({ scopeConfig, clientID, audience, }) => {
|
|
10
|
-
if (typeof scopeConfig ===
|
|
11
|
+
if (typeof scopeConfig === "string")
|
|
11
12
|
return scopeConfig;
|
|
12
|
-
let defaultScope = scopeConfig.find((application) => application.clientID ===
|
|
13
|
+
let defaultScope = scopeConfig.find((application) => application.clientID === "default");
|
|
13
14
|
(0, assert_ts_1.assert)(!!clientID, `500::Did not have a clientID to derive the scope`);
|
|
14
15
|
let application = scopeConfig.find((application) => application.clientID === clientID &&
|
|
15
16
|
(application.audience ? application.audience === audience : true));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/handlers/utils.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/handlers/utils.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AAO5B,MAAM,iBAAiB,GAC5B,CAAC,KAA8B,EAAE,EAAE,CAAC,CAAC,SAA+B,EAAE,EAAE;IACtE,MAAM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AAC;IAED,IAAA,kBAAM,EACJ,CAAC,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-message.d.ts","sourceRoot":"","sources":["../../src/handlers/web-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAM9C,eAAO,MAAM,uBAAuB,QAAO,
|
|
1
|
+
{"version":3,"file":"web-message.d.ts","sourceRoot":"","sources":["../../src/handlers/web-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAM9C,eAAO,MAAM,uBAAuB,QAAO,cAoBxC,CAAC"}
|
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createWebMessageHandler = void 0;
|
|
4
4
|
const assert_ts_1 = require("assert-ts");
|
|
5
5
|
const base64_url_1 = require("base64-url");
|
|
6
|
-
const
|
|
6
|
+
const web_message_ts_1 = require("../views/web-message.js");
|
|
7
7
|
const createWebMessageHandler = () => function (req, res) {
|
|
8
|
-
(0, assert_ts_1.assert)(!!req.session, "no session");
|
|
8
|
+
(0, assert_ts_1.assert)(!!(req === null || req === void 0 ? void 0 : req.session), "no session");
|
|
9
9
|
let username = req.session.username;
|
|
10
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 = (0,
|
|
13
|
+
let message = (0, web_message_ts_1.webMessage)({
|
|
14
14
|
code: (0, base64_url_1.encode)(`${nonce}:${username}`),
|
|
15
15
|
state,
|
|
16
16
|
redirect_uri,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-message.js","sourceRoot":"","sources":["../../src/handlers/web-message.ts"],"names":[],"mappings":";;;AACA,yCAAmC;AACnC,2CAAoC;AAEpC,
|
|
1
|
+
{"version":3,"file":"web-message.js","sourceRoot":"","sources":["../../src/handlers/web-message.ts"],"names":[],"mappings":";;;AACA,yCAAmC;AACnC,2CAAoC;AAEpC,4DAAqD;AAE9C,MAAM,uBAAuB,GAAG,GAAmB,EAAE,CAC1D,UAAU,GAAG,EAAE,GAAG;IAChB,IAAA,kBAAM,EAAC,CAAC,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,CAAA,EAAE,YAAY,CAAC,CAAC;IAErC,IAAI,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;IAEpC,IAAA,kBAAM,EAAC,CAAC,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAC;IAE/C,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,KAAoB,CAAC;IAE9D,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAErC,IAAI,OAAO,GAAG,IAAA,2BAAU,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;AApBS,QAAA,uBAAuB,2BAoBhC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import type
|
|
4
|
-
import
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
export declare function createAuth0Server(options: Auth0ServerOptions): Operation<Server>;
|
|
18
|
-
export declare const auth0: Simulator;
|
|
1
|
+
import { createFoundationSimulationServer, type SimulationHandlers, type FoundationSimulator } from "@simulacrum/foundation-simulator";
|
|
2
|
+
import { ExtendedSimulationStore } from "./store/index.ts";
|
|
3
|
+
import { type Auth0InitialStore } from "./store/entities.ts";
|
|
4
|
+
import { Auth0Configuration } from "./types.ts";
|
|
5
|
+
export type Auth0Simulator = ({ initialState, extend, options, }?: {
|
|
6
|
+
initialState?: Auth0InitialStore;
|
|
7
|
+
extend?: {
|
|
8
|
+
extendStore?: SimulationInput["extendStore"];
|
|
9
|
+
openapiHandlers?: (simulationStore: ExtendedSimulationStore) => SimulationHandlers;
|
|
10
|
+
extendRouter?: SimulationInput["extendRouter"];
|
|
11
|
+
};
|
|
12
|
+
options?: Partial<Auth0Configuration>;
|
|
13
|
+
}) => ReturnType<FoundationSimulator<ExtendedSimulationStore>>;
|
|
14
|
+
type SimulationInput = Parameters<typeof createFoundationSimulationServer>[0];
|
|
15
|
+
export declare const simulation: Auth0Simulator;
|
|
16
|
+
export { auth0UserSchema, defaultUser } from "./store/entities.ts";
|
|
19
17
|
//# sourceMappingURL=index.d.ts.map
|
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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACzB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAe,MAAM,kBAAkB,CAAC;AAExE,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG,CAAC,EAC5B,YAAY,EACZ,MAAM,EACN,OAAO,GACR,CAAC,EAAE;IACF,YAAY,CAAC,EAAE,iBAAiB,CAAC;IACjC,MAAM,CAAC,EAAE;QACP,WAAW,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;QAC7C,eAAe,CAAC,EAAE,CAChB,eAAe,EAAE,uBAAuB,KACrC,kBAAkB,CAAC;QACxB,YAAY,CAAC,EAAE,eAAe,CAAC,cAAc,CAAC,CAAC;KAChD,CAAC;IACF,OAAO,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACvC,KAAK,UAAU,CAAC,mBAAmB,CAAC,uBAAuB,CAAC,CAAC,CAAC;AAE/D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,gCAAgC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9E,eAAO,MAAM,UAAU,EAAE,cAWxB,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,129 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
let debug = !!slice.slice('debug').get();
|
|
44
|
-
let { port } = options;
|
|
45
|
-
let config = (0, get_config_1.getConfig)(slice.slice('options', 'options').get());
|
|
46
|
-
let serviceURL = () => (0, get_service_url_1.getServiceUrl)(slice.get());
|
|
47
|
-
let auth0Store = slice.slice('store', 'auth0');
|
|
48
|
-
auth0Store.set({});
|
|
49
|
-
let store = {
|
|
50
|
-
get: (nonce) => auth0Store.slice(nonce).get(),
|
|
51
|
-
set: (nonce, session) => auth0Store.slice(nonce).set(session),
|
|
52
|
-
};
|
|
53
|
-
let people = {
|
|
54
|
-
*[Symbol.iterator]() {
|
|
55
|
-
var _a;
|
|
56
|
-
let values = Object.values((_a = slice.slice('store', 'people').get()) !== null && _a !== void 0 ? _a : {});
|
|
57
|
-
for (let person of values) {
|
|
58
|
-
yield person;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
let server = yield createAuth0Server({
|
|
63
|
-
debug,
|
|
64
|
-
config,
|
|
65
|
-
store,
|
|
66
|
-
serviceURL,
|
|
67
|
-
people,
|
|
68
|
-
port
|
|
69
|
-
});
|
|
70
|
-
return {
|
|
71
|
-
port: server.port,
|
|
72
|
-
protocol: 'https',
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
function createAuth0Server(options) {
|
|
77
|
-
let { config, serviceURL, store, people, port, debug = true } = options;
|
|
78
|
-
let auth0 = (0, auth0_handlers_1.createAuth0Handlers)(store, people, serviceURL, config, debug);
|
|
79
|
-
let openid = (0, openid_handlers_1.createOpenIdHandlers)(serviceURL);
|
|
80
|
-
return {
|
|
81
|
-
name: 'Auth0Server',
|
|
82
|
-
*init() {
|
|
83
|
-
let app = (0, express_1.default)()
|
|
84
|
-
.use(express_1.default.static(publicDir))
|
|
85
|
-
.use((0, session_1.createSession)())
|
|
86
|
-
.use((0, create_cors_1.createCors)())
|
|
87
|
-
.use((0, no_cache_1.noCache)())
|
|
88
|
-
.use((0, express_1.json)())
|
|
89
|
-
.use((0, express_1.urlencoded)({ extended: true }))
|
|
90
|
-
.get('/heartbeat', auth0['/heartbeat'])
|
|
91
|
-
.get('/authorize', auth0['/authorize'])
|
|
92
|
-
.get('/login', auth0['/login'])
|
|
93
|
-
.get('/u/login', auth0['/usernamepassword/login'])
|
|
94
|
-
.post('/usernamepassword/login', auth0['/usernamepassword/login'])
|
|
95
|
-
.post('/login/callback', auth0['/login/callback'])
|
|
96
|
-
.post('/oauth/token', auth0['/oauth/token'])
|
|
97
|
-
.get('/userinfo', auth0['/userinfo'])
|
|
98
|
-
.get('/v2/logout', auth0['/v2/logout'])
|
|
99
|
-
.get('/.well-known/jwks.json', openid['/.well-known/jwks.json'])
|
|
100
|
-
.get('/.well-known/openid-configuration', openid['/.well-known/openid-configuration']);
|
|
101
|
-
if (debug) {
|
|
102
|
-
app.use(server_1.consoleLogger);
|
|
103
|
-
}
|
|
104
|
-
// needs to be the last middleware added
|
|
105
|
-
app.use(error_handling_middleware_1.defaultErrorHandler);
|
|
106
|
-
let server = yield (0, server_1.createServer)(app, { protocol: 'https', port });
|
|
107
|
-
return {
|
|
108
|
-
port: server.address.port
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
exports.createAuth0Server = createAuth0Server;
|
|
114
|
-
const auth0 = () => {
|
|
115
|
-
return {
|
|
116
|
-
services: { auth0: createAuth0Service },
|
|
117
|
-
scenarios: {
|
|
118
|
-
/**
|
|
119
|
-
* Here we just export the internal `person` scenario so that it can be
|
|
120
|
-
* used with the a standalone auth0 simulator. However,
|
|
121
|
-
* what we really need to have some way to _react_ to the person
|
|
122
|
-
* having been created and augment the record at that point.
|
|
123
|
-
*/
|
|
124
|
-
person: server_1.person
|
|
125
|
-
}
|
|
126
|
-
};
|
|
3
|
+
exports.defaultUser = exports.auth0UserSchema = exports.simulation = void 0;
|
|
4
|
+
const foundation_simulator_1 = require("@simulacrum/foundation-simulator");
|
|
5
|
+
const index_ts_1 = require("./store/index.js");
|
|
6
|
+
const index_ts_2 = require("./handlers/index.js");
|
|
7
|
+
const entities_ts_1 = require("./store/entities.js");
|
|
8
|
+
const get_config_ts_1 = require("./config/get-config.js");
|
|
9
|
+
const simulation = (args = {}) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const config = (0, get_config_ts_1.getConfig)(args.options);
|
|
12
|
+
const parsedInitialState = !(args === null || args === void 0 ? void 0 : args.initialState)
|
|
13
|
+
? undefined
|
|
14
|
+
: entities_ts_1.auth0InitialStoreSchema.parse(args === null || args === void 0 ? void 0 : args.initialState);
|
|
15
|
+
return (0, foundation_simulator_1.createFoundationSimulationServer)({
|
|
16
|
+
port: 4400, // default port
|
|
17
|
+
protocol: "https",
|
|
18
|
+
extendStore: (0, index_ts_1.extendStore)(parsedInitialState, (_a = args === null || args === void 0 ? void 0 : args.extend) === null || _a === void 0 ? void 0 : _a.extendStore),
|
|
19
|
+
extendRouter: (0, index_ts_2.extendRouter)(config),
|
|
20
|
+
})();
|
|
127
21
|
};
|
|
128
|
-
exports.
|
|
22
|
+
exports.simulation = simulation;
|
|
23
|
+
var entities_ts_2 = require("./store/entities.js");
|
|
24
|
+
Object.defineProperty(exports, "auth0UserSchema", { enumerable: true, get: function () { return entities_ts_2.auth0UserSchema; } });
|
|
25
|
+
Object.defineProperty(exports, "defaultUser", { enumerable: true, get: function () { return entities_ts_2.defaultUser; } });
|
|
129
26
|
//# sourceMappingURL=index.js.map
|