@openbotauth/verifier-client 0.1.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 +201 -0
- package/README.md +319 -0
- package/dist/client.d.ts +9 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +92 -0
- package/dist/client.js.map +1 -0
- package/dist/express.d.ts +3 -0
- package/dist/express.d.ts.map +1 -0
- package/dist/express.js +2 -0
- package/dist/express.js.map +1 -0
- package/dist/headers.d.ts +5 -0
- package/dist/headers.d.ts.map +1 -0
- package/dist/headers.js +88 -0
- package/dist/headers.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware.d.ts +4 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +55 -0
- package/dist/middleware.js.map +1 -0
- package/dist/nextjs.d.ts +5 -0
- package/dist/nextjs.d.ts.map +1 -0
- package/dist/nextjs.js +26 -0
- package/dist/nextjs.js.map +1 -0
- package/dist/types.d.ts +40 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 OpenBotAuth Project
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# @openbotauth/verifier-client
|
|
2
|
+
|
|
3
|
+
Client library for verifying [Web Bot Auth](https://github.com/nicholasgriffintn/draft-web-bot-auth) / [OpenBotAuth](https://openbotauth.org) signed HTTP requests in Node.js applications.
|
|
4
|
+
|
|
5
|
+
Web Bot Auth is an IETF draft standard for authenticating AI agents and bots using RFC 9421 HTTP Message Signatures. OpenBotAuth provides the reference implementation, registry, and hosted verifier service.
|
|
6
|
+
|
|
7
|
+
This package provides:
|
|
8
|
+
- **VerifierClient**: Core client class for calling the verifier service
|
|
9
|
+
- **Express middleware**: Easy integration with Express/Connect-based apps
|
|
10
|
+
- **Next.js helpers**: Utilities for Next.js App Router (Server Components & Route Handlers)
|
|
11
|
+
- **Header extraction**: Safe parsing of RFC 9421 signature headers
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @openbotauth/verifier-client
|
|
17
|
+
# or
|
|
18
|
+
pnpm add @openbotauth/verifier-client
|
|
19
|
+
# or
|
|
20
|
+
yarn add @openbotauth/verifier-client
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### Express Middleware
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import express from 'express';
|
|
29
|
+
import { openBotAuthMiddleware } from '@openbotauth/verifier-client/express';
|
|
30
|
+
|
|
31
|
+
const app = express();
|
|
32
|
+
|
|
33
|
+
// Add middleware (uses hosted verifier by default)
|
|
34
|
+
app.use(openBotAuthMiddleware());
|
|
35
|
+
|
|
36
|
+
app.get('/api/resource', (req, res) => {
|
|
37
|
+
const oba = (req as any).oba;
|
|
38
|
+
|
|
39
|
+
if (oba.signed && oba.result?.verified) {
|
|
40
|
+
// Request is from a verified bot
|
|
41
|
+
res.json({
|
|
42
|
+
message: 'Hello verified bot!',
|
|
43
|
+
agent: oba.result.agent,
|
|
44
|
+
});
|
|
45
|
+
} else if (oba.signed) {
|
|
46
|
+
// Signed but verification failed
|
|
47
|
+
res.json({
|
|
48
|
+
message: 'Signature verification failed',
|
|
49
|
+
error: oba.result?.error,
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
// Not a signed request
|
|
53
|
+
res.json({ message: 'Hello anonymous!' });
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
app.listen(3000);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Require Verified Mode
|
|
61
|
+
|
|
62
|
+
Block unverified signed requests with a 401 response:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
// Protected routes that require verified bot signatures
|
|
66
|
+
app.use('/api/protected', openBotAuthMiddleware({
|
|
67
|
+
mode: 'require-verified'
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
app.get('/api/protected/data', (req, res) => {
|
|
71
|
+
// Only verified bots reach here
|
|
72
|
+
const oba = (req as any).oba;
|
|
73
|
+
res.json({
|
|
74
|
+
message: 'Access granted',
|
|
75
|
+
agent: oba.result.agent,
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Next.js App Router
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
// app/api/protected/route.ts
|
|
84
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
85
|
+
import {
|
|
86
|
+
VerifierClient,
|
|
87
|
+
buildVerifyRequestForNext
|
|
88
|
+
} from '@openbotauth/verifier-client';
|
|
89
|
+
|
|
90
|
+
const client = new VerifierClient();
|
|
91
|
+
|
|
92
|
+
export async function GET(request: NextRequest) {
|
|
93
|
+
const verifyRequest = buildVerifyRequestForNext(request);
|
|
94
|
+
const result = await client.verify(verifyRequest);
|
|
95
|
+
|
|
96
|
+
if (result.verified) {
|
|
97
|
+
return NextResponse.json({
|
|
98
|
+
message: 'Hello verified bot!',
|
|
99
|
+
agent: result.agent,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// For non-verified requests, you might still allow access
|
|
104
|
+
// or return an error depending on your use case
|
|
105
|
+
return NextResponse.json(
|
|
106
|
+
{ error: 'Verification failed', details: result.error },
|
|
107
|
+
{ status: 401 }
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## API Reference
|
|
113
|
+
|
|
114
|
+
### VerifierClient
|
|
115
|
+
|
|
116
|
+
Core client for verifying signatures.
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { VerifierClient } from '@openbotauth/verifier-client';
|
|
120
|
+
|
|
121
|
+
const client = new VerifierClient({
|
|
122
|
+
// Optional: Override verifier URL (default: hosted verifier)
|
|
123
|
+
verifierUrl: 'https://verifier.openbotauth.org/verify',
|
|
124
|
+
// Optional: Request timeout in ms (default: 5000)
|
|
125
|
+
timeoutMs: 5000,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const result = await client.verify({
|
|
129
|
+
method: 'GET',
|
|
130
|
+
url: 'https://example.com/api/resource',
|
|
131
|
+
headers: {
|
|
132
|
+
'signature-input': '...',
|
|
133
|
+
'signature': '...',
|
|
134
|
+
'signature-agent': '...',
|
|
135
|
+
},
|
|
136
|
+
body: undefined, // Optional request body
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// Result type:
|
|
140
|
+
// {
|
|
141
|
+
// verified: boolean;
|
|
142
|
+
// agent?: { jwks_url: string; kid: string; client_name?: string };
|
|
143
|
+
// error?: string;
|
|
144
|
+
// created?: number;
|
|
145
|
+
// expires?: number;
|
|
146
|
+
// }
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### openBotAuthMiddleware
|
|
150
|
+
|
|
151
|
+
Express middleware for automatic verification. Import from the `/express` subpath to avoid pulling Express types into non-Express projects.
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
import { openBotAuthMiddleware } from '@openbotauth/verifier-client/express';
|
|
155
|
+
|
|
156
|
+
app.use(openBotAuthMiddleware({
|
|
157
|
+
// Optional: Override verifier URL
|
|
158
|
+
verifierUrl: 'http://localhost:8081/verify',
|
|
159
|
+
|
|
160
|
+
// Optional: Behavior mode
|
|
161
|
+
// - "observe" (default): Attach result, allow all requests
|
|
162
|
+
// - "require-verified": Block unverified signed requests with 401
|
|
163
|
+
mode: 'observe',
|
|
164
|
+
|
|
165
|
+
// Optional: Property name on request object (default: "oba")
|
|
166
|
+
attachProperty: 'oba',
|
|
167
|
+
|
|
168
|
+
// Optional: Request timeout in ms (default: 5000)
|
|
169
|
+
timeoutMs: 5000,
|
|
170
|
+
}));
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Header Extraction Helpers
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import {
|
|
177
|
+
parseCoveredHeaders,
|
|
178
|
+
extractForwardedHeaders,
|
|
179
|
+
hasSignatureHeaders
|
|
180
|
+
} from '@openbotauth/verifier-client';
|
|
181
|
+
|
|
182
|
+
// Parse covered headers from Signature-Input
|
|
183
|
+
const covered = parseCoveredHeaders(
|
|
184
|
+
'sig1=("@method" "@target-uri" "content-type");created=1234'
|
|
185
|
+
);
|
|
186
|
+
// Returns: ["@method", "@target-uri", "content-type"]
|
|
187
|
+
|
|
188
|
+
// Check if request has signature headers
|
|
189
|
+
if (hasSignatureHeaders(headers)) {
|
|
190
|
+
// Extract headers safe to forward (blocks sensitive headers)
|
|
191
|
+
const result = extractForwardedHeaders(headers, signatureInput);
|
|
192
|
+
|
|
193
|
+
if (result.error) {
|
|
194
|
+
// Signature covers sensitive header (cookie, authorization, etc.)
|
|
195
|
+
console.error(result.error);
|
|
196
|
+
} else {
|
|
197
|
+
// result.headers contains safe headers to forward
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Next.js Helpers
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
import {
|
|
206
|
+
extractFromNextHeaders,
|
|
207
|
+
buildVerifyRequestForNext,
|
|
208
|
+
buildVerifyRequestForNextWithBody,
|
|
209
|
+
} from '@openbotauth/verifier-client';
|
|
210
|
+
|
|
211
|
+
// Convert Next.js Headers to plain object
|
|
212
|
+
const headersObj = extractFromNextHeaders(request.headers);
|
|
213
|
+
|
|
214
|
+
// Build verification request (without body)
|
|
215
|
+
const verifyRequest = buildVerifyRequestForNext(request);
|
|
216
|
+
|
|
217
|
+
// Build verification request (with body - consumes body stream)
|
|
218
|
+
const verifyRequestWithBody = await buildVerifyRequestForNextWithBody(request);
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Configuration
|
|
222
|
+
|
|
223
|
+
### Using Hosted Verifier (Default)
|
|
224
|
+
|
|
225
|
+
By default, the client uses the hosted verifier at `https://verifier.openbotauth.org/verify`. This requires no configuration:
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
const client = new VerifierClient();
|
|
229
|
+
// or
|
|
230
|
+
app.use(openBotAuthMiddleware());
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Using Local/Self-Hosted Verifier
|
|
234
|
+
|
|
235
|
+
For development or self-hosted deployments:
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
const client = new VerifierClient({
|
|
239
|
+
verifierUrl: 'http://localhost:8081/verify',
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// or with middleware
|
|
243
|
+
app.use(openBotAuthMiddleware({
|
|
244
|
+
verifierUrl: 'http://localhost:8081/verify',
|
|
245
|
+
}));
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Testing with bot-cli
|
|
249
|
+
|
|
250
|
+
You can test your integration using the OpenBotAuth bot-cli:
|
|
251
|
+
|
|
252
|
+
1. Start your Express server with the middleware
|
|
253
|
+
2. Run bot-cli to make a signed request:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# From the OpenBotAuth monorepo
|
|
257
|
+
pnpm --filter @openbotauth/bot-cli dev fetch http://localhost:3000/api/resource -v
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Note**: For the hosted verifier to successfully verify signatures, the `Signature-Agent` JWKS URL must be publicly accessible. Use a registry.openbotauth.org JWKS URL for testing.
|
|
261
|
+
|
|
262
|
+
## Security
|
|
263
|
+
|
|
264
|
+
This package follows security best practices:
|
|
265
|
+
|
|
266
|
+
- **No local crypto**: Signature verification is delegated to the verifier service
|
|
267
|
+
- **Sensitive header protection**: The client will NOT forward requests that sign sensitive headers:
|
|
268
|
+
- `cookie`
|
|
269
|
+
- `authorization`
|
|
270
|
+
- `proxy-authorization`
|
|
271
|
+
- `www-authenticate`
|
|
272
|
+
- **Timeout handling**: All verifier requests have configurable timeouts
|
|
273
|
+
- **Header normalization**: All forwarded headers are normalized to lowercase
|
|
274
|
+
|
|
275
|
+
## Types
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
interface VerificationRequest {
|
|
279
|
+
method: string;
|
|
280
|
+
url: string;
|
|
281
|
+
headers: Record<string, string>;
|
|
282
|
+
body?: string;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
interface VerificationResult {
|
|
286
|
+
verified: boolean;
|
|
287
|
+
agent?: {
|
|
288
|
+
jwks_url: string;
|
|
289
|
+
kid: string;
|
|
290
|
+
client_name?: string;
|
|
291
|
+
};
|
|
292
|
+
error?: string;
|
|
293
|
+
created?: number;
|
|
294
|
+
expires?: number;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
interface MiddlewareOptions {
|
|
298
|
+
verifierUrl?: string;
|
|
299
|
+
mode?: 'observe' | 'require-verified';
|
|
300
|
+
attachProperty?: string;
|
|
301
|
+
timeoutMs?: number;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
interface RequestVerificationInfo {
|
|
305
|
+
signed: boolean;
|
|
306
|
+
result?: VerificationResult;
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Standards & References
|
|
311
|
+
|
|
312
|
+
- [Web Bot Auth IETF Draft](https://github.com/nicholasgriffintn/draft-web-bot-auth) - The IETF draft specification for bot authentication
|
|
313
|
+
- [RFC 9421](https://www.rfc-editor.org/rfc/rfc9421.html) - HTTP Message Signatures
|
|
314
|
+
- [RFC 7517](https://www.rfc-editor.org/rfc/rfc7517.html) - JSON Web Key (JWK)
|
|
315
|
+
- [OpenBotAuth](https://openbotauth.org) - Reference implementation and hosted services
|
|
316
|
+
|
|
317
|
+
## License
|
|
318
|
+
|
|
319
|
+
Apache-2.0
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { VerifierClientOptions, VerificationRequest, VerificationResult } from './types.js';
|
|
2
|
+
export declare class VerifierClient {
|
|
3
|
+
private readonly verifierUrl;
|
|
4
|
+
private readonly timeoutMs;
|
|
5
|
+
constructor(options?: VerifierClientOptions);
|
|
6
|
+
verify(input: VerificationRequest): Promise<VerificationResult>;
|
|
7
|
+
private getHeaderValue;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAsCpB,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBASvB,OAAO,GAAE,qBAA0B;IAWzC,MAAM,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAwFrE,OAAO,CAAC,cAAc;CAYvB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { extractForwardedHeaders, hasSignatureHeaders } from './headers.js';
|
|
2
|
+
const DEFAULT_VERIFIER_URL = 'https://verifier.openbotauth.org/verify';
|
|
3
|
+
const DEFAULT_TIMEOUT_MS = 5000;
|
|
4
|
+
export class VerifierClient {
|
|
5
|
+
verifierUrl;
|
|
6
|
+
timeoutMs;
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.verifierUrl = options.verifierUrl ?? DEFAULT_VERIFIER_URL;
|
|
9
|
+
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
10
|
+
}
|
|
11
|
+
async verify(input) {
|
|
12
|
+
if (!hasSignatureHeaders(input.headers)) {
|
|
13
|
+
return {
|
|
14
|
+
verified: false,
|
|
15
|
+
error: 'No signature headers present',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const signatureInput = this.getHeaderValue(input.headers, 'signature-input');
|
|
19
|
+
if (!signatureInput) {
|
|
20
|
+
return {
|
|
21
|
+
verified: false,
|
|
22
|
+
error: 'Missing Signature-Input header (request has signature headers but Signature-Input is required)',
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const signature = this.getHeaderValue(input.headers, 'signature');
|
|
26
|
+
if (!signature) {
|
|
27
|
+
return {
|
|
28
|
+
verified: false,
|
|
29
|
+
error: 'Missing Signature header (request has Signature-Input but Signature is required)',
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const extractResult = extractForwardedHeaders(input.headers, signatureInput);
|
|
33
|
+
if (extractResult.error) {
|
|
34
|
+
return {
|
|
35
|
+
verified: false,
|
|
36
|
+
error: extractResult.error,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const payload = {
|
|
40
|
+
method: input.method,
|
|
41
|
+
url: input.url,
|
|
42
|
+
headers: extractResult.headers,
|
|
43
|
+
...(input.body !== undefined && { body: input.body }),
|
|
44
|
+
};
|
|
45
|
+
const controller = new AbortController();
|
|
46
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
47
|
+
try {
|
|
48
|
+
const response = await fetch(this.verifierUrl, {
|
|
49
|
+
method: 'POST',
|
|
50
|
+
headers: {
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
},
|
|
53
|
+
body: JSON.stringify(payload),
|
|
54
|
+
signal: controller.signal,
|
|
55
|
+
});
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
const errorText = await response.text();
|
|
58
|
+
return {
|
|
59
|
+
verified: false,
|
|
60
|
+
error: `Verifier returned ${response.status}: ${errorText}`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const result = await response.json();
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
68
|
+
return {
|
|
69
|
+
verified: false,
|
|
70
|
+
error: `Verification timed out after ${this.timeoutMs}ms`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
verified: false,
|
|
75
|
+
error: `Verification failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
finally {
|
|
79
|
+
clearTimeout(timeoutId);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
getHeaderValue(headers, name) {
|
|
83
|
+
const normalized = name.toLowerCase();
|
|
84
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
85
|
+
if (key.toLowerCase() === normalized) {
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAK5E,MAAM,oBAAoB,GAAG,yCAAyC,CAAC;AAKvE,MAAM,kBAAkB,GAAG,IAAI,CAAC;AA2BhC,MAAM,OAAO,cAAc;IACR,WAAW,CAAS;IACpB,SAAS,CAAS;IASnC,YAAY,UAAiC,EAAE;QAC7C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,oBAAoB,CAAC;QAC/D,IAAI,CAAC,SAAS,GAAG,OA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AG,IAAI,CAAC,WAAW,EAAE,CAAC;QACtC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,UAAU,EAAE,CAAC;gBACrC,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/express.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"express.js","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { HeaderExtractionResult } from './types.js';
|
|
2
|
+
export declare function parseCoveredHeaders(signatureInput: string): string[];
|
|
3
|
+
export declare function extractForwardedHeaders(rawHeaders: Record<string, string | undefined>, signatureInput: string): HeaderExtractionResult;
|
|
4
|
+
export declare function hasSignatureHeaders(headers: Record<string, string | undefined>): boolean;
|
|
5
|
+
//# sourceMappingURL=headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../src/headers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAuCzD,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAyBpE;AAoCD,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAC9C,cAAc,EAAE,MAAM,GACrB,sBAAsB,CAqDxB;AAsBD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAC1C,OAAO,CAQT"}
|
package/dist/headers.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const SENSITIVE_HEADERS = new Set([
|
|
2
|
+
'cookie',
|
|
3
|
+
'authorization',
|
|
4
|
+
'proxy-authorization',
|
|
5
|
+
'www-authenticate',
|
|
6
|
+
]);
|
|
7
|
+
const SIGNATURE_HEADERS = ['signature-input', 'signature'];
|
|
8
|
+
const SIGNATURE_AGENT_HEADER = 'signature-agent';
|
|
9
|
+
export function parseCoveredHeaders(signatureInput) {
|
|
10
|
+
const openParen = signatureInput.indexOf('(');
|
|
11
|
+
if (openParen === -1) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const closeParen = signatureInput.indexOf(')', openParen);
|
|
15
|
+
if (closeParen === -1) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const content = signatureInput.slice(openParen + 1, closeParen);
|
|
19
|
+
return content
|
|
20
|
+
.split(/\s+/)
|
|
21
|
+
.filter((s) => s.length > 0)
|
|
22
|
+
.map((s) => {
|
|
23
|
+
if (s.startsWith('"') && s.endsWith('"')) {
|
|
24
|
+
return s.slice(1, -1).toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
return s.toLowerCase();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function normalizeHeaderName(name) {
|
|
30
|
+
return name.toLowerCase();
|
|
31
|
+
}
|
|
32
|
+
function isDerivedComponent(name) {
|
|
33
|
+
return name.startsWith('@');
|
|
34
|
+
}
|
|
35
|
+
export function extractForwardedHeaders(rawHeaders, signatureInput) {
|
|
36
|
+
const result = {};
|
|
37
|
+
const getHeader = (name) => {
|
|
38
|
+
const normalized = normalizeHeaderName(name);
|
|
39
|
+
for (const [key, value] of Object.entries(rawHeaders)) {
|
|
40
|
+
if (normalizeHeaderName(key) === normalized && value !== undefined) {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
};
|
|
46
|
+
for (const headerName of SIGNATURE_HEADERS) {
|
|
47
|
+
const value = getHeader(headerName);
|
|
48
|
+
if (value !== undefined) {
|
|
49
|
+
result[headerName] = value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const signatureAgent = getHeader(SIGNATURE_AGENT_HEADER);
|
|
53
|
+
if (signatureAgent !== undefined) {
|
|
54
|
+
result[SIGNATURE_AGENT_HEADER] = signatureAgent;
|
|
55
|
+
}
|
|
56
|
+
const coveredHeaders = parseCoveredHeaders(signatureInput);
|
|
57
|
+
for (const headerName of coveredHeaders) {
|
|
58
|
+
if (isDerivedComponent(headerName)) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (SENSITIVE_HEADERS.has(headerName)) {
|
|
62
|
+
return {
|
|
63
|
+
error: `Signature covers sensitive header: ${headerName}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const value = getHeader(headerName);
|
|
67
|
+
if (value !== undefined) {
|
|
68
|
+
result[headerName] = value;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { headers: result };
|
|
72
|
+
}
|
|
73
|
+
const SIGNATURE_RELATED_HEADERS = new Set([
|
|
74
|
+
'signature-input',
|
|
75
|
+
'signature',
|
|
76
|
+
'signature-agent',
|
|
77
|
+
]);
|
|
78
|
+
export function hasSignatureHeaders(headers) {
|
|
79
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
80
|
+
if (value === undefined)
|
|
81
|
+
continue;
|
|
82
|
+
if (SIGNATURE_RELATED_HEADERS.has(normalizeHeaderName(key))) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}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AAS;QACX,CAAC;QAGD,IAAI,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACtC,OAAO;gBACL,KAAK,EAAE,sCAAsC,UAAU,EAAE;aAC1D,CAAC;QACJ,CAAC;QAGD,MAAM,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC;AAKD,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACxC,iBAAiB;IACjB,WAAW;IACX,iBAAiB;CAClB,CAAC,CAAC;AAaH,MAAM,UAAU,mBAAmB,CACjC,OAA2C;IAE3C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IAAI,yBAAyB,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC5D,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { VerificationRequest, VerificationResult, VerifiedAgent, VerifierClientOptions, HeaderExtractionResult, } from './types.js';
|
|
2
|
+
export { VerifierClient } from './client.js';
|
|
3
|
+
export { parseCoveredHeaders, extractForwardedHeaders, hasSignatureHeaders, } from './headers.js';
|
|
4
|
+
export { extractFromNextHeaders, buildVerifyRequestForNext, buildVerifyRequestForNextWithBody, } from './nextjs.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,iCAAiC,GAClC,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { VerifierClient } from './client.js';
|
|
2
|
+
export { parseCoveredHeaders, extractForwardedHeaders, hasSignatureHeaders, } from './headers.js';
|
|
3
|
+
export { extractFromNextHeaders, buildVerifyRequestForNext, buildVerifyRequestForNextWithBody, } from './nextjs.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,iCAAiC,GAClC,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Request, Response, NextFunction } from 'express';
|
|
2
|
+
import type { MiddlewareOptions } from './types.js';
|
|
3
|
+
export declare function openBotAuthMiddleware(options?: MiddlewareOptions): (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
4
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAA2B,MAAM,YAAY,CAAC;AAoC7E,wBAAgB,qBAAqB,CACnC,OAAO,GAAE,iBAAsB,GAC9B,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAuEpE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { VerifierClient } from './client.js';
|
|
2
|
+
import { hasSignatureHeaders } from './headers.js';
|
|
3
|
+
export function openBotAuthMiddleware(options = {}) {
|
|
4
|
+
const { verifierUrl, mode = 'observe', attachProperty = 'oba', timeoutMs, } = options;
|
|
5
|
+
const client = new VerifierClient({ verifierUrl, timeoutMs });
|
|
6
|
+
return async (req, res, next) => {
|
|
7
|
+
const headers = {};
|
|
8
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
9
|
+
if (typeof value === 'string') {
|
|
10
|
+
headers[key] = value;
|
|
11
|
+
}
|
|
12
|
+
else if (Array.isArray(value)) {
|
|
13
|
+
headers[key] = value.join(', ');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (!hasSignatureHeaders(headers)) {
|
|
17
|
+
const info = { signed: false };
|
|
18
|
+
req[attachProperty] = info;
|
|
19
|
+
next();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const protocol = req.protocol;
|
|
23
|
+
const host = req.get('host') || 'localhost';
|
|
24
|
+
const url = `${protocol}://${host}${req.originalUrl}`;
|
|
25
|
+
let body;
|
|
26
|
+
if (req.body !== undefined && req.body !== null) {
|
|
27
|
+
if (typeof req.body === 'string') {
|
|
28
|
+
body = req.body;
|
|
29
|
+
}
|
|
30
|
+
else if (Buffer.isBuffer(req.body)) {
|
|
31
|
+
body = req.body.toString('utf-8');
|
|
32
|
+
}
|
|
33
|
+
else if (typeof req.body === 'object') {
|
|
34
|
+
body = JSON.stringify(req.body);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const result = await client.verify({
|
|
38
|
+
method: req.method,
|
|
39
|
+
url,
|
|
40
|
+
headers: headers,
|
|
41
|
+
body,
|
|
42
|
+
});
|
|
43
|
+
const info = { signed: true, result };
|
|
44
|
+
req[attachProperty] = info;
|
|
45
|
+
if (mode === 'require-verified' && !result.verified) {
|
|
46
|
+
res.status(401).json({
|
|
47
|
+
error: 'Signature verification failed',
|
|
48
|
+
details: result.error,
|
|
49
|
+
});
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
next();
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAkCnD,MAAM,UAAU,qBAAqB,CACnC,UAA6B,EAAE;IAE/B,MAAM,EACJ,WAAW,EACX,IAAI,GAAG,SAAS,EAChB,cAAc,GAAG,KAAK,EACtB,SAAS,GACV,GAAG,OAAO,CAAC;IAEZ,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC;IAE9D,OAAO,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAiB,EAAE;QAE9E,MAAM,OAAO,GAAuC,EAAE,CAAC;QACvD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACvD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACvB,CA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C,MAAM;YAClB,GAAG;YACH,OAAO,EAAE,OAAiC;YAC1C,IAAI;SACL,CAAC,CAAC;QAGH,MAAM,IAAI,GAA4B,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QAC9D,GAA0C,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;QAGnE,IAAI,IAAI,KAAK,kBAAkB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,+BAA+B;gBACtC,OAAO,EAAE,MAAM,CAAC,KAAK;aACtB,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/nextjs.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { VerificationRequest } from './types.js';
|
|
2
|
+
export declare function extractFromNextHeaders(nextHeaders: Headers): Record<string, string>;
|
|
3
|
+
export declare function buildVerifyRequestForNext(request: Request): Omit<VerificationRequest, 'body'>;
|
|
4
|
+
export declare function buildVerifyRequestForNextWithBody(request: Request): Promise<VerificationRequest>;
|
|
5
|
+
//# sourceMappingURL=nextjs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextjs.d.ts","sourceRoot":"","sources":["../src/nextjs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAqBtD,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQnF;AAqCD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,GACf,IAAI,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAQnC;AA2BD,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,mBAAmB,CAAC,CAU9B"}
|
package/dist/nextjs.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export function extractFromNextHeaders(nextHeaders) {
|
|
2
|
+
const result = {};
|
|
3
|
+
nextHeaders.forEach((value, key) => {
|
|
4
|
+
result[key.toLowerCase()] = value;
|
|
5
|
+
});
|
|
6
|
+
return result;
|
|
7
|
+
}
|
|
8
|
+
export function buildVerifyRequestForNext(request) {
|
|
9
|
+
const headers = extractFromNextHeaders(request.headers);
|
|
10
|
+
return {
|
|
11
|
+
method: request.method,
|
|
12
|
+
url: request.url,
|
|
13
|
+
headers,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export async function buildVerifyRequestForNextWithBody(request) {
|
|
17
|
+
const headers = extractFromNextHeaders(request.headers);
|
|
18
|
+
const body = await request.text();
|
|
19
|
+
return {
|
|
20
|
+
method: request.method,
|
|
21
|
+
url: request.url,
|
|
22
|
+
headers,
|
|
23
|
+
body: body || undefined,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=nextjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextjs.js","sourceRoot":"","sources":["../src/nextjs.ts"],"names":[],"mappings":"AAqBA,MAAM,UAAU,sBAAsB,CAAC,WAAoB;IACzD,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACjC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAqCD,MAAM,UAAU,yBAAyB,CACvC,OAAgB;IAEhB,MAAM,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAExD,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,OAAO;KACR,CAAC;AACJ,CAAC;AA2BD,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,OAAgB;IAEhB,MAAM,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IAElC,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,OAAO;QACP,IAAI,EAAE,IAAI,IAAI,SAAS;KACxB,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface VerificationRequest {
|
|
2
|
+
method: string;
|
|
3
|
+
url: string;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
body?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface VerifiedAgent {
|
|
8
|
+
jwks_url: string;
|
|
9
|
+
kid: string;
|
|
10
|
+
client_name?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface VerificationResult {
|
|
13
|
+
verified: boolean;
|
|
14
|
+
agent?: VerifiedAgent;
|
|
15
|
+
error?: string;
|
|
16
|
+
created?: number;
|
|
17
|
+
expires?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface VerifierClientOptions {
|
|
20
|
+
verifierUrl?: string;
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface MiddlewareOptions {
|
|
24
|
+
verifierUrl?: string;
|
|
25
|
+
mode?: 'observe' | 'require-verified';
|
|
26
|
+
attachProperty?: string;
|
|
27
|
+
timeoutMs?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface RequestVerificationInfo {
|
|
30
|
+
signed: boolean;
|
|
31
|
+
result?: VerificationResult;
|
|
32
|
+
}
|
|
33
|
+
export type HeaderExtractionResult = {
|
|
34
|
+
headers: Record<string, string>;
|
|
35
|
+
error?: never;
|
|
36
|
+
} | {
|
|
37
|
+
headers?: never;
|
|
38
|
+
error: string;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAKD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAKD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,MAAM,WAAW,qBAAqB;IAKpC,WAAW,CAAC,EAAE,MAAM,CAAC;IAMrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,MAAM,WAAW,iBAAiB;IAKhC,WAAW,CAAC,EAAE,MAAM,CAAC;IAQrB,IAAI,CAAC,EAAE,SAAS,GAAG,kBAAkB,CAAC;IAMtC,cAAc,CAAC,EAAE,MAAM,CAAC;IAMxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AAKD,MAAM,MAAM,sBAAsB,GAC9B;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,GAClD;IAAE,OAAO,CAAC,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openbotauth/verifier-client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Client library for verifying Web Bot Auth / OpenBotAuth (RFC 9421) signed HTTP requests",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./express": {
|
|
14
|
+
"types": "./dist/express.d.ts",
|
|
15
|
+
"import": "./dist/express.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc",
|
|
25
|
+
"dev": "tsc --watch",
|
|
26
|
+
"clean": "rm -rf dist",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"webbotauth",
|
|
32
|
+
"web-bot-auth",
|
|
33
|
+
"openbotauth",
|
|
34
|
+
"rfc9421",
|
|
35
|
+
"http-signatures",
|
|
36
|
+
"verification",
|
|
37
|
+
"express",
|
|
38
|
+
"nextjs",
|
|
39
|
+
"middleware",
|
|
40
|
+
"bot-auth",
|
|
41
|
+
"agent-auth",
|
|
42
|
+
"ai-agent"
|
|
43
|
+
],
|
|
44
|
+
"author": "OpenBotAuth",
|
|
45
|
+
"license": "Apache-2.0",
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/OpenBotAuth/openbotauth.git",
|
|
49
|
+
"directory": "packages/verifier-client"
|
|
50
|
+
},
|
|
51
|
+
"homepage": "https://openbotauth.org",
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/OpenBotAuth/openbotauth/issues"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=18.0.0"
|
|
57
|
+
},
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/express": "^4.17.21",
|
|
63
|
+
"@types/node": "^20.14.0",
|
|
64
|
+
"typescript": "^5.4.5",
|
|
65
|
+
"vitest": "^1.6.0"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"express": "^4.x || ^5.x"
|
|
69
|
+
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"express": {
|
|
72
|
+
"optional": true
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|