@feathersjs/authentication-local 5.0.0-pre.23 → 5.0.0-pre.26
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/CHANGELOG.md +27 -0
- package/lib/hooks/hash-password.d.ts +6 -0
- package/lib/hooks/hash-password.js +6 -0
- package/lib/hooks/hash-password.js.map +1 -1
- package/lib/hooks/protect.d.ts +4 -0
- package/lib/hooks/protect.js +4 -0
- package/lib/hooks/protect.js.map +1 -1
- package/lib/index.d.ts +15 -2
- package/lib/index.js +17 -3
- package/lib/index.js.map +1 -1
- package/package.json +8 -7
- package/src/hooks/hash-password.ts +6 -0
- package/src/hooks/protect.ts +4 -0
- package/src/index.ts +20 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.0.0-pre.26](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.25...v5.0.0-pre.26) (2022-06-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @feathersjs/authentication-local
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [5.0.0-pre.25](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.24...v5.0.0-pre.25) (2022-06-22)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @feathersjs/authentication-local
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [5.0.0-pre.24](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.23...v5.0.0-pre.24) (2022-06-21)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **authentication-local:** Add passwordHash property resolver ([#2660](https://github.com/feathersjs/feathers/issues/2660)) ([b41279b](https://github.com/feathersjs/feathers/commit/b41279b55eea3771a6fa4983a37be2413287bbc6))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
# [5.0.0-pre.23](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.22...v5.0.0-pre.23) (2022-06-06)
|
|
7
34
|
|
|
8
35
|
**Note:** Version bump only for package @feathersjs/authentication-local
|
|
@@ -3,4 +3,10 @@ export interface HashPasswordOptions {
|
|
|
3
3
|
authentication?: string;
|
|
4
4
|
strategy?: string;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use Feathers schema resolvers and the `passwordHash` resolver instead
|
|
8
|
+
* @param field
|
|
9
|
+
* @param options
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
6
12
|
export default function hashPassword(field: string, options?: HashPasswordOptions): (context: HookContext, next?: NextFunction) => Promise<any>;
|
|
@@ -9,6 +9,12 @@ const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
|
9
9
|
const errors_1 = require("@feathersjs/errors");
|
|
10
10
|
const commons_1 = require("@feathersjs/commons");
|
|
11
11
|
const debug = (0, commons_1.createDebug)('@feathersjs/authentication-local/hooks/hash-password');
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use Feathers schema resolvers and the `passwordHash` resolver instead
|
|
14
|
+
* @param field
|
|
15
|
+
* @param options
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
12
18
|
function hashPassword(field, options = {}) {
|
|
13
19
|
if (!field) {
|
|
14
20
|
throw new Error('The hashPassword hook requires a field name option');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-password.js","sourceRoot":"","sources":["../../src/hooks/hash-password.ts"],"names":[],"mappings":";;;;;AAAA,qDAA4B;AAC5B,qDAA4B;AAC5B,iEAAwC;AACxC,+CAA+C;AAC/C,iDAAiD;AAIjD,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,sDAAsD,C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AC,GAAG,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAoB,CAAA;YAE9E,IAAI,CAAC,aAAa,IAAI,OAAO,aAAa,CAAC,YAAY,KAAK,UAAU,EAAE;gBACtE,MAAM,IAAI,mBAAU,CAAC,mBAAmB,QAAQ,6BAA6B,CAAC,CAAA;aAC/E;YAED,MAAM,iBAAiB,GAAG,KAAK,EAAE,IAAS,EAAE,EAAE;gBAC5C,MAAM,QAAQ,GAAG,IAAA,aAAG,EAAC,IAAI,EAAE,KAAK,CAAC,CAAA;gBAEjC,IAAI,QAAQ,KAAK,SAAS,EAAE;oBAC1B,KAAK,CAAC,aAAa,KAAK,qCAAqC,CAAC,CAAA;oBAC9D,OAAO,IAAI,CAAA;iBACZ;gBAED,MAAM,cAAc,GAAW,MAAM,aAAa,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;gBAEjF,OAAO,IAAA,aAAG,EAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;YACpD,CAAC,CAAA;YAED,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBAChC,CAAC,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;gBAChD,CAAC,CAAC,MAAM,iBAAiB,CAAC,IAAI,CAAC,CAAA;SAClC;QAED,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;YAC9B,OAAO,IAAI,EAAE,CAAA;SACd;IACH,CAAC,CAAA;AACH,CAAC;AA5CD,+BA4CC"}
|
package/lib/hooks/protect.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { HookContext, NextFunction } from '@feathersjs/feathers';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated For reliable safe data representations use Feathers schema dispatch resolvers.
|
|
4
|
+
* See https://dove.docs.feathersjs.com/api/schema/resolvers.html#safe-data-resolvers for more information.
|
|
5
|
+
*/
|
|
2
6
|
declare const _default: (...fields: string[]) => (context: HookContext, next?: NextFunction) => Promise<void>;
|
|
3
7
|
export default _default;
|
package/lib/hooks/protect.js
CHANGED
|
@@ -4,6 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated For reliable safe data representations use Feathers schema dispatch resolvers.
|
|
9
|
+
* See https://dove.docs.feathersjs.com/api/schema/resolvers.html#safe-data-resolvers for more information.
|
|
10
|
+
*/
|
|
7
11
|
exports.default = (...fields) => {
|
|
8
12
|
const o = (current) => {
|
|
9
13
|
if (typeof current === 'object' && !Array.isArray(current)) {
|
package/lib/hooks/protect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protect.js","sourceRoot":"","sources":["../../src/hooks/protect.ts"],"names":[],"mappings":";;;;;AAAA,uDAA8B;AAG9B,kBAAe,CAAC,GAAG,MAAgB,EAAE,EAAE;IACrC,MAAM,CAAC,GAAG,CAAC,OAAY,EAAE,EAAE;QACzB,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC1D,MAAM,IAAI,GAAG,OAAO,OAAO,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;YAE9E,OAAO,IAAA,cAAI,EAAC,IAAI,EAAE,MAAM,CAAC,CAAA;SAC1B;QAED,OAAO,OAAO,CAAA;IAChB,CAAC,CAAA;IAED,OAAO,KAAK,EAAE,OAAoB,EAAE,IAAmB,EAAE,EAAE;QACzD,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;YAC9B,MAAM,IAAI,EAAE,CAAA;SACb;QAED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O,OAAO,CAAA;IAChB,CAAC,CAAA;IAED,OAAO,KAAK,EAAE,OAAoB,EAAE,IAAmB,EAAE,EAAE;QACzD,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;YAC9B,MAAM,IAAI,EAAE,CAAA;SACb;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAA;QAEjD,IAAI,MAAM,EAAE;YACV,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBACzB,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;aACjC;iBAAM,IAAI,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE;gBACnD,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE;oBAC3C,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;iBACzB,CAAC,CAAA;aACH;iBAAM;gBACL,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,CAAA;aAC7B;YAED,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE;gBAC7C,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAA;aAClC;SACF;IACH,CAAC,CAAA;AACH,CAAC,CAAA"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
import { HookContext } from '@feathersjs/feathers';
|
|
1
2
|
import hashPassword from './hooks/hash-password';
|
|
3
|
+
import { LocalStrategy } from './strategy';
|
|
2
4
|
export declare const hooks: {
|
|
3
5
|
hashPassword: typeof hashPassword;
|
|
4
|
-
protect: (...fields: string[]) => (context:
|
|
6
|
+
protect: (...fields: string[]) => (context: HookContext<import("@feathersjs/feathers").Application<any, any>, any>, next?: import("@feathersjs/feathers").NextFunction) => Promise<void>;
|
|
5
7
|
};
|
|
6
|
-
export { LocalStrategy }
|
|
8
|
+
export { LocalStrategy };
|
|
9
|
+
/**
|
|
10
|
+
* Returns as property resolver that hashes a given plain text password using a Local
|
|
11
|
+
* authentication strategy.
|
|
12
|
+
*
|
|
13
|
+
* @param options The authentication `service` and `strategy` name
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export declare const passwordHash: (options: {
|
|
17
|
+
service?: string;
|
|
18
|
+
strategy: string;
|
|
19
|
+
}) => <H extends HookContext<any, any>>(value: string | undefined, _data: any, context: H) => Promise<string>;
|
package/lib/index.js
CHANGED
|
@@ -3,10 +3,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LocalStrategy = exports.hooks = void 0;
|
|
6
|
+
exports.passwordHash = exports.LocalStrategy = exports.hooks = void 0;
|
|
7
7
|
const hash_password_1 = __importDefault(require("./hooks/hash-password"));
|
|
8
8
|
const protect_1 = __importDefault(require("./hooks/protect"));
|
|
9
|
-
|
|
10
|
-
var strategy_1 = require("./strategy");
|
|
9
|
+
const strategy_1 = require("./strategy");
|
|
11
10
|
Object.defineProperty(exports, "LocalStrategy", { enumerable: true, get: function () { return strategy_1.LocalStrategy; } });
|
|
11
|
+
exports.hooks = { hashPassword: hash_password_1.default, protect: protect_1.default };
|
|
12
|
+
/**
|
|
13
|
+
* Returns as property resolver that hashes a given plain text password using a Local
|
|
14
|
+
* authentication strategy.
|
|
15
|
+
*
|
|
16
|
+
* @param options The authentication `service` and `strategy` name
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
const passwordHash = (options) => async (value, _data, context) => {
|
|
20
|
+
const { app, params } = context;
|
|
21
|
+
const authService = app.defaultAuthentication(options.service);
|
|
22
|
+
const localStrategy = authService.getStrategy(options.strategy);
|
|
23
|
+
return localStrategy.hashPassword(value, params);
|
|
24
|
+
};
|
|
25
|
+
exports.passwordHash = passwordHash;
|
|
12
26
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,0EAAgD;AAChD,8DAAqC;AACrC,yCAA0C;AAGjC,8FAHA,wBAAa,OAGA;AADT,QAAA,KAAK,GAAG,EAAE,YAAY,EAAZ,uBAAY,EAAE,OAAO,EAAP,iBAAO,EAAE,CAAA;AAG9C;;;;;;GAMG;AACI,MAAM,YAAY,GACvB,CAAC,OAA+C,EAAE,EAAE,CACpD,KAAK,EAAmC,KAAyB,EAAE,KAAU,EAAE,OAAU,EAAE,EAAE;IAC3F,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAC/B,MAAM,WAAW,GAAG,GAAG,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9D,MAAM,aAAa,GAAG,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAkB,CAAA;IAEhF,OAAO,aAAa,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAClD,CAAC,CAAA;AARU,QAAA,YAAY,gBAQtB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feathersjs/authentication-local",
|
|
3
3
|
"description": "Local authentication strategy for @feathers/authentication",
|
|
4
|
-
"version": "5.0.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.26",
|
|
5
5
|
"homepage": "https://feathersjs.com",
|
|
6
6
|
"main": "lib/",
|
|
7
7
|
"types": "lib/",
|
|
@@ -52,15 +52,16 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@feathersjs/authentication": "^5.0.0-pre.
|
|
56
|
-
"@feathersjs/commons": "^5.0.0-pre.
|
|
57
|
-
"@feathersjs/errors": "^5.0.0-pre.
|
|
58
|
-
"@feathersjs/feathers": "^5.0.0-pre.
|
|
55
|
+
"@feathersjs/authentication": "^5.0.0-pre.26",
|
|
56
|
+
"@feathersjs/commons": "^5.0.0-pre.26",
|
|
57
|
+
"@feathersjs/errors": "^5.0.0-pre.26",
|
|
58
|
+
"@feathersjs/feathers": "^5.0.0-pre.26",
|
|
59
59
|
"bcryptjs": "^2.4.3",
|
|
60
60
|
"lodash": "^4.17.21"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@feathersjs/memory": "^5.0.0-pre.
|
|
63
|
+
"@feathersjs/memory": "^5.0.0-pre.26",
|
|
64
|
+
"@feathersjs/schema": "^5.0.0-pre.26",
|
|
64
65
|
"@types/bcryptjs": "^2.4.2",
|
|
65
66
|
"@types/lodash": "^4.14.182",
|
|
66
67
|
"@types/mocha": "^9.1.1",
|
|
@@ -70,5 +71,5 @@
|
|
|
70
71
|
"ts-node": "^10.8.1",
|
|
71
72
|
"typescript": "^4.7.3"
|
|
72
73
|
},
|
|
73
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "0e7553ded9b24016d36021aaedcc2cdb19ab0157"
|
|
74
75
|
}
|
|
@@ -13,6 +13,12 @@ export interface HashPasswordOptions {
|
|
|
13
13
|
strategy?: string
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use Feathers schema resolvers and the `passwordHash` resolver instead
|
|
18
|
+
* @param field
|
|
19
|
+
* @param options
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
16
22
|
export default function hashPassword(field: string, options: HashPasswordOptions = {}) {
|
|
17
23
|
if (!field) {
|
|
18
24
|
throw new Error('The hashPassword hook requires a field name option')
|
package/src/hooks/protect.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import omit from 'lodash/omit'
|
|
2
2
|
import { HookContext, NextFunction } from '@feathersjs/feathers'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated For reliable safe data representations use Feathers schema dispatch resolvers.
|
|
6
|
+
* See https://dove.docs.feathersjs.com/api/schema/resolvers.html#safe-data-resolvers for more information.
|
|
7
|
+
*/
|
|
4
8
|
export default (...fields: string[]) => {
|
|
5
9
|
const o = (current: any) => {
|
|
6
10
|
if (typeof current === 'object' && !Array.isArray(current)) {
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
+
import { HookContext } from '@feathersjs/feathers'
|
|
1
2
|
import hashPassword from './hooks/hash-password'
|
|
2
3
|
import protect from './hooks/protect'
|
|
4
|
+
import { LocalStrategy } from './strategy'
|
|
3
5
|
|
|
4
6
|
export const hooks = { hashPassword, protect }
|
|
5
|
-
export { LocalStrategy }
|
|
7
|
+
export { LocalStrategy }
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns as property resolver that hashes a given plain text password using a Local
|
|
11
|
+
* authentication strategy.
|
|
12
|
+
*
|
|
13
|
+
* @param options The authentication `service` and `strategy` name
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export const passwordHash =
|
|
17
|
+
(options: { service?: string; strategy: string }) =>
|
|
18
|
+
async <H extends HookContext<any, any>>(value: string | undefined, _data: any, context: H) => {
|
|
19
|
+
const { app, params } = context
|
|
20
|
+
const authService = app.defaultAuthentication(options.service)
|
|
21
|
+
const localStrategy = authService.getStrategy(options.strategy) as LocalStrategy
|
|
22
|
+
|
|
23
|
+
return localStrategy.hashPassword(value, params)
|
|
24
|
+
}
|