@simulacrum/auth0-simulator 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -206
- package/bin/start.js +7 -0
- package/dist/auth/constants.d.ts.map +1 -1
- package/dist/auth/constants.js +2 -5
- package/dist/auth/constants.js.map +1 -1
- package/dist/auth/date.js +3 -9
- 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 +6 -11
- 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 +10 -15
- 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 +18 -18
- 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 +81 -66
- 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 +36 -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 +3 -7
- 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 +55 -58
- 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 +11 -15
- package/dist/handlers/openid-handlers.js.map +1 -1
- package/dist/handlers/url.d.ts.map +1 -1
- package/dist/handlers/url.js +1 -5
- 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 +11 -15
- 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 +8 -12
- 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 +18 -127
- package/dist/index.js.map +1 -1
- package/dist/middleware/create-cors.d.ts +1 -1
- package/dist/middleware/create-cors.js +2 -9
- 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 -11
- package/dist/middleware/error-handling.js.map +1 -0
- package/dist/middleware/no-cache.d.ts +1 -1
- package/dist/middleware/no-cache.js +1 -5
- package/dist/middleware/no-cache.js.map +1 -1
- package/dist/middleware/session.d.ts +1 -1
- package/dist/middleware/session.js +3 -10
- package/dist/middleware/session.js.map +1 -1
- package/dist/rules/extensionless-file-name.js +1 -5
- package/dist/rules/extensionless-file-name.js.map +1 -1
- package/dist/rules/parse-rules-files.d.ts.map +1 -1
- package/dist/rules/parse-rules-files.js +15 -22
- 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 +14 -21
- 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/rules/types.js +1 -2
- package/dist/store/entities.d.ts +111 -0
- package/dist/store/entities.d.ts.map +1 -0
- package/dist/store/entities.js +38 -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 +44 -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 +21 -25
- 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 -34
- 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/username-password.js +3 -7
- package/dist/views/username-password.js.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 +3 -10
- package/dist/views/web-message.js.map +1 -1
- package/package.json +24 -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
package/dist/index.js
CHANGED
|
@@ -1,129 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
1
|
+
import { createFoundationSimulationServer, } from "@simulacrum/foundation-simulator";
|
|
2
|
+
import { extendStore } from "./store/index";
|
|
3
|
+
import { extendRouter } from "./handlers";
|
|
4
|
+
import { auth0InitialStoreSchema, } from "./store/entities";
|
|
5
|
+
import { getConfig } from "./config/get-config";
|
|
6
|
+
export const simulation = (args = {}) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const config = getConfig(args.options);
|
|
9
|
+
const parsedInitialState = !(args === null || args === void 0 ? void 0 : args.initialState)
|
|
10
|
+
? undefined
|
|
11
|
+
: auth0InitialStoreSchema.parse(args === null || args === void 0 ? void 0 : args.initialState);
|
|
12
|
+
return createFoundationSimulationServer({
|
|
13
|
+
port: 4400, // default port
|
|
14
|
+
protocol: "https",
|
|
15
|
+
extendStore: extendStore(parsedInitialState, (_a = args === null || args === void 0 ? void 0 : args.extend) === null || _a === void 0 ? void 0 : _a.extendStore),
|
|
16
|
+
extendRouter: extendRouter(config),
|
|
17
|
+
})();
|
|
20
18
|
};
|
|
21
|
-
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
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
|
-
};
|
|
127
|
-
};
|
|
128
|
-
exports.auth0 = auth0;
|
|
19
|
+
export { auth0UserSchema, defaultUser } from "./store/entities";
|
|
129
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,GAGjC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAA2B,WAAW,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAEL,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAoBhD,MAAM,CAAC,MAAM,UAAU,GAAmB,CAAC,IAAI,GAAG,EAAE,EAAE,EAAE;;IACtD,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,kBAAkB,GAAG,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,CAAA;QAC5C,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,uBAAuB,CAAC,KAAK,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,CAAC,CAAC;IACtD,OAAO,gCAAgC,CAAC;QACtC,IAAI,EAAE,IAAI,EAAE,eAAe;QAC3B,QAAQ,EAAE,OAAO;QACjB,WAAW,EAAE,WAAW,CAAC,kBAAkB,EAAE,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,0CAAE,WAAW,CAAC;QACvE,YAAY,EAAE,YAAY,CAAC,MAAM,CAAC;KACnC,CAAC,EAAE,CAAC;AACP,CAAC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createCors = void 0;
|
|
7
|
-
const cors_1 = __importDefault(require("cors"));
|
|
8
|
-
const createCors = () => (0, cors_1.default)({
|
|
1
|
+
import cors from "cors";
|
|
2
|
+
export const createCors = () => cors({
|
|
9
3
|
origin: (origin, cb) => {
|
|
10
4
|
if (typeof origin === "string") {
|
|
11
5
|
return cb(null, [origin]);
|
|
@@ -14,5 +8,4 @@ const createCors = () => (0, cors_1.default)({
|
|
|
14
8
|
},
|
|
15
9
|
credentials: true,
|
|
16
10
|
});
|
|
17
|
-
exports.createCors = createCors;
|
|
18
11
|
//# sourceMappingURL=create-cors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-cors.js","sourceRoot":"","sources":["../../src/middleware/create-cors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-cors.js","sourceRoot":"","sources":["../../src/middleware/create-cors.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,MAAM,UAAU,GAAG,GAAmB,EAAE,CAC7C,IAAI,CAAC;IACH,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE;QACrB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAC5B,CAAC;QAED,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAChB,CAAC;IACD,WAAW,EAAE,IAAI;CAClB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handling.d.ts","sourceRoot":"","sources":["../../src/middleware/error-handling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE/D,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,QA6BnB"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultErrorHandler = void 0;
|
|
4
|
-
function defaultErrorHandler(error, _req, res, next) {
|
|
1
|
+
export function defaultErrorHandler(error, _req, res, next) {
|
|
5
2
|
var _a;
|
|
6
3
|
if (res.headersSent) {
|
|
7
4
|
return next(error);
|
|
8
5
|
}
|
|
9
|
-
let assertCondition =
|
|
6
|
+
let assertCondition = "Assert condition failed: ";
|
|
10
7
|
if ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.startsWith(assertCondition)) {
|
|
11
8
|
let errorCode = 500;
|
|
12
9
|
let errorResponse = error.message;
|
|
13
|
-
if (error.message.includes(
|
|
10
|
+
if (error.message.includes("::")) {
|
|
14
11
|
let errorMessage = error.message.slice(assertCondition.length);
|
|
15
12
|
errorCode = parseInt(errorMessage.slice(0, 3));
|
|
16
13
|
errorResponse = errorMessage.slice(5);
|
|
@@ -19,9 +16,7 @@ function defaultErrorHandler(error, _req, res, next) {
|
|
|
19
16
|
}
|
|
20
17
|
else {
|
|
21
18
|
console.error(error);
|
|
22
|
-
res
|
|
23
|
-
.status(500)
|
|
24
|
-
.json({
|
|
19
|
+
res.status(500).json({
|
|
25
20
|
error: {
|
|
26
21
|
name: error.name,
|
|
27
22
|
message: error.message,
|
|
@@ -30,5 +25,4 @@ function defaultErrorHandler(error, _req, res, next) {
|
|
|
30
25
|
});
|
|
31
26
|
}
|
|
32
27
|
}
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=error-handling-middleware.js.map
|
|
28
|
+
//# sourceMappingURL=error-hand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 -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.noCache = void 0;
|
|
4
|
-
const noCache = () => (_, res, next) => {
|
|
1
|
+
export const noCache = () => (_, res, next) => {
|
|
5
2
|
res.set("Pragma", "no-cache");
|
|
6
3
|
res.set("Cache-Control", "no-cache, no-store");
|
|
7
4
|
next();
|
|
8
5
|
};
|
|
9
|
-
exports.noCache = noCache;
|
|
10
6
|
//# sourceMappingURL=no-cache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-cache.js","sourceRoot":"","sources":["../../src/middleware/no-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-cache.js","sourceRoot":"","sources":["../../src/middleware/no-cache.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAyB,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;IAClE,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC9B,GAAG,CAAC,GAAG,CAAC,eAAe,EAAE,oBAAoB,CAAC,CAAC;IAC/C,IAAI,EAAE,CAAC;AACT,CAAC,CAAC"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createSession = void 0;
|
|
7
|
-
const cookie_session_1 = __importDefault(require("cookie-session"));
|
|
1
|
+
import cookieSession from "cookie-session";
|
|
8
2
|
const twentyFourHours = 24 * 60 * 60 * 1000;
|
|
9
|
-
const createSession = () => {
|
|
10
|
-
return (
|
|
3
|
+
export const createSession = () => {
|
|
4
|
+
return cookieSession({
|
|
11
5
|
name: "session",
|
|
12
6
|
keys: ["shhh"],
|
|
13
7
|
secure: true,
|
|
@@ -16,5 +10,4 @@ const createSession = () => {
|
|
|
16
10
|
sameSite: "none",
|
|
17
11
|
});
|
|
18
12
|
};
|
|
19
|
-
exports.createSession = createSession;
|
|
20
13
|
//# sourceMappingURL=session.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/middleware/session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/middleware/session.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE5C,MAAM,CAAC,MAAM,aAAa,GAAG,GAAmB,EAAE;IAChD,OAAO,aAAa,CAAC;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;KACjB,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extensionlessFileName = void 0;
|
|
4
|
-
const extensionlessFileName = (fileName) => fileName.indexOf(".") === -1
|
|
1
|
+
export const extensionlessFileName = (fileName) => fileName.indexOf(".") === -1
|
|
5
2
|
? fileName
|
|
6
3
|
: fileName.split(".").slice(0, -1).join(".");
|
|
7
|
-
exports.extensionlessFileName = extensionlessFileName;
|
|
8
4
|
//# sourceMappingURL=extensionless-file-name.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensionless-file-name.js","sourceRoot":"","sources":["../../src/rules/extensionless-file-name.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extensionless-file-name.js","sourceRoot":"","sources":["../../src/rules/extensionless-file-name.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,QAAgB,EAAU,EAAE,CAChE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,CAAC,QAAQ;IACV,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-rules-files.d.ts","sourceRoot":"","sources":["../../src/rules/parse-rules-files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-rules-files.d.ts","sourceRoot":"","sources":["../../src/rules/parse-rules-files.ts"],"names":[],"mappings":"AAKA,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,GAChB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAAE,CAmCtC"}
|
|
@@ -1,35 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.parseRulesFiles = void 0;
|
|
7
|
-
const extensionless_file_name_1 = require("./extensionless-file-name");
|
|
8
|
-
const assert_ts_1 = require("assert-ts");
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
function parseRulesFiles(rulesPath) {
|
|
1
|
+
import { extensionlessFileName } from "./extensionless-file-name";
|
|
2
|
+
import { assert } from "assert-ts";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
export function parseRulesFiles(rulesPath) {
|
|
12
6
|
var _a;
|
|
13
|
-
let ruleFiles =
|
|
7
|
+
let ruleFiles = fs
|
|
14
8
|
.readdirSync(rulesPath)
|
|
15
|
-
.filter((f) =>
|
|
16
|
-
return (_a = ruleFiles
|
|
9
|
+
.filter((f) => path.extname(f) === ".js");
|
|
10
|
+
return ((_a = ruleFiles
|
|
17
11
|
.map((r) => {
|
|
18
|
-
let filename =
|
|
19
|
-
let jsonFile = `${
|
|
20
|
-
|
|
21
|
-
let rawRule =
|
|
12
|
+
let filename = path.join(rulesPath, r);
|
|
13
|
+
let jsonFile = `${extensionlessFileName(filename)}.json`;
|
|
14
|
+
assert(!!jsonFile, `no corresponding rule file for ${r}`);
|
|
15
|
+
let rawRule = fs.readFileSync(jsonFile, "utf8");
|
|
22
16
|
let { enabled, order = 0, stage = "login_success", } = JSON.parse(rawRule);
|
|
23
17
|
if (!enabled) {
|
|
24
18
|
return undefined;
|
|
25
19
|
}
|
|
26
|
-
let code =
|
|
20
|
+
let code = fs.readFileSync(filename, {
|
|
27
21
|
encoding: "utf-8",
|
|
28
22
|
});
|
|
29
23
|
return { code, filename, order, stage };
|
|
30
24
|
})
|
|
31
|
-
.flatMap(x => !!x ? x : [])
|
|
32
|
-
.sort((left, right) => left.order - right.order)) !== null && _a !== void 0 ? _a : [];
|
|
25
|
+
.flatMap((x) => (!!x ? x : []))
|
|
26
|
+
.sort((left, right) => left.order - right.order)) !== null && _a !== void 0 ? _a : []);
|
|
33
27
|
}
|
|
34
|
-
exports.parseRulesFiles = parseRulesFiles;
|
|
35
28
|
//# sourceMappingURL=parse-rules-files.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-rules-files.js","sourceRoot":"","sources":["../../src/rules/parse-rules-files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-rules-files.js","sourceRoot":"","sources":["../../src/rules/parse-rules-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAA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,KAAK,CAAC,mCAAI,EAAE,CACzD,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RuleContext, RuleUser } from
|
|
2
|
-
export
|
|
1
|
+
import type { RuleContext, RuleUser } from "./types";
|
|
2
|
+
export type RulesRunner = <A, I>(user: RuleUser, context: RuleContext<A, I>) => void;
|
|
3
3
|
export declare function createRulesRunner(rulesPath?: string): RulesRunner;
|
|
4
4
|
//# sourceMappingURL=rules-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules-runner.d.ts","sourceRoot":"","sources":["../../src/rules/rules-runner.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAQ,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE3D,
|
|
1
|
+
{"version":3,"file":"rules-runner.d.ts","sourceRoot":"","sources":["../../src/rules/rules-runner.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAQ,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE3D,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,EAAE,CAAC,EAC7B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,KACvB,IAAI,CAAC;AAwDV,wBAAgB,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CA4BjE"}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.createRulesRunner = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const vm_1 = __importDefault(require("vm"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const assert_ts_1 = require("assert-ts");
|
|
11
|
-
const parse_rules_files_1 = require("./parse-rules-files");
|
|
1
|
+
import path from "path";
|
|
2
|
+
import vm from "vm";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import { assert } from "assert-ts";
|
|
5
|
+
import { parseRulesFiles } from "./parse-rules-files";
|
|
12
6
|
async function runRule(user, context, rule) {
|
|
13
7
|
await new Promise((resolve, reject) => {
|
|
14
8
|
let sandbox = {
|
|
@@ -32,11 +26,11 @@ async function runRule(user, context, rule) {
|
|
|
32
26
|
},
|
|
33
27
|
},
|
|
34
28
|
};
|
|
35
|
-
let vmContext =
|
|
36
|
-
|
|
29
|
+
let vmContext = vm.createContext(sandbox);
|
|
30
|
+
assert(typeof rule !== "undefined", "undefined rule");
|
|
37
31
|
let { code, filename } = rule;
|
|
38
|
-
console.debug(`executing rule ${
|
|
39
|
-
let script = new
|
|
32
|
+
console.debug(`executing rule ${path.basename(filename)}`);
|
|
33
|
+
let script = new vm.Script(`
|
|
40
34
|
(async function(exports) {
|
|
41
35
|
try {
|
|
42
36
|
await (${code})(__simulator.user, __simulator.context, resolve);
|
|
@@ -53,15 +47,15 @@ async function runRule(user, context, rule) {
|
|
|
53
47
|
});
|
|
54
48
|
}).catch((error) => console.error(error));
|
|
55
49
|
}
|
|
56
|
-
function createRulesRunner(rulesPath) {
|
|
50
|
+
export function createRulesRunner(rulesPath) {
|
|
57
51
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
58
52
|
let callback = (_user, _context) => { };
|
|
59
|
-
if (typeof rulesPath ===
|
|
53
|
+
if (typeof rulesPath === "undefined") {
|
|
60
54
|
return callback;
|
|
61
55
|
}
|
|
62
|
-
let fullPath =
|
|
63
|
-
|
|
64
|
-
let rules =
|
|
56
|
+
let fullPath = path.join(process.cwd(), rulesPath);
|
|
57
|
+
assert(fs.existsSync(fullPath), `no rules directory at ${fullPath}`);
|
|
58
|
+
let rules = parseRulesFiles(rulesPath);
|
|
65
59
|
if (rules.length === 0) {
|
|
66
60
|
return callback;
|
|
67
61
|
}
|
|
@@ -72,5 +66,4 @@ function createRulesRunner(rulesPath) {
|
|
|
72
66
|
}
|
|
73
67
|
};
|
|
74
68
|
}
|
|
75
|
-
exports.createRulesRunner = createRulesRunner;
|
|
76
69
|
//# sourceMappingURL=rules-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules-runner.js","sourceRoot":"","sources":["../../src/rules/rules-runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rules-runner.js","sourceRoot":"","sources":["../../src/rules/rules-runner.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQtD,KAAK,UAAU,OAAO,CACpB,IAAc,EACd,OAA0B,EAC1B,IAAU;IAEV,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpC,IAAI,OAAO,GAAG;YACZ,OAAO;YACP,MAAM;YACN,cAAc;YACd,aAAa;YACb,YAAY;YACZ,YAAY;YACZ,WAAW;YACX,UAAU;YACV,OAAO;YACP,OAAO;YACP,MAAM;YACN,OAAO;YACP,MAAM;YACN,WAAW,EAAE;gBACX,GAAG;oBACD,IAAI;oBACJ,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE;iBACxB;aACF;SACF,CAAC;QAEF,IAAI,SAAS,GAAG,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,CAAC,OAAO,IAAI,KAAK,WAAW,EAAE,gBAAgB,CAAC,CAAC;QAEtD,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAE9B,OAAO,CAAC,KAAK,CAAC,kBAAkB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAE3D,IAAI,MAAM,GAAG,IAAI,EAAE,CAAC,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E,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,UAAU,EAAE,gBAAgB,EAAE,GAAG,SAAS,CAAC;CAC5C;AAED,KAAK,gBAAgB,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,WAAW,CAAC,CAAC,EAAE,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE;QACX,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KAC1B,GAAG,CAAC,CAAC;IAEN,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/rules/types.js
CHANGED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { IdProp } from "@simulacrum/foundation-simulator";
|
|
3
|
+
export declare const auth0UserSchema: z.ZodEffects<z.ZodObject<{
|
|
4
|
+
id: z.ZodDefault<z.ZodString>;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
password: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
7
|
+
email: z.ZodOptional<z.ZodString>;
|
|
8
|
+
picture: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
password: string;
|
|
13
|
+
email?: string | undefined;
|
|
14
|
+
picture?: string | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
name: string;
|
|
17
|
+
id?: string | undefined;
|
|
18
|
+
password?: string | undefined;
|
|
19
|
+
email?: string | undefined;
|
|
20
|
+
picture?: string | undefined;
|
|
21
|
+
}>, {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
password: string;
|
|
25
|
+
email?: string | undefined;
|
|
26
|
+
picture?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
name: string;
|
|
29
|
+
id?: string | undefined;
|
|
30
|
+
password?: string | undefined;
|
|
31
|
+
email?: string | undefined;
|
|
32
|
+
picture?: string | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
export type Auth0User = z.infer<typeof auth0UserSchema>;
|
|
35
|
+
export declare const defaultUser: {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
password: string;
|
|
39
|
+
email?: string | undefined;
|
|
40
|
+
picture?: string | undefined;
|
|
41
|
+
};
|
|
42
|
+
export declare const auth0InitialStoreSchema: z.ZodObject<{
|
|
43
|
+
users: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
44
|
+
id: z.ZodDefault<z.ZodString>;
|
|
45
|
+
name: z.ZodString;
|
|
46
|
+
password: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
47
|
+
email: z.ZodOptional<z.ZodString>;
|
|
48
|
+
picture: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
password: string;
|
|
53
|
+
email?: string | undefined;
|
|
54
|
+
picture?: string | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
name: string;
|
|
57
|
+
id?: string | undefined;
|
|
58
|
+
password?: string | undefined;
|
|
59
|
+
email?: string | undefined;
|
|
60
|
+
picture?: string | undefined;
|
|
61
|
+
}>, {
|
|
62
|
+
id: string;
|
|
63
|
+
name: string;
|
|
64
|
+
password: string;
|
|
65
|
+
email?: string | undefined;
|
|
66
|
+
picture?: string | undefined;
|
|
67
|
+
}, {
|
|
68
|
+
name: string;
|
|
69
|
+
id?: string | undefined;
|
|
70
|
+
password?: string | undefined;
|
|
71
|
+
email?: string | undefined;
|
|
72
|
+
picture?: string | undefined;
|
|
73
|
+
}>, "many">;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
users: {
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
password: string;
|
|
79
|
+
email?: string | undefined;
|
|
80
|
+
picture?: string | undefined;
|
|
81
|
+
}[];
|
|
82
|
+
}, {
|
|
83
|
+
users: {
|
|
84
|
+
name: string;
|
|
85
|
+
id?: string | undefined;
|
|
86
|
+
password?: string | undefined;
|
|
87
|
+
email?: string | undefined;
|
|
88
|
+
picture?: string | undefined;
|
|
89
|
+
}[];
|
|
90
|
+
}>;
|
|
91
|
+
export type AuthSession = {
|
|
92
|
+
username: string;
|
|
93
|
+
nonce: string;
|
|
94
|
+
};
|
|
95
|
+
export type Auth0Store = z.output<typeof auth0InitialStoreSchema> & {
|
|
96
|
+
sessions: AuthSession[];
|
|
97
|
+
};
|
|
98
|
+
export type Auth0InitialStore = z.input<typeof auth0InitialStoreSchema>;
|
|
99
|
+
export declare const convertToObj: <T extends {
|
|
100
|
+
[k: string]: any;
|
|
101
|
+
}>(arrayOfObjects: T[], key?: IdProp) => Record<IdProp, T>;
|
|
102
|
+
export declare const convertInitialStateToStoreState: (initialState: Auth0InitialStore | undefined) => {
|
|
103
|
+
users: Record<IdProp, {
|
|
104
|
+
id: string;
|
|
105
|
+
name: string;
|
|
106
|
+
password: string;
|
|
107
|
+
email?: string | undefined;
|
|
108
|
+
picture?: string | undefined;
|
|
109
|
+
}>;
|
|
110
|
+
} | undefined;
|
|
111
|
+
//# sourceMappingURL=entities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/store/entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAG1D,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcxB,CAAC;AACL,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AACxD,eAAO,MAAM,WAAW;;;;;;CAGtB,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAElC,CAAC;AACH,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAC9D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,uBAAuB,CAAC,GAAG;IAClE,QAAQ,EAAE,WAAW,EAAE,CAAC;CACzB,CAAC;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,kBACzC,CAAC,EAAE,QACd,MAAM,KACV,MAAM,CAAC,MAAM,EAAE,CAAC,CAIU,CAAC;AAE9B,eAAO,MAAM,+BAA+B,iBAC5B,iBAAiB,GAAG,SAAS;;;;;;;;aAQ5C,CAAC"}
|