@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.
Files changed (105) hide show
  1. package/README.md +28 -206
  2. package/bin/start.js +14 -0
  3. package/dist/auth/constants.d.ts.map +1 -1
  4. package/dist/auth/constants.js.map +1 -1
  5. package/dist/auth/date.d.ts.map +1 -1
  6. package/dist/auth/jwt.d.ts +1 -1
  7. package/dist/auth/jwt.d.ts.map +1 -1
  8. package/dist/auth/jwt.js +5 -5
  9. package/dist/auth/jwt.js.map +1 -1
  10. package/dist/auth/refresh-token.d.ts +2 -2
  11. package/dist/auth/refresh-token.d.ts.map +1 -1
  12. package/dist/auth/refresh-token.js +7 -8
  13. package/dist/auth/refresh-token.js.map +1 -1
  14. package/dist/config/get-config.d.ts +6 -6
  15. package/dist/config/get-config.d.ts.map +1 -1
  16. package/dist/config/get-config.js +10 -10
  17. package/dist/config/get-config.js.map +1 -1
  18. package/dist/handlers/auth0-handlers.d.ts +6 -10
  19. package/dist/handlers/auth0-handlers.d.ts.map +1 -1
  20. package/dist/handlers/auth0-handlers.js +96 -70
  21. package/dist/handlers/auth0-handlers.js.map +1 -1
  22. package/dist/handlers/index.d.ts +5 -0
  23. package/dist/handlers/index.d.ts.map +1 -0
  24. package/dist/handlers/index.js +43 -0
  25. package/dist/handlers/index.js.map +1 -0
  26. package/dist/handlers/login-redirect.d.ts +2 -2
  27. package/dist/handlers/login-redirect.d.ts.map +1 -1
  28. package/dist/handlers/login-redirect.js.map +1 -1
  29. package/dist/handlers/oauth-handlers.d.ts +10 -9
  30. package/dist/handlers/oauth-handlers.d.ts.map +1 -1
  31. package/dist/handlers/oauth-handlers.js +56 -50
  32. package/dist/handlers/oauth-handlers.js.map +1 -1
  33. package/dist/handlers/openid-handlers.d.ts +4 -4
  34. package/dist/handlers/openid-handlers.d.ts.map +1 -1
  35. package/dist/handlers/openid-handlers.js +10 -10
  36. package/dist/handlers/openid-handlers.js.map +1 -1
  37. package/dist/handlers/url.d.ts.map +1 -1
  38. package/dist/handlers/url.js +1 -1
  39. package/dist/handlers/url.js.map +1 -1
  40. package/dist/handlers/utils.d.ts +11 -4
  41. package/dist/handlers/utils.d.ts.map +1 -1
  42. package/dist/handlers/utils.js +5 -4
  43. package/dist/handlers/utils.js.map +1 -1
  44. package/dist/handlers/web-message.d.ts +1 -1
  45. package/dist/handlers/web-message.d.ts.map +1 -1
  46. package/dist/handlers/web-message.js +3 -3
  47. package/dist/handlers/web-message.js.map +1 -1
  48. package/dist/index.d.ts +16 -18
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +22 -125
  51. package/dist/index.js.map +1 -1
  52. package/dist/middleware/create-cors.d.ts +1 -1
  53. package/dist/middleware/create-cors.js.map +1 -1
  54. package/dist/middleware/error-handling.d.ts +3 -0
  55. package/dist/middleware/error-handling.d.ts.map +1 -0
  56. package/dist/{error-handling-middleware.js → middleware/error-handling.js} +5 -8
  57. package/dist/middleware/error-handling.js.map +1 -0
  58. package/dist/middleware/no-cache.d.ts +1 -1
  59. package/dist/middleware/session.d.ts +1 -1
  60. package/dist/middleware/session.js.map +1 -1
  61. package/dist/rules/extensionless-file-name.d.ts.map +1 -1
  62. package/dist/rules/parse-rules-files.d.ts.map +1 -1
  63. package/dist/rules/parse-rules-files.js +7 -8
  64. package/dist/rules/parse-rules-files.js.map +1 -1
  65. package/dist/rules/rules-runner.d.ts +2 -2
  66. package/dist/rules/rules-runner.d.ts.map +1 -1
  67. package/dist/rules/rules-runner.js +49 -41
  68. package/dist/rules/rules-runner.js.map +1 -1
  69. package/dist/rules/types.d.ts +1 -1
  70. package/dist/rules/types.d.ts.map +1 -1
  71. package/dist/store/entities.d.ts +111 -0
  72. package/dist/store/entities.d.ts.map +1 -0
  73. package/dist/store/entities.js +43 -0
  74. package/dist/store/entities.js.map +1 -0
  75. package/dist/store/index.d.ts +37 -0
  76. package/dist/store/index.d.ts.map +1 -0
  77. package/dist/store/index.js +40 -0
  78. package/dist/store/index.js.map +1 -0
  79. package/dist/types.d.ts +20 -20
  80. package/dist/types.d.ts.map +1 -1
  81. package/dist/types.js +10 -11
  82. package/dist/types.js.map +1 -1
  83. package/dist/views/login.d.ts +2 -2
  84. package/dist/views/login.d.ts.map +1 -1
  85. package/dist/views/login.js +81 -30
  86. package/dist/views/login.js.map +1 -1
  87. package/dist/views/username-password.d.ts +2 -2
  88. package/dist/views/username-password.d.ts.map +1 -1
  89. package/dist/views/web-message.d.ts +1 -1
  90. package/dist/views/web-message.d.ts.map +1 -1
  91. package/dist/views/web-message.js.map +1 -1
  92. package/package.json +26 -41
  93. package/CHANGELOG.md +0 -176
  94. package/bin/index.js +0 -2
  95. package/dist/error-handling-middleware.d.ts +0 -3
  96. package/dist/error-handling-middleware.d.ts.map +0 -1
  97. package/dist/error-handling-middleware.js.map +0 -1
  98. package/dist/handlers/get-service-url.d.ts +0 -3
  99. package/dist/handlers/get-service-url.d.ts.map +0 -1
  100. package/dist/handlers/get-service-url.js +0 -11
  101. package/dist/handlers/get-service-url.js.map +0 -1
  102. package/dist/start.d.ts +0 -2
  103. package/dist/start.d.ts.map +0 -1
  104. package/dist/start.js +0 -77
  105. 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 date_1 = require("../auth/date");
