Skip to content

Commit 4acb92f

Browse files
Support for wildcard domains
1 parent ecec761 commit 4acb92f

26 files changed

Lines changed: 519 additions & 89 deletions

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const result = await gatekeeper.validateRequest();
6363

6464
// Handle the validation result
6565
if (result.setCookie) {
66-
gatekeeper.setCookie(result.cookieValue);
66+
gatekeeper.setCookie(result.cookieValue, result.domain);
6767
}
6868

6969
if (result.stripParams) {
@@ -106,7 +106,7 @@ const result = await gatekeeper.validateRequest();
106106

107107
// Handle the validation result
108108
if (result.setCookie) {
109-
gatekeeper.setCookie(result.cookieValue);
109+
gatekeeper.setCookie(result.cookieValue, result.domain);
110110
}
111111

112112
if (result.stripParams) {
@@ -199,13 +199,13 @@ try {
199199
}
200200
```
201201

202-
### gatekeeper.setCookie(value)
202+
### gatekeeper.setCookie(value, domain?)
203203

204-
Sets the CrowdHandler session cookie. Always call this when `result.setCookie` is true to maintain the user's queue position.
204+
Sets the CrowdHandler session cookie. Always call this when `result.setCookie` is true to maintain the user's queue position. The optional `domain` parameter (provided in `result.domain`) enables proper cookie scoping for wildcard domains.
205205

206206
```javascript
207207
if (result.setCookie) {
208-
gatekeeper.setCookie(result.cookieValue);
208+
gatekeeper.setCookie(result.cookieValue, result.domain);
209209
}
210210
```
211211

@@ -469,7 +469,7 @@ async function protectRoute(req, res, next) {
469469
const result = await gatekeeper.validateRequest();
470470

471471
if (result.setCookie) {
472-
gatekeeper.setCookie(result.cookieValue);
472+
gatekeeper.setCookie(result.cookieValue, result.domain);
473473
}
474474

475475
if (result.stripParams) {

dist/common/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ exports.ValidateRequestObject = zod_1.z.object({
145145
requested: zod_1.z.string().optional(),
146146
liteValidatorRedirect: zod_1.z.boolean().optional(),
147147
liteValidatorUrl: zod_1.z.string().optional(),
148+
domain: zod_1.z.string().optional(),
148149
});
149150
exports.HttpErrorWrapper = zod_1.z.object({
150151
result: zod_1.z.object({

dist/crowdhandler.cjs.js

Lines changed: 92 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/crowdhandler.cjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)