@vsaas/loopback 12.1.1 → 12.2.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 (117) hide show
  1. package/README.md +6 -0
  2. package/common/models/rate-limit-state.json +121 -0
  3. package/common/models/two-factor-challenge.json +112 -0
  4. package/common/models/two-factor-credential.json +117 -0
  5. package/common/models/two-factor-recovery-code.json +63 -0
  6. package/common/models/user.json +30 -0
  7. package/dist/_virtual/_rolldown/runtime.cjs +9 -2
  8. package/dist/common/models/access-token.d.cts +3 -0
  9. package/dist/common/models/acl.cjs +1 -3
  10. package/dist/common/models/acl.d.cts +1 -0
  11. package/dist/common/models/application.d.cts +3 -0
  12. package/dist/common/models/change.cjs +21 -18
  13. package/dist/common/models/change.d.cts +1 -0
  14. package/dist/common/models/checkpoint.d.cts +3 -0
  15. package/dist/common/models/email.d.cts +3 -0
  16. package/dist/common/models/key-value-model.d.cts +3 -0
  17. package/dist/common/models/rate-limit-state.cjs +7 -0
  18. package/dist/common/models/rate-limit-state.d.cts +3 -0
  19. package/dist/common/models/rate-limit-state2.cjs +109 -0
  20. package/dist/common/models/role-mapping.d.cts +3 -0
  21. package/dist/common/models/role.cjs +12 -8
  22. package/dist/common/models/role.d.cts +1 -0
  23. package/dist/common/models/scope.d.cts +3 -0
  24. package/dist/common/models/two-factor-challenge.cjs +7 -0
  25. package/dist/common/models/two-factor-challenge.d.cts +3 -0
  26. package/dist/common/models/two-factor-challenge2.cjs +108 -0
  27. package/dist/common/models/two-factor-credential.cjs +7 -0
  28. package/dist/common/models/two-factor-credential.d.cts +3 -0
  29. package/dist/common/models/two-factor-credential2.cjs +103 -0
  30. package/dist/common/models/two-factor-recovery-code.cjs +7 -0
  31. package/dist/common/models/two-factor-recovery-code.d.cts +3 -0
  32. package/dist/common/models/two-factor-recovery-code2.cjs +57 -0
  33. package/dist/common/models/user.cjs +258 -21
  34. package/dist/common/models/user.d.cts +3 -0
  35. package/dist/common/models/user2.cjs +30 -0
  36. package/dist/index.cjs +2 -0
  37. package/dist/index.d.cts +3 -0
  38. package/dist/lib/access-context.d.cts +33 -0
  39. package/dist/lib/application.d.cts +1 -0
  40. package/dist/lib/authentication-security-initializer.cjs +351 -0
  41. package/dist/lib/authentication-security-initializer.d.cts +4 -0
  42. package/dist/lib/builtin-models.cjs +12 -0
  43. package/dist/lib/builtin-models.d.cts +3 -0
  44. package/dist/lib/configure-shared-methods.cjs +7 -4
  45. package/dist/lib/configure-shared-methods.d.cts +3 -0
  46. package/dist/lib/connectors/base-connector.d.cts +6 -0
  47. package/dist/lib/connectors/mail-direct-transport.cjs +26 -23
  48. package/dist/lib/connectors/mail-direct-transport.d.cts +22 -0
  49. package/dist/lib/connectors/mail-stub-transport.d.cts +14 -0
  50. package/dist/lib/connectors/mail.d.cts +7 -0
  51. package/dist/lib/connectors/memory.d.cts +6 -0
  52. package/dist/lib/current-context.d.cts +3 -0
  53. package/dist/lib/globalize.d.cts +10 -0
  54. package/dist/lib/loopback.cjs +6 -0
  55. package/dist/lib/loopback.d.cts +1 -0
  56. package/dist/lib/model.d.cts +1 -0
  57. package/dist/lib/persisted-model.cjs +7 -12
  58. package/dist/lib/persisted-model.d.cts +1 -0
  59. package/dist/lib/rate-limit/algorithms/common.cjs +37 -0
  60. package/dist/lib/rate-limit/algorithms/failure-lockout.cjs +70 -0
  61. package/dist/lib/rate-limit/algorithms/fixed-window.cjs +61 -0
  62. package/dist/lib/rate-limit/algorithms/index.cjs +55 -0
  63. package/dist/lib/rate-limit/config.cjs +107 -0
  64. package/dist/lib/rate-limit/errors.cjs +58 -0
  65. package/dist/lib/rate-limit/index.cjs +15 -0
  66. package/dist/lib/rate-limit/index.d.cts +1 -0
  67. package/dist/lib/rate-limit/initializer.cjs +92 -0
  68. package/dist/lib/rate-limit/initializer.d.cts +4 -0
  69. package/dist/lib/rate-limit/limiter.cjs +368 -0
  70. package/dist/lib/rate-limit/registry.cjs +92 -0
  71. package/dist/lib/rate-limit/remote.cjs +180 -0
  72. package/dist/lib/rate-limit/remote.d.cts +6 -0
  73. package/dist/lib/rate-limit/stores/persisted-model.cjs +353 -0
  74. package/dist/lib/rate-limit/subject.cjs +127 -0
  75. package/dist/lib/rate-limit/types.cjs +1 -0
  76. package/dist/lib/rate-limit/types.d.cts +167 -0
  77. package/dist/lib/registry.d.cts +1 -0
  78. package/dist/lib/runtime.d.cts +10 -0
  79. package/dist/lib/server-app.d.cts +3 -0
  80. package/dist/lib/two-factor/config.cjs +199 -0
  81. package/dist/lib/two-factor/config.d.cts +55 -0
  82. package/dist/lib/two-factor/crypto.cjs +68 -0
  83. package/dist/lib/two-factor/crypto.d.cts +16 -0
  84. package/dist/lib/two-factor/errors.cjs +58 -0
  85. package/dist/lib/two-factor/errors.d.cts +18 -0
  86. package/dist/lib/two-factor/rate-limit.cjs +153 -0
  87. package/dist/lib/two-factor/rate-limit.d.cts +22 -0
  88. package/dist/lib/two-factor/recovery-codes.cjs +49 -0
  89. package/dist/lib/two-factor/recovery-codes.d.cts +16 -0
  90. package/dist/lib/two-factor/service.cjs +1108 -0
  91. package/dist/lib/two-factor/service.d.cts +78 -0
  92. package/dist/lib/two-factor/totp.cjs +50 -0
  93. package/dist/lib/two-factor/totp.d.cts +14 -0
  94. package/dist/lib/utils.d.cts +36 -0
  95. package/dist/package.cjs +46 -10
  96. package/dist/server/middleware/context.d.cts +3 -0
  97. package/dist/server/middleware/error-handler.d.cts +3 -0
  98. package/dist/server/middleware/favicon.d.cts +7 -0
  99. package/dist/server/middleware/rest.d.cts +6 -0
  100. package/dist/server/middleware/static.d.cts +3 -0
  101. package/dist/server/middleware/status.d.cts +19 -0
  102. package/dist/server/middleware/token.d.cts +3 -0
  103. package/dist/server/middleware/url-not-found.d.cts +13 -0
  104. package/docs/api-explorer-details.md +110 -0
  105. package/docs/application-guide.md +1110 -0
  106. package/docs/assets/explorer-api.png +0 -0
  107. package/docs/assets/explorer-endpoint.png +0 -0
  108. package/docs/assets/explorer-listing.png +0 -0
  109. package/docs/assets/explorer-req-res.png +0 -0
  110. package/docs/assets/lb-modules.png +0 -0
  111. package/docs/assets/loopback-architecture.png +0 -0
  112. package/docs/assets/loopback-concepts.png +0 -0
  113. package/docs/assets/loopback_ov.png +0 -0
  114. package/docs/rate-limiting.md +879 -0
  115. package/docs/two-factor-authentication.md +611 -0
  116. package/docs/two-factor-authenticator-loss-runbook.md +117 -0
  117. package/package.json +56 -20
