dbsc-toolkit 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +132 -0
- package/README.md +205 -0
- package/dist/client/detect.d.ts +3 -0
- package/dist/client/detect.d.ts.map +1 -0
- package/dist/client/detect.js +20 -0
- package/dist/client/detect.js.map +1 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +4 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/signals.d.ts +9 -0
- package/dist/client/signals.d.ts.map +1 -0
- package/dist/client/signals.js +13 -0
- package/dist/client/signals.js.map +1 -0
- package/dist/client/webauthn.d.ts +3 -0
- package/dist/client/webauthn.d.ts.map +1 -0
- package/dist/client/webauthn.js +8 -0
- package/dist/client/webauthn.js.map +1 -0
- package/dist/core/crypto/jwk.d.ts +3 -0
- package/dist/core/crypto/jwk.d.ts.map +1 -0
- package/dist/core/crypto/jwk.js +36 -0
- package/dist/core/crypto/jwk.js.map +1 -0
- package/dist/core/crypto/jws.d.ts +15 -0
- package/dist/core/crypto/jws.d.ts.map +1 -0
- package/dist/core/crypto/jws.js +89 -0
- package/dist/core/crypto/jws.js.map +1 -0
- package/dist/core/errors.d.ts +27 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +39 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/fallback/hmac.d.ts +9 -0
- package/dist/core/fallback/hmac.d.ts.map +1 -0
- package/dist/core/fallback/hmac.js +37 -0
- package/dist/core/fallback/hmac.js.map +1 -0
- package/dist/core/fallback/negotiate.d.ts +9 -0
- package/dist/core/fallback/negotiate.d.ts.map +1 -0
- package/dist/core/fallback/negotiate.js +22 -0
- package/dist/core/fallback/negotiate.js.map +1 -0
- package/dist/core/fallback/webauthn.d.ts +10 -0
- package/dist/core/fallback/webauthn.d.ts.map +1 -0
- package/dist/core/fallback/webauthn.js +41 -0
- package/dist/core/fallback/webauthn.js.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/protocol/challenge.d.ts +4 -0
- package/dist/core/protocol/challenge.d.ts.map +1 -0
- package/dist/core/protocol/challenge.js +18 -0
- package/dist/core/protocol/challenge.js.map +1 -0
- package/dist/core/protocol/headers.d.ts +21 -0
- package/dist/core/protocol/headers.d.ts.map +1 -0
- package/dist/core/protocol/headers.js +33 -0
- package/dist/core/protocol/headers.js.map +1 -0
- package/dist/core/protocol/refresh.d.ts +8 -0
- package/dist/core/protocol/refresh.d.ts.map +1 -0
- package/dist/core/protocol/refresh.js +37 -0
- package/dist/core/protocol/refresh.js.map +1 -0
- package/dist/core/protocol/registration.d.ts +11 -0
- package/dist/core/protocol/registration.d.ts.map +1 -0
- package/dist/core/protocol/registration.js +40 -0
- package/dist/core/protocol/registration.js.map +1 -0
- package/dist/core/ratelimit/interface.d.ts +7 -0
- package/dist/core/ratelimit/interface.d.ts.map +1 -0
- package/dist/core/ratelimit/interface.js +11 -0
- package/dist/core/ratelimit/interface.js.map +1 -0
- package/dist/core/telemetry/hooks.d.ts +4 -0
- package/dist/core/telemetry/hooks.d.ts.map +1 -0
- package/dist/core/telemetry/hooks.js +11 -0
- package/dist/core/telemetry/hooks.js.map +1 -0
- package/dist/core/testing/memory-storage-stub.d.ts +18 -0
- package/dist/core/testing/memory-storage-stub.d.ts.map +1 -0
- package/dist/core/testing/memory-storage-stub.js +50 -0
- package/dist/core/testing/memory-storage-stub.js.map +1 -0
- package/dist/core/types.d.ts +92 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/express/index.d.ts +20 -0
- package/dist/express/index.d.ts.map +1 -0
- package/dist/express/index.js +217 -0
- package/dist/express/index.js.map +1 -0
- package/dist/fastify/index.d.ts +17 -0
- package/dist/fastify/index.d.ts.map +1 -0
- package/dist/fastify/index.js +115 -0
- package/dist/fastify/index.js.map +1 -0
- package/dist/hono/index.d.ts +13 -0
- package/dist/hono/index.d.ts.map +1 -0
- package/dist/hono/index.js +107 -0
- package/dist/hono/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/nextjs/index.d.ts +13 -0
- package/dist/nextjs/index.d.ts.map +1 -0
- package/dist/nextjs/index.js +126 -0
- package/dist/nextjs/index.js.map +1 -0
- package/dist/storage/memory/index.d.ts +20 -0
- package/dist/storage/memory/index.d.ts.map +1 -0
- package/dist/storage/memory/index.js +79 -0
- package/dist/storage/memory/index.js.map +1 -0
- package/dist/storage/postgres/index.d.ts +19 -0
- package/dist/storage/postgres/index.d.ts.map +1 -0
- package/dist/storage/postgres/index.js +89 -0
- package/dist/storage/postgres/index.js.map +1 -0
- package/dist/storage/redis/index.d.ts +18 -0
- package/dist/storage/redis/index.d.ts.map +1 -0
- package/dist/storage/redis/index.js +88 -0
- package/dist/storage/redis/index.js.map +1 -0
- package/migrations/001_initial.sql +41 -0
- package/package.json +124 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
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.
|
|
18
|
+
|
|
19
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
20
|
+
exercising permissions granted by this License.
|
|
21
|
+
|
|
22
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
23
|
+
including but not limited to software source code, documentation
|
|
24
|
+
source, and configuration files.
|
|
25
|
+
|
|
26
|
+
"Object" form shall mean any form resulting from mechanical
|
|
27
|
+
transformation or translation of a Source form, including but
|
|
28
|
+
not limited to compiled object code, generated documentation,
|
|
29
|
+
and conversions to other media types.
|
|
30
|
+
|
|
31
|
+
"Work" shall mean the work of authorship made available under
|
|
32
|
+
the License, as indicated by a copyright notice that is included in
|
|
33
|
+
or attached to the work.
|
|
34
|
+
|
|
35
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
36
|
+
form, that is based on (or derived from) the Work and for which the
|
|
37
|
+
editorial revisions, annotations, elaborations, or other transformations
|
|
38
|
+
represent, as a whole, an original work of authorship.
|
|
39
|
+
|
|
40
|
+
"Contribution" shall mean any work of authorship, including
|
|
41
|
+
the original version of the Work and any modifications or additions
|
|
42
|
+
to that Work or Derivative Works of the Work, that is intentionally
|
|
43
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
44
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
45
|
+
the copyright owner.
|
|
46
|
+
|
|
47
|
+
"Contributor" shall mean Licensor and any Legal Entity
|
|
48
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
49
|
+
subsequently incorporated within the Work.
|
|
50
|
+
|
|
51
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
52
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
53
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
54
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
55
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
56
|
+
Work and such Derivative Works in Source or Object form.
|
|
57
|
+
|
|
58
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
59
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
60
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
61
|
+
(except as stated in this section) patent license to make, have made,
|
|
62
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
63
|
+
where such license applies only to those patent claims licensable
|
|
64
|
+
by such Contributor that are necessarily infringed by their
|
|
65
|
+
Contribution(s) alone or by the combined work of their Contribution(s)
|
|
66
|
+
with the Work to which such Contribution(s) was submitted.
|
|
67
|
+
|
|
68
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
69
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
70
|
+
modifications, and in Source or Object form, provided that You
|
|
71
|
+
meet the following conditions:
|
|
72
|
+
|
|
73
|
+
(a) You must give any other recipients of the Work or Derivative Works
|
|
74
|
+
a copy of this License; and
|
|
75
|
+
|
|
76
|
+
(b) You must cause any modified files to carry prominent notices
|
|
77
|
+
stating that You changed the files; and
|
|
78
|
+
|
|
79
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
80
|
+
that You distribute, all copyright, patent, trademark, and
|
|
81
|
+
attribution notices from the Source form of the Work; and
|
|
82
|
+
|
|
83
|
+
(d) If the Work includes a "NOTICE" text file, you must include a
|
|
84
|
+
readable copy of the attribution notices contained within such NOTICE
|
|
85
|
+
file, in at least one of the following places: within a NOTICE text
|
|
86
|
+
file distributed as part of the Derivative Works; or, within the
|
|
87
|
+
Source form or documentation, if provided along with the Derivative
|
|
88
|
+
Works; or, on a display generated by the Derivative Works.
|
|
89
|
+
|
|
90
|
+
The "NOTICE" file referenced above refers to a text file that may
|
|
91
|
+
accompany the source form of the Work.
|
|
92
|
+
|
|
93
|
+
You may add Your own attribution notices within Derivative Works
|
|
94
|
+
that You distribute, alongside or as an addendum to the NOTICE text
|
|
95
|
+
from the Work, provided that such additional attribution notices
|
|
96
|
+
cannot be construed as modifying the License.
|
|
97
|
+
|
|
98
|
+
You may add Your own license statement for Your modifications and
|
|
99
|
+
may provide additional grant of rights to use, reproduce, or
|
|
100
|
+
distribute Derivative Works, subject to the terms and conditions
|
|
101
|
+
for the Work itself.
|
|
102
|
+
|
|
103
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
104
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
105
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
106
|
+
this License, without any additional terms or conditions.
|
|
107
|
+
|
|
108
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
109
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
110
|
+
|
|
111
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
112
|
+
agreed to in writing, Licensor provides the Work (and each Contributor
|
|
113
|
+
provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
|
|
114
|
+
OR CONDITIONS OF ANY KIND, either express or implied, including,
|
|
115
|
+
without limitation, any warranties or conditions of TITLE,
|
|
116
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
|
117
|
+
|
|
118
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
119
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
120
|
+
unless required by applicable law (such as deliberate and grossly
|
|
121
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
122
|
+
liable to You for damages, including any direct, indirect, special,
|
|
123
|
+
incidental, or exemplary damages of any character arising as a
|
|
124
|
+
result of this License or out of the use or inability to use the
|
|
125
|
+
Work.
|
|
126
|
+
|
|
127
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
128
|
+
the Work or Derivative Works thereof, You may choose to offer, and
|
|
129
|
+
charge a fee for, acceptance of support, warranty, indemnity,
|
|
130
|
+
or other liability obligations and/or rights consistent with this License.
|
|
131
|
+
|
|
132
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# DBSC Toolkit
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/dbsc-toolkit)
|
|
4
|
+
[](https://github.com/SulimanAbdulrazzaq/dbsc-toolkit/actions/workflows/ci.yml)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
[](https://nodejs.org)
|
|
7
|
+
|
|
8
|
+
Server-side implementation of [Device Bound Session Credentials](https://w3c.github.io/webappsec-dbsc/) (DBSC) for Node.js.
|
|
9
|
+
|
|
10
|
+
DBSC is a W3C draft that binds session cookies to a hardware-resident private key inside the browser. A stolen cookie is useless without that key — which never leaves the user's device.
|
|
11
|
+
|
|
12
|
+
Chrome 147+ supports DBSC natively. This library handles the server side. Verified end-to-end against Chrome 147 on Windows.
|
|
13
|
+
|
|
14
|
+
## Live demo
|
|
15
|
+
|
|
16
|
+
Try it: <https://dbsctest-production.up.railway.app/>
|
|
17
|
+
|
|
18
|
+
Open in Chrome 147+, click **Login**, then **Check session** — `tier` reads `"dbsc"` once the TPM key is bound. Use **Clear cookies** to reset and replay the flow. Source in [examples/express/](./examples/express/).
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
npm install dbsc-toolkit
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then install whichever framework and storage you actually use. Each is an optional peer dependency — install only what you need.
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
# Express + in-memory storage (dev)
|
|
30
|
+
npm install express cookie-parser
|
|
31
|
+
|
|
32
|
+
# Or with Redis storage
|
|
33
|
+
npm install express cookie-parser ioredis
|
|
34
|
+
|
|
35
|
+
# Or with Postgres storage
|
|
36
|
+
npm install express cookie-parser pg
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Quick start — Express
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import express from "express";
|
|
43
|
+
import cookieParser from "cookie-parser";
|
|
44
|
+
import { dbsc } from "dbsc-toolkit/express";
|
|
45
|
+
import { MemoryStorage } from "dbsc-toolkit/storage/memory";
|
|
46
|
+
|
|
47
|
+
const app = express();
|
|
48
|
+
app.use(cookieParser());
|
|
49
|
+
app.use(dbsc({ storage: new MemoryStorage() }));
|
|
50
|
+
|
|
51
|
+
app.get("/me", (req, res) => {
|
|
52
|
+
res.json(res.locals.dbsc);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
app.listen(3000);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
That single `app.use(dbsc(...))` mounts `POST /dbsc/registration` and `POST /dbsc/refresh` automatically. Chrome drives both — your application code never sees those requests.
|
|
59
|
+
|
|
60
|
+
A full `/login` flow with cookie issuance is in [examples/express/src/server.js](./examples/express/src/server.js).
|
|
61
|
+
|
|
62
|
+
## Subpath imports
|
|
63
|
+
|
|
64
|
+
| Import | What it is |
|
|
65
|
+
|--------|------------|
|
|
66
|
+
| `dbsc-toolkit` | Core types, crypto, protocol functions |
|
|
67
|
+
| `dbsc-toolkit/express` | Express middleware |
|
|
68
|
+
| `dbsc-toolkit/fastify` | Fastify plugin |
|
|
69
|
+
| `dbsc-toolkit/hono` | Hono middleware |
|
|
70
|
+
| `dbsc-toolkit/nextjs` | Next.js App Router middleware + handlers |
|
|
71
|
+
| `dbsc-toolkit/client` | Browser SDK for fallback paths |
|
|
72
|
+
| `dbsc-toolkit/storage/memory` | In-memory storage (dev/test) |
|
|
73
|
+
| `dbsc-toolkit/storage/redis` | Redis storage |
|
|
74
|
+
| `dbsc-toolkit/storage/postgres` | Postgres storage |
|
|
75
|
+
|
|
76
|
+
Tree-shaking eliminates anything you don't import.
|
|
77
|
+
|
|
78
|
+
## How a verified flow looks
|
|
79
|
+
|
|
80
|
+
1. User hits `POST /login`. Server creates a session, issues a challenge, sets `Secure-Session-Registration` response header and two short-lived cookies (`__Host-dbsc-reg`, `__Host-dbsc-challenge`).
|
|
81
|
+
2. Chrome immediately POSTs to `/dbsc/registration` with `Secure-Session-Response: <jws>`. The JWS carries the device public key signed by the matching private key (TPM).
|
|
82
|
+
3. Middleware verifies the JWS, stores the public key bound to the session, sets `__Host-dbsc-session` cookie, returns DBSC session config JSON.
|
|
83
|
+
4. From now on, every refresh cycle (default 10 min) Chrome signs a fresh challenge with the TPM key. A copied cookie cannot pass refresh — the attacker has no key.
|
|
84
|
+
|
|
85
|
+
`tier` on `res.locals.dbsc` reads `"dbsc"` once registration completes.
|
|
86
|
+
|
|
87
|
+
## Local testing
|
|
88
|
+
|
|
89
|
+
You need HTTPS — `__Host-` cookies require it and Chrome rejects DBSC on plain HTTP. Two options:
|
|
90
|
+
|
|
91
|
+
- Deploy somewhere that gives you HTTPS (Railway, Fly, Render, Cloudflare Tunnel). Easiest path. We tested against Railway successfully.
|
|
92
|
+
- Run `local-ssl-proxy --source 3001 --target 3000` in front of your local server.
|
|
93
|
+
|
|
94
|
+
A working demo is in [examples/express/](./examples/express/).
|
|
95
|
+
|
|
96
|
+
## Framework support
|
|
97
|
+
|
|
98
|
+
The library has two layers:
|
|
99
|
+
|
|
100
|
+
**Core (`dbsc-toolkit`)** — pure protocol. No framework deps. Functions in, plain data out. Works anywhere Node.js runs.
|
|
101
|
+
|
|
102
|
+
**Adapters** — thin wrappers for specific frameworks. Four shipped: Express, Fastify, Hono, Next.js.
|
|
103
|
+
|
|
104
|
+
If you use Koa, Hapi, raw `http`, Bun, or Deno — call core directly:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import {
|
|
108
|
+
handleRefresh,
|
|
109
|
+
handleRegistration,
|
|
110
|
+
issueChallenge,
|
|
111
|
+
readSessionResponseHeader,
|
|
112
|
+
} from "dbsc-toolkit";
|
|
113
|
+
|
|
114
|
+
const result = await handleRefresh({
|
|
115
|
+
sessionId: getCookie(req, "__Host-dbsc-session"),
|
|
116
|
+
secSessionResponseHeader: readSessionResponseHeader(req.headers),
|
|
117
|
+
expectedJti: getCookie(req, "__Host-dbsc-challenge"),
|
|
118
|
+
}, storage);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`readSessionResponseHeader` reads `Secure-Session-Response` (the current spec name) with fallback to `Sec-Session-Response` (the legacy name) for older Chrome builds.
|
|
122
|
+
|
|
123
|
+
## Protection tiers
|
|
124
|
+
|
|
125
|
+
The library negotiates the strongest available binding per session:
|
|
126
|
+
|
|
127
|
+
| Tier | Mechanism | Protection |
|
|
128
|
+
|------|-----------|------------|
|
|
129
|
+
| `dbsc` | Hardware-backed key, Chrome 147+ | Hardware binding — exfiltrated cookie is useless |
|
|
130
|
+
| `webauthn` | Platform authenticator | Hardware binding via platform authenticator |
|
|
131
|
+
| `hmac` | HMAC + browser signals | Best-effort context binding, not hardware |
|
|
132
|
+
| `none` | Standard cookie | No additional binding |
|
|
133
|
+
|
|
134
|
+
The tier is available at `res.locals.dbsc.tier` (Express), `c.get("dbscTier")` (Hono), `req.dbsc.tier` (Fastify), and via `getDbscSession()` (Next.js). Use it to apply different authorization policies per tier — for example, block payment flows when `tier !== "dbsc"`.
|
|
135
|
+
|
|
136
|
+
## Storage
|
|
137
|
+
|
|
138
|
+
### Redis
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import Redis from "ioredis";
|
|
142
|
+
import { RedisStorage } from "dbsc-toolkit/storage/redis";
|
|
143
|
+
|
|
144
|
+
const redis = new Redis(process.env.REDIS_URL);
|
|
145
|
+
const storage = new RedisStorage(redis);
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### PostgreSQL
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import { Pool } from "pg";
|
|
152
|
+
import { PostgresStorage } from "dbsc-toolkit/storage/postgres";
|
|
153
|
+
|
|
154
|
+
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
|
155
|
+
const storage = new PostgresStorage(pool);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Run the migration before first use:
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
psql $DATABASE_URL < node_modules/dbsc-toolkit/migrations/001_initial.sql
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Telemetry hooks
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
app.use(dbsc({
|
|
168
|
+
storage,
|
|
169
|
+
onEvent: (event) => {
|
|
170
|
+
if (event.type === "session_stolen") {
|
|
171
|
+
alerting.trigger("dbsc.session_stolen", { sessionId: event.sessionId });
|
|
172
|
+
}
|
|
173
|
+
metrics.increment(`dbsc.${event.type}`, { tier: event.tier });
|
|
174
|
+
},
|
|
175
|
+
}));
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Event types: `registration`, `refresh`, `verification_failure`, `session_stolen`, `fallback_tier`.
|
|
179
|
+
|
|
180
|
+
## Header naming
|
|
181
|
+
|
|
182
|
+
The W3C draft renamed the headers from `Sec-Session-*` to `Secure-Session-*`. Chrome 147 acts on the new names. The middleware reads both and writes both for compatibility. If you build response headers manually, send both:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
res.setHeader("Secure-Session-Registration", header);
|
|
186
|
+
res.setHeader("Sec-Session-Registration", header);
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Security
|
|
190
|
+
|
|
191
|
+
Defense-in-depth layer. Does not replace TLS, secure cookie flags, MFA, or server hardening.
|
|
192
|
+
|
|
193
|
+
HMAC tier is not hardware binding. It provides better-than-nothing context binding for browsers without DBSC or WebAuthn. Operators should communicate the protection tier to users and restrict sensitive operations when `tier === "hmac"` or `tier === "none"`.
|
|
194
|
+
|
|
195
|
+
See [SECURITY.md](./SECURITY.md) for reporting vulnerabilities.
|
|
196
|
+
|
|
197
|
+
## Project status
|
|
198
|
+
|
|
199
|
+
- Single package on npm: `dbsc-toolkit`
|
|
200
|
+
- Verified end-to-end on Chrome 147 / Windows / TPM 2.0
|
|
201
|
+
- No third-party security audit yet
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
Apache 2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../src/client/detect.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/D,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC,CAoB5D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export async function detectClientTier() {
|
|
2
|
+
// DBSC is browser-native; Chrome 146+ handles it automatically via HTTP headers.
|
|
3
|
+
// No JS detection is needed for the DBSC path — the browser drives it.
|
|
4
|
+
// This SDK only handles the fallback paths.
|
|
5
|
+
if (typeof window === "undefined")
|
|
6
|
+
return "none";
|
|
7
|
+
if (window.PublicKeyCredential &&
|
|
8
|
+
typeof PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable === "function") {
|
|
9
|
+
try {
|
|
10
|
+
const available = await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();
|
|
11
|
+
if (available)
|
|
12
|
+
return "webauthn";
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// platform check failed, fall through to hmac
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return "hmac";
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=detect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../../src/client/detect.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,iFAAiF;IACjF,uEAAuE;IACvE,4CAA4C;IAE5C,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,MAAM,CAAC;IAEjD,IACE,MAAM,CAAC,mBAAmB;QAC1B,OAAO,mBAAmB,CAAC,6CAA6C,KAAK,UAAU,EACvF,CAAC;QACD,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,MAAM,mBAAmB,CAAC,6CAA6C,EAAE,CAAC;YAC5F,IAAI,SAAS;gBAAE,OAAO,UAAU,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;QAChD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAsB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/client/signals.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,oBAAoB,IAAI,aAAa,CAQpD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Signal collection for the HMAC fallback tier.
|
|
2
|
+
// This is NOT hardware binding. It is best-effort context binding.
|
|
3
|
+
// Operators using this tier must review GDPR obligations for signal collection.
|
|
4
|
+
export function collectClientSignals() {
|
|
5
|
+
return {
|
|
6
|
+
userAgent: navigator.userAgent,
|
|
7
|
+
acceptLanguage: navigator.language,
|
|
8
|
+
secureContext: window.isSecureContext,
|
|
9
|
+
screenDepth: screen.colorDepth,
|
|
10
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=signals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals.js","sourceRoot":"","sources":["../../src/client/signals.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,mEAAmE;AACnE,gFAAgF;AAUhF,MAAM,UAAU,oBAAoB;IAClC,OAAO;QACL,SAAS,EAAE,SAAS,CAAC,SAAS;QAC9B,cAAc,EAAE,SAAS,CAAC,QAAQ;QAClC,aAAa,EAAE,MAAM,CAAC,eAAe;QACrC,WAAW,EAAE,MAAM,CAAC,UAAU;QAC9B,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ;KAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webauthn.d.ts","sourceRoot":"","sources":["../../src/client/webauthn.ts"],"names":[],"mappings":"AAEA,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAEzE;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAE7E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { startRegistration, startAuthentication } from "@simplewebauthn/browser";
|
|
2
|
+
export async function registerWebAuthn(options) {
|
|
3
|
+
return startRegistration(options);
|
|
4
|
+
}
|
|
5
|
+
export async function authenticateWebAuthn(options) {
|
|
6
|
+
return startAuthentication(options);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=webauthn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webauthn.js","sourceRoot":"","sources":["../../src/client/webauthn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAgB;IACrD,OAAO,iBAAiB,CAAC,OAAkD,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAgB;IACzD,OAAO,mBAAmB,CAAC,OAAoD,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwk.d.ts","sourceRoot":"","sources":["../../../src/core/crypto/jwk.ts"],"names":[],"mappings":"AAKA,wBAAgB,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CAsCjD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO,CAOlE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DbscVerificationError, ErrorCodes } from "../errors.js";
|
|
2
|
+
const SUPPORTED_CURVES = new Set(["P-256"]);
|
|
3
|
+
const MIN_RSA_BITS = 2048;
|
|
4
|
+
export function validateJwk(jwk) {
|
|
5
|
+
if (jwk.kty === "EC") {
|
|
6
|
+
if (!SUPPORTED_CURVES.has(jwk.crv ?? "")) {
|
|
7
|
+
throw new DbscVerificationError(ErrorCodes.INVALID_JWK, `unsupported curve: ${jwk.crv}`);
|
|
8
|
+
}
|
|
9
|
+
if (!jwk.x || !jwk.y) {
|
|
10
|
+
throw new DbscVerificationError(ErrorCodes.INVALID_JWK, "EC key missing x or y coordinate");
|
|
11
|
+
}
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (jwk.kty === "RSA") {
|
|
15
|
+
if (!jwk.n) {
|
|
16
|
+
throw new DbscVerificationError(ErrorCodes.INVALID_JWK, "RSA key missing modulus");
|
|
17
|
+
}
|
|
18
|
+
const bits = base64urlBits(jwk.n);
|
|
19
|
+
if (bits < MIN_RSA_BITS) {
|
|
20
|
+
throw new DbscVerificationError(ErrorCodes.INVALID_JWK, `RSA key too short: ${bits} bits, minimum ${MIN_RSA_BITS}`);
|
|
21
|
+
}
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
throw new DbscVerificationError(ErrorCodes.INVALID_JWK, `unsupported key type: ${jwk.kty}`);
|
|
25
|
+
}
|
|
26
|
+
export function detectAlgorithm(jwk) {
|
|
27
|
+
if (jwk.kty === "EC" && jwk.crv === "P-256")
|
|
28
|
+
return "ES256";
|
|
29
|
+
if (jwk.kty === "RSA")
|
|
30
|
+
return "RS256";
|
|
31
|
+
throw new DbscVerificationError(ErrorCodes.UNKNOWN_ALGORITHM, `cannot determine algorithm for kty=${jwk.kty} crv=${jwk.crv}`);
|
|
32
|
+
}
|
|
33
|
+
function base64urlBits(b64) {
|
|
34
|
+
return (b64.length * 6) / 8 * 8;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=jwk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwk.js","sourceRoot":"","sources":["../../../src/core/crypto/jwk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEjE,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AAC5C,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,MAAM,UAAU,WAAW,CAAC,GAAe;IACzC,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;QACrB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,qBAAqB,CAC7B,UAAU,CAAC,WAAW,EACtB,sBAAsB,GAAG,CAAC,GAAG,EAAE,CAChC,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACrB,MAAM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
|
+
jti: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ParsedDbscJws {
|
|
6
|
+
claims: DbscJwsClaims;
|
|
7
|
+
jwk?: JsonWebKey;
|
|
8
|
+
}
|
|
9
|
+
export declare function verifyDbscJws(token: string, storedJwk: JsonWebKey, expectedJti: string): Promise<DbscJwsClaims>;
|
|
10
|
+
export declare function parseRegistrationJws(token: string): Promise<{
|
|
11
|
+
claims: JWTPayload;
|
|
12
|
+
jwk: JsonWebKey;
|
|
13
|
+
algorithm: "ES256" | "RS256";
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=jws.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jws.d.ts","sourceRoot":"","sources":["../../../src/core/crypto/jws.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,KAAK,UAAU,EAAY,MAAM,MAAM,CAAC;AAO9F,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC/C,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,aAAa,CAAC;IACtB,GAAG,CAAC,EAAE,UAAU,CAAC;CAClB;AAED,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,UAAU,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,CAAC,CAoDxB;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IACjE,MAAM,EAAE,UAAU,CAAC;IACnB,GAAG,EAAE,UAAU,CAAC;IAChB,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC;CAC9B,CAAC,CAiDD"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { importJWK, jwtVerify, decodeProtectedHeader } from "jose";
|
|
2
|
+
import { DbscVerificationError, ErrorCodes } from "../errors.js";
|
|
3
|
+
import { validateJwk } from "./jwk.js";
|
|
4
|
+
const DBSC_TYPE = "dbsc+jwt";
|
|
5
|
+
const SUPPORTED_ALGS = ["ES256", "RS256"];
|
|
6
|
+
export async function verifyDbscJws(token, storedJwk, expectedJti) {
|
|
7
|
+
let header;
|
|
8
|
+
try {
|
|
9
|
+
header = decodeProtectedHeader(token);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
throw new DbscVerificationError(ErrorCodes.MALFORMED_JWS, "failed to decode JWS header");
|
|
13
|
+
}
|
|
14
|
+
if (header["typ"] !== DBSC_TYPE) {
|
|
15
|
+
throw new DbscVerificationError(ErrorCodes.MALFORMED_JWS, `expected typ=${DBSC_TYPE}, got ${header["typ"]}`);
|
|
16
|
+
}
|
|
17
|
+
const alg = header["alg"];
|
|
18
|
+
if (!SUPPORTED_ALGS.includes(alg)) {
|
|
19
|
+
throw new DbscVerificationError(ErrorCodes.UNKNOWN_ALGORITHM, `unsupported algorithm: ${alg}`);
|
|
20
|
+
}
|
|
21
|
+
let key;
|
|
22
|
+
try {
|
|
23
|
+
key = await importJWK(storedJwk, alg);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new DbscVerificationError(ErrorCodes.INVALID_JWK, "failed to import stored JWK");
|
|
27
|
+
}
|
|
28
|
+
let payload;
|
|
29
|
+
try {
|
|
30
|
+
const result = await jwtVerify(token, key, {
|
|
31
|
+
algorithms: [...SUPPORTED_ALGS],
|
|
32
|
+
});
|
|
33
|
+
payload = result.payload;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
throw new DbscVerificationError(ErrorCodes.SIGNATURE_INVALID, "JWS signature verification failed");
|
|
37
|
+
}
|
|
38
|
+
if (typeof payload.jti !== "string") {
|
|
39
|
+
throw new DbscVerificationError(ErrorCodes.MALFORMED_JWS, "missing jti claim");
|
|
40
|
+
}
|
|
41
|
+
if (payload.jti !== expectedJti) {
|
|
42
|
+
throw new DbscVerificationError(ErrorCodes.JTI_MISMATCH, "jti does not match issued challenge");
|
|
43
|
+
}
|
|
44
|
+
return payload;
|
|
45
|
+
}
|
|
46
|
+
export async function parseRegistrationJws(token) {
|
|
47
|
+
let header;
|
|
48
|
+
try {
|
|
49
|
+
header = decodeProtectedHeader(token);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
throw new DbscVerificationError(ErrorCodes.MALFORMED_JWS, "failed to decode registration JWS header");
|
|
53
|
+
}
|
|
54
|
+
if (header["typ"] !== DBSC_TYPE) {
|
|
55
|
+
throw new DbscVerificationError(ErrorCodes.MALFORMED_JWS, `expected typ=${DBSC_TYPE}, got ${header["typ"]}`);
|
|
56
|
+
}
|
|
57
|
+
const alg = header["alg"];
|
|
58
|
+
if (!SUPPORTED_ALGS.includes(alg)) {
|
|
59
|
+
throw new DbscVerificationError(ErrorCodes.UNKNOWN_ALGORITHM, `unsupported algorithm: ${alg}`);
|
|
60
|
+
}
|
|
61
|
+
const jwk = header["jwk"];
|
|
62
|
+
if (!jwk) {
|
|
63
|
+
throw new DbscVerificationError(ErrorCodes.MALFORMED_JWS, "registration JWS missing jwk in header");
|
|
64
|
+
}
|
|
65
|
+
validateJwk(jwk);
|
|
66
|
+
let key;
|
|
67
|
+
try {
|
|
68
|
+
key = await importJWK(jwk, alg);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
throw new DbscVerificationError(ErrorCodes.INVALID_JWK, "failed to import registration JWK");
|
|
72
|
+
}
|
|
73
|
+
let payload;
|
|
74
|
+
try {
|
|
75
|
+
const result = await jwtVerify(token, key, {
|
|
76
|
+
algorithms: [...SUPPORTED_ALGS],
|
|
77
|
+
});
|
|
78
|
+
payload = result.payload;
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
throw new DbscVerificationError(ErrorCodes.SIGNATURE_INVALID, "registration JWS self-signature invalid");
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
claims: payload,
|
|
85
|
+
jwk,
|
|
86
|
+
algorithm: alg,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=j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AAG,MAAM,CAAC,KAAK,CAAW,CAAC;IACpC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAsC,CAAC,EAAE,CAAC;QACrE,MAAM,IAAI,qBAAqB,CAAC,UAAU,CAAC,iBAAiB,EAAE,0BAA0B,GAAG,EAAE,CAAC,CAAC;IACjG,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAA2B,CAAC;IACpD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,qBAAqB,CAAC,UAAU,CAAC,aAAa,EAAE,wCAAwC,CAAC,CAAC;IACtG,CAAC;IAED,WAAW,CAAC,GAAG,CAAC,CAAC;IAEjB,IAAI,GAA0C,CAAC;IAC/C,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,SAAS,CAAC,GAAU,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,qBAAqB,CAAC,UAAU,CAAC,WAAW,EAAE,mCAAmC,CAAC,CAAC;IAC/F,CAAC;IAED,IAAI,OAAmB,CAAC;IACxB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE;YACzC,UAAU,EAAE,CAAC,GAAG,cAAc,CAAC;SAChC,CAAC,CAAC;QACH,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,qBAAqB,CAAC,UAAU,CAAC,iBAAiB,EAAE,yCAAyC,CAAC,CAAC;IAC3G,CAAC;IAED,OAAO;QACL,MAAM,EAAE,OAAO;QACf,GAAG;QACH,SAAS,EAAE,GAAwB;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare class DbscProtocolError extends Error {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
constructor(code: string, message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class DbscVerificationError extends Error {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
constructor(code: string, message: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class DbscStorageError extends Error {
|
|
10
|
+
readonly code: string;
|
|
11
|
+
constructor(code: string, message: string);
|
|
12
|
+
}
|
|
13
|
+
export declare const ErrorCodes: {
|
|
14
|
+
readonly MISSING_RESPONSE_HEADER: "MISSING_RESPONSE_HEADER";
|
|
15
|
+
readonly MALFORMED_JWS: "MALFORMED_JWS";
|
|
16
|
+
readonly INVALID_JWK: "INVALID_JWK";
|
|
17
|
+
readonly UNKNOWN_ALGORITHM: "UNKNOWN_ALGORITHM";
|
|
18
|
+
readonly CHALLENGE_NOT_FOUND: "CHALLENGE_NOT_FOUND";
|
|
19
|
+
readonly CHALLENGE_EXPIRED: "CHALLENGE_EXPIRED";
|
|
20
|
+
readonly CHALLENGE_CONSUMED: "CHALLENGE_CONSUMED";
|
|
21
|
+
readonly JTI_MISMATCH: "JTI_MISMATCH";
|
|
22
|
+
readonly SIGNATURE_INVALID: "SIGNATURE_INVALID";
|
|
23
|
+
readonly KEY_NOT_FOUND: "KEY_NOT_FOUND";
|
|
24
|
+
readonly SESSION_NOT_FOUND: "SESSION_NOT_FOUND";
|
|
25
|
+
readonly RATE_LIMITED: "RATE_LIMITED";
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAED,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;CAab,CAAC"}
|