@spinajs/rbac-http 2.0.485 → 2.0.487
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/lib/cjs/decorators.d.ts +6 -0
- package/lib/cjs/decorators.d.ts.map +1 -1
- package/lib/cjs/decorators.js +9 -0
- package/lib/cjs/decorators.js.map +1 -1
- package/lib/cjs/middlewares.d.ts +4 -2
- package/lib/cjs/middlewares.d.ts.map +1 -1
- package/lib/cjs/middlewares.js +44 -5
- package/lib/cjs/middlewares.js.map +1 -1
- package/lib/cjs/route-args.d.ts +19 -0
- package/lib/cjs/route-args.d.ts.map +1 -1
- package/lib/cjs/route-args.js +75 -1
- package/lib/cjs/route-args.js.map +1 -1
- package/lib/mjs/decorators.d.ts +6 -0
- package/lib/mjs/decorators.d.ts.map +1 -1
- package/lib/mjs/decorators.js +8 -0
- package/lib/mjs/decorators.js.map +1 -1
- package/lib/mjs/middlewares.d.ts +4 -2
- package/lib/mjs/middlewares.d.ts.map +1 -1
- package/lib/mjs/middlewares.js +45 -6
- package/lib/mjs/middlewares.js.map +1 -1
- package/lib/mjs/route-args.d.ts +19 -0
- package/lib/mjs/route-args.d.ts.map +1 -1
- package/lib/mjs/route-args.js +41 -0
- package/lib/mjs/route-args.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +10 -10
package/lib/mjs/route-args.js
CHANGED
|
@@ -4,8 +4,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
7
10
|
import { RouteArgs, ParameterType } from '@spinajs/http';
|
|
8
11
|
import { Injectable } from '@spinajs/di';
|
|
12
|
+
import { Config } from '@spinajs/configuration';
|
|
13
|
+
import { sessionCookieName } from '@spinajs/rbac';
|
|
14
|
+
import * as cs from 'cookie-signature';
|
|
9
15
|
let UserArg = class UserArg extends RouteArgs {
|
|
10
16
|
get SupportedType() {
|
|
11
17
|
return ParameterType.Other;
|
|
@@ -30,6 +36,41 @@ SessionArg = __decorate([
|
|
|
30
36
|
Injectable()
|
|
31
37
|
], SessionArg);
|
|
32
38
|
export { SessionArg };
|
|
39
|
+
/**
|
|
40
|
+
* Verified session id from the session cookie, or `null`.
|
|
41
|
+
*
|
|
42
|
+
* `@Cookie(true) ssid` hardcodes the cookie NAME to the parameter name, so a
|
|
43
|
+
* deployment that renames the cookie — or turns on the `__Host-` prefix, which
|
|
44
|
+
* changes the name by definition — silently stopped every controller that read
|
|
45
|
+
* the id that way. This resolves the configured name at request time and
|
|
46
|
+
* verifies the signature exactly as the session middleware does.
|
|
47
|
+
*/
|
|
48
|
+
let SessionIdArg = class SessionIdArg extends RouteArgs {
|
|
49
|
+
get SupportedType() {
|
|
50
|
+
return ParameterType.Other;
|
|
51
|
+
}
|
|
52
|
+
async extract(callData, _args, _param, req) {
|
|
53
|
+
const name = sessionCookieName(this.SessionCookieConfig);
|
|
54
|
+
const raw = req.cookies?.[name];
|
|
55
|
+
// Same two shapes the middleware accepts: signed by hand ( stays in
|
|
56
|
+
// `cookies` ) or signed by express ( moved to `signedCookies`, already
|
|
57
|
+
// unsigned by cookie-parser ).
|
|
58
|
+
const unsigned = raw ? cs.unsign(raw, this.CookieSecret) : req.signedCookies?.[name] ?? false;
|
|
59
|
+
return { CallData: callData, Args: unsigned === false ? null : unsigned };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
__decorate([
|
|
63
|
+
Config('rbac.session.cookie', {}),
|
|
64
|
+
__metadata("design:type", Object)
|
|
65
|
+
], SessionIdArg.prototype, "SessionCookieConfig", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
Config('http.cookie.secret'),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], SessionIdArg.prototype, "CookieSecret", void 0);
|
|
70
|
+
SessionIdArg = __decorate([
|
|
71
|
+
Injectable()
|
|
72
|
+
], SessionIdArg);
|
|
73
|
+
export { SessionIdArg };
|
|
33
74
|
let CurrentSessionArg = class CurrentSessionArg extends RouteArgs {
|
|
34
75
|
get SupportedType() {
|
|
35
76
|
return ParameterType.Other;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-args.js","sourceRoot":"","sources":["../../src/route-args.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route-args.js","sourceRoot":"","sources":["../../src/route-args.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAmB,aAAa,EAAc,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAwB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAIhC,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,SAAS;IACpC,IAAW,aAAa;QACtB,OAAO,aAAa,CAAC,KAAK,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,QAAoB,EAAE,KAAgB,EAAE,MAAuB,EAAE,GAAY;QAChG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACxD,CAAC;CACF,CAAA;AARY,OAAO;IADnB,UAAU,EAAE;GACA,OAAO,CAQnB;;AAGM,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,SAAS;IACvC,IAAI,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