houdini-react 1.2.10 → 1.2.11

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.
@@ -16360,234 +16360,6 @@ var require_main4 = __commonJS({
16360
16360
  }
16361
16361
  });
16362
16362
 
16363
- // ../../node_modules/.pnpm/cookie@0.4.1/node_modules/cookie/index.js
16364
- var require_cookie = __commonJS({
16365
- "../../node_modules/.pnpm/cookie@0.4.1/node_modules/cookie/index.js"(exports) {
16366
- "use strict";
16367
- exports.parse = parse3;
16368
- exports.serialize = serialize;
16369
- var decode = decodeURIComponent;
16370
- var encode = encodeURIComponent;
16371
- var pairSplitRegExp = /; */;
16372
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
16373
- function parse3(str, options) {
16374
- if (typeof str !== "string") {
16375
- throw new TypeError("argument str must be a string");
16376
- }
16377
- var obj = {};
16378
- var opt = options || {};
16379
- var pairs = str.split(pairSplitRegExp);
16380
- var dec = opt.decode || decode;
16381
- for (var i2 = 0; i2 < pairs.length; i2++) {
16382
- var pair = pairs[i2];
16383
- var eq_idx = pair.indexOf("=");
16384
- if (eq_idx < 0) {
16385
- continue;
16386
- }
16387
- var key = pair.substr(0, eq_idx).trim();
16388
- var val = pair.substr(++eq_idx, pair.length).trim();
16389
- if ('"' == val[0]) {
16390
- val = val.slice(1, -1);
16391
- }
16392
- if (void 0 == obj[key]) {
16393
- obj[key] = tryDecode(val, dec);
16394
- }
16395
- }
16396
- return obj;
16397
- }
16398
- function serialize(name, val, options) {
16399
- var opt = options || {};
16400
- var enc = opt.encode || encode;
16401
- if (typeof enc !== "function") {
16402
- throw new TypeError("option encode is invalid");
16403
- }
16404
- if (!fieldContentRegExp.test(name)) {
16405
- throw new TypeError("argument name is invalid");
16406
- }
16407
- var value = enc(val);
16408
- if (value && !fieldContentRegExp.test(value)) {
16409
- throw new TypeError("argument val is invalid");
16410
- }
16411
- var str = name + "=" + value;
16412
- if (null != opt.maxAge) {
16413
- var maxAge = opt.maxAge - 0;
16414
- if (isNaN(maxAge) || !isFinite(maxAge)) {
16415
- throw new TypeError("option maxAge is invalid");
16416
- }
16417
- str += "; Max-Age=" + Math.floor(maxAge);
16418
- }
16419
- if (opt.domain) {
16420
- if (!fieldContentRegExp.test(opt.domain)) {
16421
- throw new TypeError("option domain is invalid");
16422
- }
16423
- str += "; Domain=" + opt.domain;
16424
- }
16425
- if (opt.path) {
16426
- if (!fieldContentRegExp.test(opt.path)) {
16427
- throw new TypeError("option path is invalid");
16428
- }
16429
- str += "; Path=" + opt.path;
16430
- }
16431
- if (opt.expires) {
16432
- if (typeof opt.expires.toUTCString !== "function") {
16433
- throw new TypeError("option expires is invalid");
16434
- }
16435
- str += "; Expires=" + opt.expires.toUTCString();
16436
- }
16437
- if (opt.httpOnly) {
16438
- str += "; HttpOnly";
16439
- }
16440
- if (opt.secure) {
16441
- str += "; Secure";
16442
- }
16443
- if (opt.sameSite) {
16444
- var sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
16445
- switch (sameSite) {
16446
- case true:
16447
- str += "; SameSite=Strict";
16448
- break;
16449
- case "lax":
16450
- str += "; SameSite=Lax";
16451
- break;
16452
- case "strict":
16453
- str += "; SameSite=Strict";
16454
- break;
16455
- case "none":
16456
- str += "; SameSite=None";
16457
- break;
16458
- default:
16459
- throw new TypeError("option sameSite is invalid");
16460
- }
16461
- }
16462
- return str;
16463
- }
16464
- function tryDecode(str, decode2) {
16465
- try {
16466
- return decode2(str);
16467
- } catch (e2) {
16468
- return str;
16469
- }
16470
- }
16471
- }
16472
- });
16473
-
16474
- // ../../node_modules/.pnpm/cookie-signature@1.0.6/node_modules/cookie-signature/index.js
16475
- var require_cookie_signature = __commonJS({
16476
- "../../node_modules/.pnpm/cookie-signature@1.0.6/node_modules/cookie-signature/index.js"(exports) {
16477
- var crypto = __require("crypto");
16478
- exports.sign = function(val, secret) {
16479
- if ("string" != typeof val)
16480
- throw new TypeError("Cookie value must be provided as a string.");
16481
- if ("string" != typeof secret)
16482
- throw new TypeError("Secret string must be provided.");
16483
- return val + "." + crypto.createHmac("sha256", secret).update(val).digest("base64").replace(/\=+$/, "");
16484
- };
16485
- exports.unsign = function(val, secret) {
16486
- if ("string" != typeof val)
16487
- throw new TypeError("Signed cookie string must be provided.");
16488
- if ("string" != typeof secret)
16489
- throw new TypeError("Secret string must be provided.");
16490
- var str = val.slice(0, val.lastIndexOf(".")), mac = exports.sign(str, secret);
16491
- return sha1(mac) == sha1(val) ? str : false;
16492
- };
16493
- function sha1(str) {
16494
- return crypto.createHash("sha1").update(str).digest("hex");
16495
- }
16496
- }
16497
- });
16498
-
16499
- // ../../node_modules/.pnpm/cookie-parser@1.4.6/node_modules/cookie-parser/index.js
16500
- var require_cookie_parser = __commonJS({
16501
- "../../node_modules/.pnpm/cookie-parser@1.4.6/node_modules/cookie-parser/index.js"(exports, module) {
16502
- "use strict";
16503
- var cookie = require_cookie();
16504
- var signature = require_cookie_signature();
16505
- module.exports = cookieParser2;
16506
- module.exports.JSONCookie = JSONCookie;
16507
- module.exports.JSONCookies = JSONCookies;
16508
- module.exports.signedCookie = signedCookie;
16509
- module.exports.signedCookies = signedCookies;
16510
- function cookieParser2(secret, options) {
16511
- var secrets = !secret || Array.isArray(secret) ? secret || [] : [secret];
16512
- return function cookieParser3(req, res, next) {
16513
- if (req.cookies) {
16514
- return next();
16515
- }
16516
- var cookies = req.headers.cookie;
16517
- req.secret = secrets[0];
16518
- req.cookies = /* @__PURE__ */ Object.create(null);
16519
- req.signedCookies = /* @__PURE__ */ Object.create(null);
16520
- if (!cookies) {
16521
- return next();
16522
- }
16523
- req.cookies = cookie.parse(cookies, options);
16524
- if (secrets.length !== 0) {
16525
- req.signedCookies = signedCookies(req.cookies, secrets);
16526
- req.signedCookies = JSONCookies(req.signedCookies);
16527
- }
16528
- req.cookies = JSONCookies(req.cookies);
16529
- next();
16530
- };
16531
- }
16532
- function JSONCookie(str) {
16533
- if (typeof str !== "string" || str.substr(0, 2) !== "j:") {
16534
- return void 0;
16535
- }
16536
- try {
16537
- return JSON.parse(str.slice(2));
16538
- } catch (err) {
16539
- return void 0;
16540
- }
16541
- }
16542
- function JSONCookies(obj) {
16543
- var cookies = Object.keys(obj);
16544
- var key;
16545
- var val;
16546
- for (var i2 = 0; i2 < cookies.length; i2++) {
16547
- key = cookies[i2];
16548
- val = JSONCookie(obj[key]);
16549
- if (val) {
16550
- obj[key] = val;
16551
- }
16552
- }
16553
- return obj;
16554
- }
16555
- function signedCookie(str, secret) {
16556
- if (typeof str !== "string") {
16557
- return void 0;
16558
- }
16559
- if (str.substr(0, 2) !== "s:") {
16560
- return str;
16561
- }
16562
- var secrets = !secret || Array.isArray(secret) ? secret || [] : [secret];
16563
- for (var i2 = 0; i2 < secrets.length; i2++) {
16564
- var val = signature.unsign(str.slice(2), secrets[i2]);
16565
- if (val !== false) {
16566
- return val;
16567
- }
16568
- }
16569
- return false;
16570
- }
16571
- function signedCookies(obj, secret) {
16572
- var cookies = Object.keys(obj);
16573
- var dec;
16574
- var key;
16575
- var ret = /* @__PURE__ */ Object.create(null);
16576
- var val;
16577
- for (var i2 = 0; i2 < cookies.length; i2++) {
16578
- key = cookies[i2];
16579
- val = obj[key];
16580
- dec = signedCookie(val, secret);
16581
- if (val !== dec) {
16582
- ret[key] = dec;
16583
- delete obj[key];
16584
- }
16585
- }
16586
- return ret;
16587
- }
16588
- }
16589
- });
16590
-
16591
16363
  // ../houdini/build/lib-esm/index.js
