@vercube/auth 0.0.1-beta.7 → 0.0.2-beta.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/index.cjs +40 -2
- package/dist/index.mjs +39 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -32,8 +32,8 @@ const __vercube_logger = __toESM(require("@vercube/logger"));
|
|
|
32
32
|
var AuthProvider = class {};
|
|
33
33
|
|
|
34
34
|
//#endregion
|
|
35
|
-
//#region node_modules/.pnpm/@oxc-project+runtime@0.
|
|
36
|
-
var require_decorate = __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.
|
|
35
|
+
//#region node_modules/.pnpm/@oxc-project+runtime@0.65.0/node_modules/@oxc-project/runtime/src/helpers/decorate.js
|
|
36
|
+
var require_decorate = __commonJS({ "node_modules/.pnpm/@oxc-project+runtime@0.65.0/node_modules/@oxc-project/runtime/src/helpers/decorate.js"(exports, module) {
|
|
37
37
|
function __decorate(decorators, target, key, desc) {
|
|
38
38
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
39
39
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -46,6 +46,14 @@ var import_decorate = __toESM(require_decorate(), 1);
|
|
|
46
46
|
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region packages/auth/src/Middleware/AuthMiddleware.ts
|
|
49
|
+
/**
|
|
50
|
+
* Middleware for auth
|
|
51
|
+
* @implements {BaseMiddleware}
|
|
52
|
+
* @description authorizes incoming request
|
|
53
|
+
* @example
|
|
54
|
+
* const middleware = new AuthMiddleware();
|
|
55
|
+
* await middleware.use(event);
|
|
56
|
+
*/
|
|
49
57
|
var AuthMiddleware = class {
|
|
50
58
|
gContainer;
|
|
51
59
|
gLogger;
|
|
@@ -75,6 +83,11 @@ var AuthMiddleware = class {
|
|
|
75
83
|
|
|
76
84
|
//#endregion
|
|
77
85
|
//#region packages/auth/src/Decorators/Auth.ts
|
|
86
|
+
/**
|
|
87
|
+
* Authentication decorator that adds middleware to protect routes or controllers
|
|
88
|
+
* @param options Optional options for the authentication middleware
|
|
89
|
+
* @returns A decorator function that adds authentication middleware to the target
|
|
90
|
+
*/
|
|
78
91
|
function Auth(options) {
|
|
79
92
|
return function internalDecorator(target, propertyName) {
|
|
80
93
|
const meta = (0, __vercube_core.initializeMetadata)(propertyName ? target : target.prototype);
|
|
@@ -90,6 +103,13 @@ function Auth(options) {
|
|
|
90
103
|
|
|
91
104
|
//#endregion
|
|
92
105
|
//#region packages/auth/src/Decorators/User.ts
|
|
106
|
+
/**
|
|
107
|
+
* Decorator class for injecting the current user into controller methods
|
|
108
|
+
* Extends BaseDecorator to provide user injection functionality
|
|
109
|
+
*
|
|
110
|
+
* @class UserDecorator
|
|
111
|
+
* @extends {BaseDecorator<UserDecoratorOptions>}
|
|
112
|
+
*/
|
|
93
113
|
var UserDecorator = class extends __vercube_di.BaseDecorator {
|
|
94
114
|
gContainer;
|
|
95
115
|
/**
|
|
@@ -112,6 +132,24 @@ var UserDecorator = class extends __vercube_di.BaseDecorator {
|
|
|
112
132
|
}
|
|
113
133
|
};
|
|
114
134
|
(0, import_decorate.default)([(0, __vercube_di.Inject)(__vercube_di.Container)], UserDecorator.prototype, "gContainer", void 0);
|
|
135
|
+
/**
|
|
136
|
+
* Creates a decorator that injects the current user into controller methods
|
|
137
|
+
*
|
|
138
|
+
* @param {UserDecoratorOptions} [params] - Optional configuration for the decorator
|
|
139
|
+
* @returns {Function} A decorator function that can be applied to controller method parameters
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* // Basic usage
|
|
143
|
+
* async someMethod(@User() user: User) {
|
|
144
|
+
* // user is automatically injected
|
|
145
|
+
* }
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* // With custom provider
|
|
149
|
+
* async someMethod(@User() user: User) {
|
|
150
|
+
* // user is retrieved using CustomAuthProvider
|
|
151
|
+
* }
|
|
152
|
+
*/
|
|
115
153
|
function User(params) {
|
|
116
154
|
return (0, __vercube_di.createDecorator)(UserDecorator, params);
|
|
117
155
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { Logger } from "@vercube/logger";
|
|
|
6
6
|
var AuthProvider = class {};
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
|
-
//#region node_modules/.pnpm/@oxc-project+runtime@0.
|
|
9
|
+
//#region node_modules/.pnpm/@oxc-project+runtime@0.65.0/node_modules/@oxc-project/runtime/src/helpers/esm/decorate.js
|
|
10
10
|
function __decorate(decorators, target, key, desc) {
|
|
11
11
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
12
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -16,6 +16,14 @@ function __decorate(decorators, target, key, desc) {
|
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region packages/auth/src/Middleware/AuthMiddleware.ts
|
|
19
|
+
/**
|
|
20
|
+
* Middleware for auth
|
|
21
|
+
* @implements {BaseMiddleware}
|
|
22
|
+
* @description authorizes incoming request
|
|
23
|
+
* @example
|
|
24
|
+
* const middleware = new AuthMiddleware();
|
|
25
|
+
* await middleware.use(event);
|
|
26
|
+
*/
|
|
19
27
|
var AuthMiddleware = class {
|
|
20
28
|
gContainer;
|
|
21
29
|
gLogger;
|
|
@@ -45,6 +53,11 @@ __decorate([InjectOptional(AuthProvider)], AuthMiddleware.prototype, "gAuthProvi
|
|
|
45
53
|
|
|
46
54
|
//#endregion
|
|
47
55
|
//#region packages/auth/src/Decorators/Auth.ts
|
|
56
|
+
/**
|
|
57
|
+
* Authentication decorator that adds middleware to protect routes or controllers
|
|
58
|
+
* @param options Optional options for the authentication middleware
|
|
59
|
+
* @returns A decorator function that adds authentication middleware to the target
|
|
60
|
+
*/
|
|
48
61
|
function Auth(options) {
|
|
49
62
|
return function internalDecorator(target, propertyName) {
|
|
50
63
|
const meta = initializeMetadata(propertyName ? target : target.prototype);
|
|
@@ -60,6 +73,13 @@ function Auth(options) {
|
|
|
60
73
|
|
|
61
74
|
//#endregion
|
|
62
75
|
//#region packages/auth/src/Decorators/User.ts
|
|
76
|
+
/**
|
|
77
|
+
* Decorator class for injecting the current user into controller methods
|
|
78
|
+
* Extends BaseDecorator to provide user injection functionality
|
|
79
|
+
*
|
|
80
|
+
* @class UserDecorator
|
|
81
|
+
* @extends {BaseDecorator<UserDecoratorOptions>}
|
|
82
|
+
*/
|
|
63
83
|
var UserDecorator = class extends BaseDecorator {
|
|
64
84
|
gContainer;
|
|
65
85
|
/**
|
|
@@ -82,6 +102,24 @@ var UserDecorator = class extends BaseDecorator {
|
|
|
82
102
|
}
|
|
83
103
|
};
|
|
84
104
|
__decorate([Inject(Container)], UserDecorator.prototype, "gContainer", void 0);
|
|
105
|
+
/**
|
|
106
|
+
* Creates a decorator that injects the current user into controller methods
|
|
107
|
+
*
|
|
108
|
+
* @param {UserDecoratorOptions} [params] - Optional configuration for the decorator
|
|
109
|
+
* @returns {Function} A decorator function that can be applied to controller method parameters
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* // Basic usage
|
|
113
|
+
* async someMethod(@User() user: User) {
|
|
114
|
+
* // user is automatically injected
|
|
115
|
+
* }
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* // With custom provider
|
|
119
|
+
* async someMethod(@User() user: User) {
|
|
120
|
+
* // user is retrieved using CustomAuthProvider
|
|
121
|
+
* }
|
|
122
|
+
*/
|
|
85
123
|
function User(params) {
|
|
86
124
|
return createDecorator(UserDecorator, params);
|
|
87
125
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercube/auth",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-beta.0",
|
|
4
4
|
"description": "Auth module for Vercube framework",
|
|
5
5
|
"repository": "@vercube/auth",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"README.md"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@vercube/
|
|
25
|
-
"@vercube/
|
|
26
|
-
"@vercube/logger": "0.0.
|
|
24
|
+
"@vercube/di": "0.0.2-beta.0",
|
|
25
|
+
"@vercube/core": "0.0.2-beta.0",
|
|
26
|
+
"@vercube/logger": "0.0.2-beta.0"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|