7
- const jwt_1 = require("../auth/jwt");
8
- const rules_runner_1 = require("../rules/rules-runner");
9
- const utils_1 = require("./utils");
10
- const refresh_token_1 = require("../auth/refresh-token");
11
- const createTokens = async ({ body, iss, clientID, audience, rulesDirectory, people, scope: scopeConfig, }) => {
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, utils_1.deriveScope)({ scopeConfig, clientID, audience });
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 === 'client_credentials') {
18
- return { access_token: (0, jwt_1.createJsonWebToken)(accessToken) };
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 === 'refresh_token') {
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, utils_1.createPersonQuery)(people);
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
- people,
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, '500::No user found');
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, rules_runner_1.createRulesRunner)(rulesDirectory);
60
+ let rulesRunner = (0, rules_runner_ts_1.createRulesRunner)(rulesDirectory);
52
61
  // the rules mutate the values
53
- await rulesRunner(userData, context);
62
+ yield rulesRunner(userData, context);
54
63
  return {
55
- access_token: (0, jwt_1.createJsonWebToken)({
56
- ...accessToken,
57
- ...context.accessToken,
58
- }),
59
- id_token: (0, jwt_1.createJsonWebToken)({
60
- ...userData,
61
- ...context.idToken,
62
- }),
63
- refresh_token: (0, refresh_token_1.issueRefreshToken)(scope, grant_type) ? (0, refresh_token_1.createRefreshToken)({
64
- exp: idTokenData.exp,
65
- rotations: 0,
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, '500::User in store requires an email');
89
+ (0, assert_ts_1.assert)(!!user.email, "500::User in store requires an email");
84
90
  let idTokenData = {
85
- alg: 'RS256',
86
- typ: 'JWT',
91
+ alg: "RS256",
92
+ typ: "JWT",
87
93
  iss,
88
- exp: (0, date_1.expiresAt)(),
89
- iat: (0, date_1.epochTime)(),
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 !== 'undefined') {
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, date_1.expiresAt)(),
103
- iat: (0, date_1.epochTime)(),
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 = ({ people, body, grant_type, }) => {
115
+ const verifyUserExistsInStore = ({ simulationStore, body, grant_type, }) => {
110
116
  let { code } = body;
111
- let personQuery = (0, utils_1.createPersonQuery)(people);
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 === 'password') {
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 !== 'undefined', '400::no code in /oauth/token');
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 === 'undefined') {
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, '401::Unauthorized');
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":";;;AAAA,yCAAmC;AACnC,2CAA4D;AAC5D,uCAAoD;AACpD,qCAAiD;AACjD,wDAA0D;AAC1D,mCAAyD;AAYzD,yDAA8E;AAEvE,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,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AK,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 'express';
2
- declare type Routes = '/jwks.json' | '/openid-configuration';
3
- export declare type OpenIdRoutes = `${`/.well-known`}${Routes}`;
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: () => URL) => Record<OpenIdRoutes, RequestHandler>;
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;AAI9C,aAAK,MAAM,GACP,YAAY,GACZ,uBAAuB,CAAA;AAE3B,oBAAY,YAAY,GAAG,GAAG,cAAc,GAAG,MAAM,EAAE,CAAA;AAEvD,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,eAAgB,MAAM,GAAG,KAAG,OAAO,YAAY,EAAE,cAAc,CAkB/F,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 constants_1 = require("../auth/constants");
5
- const url_1 = require("./url");
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
- ['/.well-known/jwks.json']: function (_, res) {
9
- res.json(constants_1.JWKS);
8
+ ["/.well-known/jwks.json"]: function (_, res) {
9
+ res.json(constants_ts_1.JWKS);
10
10
  },
11
- ['/.well-known/openid-configuration']: function (_, res) {
12
- let url = (0, url_1.removeTrailingSlash)(serviceURL().toString());
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,iDAAyC;AACzC,+BAA4C;AAgBrC,MAAM,oBAAoB,GAAG,CAAC,UAAqB,EAAwC,EAAE;IAClG,OAAO;QACL,CAAC,wBAAwB,CAAC,EAAE,UAAS,CAAC,EAAE,GAAG;YACzC,GAAG,CAAC,IAAI,CAAC,gBAAI,CAAC,CAAC;QACjB,CAAC;QAED,CAAC,mCAAmC,CAAC,EAAE,UAAS,CAAC,EAAE,GAAG;YACpD,IAAI,GAAG,GAAG,IAAA,yBAAmB,EAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEvD,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"}
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,QAAS,MAAM,KAAG,MAAgC,CAAC"}
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"}
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/handlers/url.ts"],"names":[],"mappings":";;;AAAO,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAAtE,QAAA,mBAAmB,uBAAmD"}
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"}
@@ -1,7 +1,14 @@
1
- import type { Person } from '@simulacrum/server';
2
- import type { ScopeConfig } from '../types';
3
- declare type Predicate<T> = (this: void, value: T, index: number, obj: T[]) => boolean;
4
- export declare const createPersonQuery: (people: Iterable<Person>) => (predicate: Predicate<Person>) => Person | undefined;
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,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,aAAK,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,OAAO,CAAC;AAE/E,eAAO,MAAM,iBAAiB,WACnB,SAAS,MAAM,CAAC,iBAAiB,UAAU,MAAM,CAAC,uBAE1D,CAAC;AAEJ,eAAO,MAAM,WAAW;iBAKT,WAAW;cACd,MAAM;cACN,MAAM;YAwCjB,CAAC"}
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"}
@@ -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 = (people) => (predicate) => {
6
- return [...people].find(predicate);
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 === 'string')
11
+ if (typeof scopeConfig === "string")
11
12
  return scopeConfig;
12
- let defaultScope = scopeConfig.find((application) => application.clientID === 'default');
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;AAM5B,MAAM,iBAAiB,GAC5B,CAAC,MAAwB,EAAE,EAAE,CAAC,CAAC,SAA4B,EAAE,EAAE;IAC7D,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC,CAAC;AAHS,QAAA,iBAAiB,qBAG1B;AAEG,MAAM,WAAW,GAAG,CAAC,EAC1B,WAAW,EACX,QAAQ,EACR,QAAQ,GAKT,EAAE,EAAE;IACH,IAAI,OAAO,WAAW,KAAK,QAAQ;QAAE,OAAO,WAAW,CAAC;IACxD,IAAI,YAAY,GAAG,WAAW,CAAC,IAAI,CACjC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,KAAK,SAA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AAC,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,3 +1,3 @@
1
- import type { RequestHandler } from 'express';
1
+ import type { RequestHandler } from "express";
2
2
  export declare const createWebMessageHandler: () => RequestHandler;
3
3
  //# sourceMappingURL=web-message.d.ts.map
@@ -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,cAwBxC,CAAC"}
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 web_message_1 = require("../views/web-message");
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, web_message_1.webMessage)({
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,sDAAkD;AAE3C,MAAM,uBAAuB,GAAG,GAAmB,EAAE,CAC1D,UAAS,GAAG,EAAE,GAAG;IACf,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"}
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 type { Person, Simulator } from '@simulacrum/server';
2
- import type { Operation } from 'effection';
3
- import type { Auth0Store } from './handlers/auth0-handlers';
4
- import type { Auth0Configuration } from './types';
5
- export { getConfig } from './config/get-config';
6
- export interface Server {
7
- port: number;
8
- }
9
- export interface Auth0ServerOptions {
10
- config: Auth0Configuration;
11
- store: Auth0Store;
12
- people: Iterable<Person>;
13
- serviceURL: () => URL;
14
- port?: number;
15
- debug?: boolean;
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAErF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAK3C,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,2BAA2B,CAAC;AAOzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIhD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AA4CD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,SAAS,CAAC,MAAM,CAAC,CAyChF;AAED,eAAO,MAAM,KAAK,EAAE,SAanB,CAAC"}
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.auth0 = exports.createAuth0Server = exports.getConfig = void 0;
26
- const server_1 = require("@simulacrum/server");
27
- const express_1 = __importStar(require("express"));
28
- const path_1 = __importDefault(require("path"));
29
- const get_config_1 = require("./config/get-config");
30
- const error_handling_middleware_1 = require("./error-handling-middleware");
31
- const auth0_handlers_1 = require("./handlers/auth0-handlers");
32
- const get_service_url_1 = require("./handlers/get-service-url");
33
- const openid_handlers_1 = require("./handlers/openid-handlers");
34
- const create_cors_1 = require("./middleware/create-cors");
35
- const no_cache_1 = require("./middleware/no-cache");
36
- const session_1 = require("./middleware/session");
37
- var get_config_2 = require("./config/get-config");
38
- Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return get_config_2.getConfig; } });
39
- const publicDir = path_1.default.join(__dirname, 'views', 'public');
40
- const createAuth0Service = (slice, options) => ({
41
- name: 'Auth0Service',
42
- *init() {
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.auth0 = auth0;
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