@koala-ts/framework 2.7.1 → 2.8.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/dist/Application/ApplicationFactory.js.map +1 -1
- package/dist/Security/index.d.ts +1 -0
- package/dist/Security/index.d.ts.map +1 -1
- package/dist/Security/index.js +1 -0
- package/dist/Security/index.js.map +1 -1
- package/dist/Security/password/index.d.ts +3 -0
- package/dist/Security/password/index.d.ts.map +1 -0
- package/dist/Security/password/index.js +3 -0
- package/dist/Security/password/index.js.map +1 -0
- package/dist/Security/password/password.d.ts +3 -0
- package/dist/Security/password/password.d.ts.map +1 -0
- package/dist/Security/password/password.js +24 -0
- package/dist/Security/password/password.js.map +1 -0
- package/dist/Security/password/password.test.d.ts +2 -0
- package/dist/Security/password/password.test.d.ts.map +1 -0
- package/dist/Security/password/password.test.js +24 -0
- package/dist/Security/password/password.test.js.map +1 -0
- package/dist/Security/password/types.d.ts +14 -0
- package/dist/Security/password/types.d.ts.map +1 -0
- package/dist/Security/password/types.js +1 -0
- package/dist/Security/password/types.js.map +1 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationFactory.js","sourceRoot":"","sources":["../../src/Application/ApplicationFactory.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ApplicationFactory.js","sourceRoot":"","sources":["../../src/Application/ApplicationFactory.ts"],"names":[],"mappings":"AAAA,OAAO,MAA+B,MAAM,aAAa,CAAC;AAC1D,OAAO,GAAgE,MAAM,KAAK,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAwB,UAAU,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW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CAAC,eAAe,CAAC;YAC7G,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,GAAI,eAA0E,CAAC,CAAC;QAC7G,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,wBAAwB,CAAC,GAAgB,EAAE,UAA4B;IAC9E,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;QAC5B,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,GAAgB,EAAE,GAAwD;IAC1G,KAAK,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvD,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,KAAK,MAAM,UAAU,IAAI,WAAW;gBAAE,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,UAAqD,CAAC,CAAC;YAC3G,SAAS;QACX,CAAC;QAED,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,WAAsD,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
|
package/dist/Security/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Security/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Security/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,YAAY,CAAC"}
|
package/dist/Security/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Security/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Security/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Security/password/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Security/password/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../../src/Security/password/password.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAoBrF,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,cAAc,CAM5E"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { hash as _hash, needsRehash as _needsRehash, verify as _verify } from 'argon2';
|
|
2
|
+
function hash(config) {
|
|
3
|
+
return function (plainPassword) {
|
|
4
|
+
return _hash(plainPassword, config);
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
function verify(config) {
|
|
8
|
+
return function (hashedPassword, plainPassword) {
|
|
9
|
+
return _verify(hashedPassword, plainPassword, config);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function needsRehash(config) {
|
|
13
|
+
return function (hashedPassword) {
|
|
14
|
+
return _needsRehash(hashedPassword, config);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function createPasswordHasher(config) {
|
|
18
|
+
return {
|
|
19
|
+
hash: hash(config),
|
|
20
|
+
verify: verify(config),
|
|
21
|
+
needsRehash: needsRehash(config),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=password.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.js","sourceRoot":"","sources":["../../../src/Security/password/password.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGvF,SAAS,IAAI,CAAC,MAAuB;IACnC,OAAO,UAAU,aAAqB;QACpC,OAAO,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAC,MAAuB;IACrC,OAAO,UAAU,cAAsB,EAAE,aAAqB;QAC5D,OAAO,OAAO,CAAC,cAAc,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,MAAuB;IAC1C,OAAO,UAAU,cAAsB;QACrC,OAAO,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAAuB;IAC1D,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;QACtB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.test.d.ts","sourceRoot":"","sources":["../../../src/Security/password/password.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { createPasswordHasher } from './password.js';
|
|
3
|
+
describe('createPasswordHasher', () => {
|
|
4
|
+
test('hash and verify password', async () => {
|
|
5
|
+
const hasher = createPasswordHasher({ timeCost: 1, memoryCost: 1024 });
|
|
6
|
+
const hashedPassword = await hasher.hash('mySecretPassword123');
|
|
7
|
+
expect(await hasher.verify(hashedPassword, 'mySecretPassword123')).toBeTruthy();
|
|
8
|
+
expect(await hasher.verify(hashedPassword, 'wrongPassword')).toBeFalsy();
|
|
9
|
+
});
|
|
10
|
+
test('it should detect needs rehash on changed config', async () => {
|
|
11
|
+
const originalHasher = createPasswordHasher({ timeCost: 1, memoryCost: 1024 });
|
|
12
|
+
const strongerHasher = createPasswordHasher({ timeCost: 2, memoryCost: 2048 });
|
|
13
|
+
const hashedPassword = await originalHasher.hash('mySecretPassword123');
|
|
14
|
+
expect(strongerHasher.needsRehash(hashedPassword)).toBeTruthy();
|
|
15
|
+
expect(originalHasher.needsRehash(hashedPassword)).toBeFalsy();
|
|
16
|
+
});
|
|
17
|
+
test('verify on changed config still works', async () => {
|
|
18
|
+
const originalHasher = createPasswordHasher({ timeCost: 1, memoryCost: 1024 });
|
|
19
|
+
const modifiedHasher = createPasswordHasher({ timeCost: 2, memoryCost: 2048 });
|
|
20
|
+
const hashedPassword = await originalHasher.hash('mySecretPassword123');
|
|
21
|
+
expect(await modifiedHasher.verify(hashedPassword, 'mySecretPassword123')).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=password.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.test.js","sourceRoot":"","sources":["../../../src/Security/password/password.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,IAAI,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,MAAM,GAAG,oBAAoB,CAAC,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qB,CAAC,CAAC;QAExE,MAAM,CAAC,MAAM,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IAC1F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PasswordConfig {
|
|
2
|
+
hashLength?: number;
|
|
3
|
+
timeCost?: number;
|
|
4
|
+
memoryCost?: number;
|
|
5
|
+
parallelism?: number;
|
|
6
|
+
secret?: Buffer;
|
|
7
|
+
associatedData?: Buffer;
|
|
8
|
+
}
|
|
9
|
+
export interface PasswordHasher {
|
|
10
|
+
hash(plainPassword: string): Promise<string>;
|
|
11
|
+
verify(hashedPassword: string, plainPassword: string): Promise<boolean>;
|
|
12
|
+
needsRehash(hashedPassword: string): boolean;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/Security/password/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE7C,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAExE,WAAW,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/Security/password/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@koala-ts/framework",
|
|
3
3
|
"main": "dist/index.js",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.8.0",
|
|
6
6
|
"description": "A NodeJS framework for lazy developers",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"koala",
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"format:check": "prettier --check ."
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@koa/router": "^
|
|
45
|
+
"@koa/router": "^15.1.1",
|
|
46
46
|
"@koa/send": "^6.0.0",
|
|
47
47
|
"@types/koa": "^3.0.0",
|
|
48
|
-
"@types/koa__router": "^12.0.4",
|
|
49
48
|
"@types/stack-trace": "^0.0.33",
|
|
50
49
|
"@types/supertest": "^6.0.3",
|
|
50
|
+
"argon2": "^0.44.0",
|
|
51
51
|
"dotenv": "^17.2.3",
|
|
52
52
|
"dotenv-expand": "^12.0.3",
|
|
53
53
|
"koa": "^3.0.3",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"eslint-plugin-prettier": "^5.5.4",
|
|
68
68
|
"eslint-plugin-promise": "^7.2.1",
|
|
69
69
|
"eslint-plugin-sonarjs": "^3.0.5",
|
|
70
|
-
"globals": "^
|
|
70
|
+
"globals": "^17.0.0",
|
|
71
71
|
"prettier": "^3.7.4",
|
|
72
72
|
"tsc-alias": "^1.8.16",
|
|
73
73
|
"tsx": "^4.20.6",
|