@@ -0,0 +1,109 @@
1
+ //#region common/models/rate-limit-state.json
2
+ var require_rate_limit_state = /* @__PURE__ */ require("../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
3
+ module.exports = {
4
+ "name": "RateLimitState",
5
+ "base": "PersistedModel",
6
+ "strict": true,
7
+ "properties": {
8
+ "id": {
9
+ "type": "string",
10
+ "id": true
11
+ },
12
+ "namespace": {
13
+ "type": "string",
14
+ "required": true
15
+ },
16
+ "scope": {
17
+ "type": "string",
18
+ "required": true
19
+ },
20
+ "subjectType": {
21
+ "type": "string",
22
+ "required": true
23
+ },
24
+ "bucket": {
25
+ "type": "string",
26
+ "required": true
27
+ },
28
+ "subjectKeyId": {
29
+ "type": "string",
30
+ "required": true
31
+ },
32
+ "formatVersion": {
33
+ "type": "number",
34
+ "required": true,
35
+ "default": 1
36
+ },
37
+ "policyFingerprint": {
38
+ "type": "string",
39
+ "required": true
40
+ },
41
+ "failureCount": {
42
+ "type": "number",
43
+ "required": true,
44
+ "default": 0
45
+ },
46
+ "attemptCount": {
47
+ "type": "number",
48
+ "required": true,
49
+ "default": 0
50
+ },
51
+ "lockoutLevel": {
52
+ "type": "number",
53
+ "required": true,
54
+ "default": 0
55
+ },
56
+ "windowStartedAt": { "type": "date" },
57
+ "lastAttemptAt": { "type": "date" },
58
+ "lastFailureAt": { "type": "date" },
59
+ "blockedUntil": { "type": "date" },
60
+ "revision": {
61
+ "type": "number",
62
+ "required": true,
63
+ "default": 0
64
+ },
65
+ "lastOperationId": { "type": "string" },
66
+ "lastOperationResultJson": { "type": "string" },
67
+ "createdAt": {
68
+ "type": "date",
69
+ "defaultFn": "now"
70
+ },
71
+ "updatedAt": {
72
+ "type": "date",
73
+ "defaultFn": "now"
74
+ },
75
+ "expiresAt": {
76
+ "type": "date",
77
+ "required": true
78
+ }
79
+ },
80
+ "indexes": {
81
+ "rate_limit_expiry": { "keys": { "expiresAt": 1 } },
82
+ "rate_limit_bucket": { "keys": {
83
+ "namespace": 1,
84
+ "scope": 1,
85
+ "subjectType": 1,
86
+ "bucket": 1,
87
+ "blockedUntil": 1
88
+ } },
89
+ "rate_limit_policy": { "keys": {
90
+ "namespace": 1,
91
+ "scope": 1,
92
+ "bucket": 1,
93
+ "policyFingerprint": 1
94
+ } }
95
+ },
96
+ "acls": [{
97
+ "principalType": "ROLE",
98
+ "principalId": "$everyone",
99
+ "permission": "DENY"
100
+ }]
101
+ };
102
+ }));
103
+ //#endregion
104
+ Object.defineProperty(exports, "default", {
105
+ enumerable: true,
106
+ get: function() {
107
+ return require_rate_limit_state();
108
+ }
109
+ });
@@ -0,0 +1,3 @@
1
+ //#region src/common/models/role-mapping.d.ts
2
+ declare function configureRoleMapping(RoleMapping: any): void;
3
+ export = configureRoleMapping;
@@ -28,10 +28,12 @@ var require_role = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, modu
28
28
  "roles"
29
29
  ].forEach(function(rel) {
30
30
  Role.prototype[rel] = function(query, callback) {
31
- if (!callback) if (typeof query === "function") {
32
- callback = query;
33
- query = {};
34
- } else callback = utils.createPromiseCallback();
31
+ if (!callback) {
32
+ if (typeof query === "function") {
33
+ callback = query;
34
+ query = {};
35
+ } else callback = utils.createPromiseCallback();
36
+ }
35
37
  query = query || {};
36
38
  query.where = query.where || {};
37
39
  roleModel.resolveRelatedModels();
@@ -330,10 +332,12 @@ var require_role = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, modu
330
332
  return callback.promise;
331
333
  };
332
334
  Role.getRoles = function(context, options, callback) {
333
- if (!callback) if (typeof options === "function") {
334
- callback = options;
335
- options = {};
336
- } else callback = utils.createPromiseCallback();
335
+ if (!callback) {
336
+ if (typeof options === "function") {
337
+ callback = options;
338
+ options = {};
339
+ } else callback = utils.createPromiseCallback();
340
+ }
337
341
  if (!options) options = {};
338
342
  context.registry = this.registry;
339
343
  if (!(context instanceof AccessContext)) context = new AccessContext(context);
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,3 @@
1
+ //#region src/common/models/scope.d.ts
2
+ declare function configureScope(Scope: any): void;
3
+ export = configureScope;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ //#region src/common/models/two-factor-challenge.ts
3
+ var require_two_factor_challenge = /* @__PURE__ */ require("../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
4
+ module.exports = function configureTwoFactorChallenge(_TwoFactorChallenge) {};
5
+ }));
6
+ //#endregion
7
+ module.exports = require_two_factor_challenge();
@@ -0,0 +1,3 @@
1
+ //#region src/common/models/two-factor-challenge.d.ts
2
+ declare const _default: (_TwoFactorChallenge: any) => void;
3
+ export = _default;
@@ -0,0 +1,108 @@
1
+ //#region common/models/two-factor-challenge.json
2
+ var require_two_factor_challenge = /* @__PURE__ */ require("../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
3
+ module.exports = {
4
+ "name": "TwoFactorChallenge",
5
+ "base": "PersistedModel",
6
+ "strict": true,
7
+ "properties": {
8
+ "id": {
9
+ "type": "string",
10
+ "id": true
11
+ },
12
+ "principalType": {
13
+ "type": "string",
14
+ "required": true
15
+ },
16
+ "principalId": {
17
+ "type": "string",
18
+ "required": true
19
+ },
20
+ "credentialId": {
21
+ "type": "string",
22
+ "required": true
23
+ },
24
+ "credentialVersion": {
25
+ "type": "number",
26
+ "required": true
27
+ },
28
+ "flowType": {
29
+ "type": "string",
30
+ "required": true,
31
+ "default": "external"
32
+ },
33
+ "principalBindingKeyId": {
34
+ "type": "string",
35
+ "required": true
36
+ },
37
+ "principalBindingDigest": {
38
+ "type": "string",
39
+ "required": true
40
+ },
41
+ "status": {
42
+ "type": "string",
43
+ "required": true,
44
+ "default": "pending"
45
+ },
46
+ "attempts": {
47
+ "type": "number",
48
+ "required": true,
49
+ "default": 0
50
+ },
51
+ "maxAttempts": {
52
+ "type": "number",
53
+ "required": true
54
+ },
55
+ "verificationLeaseId": { "type": "string" },
56
+ "verificationLeaseExpiresAt": { "type": "date" },
57
+ "encryptedLoginContext": {
58
+ "type": "string",
59
+ "required": true
60
+ },
61
+ "loginContextKeyId": {
62
+ "type": "string",
63
+ "required": true
64
+ },
65
+ "includeUser": {
66
+ "type": "boolean",
67
+ "required": true,
68
+ "default": false
69
+ },
70
+ "createdAt": {
71
+ "type": "date",
72
+ "defaultFn": "now"
73
+ },
74
+ "expiresAt": {
75
+ "type": "date",
76
+ "required": true
77
+ },
78
+ "claimedAt": { "type": "date" },
79
+ "consumedAt": { "type": "date" },
80
+ "issuedTokenId": { "type": "string" }
81
+ },
82
+ "hidden": [
83
+ "encryptedLoginContext",
84
+ "principalBindingDigest",
85
+ "issuedTokenId"
86
+ ],
87
+ "indexes": {
88
+ "two_factor_challenge_expiry": { "keys": { "expiresAt": 1 } },
89
+ "two_factor_challenge_principal_status": { "keys": {
90
+ "principalType": 1,
91
+ "principalId": 1,
92
+ "status": 1
93
+ } }
94
+ },
95
+ "acls": [{
96
+ "principalType": "ROLE",
97
+ "principalId": "$everyone",
98
+ "permission": "DENY"
99
+ }]
100
+ };
101
+ }));
102
+ //#endregion
103
+ Object.defineProperty(exports, "default", {
104
+ enumerable: true,
105
+ get: function() {
106
+ return require_two_factor_challenge();
107
+ }
108
+ });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ //#region src/common/models/two-factor-credential.ts
3
+ var require_two_factor_credential = /* @__PURE__ */ require("../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
4
+ module.exports = function configureTwoFactorCredential(_TwoFactorCredential) {};
5
+ }));
6
+ //#endregion
7
+ module.exports = require_two_factor_credential();
@@ -0,0 +1,3 @@
1
+ //#region src/common/models/two-factor-credential.d.ts
2
+ declare const _default: (_TwoFactorCredential: any) => void;
3
+ export = _default;
@@ -0,0 +1,103 @@
1
+ //#region common/models/two-factor-credential.json
2
+ var require_two_factor_credential = /* @__PURE__ */ require("../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
3
+ module.exports = {
4
+ "name": "TwoFactorCredential",
5
+ "base": "PersistedModel",
6
+ "strict": true,
7
+ "properties": {
8
+ "id": {
9
+ "type": "string",
10
+ "id": true,
11
+ "defaultFn": "guid"
12
+ },
13
+ "principalType": {
14
+ "type": "string",
15
+ "required": true
16
+ },
17
+ "principalId": {
18
+ "type": "string",
19
+ "required": true
20
+ },
21
+ "provider": {
22
+ "type": "string",
23
+ "required": true,
24
+ "default": "totp"
25
+ },
26
+ "totpAlgorithm": {
27
+ "type": "string",
28
+ "required": true,
29
+ "default": "SHA1"
30
+ },
31
+ "totpDigits": {
32
+ "type": "number",
33
+ "required": true,
34
+ "default": 6
35
+ },
36
+ "totpPeriod": {
37
+ "type": "number",
38
+ "required": true,
39
+ "default": 30
40
+ },
41
+ "status": {
42
+ "type": "string",
43
+ "required": true,
44
+ "default": "pending"
45
+ },
46
+ "version": {
47
+ "type": "number",
48
+ "required": true,
49
+ "default": 1
50
+ },
51
+ "encryptedSecret": { "type": "string" },
52
+ "secretKeyId": { "type": "string" },
53
+ "enrollmentTokenDigest": { "type": "string" },
54
+ "activeRecoveryCodeSetId": { "type": "string" },
55
+ "activeRecoveryCodeFormatVersion": { "type": "number" },
56
+ "activeRecoveryCodeLength": { "type": "number" },
57
+ "lastUsedCounter": {
58
+ "type": "number",
59
+ "required": true,
60
+ "default": -1
61
+ },
62
+ "pendingExpiresAt": { "type": "date" },
63
+ "confirmedAt": { "type": "date" },
64
+ "disabledAt": { "type": "date" },
65
+ "createdAt": {
66
+ "type": "date",
67
+ "defaultFn": "now"
68
+ },
69
+ "updatedAt": {
70
+ "type": "date",
71
+ "defaultFn": "now"
72
+ }
73
+ },
74
+ "hidden": ["encryptedSecret", "enrollmentTokenDigest"],
75
+ "indexes": {
76
+ "two_factor_principal_provider_unique": {
77
+ "keys": {
78
+ "principalType": 1,
79
+ "principalId": 1,
80
+ "provider": 1
81
+ },
82
+ "options": { "unique": true }
83
+ },
84
+ "two_factor_principal_status": { "keys": {
85
+ "principalType": 1,
86
+ "principalId": 1,
87
+ "status": 1
88
+ } }
89
+ },
90
+ "acls": [{
91
+ "principalType": "ROLE",
92
+ "principalId": "$everyone",
93
+ "permission": "DENY"
94
+ }]
95
+ };
96
+ }));
97
+ //#endregion
98
+ Object.defineProperty(exports, "default", {
99
+ enumerable: true,
100
+ get: function() {
101
+ return require_two_factor_credential();
102
+ }
103
+ });
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ //#region src/common/models/two-factor-recovery-code.ts
3
+ var require_two_factor_recovery_code = /* @__PURE__ */ require("../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
4
+ module.exports = function configureTwoFactorRecoveryCode(_TwoFactorRecoveryCode) {};
5
+ }));
6
+ //#endregion
7
+ module.exports = require_two_factor_recovery_code();
@@ -0,0 +1,3 @@
1
+ //#region src/common/models/two-factor-recovery-code.d.ts
2
+ declare const _default: (_TwoFactorRecoveryCode: any) => void;
3
+ export = _default;
@@ -0,0 +1,57 @@
1
+ //#region common/models/two-factor-recovery-code.json
2
+ var require_two_factor_recovery_code = /* @__PURE__ */ require("../../_virtual/_rolldown/runtime.cjs").__commonJSMin(((exports, module) => {
3
+ module.exports = {
4
+ "name": "TwoFactorRecoveryCode",
5
+ "base": "PersistedModel",
6
+ "strict": true,
7
+ "properties": {
8
+ "id": {
9
+ "type": "string",
10
+ "id": true
11
+ },
12
+ "credentialId": {
13
+ "type": "string",
14
+ "required": true
15
+ },
16
+ "setId": {
17
+ "type": "string",
18
+ "required": true
19
+ },
20
+ "keyId": {
21
+ "type": "string",
22
+ "required": true
23
+ },
24
+ "status": {
25
+ "type": "string",
26
+ "required": true,
27
+ "default": "unused"
28
+ },
29
+ "reservationId": { "type": "string" },
30
+ "reservationExpiresAt": { "type": "date" },
31
+ "reservationOwnerType": { "type": "string" },
32
+ "reservationOwnerId": { "type": "string" },
33
+ "createdAt": {
34
+ "type": "date",
35
+ "defaultFn": "now"
36
+ },
37
+ "usedAt": { "type": "date" }
38
+ },
39
+ "indexes": { "two_factor_recovery_credential": { "keys": {
40
+ "credentialId": 1,
41
+ "setId": 1,
42
+ "status": 1
43
+ } } },
44
+ "acls": [{
45
+ "principalType": "ROLE",
46
+ "principalId": "$everyone",
47
+ "permission": "DENY"
48
+ }]
49
+ };
50
+ }));
51
+ //#endregion
52
+ Object.defineProperty(exports, "default", {
53
+ enumerable: true,
54
+ get: function() {
55
+ return require_two_factor_recovery_code();
56
+ }
57
+ });