@idpartners/client-attestation-sdk 0.0.0-stage → 0.2.0
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 +202 -0
- package/README.md +111 -2
- package/dist/builders.d.ts +96 -0
- package/dist/builders.js +276 -0
- package/dist/credential.d.ts +22 -0
- package/dist/credential.js +44 -0
- package/dist/errors.d.ts +29 -0
- package/dist/errors.js +28 -0
- package/dist/evidence.d.ts +70 -0
- package/dist/evidence.js +150 -0
- package/dist/http.d.ts +41 -0
- package/dist/http.js +158 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +14 -0
- package/dist/issuance.d.ts +42 -0
- package/dist/issuance.js +110 -0
- package/dist/signer.d.ts +33 -0
- package/dist/signer.js +116 -0
- package/dist/signing-key-pair.d.ts +50 -0
- package/dist/signing-key-pair.js +115 -0
- package/dist/svid-source.d.ts +27 -0
- package/dist/svid-source.js +64 -0
- package/dist/token-source.d.ts +120 -0
- package/dist/token-source.js +424 -0
- package/dist/validator/config.d.ts +64 -0
- package/dist/validator/config.js +44 -0
- package/dist/validator/errors.d.ts +20 -0
- package/dist/validator/errors.js +18 -0
- package/dist/validator/index.d.ts +18 -0
- package/dist/validator/index.js +12 -0
- package/dist/validator/jwks.d.ts +39 -0
- package/dist/validator/jwks.js +135 -0
- package/dist/validator/resource.d.ts +42 -0
- package/dist/validator/resource.js +96 -0
- package/dist/validator/result.d.ts +19 -0
- package/dist/validator/result.js +26 -0
- package/dist/validator/validator.d.ts +33 -0
- package/dist/validator/validator.js +197 -0
- package/package.json +53 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,112 @@
|
|
|
1
|
-
#
|
|
1
|
+
# client-attestation-sdk (TypeScript)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Client-side builder SDK for **OAuth Attestation-Based Client Authentication**
|
|
4
|
+
(`draft-ietf-oauth-attestation-based-client-auth`). Mints the three artifacts a client
|
|
5
|
+
presents at the token endpoint:
|
|
6
|
+
|
|
7
|
+
- **Client Attestation JWT** (`typ=oauth-client-attestation+jwt`) — issued by a Client Attester,
|
|
8
|
+
names the client (`sub` = `client_id`) and binds its instance key via `cnf.jwk`.
|
|
9
|
+
- **Client Attestation PoP JWT** (`typ=oauth-client-attestation-pop+jwt`) — proves possession of
|
|
10
|
+
the instance key (PoP method `attestation_pop_jwt`).
|
|
11
|
+
- **DPoP proof JWT** (`typ=dpop+jwt`) — combined mode (PoP method `dpop_combined`); its embedded
|
|
12
|
+
`jwk` header is the instance key bound in the attestation's `cnf`.
|
|
13
|
+
|
|
14
|
+
This is one port of a polyglot SDK; it emits byte-compatible artifacts with the Java and Python
|
|
15
|
+
ports and is judged by a shared Java verifier. Built on [panva `jose`](https://github.com/panva/jose).
|
|
16
|
+
`kid` values are RFC 7638 JWK thumbprints (SHA-256, base64url); `iat`/`exp` are integer epoch seconds.
|
|
17
|
+
|
|
18
|
+
## Install / build
|
|
19
|
+
|
|
20
|
+
Requires **Node 20+**. The package uses Node built-ins (`node:crypto`, `node:fs`, and
|
|
21
|
+
`node:child_process` for the SPIRE evidence source), so it does not run on edge or browser runtimes.
|
|
22
|
+
|
|
23
|
+
Not on npm yet (it will publish as `@idpartners/client-attestation-sdk`). Build from a clone:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install
|
|
27
|
+
npm run build # tsc -> dist/
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
jose's crypto is async, so key factories and `build()` return promises.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import {
|
|
36
|
+
ClientAttestationBuilder,
|
|
37
|
+
ClientAttestationCredential,
|
|
38
|
+
SigningKeyPair,
|
|
39
|
+
} from "client-attestation-sdk";
|
|
40
|
+
|
|
41
|
+
// Attester side: issue the attestation.
|
|
42
|
+
const attester = await SigningKeyPair.generate("ES256"); // or SigningKeyPair.fromJwk(jwk, "ES256")
|
|
43
|
+
const instance = await SigningKeyPair.generate("ES256"); // the client's instance key
|
|
44
|
+
const attestation = await new ClientAttestationBuilder(attester, "https://attester.example.com")
|
|
45
|
+
.clientId("https://rp.example.com")
|
|
46
|
+
.confirmationKey(instance)
|
|
47
|
+
.expiresIn(300)
|
|
48
|
+
// optional: .authorizationDetails(...) / .workload(...) / .operator(sub, issuer?) —
|
|
49
|
+
// operator names who's accountable for running the client (RFC 8693 may_act-shaped; an
|
|
50
|
+
// assertion, not proof of authorisation), distinct from clientId and from the principal.
|
|
51
|
+
.build();
|
|
52
|
+
|
|
53
|
+
// Client side: produce token-request headers.
|
|
54
|
+
const cred = new ClientAttestationCredential(attestation, instance);
|
|
55
|
+
|
|
56
|
+
const popHeaders = await cred.popHeaders("https://rp.example.com", "https://as.example.com");
|
|
57
|
+
// { "OAuth-Client-Attestation": "...", "OAuth-Client-Attestation-PoP": "..." }
|
|
58
|
+
|
|
59
|
+
const dpopHeaders = await cred.dpopHeaders("POST", "https://as.example.com/as/token.oauth2");
|
|
60
|
+
// { "OAuth-Client-Attestation": "...", "DPoP": "..." }
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The one-call `ClientAttestation` orchestration class (see the [root README](../README.md#get-a-token-in-one-call))
|
|
64
|
+
wraps this: `{ popMethod: "dpop_combined" }` in its options switches it to DPoP mode, and a fetched
|
|
65
|
+
challenge is carried through automatically as the PoP JWT's `challenge` claim or the DPoP proof's `nonce`
|
|
66
|
+
claim, whichever mode is active. `operator: {...}` asks the attester to state the client's operator: it
|
|
67
|
+
goes in the mint request and, repeated as compact sorted-key JSON, in the token request's `operator` form
|
|
68
|
+
parameter. `DRAFT_REVISION` names the draft revision implemented (`"10"`).
|
|
69
|
+
|
|
70
|
+
### Presenting the token at a resource
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
const ca = new ClientAttestation("pf.example.com", { popMethod: "dpop_combined" });
|
|
74
|
+
await ca.fetch("https://api.example.com/things"); // headers + one nonce retry
|
|
75
|
+
const headers = await ca.requestHeaders("GET", "https://api.example.com/things");
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`requestHeaders(method, url)` returns what to send for one request. For a Bearer token that is just
|
|
79
|
+
`Authorization: Bearer <t>`. When the AS answers `token_type: DPoP` (normal in `dpop_combined` mode) the
|
|
80
|
+
token is bound to the instance key that minted the attestation, so the SDK keeps that key with the cached
|
|
81
|
+
token and returns `Authorization: DPoP <t>` plus a fresh `DPoP` proof (`htm`, `htu` without query or
|
|
82
|
+
fragment, `ath`, and the last `DPoP-Nonce` that origin sent). `authorizationHeader()` still works, but for
|
|
83
|
+
a DPoP-bound token it returns only the `DPoP` scheme - a resource will also want the proof.
|
|
84
|
+
|
|
85
|
+
`ca.fetch` resends once when a resource answers with a `use_dpop_nonce` challenge (401
|
|
86
|
+
`WWW-Authenticate: DPoP error="use_dpop_nonce"`, or a 400 JSON error) and a `DPoP-Nonce`. String,
|
|
87
|
+
`URLSearchParams`, `ArrayBuffer` and `Request` bodies are resent; a one-shot `ReadableStream` body is not,
|
|
88
|
+
and the challenge response is returned instead. The token request itself retries once on an AS's
|
|
89
|
+
`use_dpop_nonce` demand.
|
|
90
|
+
|
|
91
|
+
### Failing closed
|
|
92
|
+
|
|
93
|
+
- If the attester advertises a `challenge_endpoint` and the challenge cannot be fetched, `token()` throws
|
|
94
|
+
`ClientAttestationError`. Pass `requireChallenge: false` to mint without one instead.
|
|
95
|
+
- `CLIENT_ATTESTATION_TOKEN_FILE` or `SPIFFE_ENDPOINT_SOCKET` pointing at a missing path throws
|
|
96
|
+
`EvidenceNotFound` naming the variable - it never falls through to another identity source.
|
|
97
|
+
- `challengeAtToken: false` keeps the attester challenge in the mint's instance proof but leaves it out
|
|
98
|
+
of the token-endpoint PoP `challenge` claim / DPoP `nonce` - for attesters that consume a challenge at
|
|
99
|
+
mint and reject it when the token request presents it again.
|
|
100
|
+
- The PingFederate host and every endpoint the attester advertises must be `https`, except loopback
|
|
101
|
+
(`localhost`, `127.0.0.1`, `::1`). Pass `allowInsecure: true` for, say, an in-cluster plain-http PF.
|
|
102
|
+
|
|
103
|
+
The validator's `ProtectedResource` strips control characters from every quoted `WWW-Authenticate` value,
|
|
104
|
+
and validation failures never echo the token's own `alg`, `kid`, `iss` or `aud` back in
|
|
105
|
+
`error_description`.
|
|
106
|
+
|
|
107
|
+
## Test & interop
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
npm test # vitest — self-verifies each artifact with jose
|
|
111
|
+
npm run emit # writes ../vectors/out/typescript.json for the cross-language Java verifier
|
|
112
|
+
```
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { JWK } from "jose";
|
|
2
|
+
import { SigningKeyPair } from "./signing-key-pair.js";
|
|
3
|
+
import { type JwsSigner } from "./signer.js";
|
|
4
|
+
export declare const ATTESTATION_TYP = "oauth-client-attestation+jwt";
|
|
5
|
+
export declare const POP_TYP = "oauth-client-attestation-pop+jwt";
|
|
6
|
+
export declare const DPOP_TYP = "dpop+jwt";
|
|
7
|
+
/**
|
|
8
|
+
* Builds a Client Attestation JWT — the credential a Client Attester issues to name a client
|
|
9
|
+
* (`sub`) and bind its instance key via `cnf.jwk`. Attester side; sign with the attester's key.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ClientAttestationBuilder {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(attesterKey: SigningKeyPair | JwsSigner, issuer: string);
|
|
14
|
+
/** The client being attested — becomes the attestation `sub` (= `client_id`). */
|
|
15
|
+
clientId(clientId: string): this;
|
|
16
|
+
/** Binds the client instance key as `cnf.jwk`. Must be a public JWK. */
|
|
17
|
+
confirmationJwk(publicInstanceJwk: JWK): this;
|
|
18
|
+
/** Convenience: binds the public half of the given instance key as `cnf.jwk`. */
|
|
19
|
+
confirmationKey(instanceKey: SigningKeyPair): this;
|
|
20
|
+
issuedAt(epochSeconds: number): this;
|
|
21
|
+
/** Sets an absolute `exp`. */
|
|
22
|
+
expiresAt(epochSeconds: number): this;
|
|
23
|
+
/** Sets `exp` to `iat + seconds`. */
|
|
24
|
+
expiresIn(seconds: number): this;
|
|
25
|
+
/** The optional RFC 9396 `authorization_details` entitlement the attester asserts. */
|
|
26
|
+
authorizationDetails(details: unknown[]): this;
|
|
27
|
+
/** Optional attester-asserted `workload` attributes. */
|
|
28
|
+
workload(workload: Record<string, unknown>): this;
|
|
29
|
+
/**
|
|
30
|
+
* Names the client's OPERATOR — the human or organisation accountable for running this client,
|
|
31
|
+
* as distinct from the client itself (`sub`) and from the principal it acts for.
|
|
32
|
+
*
|
|
33
|
+
* Deliberately a top-level claim rather than a member of `workload`: `workload` describes the
|
|
34
|
+
* running software, whereas the operator is an accountability statement about who answers for
|
|
35
|
+
* it. It is per-client and static, so it does not affect how far an attestation can be cached.
|
|
36
|
+
*
|
|
37
|
+
* The shape mirrors RFC 8693 `may_act` (`{ sub: ..., iss: ... }`) on purpose. An AS that wants
|
|
38
|
+
* the operator to become the party authorised to act for the subject can lift this straight
|
|
39
|
+
* into `may_act`; `iss` names the OP the operator's `sub` is meaningful in, so the identifier is
|
|
40
|
+
* not ambiguous across directories.
|
|
41
|
+
*
|
|
42
|
+
* This is an ASSERTION by the attester, not proof the operator authorised anything. A relying
|
|
43
|
+
* AS should treat it as it treats the rest of the attestation: trusted exactly as far as the
|
|
44
|
+
* attester is.
|
|
45
|
+
*/
|
|
46
|
+
operator(sub: string, issuer?: string | null): this;
|
|
47
|
+
build(): Promise<string>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Builds a Client Attestation PoP JWT proving possession of the instance key. Client side of
|
|
51
|
+
* `attest_jwt_client_auth`; mint a fresh one per token request.
|
|
52
|
+
*/
|
|
53
|
+
export declare class PopBuilder {
|
|
54
|
+
#private;
|
|
55
|
+
constructor(instanceKey: SigningKeyPair);
|
|
56
|
+
/** Sets the optional `iss`; when present the verifier requires it to equal the attestation `sub`. */
|
|
57
|
+
clientId(clientId: string | null): this;
|
|
58
|
+
/** The AS identifier this PoP is bound to (`aud`) — required. */
|
|
59
|
+
audience(audience: string): this;
|
|
60
|
+
challenge(challenge: string | null): this;
|
|
61
|
+
jwtId(jwtId: string): this;
|
|
62
|
+
issuedAt(epochSeconds: number): this;
|
|
63
|
+
build(): Promise<string>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Builds a DPoP proof JWT (RFC 9449) for attestation combined mode
|
|
67
|
+
* (PoP method `dpop_combined`): the embedded `jwk` header MUST be the attestation's `cnf` key.
|
|
68
|
+
*/
|
|
69
|
+
export declare class DpopProofBuilder {
|
|
70
|
+
#private;
|
|
71
|
+
constructor(instanceKey: SigningKeyPair);
|
|
72
|
+
/** The request's HTTP method (`htm`, upper-cased when built); defaults to `POST`. */
|
|
73
|
+
method(htm: string | null | undefined): this;
|
|
74
|
+
/**
|
|
75
|
+
* The target URL (`htu`) — required. Normalised when built: query and fragment are dropped, and
|
|
76
|
+
* scheme and host lower-cased (RFC 9449 section 4.2).
|
|
77
|
+
*/
|
|
78
|
+
uri(htu: string): this;
|
|
79
|
+
/** The server challenge, carried in DPoP `nonce`. */
|
|
80
|
+
nonce(nonce: string | null): this;
|
|
81
|
+
/**
|
|
82
|
+
* The access token this proof accompanies at a resource: sets `ath` = base64url(SHA-256(token)).
|
|
83
|
+
* Leave unset for a proof sent to the token endpoint.
|
|
84
|
+
*/
|
|
85
|
+
accessToken(accessToken: string | null): this;
|
|
86
|
+
jwtId(jwtId: string): this;
|
|
87
|
+
issuedAt(epochSeconds: number): this;
|
|
88
|
+
build(): Promise<string>;
|
|
89
|
+
}
|
|
90
|
+
/** RFC 9449 `ath`: base64url(SHA-256(ASCII access token)). */
|
|
91
|
+
export declare function accessTokenHash(accessToken: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* The DPoP `htu` for a URL: scheme, host, port and path, with no query and no fragment. Scheme and host
|
|
94
|
+
* are lower-cased and a default port dropped; a URL with no path keeps none (no slash is invented).
|
|
95
|
+
*/
|
|
96
|
+
export declare function normalizeHtu(url: string): string;
|