dbsc-toolkit 2.8.0 → 2.9.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 -132
- package/README.md +2 -0
- package/dist/core/cookies/options.d.ts +56 -0
- package/dist/core/cookies/options.d.ts.map +1 -0
- package/dist/core/cookies/options.js +84 -0
- package/dist/core/cookies/options.js.map +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/types.d.ts +15 -5
- package/dist/core/types.d.ts.map +1 -1
- package/dist/express/create-dbsc.d.ts.map +1 -1
- package/dist/express/create-dbsc.js +19 -7
- package/dist/express/create-dbsc.js.map +1 -1
- package/dist/express/index.d.ts +5 -1
- package/dist/express/index.d.ts.map +1 -1
- package/dist/express/index.js +40 -25
- package/dist/express/index.js.map +1 -1
- package/dist/fastify/create-dbsc.d.ts.map +1 -1
- package/dist/fastify/create-dbsc.js +17 -6
- package/dist/fastify/create-dbsc.js.map +1 -1
- package/dist/fastify/index.d.ts +5 -1
- package/dist/fastify/index.d.ts.map +1 -1
- package/dist/fastify/index.js +24 -11
- package/dist/fastify/index.js.map +1 -1
- package/dist/hono/create-dbsc.d.ts.map +1 -1
- package/dist/hono/create-dbsc.js +17 -6
- package/dist/hono/create-dbsc.js.map +1 -1
- package/dist/hono/index.d.ts +5 -1
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +30 -12
- package/dist/hono/index.js.map +1 -1
- package/dist/nextjs/create-dbsc.d.ts.map +1 -1
- package/dist/nextjs/create-dbsc.js +15 -2
- package/dist/nextjs/create-dbsc.js.map +1 -1
- package/dist/nextjs/index.d.ts +7 -1
- package/dist/nextjs/index.d.ts.map +1 -1
- package/dist/nextjs/index.js +41 -23
- package/dist/nextjs/index.js.map +1 -1
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,132 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
the copyright owner
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
not limited to
|
|
29
|
-
and
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
copyright
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
You
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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 2026 Suliman Abdulrazzaq
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -129,6 +129,8 @@ app.post("/logout", async (req, res) => {
|
|
|
129
129
|
|
|
130
130
|
**No server-side session id** (NextAuth JWT mode, iron-session, Lucia stateless)? Call `dbsc.bind(res, { userId })` with no id — the kit derives a stable one and manages a per-device cookie so each browser of the same user binds independently. Per-system recipes: [docs/integration-recipes.md](./docs/integration-recipes.md).
|
|
131
131
|
|
|
132
|
+
**App split across subdomains** (`app.example.com` + `api.example.com`)? Default `__Host-` cookies are origin-locked — keep DBSC on one origin (proxy `/dbsc/*` and `/dbsc-bound/*` through the UI host) for the strongest setting. If a same-origin layout is genuinely not workable, v2.9.0+ exposes `cookieScope: "site"` + `cookieDomain: "example.com"` on `createDbsc({...})`, switching the binding cookies to `__Secure-` with a `Domain` attribute. The validator throws at construction if either is wrong, so misconfiguration is loud, not silent. Trade-off and concrete recipe: [docs/integration-recipes.md#multi-subdomain-apps-cookiescope-site](./docs/integration-recipes.md#multi-subdomain-apps-cookiescope-site).
|
|
133
|
+
|
|
132
134
|
**The full step-by-step** — every option and its default, the `autoBind` transparent-rollout variant, the per-route policy table, the migration timeline — is in [docs/integrating-existing-auth.md](./docs/integrating-existing-auth.md).
|
|
133
135
|
|
|
134
136
|
## Protect your routes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cookie-scope helpers shared by every adapter (v2.9+).
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for the cookie prefix (`__Host-` vs `__Secure-`),
|
|
5
|
+
* the `Domain` attribute, and the `attributes` string echoed back in the
|
|
6
|
+
* registration response's `credentials[].attributes` field.
|
|
7
|
+
*
|
|
8
|
+
* The four adapters wrap framework-specific cookie APIs around the values
|
|
9
|
+
* returned here. The validator throws on construction so a missing
|
|
10
|
+
* `cookieDomain` cannot silently degrade into a broken state at request
|
|
11
|
+
* time.
|
|
12
|
+
*/
|
|
13
|
+
export type CookieScope = "host" | "site";
|
|
14
|
+
export interface CookieScopeOptions {
|
|
15
|
+
secure: boolean;
|
|
16
|
+
cookieScope?: CookieScope;
|
|
17
|
+
cookieDomain?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface CookieScopeResolved {
|
|
20
|
+
/** Whether the cookies use the `__Host-` prefix (host scope, secure). */
|
|
21
|
+
hostPrefix: boolean;
|
|
22
|
+
/** `"__Host-"`, `"__Secure-"`, or `""` (insecure dev). */
|
|
23
|
+
prefix: "__Host-" | "__Secure-" | "";
|
|
24
|
+
/** The `Domain` attribute value, or undefined when no domain is emitted. */
|
|
25
|
+
domain: string | undefined;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validates a cookie-scope configuration and returns the resolved values
|
|
29
|
+
* the adapters consume. Throws when `"site"` scope is requested without a
|
|
30
|
+
* `cookieDomain`, or when an insecure config tries to use site scope (a
|
|
31
|
+
* `__Secure-` cookie requires the `Secure` flag, which requires HTTPS).
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveCookieScope(opts: CookieScopeOptions): CookieScopeResolved;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the three cookie names (`bound`, `reg`, `challenge`) the adapters
|
|
36
|
+
* read and write. Encapsulates the prefix swap so callers never concatenate
|
|
37
|
+
* a prefix by hand.
|
|
38
|
+
*/
|
|
39
|
+
export declare function cookieNames(opts: CookieScopeOptions): {
|
|
40
|
+
bound: string;
|
|
41
|
+
reg: string;
|
|
42
|
+
challenge: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The name of the per-device cookie used by the JWT-mode `bind()` path.
|
|
46
|
+
* Same prefix rules as the binding cookies above.
|
|
47
|
+
*/
|
|
48
|
+
export declare function deviceCookieName(opts: CookieScopeOptions): string;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the `attributes` string echoed back in the registration response's
|
|
51
|
+
* `credentials[].attributes` field, which Chromium re-reads to know how to
|
|
52
|
+
* re-issue the bound cookie on refresh. Must match what the server actually
|
|
53
|
+
* sets in `Set-Cookie`, byte for byte, or Chromium drops the binding.
|
|
54
|
+
*/
|
|
55
|
+
export declare function cookieAttributesString(opts: CookieScopeOptions): string;
|
|
56
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/core/cookies/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1C,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,yEAAyE;IACzE,UAAU,EAAE,OAAO,CAAC;IACpB,0DAA0D;IAC1D,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,EAAE,CAAC;IACrC,4EAA4E;IAC5E,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,kBAAkB,GAAG,mBAAmB,CAwChF;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB,CAOA;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAGjE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM,CAKvE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cookie-scope helpers shared by every adapter (v2.9+).
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for the cookie prefix (`__Host-` vs `__Secure-`),
|
|
5
|
+
* the `Domain` attribute, and the `attributes` string echoed back in the
|
|
6
|
+
* registration response's `credentials[].attributes` field.
|
|
7
|
+
*
|
|
8
|
+
* The four adapters wrap framework-specific cookie APIs around the values
|
|
9
|
+
* returned here. The validator throws on construction so a missing
|
|
10
|
+
* `cookieDomain` cannot silently degrade into a broken state at request
|
|
11
|
+
* time.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Validates a cookie-scope configuration and returns the resolved values
|
|
15
|
+
* the adapters consume. Throws when `"site"` scope is requested without a
|
|
16
|
+
* `cookieDomain`, or when an insecure config tries to use site scope (a
|
|
17
|
+
* `__Secure-` cookie requires the `Secure` flag, which requires HTTPS).
|
|
18
|
+
*/
|
|
19
|
+
export function resolveCookieScope(opts) {
|
|
20
|
+
const scope = opts.cookieScope ?? "host";
|
|
21
|
+
const secure = opts.secure;
|
|
22
|
+
if (scope === "site") {
|
|
23
|
+
if (!opts.cookieDomain) {
|
|
24
|
+
throw new Error('dbsc: cookieScope: "site" requires cookieDomain. ' +
|
|
25
|
+
"Set cookieDomain to the registrable apex (e.g. \"example.com\") " +
|
|
26
|
+
"so the binding cookie can be shared across subdomains. " +
|
|
27
|
+
'Drop cookieScope to keep the default "host" mode.');
|
|
28
|
+
}
|
|
29
|
+
if (!secure) {
|
|
30
|
+
throw new Error('dbsc: cookieScope: "site" requires secure: true. ' +
|
|
31
|
+
"The __Secure- prefix is rejected by browsers without the Secure flag.");
|
|
32
|
+
}
|
|
33
|
+
if (opts.cookieDomain.startsWith(".")) {
|
|
34
|
+
throw new Error('dbsc: cookieDomain must not start with a leading dot. ' +
|
|
35
|
+
'Use "example.com", not ".example.com".');
|
|
36
|
+
}
|
|
37
|
+
return { hostPrefix: false, prefix: "__Secure-", domain: opts.cookieDomain };
|
|
38
|
+
}
|
|
39
|
+
// host scope
|
|
40
|
+
if (opts.cookieDomain) {
|
|
41
|
+
throw new Error('dbsc: cookieDomain is only valid when cookieScope: "site". ' +
|
|
42
|
+
'Remove cookieDomain or set cookieScope: "site".');
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
hostPrefix: secure,
|
|
46
|
+
prefix: secure ? "__Host-" : "",
|
|
47
|
+
domain: undefined,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns the three cookie names (`bound`, `reg`, `challenge`) the adapters
|
|
52
|
+
* read and write. Encapsulates the prefix swap so callers never concatenate
|
|
53
|
+
* a prefix by hand.
|
|
54
|
+
*/
|
|
55
|
+
export function cookieNames(opts) {
|
|
56
|
+
const { prefix } = resolveCookieScope(opts);
|
|
57
|
+
return {
|
|
58
|
+
bound: `${prefix}dbsc-session`,
|
|
59
|
+
reg: `${prefix}dbsc-reg`,
|
|
60
|
+
challenge: `${prefix}dbsc-challenge`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The name of the per-device cookie used by the JWT-mode `bind()` path.
|
|
65
|
+
* Same prefix rules as the binding cookies above.
|
|
66
|
+
*/
|
|
67
|
+
export function deviceCookieName(opts) {
|
|
68
|
+
const { prefix } = resolveCookieScope(opts);
|
|
69
|
+
return `${prefix}dbsc-device`;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Returns the `attributes` string echoed back in the registration response's
|
|
73
|
+
* `credentials[].attributes` field, which Chromium re-reads to know how to
|
|
74
|
+
* re-issue the bound cookie on refresh. Must match what the server actually
|
|
75
|
+
* sets in `Set-Cookie`, byte for byte, or Chromium drops the binding.
|
|
76
|
+
*/
|
|
77
|
+
export function cookieAttributesString(opts) {
|
|
78
|
+
const { domain } = resolveCookieScope(opts);
|
|
79
|
+
const parts = ["Path=/", "Secure", "HttpOnly", "SameSite=Lax"];
|
|
80
|
+
if (domain)
|
|
81
|
+
parts.push(`Domain=${domain}`);
|
|
82
|
+
return parts.join("; ");
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/core/cookies/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAmBH;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAwB;IACzD,MAAM,KAAK,GAAgB,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC;IACtD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAE3B,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,mDAAmD;gBACjD,kEAAkE;gBAClE,yDAAyD;gBACzD,mDAAmD,CACtD,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CACb,mDAAmD;gBACjD,uEAAuE,CAC1E,CAAC;QACJ,CAAC;QACD,IAAI,IA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,CAAC,UAAU,MAAM,EAAE,CAAC,CAAC;IAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -21,4 +21,6 @@ export type { DeriveSessionIdInput } from "./derive-session-id.js";
|
|
|
21
21
|
export { noBindingReason } from "./protect-policy.js";
|
|
22
22
|
export type { RequireProofOptions } from "./protect-policy.js";
|
|
23
23
|
export { parseCookieHeader } from "./protocol/cookies.js";
|
|
24
|
+
export { resolveCookieScope, cookieNames as resolveCookieNames, deviceCookieName, cookieAttributesString, } from "./cookies/options.js";
|
|
25
|
+
export type { CookieScope, CookieScopeOptions, CookieScopeResolved } from "./cookies/options.js";
|
|
24
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,wBAAwB,EACxB,kBAAkB,EAClB,eAAe,EACf,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErG,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EACL,uBAAuB,EACvB,oBAAoB,E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AAuB,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEtG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EACL,kBAAkB,EAClB,WAAW,IAAI,kBAAkB,EACjC,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -16,4 +16,5 @@ export { maybeEmitPolyfillMissing, POLYFILL_MISSING_GRACE_MS } from "./telemetry
|
|
|
16
16
|
export { deriveSessionId } from "./derive-session-id.js";
|
|
17
17
|
export { noBindingReason } from "./protect-policy.js";
|
|
18
18
|
export { parseCookieHeader } from "./protocol/cookies.js";
|
|
19
|
+
export { resolveCookieScope, cookieNames as resolveCookieNames, deviceCookieName, cookieAttributesString, } from "./cookies/options.js";
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,UAAU,EAAE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iB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EACL,kBAAkB,EAClB,WAAW,IAAI,kBAAkB,EACjC,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC"}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -157,13 +157,23 @@ export interface DbscOptions {
|
|
|
157
157
|
*/
|
|
158
158
|
refreshGraceMs?: number;
|
|
159
159
|
/**
|
|
160
|
-
* Cookie prefix scope. "host" (default) uses `__Host-` cookies —
|
|
161
|
-
* locked, no Domain attribute, strongest. "site" uses
|
|
162
|
-
*
|
|
163
|
-
* (app.example.com + api.example.com)
|
|
164
|
-
*
|
|
160
|
+
* Cookie prefix scope. `"host"` (default) uses `__Host-` cookies —
|
|
161
|
+
* origin-locked, no `Domain` attribute, strongest. `"site"` uses
|
|
162
|
+
* `__Secure-` cookies carrying `Domain=<cookieDomain>` so the binding works
|
|
163
|
+
* across subdomains (e.g. `app.example.com` + `api.example.com`). The
|
|
164
|
+
* `"site"` mode drops `__Host-`'s protection against a sibling subdomain
|
|
165
|
+
* setting or overwriting the cookie; only enable it when a same-origin
|
|
166
|
+
* deployment is genuinely not workable. See docs/integration-recipes.md.
|
|
165
167
|
*/
|
|
166
168
|
cookieScope?: "host" | "site";
|
|
169
|
+
/**
|
|
170
|
+
* Required when `cookieScope: "site"`. The `Domain` attribute attached to
|
|
171
|
+
* every DBSC cookie — typically the registrable apex (`example.com`) so the
|
|
172
|
+
* cookie is visible on every subdomain. Omit the leading dot. Throws at
|
|
173
|
+
* `dbsc()` / `createDbsc()` construction when `"site"` is set without it.
|
|
174
|
+
* Ignored in `"host"` mode.
|
|
175
|
+
*/
|
|
176
|
+
cookieDomain?: string;
|
|
167
177
|
rateLimiter?: RateLimiter;
|
|
168
178
|
/**
|
|
169
179
|
* Replay cache for per-request proofs (v2.8+). Without it, an attacker who
|
package/dist/core/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.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