@dcsv-io/d2-auth-abstractions 0.1.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/LICENSE +190 -0
- package/README.md +104 -0
- package/dist/auth-error-codes.g.d.ts +29 -0
- package/dist/auth-error-codes.g.d.ts.map +1 -0
- package/dist/auth-error-codes.g.js +71 -0
- package/dist/auth-error-codes.g.js.map +1 -0
- package/dist/auth-failures.g.d.ts +85 -0
- package/dist/auth-failures.g.d.ts.map +1 -0
- package/dist/auth-failures.g.js +156 -0
- package/dist/auth-failures.g.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/jwt-claim-types.g.d.ts +108 -0
- package/dist/jwt-claim-types.g.d.ts.map +1 -0
- package/dist/jwt-claim-types.g.js +115 -0
- package/dist/jwt-claim-types.g.js.map +1 -0
- package/dist/jwt-payload.g.d.ts +101 -0
- package/dist/jwt-payload.g.d.ts.map +1 -0
- package/dist/jwt-payload.g.js +9 -0
- package/dist/jwt-payload.g.js.map +1 -0
- package/dist/protocol-audiences.g.d.ts +19 -0
- package/dist/protocol-audiences.g.d.ts.map +1 -0
- package/dist/protocol-audiences.g.js +29 -0
- package/dist/protocol-audiences.g.js.map +1 -0
- package/dist/scopes.g.d.ts +21 -0
- package/dist/scopes.g.d.ts.map +1 -0
- package/dist/scopes.g.js +33 -0
- package/dist/scopes.g.js.map +1 -0
- package/package.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright (c) DCSV
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (c) DCSV. Licensed under the Apache License, Version 2.0.
|
|
3
|
+
-->
|
|
4
|
+
|
|
5
|
+
# @dcsv-io/d2-auth-abstractions
|
|
6
|
+
|
|
7
|
+
> Parent: [`packages/typescript/`](../../README.md)
|
|
8
|
+
|
|
9
|
+
Auth-related constants for TS consumers — `Scopes` tree, `AuthErrorCodes`,
|
|
10
|
+
`AuthFailures` factories, `JwtClaimTypes`. Mirrors
|
|
11
|
+
`DcsvIo.D2.Auth.Abstractions` + `DcsvIo.D2.Auth.Errors` consolidated
|
|
12
|
+
(matches the .NET assembly placement).
|
|
13
|
+
|
|
14
|
+
## Public API
|
|
15
|
+
|
|
16
|
+
| Export | Source | Mirror |
|
|
17
|
+
| ------------------------------------------------------- | --------------------------------- | ------------------------------------------- |
|
|
18
|
+
| `Scopes` (nested constants) | `scopes.g.ts` (codegen) | `Scopes.*.*` (.NET) |
|
|
19
|
+
| `ALL_SCOPES` | `scopes.g.ts` | `Scopes.AllScopes` |
|
|
20
|
+
| `AuthErrorCodes` | `auth-error-codes.g.ts` (codegen) | `DcsvIo.D2.Auth.Errors.AuthErrorCodes` |
|
|
21
|
+
| `ALL_AUTH_ERROR_CODES` / `getAuthErrorHttpStatus(code)` | `auth-error-codes.g.ts` | `AuthErrorCodes.AllCodes` / `GetHttpStatus` |
|
|
22
|
+
| `AuthFailures.<factory>()` | `auth-failures.g.ts` (codegen) | `DcsvIo.D2.Auth.Errors.AuthFailures.*` |
|
|
23
|
+
| `JwtClaimTypes` | `jwt-claim-types.g.ts` (codegen) | `DcsvIo.D2.Auth.Abstractions.JwtClaimTypes` |
|
|
24
|
+
| `JwtPayload` | `jwt-payload.g.ts` (codegen) | TS-only typed view over the same spec |
|
|
25
|
+
|
|
26
|
+
## Codegen workflow
|
|
27
|
+
|
|
28
|
+
`prebuild` chains 4 emitter scripts (auth-scopes / auth-error-codes /
|
|
29
|
+
auth-failures / jwt-claims) before `tsc -b`, so `pnpm -r build` regenerates
|
|
30
|
+
transparently. Generated files (`*.g.ts`) are committed to git.
|
|
31
|
+
|
|
32
|
+
`JwtClaimTypes` AND `JwtPayload` both emit from
|
|
33
|
+
`contracts/jwt-claims/jwt-claims.spec.json` (one generator, two outputs; sources committed):
|
|
34
|
+
|
|
35
|
+
- `JwtClaimTypes` — string-constant catalog (every claim's wire name).
|
|
36
|
+
- `JwtPayload` — TS interface typed on every `standard` + `d2-custom`
|
|
37
|
+
claim with stable per-field types; `inside-act` claims live nested
|
|
38
|
+
inside `act` and are not surfaced as top-level fields. A trailing
|
|
39
|
+
`raw: Readonly<Record<string, unknown>>` escape hatch carries the
|
|
40
|
+
raw decoded claims for downstream consumers needing access to
|
|
41
|
+
non-spec'd claims.
|
|
42
|
+
|
|
43
|
+
The .NET side consumes the same spec for `JwtClaimTypes` constants;
|
|
44
|
+
.NET reads claim values via `ClaimsPrincipal` so a typed payload is not
|
|
45
|
+
needed there. Cross-language drift on the constant catalog is
|
|
46
|
+
structurally impossible (single source).
|
|
47
|
+
|
|
48
|
+
## Header constants
|
|
49
|
+
|
|
50
|
+
> Wire-protocol header catalogs live in the per-transport packages — see [`../../README.md` § Packages](../../README.md#packages) for the full per-transport catalog enumeration.
|
|
51
|
+
|
|
52
|
+
## Dependencies
|
|
53
|
+
|
|
54
|
+
- `@dcsv-io/d2-result` — `D2Result` shape returned by `AuthFailures.*` factories.
|
|
55
|
+
|
|
56
|
+
## Usage example
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import {
|
|
60
|
+
Scopes,
|
|
61
|
+
AuthFailures,
|
|
62
|
+
AuthErrorCodes,
|
|
63
|
+
JwtClaimTypes,
|
|
64
|
+
} from "@dcsv-io/d2-auth-abstractions";
|
|
65
|
+
import { HttpHeaders } from "@dcsv-io/d2-headers-http";
|
|
66
|
+
|
|
67
|
+
// Scope check.
|
|
68
|
+
if (!ctx.scopes.has(Scopes.auth.user.impersonate.consent)) {
|
|
69
|
+
return AuthFailures.scopeInsufficient(ctx.traceId);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Header read.
|
|
73
|
+
const idempotency = req.headers[HttpHeaders.IDEMPOTENCY_KEY];
|
|
74
|
+
|
|
75
|
+
// Claim read.
|
|
76
|
+
const sub = jwtPayload[JwtClaimTypes.SUB];
|
|
77
|
+
|
|
78
|
+
// Error-code discrimination.
|
|
79
|
+
if (result.errorCode === AuthErrorCodes.AUTH_JWT_EXPIRED) {
|
|
80
|
+
// refresh the token and retry
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Parity with .NET
|
|
85
|
+
|
|
86
|
+
Mirrors `DcsvIo.D2.Auth.Abstractions` + `DcsvIo.D2.Auth.Errors`:
|
|
87
|
+
|
|
88
|
+
- `Scopes` tree — same dot-segmented spec names emitted as nested
|
|
89
|
+
constants (e.g. `Scopes.auth.user.impersonate.consent`).
|
|
90
|
+
- `AuthErrorCodes` — same string values (every constant is its own name).
|
|
91
|
+
- `AuthFailures` — every factory returns `D2Result.fail(...)` with
|
|
92
|
+
matching `errorCode` + `statusCode` + default `messageKey`.
|
|
93
|
+
- `JwtClaimTypes` — codegen-emitted from `contracts/jwt-claims/jwt-claims.spec.json`;
|
|
94
|
+
same constant names + values on both sides.
|
|
95
|
+
- `JwtPayload` — TS-only typed view emitted from the same spec; .NET reads
|
|
96
|
+
claims via `ClaimsPrincipal` rather than a typed shape.
|
|
97
|
+
|
|
98
|
+
## Edge cases
|
|
99
|
+
|
|
100
|
+
- `getAuthErrorHttpStatus` returns 500 for unknown codes — defensive
|
|
101
|
+
default, every shipped `AUTH_*` code IS in the table.
|
|
102
|
+
- `Scopes` may include `_self` keys at branch nodes when an entry is
|
|
103
|
+
both a leaf scope AND has children (rare; edge case for forward-compat).
|
|
104
|
+
- Generated files (`*.g.ts`) are committed to git.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine-readable error codes for auth runtime failures. Mirrors .NET
|
|
3
|
+
* DcsvIo.D2.Auth.Errors.AuthErrorCodes (same string values).
|
|
4
|
+
*/
|
|
5
|
+
export declare const AuthErrorCodes: {
|
|
6
|
+
readonly AUTH_BEARER_MALFORMED: "AUTH_BEARER_MALFORMED";
|
|
7
|
+
readonly AUTH_BEARER_MISSING: "AUTH_BEARER_MISSING";
|
|
8
|
+
readonly AUTH_JWKS_UNAVAILABLE: "AUTH_JWKS_UNAVAILABLE";
|
|
9
|
+
readonly AUTH_JWT_ACT_CHAIN_MALFORMED: "AUTH_JWT_ACT_CHAIN_MALFORMED";
|
|
10
|
+
readonly AUTH_JWT_AUDIENCE_MISMATCH: "AUTH_JWT_AUDIENCE_MISMATCH";
|
|
11
|
+
readonly AUTH_JWT_CLAIM_MISSING: "AUTH_JWT_CLAIM_MISSING";
|
|
12
|
+
readonly AUTH_JWT_EXPIRED: "AUTH_JWT_EXPIRED";
|
|
13
|
+
readonly AUTH_JWT_ISSUER_MISMATCH: "AUTH_JWT_ISSUER_MISMATCH";
|
|
14
|
+
readonly AUTH_JWT_KID_NOT_FOUND: "AUTH_JWT_KID_NOT_FOUND";
|
|
15
|
+
readonly AUTH_JWT_NOT_YET_VALID: "AUTH_JWT_NOT_YET_VALID";
|
|
16
|
+
readonly AUTH_JWT_SIGNATURE_INVALID: "AUTH_JWT_SIGNATURE_INVALID";
|
|
17
|
+
readonly AUTH_REQUEST_ORIGIN_UNESTABLISHED: "AUTH_REQUEST_ORIGIN_UNESTABLISHED";
|
|
18
|
+
readonly AUTH_SCOPE_INSUFFICIENT: "AUTH_SCOPE_INSUFFICIENT";
|
|
19
|
+
readonly AUTH_SESSION_LIVENESS_UNAVAILABLE: "AUTH_SESSION_LIVENESS_UNAVAILABLE";
|
|
20
|
+
readonly AUTH_SESSION_REVOKED: "AUTH_SESSION_REVOKED";
|
|
21
|
+
};
|
|
22
|
+
export type AuthErrorCode = (typeof AuthErrorCodes)[keyof typeof AuthErrorCodes];
|
|
23
|
+
export declare const ALL_AUTH_ERROR_CODES: readonly string[];
|
|
24
|
+
/**
|
|
25
|
+
* HTTP status declared in the spec for an AUTH_* code.
|
|
26
|
+
* Returns 500 for unknown codes (defensive default).
|
|
27
|
+
*/
|
|
28
|
+
export declare function getAuthErrorHttpStatus(code: string): number;
|
|
29
|
+
//# sourceMappingURL=auth-error-codes.g.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-error-codes.g.d.ts","sourceRoot":"","sources":["../src/auth-error-codes.g.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;CAgBjB,CAAC;AAEX,MAAM,MAAM,aAAa,GACvB,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEvD,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAgBjD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmB3D"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// -----------------------------------------------------------------------
|
|
2
|
+
// <auto-generated>
|
|
3
|
+
// Generated by the D2 TypeScript catalog codegen — see emitter tests for coverage.
|
|
4
|
+
// Source spec: contracts/auth-error-codes/auth-error-codes.spec.json
|
|
5
|
+
// Manual edits will be lost on rebuild.
|
|
6
|
+
// </auto-generated>
|
|
7
|
+
// -----------------------------------------------------------------------
|
|
8
|
+
/* eslint-disable */
|
|
9
|
+
/**
|
|
10
|
+
* Machine-readable error codes for auth runtime failures. Mirrors .NET
|
|
11
|
+
* DcsvIo.D2.Auth.Errors.AuthErrorCodes (same string values).
|
|
12
|
+
*/
|
|
13
|
+
export const AuthErrorCodes = {
|
|
14
|
+
AUTH_BEARER_MALFORMED: "AUTH_BEARER_MALFORMED",
|
|
15
|
+
AUTH_BEARER_MISSING: "AUTH_BEARER_MISSING",
|
|
16
|
+
AUTH_JWKS_UNAVAILABLE: "AUTH_JWKS_UNAVAILABLE",
|
|
17
|
+
AUTH_JWT_ACT_CHAIN_MALFORMED: "AUTH_JWT_ACT_CHAIN_MALFORMED",
|
|
18
|
+
AUTH_JWT_AUDIENCE_MISMATCH: "AUTH_JWT_AUDIENCE_MISMATCH",
|
|
19
|
+
AUTH_JWT_CLAIM_MISSING: "AUTH_JWT_CLAIM_MISSING",
|
|
20
|
+
AUTH_JWT_EXPIRED: "AUTH_JWT_EXPIRED",
|
|
21
|
+
AUTH_JWT_ISSUER_MISMATCH: "AUTH_JWT_ISSUER_MISMATCH",
|
|
22
|
+
AUTH_JWT_KID_NOT_FOUND: "AUTH_JWT_KID_NOT_FOUND",
|
|
23
|
+
AUTH_JWT_NOT_YET_VALID: "AUTH_JWT_NOT_YET_VALID",
|
|
24
|
+
AUTH_JWT_SIGNATURE_INVALID: "AUTH_JWT_SIGNATURE_INVALID",
|
|
25
|
+
AUTH_REQUEST_ORIGIN_UNESTABLISHED: "AUTH_REQUEST_ORIGIN_UNESTABLISHED",
|
|
26
|
+
AUTH_SCOPE_INSUFFICIENT: "AUTH_SCOPE_INSUFFICIENT",
|
|
27
|
+
AUTH_SESSION_LIVENESS_UNAVAILABLE: "AUTH_SESSION_LIVENESS_UNAVAILABLE",
|
|
28
|
+
AUTH_SESSION_REVOKED: "AUTH_SESSION_REVOKED",
|
|
29
|
+
};
|
|
30
|
+
export const ALL_AUTH_ERROR_CODES = [
|
|
31
|
+
"AUTH_BEARER_MALFORMED",
|
|
32
|
+
"AUTH_BEARER_MISSING",
|
|
33
|
+
"AUTH_JWKS_UNAVAILABLE",
|
|
34
|
+
"AUTH_JWT_ACT_CHAIN_MALFORMED",
|
|
35
|
+
"AUTH_JWT_AUDIENCE_MISMATCH",
|
|
36
|
+
"AUTH_JWT_CLAIM_MISSING",
|
|
37
|
+
"AUTH_JWT_EXPIRED",
|
|
38
|
+
"AUTH_JWT_ISSUER_MISMATCH",
|
|
39
|
+
"AUTH_JWT_KID_NOT_FOUND",
|
|
40
|
+
"AUTH_JWT_NOT_YET_VALID",
|
|
41
|
+
"AUTH_JWT_SIGNATURE_INVALID",
|
|
42
|
+
"AUTH_REQUEST_ORIGIN_UNESTABLISHED",
|
|
43
|
+
"AUTH_SCOPE_INSUFFICIENT",
|
|
44
|
+
"AUTH_SESSION_LIVENESS_UNAVAILABLE",
|
|
45
|
+
"AUTH_SESSION_REVOKED",
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* HTTP status declared in the spec for an AUTH_* code.
|
|
49
|
+
* Returns 500 for unknown codes (defensive default).
|
|
50
|
+
*/
|
|
51
|
+
export function getAuthErrorHttpStatus(code) {
|
|
52
|
+
switch (code) {
|
|
53
|
+
case "AUTH_BEARER_MALFORMED": return 401;
|
|
54
|
+
case "AUTH_BEARER_MISSING": return 401;
|
|
55
|
+
case "AUTH_JWKS_UNAVAILABLE": return 503;
|
|
56
|
+
case "AUTH_JWT_ACT_CHAIN_MALFORMED": return 401;
|
|
57
|
+
case "AUTH_JWT_AUDIENCE_MISMATCH": return 401;
|
|
58
|
+
case "AUTH_JWT_CLAIM_MISSING": return 401;
|
|
59
|
+
case "AUTH_JWT_EXPIRED": return 401;
|
|
60
|
+
case "AUTH_JWT_ISSUER_MISMATCH": return 401;
|
|
61
|
+
case "AUTH_JWT_KID_NOT_FOUND": return 401;
|
|
62
|
+
case "AUTH_JWT_NOT_YET_VALID": return 401;
|
|
63
|
+
case "AUTH_JWT_SIGNATURE_INVALID": return 401;
|
|
64
|
+
case "AUTH_REQUEST_ORIGIN_UNESTABLISHED": return 401;
|
|
65
|
+
case "AUTH_SCOPE_INSUFFICIENT": return 401;
|
|
66
|
+
case "AUTH_SESSION_LIVENESS_UNAVAILABLE": return 503;
|
|
67
|
+
case "AUTH_SESSION_REVOKED": return 401;
|
|
68
|
+
default: return 500;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=auth-error-codes.g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-error-codes.g.js","sourceRoot":"","sources":["../src/auth-error-codes.g.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mBAAmB;AACnB,qFAAqF;AACrF,uEAAuE;AACvE,0CAA0C;AAC1C,oBAAoB;AACpB,0EAA0E;AAE1E,oBAAoB;AAEpB;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,qBAAqB,EAAE,uBA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,CAAC;QAC1C,KAAK,wBAAwB,CAAC,CAAC,OAAO,GAAG,CAAC;QAC1C,KAAK,4BAA4B,CAAC,CAAC,OAAO,GAAG,CAAC;QAC9C,KAAK,mCAAmC,CAAC,CAAC,OAAO,GAAG,CAAC;QACrD,KAAK,yBAAyB,CAAC,CAAC,OAAO,GAAG,CAAC;QAC3C,KAAK,mCAAmC,CAAC,CAAC,OAAO,GAAG,CAAC;QACrD,KAAK,sBAAsB,CAAC,CAAC,OAAO,GAAG,CAAC;QACxC,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { D2Result } from "@dcsv-io/d2-result";
|
|
2
|
+
import { type TKMessage } from "@dcsv-io/d2-i18n-abstractions";
|
|
3
|
+
/**
|
|
4
|
+
* Pre-built D2Result failures for inbound auth runtime — JWT validation
|
|
5
|
+
* rejections, session liveness outages, JWKS upstream failures.
|
|
6
|
+
* Mirrors .NET DcsvIo.D2.Auth.Errors.AuthFailures factory shape.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AuthFailures: {
|
|
9
|
+
/** The Authorization header was present but not a parseable Bearer JWT. */
|
|
10
|
+
readonly bearerMalformed: <T = void>(opts?: {
|
|
11
|
+
messages?: readonly TKMessage[];
|
|
12
|
+
traceId?: string;
|
|
13
|
+
}) => D2Result<T>;
|
|
14
|
+
/** The Authorization header was missing on a protected endpoint. */
|
|
15
|
+
readonly bearerMissing: <T = void>(opts?: {
|
|
16
|
+
messages?: readonly TKMessage[];
|
|
17
|
+
traceId?: string;
|
|
18
|
+
}) => D2Result<T>;
|
|
19
|
+
/** JWKS upstream is unavailable; no cached snapshot to fall back on. */
|
|
20
|
+
readonly jwksUnavailable: <T = void>(opts?: {
|
|
21
|
+
messages?: readonly TKMessage[];
|
|
22
|
+
traceId?: string;
|
|
23
|
+
}) => D2Result<T>;
|
|
24
|
+
/** JWT act chain is malformed (RFC 8693 section 2.1 violation). */
|
|
25
|
+
readonly jwtActChainMalformed: <T = void>(opts?: {
|
|
26
|
+
messages?: readonly TKMessage[];
|
|
27
|
+
traceId?: string;
|
|
28
|
+
}) => D2Result<T>;
|
|
29
|
+
/** JWT aud claim does not match this service's configured audience. */
|
|
30
|
+
readonly jwtAudienceMismatch: <T = void>(opts?: {
|
|
31
|
+
messages?: readonly TKMessage[];
|
|
32
|
+
traceId?: string;
|
|
33
|
+
}) => D2Result<T>;
|
|
34
|
+
/** JWT is missing a required claim that this service depends on. */
|
|
35
|
+
readonly jwtClaimMissing: <T = void>(opts?: {
|
|
36
|
+
messages?: readonly TKMessage[];
|
|
37
|
+
traceId?: string;
|
|
38
|
+
}) => D2Result<T>;
|
|
39
|
+
/** JWT is expired (exp in the past, beyond clock skew). */
|
|
40
|
+
readonly jwtExpired: <T = void>(opts?: {
|
|
41
|
+
messages?: readonly TKMessage[];
|
|
42
|
+
traceId?: string;
|
|
43
|
+
}) => D2Result<T>;
|
|
44
|
+
/** JWT iss claim does not match the configured issuer. */
|
|
45
|
+
readonly jwtIssuerMismatch: <T = void>(opts?: {
|
|
46
|
+
messages?: readonly TKMessage[];
|
|
47
|
+
traceId?: string;
|
|
48
|
+
}) => D2Result<T>;
|
|
49
|
+
/** JWT signed by an unknown kid; reactive JWKS refresh did not surface it. */
|
|
50
|
+
readonly jwtKidNotFound: <T = void>(opts?: {
|
|
51
|
+
messages?: readonly TKMessage[];
|
|
52
|
+
traceId?: string;
|
|
53
|
+
}) => D2Result<T>;
|
|
54
|
+
/** JWT not yet valid (nbf in the future, beyond clock skew). */
|
|
55
|
+
readonly jwtNotYetValid: <T = void>(opts?: {
|
|
56
|
+
messages?: readonly TKMessage[];
|
|
57
|
+
traceId?: string;
|
|
58
|
+
}) => D2Result<T>;
|
|
59
|
+
/** JWT signature verification failed against the JWKS. */
|
|
60
|
+
readonly jwtSignatureInvalid: <T = void>(opts?: {
|
|
61
|
+
messages?: readonly TKMessage[];
|
|
62
|
+
traceId?: string;
|
|
63
|
+
}) => D2Result<T>;
|
|
64
|
+
/** gRPC product call reached a host with RequestOrigin still Unestablished after the cross-process establishment interceptor (no validated mTLS peer identity). Platform fail-closed deny — not a per-handler check. Surfaces as 401 (not 403) so the auth boundary keeps a uniform shape with other policy-denied auth failures. */
|
|
65
|
+
readonly requestOriginUnestablished: <T = void>(opts?: {
|
|
66
|
+
messages?: readonly TKMessage[];
|
|
67
|
+
traceId?: string;
|
|
68
|
+
}) => D2Result<T>;
|
|
69
|
+
/** Caller is authenticated but the per-endpoint scope requirement is not satisfied. Surfaces as 401 (not 403) - the auth boundary keeps a uniform shape regardless of whether the JWT was bad or scopes were insufficient, so attackers cannot deduce which check failed. */
|
|
70
|
+
readonly scopeInsufficient: <T = void>(opts?: {
|
|
71
|
+
messages?: readonly TKMessage[];
|
|
72
|
+
traceId?: string;
|
|
73
|
+
}) => D2Result<T>;
|
|
74
|
+
/** Session liveness store unreachable. Caller fails closed: receives a 503-equivalent and may retry; the attempt is NOT treated as authenticated. Treating an unknown liveness state as alive would let revoked sessions ride through outages. */
|
|
75
|
+
readonly sessionLivenessUnavailable: <T = void>(opts?: {
|
|
76
|
+
messages?: readonly TKMessage[];
|
|
77
|
+
traceId?: string;
|
|
78
|
+
}) => D2Result<T>;
|
|
79
|
+
/** The bearer's d2_session_id is no longer alive (revoked). */
|
|
80
|
+
readonly sessionRevoked: <T = void>(opts?: {
|
|
81
|
+
messages?: readonly TKMessage[];
|
|
82
|
+
traceId?: string;
|
|
83
|
+
}) => D2Result<T>;
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=auth-failures.g.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-failures.g.d.ts","sourceRoot":"","sources":["../src/auth-failures.g.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAoC,MAAM,oBAAoB,CAAC;AAEhF,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI/D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
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// -----------------------------------------------------------------------
|
|
2
|
+
// <auto-generated>
|
|
3
|
+
// Generated by the D2 TypeScript catalog codegen — see emitter tests for coverage.
|
|
4
|
+
// Source spec: contracts/auth-error-codes/auth-error-codes.spec.json
|
|
5
|
+
// Manual edits will be lost on rebuild.
|
|
6
|
+
// </auto-generated>
|
|
7
|
+
// -----------------------------------------------------------------------
|
|
8
|
+
/* eslint-disable */
|
|
9
|
+
import { D2Result, serviceUnavailable, unauthorized } from "@dcsv-io/d2-result";
|
|
10
|
+
import { ErrorCategoryWire } from "@dcsv-io/d2-error-category";
|
|
11
|
+
import {} from "@dcsv-io/d2-i18n-abstractions";
|
|
12
|
+
import { TK } from "@dcsv-io/d2-i18n-keys";
|
|
13
|
+
import { AuthErrorCodes } from "./auth-error-codes.g.js";
|
|
14
|
+
/**
|
|
15
|
+
* Pre-built D2Result failures for inbound auth runtime — JWT validation
|
|
16
|
+
* rejections, session liveness outages, JWKS upstream failures.
|
|
17
|
+
* Mirrors .NET DcsvIo.D2.Auth.Errors.AuthFailures factory shape.
|
|
18
|
+
*/
|
|
19
|
+
export const AuthFailures = {
|
|
20
|
+
/** The Authorization header was present but not a parseable Bearer JWT. */
|
|
21
|
+
bearerMalformed(opts = {}) {
|
|
22
|
+
return unauthorized({
|
|
23
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
24
|
+
errorCode: AuthErrorCodes.AUTH_BEARER_MALFORMED,
|
|
25
|
+
category: ErrorCategoryWire.ValidationFailure,
|
|
26
|
+
traceId: opts.traceId,
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
/** The Authorization header was missing on a protected endpoint. */
|
|
30
|
+
bearerMissing(opts = {}) {
|
|
31
|
+
return unauthorized({
|
|
32
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
33
|
+
errorCode: AuthErrorCodes.AUTH_BEARER_MISSING,
|
|
34
|
+
category: ErrorCategoryWire.ValidationFailure,
|
|
35
|
+
traceId: opts.traceId,
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
/** JWKS upstream is unavailable; no cached snapshot to fall back on. */
|
|
39
|
+
jwksUnavailable(opts = {}) {
|
|
40
|
+
return serviceUnavailable({
|
|
41
|
+
messages: opts.messages ?? [TK.auth.errors.TEMPORARILY_UNAVAILABLE],
|
|
42
|
+
errorCode: AuthErrorCodes.AUTH_JWKS_UNAVAILABLE,
|
|
43
|
+
category: ErrorCategoryWire.InfrastructureUnavailable,
|
|
44
|
+
traceId: opts.traceId,
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
/** JWT act chain is malformed (RFC 8693 section 2.1 violation). */
|
|
48
|
+
jwtActChainMalformed(opts = {}) {
|
|
49
|
+
return unauthorized({
|
|
50
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
51
|
+
errorCode: AuthErrorCodes.AUTH_JWT_ACT_CHAIN_MALFORMED,
|
|
52
|
+
category: ErrorCategoryWire.ValidationFailure,
|
|
53
|
+
traceId: opts.traceId,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
/** JWT aud claim does not match this service's configured audience. */
|
|
57
|
+
jwtAudienceMismatch(opts = {}) {
|
|
58
|
+
return unauthorized({
|
|
59
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
60
|
+
errorCode: AuthErrorCodes.AUTH_JWT_AUDIENCE_MISMATCH,
|
|
61
|
+
category: ErrorCategoryWire.ValidationFailure,
|
|
62
|
+
traceId: opts.traceId,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
/** JWT is missing a required claim that this service depends on. */
|
|
66
|
+
jwtClaimMissing(opts = {}) {
|
|
67
|
+
return unauthorized({
|
|
68
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
69
|
+
errorCode: AuthErrorCodes.AUTH_JWT_CLAIM_MISSING,
|
|
70
|
+
category: ErrorCategoryWire.ValidationFailure,
|
|
71
|
+
traceId: opts.traceId,
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
/** JWT is expired (exp in the past, beyond clock skew). */
|
|
75
|
+
jwtExpired(opts = {}) {
|
|
76
|
+
return unauthorized({
|
|
77
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
78
|
+
errorCode: AuthErrorCodes.AUTH_JWT_EXPIRED,
|
|
79
|
+
category: ErrorCategoryWire.ValidationFailure,
|
|
80
|
+
traceId: opts.traceId,
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
/** JWT iss claim does not match the configured issuer. */
|
|
84
|
+
jwtIssuerMismatch(opts = {}) {
|
|
85
|
+
return unauthorized({
|
|
86
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
87
|
+
errorCode: AuthErrorCodes.AUTH_JWT_ISSUER_MISMATCH,
|
|
88
|
+
category: ErrorCategoryWire.ValidationFailure,
|
|
89
|
+
traceId: opts.traceId,
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
/** JWT signed by an unknown kid; reactive JWKS refresh did not surface it. */
|
|
93
|
+
jwtKidNotFound(opts = {}) {
|
|
94
|
+
return unauthorized({
|
|
95
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
96
|
+
errorCode: AuthErrorCodes.AUTH_JWT_KID_NOT_FOUND,
|
|
97
|
+
category: ErrorCategoryWire.ValidationFailure,
|
|
98
|
+
traceId: opts.traceId,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
/** JWT not yet valid (nbf in the future, beyond clock skew). */
|
|
102
|
+
jwtNotYetValid(opts = {}) {
|
|
103
|
+
return unauthorized({
|
|
104
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
105
|
+
errorCode: AuthErrorCodes.AUTH_JWT_NOT_YET_VALID,
|
|
106
|
+
category: ErrorCategoryWire.ValidationFailure,
|
|
107
|
+
traceId: opts.traceId,
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
/** JWT signature verification failed against the JWKS. */
|
|
111
|
+
jwtSignatureInvalid(opts = {}) {
|
|
112
|
+
return unauthorized({
|
|
113
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
114
|
+
errorCode: AuthErrorCodes.AUTH_JWT_SIGNATURE_INVALID,
|
|
115
|
+
category: ErrorCategoryWire.ValidationFailure,
|
|
116
|
+
traceId: opts.traceId,
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
/** gRPC product call reached a host with RequestOrigin still Unestablished after the cross-process establishment interceptor (no validated mTLS peer identity). Platform fail-closed deny — not a per-handler check. Surfaces as 401 (not 403) so the auth boundary keeps a uniform shape with other policy-denied auth failures. */
|
|
120
|
+
requestOriginUnestablished(opts = {}) {
|
|
121
|
+
return unauthorized({
|
|
122
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
123
|
+
errorCode: AuthErrorCodes.AUTH_REQUEST_ORIGIN_UNESTABLISHED,
|
|
124
|
+
category: ErrorCategoryWire.PolicyDenied,
|
|
125
|
+
traceId: opts.traceId,
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
/** Caller is authenticated but the per-endpoint scope requirement is not satisfied. Surfaces as 401 (not 403) - the auth boundary keeps a uniform shape regardless of whether the JWT was bad or scopes were insufficient, so attackers cannot deduce which check failed. */
|
|
129
|
+
scopeInsufficient(opts = {}) {
|
|
130
|
+
return unauthorized({
|
|
131
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
132
|
+
errorCode: AuthErrorCodes.AUTH_SCOPE_INSUFFICIENT,
|
|
133
|
+
category: ErrorCategoryWire.PolicyDenied,
|
|
134
|
+
traceId: opts.traceId,
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
/** Session liveness store unreachable. Caller fails closed: receives a 503-equivalent and may retry; the attempt is NOT treated as authenticated. Treating an unknown liveness state as alive would let revoked sessions ride through outages. */
|
|
138
|
+
sessionLivenessUnavailable(opts = {}) {
|
|
139
|
+
return serviceUnavailable({
|
|
140
|
+
messages: opts.messages ?? [TK.auth.errors.TEMPORARILY_UNAVAILABLE],
|
|
141
|
+
errorCode: AuthErrorCodes.AUTH_SESSION_LIVENESS_UNAVAILABLE,
|
|
142
|
+
category: ErrorCategoryWire.InfrastructureUnavailable,
|
|
143
|
+
traceId: opts.traceId,
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
/** The bearer's d2_session_id is no longer alive (revoked). */
|
|
147
|
+
sessionRevoked(opts = {}) {
|
|
148
|
+
return unauthorized({
|
|
149
|
+
messages: opts.messages ?? [TK.auth.errors.UNAUTHORIZED],
|
|
150
|
+
errorCode: AuthErrorCodes.AUTH_SESSION_REVOKED,
|
|
151
|
+
category: ErrorCategoryWire.PolicyDenied,
|
|
152
|
+
traceId: opts.traceId,
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=auth-failures.g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-failures.g.js","sourceRoot":"","sources":["../src/auth-failures.g.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mBAAmB;AACnB,qFAAqF;AACrF,uEAAuE;AACvE,0CAA0C;AAC1C,oBAAoB;AACpB,0EAA0E;AAE1E,oBAAoB;AAEpB,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAkB,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,2EAA2E;IAC3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BAAiB,CAAC,YAAY;YACxC,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC;IACD,6QAA6Q;IAC7Q,iBAAiB,CAAW,OAA8D,EAAE;QAC1F,OAAO,YAAY,CAAI;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;YACxD,SAAS,EAAE,cAAc,CAAC,uBAAuB;YACjD,QAAQ,EAAE,iBAAiB,CAAC,YAAY;YACxC,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC;IACD,kPAAkP;IAClP,0BAA0B,CAAW,OAA8D,EAAE;QACnG,OAAO,kBAAkB,CAAI;YAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC;YACnE,SAAS,EAAE,cAAc,CAAC,iCAAiC;YAC3D,QAAQ,EAAE,iBAAiB,CAAC,yBAAyB;YACrD,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC;IACD,+DAA+D;IAC/D,cAAc,CAAW,OAA8D,EAAE;QACvF,OAAO,YAAY,CAAI;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;YACxD,SAAS,EAAE,cAAc,CAAC,oBAAoB;YAC9C,QAAQ,EAAE,iBAAiB,CAAC,YAAY;YACxC,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAC;IACL,CAAC;CACO,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AuthErrorCodes, type AuthErrorCode, ALL_AUTH_ERROR_CODES, getAuthErrorHttpStatus, } from "./auth-error-codes.g.js";
|
|
2
|
+
export { AuthFailures } from "./auth-failures.g.js";
|
|
3
|
+
export { Scopes, ALL_SCOPES } from "./scopes.g.js";
|
|
4
|
+
export { ProtocolAudiences, type ProtocolAudience, ALL_PROTOCOL_AUDIENCES, } from "./protocol-audiences.g.js";
|
|
5
|
+
export { JwtClaimTypes, type JwtClaimType } from "./jwt-claim-types.g.js";
|
|
6
|
+
export type { JwtPayload } from "./jwt-payload.g.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAClB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC1E,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// -----------------------------------------------------------------------
|
|
2
|
+
// Copyright (c) DCSV. Licensed under the Apache License, Version 2.0.
|
|
3
|
+
// -----------------------------------------------------------------------
|
|
4
|
+
export { AuthErrorCodes, ALL_AUTH_ERROR_CODES, getAuthErrorHttpStatus, } from "./auth-error-codes.g.js";
|
|
5
|
+
export { AuthFailures } from "./auth-failures.g.js";
|
|
6
|
+
export { Scopes, ALL_SCOPES } from "./scopes.g.js";
|
|
7
|
+
export { ProtocolAudiences, ALL_PROTOCOL_AUDIENCES, } from "./protocol-audiences.g.js";
|
|
8
|
+
export { JwtClaimTypes } from "./jwt-claim-types.g.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,sEAAsE;AACtE,0EAA0E;AAE1E,OAAO,EACL,cAAc,EAEd,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,iBAAiB,EAEjB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,aAAa,EAAqB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JWT claim name string constants used across the platform. Mirrors
|
|
3
|
+
* .NET DcsvIo.D2.Auth.Abstractions.JwtClaimTypes (same string values).
|
|
4
|
+
*
|
|
5
|
+
* Standard OAuth/OIDC claims keep their canonical names (sub, aud,
|
|
6
|
+
* scope, ...); D2-specific claims use the d2_ prefix; inside-act claims
|
|
7
|
+
* are nested under the act object per RFC 8693 §2.1 (lookup path
|
|
8
|
+
* act[ACT_KIND]).
|
|
9
|
+
*/
|
|
10
|
+
export declare const JwtClaimTypes: {
|
|
11
|
+
/**
|
|
12
|
+
* Subject — the user's identifier (Guid string for user tokens) or service client_id for pure service-identity tokens (RFC 6749 §4.4).
|
|
13
|
+
* Kind: standard.
|
|
14
|
+
*/
|
|
15
|
+
readonly SUB: "sub";
|
|
16
|
+
/**
|
|
17
|
+
* Audience — the intended recipient service identifier(s). Per RFC 7519 §4.1.3 may be a single string OR a JSON array; both wire shapes accepted.
|
|
18
|
+
* Kind: standard.
|
|
19
|
+
*/
|
|
20
|
+
readonly AUD: "aud";
|
|
21
|
+
/**
|
|
22
|
+
* Issued-at — Unix timestamp seconds when the token was minted.
|
|
23
|
+
* Kind: standard.
|
|
24
|
+
*/
|
|
25
|
+
readonly IAT: "iat";
|
|
26
|
+
/**
|
|
27
|
+
* Expiry — Unix timestamp seconds after which the token is invalid.
|
|
28
|
+
* Kind: standard.
|
|
29
|
+
*/
|
|
30
|
+
readonly EXP: "exp";
|
|
31
|
+
/**
|
|
32
|
+
* Authorized party (RFC 7519 §4.1.7) — the OAuth client the token was issued for.
|
|
33
|
+
* Kind: standard.
|
|
34
|
+
*/
|
|
35
|
+
readonly AZP: "azp";
|
|
36
|
+
/**
|
|
37
|
+
* Space-separated string of granted permissions per RFC 6749 §3.3. Some authorization servers send this as a JSON array; the runtime parser accepts both shapes.
|
|
38
|
+
* Kind: standard.
|
|
39
|
+
*/
|
|
40
|
+
readonly SCOPE: "scope";
|
|
41
|
+
/**
|
|
42
|
+
* Actor chain — RFC 8693 §2.1 nested-object structure identifying the chain of services / impersonators that minted the token. Empty / absent when the token is an end-user-direct token.
|
|
43
|
+
* Kind: standard.
|
|
44
|
+
*/
|
|
45
|
+
readonly ACT: "act";
|
|
46
|
+
/**
|
|
47
|
+
* OAuth client identifier of the client that requested THIS specific token from the authorization server (RFC 8693 §4.3 / RFC 9068 §2.2). Updates on every token exchange — for a multi-hop chain, this is the immediate requesting client, not the originating one.
|
|
48
|
+
* Kind: standard.
|
|
49
|
+
*/
|
|
50
|
+
readonly CLIENT_ID: "client_id";
|
|
51
|
+
/**
|
|
52
|
+
* User session identifier — links the token to a session record in d2-auth.
|
|
53
|
+
* Kind: d2-custom.
|
|
54
|
+
*/
|
|
55
|
+
readonly SESSION_ID: "d2_session_id";
|
|
56
|
+
/**
|
|
57
|
+
* Login handle — unique, lowercase username.
|
|
58
|
+
* Kind: d2-custom.
|
|
59
|
+
*/
|
|
60
|
+
readonly USERNAME: "d2_username";
|
|
61
|
+
/**
|
|
62
|
+
* JWT fingerprint — SHA-256 of canonical request signal (User-Agent + Accept). Used for token-binding adversarial checks.
|
|
63
|
+
* Kind: d2-custom.
|
|
64
|
+
*/
|
|
65
|
+
readonly FINGERPRINT: "d2_fp";
|
|
66
|
+
/**
|
|
67
|
+
* Operating organization identifier. During impersonation: the impersonated user's org.
|
|
68
|
+
* Kind: d2-custom.
|
|
69
|
+
*/
|
|
70
|
+
readonly ORG_ID: "d2_org_id";
|
|
71
|
+
/**
|
|
72
|
+
* Operating organization display name.
|
|
73
|
+
* Kind: d2-custom.
|
|
74
|
+
*/
|
|
75
|
+
readonly ORG_NAME: "d2_org_name";
|
|
76
|
+
/**
|
|
77
|
+
* Operating organization type — string form of the OrgType enum.
|
|
78
|
+
* Kind: d2-custom.
|
|
79
|
+
*/
|
|
80
|
+
readonly ORG_TYPE: "d2_org_type";
|
|
81
|
+
/**
|
|
82
|
+
* User's role in the operating organization — string form of the Role enum.
|
|
83
|
+
* Kind: d2-custom.
|
|
84
|
+
*/
|
|
85
|
+
readonly ORG_ROLE: "d2_org_role";
|
|
86
|
+
/**
|
|
87
|
+
* Inside-act claim — flavor of impersonation when the actor's kind is impersonation. Values are lowercase strings matching ImpersonationKind (consent or force). Lookup path: act.d2_kind. There is NO top-level d2_kind claim; token kind is derived from the act chain's shape.
|
|
88
|
+
* Kind: inside-act.
|
|
89
|
+
*/
|
|
90
|
+
readonly ACT_KIND: "d2_kind";
|
|
91
|
+
/**
|
|
92
|
+
* Inside-act claim — impersonation session identifier when the actor's kind is impersonation. Lookup path: act.d2_session_id. Wire value collides with top-level d2_session_id but the lookup path is distinct (nested under act).
|
|
93
|
+
* Kind: inside-act.
|
|
94
|
+
*/
|
|
95
|
+
readonly ACT_SESSION_ID: "d2_session_id";
|
|
96
|
+
/**
|
|
97
|
+
* Authentication Methods Reference (RFC 8176). Array of strings identifying the authentication methods used. Input to risk-scoring and audit — 'password-only vs MFA vs OAuth2-with-WebAuthn' matters for sensitive-action gating.
|
|
98
|
+
* Kind: standard.
|
|
99
|
+
*/
|
|
100
|
+
readonly AMR: "amr";
|
|
101
|
+
/**
|
|
102
|
+
* Unix-seconds timestamp of last step-up authentication completion. Handlers gating sensitive actions enforce 'step-up within last N minutes'. Edge auth populates from session record at JWT mint.
|
|
103
|
+
* Kind: d2-custom.
|
|
104
|
+
*/
|
|
105
|
+
readonly STEP_UP_AT: "d2_step_up_at";
|
|
106
|
+
};
|
|
107
|
+
export type JwtClaimType = (typeof JwtClaimTypes)[keyof typeof JwtClaimTypes];
|
|
108
|
+
//# sourceMappingURL=jwt-claim-types.g.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-claim-types.g.d.ts","sourceRoot":"","sources":["../src/jwt-claim-types.g.ts"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa;IACxB;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;CAEK,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// -----------------------------------------------------------------------
|
|
2
|
+
// <auto-generated>
|
|
3
|
+
// Generated by the D2 TypeScript catalog codegen — see emitter tests for coverage.
|
|
4
|
+
// Source spec: contracts/jwt-claims/jwt-claims.spec.json
|
|
5
|
+
// Manual edits will be lost on rebuild.
|
|
6
|
+
// </auto-generated>
|
|
7
|
+
// -----------------------------------------------------------------------
|
|
8
|
+
/* eslint-disable */
|
|
9
|
+
/**
|
|
10
|
+
* JWT claim name string constants used across the platform. Mirrors
|
|
11
|
+
* .NET DcsvIo.D2.Auth.Abstractions.JwtClaimTypes (same string values).
|
|
12
|
+
*
|
|
13
|
+
* Standard OAuth/OIDC claims keep their canonical names (sub, aud,
|
|
14
|
+
* scope, ...); D2-specific claims use the d2_ prefix; inside-act claims
|
|
15
|
+
* are nested under the act object per RFC 8693 §2.1 (lookup path
|
|
16
|
+
* act[ACT_KIND]).
|
|
17
|
+
*/
|
|
18
|
+
export const JwtClaimTypes = {
|
|
19
|
+
/**
|
|
20
|
+
* Subject — the user's identifier (Guid string for user tokens) or service client_id for pure service-identity tokens (RFC 6749 §4.4).
|
|
21
|
+
* Kind: standard.
|
|
22
|
+
*/
|
|
23
|
+
SUB: "sub",
|
|
24
|
+
/**
|
|
25
|
+
* Audience — the intended recipient service identifier(s). Per RFC 7519 §4.1.3 may be a single string OR a JSON array; both wire shapes accepted.
|
|
26
|
+
* Kind: standard.
|
|
27
|
+
*/
|
|
28
|
+
AUD: "aud",
|
|
29
|
+
/**
|
|
30
|
+
* Issued-at — Unix timestamp seconds when the token was minted.
|
|
31
|
+
* Kind: standard.
|
|
32
|
+
*/
|
|
33
|
+
IAT: "iat",
|
|
34
|
+
/**
|
|
35
|
+
* Expiry — Unix timestamp seconds after which the token is invalid.
|
|
36
|
+
* Kind: standard.
|
|
37
|
+
*/
|
|
38
|
+
EXP: "exp",
|
|
39
|
+
/**
|
|
40
|
+
* Authorized party (RFC 7519 §4.1.7) — the OAuth client the token was issued for.
|
|
41
|
+
* Kind: standard.
|
|
42
|
+
*/
|
|
43
|
+
AZP: "azp",
|
|
44
|
+
/**
|
|
45
|
+
* Space-separated string of granted permissions per RFC 6749 §3.3. Some authorization servers send this as a JSON array; the runtime parser accepts both shapes.
|
|
46
|
+
* Kind: standard.
|
|
47
|
+
*/
|
|
48
|
+
SCOPE: "scope",
|
|
49
|
+
/**
|
|
50
|
+
* Actor chain — RFC 8693 §2.1 nested-object structure identifying the chain of services / impersonators that minted the token. Empty / absent when the token is an end-user-direct token.
|
|
51
|
+
* Kind: standard.
|
|
52
|
+
*/
|
|
53
|
+
ACT: "act",
|
|
54
|
+
/**
|
|
55
|
+
* OAuth client identifier of the client that requested THIS specific token from the authorization server (RFC 8693 §4.3 / RFC 9068 §2.2). Updates on every token exchange — for a multi-hop chain, this is the immediate requesting client, not the originating one.
|
|
56
|
+
* Kind: standard.
|
|
57
|
+
*/
|
|
58
|
+
CLIENT_ID: "client_id",
|
|
59
|
+
/**
|
|
60
|
+
* User session identifier — links the token to a session record in d2-auth.
|
|
61
|
+
* Kind: d2-custom.
|
|
62
|
+
*/
|
|
63
|
+
SESSION_ID: "d2_session_id",
|
|
64
|
+
/**
|
|
65
|
+
* Login handle — unique, lowercase username.
|
|
66
|
+
* Kind: d2-custom.
|
|
67
|
+
*/
|
|
68
|
+
USERNAME: "d2_username",
|
|
69
|
+
/**
|
|
70
|
+
* JWT fingerprint — SHA-256 of canonical request signal (User-Agent + Accept). Used for token-binding adversarial checks.
|
|
71
|
+
* Kind: d2-custom.
|
|
72
|
+
*/
|
|
73
|
+
FINGERPRINT: "d2_fp",
|
|
74
|
+
/**
|
|
75
|
+
* Operating organization identifier. During impersonation: the impersonated user's org.
|
|
76
|
+
* Kind: d2-custom.
|
|
77
|
+
*/
|
|
78
|
+
ORG_ID: "d2_org_id",
|
|
79
|
+
/**
|
|
80
|
+
* Operating organization display name.
|
|
81
|
+
* Kind: d2-custom.
|
|
82
|
+
*/
|
|
83
|
+
ORG_NAME: "d2_org_name",
|
|
84
|
+
/**
|
|
85
|
+
* Operating organization type — string form of the OrgType enum.
|
|
86
|
+
* Kind: d2-custom.
|
|
87
|
+
*/
|
|
88
|
+
ORG_TYPE: "d2_org_type",
|
|
89
|
+
/**
|
|
90
|
+
* User's role in the operating organization — string form of the Role enum.
|
|
91
|
+
* Kind: d2-custom.
|
|
92
|
+
*/
|
|
93
|
+
ORG_ROLE: "d2_org_role",
|
|
94
|
+
/**
|
|
95
|
+
* Inside-act claim — flavor of impersonation when the actor's kind is impersonation. Values are lowercase strings matching ImpersonationKind (consent or force). Lookup path: act.d2_kind. There is NO top-level d2_kind claim; token kind is derived from the act chain's shape.
|
|
96
|
+
* Kind: inside-act.
|
|
97
|
+
*/
|
|
98
|
+
ACT_KIND: "d2_kind",
|
|
99
|
+
/**
|
|
100
|
+
* Inside-act claim — impersonation session identifier when the actor's kind is impersonation. Lookup path: act.d2_session_id. Wire value collides with top-level d2_session_id but the lookup path is distinct (nested under act).
|
|
101
|
+
* Kind: inside-act.
|
|
102
|
+
*/
|
|
103
|
+
ACT_SESSION_ID: "d2_session_id",
|
|
104
|
+
/**
|
|
105
|
+
* Authentication Methods Reference (RFC 8176). Array of strings identifying the authentication methods used. Input to risk-scoring and audit — 'password-only vs MFA vs OAuth2-with-WebAuthn' matters for sensitive-action gating.
|
|
106
|
+
* Kind: standard.
|
|
107
|
+
*/
|
|
108
|
+
AMR: "amr",
|
|
109
|
+
/**
|
|
110
|
+
* Unix-seconds timestamp of last step-up authentication completion. Handlers gating sensitive actions enforce 'step-up within last N minutes'. Edge auth populates from session record at JWT mint.
|
|
111
|
+
* Kind: d2-custom.
|
|
112
|
+
*/
|
|
113
|
+
STEP_UP_AT: "d2_step_up_at",
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=jwt-claim-types.g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-claim-types.g.js","sourceRoot":"","sources":["../src/jwt-claim-types.g.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mBAAmB;AACnB,qFAAqF;AACrF,2DAA2D;AAC3D,0CAA0C;AAC1C,oBAAoB;AACpB,0EAA0E;AAE1E,oBAAoB;AAEpB;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B;;;OAGG;IACH,GAAG,EAAE,KAAK;IACV;;;OAGG;IACH,GAAG,EAAE,KAAK;IACV;;;OAGG;IACH,GAAG,EAAE,KAAK;IACV;;;OAGG;IACH,GAAG,EAAE,KAAK;IACV;;;OAGG;IACH,GAAG,EAAE,KAAK;IACV;;;OAGG;IACH,KAAK,EAAE,OAAO;IACd;;;OAGG;IACH,GAAG,EAAE,KAAK;IACV;;;OAGG;IACH,SAAS,EAAE,WAAW;IACtB;;;OAGG;IACH,UAAU,EAAE,eAAe;IAC3B;;;OAGG;IACH,QAAQ,EAAE,aAAa;IACvB;;;OAGG;IACH,WAAW,EAAE,OAAO;IACpB;;;OAGG;IACH,MAAM,EAAE,WAAW;IACnB;;;OAGG;IACH,QAAQ,EAAE,aAAa;IACvB;;;OAGG;IACH,QAAQ,EAAE,aAAa;IACvB;;;OAGG;IACH,QAAQ,EAAE,aAAa;IACvB;;;OAGG;IACH,QAAQ,EAAE,SAAS;IACnB;;;OAGG;IACH,cAAc,EAAE,eAAe;IAC/B;;;OAGG;IACH,GAAG,EAAE,KAAK;IACV;;;OAGG;IACH,UAAU,EAAE,eAAe;CACnB,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decoded JWT payload — typed on every spec-driven claim with a stable
|
|
3
|
+
* top-level wire name. Mirrors the spec's `kind in {standard, d2-custom}`
|
|
4
|
+
* subset; `inside-act` claims live nested inside `act` and are not
|
|
5
|
+
* surfaced as top-level fields. The trailing `raw` field carries the
|
|
6
|
+
* untyped claim object for downstream consumers that need access to
|
|
7
|
+
* non-spec'd claims.
|
|
8
|
+
*/
|
|
9
|
+
export interface JwtPayload {
|
|
10
|
+
/**
|
|
11
|
+
* Subject — the user's identifier (Guid string for user tokens) or service client_id for pure service-identity tokens (RFC 6749 §4.4).
|
|
12
|
+
* Claim wire name: sub (kind: standard).
|
|
13
|
+
*/
|
|
14
|
+
readonly sub?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Audience — the intended recipient service identifier(s). Per RFC 7519 §4.1.3 may be a single string OR a JSON array; both wire shapes accepted.
|
|
17
|
+
* Claim wire name: aud (kind: standard).
|
|
18
|
+
*/
|
|
19
|
+
readonly aud: readonly string[];
|
|
20
|
+
/**
|
|
21
|
+
* Issued-at — Unix timestamp seconds when the token was minted.
|
|
22
|
+
* Claim wire name: iat (kind: standard).
|
|
23
|
+
*/
|
|
24
|
+
readonly iat?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Expiry — Unix timestamp seconds after which the token is invalid.
|
|
27
|
+
* Claim wire name: exp (kind: standard).
|
|
28
|
+
*/
|
|
29
|
+
readonly exp?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Authorized party (RFC 7519 §4.1.7) — the OAuth client the token was issued for.
|
|
32
|
+
* Claim wire name: azp (kind: standard).
|
|
33
|
+
*/
|
|
34
|
+
readonly azp?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Space-separated string of granted permissions per RFC 6749 §3.3. Some authorization servers send this as a JSON array; the runtime parser accepts both shapes.
|
|
37
|
+
* Claim wire name: scope (kind: standard).
|
|
38
|
+
*/
|
|
39
|
+
readonly scope?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Actor chain — RFC 8693 §2.1 nested-object structure identifying the chain of services / impersonators that minted the token. Empty / absent when the token is an end-user-direct token.
|
|
42
|
+
* Claim wire name: act (kind: standard).
|
|
43
|
+
*/
|
|
44
|
+
readonly act?: Readonly<Record<string, unknown>>;
|
|
45
|
+
/**
|
|
46
|
+
* OAuth client identifier of the client that requested THIS specific token from the authorization server (RFC 8693 §4.3 / RFC 9068 §2.2). Updates on every token exchange — for a multi-hop chain, this is the immediate requesting client, not the originating one.
|
|
47
|
+
* Claim wire name: client_id (kind: standard).
|
|
48
|
+
*/
|
|
49
|
+
readonly client_id?: string;
|
|
50
|
+
/**
|
|
51
|
+
* User session identifier — links the token to a session record in d2-auth.
|
|
52
|
+
* Claim wire name: d2_session_id (kind: d2-custom).
|
|
53
|
+
*/
|
|
54
|
+
readonly d2_session_id?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Login handle — unique, lowercase username.
|
|
57
|
+
* Claim wire name: d2_username (kind: d2-custom).
|
|
58
|
+
*/
|
|
59
|
+
readonly d2_username?: string;
|
|
60
|
+
/**
|
|
61
|
+
* JWT fingerprint — SHA-256 of canonical request signal (User-Agent + Accept). Used for token-binding adversarial checks.
|
|
62
|
+
* Claim wire name: d2_fp (kind: d2-custom).
|
|
63
|
+
*/
|
|
64
|
+
readonly d2_fp?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Operating organization identifier. During impersonation: the impersonated user's org.
|
|
67
|
+
* Claim wire name: d2_org_id (kind: d2-custom).
|
|
68
|
+
*/
|
|
69
|
+
readonly d2_org_id?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Operating organization display name.
|
|
72
|
+
* Claim wire name: d2_org_name (kind: d2-custom).
|
|
73
|
+
*/
|
|
74
|
+
readonly d2_org_name?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Operating organization type — string form of the OrgType enum.
|
|
77
|
+
* Claim wire name: d2_org_type (kind: d2-custom).
|
|
78
|
+
*/
|
|
79
|
+
readonly d2_org_type?: string;
|
|
80
|
+
/**
|
|
81
|
+
* User's role in the operating organization — string form of the Role enum.
|
|
82
|
+
* Claim wire name: d2_org_role (kind: d2-custom).
|
|
83
|
+
*/
|
|
84
|
+
readonly d2_org_role?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Authentication Methods Reference (RFC 8176). Array of strings identifying the authentication methods used. Input to risk-scoring and audit — 'password-only vs MFA vs OAuth2-with-WebAuthn' matters for sensitive-action gating.
|
|
87
|
+
* Claim wire name: amr (kind: standard).
|
|
88
|
+
*/
|
|
89
|
+
readonly amr?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Unix-seconds timestamp of last step-up authentication completion. Handlers gating sensitive actions enforce 'step-up within last N minutes'. Edge auth populates from session record at JWT mint.
|
|
92
|
+
* Claim wire name: d2_step_up_at (kind: d2-custom).
|
|
93
|
+
*/
|
|
94
|
+
readonly d2_step_up_at?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Raw decoded claims object — escape hatch for downstream consumers
|
|
97
|
+
* that need access to non-spec'd claims.
|
|
98
|
+
*/
|
|
99
|
+
readonly raw: Readonly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C9B;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACjD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// -----------------------------------------------------------------------
|
|
2
|
+
// <auto-generated>
|
|
3
|
+
// Generated by the D2 TypeScript catalog codegen — see emitter tests for coverage.
|
|
4
|
+
// Source spec: contracts/jwt-claims/jwt-claims.spec.json
|
|
5
|
+
// Manual edits will be lost on rebuild.
|
|
6
|
+
// </auto-generated>
|
|
7
|
+
// -----------------------------------------------------------------------
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=jwt-payload.g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-payload.g.js","sourceRoot":"","sources":["../src/jwt-payload.g.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mBAAmB;AACnB,qFAAqF;AACrF,2DAA2D;AAC3D,0CAA0C;AAC1C,oBAAoB;AACpB,0EAA0E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protocol-audience constants emitted from
|
|
3
|
+
* contracts/auth-protocol-audiences/protocol-audiences.spec.json. These are the
|
|
4
|
+
* bare-token aud values (d2.internal, d2-edge) — NOT the URL-shaped
|
|
5
|
+
* token-exchange targets in @dcsv-io/d2-auth-abstractions' Audiences catalog. Mirrors
|
|
6
|
+
* the .NET DcsvIo.D2.Auth.Abstractions.WellKnownAudiences constants.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ProtocolAudiences: {
|
|
9
|
+
/** The Edge self-audience for the Edge's own operations — the aud the Edge accepts on tokens minted for itself. */
|
|
10
|
+
readonly D2_EDGE_SELF_AUDIENCE: "d2-edge";
|
|
11
|
+
/** The single universal internal receive audience. The Edge mints exactly one internal transaction-token with aud=this value, and every hop validates aud == this value. It is NOT a token-exchange target (those live in auth-audiences/audiences.spec.json) — it is the universal receive audience that makes forward-unchanged possible. */
|
|
12
|
+
readonly D2_INTERNAL_AUDIENCE: "d2.internal";
|
|
13
|
+
};
|
|
14
|
+
export type ProtocolAudience = (typeof ProtocolAudiences)[keyof typeof ProtocolAudiences];
|
|
15
|
+
/**
|
|
16
|
+
* All declared protocol-audience VALUES in spec-name-sorted order.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ALL_PROTOCOL_AUDIENCES: readonly string[];
|
|
19
|
+
//# sourceMappingURL=protocol-audiences.g.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-audiences.g.d.ts","sourceRoot":"","sources":["../src/protocol-audiences.g.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB;IAC5B,mHAAmH;;IAEnH,+UAA+U;;CAEvU,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE1F;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAGnD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// -----------------------------------------------------------------------
|
|
2
|
+
// <auto-generated>
|
|
3
|
+
// Generated by the D2 TypeScript catalog codegen — see emitter tests for coverage.
|
|
4
|
+
// Source spec: contracts/auth-protocol-audiences/protocol-audiences.spec.json
|
|
5
|
+
// Manual edits will be lost on rebuild.
|
|
6
|
+
// </auto-generated>
|
|
7
|
+
// -----------------------------------------------------------------------
|
|
8
|
+
/* eslint-disable */
|
|
9
|
+
/**
|
|
10
|
+
* Protocol-audience constants emitted from
|
|
11
|
+
* contracts/auth-protocol-audiences/protocol-audiences.spec.json. These are the
|
|
12
|
+
* bare-token aud values (d2.internal, d2-edge) — NOT the URL-shaped
|
|
13
|
+
* token-exchange targets in @dcsv-io/d2-auth-abstractions' Audiences catalog. Mirrors
|
|
14
|
+
* the .NET DcsvIo.D2.Auth.Abstractions.WellKnownAudiences constants.
|
|
15
|
+
*/
|
|
16
|
+
export const ProtocolAudiences = {
|
|
17
|
+
/** The Edge self-audience for the Edge's own operations — the aud the Edge accepts on tokens minted for itself. */
|
|
18
|
+
D2_EDGE_SELF_AUDIENCE: "d2-edge",
|
|
19
|
+
/** The single universal internal receive audience. The Edge mints exactly one internal transaction-token with aud=this value, and every hop validates aud == this value. It is NOT a token-exchange target (those live in auth-audiences/audiences.spec.json) — it is the universal receive audience that makes forward-unchanged possible. */
|
|
20
|
+
D2_INTERNAL_AUDIENCE: "d2.internal",
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* All declared protocol-audience VALUES in spec-name-sorted order.
|
|
24
|
+
*/
|
|
25
|
+
export const ALL_PROTOCOL_AUDIENCES = [
|
|
26
|
+
"d2-edge",
|
|
27
|
+
"d2.internal",
|
|
28
|
+
];
|
|
29
|
+
//# sourceMappingURL=protocol-audiences.g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol-audiences.g.js","sourceRoot":"","sources":["../src/protocol-audiences.g.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mBAAmB;AACnB,qFAAqF;AACrF,gFAAgF;AAChF,0CAA0C;AAC1C,oBAAoB;AACpB,0EAA0E;AAE1E,oBAAoB;AAEpB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,mHAAmH;IACnH,qBAAqB,EAAE,SAAS;IAChC,+UAA+U;IAC/U,oBAAoB,EAAE,aAAa;CAC3B,CAAC;AAIX;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB;IACvD,SAAS;IACT,aAAa;CACd,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth scope catalog emitted from contracts/auth-scopes/scopes.spec.json.
|
|
3
|
+
* Tree-emitted nested constants — `Scopes.auth.user.impersonate.consent` resolves
|
|
4
|
+
* to the dot-segmented spec name.
|
|
5
|
+
*/
|
|
6
|
+
export declare const Scopes: {
|
|
7
|
+
readonly anon: {
|
|
8
|
+
readonly public: {
|
|
9
|
+
readonly health: "anon.public.health";
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
readonly self: {
|
|
13
|
+
readonly read: "self.read";
|
|
14
|
+
readonly write: "self.write";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* All declared scopes in spec-sorted order.
|
|
19
|
+
*/
|
|
20
|
+
export declare const ALL_SCOPES: readonly string[];
|
|
21
|
+
//# sourceMappingURL=scopes.g.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopes.g.d.ts","sourceRoot":"","sources":["../src/scopes.g.ts"],"names":[],"mappings":"AAUA;;;;GAIG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;CAUT,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAIvC,CAAC"}
|
package/dist/scopes.g.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// -----------------------------------------------------------------------
|
|
2
|
+
// <auto-generated>
|
|
3
|
+
// Generated by the D2 TypeScript catalog codegen — see emitter tests for coverage.
|
|
4
|
+
// Source spec: contracts/auth-scopes/scopes.spec.json
|
|
5
|
+
// Manual edits will be lost on rebuild.
|
|
6
|
+
// </auto-generated>
|
|
7
|
+
// -----------------------------------------------------------------------
|
|
8
|
+
/* eslint-disable */
|
|
9
|
+
/**
|
|
10
|
+
* OAuth scope catalog emitted from contracts/auth-scopes/scopes.spec.json.
|
|
11
|
+
* Tree-emitted nested constants — `Scopes.auth.user.impersonate.consent` resolves
|
|
12
|
+
* to the dot-segmented spec name.
|
|
13
|
+
*/
|
|
14
|
+
export const Scopes = {
|
|
15
|
+
anon: {
|
|
16
|
+
public: {
|
|
17
|
+
health: "anon.public.health",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
self: {
|
|
21
|
+
read: "self.read",
|
|
22
|
+
write: "self.write",
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* All declared scopes in spec-sorted order.
|
|
27
|
+
*/
|
|
28
|
+
export const ALL_SCOPES = [
|
|
29
|
+
"anon.public.health",
|
|
30
|
+
"self.read",
|
|
31
|
+
"self.write",
|
|
32
|
+
];
|
|
33
|
+
//# sourceMappingURL=scopes.g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopes.g.js","sourceRoot":"","sources":["../src/scopes.g.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mBAAmB;AACnB,qFAAqF;AACrF,wDAAwD;AACxD,0CAA0C;AAC1C,oBAAoB;AACpB,0EAA0E;AAE1E,oBAAoB;AAEpB;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE;QACJ,MAAM,EAAE;YACN,MAAM,EAAE,oBAAoB;SAC7B;KACF;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,YAAY;KACpB;CACO,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAsB;IAC3C,oBAAoB;IACpB,WAAW;IACX,YAAY;CACb,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dcsv-io/d2-auth-abstractions",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@dcsv-io/d2-i18n-abstractions": "0.1.1",
|
|
18
|
+
"@dcsv-io/d2-i18n-keys": "0.1.1",
|
|
19
|
+
"@dcsv-io/d2-error-category": "0.1.1",
|
|
20
|
+
"@dcsv-io/d2-result": "0.1.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
24
|
+
"typescript": "5.9.3",
|
|
25
|
+
"vitest": "4.0.18"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"prebuild": "node ../../scripts/run-ts-codegen.mjs src/auth-scopes-emit.ts && node ../../scripts/run-ts-codegen.mjs src/error-codes-emit.ts && node ../../scripts/run-ts-codegen.mjs src/jwt-claims-emit.ts",
|
|
29
|
+
"build": "tsc -b",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:coverage": "vitest run --coverage",
|
|
32
|
+
"type-check:test": "tsc -p tsconfig.test.json"
|
|
33
|
+
}
|
|
34
|
+
}
|