16592
16364
  import { createRequire as conflict_free } from "module";
16593
16365
  import { statSync, createReadStream, promises as fs2 } from "node:fs";
@@ -18044,7 +17816,7 @@ var require_parser = __commonJS2({
18044
17816
  Object.defineProperty(exports, "__esModule", {
18045
17817
  value: true
18046
17818
  });
18047
- exports.parse = parse5;
17819
+ exports.parse = parse6;
18048
17820
  exports.parseValue = parseValue;
18049
17821
  exports.parseType = parseType;
18050
17822
  exports.Parser = void 0;
@@ -18055,7 +17827,7 @@ var require_parser = __commonJS2({
18055
17827
  var _source = require_source();
18056
17828
  var _directiveLocation = require_directiveLocation();
18057
17829
  var _lexer = require_lexer();
18058
- function parse5(source, options) {
17830
+ function parse6(source, options) {
18059
17831
  var parser = new Parser(source, options);
18060
17832
  return parser.parseDocument();
18061
17833
  }
@@ -49117,14 +48889,14 @@ var require_lib3 = __commonJS2({
49117
48889
  super.checkParams(node, false, true);
49118
48890
  this.scope.exit();
49119
48891
  }
49120
- forwardNoArrowParamsConversionAt(node, parse6) {
48892
+ forwardNoArrowParamsConversionAt(node, parse7) {
49121
48893
  let result;
49122
48894
  if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
49123
48895
  this.state.noArrowParamsConversionAt.push(this.state.start);
49124
- result = parse6();
48896
+ result = parse7();
49125
48897
  this.state.noArrowParamsConversionAt.pop();
49126
48898
  } else {
49127
- result = parse6();
48899
+ result = parse7();
49128
48900
  }
49129
48901
  return result;
49130
48902
  }
@@ -58179,7 +57951,7 @@ var require_lib3 = __commonJS2({
58179
57951
  }
58180
57952
  return pluginMap;
58181
57953
  }
58182
- function parse5(input, options) {
57954
+ function parse6(input, options) {
58183
57955
  var _options;
58184
57956
  if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
58185
57957
  options = Object.assign({}, options);
@@ -58249,7 +58021,7 @@ var require_lib3 = __commonJS2({
58249
58021
  }
58250
58022
  return cls;
58251
58023
  }
58252
- exports.parse = parse5;
58024
+ exports.parse = parse6;
58253
58025
  exports.parseExpression = parseExpression;
58254
58026
  exports.tokTypes = tokTypes;
58255
58027
  }
@@ -64105,7 +63877,7 @@ var require_esprima2 = __commonJS2({
64105
63877
  var jsx_parser_1 = __webpack_require__(3);
64106
63878
  var parser_1 = __webpack_require__(8);
64107
63879
  var tokenizer_1 = __webpack_require__(15);
64108
- function parse5(code, options, delegate) {
63880
+ function parse6(code, options, delegate) {
64109
63881
  var commentHandler = null;
64110
63882
  var proxyDelegate = function(node, metadata) {
64111
63883
  if (delegate) {
@@ -64150,17 +63922,17 @@ var require_esprima2 = __commonJS2({
64150
63922
  }
64151
63923
  return ast;
64152
63924
  }
64153
- exports2.parse = parse5;
63925
+ exports2.parse = parse6;
64154
63926
  function parseModule(code, options, delegate) {
64155
63927
  var parsingOptions = options || {};
64156
63928
  parsingOptions.sourceType = "module";
64157
- return parse5(code, parsingOptions, delegate);
63929
+ return parse6(code, parsingOptions, delegate);
64158
63930
  }
64159
63931
  exports2.parseModule = parseModule;
64160
63932
  function parseScript(code, options, delegate) {
64161
63933
  var parsingOptions = options || {};
64162
63934
  parsingOptions.sourceType = "script";
64163
- return parse5(code, parsingOptions, delegate);
63935
+ return parse6(code, parsingOptions, delegate);
64164
63936
  }
64165
63937
  exports2.parseScript = parseScript;
64166
63938
  function tokenize(code, options, delegate) {
@@ -70222,7 +69994,7 @@ var require_esprima3 = __commonJS2({
70222
69994
  Object.defineProperty(exports, "__esModule", { value: true });
70223
69995
  exports.parse = void 0;
70224
69996
  var util_1 = require_util2();
70225
- function parse5(source, options) {
69997
+ function parse6(source, options) {
70226
69998
  var comments = [];
70227
69999
  var ast = require_esprima2().parse(source, {
70228
70000
  loc: true,
@@ -70240,7 +70012,7 @@ var require_esprima3 = __commonJS2({
70240
70012
  }
70241
70013
  return ast;
70242
70014
  }
70243
- exports.parse = parse5;
70015
+ exports.parse = parse6;
70244
70016
  }
70245
70017
  });
70246
70018
  var require_options = __commonJS2({
@@ -71352,7 +71124,7 @@ var require_parser2 = __commonJS2({
71352
71124
  var lines_1 = require_lines();
71353
71125
  var comments_1 = require_comments();
71354
71126
  var util = tslib_1.__importStar(require_util2());
71355
- function parse5(source, options) {
71127
+ function parse6(source, options) {
71356
71128
  options = (0, options_1.normalize)(options);
71357
71129
  var lines = (0, lines_1.fromString)(source, options);
71358
71130
  var sourceWithoutTabs = lines.toString({
@@ -71424,7 +71196,7 @@ var require_parser2 = __commonJS2({
71424
71196
  (0, comments_1.attach)(comments, program.body.length ? file.program : file, lines);
71425
71197
  return new TreeCopier(lines, tokens).copy(file);
71426
71198
  }
71427
- exports.parse = parse5;
71199
+ exports.parse = parse6;
71428
71200
  var TreeCopier = function TreeCopier2(lines, tokens) {
71429
71201
  assert_1.default.ok(this instanceof TreeCopier2);
71430
71202
  this.lines = lines;
@@ -93459,6 +93231,245 @@ async function extractQueries(source) {
93459
93231
  }
93460
93232
  return props.filter((p) => p !== "children");
93461
93233
  }
93234
+ function parse5(str, options) {
93235
+ if (typeof str !== "string") {
93236
+ throw new TypeError("argument str must be a string");
93237
+ }
93238
+ let obj = {};
93239
+ let opt = options || {};
93240
+ let dec = opt.decode || decode;
93241
+ let index = 0;
93242
+ while (index < str.length) {
93243
+ let eqIdx = str.indexOf("=", index);
93244
+ if (eqIdx === -1) {
93245
+ break;
93246
+ }
93247
+ let endIdx = str.indexOf(";", index);
93248
+ if (endIdx === -1) {
93249
+ endIdx = str.length;
93250
+ } else if (endIdx < eqIdx) {
93251
+ index = str.lastIndexOf(";", eqIdx - 1) + 1;
93252
+ continue;
93253
+ }
93254
+ let key = str.slice(index, eqIdx).trim();
93255
+ if (void 0 === obj[key]) {
93256
+ let val = str.slice(eqIdx + 1, endIdx).trim();
93257
+ if (val.charCodeAt(0) === 34) {
93258
+ val = val.slice(1, -1);
93259
+ }
93260
+ obj[key] = tryDecode(val, dec);
93261
+ }
93262
+ index = endIdx + 1;
93263
+ }
93264
+ return obj;
93265
+ }
93266
+ function decode(str) {
93267
+ return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
93268
+ }
93269
+ function tryDecode(str, decode3) {
93270
+ try {
93271
+ return decode3(str);
93272
+ } catch (e2) {
93273
+ return str;
93274
+ }
93275
+ }
93276
+ function base64UrlParse(s2) {
93277
+ return new Uint8Array(
93278
+ Array.prototype.map.call(
93279
+ atob(s2.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "")),
93280
+ (c) => c.charCodeAt(0)
93281
+ )
93282
+ );
93283
+ }
93284
+ function base64UrlStringify(a) {
93285
+ return btoa(String.fromCharCode.apply(0, a)).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
93286
+ }
93287
+ var algorithms = {
93288
+ ES256: { name: "ECDSA", namedCurve: "P-256", hash: { name: "SHA-256" } },
93289
+ ES384: { name: "ECDSA", namedCurve: "P-384", hash: { name: "SHA-384" } },
93290
+ ES512: { name: "ECDSA", namedCurve: "P-521", hash: { name: "SHA-512" } },
93291
+ HS256: { name: "HMAC", hash: { name: "SHA-256" } },
93292
+ HS384: { name: "HMAC", hash: { name: "SHA-384" } },
93293
+ HS512: { name: "HMAC", hash: { name: "SHA-512" } },
93294
+ RS256: { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-256" } },
93295
+ RS384: { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-384" } },
93296
+ RS512: { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-512" } }
93297
+ };
93298
+ function _utf8ToUint8Array(str) {
93299
+ return base64UrlParse(btoa(unescape(encodeURIComponent(str))));
93300
+ }
93301
+ function _str2ab(str) {
93302
+ str = atob(str);
93303
+ const buf = new ArrayBuffer(str.length);
93304
+ const bufView = new Uint8Array(buf);
93305
+ for (let i2 = 0, strLen = str.length; i2 < strLen; i2++) {
93306
+ bufView[i2] = str.charCodeAt(i2);
93307
+ }
93308
+ return buf;
93309
+ }
93310
+ function _decodePayload(raw) {
93311
+ switch (raw.length % 4) {
93312
+ case 0:
93313
+ break;
93314
+ case 2:
93315
+ raw += "==";
93316
+ break;
93317
+ case 3:
93318
+ raw += "=";
93319
+ break;
93320
+ default:
93321
+ throw new Error("Illegal base64url string!");
93322
+ }
93323
+ try {
93324
+ return JSON.parse(decodeURIComponent(escape(atob(raw))));
93325
+ } catch {
93326
+ return null;
93327
+ }
93328
+ }
93329
+ async function encode(payload, secret, options = { algorithm: "HS256", header: { typ: "JWT" } }) {
93330
+ if (typeof options === "string")
93331
+ options = { algorithm: options, header: { typ: "JWT" } };
93332
+ options = { algorithm: "HS256", header: { typ: "JWT" }, ...options };
93333
+ if (payload === null || typeof payload !== "object")
93334
+ throw new Error("payload must be an object");
93335
+ if (typeof secret !== "string" && typeof secret !== "object")
93336
+ throw new Error("secret must be a string or a JWK object");
93337
+ if (typeof options.algorithm !== "string")
93338
+ throw new Error("options.algorithm must be a string");
93339
+ const algorithm = algorithms[options.algorithm];
93340
+ if (!algorithm)
93341
+ throw new Error("algorithm not found");
93342
+ if (!payload.iat)
93343
+ payload.iat = Math.floor(Date.now() / 1e3);
93344
+ const payloadAsJSON = JSON.stringify(payload);
93345
+ const partialToken = `${base64UrlStringify(
93346
+ _utf8ToUint8Array(JSON.stringify({ ...options.header, alg: options.algorithm }))
93347
+ )}.${base64UrlStringify(_utf8ToUint8Array(payloadAsJSON))}`;
93348
+ let keyFormat = "raw";
93349
+ let keyData;
93350
+ if (typeof secret === "object") {
93351
+ keyFormat = "jwk";
93352
+ keyData = secret;
93353
+ } else if (typeof secret === "string" && secret.startsWith("-----BEGIN")) {
93354
+ keyFormat = "pkcs8";
93355
+ keyData = _str2ab(
93356
+ secret.replace(/-----BEGIN.*?-----/g, "").replace(/-----END.*?-----/g, "").replace(/\s/g, "")
93357
+ );
93358
+ } else
93359
+ keyData = _utf8ToUint8Array(secret);
93360
+ const key = await crypto.subtle.importKey(keyFormat, keyData, algorithm, false, ["sign"]);
93361
+ const signature = await crypto.subtle.sign(algorithm, key, _utf8ToUint8Array(partialToken));
93362
+ return `${partialToken}.${base64UrlStringify(new Uint8Array(signature))}`;
93363
+ }
93364
+ async function verify(token, secret, options = { algorithm: "HS256", throwError: false }) {
93365
+ if (typeof options === "string")
93366
+ options = { algorithm: options, throwError: false };
93367
+ options = { algorithm: "HS256", throwError: false, ...options };
93368
+ if (typeof token !== "string")
93369
+ throw new Error("token must be a string");
93370
+ if (typeof secret !== "string" && typeof secret !== "object")
93371
+ throw new Error("secret must be a string or a JWK object");
93372
+ if (typeof options.algorithm !== "string")
93373
+ throw new Error("options.algorithm must be a string");
93374
+ const tokenParts = token.split(".");
93375
+ if (tokenParts.length !== 3)
93376
+ throw new Error("token must consist of 3 parts");
93377
+ const algorithm = algorithms[options.algorithm];
93378
+ if (!algorithm)
93379
+ throw new Error("algorithm not found");
93380
+ const { payload } = decode2(token);
93381
+ if (!payload) {
93382
+ if (options.throwError)
93383
+ throw "PARSE_ERROR";
93384
+ return false;
93385
+ }
93386
+ if (payload.nbf && payload.nbf > Math.floor(Date.now() / 1e3)) {
93387
+ if (options.throwError)
93388
+ throw "NOT_YET_VALID";
93389
+ return false;
93390
+ }
93391
+ if (payload.exp && payload.exp <= Math.floor(Date.now() / 1e3)) {
93392
+ if (options.throwError)
93393
+ throw "EXPIRED";
93394
+ return false;
93395
+ }
93396
+ let keyFormat = "raw";
93397
+ let keyData;
93398
+ if (typeof secret === "object") {
93399
+ keyFormat = "jwk";
93400
+ keyData = secret;
93401
+ } else if (typeof secret === "string" && secret.startsWith("-----BEGIN")) {
93402
+ keyFormat = "spki";
93403
+ keyData = _str2ab(
93404
+ secret.replace(/-----BEGIN.*?-----/g, "").replace(/-----END.*?-----/g, "").replace(/\s/g, "")
93405
+ );
93406
+ } else
93407
+ keyData = _utf8ToUint8Array(secret);
93408
+ const key = await crypto.subtle.importKey(keyFormat, keyData, algorithm, false, ["verify"]);
93409
+ return await crypto.subtle.verify(
93410
+ algorithm,
93411
+ key,
93412
+ base64UrlParse(tokenParts[2]),
93413
+ _utf8ToUint8Array(`${tokenParts[0]}.${tokenParts[1]}`)
93414
+ );
93415
+ }
93416
+ function decode2(token) {
93417
+ return {
93418
+ header: _decodePayload(
93419
+ token.split(".")[0].replace(/-/g, "+").replace(/_/g, "/")
93420
+ ),
93421
+ payload: _decodePayload(
93422
+ token.split(".")[1].replace(/-/g, "+").replace(/_/g, "/")
93423
+ )
93424
+ };
93425
+ }
93426
+ async function handle_request(args) {
93427
+ const plugin_config2 = args.config.plugins?.["houdini-react"];
93428
+ if (plugin_config2.auth && "redirect" in plugin_config2.auth && args.url.startsWith(plugin_config2.auth.redirect)) {
93429
+ return await redirect_auth(args);
93430
+ }
93431
+ args.next();
93432
+ }
93433
+ async function redirect_auth(args) {
93434
+ const { searchParams } = new URL(args.url, `http://${args.get_header("host")}`);
93435
+ const { redirectTo, ...session } = Object.fromEntries(searchParams.entries());
93436
+ await set_session(args, session);
93437
+ if (redirectTo) {
93438
+ return args.redirect(302, redirectTo);
93439
+ }
93440
+ args.next();
93441
+ }
93442
+ var session_cookie_name = "__houdini__";
93443
+ async function set_session(req, value) {
93444
+ const today = new Date();
93445
+ const expires = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1e3);
93446
+ const serialized = await encode(value, req.session_keys[0]);
93447
+ req.set_header(
93448
+ "Set-Cookie",
93449
+ `${session_cookie_name}=${serialized}; Path=/; HttpOnly; Secure; SameSite=Lax; Expires=${expires.toUTCString()} `
93450
+ );
93451
+ }
93452
+ async function get_session(req, secrets) {
93453
+ const cookies = req.get("cookie");
93454
+ if (!cookies) {
93455
+ return {};
93456
+ }
93457
+ const cookie = parse5(cookies)[session_cookie_name];
93458
+ if (!cookie) {
93459
+ return {};
93460
+ }
93461
+ for (const secret of secrets) {
93462
+ if (!await verify(cookie, secret)) {
93463
+ continue;
93464
+ }
93465
+ const parsed = decode2(cookie);
93466
+ if (!parsed) {
93467
+ return {};
93468
+ }
93469
+ return parsed.payload;
93470
+ }
93471
+ return {};
93472
+ }
93462
93473
 
93463
93474
  // src/plugin/index.ts
93464
93475
  import path3 from "node:path";
@@ -93907,12 +93918,12 @@ function parse_page_pattern(id) {
93907
93918
  const result = parts.map((content, i2) => {
93908
93919
  if (i2 % 2) {
93909
93920
  if (content.startsWith("x+")) {
93910
- return escape(
93921
+ return escape2(
93911
93922
  String.fromCharCode(parseInt(content.slice(2), 16))
93912
93923
  );
93913
93924
  }
93914
93925
  if (content.startsWith("u+")) {
93915
- return escape(
93926
+ return escape2(
93916
93927
  String.fromCharCode(
93917
93928
  ...content.slice(2).split("-").map((code) => parseInt(code, 16))
93918
93929
  )
@@ -93934,7 +93945,7 @@ function parse_page_pattern(id) {
93934
93945
  });
93935
93946
  return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
93936
93947
  }
93937
- return escape(content);
93948
+ return escape2(content);
93938
93949
  }).join("");
93939
93950
  return "/" + result;
93940
93951
  }).join("")}/?$`
@@ -93969,7 +93980,7 @@ function exec(match, params) {
93969
93980
  return;
93970
93981
  return result;
93971
93982
  }
93972
- function escape(str) {
93983
+ function escape2(str) {
93973
93984
  return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
93974
93985
  }
93975
93986
 
@@ -95551,7 +95562,7 @@ var require_parser4 = __commonJS3({
95551
95562
  Object.defineProperty(exports, "__esModule", {
95552
95563
  value: true
95553
95564
  });
95554
- exports.parse = parse5;
95565
+ exports.parse = parse6;
95555
95566
  exports.parseValue = parseValue;
95556
95567
  exports.parseType = parseType;
95557
95568
  exports.Parser = void 0;
@@ -95562,7 +95573,7 @@ var require_parser4 = __commonJS3({
95562
95573
  var _source = require_source2();
95563
95574
  var _directiveLocation = require_directiveLocation2();
95564
95575
  var _lexer = require_lexer2();
95565
- function parse5(source, options) {
95576
+ function parse6(source, options) {
95566
95577
  var parser = new Parser(source, options);
95567
95578
  return parser.parseDocument();
95568
95579
  }
@@ -122263,14 +122274,14 @@ var require_lib32 = __commonJS3({
122263
122274
  super.checkParams(node, false, true);
122264
122275
  this.scope.exit();
122265
122276
  }
122266
- forwardNoArrowParamsConversionAt(node, parse6) {
122277
+ forwardNoArrowParamsConversionAt(node, parse7) {
122267
122278
  let result;
122268
122279
  if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
122269
122280
  this.state.noArrowParamsConversionAt.push(this.state.start);
122270
- result = parse6();
122281
+ result = parse7();
122271
122282
  this.state.noArrowParamsConversionAt.pop();
122272
122283
  } else {
122273
- result = parse6();
122284
+ result = parse7();
122274
122285
  }
122275
122286
  return result;
122276
122287
  }
@@ -131325,7 +131336,7 @@ var require_lib32 = __commonJS3({
131325
131336
  }
131326
131337
  return pluginMap;
131327
131338
  }
131328
- function parse5(input, options) {
131339
+ function parse6(input, options) {
131329
131340
  var _options;
131330
131341
  if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
131331
131342
  options = Object.assign({}, options);
@@ -131395,7 +131406,7 @@ var require_lib32 = __commonJS3({
131395
131406
  }
131396
131407
  return cls;
131397
131408
  }
131398
- exports.parse = parse5;
131409
+ exports.parse = parse6;
131399
131410
  exports.parseExpression = parseExpression;
131400
131411
  exports.tokTypes = tokTypes;
131401
131412
  }
@@ -137251,7 +137262,7 @@ var require_esprima22 = __commonJS3({
137251
137262
  var jsx_parser_1 = __webpack_require__(3);
137252
137263
  var parser_1 = __webpack_require__(8);
137253
137264
  var tokenizer_1 = __webpack_require__(15);
137254
- function parse5(code, options, delegate) {
137265
+ function parse6(code, options, delegate) {
137255
137266
  var commentHandler = null;
137256
137267
  var proxyDelegate = function(node, metadata) {
137257
137268
  if (delegate) {
@@ -137296,17 +137307,17 @@ var require_esprima22 = __commonJS3({
137296
137307
  }
137297
137308
  return ast;
137298
137309
  }
137299
- exports2.parse = parse5;
137310
+ exports2.parse = parse6;
137300
137311
  function parseModule(code, options, delegate) {
137301
137312
  var parsingOptions = options || {};
137302
137313
  parsingOptions.sourceType = "module";
137303
- return parse5(code, parsingOptions, delegate);
137314
+ return parse6(code, parsingOptions, delegate);
137304
137315
  }
137305
137316
  exports2.parseModule = parseModule;
137306
137317
  function parseScript(code, options, delegate) {
137307
137318
  var parsingOptions = options || {};
137308
137319
  parsingOptions.sourceType = "script";
137309
- return parse5(code, parsingOptions, delegate);
137320
+ return parse6(code, parsingOptions, delegate);
137310
137321
  }
137311
137322
  exports2.parseScript = parseScript;
137312
137323
  function tokenize(code, options, delegate) {
@@ -143368,7 +143379,7 @@ var require_esprima32 = __commonJS3({
143368
143379
  Object.defineProperty(exports, "__esModule", { value: true });
143369
143380
  exports.parse = void 0;
143370
143381
  var util_1 = require_util22();
143371
- function parse5(source, options) {
143382
+ function parse6(source, options) {
143372
143383
  var comments = [];
143373
143384
  var ast = require_esprima22().parse(source, {
143374
143385
  loc: true,
@@ -143386,7 +143397,7 @@ var require_esprima32 = __commonJS3({
143386
143397
  }
143387
143398
  return ast;
143388
143399
  }
143389
- exports.parse = parse5;
143400
+ exports.parse = parse6;
143390
143401
  }
143391
143402
  });
143392
143403
  var require_options3 = __commonJS3({
@@ -144498,7 +144509,7 @@ var require_parser22 = __commonJS3({
144498
144509
  var lines_1 = require_lines3();
144499
144510
  var comments_1 = require_comments3();
144500
144511
  var util = tslib_1.__importStar(require_util22());
144501
- function parse5(source, options) {
144512
+ function parse6(source, options) {
144502
144513
  options = (0, options_1.normalize)(options);
144503
144514
  var lines = (0, lines_1.fromString)(source, options);
144504
144515
  var sourceWithoutTabs = lines.toString({
@@ -144570,7 +144581,7 @@ var require_parser22 = __commonJS3({
144570
144581
  (0, comments_1.attach)(comments, program.body.length ? file.program : file, lines);
144571
144582
  return new TreeCopier(lines, tokens).copy(file);
144572
144583
  }
144573
- exports.parse = parse5;
144584
+ exports.parse = parse6;
144574
144585
  var TreeCopier = function TreeCopier2(lines, tokens) {
144575
144586
  assert_1.default.ok(this instanceof TreeCopier2);
144576
144587
  this.lines = lines;
@@ -165247,88 +165258,6 @@ function plugin_config(config) {
165247
165258
  return config.pluginConfig("houdini-react");
165248
165259
  }
165249
165260
 
165250
- // src/runtime/server/session.ts
165251
- var import_cookie_parser = __toESM(require_cookie_parser());
165252
- var session_cookie_name = "__houdini__";
165253
- function set_session(res, value) {
165254
- const today = new Date();
165255
- const expires = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1e3);
165256
- const serialized = JSON.stringify(value);
165257
- res.set_header(
165258
- "Set-Cookie",
165259
- `${session_cookie_name}=${serialized}; Path=/; HttpOnly; Secure; SameSite=Lax; Expires=${expires.toUTCString()} `
165260
- );
165261
- }
165262
- function get_session(req, secrets) {
165263
- const cookie = req.get("cookie");
165264
- if (!cookie) {
165265
- return {};
165266
- }
165267
- const parsed = import_cookie_parser.default.signedCookie(cookie, secrets);
165268
- if (!parsed) {
165269
- return {};
165270
- }
165271
- const houdini_session_cookie = parsed.split(";").map((s2) => s2.trim().split("=")).filter((s2) => s2[0] === session_cookie_name);
165272
- if (houdini_session_cookie.length === 1) {
165273
- return JSON.parse(houdini_session_cookie[0][1]);
165274
- }
165275
- return {};
165276
- }
165277
-
165278
- // src/runtime/server/index.ts
165279
- function configure_server({ server, config }) {
165280
- server.use(server_handler({ config }));
165281
- }
165282
- function server_handler({ config }) {
165283
- const plugin_config2 = plugin_config(config);
165284
- return (req, res, next) => {
165285
- if (!req.url) {
165286
- next();
165287
- return;
165288
- }
165289
- if (plugin_config2.auth && "redirect" in plugin_config2.auth && req.url.startsWith(plugin_config2.auth.redirect)) {
165290
- return redirect_auth(req, res, next);
165291
- }
165292
- next();
165293
- };
165294
- }
165295
- var redirect_auth = (req, res, next) => {
165296
- const { searchParams } = new URL(req.url, `http://${req.headers.get("host")}`);
165297
- const { redirectTo, ...session } = Object.fromEntries(searchParams.entries());
165298
- set_session(res, session);
165299
- if (redirectTo) {
165300
- return res.redirect(redirectTo);
165301
- }
165302
- next();
165303
- };
165304
-
165305
- // src/runtime/server/compat.ts
165306
- function dev_server({ server, config }) {
165307
- return {
165308
- use(fn) {
165309
- server.use((req, res, next) => {
165310
- fn(
165311
- {
165312
- url: req.url,
165313
- headers: new Headers(req.headers)
165314
- },
165315
- {
165316
- ...res,
165317
- redirect(url, status = 307) {
165318
- res.statusCode = status;
165319
- res.setHeader("location", url);
165320
- res.setHeader("content-length", "0");
165321
- return res.end();
165322
- },
165323
- set_header: res.setHeader.bind(res)
165324
- },
165325
- next
165326
- );
165327
- });
165328
- }
165329
- };
165330
- }
165331
-
165332
165261
  // src/plugin/vite.tsx
165333
165262
  var manifest;
165334
165263
  var vite_default = {
@@ -165448,17 +165377,32 @@ if (window.__houdini__nav_caches__ && window.__houdini__nav_caches__.artifact_ca
165448
165377
  }
165449
165378
  },
165450
165379
  configureServer(server) {
165451
- const houdini_server = dev_server({
165452
- server: server.middlewares,
165453
- config: server.houdiniConfig
165454
- });
165455
- configure_server({
165456
- server: houdini_server,
165457
- config: server.houdiniConfig
165458
- });
165380
+ server.middlewares.use(houdini_server(server));
165459
165381
  server.middlewares.use(render_stream(server));
165460
165382
  }
165461
165383
  };
165384
+ var houdini_server = (server) => {
165385
+ return async (req, res, next) => {
165386
+ if (!req.url) {
165387
+ return next();
165388
+ }
165389
+ handle_request({
165390
+ config: server.houdiniConfig.configFile,
165391
+ session_keys: plugin_config(server.houdiniConfig).auth?.sessionKeys ?? [],
165392
+ next,
165393
+ url: req.url,
165394
+ ...res,
165395
+ redirect(status = 307, url) {
165396
+ res.statusCode = status;
165397
+ res.setHeader("location", url);
165398
+ res.setHeader("content-length", "0");
165399
+ return res.end();
165400
+ },
165401
+ get_header: res.getHeader.bind(res),
165402
+ set_header: res.setHeader.bind(res)
165403
+ });
165404
+ };
165405
+ };
165462
165406
  var render_stream = (server) => async (request, response, next) => {
165463
165407
  if (!request.url) {
165464
165408
  return next();
@@ -165707,12 +165651,6 @@ export {
165707
165651
  * Copyright(c) 2015 Douglas Christopher Wilson
165708
165652
  * MIT Licensed
165709
165653
  */
165710
- /*!
165711
- * cookie-parser
165712
- * Copyright(c) 2014 TJ Holowaychuk
165713
- * Copyright(c) 2015 Douglas Christopher Wilson
165714
- * MIT Licensed
165715
- */
165716
165654
  /*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
165717
165655
  /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
165718
165656
  /*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */