@furystack/security 1.0.1 → 2.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 (74) hide show
  1. package/dist/helpers.js +17 -0
  2. package/dist/helpers.js.map +1 -0
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/password-authenticator.spec.js +59 -76
  6. package/dist/password-authenticator.spec.js.map +1 -1
  7. package/dist/security-policy-manager.spec.js +3 -4
  8. package/dist/security-policy-manager.spec.js.map +1 -1
  9. package/package.json +9 -11
  10. package/src/helpers.ts +14 -0
  11. package/src/index.ts +1 -1
  12. package/src/password-authenticator.spec.ts +75 -96
  13. package/src/security-policy-manager.spec.ts +4 -4
  14. package/{dist → types}/crypto-password-hasher.d.ts +0 -0
  15. package/{dist → types}/crypto-password-hasher.d.ts.map +0 -0
  16. package/{dist → types}/errors/index.d.ts +0 -0
  17. package/{dist → types}/errors/index.d.ts.map +0 -0
  18. package/{dist → types}/errors/password-complexity-error.d.ts +0 -0
  19. package/{dist → types}/errors/password-complexity-error.d.ts.map +0 -0
  20. package/{dist → types}/errors/unauthenticated-error.d.ts +0 -0
  21. package/{dist → types}/errors/unauthenticated-error.d.ts.map +0 -0
  22. package/types/helpers.d.ts +10 -0
  23. package/types/helpers.d.ts.map +1 -0
  24. package/{dist → types}/index.d.ts +1 -1
  25. package/{dist → types}/index.d.ts.map +1 -1
  26. package/{dist → types}/models/index.d.ts +0 -0
  27. package/{dist → types}/models/index.d.ts.map +0 -0
  28. package/{dist → types}/models/password-check-result.d.ts +0 -0
  29. package/{dist → types}/models/password-check-result.d.ts.map +0 -0
  30. package/{dist → types}/models/password-complexity-result.d.ts +0 -0
  31. package/{dist → types}/models/password-complexity-result.d.ts.map +0 -0
  32. package/{dist → types}/models/password-complexity-rule.d.ts +0 -0
  33. package/{dist → types}/models/password-complexity-rule.d.ts.map +0 -0
  34. package/{dist → types}/models/password-credential.d.ts +0 -0
  35. package/{dist → types}/models/password-credential.d.ts.map +0 -0
  36. package/{dist → types}/models/password-reset-token.d.ts +0 -0
  37. package/{dist → types}/models/password-reset-token.d.ts.map +0 -0
  38. package/{dist → types}/password-authenticator.d.ts +0 -0
  39. package/{dist → types}/password-authenticator.d.ts.map +0 -0
  40. package/types/password-authenticator.spec.d.ts +2 -0
  41. package/{dist → types}/password-authenticator.spec.d.ts.map +1 -1
  42. package/{dist → types}/password-complexity-rules/contains-lowercase.d.ts +0 -0
  43. package/{dist → types}/password-complexity-rules/contains-lowercase.d.ts.map +0 -0
  44. package/{dist → types}/password-complexity-rules/contains-lowercase.spec.d.ts +0 -0
  45. package/{dist → types}/password-complexity-rules/contains-lowercase.spec.d.ts.map +0 -0
  46. package/{dist → types}/password-complexity-rules/contains-uppercase.d.ts +0 -0
  47. package/{dist → types}/password-complexity-rules/contains-uppercase.d.ts.map +0 -0
  48. package/{dist → types}/password-complexity-rules/contains-uppercase.spec.d.ts +0 -0
  49. package/{dist → types}/password-complexity-rules/contains-uppercase.spec.d.ts.map +0 -0
  50. package/{dist → types}/password-complexity-rules/index.d.ts +0 -0
  51. package/{dist → types}/password-complexity-rules/index.d.ts.map +0 -0
  52. package/{dist → types}/password-complexity-rules/max-length.d.ts +0 -0
  53. package/{dist → types}/password-complexity-rules/max-length.d.ts.map +0 -0
  54. package/{dist → types}/password-complexity-rules/max-length.spec.d.ts +0 -0
  55. package/{dist → types}/password-complexity-rules/max-length.spec.d.ts.map +0 -0
  56. package/{dist → types}/password-complexity-rules/min-length.d.ts +0 -0
  57. package/{dist → types}/password-complexity-rules/min-length.d.ts.map +0 -0
  58. package/{dist → types}/password-complexity-rules/min-length.spec.d.ts +0 -0
  59. package/{dist → types}/password-complexity-rules/min-length.spec.d.ts.map +0 -0
  60. package/{dist → types}/password-hasher.d.ts +0 -0
  61. package/{dist → types}/password-hasher.d.ts.map +0 -0
  62. package/{dist → types}/security-policy-manager.d.ts +0 -0
  63. package/{dist → types}/security-policy-manager.d.ts.map +0 -0
  64. package/types/security-policy-manager.spec.d.ts +2 -0
  65. package/{dist → types}/security-policy-manager.spec.d.ts.map +1 -1
  66. package/{dist → types}/security-policy.d.ts +0 -0
  67. package/{dist → types}/security-policy.d.ts.map +0 -0
  68. package/dist/injector-extensions.d.ts +0 -13
  69. package/dist/injector-extensions.d.ts.map +0 -1
  70. package/dist/injector-extensions.js +0 -11
  71. package/dist/injector-extensions.js.map +0 -1
  72. package/dist/password-authenticator.spec.d.ts +0 -2
  73. package/dist/security-policy-manager.spec.d.ts +0 -2
  74. package/src/injector-extensions.ts +0 -21
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePasswordPolicy = void 0;
4
+ const security_policy_1 = require("./security-policy");
5
+ /**
6
+ * Sets up the @furystack/security with the provided settings
7
+ *
8
+ * @param injector The Injector instance
9
+ * @param {Partial<SecurityPolicy>} policy The security policy to use
10
+ */
11
+ const usePasswordPolicy = (injector, policy) => {
12
+ const plainPolicy = new security_policy_1.SecurityPolicy();
13
+ policy && Object.assign(plainPolicy, policy);
14
+ injector.setExplicitInstance(plainPolicy, security_policy_1.SecurityPolicy);
15
+ };
16
+ exports.usePasswordPolicy = usePasswordPolicy;
17
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AACA,uDAAkD;AAElD;;;;;GAKG;AACI,MAAM,iBAAiB,GAAG,CAAC,QAAkB,EAAE,MAAgC,EAAE,EAAE;IACxF,MAAM,WAAW,GAAG,IAAI,gCAAc,EAAE,CAAA;IACxC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;IAC5C,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,gCAAc,CAAC,CAAA;AAC3D,CAAC,CAAA;AAJY,QAAA,iBAAiB,qBAI7B"}
package/dist/index.js CHANGED
@@ -8,5 +8,5 @@ tslib_1.__exportStar(require("./password-authenticator"), exports);
8
8
  tslib_1.__exportStar(require("./password-complexity-rules"), exports);
9
9
  tslib_1.__exportStar(require("./password-hasher"), exports);
10
10
  tslib_1.__exportStar(require("./security-policy-manager"), exports);
11
- require("./injector-extensions");
11
+ tslib_1.__exportStar(require("./helpers"), exports);
12
12
  //# 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":";;;AAAA,mEAAwC;AACxC,mDAAwB;AACxB,mDAAwB;AACxB,mEAAwC;AACxC,sEAA2C;AAC3C,4DAAiC;AACjC,oEAAyC;AAEzC,iCAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mEAAwC;AACxC,mDAAwB;AACxB,mDAAwB;AACxB,mEAAwC;AACxC,sEAA2C;AAC3C,4DAAiC;AACjC,oEAAyC;AAEzC,oDAAyB"}
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@furystack/core");
4
4
  const inject_1 = require("@furystack/inject");
5
5
  const utils_1 = require("@furystack/utils");
6
- require("./injector-extensions");
7
- const uuid_1 = require("uuid");
6
+ const helpers_1 = require("./helpers");
8
7
  const models_1 = require("./models");
9
8
  const password_authenticator_1 = require("./password-authenticator");
10
9
  const password_complexity_rules_1 = require("./password-complexity-rules");
11
10
  const security_policy_manager_1 = require("./security-policy-manager");
12
11
  const errors_1 = require("./errors");
12
+ const crypto_1 = require("crypto");
13
+ const randomString = () => (0, crypto_1.randomBytes)(32).toString('hex');
13
14
  describe('PasswordAuthenticator', () => {
14
15
  it('Should be instantiated', () => {
15
16
  (0, utils_1.using)(new inject_1.Injector(), (i) => {
@@ -19,7 +20,7 @@ describe('PasswordAuthenticator', () => {
19
20
  });
20
21
  it('Should inherit policy from the extension method', () => {
21
22
  (0, utils_1.using)(new inject_1.Injector(), (i) => {
22
- i.usePasswordPolicy({
23
+ (0, helpers_1.usePasswordPolicy)(i, {
23
24
  passwordComplexityRules: [(0, password_complexity_rules_1.createMinLengthComplexityRule)(3)],
24
25
  });
25
26
  const auth = i.getInstance(password_authenticator_1.PasswordAuthenticator);
@@ -30,12 +31,10 @@ describe('PasswordAuthenticator', () => {
30
31
  describe('checkPasswordForUser', () => {
31
32
  it('Should return a truthy value for valid username and password', async () => {
32
33
  await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
33
- const userName = (0, uuid_1.v4)();
34
- const password = (0, uuid_1.v4)();
35
- i.setupStores((sm) => sm
36
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
37
- .addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' })));
38
- i.usePasswordPolicy({});
34
+ const userName = randomString();
35
+ const password = randomString();
36
+ (0, core_1.addStore)(i, new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' })).addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' }));
37
+ (0, helpers_1.usePasswordPolicy)(i, {});
39
38
  const authenticator = i.getInstance(password_authenticator_1.PasswordAuthenticator);
40
39
  const hasher = authenticator.getHasher();
41
40
  const passwordStore = i.getInstance(core_1.StoreManager).getStoreFor(models_1.PasswordCredential, 'userName');
@@ -47,12 +46,10 @@ describe('PasswordAuthenticator', () => {
47
46
  });
48
47
  it('Should return a falsy value for invalid username', async () => {
49
48
  await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
50
- const userName = (0, uuid_1.v4)();
51
- const password = (0, uuid_1.v4)();
52
- i.setupStores((sm) => sm
53
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
54
- .addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' })));
55
- i.usePasswordPolicy({});
49
+ const userName = randomString();
50
+ const password = randomString();
51
+ (0, core_1.addStore)(i, new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' })).addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' }));
52
+ (0, helpers_1.usePasswordPolicy)(i);
56
53
  const authenticator = i.getInstance(password_authenticator_1.PasswordAuthenticator);
57
54
  const hasher = authenticator.getHasher();
58
55
  const passwordStore = i.getInstance(core_1.StoreManager).getStoreFor(models_1.PasswordCredential, 'userName');
@@ -65,12 +62,10 @@ describe('PasswordAuthenticator', () => {
65
62
  });
66
63
  it('Should return a falsy value for invalid password', async () => {
67
64
  await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
68
- const userName = (0, uuid_1.v4)();
69
- const password = (0, uuid_1.v4)();
70
- i.setupStores((sm) => sm
71
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
72
- .addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' })));
73
- i.usePasswordPolicy({});
65
+ const userName = randomString();
66
+ const password = randomString();
67
+ (0, core_1.addStore)(i, new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' })).addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' }));
68
+ (0, helpers_1.usePasswordPolicy)(i);
74
69
  const authenticator = i.getInstance(password_authenticator_1.PasswordAuthenticator);
75
70
  const hasher = authenticator.getHasher();
76
71
  const passwordStore = i.getInstance(core_1.StoreManager).getStoreFor(models_1.PasswordCredential, 'userName');
@@ -83,12 +78,10 @@ describe('PasswordAuthenticator', () => {
83
78
  });
84
79
  it('Should return a falsy value for an expired password', async () => {
85
80
  await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
86
- const userName = (0, uuid_1.v4)();
87
- const password = (0, uuid_1.v4)();
88
- i.setupStores((sm) => sm
89
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
90
- .addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' })));
91
- i.usePasswordPolicy({ passwordExpirationDays: 1 });
81
+ const userName = randomString();
82
+ const password = randomString();
83
+ (0, core_1.addStore)(i, new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' })).addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' }));
84
+ (0, helpers_1.usePasswordPolicy)(i, { passwordExpirationDays: 1 });
92
85
  const authenticator = i.getInstance(password_authenticator_1.PasswordAuthenticator);
93
86
  const hasher = authenticator.getHasher();
94
87
  const passwordStore = i.getInstance(core_1.StoreManager).getStoreFor(models_1.PasswordCredential, 'userName');
@@ -106,13 +99,11 @@ describe('PasswordAuthenticator', () => {
106
99
  describe('setPasswordForUser', () => {
107
100
  it('Should be able to set the password for the user using the last password', async () => {
108
101
  await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
109
- const userName = (0, uuid_1.v4)();
110
- const lastPassword = (0, uuid_1.v4)();
111
- const password = (0, uuid_1.v4)();
112
- i.setupStores((sm) => sm
113
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
114
- .addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' })));
115
- i.usePasswordPolicy({});
102
+ const userName = randomString();
103
+ const lastPassword = randomString();
104
+ const password = randomString();
105
+ (0, core_1.addStore)(i, new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' })).addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' }));
106
+ (0, helpers_1.usePasswordPolicy)(i);
116
107
  const authenticator = i.getInstance(password_authenticator_1.PasswordAuthenticator);
117
108
  const hasher = authenticator.getHasher();
118
109
  const passwordStore = i.getInstance(core_1.StoreManager).getStoreFor(models_1.PasswordCredential, 'userName');
@@ -134,13 +125,11 @@ describe('PasswordAuthenticator', () => {
134
125
  });
135
126
  it('Should throw PasswordComplexityError if the complexity rules are not respected', async () => {
136
127
  await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
137
- const userName = (0, uuid_1.v4)();
138
- const lastPassword = (0, uuid_1.v4)();
128
+ const userName = randomString();
129
+ const lastPassword = randomString();
139
130
  const password = '';
140
- i.setupStores((sm) => sm
141
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
142
- .addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' })));
143
- i.usePasswordPolicy({ passwordComplexityRules: [(0, password_complexity_rules_1.createMinLengthComplexityRule)(3)] });
131
+ (0, core_1.addStore)(i, new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' })).addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' }));
132
+ (0, helpers_1.usePasswordPolicy)(i, { passwordComplexityRules: [(0, password_complexity_rules_1.createMinLengthComplexityRule)(3)] });
144
133
  const authenticator = i.getInstance(password_authenticator_1.PasswordAuthenticator);
145
134
  const hasher = authenticator.getHasher();
146
135
  const passwordStore = i.getInstance(core_1.StoreManager).getStoreFor(models_1.PasswordCredential, 'userName');
@@ -163,13 +152,11 @@ describe('PasswordAuthenticator', () => {
163
152
  });
164
153
  it('Should throw UnauthenticatedError if the last password is not valid', async () => {
165
154
  await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
166
- const userName = (0, uuid_1.v4)();
167
- const lastPassword = (0, uuid_1.v4)();
168
- const password = (0, uuid_1.v4)();
169
- i.setupStores((sm) => sm
170
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
171
- .addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' })));
172
- i.usePasswordPolicy();
155
+ const userName = randomString();
156
+ const lastPassword = randomString();
157
+ const password = randomString();
158
+ (0, core_1.addStore)(i, new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' })).addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' }));
159
+ (0, helpers_1.usePasswordPolicy)(i);
173
160
  const authenticator = i.getInstance(password_authenticator_1.PasswordAuthenticator);
174
161
  const hasher = authenticator.getHasher();
175
162
  const passwordStore = i.getInstance(core_1.StoreManager).getStoreFor(models_1.PasswordCredential, 'userName');
@@ -194,15 +181,14 @@ describe('PasswordAuthenticator', () => {
194
181
  describe('resetPasswordForUser', () => {
195
182
  it('Should reset the password with the valid token', async () => {
196
183
  await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
197
- const userName = (0, uuid_1.v4)();
198
- const lastPassword = (0, uuid_1.v4)();
199
- const password = (0, uuid_1.v4)();
200
- const token = (0, uuid_1.v4)();
201
- i.setupStores((sm) => sm
202
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
184
+ const userName = randomString();
185
+ const lastPassword = randomString();
186
+ const password = randomString();
187
+ const token = randomString();
188
+ (0, core_1.addStore)(i, new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
203
189
  .addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' }))
204
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordResetToken, primaryKey: 'token' })));
205
- i.usePasswordPolicy();
190
+ .addStore(new core_1.InMemoryStore({ model: models_1.PasswordResetToken, primaryKey: 'token' }));
191
+ (0, helpers_1.usePasswordPolicy)(i);
206
192
  const authenticator = i.getInstance(password_authenticator_1.PasswordAuthenticator);
207
193
  const hasher = authenticator.getHasher();
208
194
  const passwordStore = i.getInstance(core_1.StoreManager).getStoreFor(models_1.PasswordCredential, 'userName');
@@ -221,15 +207,14 @@ describe('PasswordAuthenticator', () => {
221
207
  });
222
208
  it('Should throw PasswordComplexityError if the complexity rules are not respected', async () => {
223
209
  await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
224
- const userName = (0, uuid_1.v4)();
225
- const lastPassword = (0, uuid_1.v4)();
210
+ const userName = randomString();
211
+ const lastPassword = randomString();
226
212
  const password = '';
227
- const token = (0, uuid_1.v4)();
228
- i.setupStores((sm) => sm
229
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
213
+ const token = randomString();
214
+ (0, core_1.addStore)(i, new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
230
215
  .addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' }))
231
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordResetToken, primaryKey: 'token' })));
232
- i.usePasswordPolicy({ passwordComplexityRules: [(0, password_complexity_rules_1.createMinLengthComplexityRule)(3)] });
216
+ .addStore(new core_1.InMemoryStore({ model: models_1.PasswordResetToken, primaryKey: 'token' }));
217
+ (0, helpers_1.usePasswordPolicy)(i, { passwordComplexityRules: [(0, password_complexity_rules_1.createMinLengthComplexityRule)(3)] });
233
218
  const authenticator = i.getInstance(password_authenticator_1.PasswordAuthenticator);
234
219
  const hasher = authenticator.getHasher();
235
220
  const passwordStore = i.getInstance(core_1.StoreManager).getStoreFor(models_1.PasswordCredential, 'userName');
@@ -248,15 +233,14 @@ describe('PasswordAuthenticator', () => {
248
233
  });
249
234
  it('Should throw UnauthenticatedError if the token is not valid', async () => {
250
235
  await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
251
- const userName = (0, uuid_1.v4)();
252
- const lastPassword = (0, uuid_1.v4)();
236
+ const userName = randomString();
237
+ const lastPassword = randomString();
253
238
  const password = '';
254
- const token = (0, uuid_1.v4)();
255
- i.setupStores((sm) => sm
256
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
239
+ const token = randomString();
240
+ (0, core_1.addStore)(i, new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
257
241
  .addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' }))
258
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordResetToken, primaryKey: 'token' })));
259
- i.usePasswordPolicy();
242
+ .addStore(new core_1.InMemoryStore({ model: models_1.PasswordResetToken, primaryKey: 'token' }));
243
+ (0, helpers_1.usePasswordPolicy)(i);
260
244
  const authenticator = i.getInstance(password_authenticator_1.PasswordAuthenticator);
261
245
  const hasher = authenticator.getHasher();
262
246
  const passwordStore = i.getInstance(core_1.StoreManager).getStoreFor(models_1.PasswordCredential, 'userName');
@@ -275,15 +259,14 @@ describe('PasswordAuthenticator', () => {
275
259
  });
276
260
  it('Should throw UnauthenticatedError and clean up token if the token has been expired', async () => {
277
261
  await (0, utils_1.usingAsync)(new inject_1.Injector(), async (i) => {
278
- const userName = (0, uuid_1.v4)();
279
- const lastPassword = (0, uuid_1.v4)();
262
+ const userName = randomString();
263
+ const lastPassword = randomString();
280
264
  const password = '';
281
- const token = (0, uuid_1.v4)();
282
- i.setupStores((sm) => sm
283
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
265
+ const token = randomString();
266
+ (0, core_1.addStore)(i, new core_1.InMemoryStore({ model: models_1.PasswordCredential, primaryKey: 'userName' }))
284
267
  .addStore(new core_1.InMemoryStore({ model: core_1.User, primaryKey: 'username' }))
285
- .addStore(new core_1.InMemoryStore({ model: models_1.PasswordResetToken, primaryKey: 'token' })));
286
- i.usePasswordPolicy({ resetTokenExpirationSeconds: 1 });
268
+ .addStore(new core_1.InMemoryStore({ model: models_1.PasswordResetToken, primaryKey: 'token' }));
269
+ (0, helpers_1.usePasswordPolicy)(i, { resetTokenExpirationSeconds: 1 });
287
270
  const authenticator = i.getInstance(password_authenticator_1.PasswordAuthenticator);
288
271
  const hasher = authenticator.getHasher();
289
272
  const passwordStore = i.getInstance(core_1.StoreManager).getStoreFor(models_1.PasswordCredential, 'userName');
@@ -1 +1 @@
1
- {"version":3,"file":"password-authenticator.spec.js","sourceRoot":"","sources":["../src/password-authenticator.spec.ts"],"names":[],"mappings":";;AAAA,0CAAmE;AACnE,8CAA4C;AAC5C,4CAAoD;AACpD,iCAA8B;AAC9B,+BAAyB;AACzB,qCAA4F;AAC5F,qEAAgE;AAChE,2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AC5G,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,oBAAoB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;gBACtF,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,CAAA;gBAE1C,iDAAiD;gBACjD,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;gBAC/E,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,CAAA;gBACtC,MAAM,CAAE,UAAwC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;gBAEtF,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,KAAK,EAAE,CAAA;gBAChD,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAC5B,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -2,16 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const inject_1 = require("@furystack/inject");
4
4
  const utils_1 = require("@furystack/utils");
5
- const uuid_1 = require("uuid");
6
- require("./injector-extensions");
5
+ const helpers_1 = require("./helpers");
7
6
  const security_policy_manager_1 = require("./security-policy-manager");
8
7
  describe('SecurityPolicyManager', () => {
9
8
  it('Should return false when no token expiration has been set', () => {
10
9
  (0, utils_1.using)(new inject_1.Injector(), (i) => {
11
- i.usePasswordPolicy({ resetTokenExpirationSeconds: 0 });
10
+ (0, helpers_1.usePasswordPolicy)(i, { resetTokenExpirationSeconds: 0 });
12
11
  const result = i
13
12
  .getInstance(security_policy_manager_1.SecurityPolicyManager)
14
- .hasTokenExpired({ createdAt: new Date().toISOString(), token: (0, uuid_1.v4)(), userName: (0, uuid_1.v4)() });
13
+ .hasTokenExpired({ createdAt: new Date().toISOString(), token: 'token', userName: 'user' });
15
14
  expect(result).toBeFalsy();
16
15
  });
17
16
  });
@@ -1 +1 @@
1
- {"version":3,"file":"security-policy-manager.spec.js","sourceRoot":"","sources":["../src/security-policy-manager.spec.ts"],"names":[],"mappings":";;AAAA,8CAA4C;AAC5C,4CAAwC;AACxC,+BAAyB;AACzB,iCAA8B;AAC9B,uEAAiE;AACjE,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,IAAA,aAAK,EAAC,IAAI,iBAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE;YAC1B,CAAC,CAAC,iBAAiB,CAAC,EAAE,2BAA2B,EAAE,CAAC,EAAE,CAAC,CAAA;YACvD,MAAM,MAAM,GAAG,CAAC;iBACb,WAAW,CAAC,+CAAqB,CAAC;iBAClC,eAAe,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAA,SAAE,GAAE,EAAE,QAAQ,EAAE,IAAA,SAAE,GAAE,EAAE,CAAC,CAAA;YACxF,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAA;QAC5B,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"security-policy-manager.spec.js","sourceRoot":"","sources":["../src/security-policy-manager.spec.ts"],"names":[],"mappings":";;AAAA,8CAA4C;AAC5C,4CAAwC;AACxC,uCAA6C;AAC7C,uEAAiE;AAEjE,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,IAAA,aAAK,EAAC,IAAI,iBAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE;YAC1B,IAAA,2BAAiB,EAAC,CAAC,EAAE,EAAE,2BAA2B,EAAE,CAAC,EAAE,CAAC,CAAA;YACxD,MAAM,MAAM,GAAG,CAAC;iBACb,WAAW,CAAC,+CAAqB,CAAC;iBAClC,eAAe,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;YAC7F,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAA;QAC5B,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@furystack/security",
3
- "version": "1.0.1",
3
+ "version": "2.0.0",
4
4
  "description": "Security, password management and authorization related stuff for FuryStack",
5
5
  "main": "dist/index.js",
6
- "typings": "./dist/index.d.ts",
6
+ "typings": "./types/index.d.ts",
7
7
  "files": [
8
8
  "dist",
9
- "src",
10
- "test"
9
+ "types",
10
+ "src"
11
11
  ],
12
12
  "scripts": {
13
13
  "fix:prettier": "prettier \"{,!(dist|temp)/**/}*.{ts,tsx}\" --write",
@@ -30,16 +30,14 @@
30
30
  "url": "https://github.com/furystack/furystack/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@furystack/core": "^10.4.10",
34
- "@furystack/inject": "^5.0.7",
35
- "@furystack/utils": "^2.1.0",
36
- "tslib": "^2.3.1",
37
- "uuid": "^8.3.2"
33
+ "@furystack/core": "^11.0.0",
34
+ "@furystack/inject": "^6.0.0",
35
+ "@furystack/utils": "^3.0.0",
36
+ "tslib": "^2.4.0"
38
37
  },
39
38
  "homepage": "https://github.com/furystack/furystack",
40
39
  "devDependencies": {
41
40
  "@types/jest": "^27.4.1",
42
- "@types/node": "^17.0.23",
43
- "@types/uuid": "^8.3.4"
41
+ "@types/node": "^17.0.30"
44
42
  }
45
43
  }
package/src/helpers.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { Injector } from '@furystack/inject'
2
+ import { SecurityPolicy } from './security-policy'
3
+
4
+ /**
5
+ * Sets up the @furystack/security with the provided settings
6
+ *
7
+ * @param injector The Injector instance
8
+ * @param {Partial<SecurityPolicy>} policy The security policy to use
9
+ */
10
+ export const usePasswordPolicy = (injector: Injector, policy?: Partial<SecurityPolicy>) => {
11
+ const plainPolicy = new SecurityPolicy()
12
+ policy && Object.assign(plainPolicy, policy)
13
+ injector.setExplicitInstance(plainPolicy, SecurityPolicy)
14
+ }
package/src/index.ts CHANGED
@@ -6,4 +6,4 @@ export * from './password-complexity-rules'
6
6
  export * from './password-hasher'
7
7
  export * from './security-policy-manager'
8
8
 
9
- import './injector-extensions'
9
+ export * from './helpers'
@@ -1,13 +1,15 @@
1
- import { InMemoryStore, StoreManager, User } from '@furystack/core'
1
+ import { addStore, InMemoryStore, StoreManager, User } from '@furystack/core'
2
2
  import { Injector } from '@furystack/inject'
3
3
  import { using, usingAsync } from '@furystack/utils'
4
- import './injector-extensions'
5
- import { v4 } from 'uuid'
4
+ import { usePasswordPolicy } from './helpers'
6
5
  import { PasswordCheckFailedResult, PasswordCredential, PasswordResetToken } from './models'
7
6
  import { PasswordAuthenticator } from './password-authenticator'
8
7
  import { createMinLengthComplexityRule } from './password-complexity-rules'
9
8
  import { SecurityPolicyManager } from './security-policy-manager'
10
9
  import { PasswordComplexityError, UnauthenticatedError } from './errors'
10
+ import { randomBytes } from 'crypto'
11
+
12
+ const randomString = () => randomBytes(32).toString('hex')
11
13
 
12
14
  describe('PasswordAuthenticator', () => {
13
15
  it('Should be instantiated', () => {
@@ -19,7 +21,7 @@ describe('PasswordAuthenticator', () => {
19
21
 
20
22
  it('Should inherit policy from the extension method', () => {
21
23
  using(new Injector(), (i) => {
22
- i.usePasswordPolicy({
24
+ usePasswordPolicy(i, {
23
25
  passwordComplexityRules: [createMinLengthComplexityRule(3)],
24
26
  })
25
27
  const auth = i.getInstance(PasswordAuthenticator)
@@ -31,14 +33,13 @@ describe('PasswordAuthenticator', () => {
31
33
  describe('checkPasswordForUser', () => {
32
34
  it('Should return a truthy value for valid username and password', async () => {
33
35
  await usingAsync(new Injector(), async (i) => {
34
- const userName = v4()
35
- const password = v4()
36
- i.setupStores((sm) =>
37
- sm
38
- .addStore(new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
39
- .addStore(new InMemoryStore({ model: User, primaryKey: 'username' })),
36
+ const userName = randomString()
37
+ const password = randomString()
38
+
39
+ addStore(i, new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' })).addStore(
40
+ new InMemoryStore({ model: User, primaryKey: 'username' }),
40
41
  )
41
- i.usePasswordPolicy({})
42
+ usePasswordPolicy(i, {})
42
43
  const authenticator = i.getInstance(PasswordAuthenticator)
43
44
  const hasher = authenticator.getHasher()
44
45
  const passwordStore = i.getInstance(StoreManager).getStoreFor(PasswordCredential, 'userName')
@@ -53,14 +54,13 @@ describe('PasswordAuthenticator', () => {
53
54
 
54
55
  it('Should return a falsy value for invalid username', async () => {
55
56
  await usingAsync(new Injector(), async (i) => {
56
- const userName = v4()
57
- const password = v4()
58
- i.setupStores((sm) =>
59
- sm
60
- .addStore(new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
61
- .addStore(new InMemoryStore({ model: User, primaryKey: 'username' })),
57
+ const userName = randomString()
58
+ const password = randomString()
59
+ addStore(i, new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' })).addStore(
60
+ new InMemoryStore({ model: User, primaryKey: 'username' }),
62
61
  )
63
- i.usePasswordPolicy({})
62
+
63
+ usePasswordPolicy(i)
64
64
  const authenticator = i.getInstance(PasswordAuthenticator)
65
65
  const hasher = authenticator.getHasher()
66
66
  const passwordStore = i.getInstance(StoreManager).getStoreFor(PasswordCredential, 'userName')
@@ -76,14 +76,12 @@ describe('PasswordAuthenticator', () => {
76
76
 
77
77
  it('Should return a falsy value for invalid password', async () => {
78
78
  await usingAsync(new Injector(), async (i) => {
79
- const userName = v4()
80
- const password = v4()
81
- i.setupStores((sm) =>
82
- sm
83
- .addStore(new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
84
- .addStore(new InMemoryStore({ model: User, primaryKey: 'username' })),
79
+ const userName = randomString()
80
+ const password = randomString()
81
+ addStore(i, new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' })).addStore(
82
+ new InMemoryStore({ model: User, primaryKey: 'username' }),
85
83
  )
86
- i.usePasswordPolicy({})
84
+ usePasswordPolicy(i)
87
85
  const authenticator = i.getInstance(PasswordAuthenticator)
88
86
  const hasher = authenticator.getHasher()
89
87
  const passwordStore = i.getInstance(StoreManager).getStoreFor(PasswordCredential, 'userName')
@@ -99,14 +97,13 @@ describe('PasswordAuthenticator', () => {
99
97
 
100
98
  it('Should return a falsy value for an expired password', async () => {
101
99
  await usingAsync(new Injector(), async (i) => {
102
- const userName = v4()
103
- const password = v4()
104
- i.setupStores((sm) =>
105
- sm
106
- .addStore(new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
107
- .addStore(new InMemoryStore({ model: User, primaryKey: 'username' })),
100
+ const userName = randomString()
101
+ const password = randomString()
102
+ addStore(i, new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' })).addStore(
103
+ new InMemoryStore({ model: User, primaryKey: 'username' }),
108
104
  )
109
- i.usePasswordPolicy({ passwordExpirationDays: 1 })
105
+
106
+ usePasswordPolicy(i, { passwordExpirationDays: 1 })
110
107
  const authenticator = i.getInstance(PasswordAuthenticator)
111
108
  const hasher = authenticator.getHasher()
112
109
  const passwordStore = i.getInstance(StoreManager).getStoreFor(PasswordCredential, 'userName')
@@ -129,15 +126,13 @@ describe('PasswordAuthenticator', () => {
129
126
  describe('setPasswordForUser', () => {
130
127
  it('Should be able to set the password for the user using the last password', async () => {
131
128
  await usingAsync(new Injector(), async (i) => {
132
- const userName = v4()
133
- const lastPassword = v4()
134
- const password = v4()
135
- i.setupStores((sm) =>
136
- sm
137
- .addStore(new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
138
- .addStore(new InMemoryStore({ model: User, primaryKey: 'username' })),
129
+ const userName = randomString()
130
+ const lastPassword = randomString()
131
+ const password = randomString()
132
+ addStore(i, new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' })).addStore(
133
+ new InMemoryStore({ model: User, primaryKey: 'username' }),
139
134
  )
140
- i.usePasswordPolicy({})
135
+ usePasswordPolicy(i)
141
136
  const authenticator = i.getInstance(PasswordAuthenticator)
142
137
  const hasher = authenticator.getHasher()
143
138
  const passwordStore = i.getInstance(StoreManager).getStoreFor(PasswordCredential, 'userName')
@@ -167,15 +162,13 @@ describe('PasswordAuthenticator', () => {
167
162
 
168
163
  it('Should throw PasswordComplexityError if the complexity rules are not respected', async () => {
169
164
  await usingAsync(new Injector(), async (i) => {
170
- const userName = v4()
171
- const lastPassword = v4()
165
+ const userName = randomString()
166
+ const lastPassword = randomString()
172
167
  const password = ''
173
- i.setupStores((sm) =>
174
- sm
175
- .addStore(new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
176
- .addStore(new InMemoryStore({ model: User, primaryKey: 'username' })),
168
+ addStore(i, new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' })).addStore(
169
+ new InMemoryStore({ model: User, primaryKey: 'username' }),
177
170
  )
178
- i.usePasswordPolicy({ passwordComplexityRules: [createMinLengthComplexityRule(3)] })
171
+ usePasswordPolicy(i, { passwordComplexityRules: [createMinLengthComplexityRule(3)] })
179
172
  const authenticator = i.getInstance(PasswordAuthenticator)
180
173
  const hasher = authenticator.getHasher()
181
174
  const passwordStore = i.getInstance(StoreManager).getStoreFor(PasswordCredential, 'userName')
@@ -209,15 +202,13 @@ describe('PasswordAuthenticator', () => {
209
202
 
210
203
  it('Should throw UnauthenticatedError if the last password is not valid', async () => {
211
204
  await usingAsync(new Injector(), async (i) => {
212
- const userName = v4()
213
- const lastPassword = v4()
214
- const password = v4()
215
- i.setupStores((sm) =>
216
- sm
217
- .addStore(new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
218
- .addStore(new InMemoryStore({ model: User, primaryKey: 'username' })),
205
+ const userName = randomString()
206
+ const lastPassword = randomString()
207
+ const password = randomString()
208
+ addStore(i, new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' })).addStore(
209
+ new InMemoryStore({ model: User, primaryKey: 'username' }),
219
210
  )
220
- i.usePasswordPolicy()
211
+ usePasswordPolicy(i)
221
212
  const authenticator = i.getInstance(PasswordAuthenticator)
222
213
  const hasher = authenticator.getHasher()
223
214
  const passwordStore = i.getInstance(StoreManager).getStoreFor(PasswordCredential, 'userName')
@@ -253,17 +244,14 @@ describe('PasswordAuthenticator', () => {
253
244
  describe('resetPasswordForUser', () => {
254
245
  it('Should reset the password with the valid token', async () => {
255
246
  await usingAsync(new Injector(), async (i) => {
256
- const userName = v4()
257
- const lastPassword = v4()
258
- const password = v4()
259
- const token = v4()
260
- i.setupStores((sm) =>
261
- sm
262
- .addStore(new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
263
- .addStore(new InMemoryStore({ model: User, primaryKey: 'username' }))
264
- .addStore(new InMemoryStore({ model: PasswordResetToken, primaryKey: 'token' })),
265
- )
266
- i.usePasswordPolicy()
247
+ const userName = randomString()
248
+ const lastPassword = randomString()
249
+ const password = randomString()
250
+ const token = randomString()
251
+ addStore(i, new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
252
+ .addStore(new InMemoryStore({ model: User, primaryKey: 'username' }))
253
+ .addStore(new InMemoryStore({ model: PasswordResetToken, primaryKey: 'token' }))
254
+ usePasswordPolicy(i)
267
255
  const authenticator = i.getInstance(PasswordAuthenticator)
268
256
  const hasher = authenticator.getHasher()
269
257
  const passwordStore = i.getInstance(StoreManager).getStoreFor(PasswordCredential, 'userName')
@@ -286,17 +274,14 @@ describe('PasswordAuthenticator', () => {
286
274
  })
287
275
  it('Should throw PasswordComplexityError if the complexity rules are not respected', async () => {
288
276
  await usingAsync(new Injector(), async (i) => {
289
- const userName = v4()
290
- const lastPassword = v4()
277
+ const userName = randomString()
278
+ const lastPassword = randomString()
291
279
  const password = ''
292
- const token = v4()
293
- i.setupStores((sm) =>
294
- sm
295
- .addStore(new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
296
- .addStore(new InMemoryStore({ model: User, primaryKey: 'username' }))
297
- .addStore(new InMemoryStore({ model: PasswordResetToken, primaryKey: 'token' })),
298
- )
299
- i.usePasswordPolicy({ passwordComplexityRules: [createMinLengthComplexityRule(3)] })
280
+ const token = randomString()
281
+ addStore(i, new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
282
+ .addStore(new InMemoryStore({ model: User, primaryKey: 'username' }))
283
+ .addStore(new InMemoryStore({ model: PasswordResetToken, primaryKey: 'token' }))
284
+ usePasswordPolicy(i, { passwordComplexityRules: [createMinLengthComplexityRule(3)] })
300
285
  const authenticator = i.getInstance(PasswordAuthenticator)
301
286
  const hasher = authenticator.getHasher()
302
287
  const passwordStore = i.getInstance(StoreManager).getStoreFor(PasswordCredential, 'userName')
@@ -318,17 +303,14 @@ describe('PasswordAuthenticator', () => {
318
303
  })
319
304
  it('Should throw UnauthenticatedError if the token is not valid', async () => {
320
305
  await usingAsync(new Injector(), async (i) => {
321
- const userName = v4()
322
- const lastPassword = v4()
306
+ const userName = randomString()
307
+ const lastPassword = randomString()
323
308
  const password = ''
324
- const token = v4()
325
- i.setupStores((sm) =>
326
- sm
327
- .addStore(new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
328
- .addStore(new InMemoryStore({ model: User, primaryKey: 'username' }))
329
- .addStore(new InMemoryStore({ model: PasswordResetToken, primaryKey: 'token' })),
330
- )
331
- i.usePasswordPolicy()
309
+ const token = randomString()
310
+ addStore(i, new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
311
+ .addStore(new InMemoryStore({ model: User, primaryKey: 'username' }))
312
+ .addStore(new InMemoryStore({ model: PasswordResetToken, primaryKey: 'token' }))
313
+ usePasswordPolicy(i)
332
314
  const authenticator = i.getInstance(PasswordAuthenticator)
333
315
  const hasher = authenticator.getHasher()
334
316
  const passwordStore = i.getInstance(StoreManager).getStoreFor(PasswordCredential, 'userName')
@@ -352,17 +334,14 @@ describe('PasswordAuthenticator', () => {
352
334
  })
353
335
  it('Should throw UnauthenticatedError and clean up token if the token has been expired', async () => {
354
336
  await usingAsync(new Injector(), async (i) => {
355
- const userName = v4()
356
- const lastPassword = v4()
337
+ const userName = randomString()
338
+ const lastPassword = randomString()
357
339
  const password = ''
358
- const token = v4()
359
- i.setupStores((sm) =>
360
- sm
361
- .addStore(new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
362
- .addStore(new InMemoryStore({ model: User, primaryKey: 'username' }))
363
- .addStore(new InMemoryStore({ model: PasswordResetToken, primaryKey: 'token' })),
364
- )
365
- i.usePasswordPolicy({ resetTokenExpirationSeconds: 1 })
340
+ const token = randomString()
341
+ addStore(i, new InMemoryStore({ model: PasswordCredential, primaryKey: 'userName' }))
342
+ .addStore(new InMemoryStore({ model: User, primaryKey: 'username' }))
343
+ .addStore(new InMemoryStore({ model: PasswordResetToken, primaryKey: 'token' }))
344
+ usePasswordPolicy(i, { resetTokenExpirationSeconds: 1 })
366
345
  const authenticator = i.getInstance(PasswordAuthenticator)
367
346
  const hasher = authenticator.getHasher()
368
347
  const passwordStore = i.getInstance(StoreManager).getStoreFor(PasswordCredential, 'userName')
@@ -1,15 +1,15 @@
1
1
  import { Injector } from '@furystack/inject'
2
2
  import { using } from '@furystack/utils'
3
- import { v4 } from 'uuid'
4
- import './injector-extensions'
3
+ import { usePasswordPolicy } from './helpers'
5
4
  import { SecurityPolicyManager } from './security-policy-manager'
5
+
6
6
  describe('SecurityPolicyManager', () => {
7
7
  it('Should return false when no token expiration has been set', () => {
8
8
  using(new Injector(), (i) => {
9
- i.usePasswordPolicy({ resetTokenExpirationSeconds: 0 })
9
+ usePasswordPolicy(i, { resetTokenExpirationSeconds: 0 })
10
10
  const result = i
11
11
  .getInstance(SecurityPolicyManager)
12
- .hasTokenExpired({ createdAt: new Date().toISOString(), token: v4(), userName: v4() })
12
+ .hasTokenExpired({ createdAt: new Date().toISOString(), token: 'token', userName: 'user' })
13
13
  expect(result).toBeFalsy()
14
14
  })
15
15
  })
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,10 @@
1
+ import { Injector } from '@furystack/inject';
2
+ import { SecurityPolicy } from './security-policy';
3
+ /**
4
+ * Sets up the @furystack/security with the provided settings
5
+ *
6
+ * @param injector The Injector instance
7
+ * @param {Partial<SecurityPolicy>} policy The security policy to use
8
+ */
9
+ export declare const usePasswordPolicy: (injector: Injector, policy?: Partial<SecurityPolicy> | undefined) => void;
10
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,aAAc,QAAQ,uDAInD,CAAA"}
@@ -5,5 +5,5 @@ export * from './password-authenticator';
5
5
  export * from './password-complexity-rules';
6
6
  export * from './password-hasher';
7
7
  export * from './security-policy-manager';
8
- import './injector-extensions';
8
+ export * from './helpers';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,0BAA0B,CAAA;AACxC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AAEzC,OAAO,uBAAuB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,0BAA0B,CAAA;AACxC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AAEzC,cAAc,WAAW,CAAA"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=password-authenticator.spec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"password-authenticator.spec.d.ts","sourceRoot":"","sources":["../src/password-authenticator.spec.ts"],"names":[],"mappings":"AAGA,OAAO,uBAAuB,CAAA"}
1
+ {"version":3,"file":"password-authenticator.spec.d.ts","sourceRoot":"","sources":["../src/password-authenticator.spec.ts"],"names":[],"mappings":""}
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=security-policy-manager.spec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"security-policy-manager.spec.d.ts","sourceRoot":"","sources":["../src/security-policy-manager.spec.ts"],"names":[],"mappings":"AAGA,OAAO,uBAAuB,CAAA"}
1
+ {"version":3,"file":"security-policy-manager.spec.d.ts","sourceRoot":"","sources":["../src/security-policy-manager.spec.ts"],"names":[],"mappings":""}
File without changes
File without changes
@@ -1,13 +0,0 @@
1
- import { SecurityPolicy } from './security-policy';
2
- declare module '@furystack/inject/dist/injector' {
3
- /**
4
- * Extended Injector with Password Policy related methods
5
- */
6
- interface Injector {
7
- /**
8
- * Sets up the @furystack/security with the provided settings
9
- */
10
- usePasswordPolicy: (policy?: Partial<SecurityPolicy>) => this;
11
- }
12
- }
13
- //# sourceMappingURL=injector-extensions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injector-extensions.d.ts","sourceRoot":"","sources":["../src/injector-extensions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,OAAO,QAAQ,iCAAiC,CAAC;IAC/C;;OAEG;IACH,UAAiB,QAAQ;QACvB;;WAEG;QACH,iBAAiB,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,CAAA;KAC9D;CACF"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const injector_1 = require("@furystack/inject/dist/injector");
4
- const security_policy_1 = require("./security-policy");
5
- injector_1.Injector.prototype.usePasswordPolicy = function (policy) {
6
- const plainPolicy = new security_policy_1.SecurityPolicy();
7
- policy && Object.assign(plainPolicy, policy);
8
- this.setExplicitInstance(plainPolicy, security_policy_1.SecurityPolicy);
9
- return this;
10
- };
11
- //# sourceMappingURL=injector-extensions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"injector-extensions.js","sourceRoot":"","sources":["../src/injector-extensions.ts"],"names":[],"mappings":";;AAAA,8DAA0D;AAC1D,uDAAkD;AAclD,mBAAQ,CAAC,SAAS,CAAC,iBAAiB,GAAG,UAAU,MAAM;IACrD,MAAM,WAAW,GAAG,IAAI,gCAAc,EAAE,CAAA;IACxC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;IAC5C,IAAI,CAAC,mBAAmB,CAAC,WAAW,EAAE,gCAAc,CAAC,CAAA;IACrD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- import './injector-extensions';
2
- //# sourceMappingURL=password-authenticator.spec.d.ts.map
@@ -1,2 +0,0 @@
1
- import './injector-extensions';
2
- //# sourceMappingURL=security-policy-manager.spec.d.ts.map
@@ -1,21 +0,0 @@
1
- import { Injector } from '@furystack/inject/dist/injector'
2
- import { SecurityPolicy } from './security-policy'
3
-
4
- declare module '@furystack/inject/dist/injector' {
5
- /**
6
- * Extended Injector with Password Policy related methods
7
- */
8
- export interface Injector {
9
- /**
10
- * Sets up the @furystack/security with the provided settings
11
- */
12
- usePasswordPolicy: (policy?: Partial<SecurityPolicy>) => this
13
- }
14
- }
15
-
16
- Injector.prototype.usePasswordPolicy = function (policy) {
17
- const plainPolicy = new SecurityPolicy()
18
- policy && Object.assign(plainPolicy, policy)
19
- this.setExplicitInstance(plainPolicy, SecurityPolicy)
20
- return this
21
- }