@stealthmark/next 0.0.0-stage → 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 +202 -0
- package/NOTICE +4 -0
- package/README.md +131 -2
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware.d.ts +79 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +216 -0
- package/dist/middleware.js.map +1 -0
- package/package.json +64 -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/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,132 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @stealthmark/next
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Next.js middleware that detects self-identified AI agents, serves an agent manifest and meters agent traffic.**
|
|
4
|
+
|
|
5
|
+
> Detects only agents that identify themselves. It does not detect stealth bots and is not a security control.
|
|
6
|
+
|
|
7
|
+
By default (`agentPolicy: 'observe'`) your page content is unchanged; `withStealthMark` only adds the informational `x-stealthmark-shield` and `x-stealthmark-agent-policy` response headers to every response of your middleware, human visitors included. Requests from agents that identify themselves are tagged with an `x-stealthmark-agent-detected` response header and, if you set an API key, metered. Agents get the JSON manifest at `/.well-known/agent.json`, or on any path when they send `Accept: application/agent+json`. Set `agentPolicy: 'manifest'` to serve the manifest to detected agents instead of the page, or `'block'` to answer them with 403.
|
|
8
|
+
|
|
9
|
+
The manifest is StealthMark's own format. It is not an A2A Agent Card, an MCP server manifest or an adopted standard.
|
|
10
|
+
|
|
11
|
+
> **Status:** v0.1.0, not published to npm yet. The `npm install` and `npx` commands below will work once it is published; until then build from source as described in the [repository README](https://github.com/Gastonchevarria/stealthmark-sdk#status).
|
|
12
|
+
|
|
13
|
+
## Installation from source
|
|
14
|
+
|
|
15
|
+
Until the first npm release, build the repository and install the tarballs (`@stealthmark/next` depends on `@stealthmark/core`):
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# in a clone of the repository
|
|
19
|
+
npm install && npm run build
|
|
20
|
+
npm pack -w @stealthmark/core -w @stealthmark/next
|
|
21
|
+
# in your project
|
|
22
|
+
npm install /path/to/stealthmark-core-0.1.0.tgz /path/to/stealthmark-next-0.1.0.tgz
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Installation (after the first npm release)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @stealthmark/next @stealthmark/core
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Requires Node.js 20 or newer. The Next.js peer range is 15 or newer; the repository's own development dependency is Next.js 16.
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// middleware.ts
|
|
37
|
+
import { NextResponse } from 'next/server';
|
|
38
|
+
import { withStealthMark } from '@stealthmark/next';
|
|
39
|
+
|
|
40
|
+
export default withStealthMark(() => NextResponse.next(), {
|
|
41
|
+
siteName: 'My SaaS',
|
|
42
|
+
capabilities: [
|
|
43
|
+
{ id: 'search', endpoint: '/api/search', method: 'GET' },
|
|
44
|
+
{ id: 'create-order', endpoint: '/api/orders', method: 'POST', hitl: true },
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const config = {
|
|
49
|
+
matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
|
|
50
|
+
};
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`hitl` is advisory metadata for agents. StealthMark does not block, approve or rate-limit anything; enforce approvals in your own handler.
|
|
54
|
+
|
|
55
|
+
`withStealthMark` runs your own middleware (here, a plain `NextResponse.next()`), keeps its response and adds StealthMark on top. Your site now:
|
|
56
|
+
- Serves the manifest at `/.well-known/agent.json`, and also at `/.well-known/ai-plugin.json` and `/api/agent-manifest`. These paths are answered by the middleware for every visitor, so do not use them for your own routes.
|
|
57
|
+
- Detects agents that identify themselves by Accept header, User-Agent, or `x-stealthmark-agent`
|
|
58
|
+
- Adds an informational `x-stealthmark-shield: ACTIVE` marker header to responses from your middleware (it does not protect anything), plus `x-stealthmark-agent-detected` and `x-stealthmark-agent-id` when an agent is detected
|
|
59
|
+
- Returns CORS-friendly agent manifests. The manifest on the three fixed paths is cacheable (`public, max-age=60, s-maxage=300`); a manifest or 403 chosen from the request headers on any other path is sent with `Cache-Control: private, no-store` and `Vary: accept, user-agent, x-stealthmark-agent`
|
|
60
|
+
|
|
61
|
+
## Composing with Existing Middleware
|
|
62
|
+
|
|
63
|
+
Already have auth, i18n or redirects in `middleware.ts`? Pass that function instead of `() => NextResponse.next()`:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// middleware.ts
|
|
67
|
+
import { withStealthMark } from '@stealthmark/next';
|
|
68
|
+
import { NextResponse } from 'next/server';
|
|
69
|
+
import type { NextRequest } from 'next/server';
|
|
70
|
+
|
|
71
|
+
function myMiddleware(request: NextRequest) {
|
|
72
|
+
// Your existing auth, i18n, etc.
|
|
73
|
+
return NextResponse.next();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default withStealthMark(myMiddleware, {
|
|
77
|
+
siteName: 'My SaaS',
|
|
78
|
+
capabilities: [
|
|
79
|
+
{ id: 'search', endpoint: '/api/search', method: 'GET' },
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
If your middleware returns nothing, Next.js continues the chain untouched and no headers are added to that response.
|
|
85
|
+
|
|
86
|
+
## Minimal Option: Manifest Only
|
|
87
|
+
|
|
88
|
+
`stealthmark()` is the smallest setup. It serves the manifest paths, answers `Accept: application/agent+json` requests and applies `agentPolicy`, and returns nothing for every other request so Next.js serves your page as usual. Because it returns nothing there, it cannot add the marker or detection headers to your pages. Use `withStealthMark` if you want those.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
// middleware.ts
|
|
92
|
+
import { stealthmark } from '@stealthmark/next';
|
|
93
|
+
|
|
94
|
+
export default stealthmark({
|
|
95
|
+
siteName: 'My SaaS',
|
|
96
|
+
capabilities: [{ id: 'search', endpoint: '/api/search', method: 'GET' }],
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Usage metering with StealthMark Cloud (optional)
|
|
101
|
+
|
|
102
|
+
Set an API key to report requests from self-identified agents as usage events to the [StealthMark](https://stealthmark.io) hosted API. Without a key the SDK makes no network calls.
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
export default withStealthMark(() => NextResponse.next(), {
|
|
106
|
+
siteName: 'My SaaS',
|
|
107
|
+
apiKey: process.env.STEALTHMARK_API_KEY, // from your StealthMark console
|
|
108
|
+
siteId: process.env.STEALTHMARK_SITE_ID, // optional, stored as site_id (UUID of a registered site)
|
|
109
|
+
capabilities: [/* ... */],
|
|
110
|
+
onQuotaExceeded: ({ pausedUntil }) => {
|
|
111
|
+
console.warn(`StealthMark reporting paused until ${new Date(pausedUntil).toISOString()}`);
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
What is sent, and where, is listed in the [repository README](https://github.com/Gastonchevarria/stealthmark-sdk#data-sent-to-stealthmark-cloud). The default host is https://stealthmark-api-cifepjj5ca-uc.a.run.app; override it with `usageEndpoint` or `STEALTHMARK_USAGE_ENDPOINT`. Identification is self-declared, and events are reported best-effort and can be dropped.
|
|
117
|
+
|
|
118
|
+
### Several sites, one API key
|
|
119
|
+
|
|
120
|
+
Every metered event carries `metadata.host`, the host the agent requested (the `Host` header, lowercased, no port). The console groups and filters agent traffic by `metadata.host`, so no configuration is needed to tell your sites apart.
|
|
121
|
+
|
|
122
|
+
`siteId` (or the `STEALTHMARK_SITE_ID` environment variable) is optional. It is only stored on the event as `site_id`, and it must be the UUID of a site registered to the same organization; otherwise it is stored as null.
|
|
123
|
+
|
|
124
|
+
Behind a proxy you control that rewrites the host, set `trustForwardedHost: true` to read the first `X-Forwarded-Host` value instead of `Host`. It is off by default because that header is client controlled; on most hosting platforms `Host` is already the public host.
|
|
125
|
+
|
|
126
|
+
## Route discovery
|
|
127
|
+
|
|
128
|
+
`discoverCapabilities()` (re-exported from `@stealthmark/core`) lists App Router `route.ts` handlers under `app/api` as capabilities. It needs Node (`fs`): do not call it from Edge or browser code, for example inside `middleware.ts`.
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
Apache 2.0, see [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { stealthmark, withStealthMark, defaultMatcher } from './middleware.js';
|
|
2
|
+
export type { NextLikeRequest } from './middleware.js';
|
|
3
|
+
export { discoverCapabilities } from '@stealthmark/core';
|
|
4
|
+
export type { StealthMarkConfig, Capability, HttpMethod, AgentManifest, DetectionResult, RouteDiscoveryOptions, } from '@stealthmark/core';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC/E,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGzD,YAAY,EACV,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,aAAa,EACb,eAAe,EACf,qBAAqB,GACtB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
2
|
+
// @stealthmark/next — Public API
|
|
3
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
4
|
+
export { stealthmark, withStealthMark, defaultMatcher } from './middleware.js';
|
|
5
|
+
export { discoverCapabilities } from '@stealthmark/core';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,iCAAiC;AACjC,sEAAsE;AAEtE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { StealthMarkConfig } from '@stealthmark/core';
|
|
2
|
+
/** Minimal type for Next.js request (avoids hard dependency on next types) */
|
|
3
|
+
export interface NextLikeRequest {
|
|
4
|
+
headers: Headers;
|
|
5
|
+
nextUrl?: {
|
|
6
|
+
pathname: string;
|
|
7
|
+
};
|
|
8
|
+
url?: string;
|
|
9
|
+
method?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Subset of Next.js `NextFetchEvent`: lets the usage flush outlive the response on edge runtimes. */
|
|
12
|
+
interface NextLikeFetchEvent {
|
|
13
|
+
waitUntil?: (promise: Promise<unknown>) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates the minimal, manifest-only Next.js middleware.
|
|
17
|
+
*
|
|
18
|
+
* It answers the manifest paths, `Accept: application/agent+json` requests and the
|
|
19
|
+
* configured `agentPolicy` ('manifest' or 'block'), and meters agent requests.
|
|
20
|
+
* For every other request it returns `undefined`, so Next.js continues the chain and
|
|
21
|
+
* serves your page untouched. Because nothing is returned, it cannot add the marker or
|
|
22
|
+
* detection headers to those pages: use `withStealthMark` when you want them.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // middleware.ts
|
|
27
|
+
* import { stealthmark } from '@stealthmark/next';
|
|
28
|
+
*
|
|
29
|
+
* export default stealthmark({
|
|
30
|
+
* siteName: 'My SaaS',
|
|
31
|
+
* capabilities: [
|
|
32
|
+
* { id: 'search', endpoint: '/api/search', method: 'GET' },
|
|
33
|
+
* ],
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* export const config = {
|
|
37
|
+
* matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
|
|
38
|
+
* };
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param config - StealthMark SDK configuration
|
|
42
|
+
* @returns A Next.js middleware function
|
|
43
|
+
*/
|
|
44
|
+
export declare function stealthmark(config: StealthMarkConfig): (request: NextLikeRequest, event?: NextLikeFetchEvent) => Response | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Higher-order middleware wrapper for use with existing Next.js middleware.
|
|
47
|
+
*
|
|
48
|
+
* This is the recommended entry point. It runs your middleware (use
|
|
49
|
+
* `() => NextResponse.next()` when you have none), keeps its response, and stamps
|
|
50
|
+
* the `x-stealthmark-*` marker headers plus the agent detection headers on it. Manifest and block
|
|
51
|
+
* responses are served before your middleware runs. If your middleware returns
|
|
52
|
+
* nothing, the chain continues untouched and no headers are added.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* // middleware.ts
|
|
57
|
+
* import { withStealthMark } from '@stealthmark/next';
|
|
58
|
+
* import { NextResponse } from 'next/server';
|
|
59
|
+
* import type { NextRequest } from 'next/server';
|
|
60
|
+
*
|
|
61
|
+
* function myMiddleware(request: NextRequest) {
|
|
62
|
+
* // Your existing middleware logic
|
|
63
|
+
* return NextResponse.next();
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* export default withStealthMark(myMiddleware, {
|
|
67
|
+
* siteName: 'My SaaS',
|
|
68
|
+
* capabilities: [...],
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function withStealthMark<Req extends NextLikeRequest = NextLikeRequest>(existingMiddleware: (request: Req) => Response | undefined | Promise<Response | undefined>, config: StealthMarkConfig): (request: Req, event?: NextLikeFetchEvent) => Promise<Response | undefined>;
|
|
73
|
+
/**
|
|
74
|
+
* Recommended `config.matcher` for the middleware.
|
|
75
|
+
* Excludes static assets and internal Next.js routes.
|
|
76
|
+
*/
|
|
77
|
+
export declare const defaultMatcher: string[];
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAmB,iBAAiB,EAAuB,MAAM,mBAAmB,CAAC;AAEjG,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,sGAAsG;AACtG,UAAU,kBAAkB;IAC1B,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;CACjD;AAyBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,iBAAiB,IAGxB,SAAS,eAAe,EAAE,QAAQ,kBAAkB,KAAG,QAAQ,GAAG,SAAS,CAevG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,eAAe,CAAC,GAAG,SAAS,eAAe,GAAG,eAAe,EAC3E,kBAAkB,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,EAC1F,MAAM,EAAE,iBAAiB,IAIQ,SAAS,GAAG,EAAE,QAAQ,kBAAkB,KAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAoB1G;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,UAAoD,CAAC"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
2
|
+
// @stealthmark/next — Next.js Middleware
|
|
3
|
+
// Detects self-identified AI agents, serves an agent manifest and meters agent traffic
|
|
4
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
5
|
+
//
|
|
6
|
+
// Usage in your middleware.ts (recommended: withStealthMark keeps your own
|
|
7
|
+
// middleware and stamps the StealthMark marker and detection headers on its response):
|
|
8
|
+
//
|
|
9
|
+
// import { NextResponse } from 'next/server';
|
|
10
|
+
// import { withStealthMark } from '@stealthmark/next';
|
|
11
|
+
//
|
|
12
|
+
// export default withStealthMark(() => NextResponse.next(), {
|
|
13
|
+
// siteName: 'My SaaS',
|
|
14
|
+
// capabilities: [
|
|
15
|
+
// { id: 'search', endpoint: '/api/search', method: 'GET' },
|
|
16
|
+
// { id: 'create-order', endpoint: '/api/orders', method: 'POST', hitl: true },
|
|
17
|
+
// ],
|
|
18
|
+
// });
|
|
19
|
+
//
|
|
20
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
21
|
+
import { buildEventMetadata, createStealthMark, resolveAgentIdentifier, resolveRequestHost } from '@stealthmark/core';
|
|
22
|
+
/**
|
|
23
|
+
* Well-known paths where agent manifests are conventionally served.
|
|
24
|
+
* The middleware intercepts these paths and serves the manifest automatically.
|
|
25
|
+
*/
|
|
26
|
+
const MANIFEST_PATHS = new Set([
|
|
27
|
+
'/.well-known/agent.json',
|
|
28
|
+
'/.well-known/ai-plugin.json',
|
|
29
|
+
'/api/agent-manifest',
|
|
30
|
+
]);
|
|
31
|
+
/** The manifest at a fixed path is the same for every caller, so shared caches may keep it for a few minutes. */
|
|
32
|
+
const MANIFEST_CACHE_CONTROL = 'public, max-age=60, s-maxage=300';
|
|
33
|
+
/**
|
|
34
|
+
* A response chosen from the request headers (a manifest on an ordinary path, or the block 403) must never be stored as
|
|
35
|
+
* the answer for that URL: it is private, and the headers that decided it are named in Vary.
|
|
36
|
+
*/
|
|
37
|
+
const NEGOTIATED_CACHE_CONTROL = 'private, no-store';
|
|
38
|
+
const NEGOTIATED_VARY = 'accept, user-agent, x-stealthmark-agent';
|
|
39
|
+
/**
|
|
40
|
+
* Creates the minimal, manifest-only Next.js middleware.
|
|
41
|
+
*
|
|
42
|
+
* It answers the manifest paths, `Accept: application/agent+json` requests and the
|
|
43
|
+
* configured `agentPolicy` ('manifest' or 'block'), and meters agent requests.
|
|
44
|
+
* For every other request it returns `undefined`, so Next.js continues the chain and
|
|
45
|
+
* serves your page untouched. Because nothing is returned, it cannot add the marker or
|
|
46
|
+
* detection headers to those pages: use `withStealthMark` when you want them.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // middleware.ts
|
|
51
|
+
* import { stealthmark } from '@stealthmark/next';
|
|
52
|
+
*
|
|
53
|
+
* export default stealthmark({
|
|
54
|
+
* siteName: 'My SaaS',
|
|
55
|
+
* capabilities: [
|
|
56
|
+
* { id: 'search', endpoint: '/api/search', method: 'GET' },
|
|
57
|
+
* ],
|
|
58
|
+
* });
|
|
59
|
+
*
|
|
60
|
+
* export const config = {
|
|
61
|
+
* matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
|
|
62
|
+
* };
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @param config - StealthMark SDK configuration
|
|
66
|
+
* @returns A Next.js middleware function
|
|
67
|
+
*/
|
|
68
|
+
export function stealthmark(config) {
|
|
69
|
+
const sm = createStealthMark(config);
|
|
70
|
+
return function middleware(request, event) {
|
|
71
|
+
const pathname = request.nextUrl?.pathname ?? new URL(request.url ?? '/', 'http://localhost').pathname;
|
|
72
|
+
const detection = sm.detect(request.headers);
|
|
73
|
+
const handling = decideAgentHandling(sm, request, detection, pathname);
|
|
74
|
+
if (detection.isAgent) {
|
|
75
|
+
meterAgentRequest(sm, request, detection, pathname, handling);
|
|
76
|
+
scheduleUsageFlush(sm, event);
|
|
77
|
+
}
|
|
78
|
+
if (handling === 'manifest')
|
|
79
|
+
return createAgentResponse(sm.manifestJson, sm.responseHeaders, detection, !MANIFEST_PATHS.has(pathname));
|
|
80
|
+
if (handling === 'block')
|
|
81
|
+
return createBlockedResponse(sm.responseHeaders);
|
|
82
|
+
return undefined;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Higher-order middleware wrapper for use with existing Next.js middleware.
|
|
87
|
+
*
|
|
88
|
+
* This is the recommended entry point. It runs your middleware (use
|
|
89
|
+
* `() => NextResponse.next()` when you have none), keeps its response, and stamps
|
|
90
|
+
* the `x-stealthmark-*` marker headers plus the agent detection headers on it. Manifest and block
|
|
91
|
+
* responses are served before your middleware runs. If your middleware returns
|
|
92
|
+
* nothing, the chain continues untouched and no headers are added.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* // middleware.ts
|
|
97
|
+
* import { withStealthMark } from '@stealthmark/next';
|
|
98
|
+
* import { NextResponse } from 'next/server';
|
|
99
|
+
* import type { NextRequest } from 'next/server';
|
|
100
|
+
*
|
|
101
|
+
* function myMiddleware(request: NextRequest) {
|
|
102
|
+
* // Your existing middleware logic
|
|
103
|
+
* return NextResponse.next();
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* export default withStealthMark(myMiddleware, {
|
|
107
|
+
* siteName: 'My SaaS',
|
|
108
|
+
* capabilities: [...],
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export function withStealthMark(existingMiddleware, config) {
|
|
113
|
+
const sm = createStealthMark(config);
|
|
114
|
+
return async function middleware(request, event) {
|
|
115
|
+
const pathname = request.nextUrl?.pathname ?? new URL(request.url ?? '/', 'http://localhost').pathname;
|
|
116
|
+
const detection = sm.detect(request.headers);
|
|
117
|
+
const handling = decideAgentHandling(sm, request, detection, pathname);
|
|
118
|
+
if (detection.isAgent) {
|
|
119
|
+
meterAgentRequest(sm, request, detection, pathname, handling);
|
|
120
|
+
scheduleUsageFlush(sm, event);
|
|
121
|
+
}
|
|
122
|
+
if (handling === 'manifest')
|
|
123
|
+
return createAgentResponse(sm.manifestJson, sm.responseHeaders, detection, !MANIFEST_PATHS.has(pathname));
|
|
124
|
+
if (handling === 'block')
|
|
125
|
+
return createBlockedResponse(sm.responseHeaders);
|
|
126
|
+
// Observe: the site answers normally; agents only get tagged
|
|
127
|
+
const response = await existingMiddleware(request);
|
|
128
|
+
if (response === undefined)
|
|
129
|
+
return undefined;
|
|
130
|
+
applyHeaders(response, sm.responseHeaders);
|
|
131
|
+
if (detection.isAgent)
|
|
132
|
+
applyDetectionHeaders(response, detection);
|
|
133
|
+
return response;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Recommended `config.matcher` for the middleware.
|
|
138
|
+
* Excludes static assets and internal Next.js routes.
|
|
139
|
+
*/
|
|
140
|
+
export const defaultMatcher = ['/((?!_next/static|_next/image|favicon.ico).*)'];
|
|
141
|
+
// ── Internal Helpers ─────────────────────────────────────────────
|
|
142
|
+
/**
|
|
143
|
+
* Meters one agent request through the usage reporter.
|
|
144
|
+
*/
|
|
145
|
+
function meterAgentRequest(sm, request, detection, pathname, handling) {
|
|
146
|
+
const eventType = MANIFEST_PATHS.has(pathname) ? 'agent_manifest' : handling === 'block' ? 'agent_blocked' : 'agent_request';
|
|
147
|
+
sm.recordAgentEvent({
|
|
148
|
+
event_type: eventType,
|
|
149
|
+
agent_identifier: resolveAgentIdentifier(request.headers, detection),
|
|
150
|
+
metadata: buildEventMetadata({
|
|
151
|
+
path: pathname,
|
|
152
|
+
method: request.method ?? 'GET',
|
|
153
|
+
host: resolveRequestHost(request.headers, { trustForwardedHost: sm.trustForwardedHost }),
|
|
154
|
+
}),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/** Manifest paths and explicit `Accept: application/agent+json` always win; then the configured policy decides. */
|
|
158
|
+
function decideAgentHandling(sm, request, detection, pathname) {
|
|
159
|
+
if (MANIFEST_PATHS.has(pathname))
|
|
160
|
+
return 'manifest';
|
|
161
|
+
if (!detection.isAgent)
|
|
162
|
+
return 'passthrough';
|
|
163
|
+
if ((request.headers.get('accept') ?? '').includes('application/agent+json'))
|
|
164
|
+
return 'manifest';
|
|
165
|
+
if (sm.agentPolicy === 'block')
|
|
166
|
+
return 'block';
|
|
167
|
+
if (sm.agentPolicy === 'manifest')
|
|
168
|
+
return 'manifest';
|
|
169
|
+
return 'passthrough';
|
|
170
|
+
}
|
|
171
|
+
/** On edge runtimes the response may end before the batched usage POST; `waitUntil` keeps it alive. */
|
|
172
|
+
function scheduleUsageFlush(sm, event) {
|
|
173
|
+
if (event?.waitUntil && sm.usage.active) {
|
|
174
|
+
event.waitUntil(sm.usage.flush());
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function applyHeaders(response, headers) {
|
|
178
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
179
|
+
response.headers.set(key, value);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function applyDetectionHeaders(response, detection) {
|
|
183
|
+
response.headers.set('x-stealthmark-agent-detected', 'true');
|
|
184
|
+
if (detection.agentId)
|
|
185
|
+
response.headers.set('x-stealthmark-agent-id', detection.agentId);
|
|
186
|
+
}
|
|
187
|
+
function createBlockedResponse(headers) {
|
|
188
|
+
const response = new Response(JSON.stringify({ error: 'agent_blocked', message: 'This site does not accept automated agent traffic.' }), {
|
|
189
|
+
status: 403,
|
|
190
|
+
headers: {
|
|
191
|
+
'content-type': 'application/json; charset=utf-8',
|
|
192
|
+
'cache-control': NEGOTIATED_CACHE_CONTROL,
|
|
193
|
+
vary: NEGOTIATED_VARY,
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
applyHeaders(response, headers);
|
|
197
|
+
return response;
|
|
198
|
+
}
|
|
199
|
+
function createAgentResponse(manifestJson, headers, detection, negotiated) {
|
|
200
|
+
const response = new Response(manifestJson, {
|
|
201
|
+
status: 200,
|
|
202
|
+
headers: {
|
|
203
|
+
'content-type': 'application/agent+json; charset=utf-8',
|
|
204
|
+
'access-control-allow-origin': '*',
|
|
205
|
+
'access-control-allow-headers': '*',
|
|
206
|
+
'cache-control': negotiated ? NEGOTIATED_CACHE_CONTROL : MANIFEST_CACHE_CONTROL,
|
|
207
|
+
...(negotiated ? { vary: NEGOTIATED_VARY } : {}),
|
|
208
|
+
'x-stealthmark-route': 'DUAL_DOOR_AGENT_FASTPATH',
|
|
209
|
+
...headers,
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
if (detection.isAgent)
|
|
213
|
+
applyDetectionHeaders(response, detection);
|
|
214
|
+
return response;
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,yCAAyC;AACzC,uFAAuF;AACvF,sEAAsE;AACtE,EAAE;AACF,2EAA2E;AAC3E,uFAAuF;AACvF,EAAE;AACF,gDAAgD;AAChD,yDAAyD;AACzD,EAAE;AACF,gEAAgE;AAChE,2BAA2B;AAC3B,sBAAsB;AACtB,kEAAkE;AAClE,qFAAqF;AACrF,SAAS;AACT,QAAQ;AACR,EAAE;AACF,sEAAsE;AAEtE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,s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AE,iCAAiC;YACjD,eAAe,EAAE,wBAAwB;YACzC,IAAI,EAAE,eAAe;SACtB;KACF,CACF,CAAC;IACF,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,mBAAmB,CAC1B,YAAoB,EACpB,OAA+B,EAC/B,SAA0B,EAC1B,UAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,YAAY,EAAE;QAC1C,MAAM,EAAE,GAAG;QACX,OAAO,EAAE;YACP,cAAc,EAAE,uCAAuC;YACvD,6BAA6B,EAAE,GAAG;YAClC,8BAA8B,EAAE,GAAG;YACnC,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,sBAAsB;YAC/E,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAChD,qBAAqB,EAAE,0BAA0B;YACjD,GAAG,OAAO;SACX;KACF,CAAC,CAAC;IACH,IAAI,SAAS,CAAC,OAAO;QAAE,qBAAqB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAClE,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stealthmark/next",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Next.js middleware that detects self-identified AI agents, serves an agent manifest and meters agent traffic",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"NOTICE"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc --project tsconfig.build.json",
|
|
25
|
+
"dev": "tsc --project tsconfig.build.json --watch",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"clean": "rm -rf dist tsconfig.build.tsbuildinfo"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"nextjs",
|
|
32
|
+
"middleware",
|
|
33
|
+
"ai-agents",
|
|
34
|
+
"agent-manifest",
|
|
35
|
+
"stealthmark",
|
|
36
|
+
"vercel",
|
|
37
|
+
"edge"
|
|
38
|
+
],
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"next": ">=15"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@stealthmark/core": "^0.1.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"next": "^16.3.0",
|
|
47
|
+
"typescript": "^5.7.0",
|
|
48
|
+
"vitest": "^4.1.11"
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/Gastonchevarria/stealthmark-sdk.git",
|
|
53
|
+
"directory": "packages/next"
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://stealthmark.io",
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=20"
|
|
58
|
+
},
|
|
59
|
+
"bugs": {
|
|
60
|
+
"url": "https://github.com/Gastonchevarria/stealthmark-sdk/issues"
|
|
61
|
+
},
|
|
62
|
+
"author": "Gaston Chevarria <gaston_ch27@hotmail.com>",
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public"
|
|
65
|
+
}
|
|
66
|
+
}
|