@vsaas/loopback 10.0.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.
Files changed (69) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +91 -0
  3. package/common/models/README.md +109 -0
  4. package/common/models/access-token.json +37 -0
  5. package/common/models/acl.json +17 -0
  6. package/common/models/application.json +130 -0
  7. package/common/models/change.json +25 -0
  8. package/common/models/checkpoint.json +14 -0
  9. package/common/models/email.json +11 -0
  10. package/common/models/key-value-model.json +4 -0
  11. package/common/models/role-mapping.json +26 -0
  12. package/common/models/role.json +30 -0
  13. package/common/models/scope.json +14 -0
  14. package/common/models/user.json +118 -0
  15. package/dist/_virtual/_rolldown/runtime.cjs +32 -0
  16. package/dist/common/models/access-token.cjs +144 -0
  17. package/dist/common/models/access-token2.cjs +43 -0
  18. package/dist/common/models/acl.cjs +428 -0
  19. package/dist/common/models/acl2.cjs +27 -0
  20. package/dist/common/models/application.cjs +100 -0
  21. package/dist/common/models/application2.cjs +118 -0
  22. package/dist/common/models/change.cjs +404 -0
  23. package/dist/common/models/change2.cjs +25 -0
  24. package/dist/common/models/checkpoint.cjs +43 -0
  25. package/dist/common/models/checkpoint2.cjs +18 -0
  26. package/dist/common/models/email.cjs +18 -0
  27. package/dist/common/models/email2.cjs +30 -0
  28. package/dist/common/models/key-value-model.cjs +140 -0
  29. package/dist/common/models/key-value-model2.cjs +14 -0
  30. package/dist/common/models/role-mapping.cjs +57 -0
  31. package/dist/common/models/role-mapping2.cjs +34 -0
  32. package/dist/common/models/role.cjs +396 -0
  33. package/dist/common/models/role2.cjs +38 -0
  34. package/dist/common/models/scope.cjs +30 -0
  35. package/dist/common/models/scope2.cjs +21 -0
  36. package/dist/common/models/user.cjs +810 -0
  37. package/dist/common/models/user2.cjs +118 -0
  38. package/dist/index.cjs +16 -0
  39. package/dist/lib/access-context.cjs +228 -0
  40. package/dist/lib/application.cjs +450 -0
  41. package/dist/lib/builtin-models.cjs +60 -0
  42. package/dist/lib/configure-shared-methods.cjs +41 -0
  43. package/dist/lib/connectors/base-connector.cjs +23 -0
  44. package/dist/lib/connectors/mail-direct-transport.cjs +375 -0
  45. package/dist/lib/connectors/mail-stub-transport.cjs +86 -0
  46. package/dist/lib/connectors/mail.cjs +128 -0
  47. package/dist/lib/connectors/memory.cjs +19 -0
  48. package/dist/lib/current-context.cjs +22 -0
  49. package/dist/lib/globalize.cjs +29 -0
  50. package/dist/lib/loopback.cjs +313 -0
  51. package/dist/lib/model.cjs +1009 -0
  52. package/dist/lib/persisted-model.cjs +1835 -0
  53. package/dist/lib/registry.cjs +291 -0
  54. package/dist/lib/runtime.cjs +25 -0
  55. package/dist/lib/server-app.cjs +231 -0
  56. package/dist/lib/utils.cjs +154 -0
  57. package/dist/package.cjs +124 -0
  58. package/dist/server/middleware/context.cjs +7 -0
  59. package/dist/server/middleware/error-handler.cjs +6 -0
  60. package/dist/server/middleware/favicon.cjs +13 -0
  61. package/dist/server/middleware/rest.cjs +44 -0
  62. package/dist/server/middleware/static.cjs +14 -0
  63. package/dist/server/middleware/status.cjs +28 -0
  64. package/dist/server/middleware/token.cjs +66 -0
  65. package/dist/server/middleware/url-not-found.cjs +20 -0
  66. package/favicon.ico +0 -0
  67. package/package.json +121 -0
  68. package/templates/reset-form.ejs +3 -0
  69. package/templates/verify.ejs +9 -0
