@lindorm/aegis 0.8.0 → 0.8.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-actor.d.ts","sourceRoot":"","sources":["../../../src/internal/utils/validate-actor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-actor.d.ts","sourceRoot":"","sources":["../../../src/internal/utils/validate-actor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAKpF,eAAO,MAAM,aAAa,GACxB,YAAY,eAAe,EAC3B,SAAS,kBAAkB,GAAG,SAAS,KACtC,MAAM,GAAG,IAmDX,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Predicated } from "@lindorm/utils";
|
|
2
|
+
const describeActor = (actor) => actor.subject ?? actor.clientId ?? "undefined";
|
|
1
3
|
export const validateActor = (delegation, options) => {
|
|
2
4
|
if (!options)
|
|
3
5
|
return null;
|
|
@@ -11,10 +13,31 @@ export const validateActor = (delegation, options) => {
|
|
|
11
13
|
delegation.actorChain.length > options.maxChainDepth) {
|
|
12
14
|
return `Actor chain exceeds maximum depth of ${options.maxChainDepth}`;
|
|
13
15
|
}
|
|
14
|
-
if (options.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
if (options.allowedActors) {
|
|
17
|
+
const predicate = options.allowedActors;
|
|
18
|
+
const scope = options.actorScope ?? "every";
|
|
19
|
+
switch (scope) {
|
|
20
|
+
case "current": {
|
|
21
|
+
const current = delegation.actorChain[0];
|
|
22
|
+
if (!current || !Predicated.match(current, predicate)) {
|
|
23
|
+
return `Actor not allowed: ${current ? describeActor(current) : "undefined"}`;
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
case "some": {
|
|
28
|
+
if (!delegation.actorChain.some((entry) => Predicated.match(entry, predicate))) {
|
|
29
|
+
return "No actor in the chain matches the allowed predicate";
|
|
30
|
+
}
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
case "every":
|
|
34
|
+
default: {
|
|
35
|
+
for (const entry of delegation.actorChain) {
|
|
36
|
+
if (!Predicated.match(entry, predicate)) {
|
|
37
|
+
return `Actor not allowed: ${describeActor(entry)}`;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
18
41
|
}
|
|
19
42
|
}
|
|
20
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-actor.js","sourceRoot":"","sources":["../../../src/internal/utils/validate-actor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-actor.js","sourceRoot":"","sources":["../../../src/internal/utils/validate-actor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAI5C,MAAM,aAAa,GAAG,CAAC,KAAe,EAAU,EAAE,CAChD,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,IAAI,WAAW,CAAC;AAEjD,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,UAA2B,EAC3B,OAAuC,EACxB,EAAE;IACjB,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAE1B,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;QAChD,OAAO,yCAAyC,CAAC;IACnD,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;QAChD,OAAO,8BAA8B,CAAC;IACxC,CAAC;IAED,IACE,OAAO,CAAC,aAAa,KAAK,SAAS;QACnC,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,aAAa,EACpD,CAAC;QACD,OAAO,wCAAwC,OAAO,CAAC,aAAa,EAAE,CAAC;IACzE,CAAC;IAED,IAAI,OAAO,C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import type { ActClaim } from "../claims/act-claim.js";
|
|
2
4
|
import type { JwtClaimMatchers } from "./jwt-claim-matchers.js";
|
|
5
|
+
export type ActorScope = "every" | "current" | "some";
|
|
3
6
|
export type VerifyActorOptions = {
|
|
4
7
|
required?: boolean;
|
|
5
8
|
forbidden?: boolean;
|
|
6
|
-
|
|
9
|
+
allowedActors?: Predicate<ActClaim>;
|
|
10
|
+
actorScope?: ActorScope;
|
|
7
11
|
maxChainDepth?: number;
|
|
8
12
|
};
|
|
9
13
|
export type VerifyJwtOptions = JwtClaimMatchers & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-verify.d.ts","sourceRoot":"","sources":["../../../src/types/jwt/jwt-verify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"jwt-verify.d.ts","sourceRoot":"","sources":["../../../src/types/jwt/jwt-verify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAUhE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEtD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG;IAChD,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IAUnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lindorm/aegis",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"license": "AGPL-3.0-or-later",
|
|
5
5
|
"author": "Jonn Nilsson",
|
|
6
6
|
"repository": {
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"jose": "^6.2.1",
|
|
73
73
|
"jsonwebtoken": "^9.0.3"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "58e03da1d2143a50758781410e196db2e353ff2e"
|
|
76
76
|
}
|