@starci/eslint-canon-be 3.5.0 → 3.6.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.
- package/CHANGELOG.md +21 -0
- package/README.md +13 -2
- package/dist/ambient-id.d.ts +9 -0
- package/{ambient-id.mjs → dist/ambient-id.js} +43 -39
- package/dist/app-composition.d.ts +21 -0
- package/{app-composition.mjs → dist/app-composition.js} +396 -300
- package/dist/async-discipline.d.ts +9 -0
- package/dist/async-discipline.js +77 -0
- package/dist/authorization.d.ts +12 -0
- package/{authorization.mjs → dist/authorization.js} +53 -59
- package/dist/boundary-schema.d.ts +15 -0
- package/{boundary-schema.mjs → dist/boundary-schema.js} +120 -105
- package/dist/builders.d.ts +21 -0
- package/{builders.mjs → dist/builders.js} +162 -146
- package/dist/cli.d.ts +15 -0
- package/{cli.mjs → dist/cli.js} +97 -82
- package/dist/comments.d.ts +52 -0
- package/dist/comments.js +412 -0
- package/dist/config-owner.d.ts +24 -0
- package/{config-owner.mjs → dist/config-owner.js} +256 -219
- package/dist/connections.d.ts +12 -0
- package/{connections.mjs → dist/connections.js} +138 -140
- package/dist/cookies.d.ts +9 -0
- package/{cookies.mjs → dist/cookies.js} +58 -58
- package/dist/cqrs.d.ts +27 -0
- package/{cqrs.mjs → dist/cqrs.js} +341 -282
- package/dist/data-access.d.ts +50 -0
- package/{data-access.mjs → dist/data-access.js} +238 -243
- package/dist/default-deny.d.ts +15 -0
- package/{default-deny.mjs → dist/default-deny.js} +103 -88
- package/dist/e2e-flow.d.ts +25 -0
- package/{e2e-flow.mjs → dist/e2e-flow.js} +113 -112
- package/dist/edge-hardening.d.ts +10 -0
- package/dist/edge-hardening.js +173 -0
- package/dist/error-handling.d.ts +21 -0
- package/{error-handling.mjs → dist/error-handling.js} +289 -239
- package/dist/event-bus.d.ts +14 -0
- package/{event-bus.mjs → dist/event-bus.js} +146 -129
- package/dist/feature-thin.d.ts +12 -0
- package/{feature-thin.mjs → dist/feature-thin.js} +208 -191
- package/dist/function-budget.d.ts +7 -0
- package/{function-budget.mjs → dist/function-budget.js} +24 -27
- package/dist/health-ready.d.ts +10 -0
- package/dist/health-ready.js +703 -0
- package/dist/idempotency.d.ts +10 -0
- package/{idempotency.mjs → dist/idempotency.js} +296 -226
- package/dist/index.d.ts +54 -0
- package/{index.mjs → dist/index.js} +91 -109
- package/dist/infra-owner.d.ts +18 -0
- package/{infra-owner.mjs → dist/infra-owner.js} +58 -51
- package/dist/injection.d.ts +30 -0
- package/{injection.mjs → dist/injection.js} +397 -344
- package/dist/input-bounds.d.ts +15 -0
- package/{input-bounds.mjs → dist/input-bounds.js} +143 -132
- package/dist/jobs.d.ts +17 -0
- package/{jobs.mjs → dist/jobs.js} +116 -99
- package/dist/jwt-alg.d.ts +6 -0
- package/dist/jwt-alg.js +49 -0
- package/dist/lib/app-roles.d.ts +25 -0
- package/{lib/app-roles.mjs → dist/lib/app-roles.js} +15 -17
- package/dist/lib/ast.d.ts +40 -0
- package/dist/lib/ast.js +100 -0
- package/dist/lib/client-idempotency.d.ts +3 -0
- package/{lib/client-idempotency.mjs → dist/lib/client-idempotency.js} +316 -268
- package/dist/lib/config.d.ts +36 -0
- package/{lib/config.mjs → dist/lib/config.js} +24 -27
- package/dist/lib/db-writes.d.ts +29 -0
- package/{lib/db-writes.mjs → dist/lib/db-writes.js} +27 -27
- package/dist/lib/declared.d.ts +77 -0
- package/{lib/declared.mjs → dist/lib/declared.js} +83 -78
- package/dist/lib/doors.d.ts +50 -0
- package/{lib/doors.mjs → dist/lib/doors.js} +45 -50
- package/dist/lib/edition.d.ts +25 -0
- package/{lib/edition.mjs → dist/lib/edition.js} +15 -20
- package/dist/lib/entity-writes.d.ts +7 -0
- package/{lib/entity-writes.mjs → dist/lib/entity-writes.js} +31 -22
- package/dist/lib/hfs-view.d.ts +127 -0
- package/dist/lib/hfs-view.js +1 -0
- package/dist/lib/hfs.d.ts +34 -0
- package/{lib/hfs.mjs → dist/lib/hfs.js} +31 -29
- package/dist/lib/import-source.d.ts +63 -0
- package/dist/lib/import-source.js +134 -0
- package/dist/lib/path.d.ts +8 -0
- package/{lib/path.mjs → dist/lib/path.js} +4 -7
- package/dist/lib/persistence.d.ts +115 -0
- package/{lib/persistence.mjs → dist/lib/persistence.js} +55 -66
- package/dist/lib/ports.d.ts +70 -0
- package/{lib/ports.mjs → dist/lib/ports.js} +62 -66
- package/dist/lib/rule.d.ts +31 -0
- package/dist/lib/rule.js +2 -0
- package/dist/lib/runtime-root.d.ts +4 -0
- package/dist/lib/runtime-root.js +10 -0
- package/dist/lib/schema-values.d.ts +13 -0
- package/{lib/schema-values.mjs → dist/lib/schema-values.js} +67 -59
- package/dist/lib/specifier.d.ts +12 -0
- package/dist/lib/specifier.js +29 -0
- package/dist/lib/subject-values.d.ts +4 -0
- package/dist/lib/subject-values.js +61 -0
- package/dist/lib/transactions.d.ts +18 -0
- package/{lib/transactions.mjs → dist/lib/transactions.js} +17 -15
- package/dist/lib/transport-slots.d.ts +17 -0
- package/{lib/transport-slots.mjs → dist/lib/transport-slots.js} +2 -4
- package/dist/lib/types.d.ts +96 -0
- package/dist/lib/types.js +150 -0
- package/dist/lib/unit-spec.d.ts +48 -0
- package/{lib/unit-spec.mjs → dist/lib/unit-spec.js} +35 -44
- package/dist/lib/webhook-ack.d.ts +4 -0
- package/{lib/webhook-ack.mjs → dist/lib/webhook-ack.js} +78 -62
- package/dist/lib/webhook-handoff-inbox.d.ts +3 -0
- package/{lib/webhook-handoff-inbox.mjs → dist/lib/webhook-handoff-inbox.js} +195 -167
- package/dist/lib/webhook-handoff-intake.d.ts +4 -0
- package/{lib/webhook-handoff-intake.mjs → dist/lib/webhook-handoff-intake.js} +125 -102
- package/dist/lib/webhook-handoff.d.ts +15 -0
- package/{lib/webhook-handoff.mjs → dist/lib/webhook-handoff.js} +107 -100
- package/dist/lib/webhook-verifiers.d.ts +20 -0
- package/{lib/webhook-verifiers.mjs → dist/lib/webhook-verifiers.js} +108 -104
- package/dist/lib/why.d.ts +9 -0
- package/{lib/why.mjs → dist/lib/why.js} +6 -6
- package/dist/log-safety.d.ts +20 -0
- package/dist/log-safety.js +308 -0
- package/dist/module-layering.d.ts +42 -0
- package/dist/module-layering.js +257 -0
- package/dist/module-shape.d.ts +47 -0
- package/{module-shape.mjs → dist/module-shape.js} +278 -236
- package/dist/naming.d.ts +49 -0
- package/dist/naming.js +246 -0
- package/dist/observability.d.ts +25 -0
- package/dist/observability.js +245 -0
- package/dist/operations.d.ts +23 -0
- package/{operations.mjs → dist/operations.js} +410 -332
- package/dist/project-graph.d.ts +9 -0
- package/{project-graph.mjs → dist/project-graph.js} +8 -13
- package/dist/projections.d.ts +11 -0
- package/{projections.mjs → dist/projections.js} +60 -57
- package/dist/query-safety.d.ts +21 -0
- package/{query-safety.mjs → dist/query-safety.js} +92 -108
- package/dist/realtime.d.ts +15 -0
- package/{realtime.mjs → dist/realtime.js} +108 -106
- package/dist/resilience.d.ts +15 -0
- package/dist/resilience.js +319 -0
- package/dist/schema-authority.d.ts +15 -0
- package/{schema-authority.mjs → dist/schema-authority.js} +256 -220
- package/dist/service-deps.d.ts +17 -0
- package/{service-deps.mjs → dist/service-deps.js} +133 -130
- package/dist/service-isolation.d.ts +8 -0
- package/dist/service-isolation.js +76 -0
- package/dist/size-budget.d.ts +9 -0
- package/{size-budget.mjs → dist/size-budget.js} +27 -27
- package/dist/sonar-parity.d.ts +5 -0
- package/{sonar-parity.mjs → dist/sonar-parity.js} +7 -7
- package/dist/spec-no-skip.d.ts +9 -0
- package/dist/spec-no-skip.js +81 -0
- package/dist/spec-quality.d.ts +10 -0
- package/{spec-quality.mjs → dist/spec-quality.js} +103 -87
- package/dist/suppression.d.ts +26 -0
- package/{suppression.mjs → dist/suppression.js} +30 -45
- package/dist/temporal.d.ts +9 -0
- package/{temporal.mjs → dist/temporal.js} +75 -65
- package/dist/test-world.d.ts +28 -0
- package/{test-world.mjs → dist/test-world.js} +102 -83
- package/dist/testing.d.ts +51 -0
- package/dist/testing.js +368 -0
- package/dist/third-party-owner.d.ts +8 -0
- package/{third-party-owner.mjs → dist/third-party-owner.js} +105 -91
- package/dist/transport.d.ts +24 -0
- package/{transport.mjs → dist/transport.js} +279 -240
- package/dist/type-safety.d.ts +25 -0
- package/dist/type-safety.js +297 -0
- package/dist/unit-spec.d.ts +30 -0
- package/{unit-spec.mjs → dist/unit-spec.js} +473 -399
- package/dist/uploads.d.ts +9 -0
- package/{uploads.mjs → dist/uploads.js} +62 -54
- package/dist/user-copy.d.ts +9 -0
- package/{user-copy.mjs → dist/user-copy.js} +76 -67
- package/dist/webhooks.d.ts +16 -0
- package/{webhooks.mjs → dist/webhooks.js} +243 -231
- package/package.json +23 -8
- package/runtime/knowledge/hfs/canon-pins.yaml +18 -11
- package/runtime/scripts/hfs/repo-identity.mjs +5 -4
- package/async-discipline.mjs +0 -83
- package/comments.mjs +0 -416
- package/edge-hardening.mjs +0 -139
- package/health-ready.mjs +0 -539
- package/jwt-alg.mjs +0 -45
- package/lib/ast.mjs +0 -88
- package/lib/import-source.mjs +0 -104
- package/lib/specifier.mjs +0 -27
- package/lib/subject-values.mjs +0 -55
- package/lib/types.mjs +0 -133
- package/log-safety.mjs +0 -303
- package/module-layering.mjs +0 -270
- package/naming.mjs +0 -251
- package/observability.mjs +0 -241
- package/resilience.mjs +0 -304
- package/service-isolation.mjs +0 -75
- package/spec-no-skip.mjs +0 -85
- package/testing.mjs +0 -384
- package/type-safety.mjs +0 -323
|
@@ -17,287 +17,292 @@
|
|
|
17
17
|
* What a receiver is comes from its TYPE (where the class is declared); what a decorator is comes from the import that binds it.
|
|
18
18
|
* No rule here tests a directory spelled in a path pattern or a variable name.
|
|
19
19
|
*/
|
|
20
|
-
import ts from "typescript"
|
|
21
|
-
import { walk } from "./lib/ast.
|
|
22
|
-
import { callsOf, decoratorsFrom, hasClassDecorator, injectedMembers, methodsDecoratedBy } from "./lib/doors.
|
|
23
|
-
import { hfsOf } from "./lib/hfs.
|
|
24
|
-
import { decoratorArguments, decoratorCallee, importOf, isImportedFrom } from "./lib/import-source.
|
|
25
|
-
import { baseName, enumMemberOf } from "./lib/ports.
|
|
26
|
-
import { typed } from "./lib/types.
|
|
27
|
-
import { isProviderAcknowledgement } from "./lib/webhook-ack.
|
|
28
|
-
import { webhookForbiddenReferences, webhookIntakeDispatchesCommand } from "./lib/webhook-handoff.
|
|
29
|
-
import { firstWebhookChallenge, firstWebhookVerification, isWebhookChallengeReturn, isWebhookDomainServiceType as isDomainServiceType, isWebhookSignatureType as isSignatureType } from "./lib/webhook-verifiers.
|
|
30
|
-
import { webhookInboxKey } from "./lib/webhook-handoff-inbox.
|
|
31
|
-
import { webhookIntakeProcessesDelivery } from "./lib/webhook-handoff-intake.
|
|
32
|
-
|
|
20
|
+
import ts from "typescript";
|
|
21
|
+
import { walk } from "./lib/ast.js";
|
|
22
|
+
import { callsOf, decoratorsFrom, hasClassDecorator, injectedMembers, methodsDecoratedBy } from "./lib/doors.js";
|
|
23
|
+
import { hfsOf } from "./lib/hfs.js";
|
|
24
|
+
import { decoratorArguments, decoratorCallee, importOf, isImportedFrom } from "./lib/import-source.js";
|
|
25
|
+
import { baseName, enumMemberOf } from "./lib/ports.js";
|
|
26
|
+
import { childNode, resolvedSymbol, typed } from "./lib/types.js";
|
|
27
|
+
import { isProviderAcknowledgement } from "./lib/webhook-ack.js";
|
|
28
|
+
import { webhookForbiddenReferences, webhookIntakeDispatchesCommand } from "./lib/webhook-handoff.js";
|
|
29
|
+
import { firstWebhookChallenge, firstWebhookVerification, isWebhookChallengeReturn, isWebhookDomainServiceType as isDomainServiceType, isWebhookSignatureType as isSignatureType } from "./lib/webhook-verifiers.js";
|
|
30
|
+
import { webhookInboxKey } from "./lib/webhook-handoff-inbox.js";
|
|
31
|
+
import { webhookIntakeProcessesDelivery } from "./lib/webhook-handoff-intake.js";
|
|
33
32
|
/** The slot of provider webhook doors. */
|
|
34
|
-
const SLOT = "be.feature.webhooks.http"
|
|
35
|
-
|
|
33
|
+
const SLOT = "be.feature.webhooks.http";
|
|
36
34
|
/** One POST intake and, optionally, one GET subscription challenge are the only webhook routes. */
|
|
37
|
-
const HTTP_VERBS = ["Get", "Post", "Put", "Patch", "Delete", "All", "Options", "Head"]
|
|
38
|
-
|
|
35
|
+
const HTTP_VERBS = ["Get", "Post", "Put", "Patch", "Delete", "All", "Options", "Head"];
|
|
39
36
|
/** Statements and expressions that are a decision or a repetition: none of them belongs in a door. */
|
|
40
|
-
const DECISION_NODES = new Set(["IfStatement", "SwitchStatement", "ConditionalExpression", "LogicalExpression", "ForStatement", "ForInStatement", "ForOfStatement", "WhileStatement", "DoWhileStatement", "TryStatement", "ThrowStatement"])
|
|
41
|
-
|
|
37
|
+
const DECISION_NODES = new Set(["IfStatement", "SwitchStatement", "ConditionalExpression", "LogicalExpression", "ForStatement", "ForInStatement", "ForOfStatement", "WhileStatement", "DoWhileStatement", "TryStatement", "ThrowStatement"]);
|
|
42
38
|
/** The `@Controller` classes of a webhook file, with their handler methods. */
|
|
43
39
|
const doorsOf = (context, program) => {
|
|
44
|
-
const doors = []
|
|
40
|
+
const doors = [];
|
|
45
41
|
walk(program, (node) => {
|
|
46
|
-
if (node.type !== "ClassDeclaration")
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
42
|
+
if (node.type !== "ClassDeclaration")
|
|
43
|
+
return;
|
|
44
|
+
if (hasClassDecorator(context, node, "@nestjs/common", "Controller"))
|
|
45
|
+
doors.push(node);
|
|
46
|
+
});
|
|
47
|
+
return doors;
|
|
48
|
+
};
|
|
52
49
|
/** The route methods of a controller: every method carrying an HTTP verb decorator. */
|
|
53
|
-
const routeMethods = (context, controller) => methodsDecoratedBy(context, controller, "@nestjs/common", HTTP_VERBS)
|
|
54
|
-
|
|
50
|
+
const routeMethods = (context, controller) => methodsDecoratedBy(context, controller, "@nestjs/common", HTTP_VERBS);
|
|
55
51
|
/** The handler of a webhook door: its `@Post` method, or null when it has none. */
|
|
56
|
-
const handlerOf = (context, controller) => methodsDecoratedBy(context, controller, "@nestjs/common", "Post")[0] ?? null
|
|
57
|
-
|
|
52
|
+
const handlerOf = (context, controller) => methodsDecoratedBy(context, controller, "@nestjs/common", "Post")[0] ?? null;
|
|
58
53
|
/** Aliased decorators retain the HTTP verb exported by Nest, rather than their local spelling. */
|
|
59
|
-
const routeVerbs = (context, route) => decoratorsFrom(context, route, "@nestjs/common", HTTP_VERBS).map((decorator) => HTTP_VERBS.find((verb) => isImportedFrom(context, decoratorCallee(decorator), "@nestjs/common", verb)))
|
|
60
|
-
|
|
54
|
+
const routeVerbs = (context, route) => decoratorsFrom(context, route, "@nestjs/common", HTTP_VERBS).map((decorator) => HTTP_VERBS.find((verb) => isImportedFrom(context, decoratorCallee(decorator), "@nestjs/common", verb)));
|
|
61
55
|
/** One unambiguous POST plus at most one unambiguous GET; stacked verb decorators grant no extra routes. */
|
|
62
56
|
const validRoutes = (context, routes) => {
|
|
63
|
-
const verbs = routes.flatMap((route) => routeVerbs(context, route))
|
|
57
|
+
const verbs = routes.flatMap((route) => routeVerbs(context, route));
|
|
64
58
|
return verbs.length === routes.length && verbs.filter((verb) => verb === "Post").length === 1
|
|
65
|
-
&& verbs.filter((verb) => verb === "Get").length <= 1 && verbs.every((verb) => verb === "Post" || verb === "Get")
|
|
66
|
-
}
|
|
67
|
-
|
|
59
|
+
&& verbs.filter((verb) => verb === "Get").length <= 1 && verbs.every((verb) => verb === "Post" || verb === "Get");
|
|
60
|
+
};
|
|
68
61
|
/** A route's name is only presentation, never its identity. */
|
|
69
|
-
const methodName = (method) => method.key.type === "Identifier" ? method.key.name : "the handler"
|
|
70
|
-
|
|
62
|
+
const methodName = (method) => method.key.type === "Identifier" ? method.key.name : "the handler";
|
|
71
63
|
/** True when the method carries `@Public({ reason: PublicReason.SignedWebhook })`: the reason is read from the enum member the argument is. */
|
|
72
|
-
const isSignedWebhookDoor = (context, method) =>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
64
|
+
const isSignedWebhookDoor = (context, method) => (method.decorators ?? []).some((decorator) => {
|
|
65
|
+
const callee = decoratorCallee(decorator);
|
|
66
|
+
if (callee?.type !== "Identifier" || importOf(context, callee) === null)
|
|
67
|
+
return false;
|
|
68
|
+
const options = decoratorArguments(decorator)[0];
|
|
69
|
+
if (options?.type !== "ObjectExpression")
|
|
70
|
+
return false;
|
|
71
|
+
const reason = options.properties.find((property) => property.type === "Property" && !property.computed && property.key.type === "Identifier" && property.key.name === "reason");
|
|
72
|
+
const member = reason ? enumMemberOf(context, reason.value) : null;
|
|
73
|
+
return member !== null && member.enumName === "PublicReason" && member.member === "SignedWebhook";
|
|
74
|
+
});
|
|
83
75
|
/** Decisions are equally forbidden in the delivery and subscription doors. */
|
|
84
76
|
const reportDecisions = (context, method) => {
|
|
85
77
|
walk(method.value.body, (child) => {
|
|
86
|
-
if (DECISION_NODES.has(child.type))
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
78
|
+
if (DECISION_NODES.has(child.type))
|
|
79
|
+
context.report({ node: child, messageId: "branch", data: { what: child.type === "LogicalExpression" ? child.operator : child.type.replace(/(Statement|Expression)$/, "").toLowerCase() } });
|
|
80
|
+
});
|
|
81
|
+
};
|
|
90
82
|
/** POST returns are restricted to the immutable literal acknowledgement of this webhook feature. */
|
|
91
83
|
const reportPostReturns = (context, hfs, handler) => {
|
|
92
84
|
walk(handler.value.body, (child) => {
|
|
93
|
-
if (child.type === "ReturnStatement" && child.argument && !isProviderAcknowledgement(context, hfs, child.argument))
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
85
|
+
if (child.type === "ReturnStatement" && child.argument && !isProviderAcknowledgement(context, hfs, child.argument))
|
|
86
|
+
context.report({ node: child, messageId: "returns", data: { name: methodName(handler) } });
|
|
87
|
+
});
|
|
88
|
+
};
|
|
97
89
|
/** Delivery calls consist only of the completed proof and one domain inbox intake. */
|
|
98
90
|
const deliveryCallKind = (context, hfs, entry, separateProof, proof) => {
|
|
99
|
-
if (entry.receiver === null)
|
|
100
|
-
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
91
|
+
if (entry.receiver === null)
|
|
92
|
+
return "call";
|
|
93
|
+
if (isSignatureType(context, entry.receiver) && entry.method === "verify")
|
|
94
|
+
return "proof";
|
|
95
|
+
if (!isDomainServiceType(context, hfs, entry.receiver))
|
|
96
|
+
return "call";
|
|
97
|
+
if (separateProof && entry.call === proof)
|
|
98
|
+
return "proof";
|
|
99
|
+
return "intake";
|
|
100
|
+
};
|
|
106
101
|
/** A declared proof is no escape hatch for dispatching commands behind the intake door. */
|
|
107
102
|
const reportDomainDispatch = (context, hfs, call, receiver) => {
|
|
108
|
-
if (receiver !== null && isDomainServiceType(context, hfs, receiver) && webhookIntakeDispatchesCommand(context, hfs, call))
|
|
109
|
-
}
|
|
110
|
-
|
|
103
|
+
if (receiver !== null && isDomainServiceType(context, hfs, receiver) && webhookIntakeDispatchesCommand(context, hfs, call))
|
|
104
|
+
context.report({ node: call, messageId: "handoff" });
|
|
105
|
+
};
|
|
111
106
|
/** Delivery calls consist only of the completed proof and one domain inbox intake. */
|
|
112
107
|
const reportIntakeCalls = (context, hfs, handler) => {
|
|
113
|
-
const proof = firstWebhookVerification(context, hfs, handler)
|
|
114
|
-
const calls = callsOf(handler)
|
|
115
|
-
const domainCalls = calls.filter(({ receiver }) => receiver !== null && isDomainServiceType(context, hfs, receiver))
|
|
116
|
-
const separateProof = domainCalls.length > 1 && domainCalls.some(({ call }) => call === proof)
|
|
117
|
-
let intake = 0
|
|
108
|
+
const proof = firstWebhookVerification(context, hfs, handler);
|
|
109
|
+
const calls = callsOf(handler);
|
|
110
|
+
const domainCalls = calls.filter(({ receiver }) => receiver !== null && isDomainServiceType(context, hfs, receiver));
|
|
111
|
+
const separateProof = domainCalls.length > 1 && domainCalls.some(({ call }) => call === proof);
|
|
112
|
+
let intake = 0;
|
|
118
113
|
for (const entry of calls) {
|
|
119
|
-
const { call } = entry
|
|
120
|
-
reportDomainDispatch(context, hfs, call, entry.receiver)
|
|
121
|
-
const kind = deliveryCallKind(context, hfs, entry, separateProof, proof)
|
|
122
|
-
if (kind === "proof")
|
|
114
|
+
const { call } = entry;
|
|
115
|
+
reportDomainDispatch(context, hfs, call, entry.receiver);
|
|
116
|
+
const kind = deliveryCallKind(context, hfs, entry, separateProof, proof);
|
|
117
|
+
if (kind === "proof")
|
|
118
|
+
continue;
|
|
123
119
|
if (kind === "intake") {
|
|
124
|
-
intake += 1
|
|
125
|
-
continue
|
|
120
|
+
intake += 1;
|
|
121
|
+
continue;
|
|
126
122
|
}
|
|
127
|
-
context.report({ node: call, messageId: "call", data: { what: context.sourceCode.getText(call.callee) } })
|
|
123
|
+
context.report({ node: call, messageId: "call", data: { what: context.sourceCode.getText(call.callee) } });
|
|
128
124
|
}
|
|
129
|
-
if (intake !== 1)
|
|
130
|
-
}
|
|
131
|
-
|
|
125
|
+
if (intake !== 1)
|
|
126
|
+
context.report({ node: handler.key, messageId: "intakeCalls", data: { name: methodName(handler), count: String(intake) } });
|
|
127
|
+
};
|
|
132
128
|
/** A challenge calls its domain verifier once and echoes exactly the returned value. */
|
|
133
129
|
const reportChallenge = (context, hfs, handler) => {
|
|
134
|
-
const challenge = firstWebhookChallenge(context, hfs, handler)
|
|
135
|
-
let echoes = 0
|
|
130
|
+
const challenge = firstWebhookChallenge(context, hfs, handler);
|
|
131
|
+
let echoes = 0;
|
|
136
132
|
walk(handler.value.body, (child) => {
|
|
137
|
-
if (child.type !== "ReturnStatement")
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
133
|
+
if (child.type !== "ReturnStatement")
|
|
134
|
+
return;
|
|
135
|
+
echoes += 1;
|
|
136
|
+
if (!isWebhookChallengeReturn(context, child, challenge))
|
|
137
|
+
context.report({ node: child, messageId: "returns", data: { name: methodName(handler) } });
|
|
138
|
+
});
|
|
139
|
+
if (echoes === 0)
|
|
140
|
+
context.report({ node: handler.key, messageId: "returns", data: { name: methodName(handler) } });
|
|
142
141
|
for (const { call, receiver } of callsOf(handler)) {
|
|
143
|
-
reportDomainDispatch(context, hfs, call, receiver)
|
|
144
|
-
if (call !== challenge?.call)
|
|
142
|
+
reportDomainDispatch(context, hfs, call, receiver);
|
|
143
|
+
if (call !== challenge?.call)
|
|
144
|
+
context.report({ node: call, messageId: "call", data: { what: context.sourceCode.getText(call.callee) } });
|
|
145
145
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
146
|
+
};
|
|
148
147
|
/** Public declaration and branch restrictions apply to both routes. */
|
|
149
148
|
const reportRoute = (context, hfs, handler, challenge = false) => {
|
|
150
|
-
if (!isSignedWebhookDoor(context, handler))
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
if (!isSignedWebhookDoor(context, handler))
|
|
150
|
+
context.report({ node: handler.key, messageId: "notPublic", data: { name: methodName(handler) } });
|
|
151
|
+
reportDecisions(context, handler);
|
|
152
|
+
if (challenge)
|
|
153
|
+
reportChallenge(context, hfs, handler);
|
|
153
154
|
else {
|
|
154
|
-
reportPostReturns(context, hfs, handler)
|
|
155
|
-
reportIntakeCalls(context, hfs, handler)
|
|
155
|
+
reportPostReturns(context, hfs, handler);
|
|
156
|
+
reportIntakeCalls(context, hfs, handler);
|
|
156
157
|
}
|
|
157
|
-
}
|
|
158
|
-
|
|
158
|
+
};
|
|
159
159
|
/** The provider file contains one controller; an exported PROVIDER_ACK declaration may accompany it. */
|
|
160
160
|
const reportDoor = (context, hfs, program) => {
|
|
161
|
-
const doors = doorsOf(context, program)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
const doors = doorsOf(context, program);
|
|
162
|
+
const [door] = doors;
|
|
163
|
+
if (doors.length !== 1 || !door) {
|
|
164
|
+
context.report({ node: program, messageId: "noDoor" });
|
|
165
|
+
return;
|
|
165
166
|
}
|
|
166
|
-
const door = doors[0]
|
|
167
167
|
for (const { node, annotation } of injectedMembers(context, door)) {
|
|
168
|
-
if (!annotation || !(isSignatureType(context, annotation) || isDomainServiceType(context, hfs, annotation)))
|
|
168
|
+
if (!annotation || !(isSignatureType(context, annotation) || isDomainServiceType(context, hfs, annotation)))
|
|
169
|
+
context.report({ node, messageId: "injects", data: { what: context.sourceCode.getText(node) } });
|
|
169
170
|
}
|
|
170
|
-
const routes = routeMethods(context, door)
|
|
171
|
+
const routes = routeMethods(context, door);
|
|
171
172
|
if (!validRoutes(context, routes)) {
|
|
172
|
-
const verbs = routes.length > 0 ? ` (${routes.map((route) => routeVerbs(context, route).join("+")).join(", ")})` : ""
|
|
173
|
-
context.report({ node: door, messageId: "route", data: { count: String(routes.length), verbs } })
|
|
174
|
-
return
|
|
173
|
+
const verbs = routes.length > 0 ? ` (${routes.map((route) => routeVerbs(context, route).join("+")).join(", ")})` : "";
|
|
174
|
+
context.report({ node: door, messageId: "route", data: { count: String(routes.length), verbs } });
|
|
175
|
+
return;
|
|
175
176
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
177
|
+
const handler = handlerOf(context, door);
|
|
178
|
+
if (handler)
|
|
179
|
+
reportRoute(context, hfs, handler);
|
|
180
|
+
for (const challenge of methodsDecoratedBy(context, door, "@nestjs/common", "Get"))
|
|
181
|
+
reportRoute(context, hfs, challenge, true);
|
|
182
|
+
};
|
|
180
183
|
/** Resolve a decorator or method through its imported alias to its declaration. */
|
|
181
|
-
const targetSymbol = (checker, node) =>
|
|
182
|
-
const symbol = checker.getSymbolAtLocation(node)
|
|
183
|
-
return symbol?.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol
|
|
184
|
-
}
|
|
185
|
-
|
|
184
|
+
const targetSymbol = (checker, node) => resolvedSymbol(checker, checker.getSymbolAtLocation(node));
|
|
186
185
|
/** Public metadata belongs to the identity owner, including aliases and namespace imports. */
|
|
187
186
|
const isPublicDecorator = (context, hfs, decorator) => {
|
|
188
|
-
const { checker, toTs } = typed(context)
|
|
189
|
-
const
|
|
190
|
-
const
|
|
187
|
+
const { checker, toTs } = typed(context);
|
|
188
|
+
const callee = decoratorCallee(decorator);
|
|
189
|
+
const node = callee && toTs(callee);
|
|
190
|
+
const symbol = node && targetSymbol(checker, ts.isPropertyAccessExpression(node) ? node.name : node);
|
|
191
191
|
return symbol?.getName() === "Public" && symbol.getDeclarations()?.some((declaration) => {
|
|
192
|
-
const file = declaration.getSourceFile().fileName.replace(/\\/g, "/")
|
|
193
|
-
return hfs.tierOf(file) === "domain" && hfs.ownerOf(file)?.split("/").at(-1) === "identity"
|
|
194
|
-
})
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
return node
|
|
192
|
+
const file = declaration.getSourceFile().fileName.replace(/\\/g, "/");
|
|
193
|
+
return hfs.tierOf(file) === "domain" && hfs.ownerOf(file)?.split("/").at(-1) === "identity";
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
function unwrapTs(node) {
|
|
197
|
+
while (node && (ts.isAsExpression(node) || ts.isSatisfiesExpression(node) || ts.isParenthesizedExpression(node)))
|
|
198
|
+
node = node.expression;
|
|
199
|
+
return node;
|
|
201
200
|
}
|
|
202
|
-
|
|
203
201
|
/** Static object properties keep aliases, spreads and computed literal keys readable. Last writes win. */
|
|
204
202
|
const propertyValue = (checker, expression, name, seen = new Set()) => {
|
|
205
|
-
const node = unwrapTs(expression)
|
|
206
|
-
if (!node || seen.has(node))
|
|
207
|
-
|
|
203
|
+
const node = unwrapTs(expression);
|
|
204
|
+
if (!node || seen.has(node))
|
|
205
|
+
return null;
|
|
206
|
+
seen.add(node);
|
|
208
207
|
if (ts.isObjectLiteralExpression(node)) {
|
|
209
208
|
for (const property of [...node.properties].reverse()) {
|
|
210
209
|
if (ts.isSpreadAssignment(property)) {
|
|
211
|
-
const value = propertyValue(checker, property.expression, name, seen)
|
|
212
|
-
if (value)
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
210
|
+
const value = propertyValue(checker, property.expression, name, seen);
|
|
211
|
+
if (value)
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
else if (ts.isPropertyAssignment(property) || ts.isShorthandPropertyAssignment(property)) {
|
|
215
|
+
const key = ts.isComputedPropertyName(property.name) ? unwrapTs(property.name.expression) : property.name;
|
|
216
|
+
if ((ts.isIdentifier(key) || ts.isStringLiteralLike(key)) && key.text === name)
|
|
217
|
+
return ts.isPropertyAssignment(property) ? property.initializer : property.name;
|
|
216
218
|
}
|
|
217
219
|
}
|
|
218
|
-
return null
|
|
220
|
+
return null;
|
|
219
221
|
}
|
|
220
|
-
const symbol = targetSymbol(checker, ts.isPropertyAccessExpression(node) ? node.name : node)
|
|
222
|
+
const symbol = targetSymbol(checker, ts.isPropertyAccessExpression(node) ? node.name : node);
|
|
221
223
|
for (const declaration of symbol?.getDeclarations() ?? []) {
|
|
222
|
-
const value = propertyValue(checker, declaration
|
|
223
|
-
if (value)
|
|
224
|
+
const value = propertyValue(checker, childNode(declaration, "initializer"), name, seen);
|
|
225
|
+
if (value)
|
|
226
|
+
return value;
|
|
224
227
|
}
|
|
225
|
-
return null
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
+
return null;
|
|
229
|
+
};
|
|
228
230
|
/** A public reason is the actual `PublicReason` member of the identity owner, even behind a const options alias. */
|
|
229
231
|
const publicReason = (context, decorator, member) => {
|
|
230
|
-
const { checker, toTs } = typed(context)
|
|
231
|
-
const options = decoratorArguments(decorator)[0]
|
|
232
|
-
const reason = options && propertyValue(checker, toTs(options), "reason")
|
|
233
|
-
if (!reason)
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
const
|
|
232
|
+
const { checker, toTs } = typed(context);
|
|
233
|
+
const options = decoratorArguments(decorator)[0];
|
|
234
|
+
const reason = options && propertyValue(checker, toTs(options), "reason");
|
|
235
|
+
if (!reason)
|
|
236
|
+
return false;
|
|
237
|
+
const type = checker.getTypeAtLocation(unwrapTs(reason));
|
|
238
|
+
const declaration = type.getSymbol()?.getDeclarations()?.[0];
|
|
239
|
+
const owner = declaration?.parent;
|
|
237
240
|
if (!declaration || !ts.isEnumMember(declaration) || !owner || !ts.isEnumDeclaration(owner)
|
|
238
|
-
|| owner.name.text !== "PublicReason" || declaration.name.getText().replace(/["']/g, "") !== member)
|
|
239
|
-
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
241
|
+
|| owner.name.text !== "PublicReason" || declaration.name.getText().replace(/["']/g, "") !== member)
|
|
242
|
+
return false;
|
|
243
|
+
const hfs = hfsOf(context);
|
|
244
|
+
const file = declaration.getSourceFile().fileName.replace(/\\/g, "/");
|
|
245
|
+
return hfs.tierOf(file) === "domain" && hfs.ownerOf(file)?.split("/").at(-1) === "identity";
|
|
246
|
+
};
|
|
244
247
|
/** A SignedWebhook reason is the actual identity enum member, even behind a const options alias. */
|
|
245
|
-
const signedReason = (context, decorator) => publicReason(context, decorator, "SignedWebhook")
|
|
246
|
-
|
|
248
|
+
const signedReason = (context, decorator) => publicReason(context, decorator, "SignedWebhook");
|
|
247
249
|
/** An explicit verifier exemption names the exact domain method in a webhook HTTP module's exported const array. */
|
|
248
250
|
const declaredVerifier = (context, hfs, method) => {
|
|
249
|
-
if (method?.type !== "MethodDefinition" || hfs.tierOf(context.filename) !== "domain" || !baseName(context.filename).endsWith(".service.ts"))
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
const
|
|
253
|
-
|
|
251
|
+
if (method?.type !== "MethodDefinition" || hfs.tierOf(context.filename) !== "domain" || !baseName(context.filename).endsWith(".service.ts"))
|
|
252
|
+
return false;
|
|
253
|
+
const { checker, program, toTs } = typed(context);
|
|
254
|
+
const declaration = toTs(method);
|
|
255
|
+
const name = childNode(declaration, "name");
|
|
256
|
+
const symbol = name && targetSymbol(checker, name);
|
|
257
|
+
if (!symbol)
|
|
258
|
+
return false;
|
|
254
259
|
return program.getSourceFiles().some((source) => hfs.slotOf(source.fileName) === SLOT && baseName(source.fileName).endsWith(".module.ts")
|
|
255
260
|
&& source.statements.some((statement) => ts.isVariableStatement(statement)
|
|
256
261
|
&& statement.declarationList.flags & ts.NodeFlags.Const
|
|
257
262
|
&& statement.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword)
|
|
258
263
|
&& statement.declarationList.declarations.some((entry) => {
|
|
259
|
-
const array = unwrapTs(entry.initializer)
|
|
264
|
+
const array = unwrapTs(entry.initializer);
|
|
260
265
|
return ts.isIdentifier(entry.name) && entry.name.text === "webhookVerifiers" && array && ts.isArrayLiteralExpression(array)
|
|
261
266
|
&& array.elements.some((item) => {
|
|
262
|
-
const reference = unwrapTs(item)
|
|
263
|
-
return reference && ts.isPropertyAccessExpression(reference) && targetSymbol(checker, reference.name) === symbol
|
|
264
|
-
})
|
|
265
|
-
})))
|
|
266
|
-
}
|
|
267
|
-
|
|
267
|
+
const reference = unwrapTs(item);
|
|
268
|
+
return reference && ts.isPropertyAccessExpression(reference) && targetSymbol(checker, reference.name) === symbol;
|
|
269
|
+
});
|
|
270
|
+
})));
|
|
271
|
+
};
|
|
268
272
|
/** Read literal paths and const aliases through the checker; Nest accepts path lists and Controller options too. */
|
|
269
273
|
const routePaths = (context, decorator) => {
|
|
270
|
-
const { checker, toTs } = typed(context)
|
|
271
|
-
const seen = new Set()
|
|
274
|
+
const { checker, toTs } = typed(context);
|
|
275
|
+
const seen = new Set();
|
|
272
276
|
const read = (original) => {
|
|
273
|
-
const node = unwrapTs(original)
|
|
274
|
-
if (!node || seen.has(node))
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (ts.
|
|
278
|
-
|
|
277
|
+
const node = unwrapTs(original);
|
|
278
|
+
if (!node || seen.has(node))
|
|
279
|
+
return [];
|
|
280
|
+
seen.add(node);
|
|
281
|
+
if (ts.isStringLiteralLike(node))
|
|
282
|
+
return [node.text];
|
|
283
|
+
if (ts.isArrayLiteralExpression(node))
|
|
284
|
+
return node.elements.flatMap(read);
|
|
285
|
+
if (ts.isObjectLiteralExpression(node))
|
|
286
|
+
return read(propertyValue(checker, node, "path"));
|
|
279
287
|
if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.PlusToken) {
|
|
280
|
-
return read(node.left).flatMap((left) => read(node.right).map((right) => left + right))
|
|
288
|
+
return read(node.left).flatMap((left) => read(node.right).map((right) => left + right));
|
|
281
289
|
}
|
|
282
290
|
if (ts.isTemplateExpression(node)) {
|
|
283
|
-
return node.templateSpans.reduce((values, span) => values.flatMap((value) => read(span.expression).map((part) => value + part + span.literal.text)), [node.head.text])
|
|
291
|
+
return node.templateSpans.reduce((values, span) => values.flatMap((value) => read(span.expression).map((part) => value + part + span.literal.text)), [node.head.text]);
|
|
284
292
|
}
|
|
285
|
-
const reference = ts.isPropertyAccessExpression(node) ? node.name : node
|
|
286
|
-
const symbol = targetSymbol(checker, reference)
|
|
287
|
-
return symbol?.getDeclarations()?.flatMap((declaration) => read(declaration
|
|
288
|
-
}
|
|
289
|
-
return decoratorArguments(decorator).flatMap((argument) => read(toTs(argument)))
|
|
290
|
-
}
|
|
291
|
-
|
|
293
|
+
const reference = ts.isPropertyAccessExpression(node) ? node.name : node;
|
|
294
|
+
const symbol = targetSymbol(checker, reference);
|
|
295
|
+
return symbol?.getDeclarations()?.flatMap((declaration) => read(childNode(declaration, "initializer"))) ?? [];
|
|
296
|
+
};
|
|
297
|
+
return decoratorArguments(decorator).flatMap((argument) => read(toTs(argument)));
|
|
298
|
+
};
|
|
292
299
|
/**
|
|
293
300
|
* A third-party OAuth redirect into the API (owner ruling 2026-10-17 "Theo y tro": the owner delegated the decision to main):
|
|
294
301
|
* a GET named `callback` that declares the closed reason `PublicReason.AuthHandshake`. It is a browser redirect with no
|
|
295
302
|
* signature to verify, so it is not a webhook door. A POST, a `webhook` or `events` path, or any other reason is still judged.
|
|
296
303
|
*/
|
|
297
|
-
const isOAuthRedirect = (context, route, publicMetadata, paths) =>
|
|
298
|
-
|
|
299
|
-
&& !paths.some((path) => /webhook|events/i.test(path))
|
|
300
|
-
|
|
304
|
+
const isOAuthRedirect = (context, route, publicMetadata, paths) => routeVerbs(context, route).every((verb) => verb === "Get") && publicMetadata.some((decorator) => publicReason(context, decorator, "AuthHandshake"))
|
|
305
|
+
&& !paths.some((path) => /webhook|events/i.test(path));
|
|
301
306
|
/** R263: public webhook traffic always enters the signed, verified webhook kind. */
|
|
302
307
|
export const webhookScope = {
|
|
303
308
|
meta: {
|
|
@@ -310,34 +315,39 @@ export const webhookScope = {
|
|
|
310
315
|
},
|
|
311
316
|
},
|
|
312
317
|
create(context) {
|
|
313
|
-
const hfs = hfsOf(context)
|
|
314
|
-
const slot = hfs.slotOf(context.filename)
|
|
315
|
-
if (slot?.startsWith("be.tests.") || /(?:\.spec|\.d)\.ts$/.test(context.filename))
|
|
316
|
-
|
|
318
|
+
const hfs = hfsOf(context);
|
|
319
|
+
const slot = hfs.slotOf(context.filename);
|
|
320
|
+
if (slot?.startsWith("be.tests.") || /(?:\.spec|\.d)\.ts$/.test(context.filename))
|
|
321
|
+
return {};
|
|
322
|
+
const inDoor = slot === SLOT && baseName(context.filename).endsWith(".webhook.ts");
|
|
317
323
|
return {
|
|
318
324
|
CallExpression(call) {
|
|
319
325
|
if (inDoor && call.callee.type === "MemberExpression" && isDomainServiceType(context, hfs, call.callee.object)
|
|
320
|
-
&& webhookIntakeProcessesDelivery(context, hfs, call))
|
|
326
|
+
&& webhookIntakeProcessesDelivery(context, hfs, call))
|
|
327
|
+
context.report({ node: call, messageId: "intake" });
|
|
321
328
|
},
|
|
322
329
|
Decorator(decorator) {
|
|
323
330
|
if (!inDoor && isPublicDecorator(context, hfs, decorator) && signedReason(context, decorator)
|
|
324
|
-
&& !declaredVerifier(context, hfs, decorator.parent))
|
|
331
|
+
&& !declaredVerifier(context, hfs, decorator.parent))
|
|
332
|
+
context.report({ node: decorator, messageId: "scope" });
|
|
325
333
|
},
|
|
326
334
|
ClassDeclaration(controller) {
|
|
327
|
-
if (inDoor || !hasClassDecorator(context, controller, "@nestjs/common", "Controller"))
|
|
328
|
-
|
|
329
|
-
const
|
|
335
|
+
if (inDoor || !hasClassDecorator(context, controller, "@nestjs/common", "Controller"))
|
|
336
|
+
return;
|
|
337
|
+
const classPublic = (controller.decorators ?? []).filter((decorator) => isPublicDecorator(context, hfs, decorator));
|
|
338
|
+
const prefix = decoratorsFrom(context, controller, "@nestjs/common", "Controller").flatMap((decorator) => routePaths(context, decorator));
|
|
330
339
|
for (const method of routeMethods(context, controller)) {
|
|
331
|
-
const publicMetadata = [...classPublic, ...(method.decorators ?? []).filter((decorator) => isPublicDecorator(context, hfs, decorator))]
|
|
332
|
-
if (publicMetadata.length === 0 || publicMetadata.some((decorator) => signedReason(context, decorator)))
|
|
333
|
-
|
|
334
|
-
|
|
340
|
+
const publicMetadata = [...classPublic, ...(method.decorators ?? []).filter((decorator) => isPublicDecorator(context, hfs, decorator))];
|
|
341
|
+
if (publicMetadata.length === 0 || publicMetadata.some((decorator) => signedReason(context, decorator)))
|
|
342
|
+
continue;
|
|
343
|
+
const paths = [...prefix, ...decoratorsFrom(context, method, "@nestjs/common", HTTP_VERBS).flatMap((decorator) => routePaths(context, decorator))];
|
|
344
|
+
if (paths.some((path) => /webhook|callback|events/i.test(path)) && !isOAuthRedirect(context, method, publicMetadata, paths))
|
|
345
|
+
context.report({ node: method.key, messageId: "scope" });
|
|
335
346
|
}
|
|
336
347
|
},
|
|
337
|
-
}
|
|
348
|
+
};
|
|
338
349
|
},
|
|
339
|
-
}
|
|
340
|
-
|
|
350
|
+
};
|
|
341
351
|
/** A provider webhook door: one signed `@Post`, the signature proof, one domain intake call, nothing else. */
|
|
342
352
|
export const webhookShape = {
|
|
343
353
|
meta: {
|
|
@@ -357,19 +367,21 @@ export const webhookShape = {
|
|
|
357
367
|
},
|
|
358
368
|
},
|
|
359
369
|
create(context) {
|
|
360
|
-
const hfs = hfsOf(context)
|
|
361
|
-
const name = baseName(context.filename)
|
|
362
|
-
const isDoor = name.endsWith(".webhook.ts")
|
|
363
|
-
if (hfs.slotOf(context.filename) !== SLOT || !(isDoor || name.endsWith(".module.ts")))
|
|
370
|
+
const hfs = hfsOf(context);
|
|
371
|
+
const name = baseName(context.filename);
|
|
372
|
+
const isDoor = name.endsWith(".webhook.ts");
|
|
373
|
+
if (hfs.slotOf(context.filename) !== SLOT || !(isDoor || name.endsWith(".module.ts")))
|
|
374
|
+
return {};
|
|
364
375
|
return {
|
|
365
376
|
"Program:exit"(program) {
|
|
366
|
-
for (const node of webhookForbiddenReferences(context, hfs, program))
|
|
367
|
-
|
|
377
|
+
for (const node of webhookForbiddenReferences(context, hfs, program))
|
|
378
|
+
context.report({ node, messageId: "handoff" });
|
|
379
|
+
if (isDoor)
|
|
380
|
+
reportDoor(context, hfs, program);
|
|
368
381
|
},
|
|
369
|
-
}
|
|
382
|
+
};
|
|
370
383
|
},
|
|
371
|
-
}
|
|
372
|
-
|
|
384
|
+
};
|
|
373
385
|
/** The first statement of the handler is the unconditional signature proof. */
|
|
374
386
|
export const webhookVerifyFirst = {
|
|
375
387
|
meta: {
|
|
@@ -381,34 +393,34 @@ export const webhookVerifyFirst = {
|
|
|
381
393
|
},
|
|
382
394
|
},
|
|
383
395
|
create(context) {
|
|
384
|
-
const hfs = hfsOf(context)
|
|
385
|
-
if (hfs.slotOf(context.filename) !== SLOT || !baseName(context.filename).endsWith(".webhook.ts"))
|
|
396
|
+
const hfs = hfsOf(context);
|
|
397
|
+
if (hfs.slotOf(context.filename) !== SLOT || !baseName(context.filename).endsWith(".webhook.ts"))
|
|
398
|
+
return {};
|
|
386
399
|
return {
|
|
387
400
|
"Program:exit"(program) {
|
|
388
401
|
for (const door of doorsOf(context, program)) {
|
|
389
402
|
for (const handler of methodsDecoratedBy(context, door, "@nestjs/common", ["Post", "Get"])) {
|
|
390
|
-
const challenge = decoratorsFrom(context, handler, "@nestjs/common", "Get").length > 0
|
|
391
|
-
const proven = challenge ? firstWebhookChallenge(context, hfs, handler) : firstWebhookVerification(context, hfs, handler)
|
|
392
|
-
if (!proven)
|
|
403
|
+
const challenge = decoratorsFrom(context, handler, "@nestjs/common", "Get").length > 0;
|
|
404
|
+
const proven = challenge ? firstWebhookChallenge(context, hfs, handler) : firstWebhookVerification(context, hfs, handler);
|
|
405
|
+
if (!proven)
|
|
406
|
+
context.report({ node: handler.key, messageId: "first", data: { name: methodName(handler) } });
|
|
393
407
|
}
|
|
394
408
|
}
|
|
395
409
|
},
|
|
396
|
-
}
|
|
410
|
+
};
|
|
397
411
|
},
|
|
398
|
-
}
|
|
399
|
-
|
|
412
|
+
};
|
|
400
413
|
/** The rules this law contributes to the plugin. */
|
|
401
414
|
export const rules = {
|
|
402
415
|
"webhook-shape": webhookShape,
|
|
403
416
|
"webhook-verify-first": webhookVerifyFirst,
|
|
404
417
|
"webhook-scope": webhookScope,
|
|
405
418
|
"webhook-inbox-key": webhookInboxKey,
|
|
406
|
-
}
|
|
407
|
-
|
|
419
|
+
};
|
|
408
420
|
/** Every rule of this law at `error`. */
|
|
409
421
|
export const recommended = {
|
|
410
422
|
"starci-be/webhook-shape": "error",
|
|
411
423
|
"starci-be/webhook-verify-first": "error",
|
|
412
424
|
"starci-be/webhook-scope": "error",
|
|
413
425
|
"starci-be/webhook-inbox-key": "error",
|
|
414
|
-
}
|
|
426
|
+
};
|