@@ -0,0 +1,124 @@
1
+ //#region package.json
2
+ var require_package = /* @__PURE__ */ require("./_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
3
+ module.exports = {
4
+ "name": "@vsaas/loopback",
5
+ "version": "10.0.0",
6
+ "description": "LoopBack: Open Source Framework for Node.js",
7
+ "keywords": [
8
+ "StrongLoop",
9
+ "api",
10
+ "auth",
11
+ "express",
12
+ "framework",
13
+ "koa",
14
+ "mBaaS",
15
+ "mobile",
16
+ "mongo",
17
+ "mongodb",
18
+ "mssql",
19
+ "mysql",
20
+ "nosql",
21
+ "oracle",
22
+ "postgres",
23
+ "postgresql",
24
+ "rest",
25
+ "restful",
26
+ "restify",
27
+ "security",
28
+ "soap",
29
+ "sqlserver",
30
+ "web"
31
+ ],
32
+ "homepage": "http://loopback.io",
33
+ "license": "MIT",
34
+ "author": "IBM Corp.",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/strongloop/loopback"
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "common/models",
42
+ "templates",
43
+ "favicon.ico",
44
+ "README.md",
45
+ "LICENSE"
46
+ ],
47
+ "main": "dist/index.cjs",
48
+ "exports": {
49
+ ".": "./dist/index.cjs",
50
+ "./common/models/*.json": "./common/models/*.json",
51
+ "./common/models/*.js": "./dist/common/models/*.cjs",
52
+ "./common/models/*": "./dist/common/models/*.cjs",
53
+ "./lib/*.js": "./dist/lib/*.cjs",
54
+ "./lib/*": "./dist/lib/*.cjs",
55
+ "./server/middleware/*.js": "./dist/server/middleware/*.cjs",
56
+ "./server/middleware/*": "./dist/server/middleware/*.cjs",
57
+ "./package.json": "./package.json"
58
+ },
59
+ "publishConfig": {
60
+ "access": "public",
61
+ "registry": "https://registry.npmjs.org/"
62
+ },
63
+ "scripts": {
64
+ "build": "tsdown",
65
+ "fmt": "oxfmt -c ../.oxfmtrc.json .",
66
+ "lint": "oxlint -c ../.oxlintrc.json .",
67
+ "lint:fix": "oxlint -c ../.oxlintrc.json . --fix",
68
+ "prepack": "pnpm run build",
69
+ "test:run": "vitest run",
70
+ "test": "pnpm run build && vitest run",
71
+ "test:vitest": "pnpm run build && vitest run",
72
+ "typecheck": "tsc --noEmit"
73
+ },
74
+ "dependencies": {
75
+ "@aws-sdk/client-sesv2": "^3.1018.0",
76
+ "@vsaas/loopback-connector-remote": "workspace:^",
77
+ "@vsaas/loopback-datasource-juggler": "workspace:^",
78
+ "@vsaas/remoting": "workspace:^",
79
+ "bcryptjs": "^2.1.0",
80
+ "debug": "^2.1.2",
81
+ "depd": "^1.0.0",
82
+ "ejs": "^5.0.1",
83
+ "express": "^4.14.0",
84
+ "isemail": "^3.2.0",
85
+ "loopback-filters": "^1.0.0",
86
+ "nodemailer": "^8.0.4",
87
+ "serve-favicon": "^2.2.0"
88
+ },
89
+ "devDependencies": {
90
+ "@types/node": "catalog:",
91
+ "@vsaas/error-handler": "workspace:^",
92
+ "@vsaas/loopback-boot": "workspace:^",
93
+ "chai": "^4.2.0",
94
+ "cookie-parser": "^1.3.4",
95
+ "dirty-chai": "^2.0.1",
96
+ "express-session": "^1.14.0",
97
+ "loopback-context": "^1.0.0",
98
+ "oxfmt": "catalog:",
99
+ "oxlint": "catalog:",
100
+ "sinon": "^16.1.1",
101
+ "sinon-chai": "^3.2.0",
102
+ "strong-task-emitter": "^0.0.8",
103
+ "supertest": "catalog:",
104
+ "tsdown": "catalog:",
105
+ "typescript": "catalog:",
106
+ "vitest": "catalog:"
107
+ },
108
+ "config": { "ci": { "debug": "*,-mocha:*,-eslint:*" } },
109
+ "engines": { "node": ">=20" },
110
+ "ci": { "downstreamIgnoreList": [
111
+ "bluemix-service-broker",
112
+ "gateway-director-bluemix",
113
+ "plan-manager"
114
+ ] },
115
+ "copyright.owner": "IBM Corp."
116
+ };
117
+ }));
118
+ //#endregion
119
+ Object.defineProperty(exports, "default", {
120
+ enumerable: true,
121
+ get: function() {
122
+ return require_package();
123
+ }
124
+ });
@@ -0,0 +1,7 @@
1
+ //#region src/server/middleware/context.ts
2
+ const g = require("../../lib/globalize.cjs");
3
+ function context() {
4
+ throw new Error(g.f("%s middleware was removed in version 3.0. See %s for more details.", "@vsaas/loopback#context", "http://loopback.io/doc/en/lb2/Using-current-context.html"));
5
+ }
6
+ module.exports = context;
7
+ //#endregion
@@ -0,0 +1,6 @@
1
+ //#region src/server/middleware/error-handler.ts
2
+ function errorHandler(options) {
3
+ throw new Error("loopback.errorHandler is no longer available. Please use the module \"@vsaas/error-handler\" instead.");
4
+ }
5
+ module.exports = errorHandler;
6
+ //#endregion
@@ -0,0 +1,13 @@
1
+ //#region src/server/middleware/favicon.ts
2
+ const favicon = require("serve-favicon");
3
+ const path = require("path");
4
+ /**
5
+ * Serve the LoopBack favicon.
6
+ * @header loopback.favicon()
7
+ */
8
+ function serveFavicon(icon, options) {
9
+ icon = icon || path.join(__dirname, "../../../favicon.ico");
10
+ return favicon(icon, options);
11
+ }
12
+ module.exports = serveFavicon;
13
+ //#endregion
@@ -0,0 +1,44 @@
1
+ const require_lib_globalize = require("../../lib/globalize.cjs");
2
+ const require_server_middleware_token = require("./token.cjs");
3
+ //#region src/server/middleware/rest.ts
4
+ /*!
5
+ * Module dependencies.
6
+ */
7
+ const g = require_lib_globalize;
8
+ /*!
9
+ * Export the middleware.
10
+ */
11
+ function rest() {
12
+ let handlers;
13
+ return function restApiHandler(req, res, next) {
14
+ const app = req.app;
15
+ const registry = app.registry;
16
+ if (!handlers) {
17
+ handlers = [];
18
+ const contextOptions = (app.get("remoting") || {}).context;
19
+ if (contextOptions !== void 0 && contextOptions !== false) throw new Error(g.f("%s was removed in version 3.0. See %s for more details.", "remoting.context option", "http://loopback.io/doc/en/lb2/Using-current-context.html"));
20
+ if (app.isAuthEnabled) {
21
+ const AccessToken = registry.getModelByType("AccessToken");
22
+ const token = require_server_middleware_token;
23
+ handlers.push(token({
24
+ model: AccessToken,
25
+ app
26
+ }));
27
+ }
28
+ handlers.push(function(req, res, next) {
29
+ return app.handler("rest")(req, res, next);
30
+ });
31
+ }
32
+ if (handlers.length === 1) return handlers[0](req, res, next);
33
+ let index = 0;
34
+ runHandler();
35
+ function runHandler(err) {
36
+ if (err) return next(err);
37
+ if (index >= handlers.length) return next();
38
+ const handler = handlers[index++];
39
+ handler(req, res, runHandler);
40
+ }
41
+ };
42
+ }
43
+ module.exports = rest;
44
+ //#endregion
@@ -0,0 +1,14 @@
1
+ //#region src/server/middleware/static.ts
2
+ /**
3
+ * Serve static assets of a LoopBack application.
4
+ *
5
+ * @param {string} root The root directory from which the static assets are to
6
+ * be served.
7
+ * @param {object} options Refer to
8
+ * [express documentation](http://expressjs.com/4x/api.html#express.static)
9
+ * for the full list of available options.
10
+ * @header loopback.static(root, [options])
11
+ */
12
+ const express = require("express");
13
+ module.exports = express.static;
14
+ //#endregion
@@ -0,0 +1,28 @@
1
+ //#region src/server/middleware/status.ts
2
+ /*!
3
+ * Export the middleware.
4
+ */
5
+ /**
6
+ * Return [HTTP response](http://expressjs.com/4x/api.html#res.send) with basic application status information:
7
+ * date the application was started and uptime, in JSON format.
8
+ * For example:
9
+ * ```js
10
+ * {
11
+ * "started": "2014-06-05T00:26:49.750Z",
12
+ * "uptime": 9.394
13
+ * }
14
+ * ```
15
+ *
16
+ * @header loopback.status()
17
+ */
18
+ function status() {
19
+ const started = /* @__PURE__ */ new Date();
20
+ return function(req, res) {
21
+ res.send({
22
+ started,
23
+ uptime: (Date.now() - Number(started)) / 1e3
24
+ });
25
+ };
26
+ }
27
+ module.exports = status;
28
+ //#endregion
@@ -0,0 +1,66 @@
1
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
2
+ const require_lib_globalize = require("../../lib/globalize.cjs");
3
+ const require_lib_utils = require("../../lib/utils.cjs");
4
+ //#region src/server/middleware/token.ts
5
+ var require_token = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, module) => {
6
+ /*!
7
+ * Module dependencies.
8
+ */
9
+ const g = require_lib_globalize;
10
+ const utils = require_lib_utils;
11
+ const assert = require("assert");
12
+ const debug = require("debug")("loopback:middleware:token");
13
+ function rewriteUserLiteral(req, currentUserLiteral, next) {
14
+ if (!currentUserLiteral) return next();
15
+ const literalRegExp = new RegExp("/" + currentUserLiteral + "(/|$|\\?)", "g");
16
+ if (req.accessToken && req.accessToken.userId) {
17
+ const urlBeforeRewrite = req.url;
18
+ req.url = req.url.replace(literalRegExp, "/" + req.accessToken.userId + "$1");
19
+ if (req.url !== urlBeforeRewrite) debug("req.url has been rewritten from %s to %s", urlBeforeRewrite, req.url);
20
+ } else if (!req.accessToken && literalRegExp.test(req.url)) {
21
+ debug("URL %s matches current-user literal %s, but no (valid) access token was provided.", req.url, currentUserLiteral);
22
+ const error = new Error(g.f("Authorization Required"));
23
+ error.status = error.statusCode = 401;
24
+ error.code = "AUTHORIZATION_REQUIRED";
25
+ return next(error);
26
+ }
27
+ next();
28
+ }
29
+ function escapeRegExp(str) {
30
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
31
+ }
32
+ function token(options) {
33
+ options = options || {};
34
+ let TokenModel;
35
+ let currentUserLiteral = options.currentUserLiteral;
36
+ if (currentUserLiteral && typeof currentUserLiteral !== "string") {
37
+ debug("Set currentUserLiteral to 'me' as the value is not a string.");
38
+ currentUserLiteral = "me";
39
+ }
40
+ if (typeof currentUserLiteral === "string") currentUserLiteral = escapeRegExp(currentUserLiteral);
41
+ if (options.bearerTokenBase64Encoded === void 0) options.bearerTokenBase64Encoded = true;
42
+ const enableDoublecheck = !!options.enableDoublecheck;
43
+ const overwriteExistingToken = !!options.overwriteExistingToken;
44
+ return function(req, res, next) {
45
+ const registry = req.app.registry;
46
+ if (!TokenModel) TokenModel = registry.getModel(options.model || "AccessToken");
47
+ assert(typeof TokenModel === "function", "loopback.token() middleware requires a AccessToken model");
48
+ if (req.accessToken !== void 0) {
49
+ if (!enableDoublecheck) return rewriteUserLiteral(req, currentUserLiteral, next);
50
+ if (req.accessToken && req.accessToken.id && !overwriteExistingToken) return rewriteUserLiteral(req, currentUserLiteral, next);
51
+ }
52
+ utils.invokeWithCallback(TokenModel.findForRequest, TokenModel, [req, options]).then(function(token) {
53
+ req.accessToken = token || null;
54
+ const ctx = req.loopbackContext;
55
+ if (ctx && ctx.active) ctx.set("accessToken", token);
56
+ rewriteUserLiteral(req, currentUserLiteral, next);
57
+ }, function(err) {
58
+ req.accessToken = null;
59
+ next(err);
60
+ });
61
+ };
62
+ }
63
+ module.exports = token;
64
+ }));
65
+ //#endregion
66
+ module.exports = require_token();
@@ -0,0 +1,20 @@
1
+ //#region src/server/middleware/url-not-found.ts
2
+ /*!
3
+ * Export the middleware.
4
+ * See discussion in Connect pull request #954 for more details
5
+ * https://github.com/senchalabs/connect/pull/954.
6
+ */
7
+ /**
8
+ * Convert any request not handled so far to a 404 error
9
+ * to be handled by error-handling middleware.
10
+ * @header loopback.urlNotFound()
11
+ */
12
+ function urlNotFound() {
13
+ return function raiseUrlNotFoundError(req, res, next) {
14
+ const error = /* @__PURE__ */ new Error("Cannot " + req.method + " " + req.url);
15
+ error.status = 404;
16
+ next(error);
17
+ };
18
+ }
19
+ module.exports = urlNotFound;
20
+ //#endregion
package/favicon.ico ADDED
Binary file
package/package.json ADDED
@@ -0,0 +1,121 @@
1
+ {
2
+ "name": "@vsaas/loopback",
3
+ "version": "10.0.0",
4
+ "description": "LoopBack: Open Source Framework for Node.js",
5
+ "keywords": [
6
+ "StrongLoop",
7
+ "api",
8
+ "auth",
9
+ "express",
10
+ "framework",
11
+ "koa",
12
+ "mBaaS",
13
+ "mobile",
14
+ "mongo",
15
+ "mongodb",
16
+ "mssql",
17
+ "mysql",
18
+ "nosql",
19
+ "oracle",
20
+ "postgres",
21
+ "postgresql",
22
+ "rest",
23
+ "restful",
24
+ "restify",
25
+ "security",
26
+ "soap",
27
+ "sqlserver",
28
+ "web"
29
+ ],
30
+ "homepage": "http://loopback.io",
31
+ "license": "MIT",
32
+ "author": "IBM Corp.",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/strongloop/loopback"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "common/models",
40
+ "templates",
41
+ "favicon.ico",
42
+ "README.md",
43
+ "LICENSE"
44
+ ],
45
+ "main": "dist/index.cjs",
46
+ "exports": {
47
+ ".": "./dist/index.cjs",
48
+ "./common/models/*.json": "./common/models/*.json",
49
+ "./common/models/*.js": "./dist/common/models/*.cjs",
50
+ "./common/models/*": "./dist/common/models/*.cjs",
51
+ "./lib/*.js": "./dist/lib/*.cjs",
52
+ "./lib/*": "./dist/lib/*.cjs",
53
+ "./server/middleware/*.js": "./dist/server/middleware/*.cjs",
54
+ "./server/middleware/*": "./dist/server/middleware/*.cjs",
55
+ "./package.json": "./package.json"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public",
59
+ "registry": "https://registry.npmjs.org/"
60
+ },
61
+ "dependencies": {
62
+ "@aws-sdk/client-sesv2": "^3.1018.0",
63
+ "bcryptjs": "^2.1.0",
64
+ "debug": "^2.1.2",
65
+ "depd": "^1.0.0",
66
+ "ejs": "^5.0.1",
67
+ "express": "^4.14.0",
68
+ "isemail": "^3.2.0",
69
+ "loopback-filters": "^1.0.0",
70
+ "nodemailer": "^8.0.4",
71
+ "serve-favicon": "^2.2.0",
72
+ "@vsaas/loopback-connector-remote": "^10.0.0",
73
+ "@vsaas/loopback-datasource-juggler": "^10.0.0",
74
+ "@vsaas/remoting": "^10.0.0"
75
+ },
76
+ "devDependencies": {
77
+ "@types/node": "25.5.0",
78
+ "chai": "^4.2.0",
79
+ "cookie-parser": "^1.3.4",
80
+ "dirty-chai": "^2.0.1",
81
+ "express-session": "^1.14.0",
82
+ "loopback-context": "^1.0.0",
83
+ "oxfmt": "0.42.0",
84
+ "oxlint": "1.57.0",
85
+ "sinon": "^16.1.1",
86
+ "sinon-chai": "^3.2.0",
87
+ "strong-task-emitter": "^0.0.8",
88
+ "supertest": "7.2.2",
89
+ "tsdown": "0.21.5",
90
+ "typescript": "6.0.2",
91
+ "vitest": "4.1.1",
92
+ "@vsaas/error-handler": "^10.0.0",
93
+ "@vsaas/loopback-boot": "^10.0.0"
94
+ },
95
+ "config": {
96
+ "ci": {
97
+ "debug": "*,-mocha:*,-eslint:*"
98
+ }
99
+ },
100
+ "engines": {
101
+ "node": ">=20"
102
+ },
103
+ "ci": {
104
+ "downstreamIgnoreList": [
105
+ "bluemix-service-broker",
106
+ "gateway-director-bluemix",
107
+ "plan-manager"
108
+ ]
109
+ },
110
+ "copyright.owner": "IBM Corp.",
111
+ "scripts": {
112
+ "build": "tsdown",
113
+ "fmt": "oxfmt -c ../.oxfmtrc.json .",
114
+ "lint": "oxlint -c ../.oxlintrc.json .",
115
+ "lint:fix": "oxlint -c ../.oxlintrc.json . --fix",
116
+ "test:run": "vitest run",
117
+ "test": "pnpm run build && vitest run",
118
+ "test:vitest": "pnpm run build && vitest run",
119
+ "typecheck": "tsc --noEmit"
120
+ }
121
+ }
@@ -0,0 +1,3 @@
1
+ <form>
2
+
3
+ </form>
@@ -0,0 +1,9 @@
1
+ <h1>Thank You</h1>
2
+
3
+ <p>
4
+ Thanks for registering. Please follow the link below to complete your registration.
5
+ </p>
6
+
7
+ <p>
8
+ <a href="<%= verifyHref %>"><%= verifyHref %></a>
9
+ </p>