@adaptic/backend-legacy 0.0.1057 → 0.0.1058
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/auth/authorization-map.cjs +306 -0
- package/auth/authorization-map.d.ts +143 -0
- package/auth/cortex-auth-checker.cjs +172 -0
- package/auth/cortex-auth-checker.d.ts +114 -0
- package/auth/credential-fields.cjs +51 -0
- package/auth/credential-fields.d.ts +19 -0
- package/auth/credential-redaction.cjs +134 -0
- package/auth/credential-redaction.d.ts +60 -0
- package/auth/graphql-auth-shadow.cjs +317 -0
- package/auth/graphql-auth-shadow.d.ts +194 -0
- package/auth/membership-write-authority.cjs +131 -0
- package/auth/membership-write-authority.d.ts +110 -0
- package/auth/mutation-authorization.cjs +376 -0
- package/auth/mutation-authorization.d.ts +261 -0
- package/auth/nested-write-inspector.cjs +189 -0
- package/auth/nested-write-inspector.d.ts +94 -0
- package/auth/nested-write-policy.cjs +189 -0
- package/auth/nested-write-policy.d.ts +99 -0
- package/auth/service-token.cjs +316 -0
- package/auth/service-token.d.ts +94 -0
- package/auth/tenancy-scope.cjs +736 -0
- package/auth/tenancy-scope.d.ts +347 -0
- package/auth/token-verifier.cjs +451 -0
- package/auth/token-verifier.d.ts +153 -0
- package/auth/totp.cjs +265 -0
- package/auth/totp.d.ts +111 -0
- package/auth/user-write-content.cjs +116 -0
- package/auth/user-write-content.d.ts +47 -0
- package/auth/ws-auth-context.cjs +75 -0
- package/auth/ws-auth-context.d.ts +69 -0
- package/config/jwtConfig.cjs +52 -0
- package/config/jwtConfig.d.ts +16 -0
- package/config/metrics.cjs +356 -0
- package/config/metrics.d.ts +128 -0
- package/config/persisted-queries.cjs +122 -0
- package/config/persisted-queries.d.ts +40 -0
- package/config/server-only-models.cjs +166 -0
- package/config/server-only-models.d.ts +89 -0
- package/config/tracing.d.ts +24 -0
- package/generated/typegraphql-prisma/enhance.cjs +3 -3
- package/generated/typegraphql-prisma/index.cjs +6 -6
- package/generated/typegraphql-prisma/resolvers/crud/args.index.cjs +95 -95
- package/generated/typegraphql-prisma/resolvers/outputs/index.cjs +1 -1
- package/generated/typegraphql-prisma/resolvers/relations/args.index.cjs +32 -32
- package/middleware/audit-log-write-redaction.cjs +143 -0
- package/middleware/audit-log-write-redaction.d.ts +82 -0
- package/middleware/audit-logger.cjs +378 -0
- package/middleware/audit-logger.d.ts +158 -0
- package/middleware/audit-payload-guard.cjs +107 -0
- package/middleware/audit-payload-guard.d.ts +85 -0
- package/middleware/auth.cjs +66 -0
- package/middleware/auth.d.ts +41 -0
- package/middleware/credential-field-guard.cjs +514 -0
- package/middleware/credential-field-guard.d.ts +173 -0
- package/middleware/generated-type-names.cjs +77 -0
- package/middleware/generated-type-names.d.ts +44 -0
- package/middleware/graphql-validation-plugin.cjs +310 -0
- package/middleware/graphql-validation-plugin.d.ts +98 -0
- package/middleware/guard-log-throttle.cjs +89 -0
- package/middleware/guard-log-throttle.d.ts +80 -0
- package/middleware/index.cjs +57 -0
- package/middleware/index.d.ts +14 -0
- package/middleware/input-validator.cjs +220 -0
- package/middleware/input-validator.d.ts +63 -0
- package/middleware/mandate-version-validation.cjs +131 -0
- package/middleware/mandate-version-validation.d.ts +41 -0
- package/middleware/mutation-account-facts.cjs +223 -0
- package/middleware/mutation-account-facts.d.ts +143 -0
- package/middleware/mutation-auth-guard.cjs +536 -0
- package/middleware/mutation-auth-guard.d.ts +100 -0
- package/middleware/mutation-membership-facts.cjs +276 -0
- package/middleware/mutation-membership-facts.d.ts +133 -0
- package/middleware/mutation-tenant-facts.cjs +132 -0
- package/middleware/mutation-tenant-facts.d.ts +81 -0
- package/middleware/query-complexity.cjs +182 -0
- package/middleware/query-complexity.d.ts +56 -0
- package/middleware/rate-limiter.cjs +223 -0
- package/middleware/rate-limiter.d.ts +93 -0
- package/middleware/rate-tier.cjs +111 -0
- package/middleware/rate-tier.d.ts +56 -0
- package/middleware/soft-delete.cjs +175 -0
- package/middleware/soft-delete.d.ts +146 -0
- package/middleware/tenancy-scoping.cjs +229 -0
- package/middleware/tenancy-scoping.d.ts +67 -0
- package/middleware/trading-policy-audit.cjs +353 -0
- package/middleware/trading-policy-audit.d.ts +184 -0
- package/middleware/types.cjs +17 -0
- package/middleware/types.d.ts +87 -0
- package/middleware/validation-examples.cjs +398 -0
- package/middleware/validation-examples.d.ts +76 -0
- package/package.json +10 -2
- package/readers/index.cjs +15 -0
- package/readers/index.d.ts +10 -0
- package/readers/intraday-lane-prefs.cjs +76 -0
- package/readers/intraday-lane-prefs.d.ts +45 -0
- package/esm/config/__tests__/server-only-surface.harness.d.ts +0 -12
- package/esm/config/__tests__/server-only-surface.harness.mjs +0 -41
- package/esm/middleware/__tests__/audit-log-write-redaction.harness.d.ts +0 -144
- package/esm/middleware/__tests__/audit-log-write-redaction.harness.mjs +0 -920
- package/esm/middleware/__tests__/credential-field-coverage.harness.d.ts +0 -55
- package/esm/middleware/__tests__/credential-field-coverage.harness.mjs +0 -440
- package/esm/middleware/__tests__/credential-field-guard.harness.d.ts +0 -34
- package/esm/middleware/__tests__/credential-field-guard.harness.mjs +0 -212
- package/esm/middleware/__tests__/mutation-auth-guard.harness.d.ts +0 -56
- package/esm/middleware/__tests__/mutation-auth-guard.harness.mjs +0 -575
- package/esm/middleware/__tests__/rate-limit-test-utils.d.ts +0 -60
- package/esm/middleware/__tests__/rate-limit-test-utils.mjs +0 -85
- package/esm/middleware/__tests__/ts-node-harness.d.ts +0 -10
- package/esm/middleware/__tests__/ts-node-harness.mjs +0 -71
- package/health.cjs +0 -274
- package/server.cjs +0 -607
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service-to-service principal minted from a dedicated HS256 secret.
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS EXISTS AS A THIRD PATH RATHER THAN REUSING EITHER EXISTING ONE.
|
|
5
|
+
* `verifyBackendToken` already knows two ways to arrive at a non-user caller,
|
|
6
|
+
* and both are wrong for a long-lived internal service:
|
|
7
|
+
*
|
|
8
|
+
* - `SERVER_AUTH_TOKEN` is an exact string match against a static value. It
|
|
9
|
+
* never expires, carries no audience, names no caller, and cannot be
|
|
10
|
+
* rotated without a simultaneous restart of every holder. A copy taken
|
|
11
|
+
* from a log or a process listing is a permanent credential.
|
|
12
|
+
* - An app-issued JWT verifies against `jwtSecret` — the SAME secret that
|
|
13
|
+
* signs end-user sessions. A service credential keyed on it would make
|
|
14
|
+
* every holder of a user secret able to mint a service identity and vice
|
|
15
|
+
* versa, and it yields `kind: "user"`, which is then subject to
|
|
16
|
+
* per-user tenancy scoping that a service must not be subject to.
|
|
17
|
+
*
|
|
18
|
+
* So the service path is keyed on `BACKEND_SERVICE_JWT_SECRET`, a secret whose
|
|
19
|
+
* ONLY purpose is service identity. It is deliberately distinct from
|
|
20
|
+
* `JWT_SECRET` so that the blast radius of either one leaking stops at that
|
|
21
|
+
* one trust domain, and the verifier refuses to run if the two are ever set to
|
|
22
|
+
* the same value — a configuration that would silently collapse the
|
|
23
|
+
* separation this module exists to create.
|
|
24
|
+
*
|
|
25
|
+
* ABSENCE DISABLES THE PATH; IT NEVER WIDENS IT. With no secret provisioned
|
|
26
|
+
* `verifyServiceToken` returns `null` and the caller falls through to the
|
|
27
|
+
* existing paths, which reject. A service that cannot prove itself is refused,
|
|
28
|
+
* never admitted.
|
|
29
|
+
*
|
|
30
|
+
* @module auth/service-token
|
|
31
|
+
*/
|
|
32
|
+
import { type BackendPrincipal } from './token-verifier';
|
|
33
|
+
/**
|
|
34
|
+
* Issuer every service credential must carry.
|
|
35
|
+
*
|
|
36
|
+
* Pinned rather than free-form so a token minted for some other HS256 system
|
|
37
|
+
* that happens to share the secret cannot be replayed here.
|
|
38
|
+
*/
|
|
39
|
+
export declare const SERVICE_TOKEN_ISSUER = "adaptic-service";
|
|
40
|
+
/**
|
|
41
|
+
* Audience every service credential must carry.
|
|
42
|
+
*
|
|
43
|
+
* This backend is the only intended recipient. Binding the audience is what
|
|
44
|
+
* stops a credential minted for a sibling service from being replayed against
|
|
45
|
+
* the data tier.
|
|
46
|
+
*/
|
|
47
|
+
export declare const SERVICE_TOKEN_AUDIENCE = "adaptic-backend";
|
|
48
|
+
/** Minimum length for the dedicated service secret, in characters. */
|
|
49
|
+
export declare const MINIMUM_SERVICE_SECRET_LENGTH = 32;
|
|
50
|
+
/**
|
|
51
|
+
* Largest lifetime this backend will honour on a service credential, seconds.
|
|
52
|
+
*
|
|
53
|
+
* A credential's own `exp` bounds the replay window on a leak, so a minter is
|
|
54
|
+
* free to choose a shorter one — but it may not choose a longer one and
|
|
55
|
+
* thereby re-create the non-expiring static bearer this path replaces. One
|
|
56
|
+
* hour is comfortably above the 15-minute lifetime the engine mints and far
|
|
57
|
+
* below "effectively permanent".
|
|
58
|
+
*/
|
|
59
|
+
export declare const MAX_SERVICE_TOKEN_LIFETIME_SEC = 3600;
|
|
60
|
+
/**
|
|
61
|
+
* How far in the future, seconds, a credential's `iat` may sit before it is
|
|
62
|
+
* refused.
|
|
63
|
+
*
|
|
64
|
+
* The lifetime ceiling is measured from `iat`, so an `iat` the verifier does
|
|
65
|
+
* not bound would let a secret holder date a token years ahead and hold a
|
|
66
|
+
* credential valid until then. One minute absorbs ordinary clock drift between
|
|
67
|
+
* a minter and this host and nothing more.
|
|
68
|
+
*/
|
|
69
|
+
export declare const MAX_SERVICE_TOKEN_CLOCK_SKEW_SEC = 60;
|
|
70
|
+
/**
|
|
71
|
+
* Which configured secret proved a credential's signature.
|
|
72
|
+
*
|
|
73
|
+
* `primary` is `BACKEND_SERVICE_JWT_SECRET`; `previous` is the optional
|
|
74
|
+
* `BACKEND_SERVICE_JWT_SECRET_PREVIOUS` that exists only for the length of a
|
|
75
|
+
* rotation.
|
|
76
|
+
*/
|
|
77
|
+
export type ServiceKeySlot = 'primary' | 'previous';
|
|
78
|
+
/**
|
|
79
|
+
* Attempt to establish a service principal from a bearer token.
|
|
80
|
+
*
|
|
81
|
+
* Returns `null` — meaning "not a service credential, keep looking" — only
|
|
82
|
+
* when the path is unprovisioned or the signature does not belong to the
|
|
83
|
+
* service secret. Once a token IS proven to carry that signature, every
|
|
84
|
+
* subsequent problem with it (expiry, wrong audience, missing subject,
|
|
85
|
+
* over-long lifetime) throws, because at that point the caller's intent is
|
|
86
|
+
* unambiguous and falling through would report a misleading `bad_signature`
|
|
87
|
+
* for what is actually an expired or mis-scoped service token.
|
|
88
|
+
*
|
|
89
|
+
* @param token - Raw bearer token; assumed to be three dot-separated segments.
|
|
90
|
+
* @returns The verified service principal, or `null` to fall through.
|
|
91
|
+
* @throws {AuthError} When the token is ours but unacceptable.
|
|
92
|
+
*/
|
|
93
|
+
export declare function verifyServiceToken(token: string, nowMs?: number): BackendPrincipal | null;
|
|
94
|
+
//# sourceMappingURL=service-token.d.ts.map
|