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.
@@ -16359,234 +16359,6 @@ var require_main4 = __commonJS({
16359
16359
  }
16360
16360
  });
16361
16361
 
16362
- // ../../node_modules/.pnpm/cookie@0.4.1/node_modules/cookie/index.js
16363
- var require_cookie = __commonJS({
16364
- "../../node_modules/.pnpm/cookie@0.4.1/node_modules/cookie/index.js"(exports) {
16365
- "use strict";
16366
- exports.parse = parse3;
16367
- exports.serialize = serialize;
16368
- var decode = decodeURIComponent;
16369
- var encode = encodeURIComponent;
16370
- var pairSplitRegExp = /; */;
16371
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
16372
- function parse3(str, options) {
16373
- if (typeof str !== "string") {
16374
- throw new TypeError("argument str must be a string");
16375
- }
16376
- var obj = {};
16377
- var opt = options || {};
16378
- var pairs = str.split(pairSplitRegExp);
16379
- var dec = opt.decode || decode;
16380
- for (var i2 = 0; i2 < pairs.length; i2++) {
16381
- var pair = pairs[i2];
16382
- var eq_idx = pair.indexOf("=");
16383
- if (eq_idx < 0) {
16384
- continue;
16385
- }
16386
- var key = pair.substr(0, eq_idx).trim();
16387
- var val = pair.substr(++eq_idx, pair.length).trim();
16388
- if ('"' == val[0]) {
16389
- val = val.slice(1, -1);
16390
- }
16391
- if (void 0 == obj[key]) {
16392
- obj[key] = tryDecode(val, dec);
16393
- }
16394
- }
16395
- return obj;
16396
- }
16397
- function serialize(name, val, options) {
16398
- var opt = options || {};
16399
- var enc = opt.encode || encode;
16400
- if (typeof enc !== "function") {
16401
- throw new TypeError("option encode is invalid");
16402
- }
16403
- if (!fieldContentRegExp.test(name)) {
16404
- throw new TypeError("argument name is invalid");
16405
- }
16406
- var value = enc(val);
16407
- if (value && !fieldContentRegExp.test(value)) {
16408
- throw new TypeError("argument val is invalid");
16409
- }
16410
- var str = name + "=" + value;
16411
- if (null != opt.maxAge) {
16412
- var maxAge = opt.maxAge - 0;
16413
- if (isNaN(maxAge) || !isFinite(maxAge)) {
16414
- throw new TypeError("option maxAge is invalid");
16415
- }
16416
- str += "; Max-Age=" + Math.floor(maxAge);
16417
- }
16418
- if (opt.domain) {
16419
- if (!fieldContentRegExp.test(opt.domain)) {
16420
- throw new TypeError("option domain is invalid");
16421
- }
16422
- str += "; Domain=" + opt.domain;
16423
- }
16424
- if (opt.path) {
16425
- if (!fieldContentRegExp.test(opt.path)) {
16426
- throw new TypeError("option path is invalid");
16427
- }
16428
- str += "; Path=" + opt.path;
16429
- }
16430
- if (opt.expires) {
16431
- if (typeof opt.expires.toUTCString !== "function") {
16432
- throw new TypeError("option expires is invalid");
16433
- }
16434
- str += "; Expires=" + opt.expires.toUTCString();
16435
- }
16436
- if (opt.httpOnly) {
16437
- str += "; HttpOnly";
16438
- }
16439
- if (opt.secure) {
16440
- str += "; Secure";
16441
- }
16442
- if (opt.sameSite) {
16443
- var sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
16444
- switch (sameSite) {
16445
- case true:
16446
- str += "; SameSite=Strict";
16447
- break;
16448
- case "lax":
16449
- str += "; SameSite=Lax";
16450
- break;
16451
- case "strict":
16452
- str += "; SameSite=Strict";
16453
- break;
16454
- case "none":
16455
- str += "; SameSite=None";
16456
- break;
16457
- default:
16458
- throw new TypeError("option sameSite is invalid");
16459
- }
16460
- }
16461
- return str;
16462
- }
16463
- function tryDecode(str, decode2) {
16464
- try {
16465
- return decode2(str);
16466
- } catch (e2) {
16467
- return str;
16468
- }
16469
- }
16470
- }
16471
- });
16472
-
16473
- // ../../node_modules/.pnpm/cookie-signature@1.0.6/node_modules/cookie-signature/index.js
16474
- var require_cookie_signature = __commonJS({
16475
- "../../node_modules/.pnpm/cookie-signature@1.0.6/node_modules/cookie-signature/index.js"(exports) {
16476
- var crypto = require("crypto");
16477
- exports.sign = function(val, secret) {
16478
- if ("string" != typeof val)
16479
- throw new TypeError("Cookie value must be provided as a string.");
16480
- if ("string" != typeof secret)
16481
- throw new TypeError("Secret string must be provided.");
16482
- return val + "." + crypto.createHmac("sha256", secret).update(val).digest("base64").replace(/\=+$/, "");
16483
- };
16484
- exports.unsign = function(val, secret) {
16485
- if ("string" != typeof val)
16486
- throw new TypeError("Signed cookie string must be provided.");
16487
- if ("string" != typeof secret)
16488
- throw new TypeError("Secret string must be provided.");
16489
- var str = val.slice(0, val.lastIndexOf(".")), mac = exports.sign(str, secret);
16490
- return sha1(mac) == sha1(val) ? str : false;
16491
- };
16492
- function sha1(str) {
16493
- return crypto.createHash("sha1").update(str).digest("hex");
16494
- }
16495
- }
16496
- });
16497
-
16498
- // ../../node_modules/.pnpm/cookie-parser@1.4.6/node_modules/cookie-parser/index.js
16499
- var require_cookie_parser = __commonJS({
16500
- "../../node_modules/.pnpm/cookie-parser@1.4.6/node_modules/cookie-parser/index.js"(exports, module2) {
16501
- "use strict";
16502
- var cookie = require_cookie();
16503
- var signature = require_cookie_signature();
16504
- module2.exports = cookieParser2;
16505
- module2.exports.JSONCookie = JSONCookie;
16506
- module2.exports.JSONCookies = JSONCookies;
16507
- module2.exports.signedCookie = signedCookie;
16508
- module2.exports.signedCookies = signedCookies;
16509
- function cookieParser2(secret, options) {
16510
- var secrets = !secret || Array.isArray(secret) ? secret || [] : [secret];
16511
- return function cookieParser3(req, res, next) {
16512
- if (req.cookies) {
16513
- return next();
16514
- }
16515
- var cookies = req.headers.cookie;
16516
- req.secret = secrets[0];
16517
- req.cookies = /* @__PURE__ */ Object.create(null);
16518
- req.signedCookies = /* @__PURE__ */ Object.create(null);
16519
- if (!cookies) {
16520
- return next();
16521
- }
16522
- req.cookies = cookie.parse(cookies, options);
16523
- if (secrets.length !== 0) {
16524
- req.signedCookies = signedCookies(req.cookies, secrets);
16525
- req.signedCookies = JSONCookies(req.signedCookies);
16526
- }
16527
- req.cookies = JSONCookies(req.cookies);
16528
- next();
16529
- };
16530
- }
16531
- function JSONCookie(str) {
16532
- if (typeof str !== "string" || str.substr(0, 2) !== "j:") {
16533
- return void 0;
16534
- }
16535
- try {
16536
- return JSON.parse(str.slice(2));
16537
- } catch (err) {
16538
- return void 0;
16539
- }
16540
- }
16541
- function JSONCookies(obj) {
16542
- var cookies = Object.keys(obj);
16543
- var key;
16544
- var val;
16545
- for (var i2 = 0; i2 < cookies.length; i2++) {
16546
- key = cookies[i2];
16547
- val = JSONCookie(obj[key]);
16548
- if (val) {
16549
- obj[key] = val;
16550
- }
16551
- }
16552
- return obj;
16553
- }
16554
- function signedCookie(str, secret) {
16555
- if (typeof str !== "string") {
16556
- return void 0;
16557
- }
16558
- if (str.substr(0, 2) !== "s:") {
16559
- return str;
16560
- }
16561
- var secrets = !secret || Array.isArray(secret) ? secret || [] : [secret];
16562
- for (var i2 = 0; i2 < secrets.length; i2++) {
16563
- var val = signature.unsign(str.slice(2), secrets[i2]);
16564
- if (val !== false) {
16565
- return val;
16566
- }
16567
- }
16568
- return false;
16569
- }
16570
- function signedCookies(obj, secret) {
16571
- var cookies = Object.keys(obj);
16572
- var dec;
16573
- var key;
16574
- var ret = /* @__PURE__ */ Object.create(null);
16575
- var val;
16576
- for (var i2 = 0; i2 < cookies.length; i2++) {
16577
- key = cookies[i2];
16578
- val = obj[key];
16579
- dec = signedCookie(val, secret);
16580
- if (val !== dec) {
16581
- ret[key] = dec;
16582
- delete obj[key];
16583
- }
16584
- }
16585
- return ret;
16586
- }
16587
- }
16588
- });
16589
-
16590
16362
  // src/plugin/index.ts
16591
16363
  var plugin_exports = {};
16592
16364
  __export(plugin_exports, {
@@ -18054,7 +17826,7 @@ var require_parser = __commonJS2({
18054
17826
  Object.defineProperty(exports, "__esModule", {
18055
17827
  value: true
18056
17828
  });
18057
- exports.parse = parse5;
17829
+ exports.parse = parse6;
18058
17830
  exports.parseValue = parseValue;
18059
17831
  exports.parseType = parseType;
18060
17832
  exports.Parser = void 0;
@@ -18065,7 +17837,7 @@ var require_parser = __commonJS2({
18065
17837
  var _source = require_source();
18066
17838
  var _directiveLocation = require_directiveLocation();
18067
17839
  var _lexer = require_lexer();
18068
- function parse5(source, options) {
17840
+ function parse6(source, options) {
18069
17841
  var parser = new Parser(source, options);
18070
17842
  return parser.parseDocument();
18071
17843
  }
@@ -49127,14 +48899,14 @@ var require_lib3 = __commonJS2({
49127
48899
  super.checkParams(node, false, true);
49128
48900
  this.scope.exit();
49129
48901
  }
49130
- forwardNoArrowParamsConversionAt(node, parse6) {
48902
+ forwardNoArrowParamsConversionAt(node, parse7) {
49131
48903
  let result;
49132
48904
  if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
49133
48905
  this.state.noArrowParamsConversionAt.push(this.state.start);
49134
- result = parse6();
48906
+ result = parse7();
49135
48907
  this.state.noArrowParamsConversionAt.pop();
49136
48908
  } else {
49137
- result = parse6();
48909
+ result = parse7();
49138
48910
  }
49139
48911
  return result;
49140
48912
  }
@@ -58189,7 +57961,7 @@ var require_lib3 = __commonJS2({
58189
57961
  }
58190
57962
  return pluginMap;
58191
57963
  }
58192
- function parse5(input, options) {
57964
+ function parse6(input, options) {
58193
57965
  var _options;
58194
57966
  if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
58195
57967
  options = Object.assign({}, options);
@@ -58259,7 +58031,7 @@ var require_lib3 = __commonJS2({
58259
58031
  }
58260
58032
  return cls;
58261
58033
  }
58262
- exports.parse = parse5;
58034
+ exports.parse = parse6;
58263
58035
  exports.parseExpression = parseExpression;
58264
58036
  exports.tokTypes = tokTypes;
58265
58037
  }
@@ -64115,7 +63887,7 @@ var require_esprima2 = __commonJS2({
64115
63887
  var jsx_parser_1 = __webpack_require__(3);
64116
63888
  var parser_1 = __webpack_require__(8);
64117
63889
  var tokenizer_1 = __webpack_require__(15);
64118
- function parse5(code, options, delegate) {
63890
+ function parse6(code, options, delegate) {
64119
63891
  var commentHandler = null;
64120
63892
  var proxyDelegate = function(node, metadata) {
64121
63893
  if (delegate) {
@@ -64160,17 +63932,17 @@ var require_esprima2 = __commonJS2({
64160
63932
  }
64161
63933
  return ast;
64162
63934
  }
64163
- exports2.parse = parse5;
63935
+ exports2.parse = parse6;
64164
63936
  function parseModule(code, options, delegate) {
64165
63937
  var parsingOptions = options || {};
64166
63938
  parsingOptions.sourceType = "module";
64167
- return parse5(code, parsingOptions, delegate);
63939
+ return parse6(code, parsingOptions, delegate);
64168
63940
  }
64169
63941
  exports2.parseModule = parseModule;
64170
63942
  function parseScript(code, options, delegate) {
64171
63943
  var parsingOptions = options || {};
64172
63944
  parsingOptions.sourceType = "script";
64173
- return parse5(code, parsingOptions, delegate);
63945
+ return parse6(code, parsingOptions, delegate);
64174
63946
  }
64175
63947
  exports2.parseScript = parseScript;
64176
63948
  function tokenize(code, options, delegate) {
@@ -70232,7 +70004,7 @@ var require_esprima3 = __commonJS2({
70232
70004
  Object.defineProperty(exports, "__esModule", { value: true });
70233
70005
  exports.parse = void 0;
70234
70006
  var util_1 = require_util2();
70235
- function parse5(source, options) {
70007
+ function parse6(source, options) {
70236
70008
  var comments = [];
70237
70009
  var ast = require_esprima2().parse(source, {
70238
70010
  loc: true,
@@ -70250,7 +70022,7 @@ var require_esprima3 = __commonJS2({
70250
70022
  }
70251
70023
  return ast;
70252
70024
  }
70253
- exports.parse = parse5;
70025
+ exports.parse = parse6;
70254
70026
  }
70255
70027
  });
70256
70028
  var require_options = __commonJS2({
@@ -71362,7 +71134,7 @@ var require_parser2 = __commonJS2({
71362
71134
  var lines_1 = require_lines();
71363
71135
  var comments_1 = require_comments();
71364
71136
  var util = tslib_1.__importStar(require_util2());
71365
- function parse5(source, options) {
71137
+ function parse6(source, options) {
71366
71138
  options = (0, options_1.normalize)(options);
71367
71139
  var lines = (0, lines_1.fromString)(source, options);
71368
71140
  var sourceWithoutTabs = lines.toString({
@@ -71434,7 +71206,7 @@ var require_parser2 = __commonJS2({
71434
71206
  (0, comments_1.attach)(comments, program.body.length ? file.program : file, lines);
71435
71207
  return new TreeCopier(lines, tokens).copy(file);
71436
71208
  }
71437
- exports.parse = parse5;
71209
+ exports.parse = parse6;
71438
71210
  var TreeCopier = function TreeCopier2(lines, tokens) {
71439
71211
  assert_1.default.ok(this instanceof TreeCopier2);
71440
71212
  this.lines = lines;
@@ -93469,6 +93241,245 @@ async function extractQueries(source) {
93469
93241
  }
93470
93242
  return props.filter((p) => p !== "children");
93471
93243
  }
93244
+ function parse5(str, options) {
93245
+ if (typeof str !== "string") {
93246
+ throw new TypeError("argument str must be a string");
93247
+ }
93248
+ let obj = {};
93249
+ let opt = options || {};
93250
+ let dec = opt.decode || decode;
93251
+ let index = 0;
93252
+ while (index < str.length) {
93253
+ let eqIdx = str.indexOf("=", index);
93254
+ if (eqIdx === -1) {
93255
+ break;
93256
+ }
93257
+ let endIdx = str.indexOf(";", index);
93258
+ if (endIdx === -1) {
93259
+ endIdx = str.length;
93260
+ } else if (endIdx < eqIdx) {
93261
+ index = str.lastIndexOf(";", eqIdx - 1) + 1;
93262
+ continue;
93263
+ }
93264
+ let key = str.slice(index, eqIdx).trim();
93265
+ if (void 0 === obj[key]) {
93266
+ let val = str.slice(eqIdx + 1, endIdx).trim();
93267
+ if (val.charCodeAt(0) === 34) {
93268
+ val = val.slice(1, -1);
93269
+ }
93270
+ obj[key] = tryDecode(val, dec);
93271
+ }
93272
+ index = endIdx + 1;
93273
+ }
93274
+ return obj;
93275
+ }
93276
+ function decode(str) {
93277
+ return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
93278
+ }
93279
+ function tryDecode(str, decode3) {
93280
+ try {
93281
+ return decode3(str);
93282
+ } catch (e2) {
93283
+ return str;
93284
+ }
93285
+ }
93286
+ function base64UrlParse(s2) {
93287
+ return new Uint8Array(
93288
+ Array.prototype.map.call(
93289
+ atob(s2.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "")),
93290
+ (c) => c.charCodeAt(0)
93291
+ )
93292
+ );
93293
+ }
93294
+ function base64UrlStringify(a) {
93295
+ return btoa(String.fromCharCode.apply(0, a)).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
93296
+ }
93297
+ var algorithms = {
93298
+ ES256: { name: "ECDSA", namedCurve: "P-256", hash: { name: "SHA-256" } },
93299
+ ES384: { name: "ECDSA", namedCurve: "P-384", hash: { name: "SHA-384" } },
93300
+ ES512: { name: "ECDSA", namedCurve: "P-521", hash: { name: "SHA-512" } },
93301
+ HS256: { name: "HMAC", hash: { name: "SHA-256" } },
93302
+ HS384: { name: "HMAC", hash: { name: "SHA-384" } },
93303
+ HS512: { name: "HMAC", hash: { name: "SHA-512" } },
93304
+ RS256: { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-256" } },
93305
+ RS384: { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-384" } },
93306
+ RS512: { name: "RSASSA-PKCS1-v1_5", hash: { name: "SHA-512" } }
93307
+ };
93308
+ function _utf8ToUint8Array(str) {
93309
+ return base64UrlParse(btoa(unescape(encodeURIComponent(str))));
93310
+ }
93311
+ function _str2ab(str) {
93312
+ str = atob(str);
93313
+ const buf = new ArrayBuffer(str.length);
93314
+ const bufView = new Uint8Array(buf);
93315
+ for (let i2 = 0, strLen = str.length; i2 < strLen; i2++) {
93316
+ bufView[i2] = str.charCodeAt(i2);
93317
+ }
93318
+ return buf;
93319
+ }
93320
+ function _decodePayload(raw) {
93321
+ switch (raw.length % 4) {
93322
+ case 0:
93323
+ break;
93324
+ case 2:
93325
+ raw += "==";
93326
+ break;
93327
+ case 3:
93328
+ raw += "=";
93329
+ break;
93330
+ default:
93331
+ throw new Error("Illegal base64url string!");
93332
+ }
93333
+ try {
93334
+ return JSON.parse(decodeURIComponent(escape(atob(raw))));
93335
+ } catch {
93336
+ return null;
93337
+ }
93338
+ }
93339
+ async function encode(payload, secret, options = { algorithm: "HS256", header: { typ: "JWT" } }) {
93340
+ if (typeof options === "string")
93341
+ options = { algorithm: options, header: { typ: "JWT" } };
93342
+ options = { algorithm: "HS256", header: { typ: "JWT" }, ...options };
93343
+ if (payload === null || typeof payload !== "object")
93344
+ throw new Error("payload must be an object");
93345
+ if (typeof secret !== "string" && typeof secret !== "object")
93346
+ throw new Error("secret must be a string or a JWK object");
93347
+ if (typeof options.algorithm !== "string")
93348
+ throw new Error("options.algorithm must be a string");
93349
+ const algorithm = algorithms[options.algorithm];
93350
+ if (!algorithm)
93351
+ throw new Error("algorithm not found");
93352
+ if (!payload.iat)
93353
+ payload.iat = Math.floor(Date.now() / 1e3);
93354
+ const payloadAsJSON = JSON.stringify(payload);
93355
+ const partialToken = `${base64UrlStringify(
93356
+ _utf8ToUint8Array(JSON.stringify({ ...options.header, alg: options.algorithm }))
93357
+ )}.${base64UrlStringify(_utf8ToUint8Array(payloadAsJSON))}`;
93358
+ let keyFormat = "raw";
93359
+ let keyData;
93360
+ if (typeof secret === "object") {
93361
+ keyFormat = "jwk";
93362
+ keyData = secret;
93363
+ } else if (typeof secret === "string" && secret.startsWith("-----BEGIN")) {
93364
+ keyFormat = "pkcs8";
93365
+ keyData = _str2ab(
93366
+ secret.replace(/-----BEGIN.*?-----/g, "").replace(/-----END.*?-----/g, "").replace(/\s/g, "")
93367
+ );
93368
+ } else
93369
+ keyData = _utf8ToUint8Array(secret);
93370
+ const key = await crypto.subtle.importKey(keyFormat, keyData, algorithm, false, ["sign"]);
93371
+ const signature = await crypto.subtle.sign(algorithm, key, _utf8ToUint8Array(partialToken));
93372
+ return `${partialToken}.${base64UrlStringify(new Uint8Array(signature))}`;
93373
+ }
93374
+ async function verify(token, secret, options = { algorithm: "HS256", throwError: false }) {
93375
+ if (typeof options === "string")
93376
+ options = { algorithm: options, throwError: false };
93377
+ options = { algorithm: "HS256", throwError: false, ...options };
93378
+ if (typeof token !== "string")
93379
+ throw new Error("token must be a string");
93380
+ if (typeof secret !== "string" && typeof secret !== "object")
93381
+ throw new Error("secret must be a string or a JWK object");
93382
+ if (typeof options.algorithm !== "string")
93383
+ throw new Error("options.algorithm must be a string");
93384
+ const tokenParts = token.split(".");
93385
+ if (tokenParts.length !== 3)
93386
+ throw new Error("token must consist of 3 parts");
93387
+ const algorithm = algorithms[options.algorithm];
93388
+ if (!algorithm)
93389
+ throw new Error("algorithm not found");
93390
+ const { payload } = decode2(token);
93391
+ if (!payload) {
93392
+ if (options.throwError)
93393
+ throw "PARSE_ERROR";
93394
+ return false;
93395
+ }
93396
+ if (payload.nbf && payload.nbf > Math.floor(Date.now() / 1e3)) {
93397
+ if (options.throwError)
93398
+ throw "NOT_YET_VALID";
93399
+ return false;
93400
+ }
93401
+ if (payload.exp && payload.exp <= Math.floor(Date.now() / 1e3)) {
93402
+ if (options.throwError)
93403
+ throw "EXPIRED";
93404
+ return false;
93405
+ }
93406
+ let keyFormat = "raw";
93407
+ let keyData;
93408
+ if (typeof secret === "object") {
93409
+ keyFormat = "jwk";
93410
+ keyData = secret;
93411
+ } else if (typeof secret === "string" && secret.startsWith("-----BEGIN")) {
93412
+ keyFormat = "spki";
93413
+ keyData = _str2ab(
93414
+ secret.replace(/-----BEGIN.*?-----/g, "").replace(/-----END.*?-----/g, "").replace(/\s/g, "")
93415
+ );
93416
+ } else
93417
+ keyData = _utf8ToUint8Array(secret);
93418
+ const key = await crypto.subtle.importKey(keyFormat, keyData, algorithm, false, ["verify"]);
93419
+ return await crypto.subtle.verify(
93420
+ algorithm,
93421
+ key,
93422
+ base64UrlParse(tokenParts[2]),
93423
+ _utf8ToUint8Array(`${tokenParts[0]}.${tokenParts[1]}`)
93424
+ );
93425
+ }
93426
+ function decode2(token) {
93427
+ return {
93428
+ header: _decodePayload(
93429
+ token.split(".")[0].replace(/-/g, "+").replace(/_/g, "/")
93430
+ ),
93431
+ payload: _decodePayload(
93432
+ token.split(".")[1].replace(/-/g, "+").replace(/_/g, "/")
93433
+ )
93434
+ };
93435
+ }
93436
+ async function handle_request(args) {
93437
+ const plugin_config2 = args.config.plugins?.["houdini-react"];
93438
+ if (plugin_config2.auth && "redirect" in plugin_config2.auth && args.url.startsWith(plugin_config2.auth.redirect)) {
93439
+ return await redirect_auth(args);
93440
+ }
93441
+ args.next();
93442
+ }
93443
+ async function redirect_auth(args) {
93444
+ const { searchParams } = new URL(args.url, `http://${args.get_header("host")}`);
93445
+ const { redirectTo, ...session } = Object.fromEntries(searchParams.entries());
93446
+ await set_session(args, session);
93447
+ if (redirectTo) {
93448
+ return args.redirect(302, redirectTo);
93449
+ }
93450
+ args.next();
93451
+ }
93452
+ var session_cookie_name = "__houdini__";
93453
+ async function set_session(req, value) {
93454
+ const today = new Date();
93455
+ const expires = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1e3);
93456
+ const serialized = await encode(value, req.session_keys[0]);
93457
+ req.set_header(
93458
+ "Set-Cookie",
93459
+ `${session_cookie_name}=${serialized}; Path=/; HttpOnly; Secure; SameSite=Lax; Expires=${expires.toUTCString()} `
93460
+ );
93461
+ }
93462
+ async function get_session(req, secrets) {
93463
+ const cookies = req.get("cookie");
93464
+ if (!cookies) {
93465
+ return {};
93466
+ }
93467
+ const cookie = parse5(cookies)[session_cookie_name];
93468
+ if (!cookie) {
93469
+ return {};
93470
+ }
93471
+ for (const secret of secrets) {
93472
+ if (!await verify(cookie, secret)) {
93473
+ continue;
93474
+ }
93475
+ const parsed = decode2(cookie);
93476
+ if (!parsed) {
93477
+ return {};
93478
+ }
93479
+ return parsed.payload;
93480
+ }
93481
+ return {};
93482
+ }
93472
93483
 
93473
93484
  // src/plugin/index.ts
93474
93485
  var import_node_path3 = __toESM(require("node:path"));
@@ -93917,12 +93928,12 @@ function parse_page_pattern(id) {
93917
93928
  const result = parts.map((content, i2) => {
93918
93929
  if (i2 % 2) {
93919
93930
  if (content.startsWith("x+")) {
93920
- return escape(
93931
+ return escape2(
93921
93932
  String.fromCharCode(parseInt(content.slice(2), 16))
93922
93933
  );
93923
93934
  }
93924
93935
  if (content.startsWith("u+")) {
93925
- return escape(
93936
+ return escape2(
93926
93937
  String.fromCharCode(
93927
93938
  ...content.slice(2).split("-").map((code) => parseInt(code, 16))
93928
93939
  )
@@ -93944,7 +93955,7 @@ function parse_page_pattern(id) {
93944
93955
  });
93945
93956
  return is_rest ? "(.*?)" : is_optional ? "([^/]*)?" : "([^/]+?)";
93946
93957
  }
93947
- return escape(content);
93958
+ return escape2(content);
93948
93959
  }).join("");
93949
93960
  return "/" + result;
93950
93961
  }).join("")}/?$`
@@ -93979,7 +93990,7 @@ function exec(match, params) {
93979
93990
  return;
93980
93991
  return result;
93981
93992
  }
93982
- function escape(str) {
93993
+ function escape2(str) {
93983
93994
  return str.normalize().replace(/[[\]]/g, "\\$&").replace(/%/g, "%25").replace(/\//g, "%2[Ff]").replace(/\?/g, "%3[Ff]").replace(/#/g, "%23").replace(/[.*+?^${}()|\\]/g, "\\$&");
93984
93995
  }
93985
93996
 
@@ -95562,7 +95573,7 @@ var require_parser4 = __commonJS3({
95562
95573
  Object.defineProperty(exports, "__esModule", {
95563
95574
  value: true
95564
95575
  });
95565
- exports.parse = parse5;
95576
+ exports.parse = parse6;
95566
95577
  exports.parseValue = parseValue;
95567
95578
  exports.parseType = parseType;
95568
95579
  exports.Parser = void 0;
@@ -95573,7 +95584,7 @@ var require_parser4 = __commonJS3({
95573
95584
  var _source = require_source2();
95574
95585
  var _directiveLocation = require_directiveLocation2();
95575
95586
  var _lexer = require_lexer2();
95576
- function parse5(source, options) {
95587
+ function parse6(source, options) {
95577
95588
  var parser = new Parser(source, options);
95578
95589
  return parser.parseDocument();
95579
95590
  }
@@ -122274,14 +122285,14 @@ var require_lib32 = __commonJS3({
122274
122285
  super.checkParams(node, false, true);
122275
122286
  this.scope.exit();
122276
122287
  }
122277
- forwardNoArrowParamsConversionAt(node, parse6) {
122288
+ forwardNoArrowParamsConversionAt(node, parse7) {
122278
122289
  let result;
122279
122290
  if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
122280
122291
  this.state.noArrowParamsConversionAt.push(this.state.start);
122281
- result = parse6();
122292
+ result = parse7();
122282
122293
  this.state.noArrowParamsConversionAt.pop();
122283
122294
  } else {
122284
- result = parse6();
122295
+ result = parse7();
122285
122296
  }
122286
122297
  return result;
122287
122298
  }
@@ -131336,7 +131347,7 @@ var require_lib32 = __commonJS3({
131336
131347
  }
131337
131348
  return pluginMap;
131338
131349
  }
131339
- function parse5(input, options) {
131350
+ function parse6(input, options) {
131340
131351
  var _options;
131341
131352
  if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
131342
131353
  options = Object.assign({}, options);
@@ -131406,7 +131417,7 @@ var require_lib32 = __commonJS3({
131406
131417
  }
131407
131418
  return cls;
131408
131419
  }
131409
- exports.parse = parse5;
131420
+ exports.parse = parse6;
131410
131421
  exports.parseExpression = parseExpression;
131411
131422
  exports.tokTypes = tokTypes;
131412
131423
  }
@@ -137262,7 +137273,7 @@ var require_esprima22 = __commonJS3({
137262
137273
  var jsx_parser_1 = __webpack_require__(3);
137263
137274
  var parser_1 = __webpack_require__(8);
137264
137275
  var tokenizer_1 = __webpack_require__(15);
137265
- function parse5(code, options, delegate) {
137276
+ function parse6(code, options, delegate) {
137266
137277
  var commentHandler = null;
137267
137278
  var proxyDelegate = function(node, metadata) {
137268
137279
  if (delegate) {
@@ -137307,17 +137318,17 @@ var require_esprima22 = __commonJS3({
137307
137318
  }
137308
137319
  return ast;
137309
137320
  }
137310
- exports2.parse = parse5;
137321
+ exports2.parse = parse6;
137311
137322
  function parseModule(code, options, delegate) {
137312
137323
  var parsingOptions = options || {};
137313
137324
  parsingOptions.sourceType = "module";
137314
- return parse5(code, parsingOptions, delegate);
137325
+ return parse6(code, parsingOptions, delegate);
137315
137326
  }
137316
137327
  exports2.parseModule = parseModule;
137317
137328
  function parseScript(code, options, delegate) {
137318
137329
  var parsingOptions = options || {};
137319
137330
  parsingOptions.sourceType = "script";
137320
- return parse5(code, parsingOptions, delegate);
137331
+ return parse6(code, parsingOptions, delegate);
137321
137332
  }
137322
137333
  exports2.parseScript = parseScript;
137323
137334
  function tokenize(code, options, delegate) {
@@ -143379,7 +143390,7 @@ var require_esprima32 = __commonJS3({
143379
143390
  Object.defineProperty(exports, "__esModule", { value: true });
143380
143391
  exports.parse = void 0;
143381
143392
  var util_1 = require_util22();
143382
- function parse5(source, options) {
143393
+ function parse6(source, options) {
143383
143394
  var comments = [];
143384
143395
  var ast = require_esprima22().parse(source, {
143385
143396
  loc: true,
@@ -143397,7 +143408,7 @@ var require_esprima32 = __commonJS3({
143397
143408
  }
143398
143409
  return ast;
143399
143410
  }
143400
- exports.parse = parse5;
143411
+ exports.parse = parse6;
143401
143412
  }
143402
143413
  });
143403
143414
  var require_options3 = __commonJS3({
@@ -144509,7 +144520,7 @@ var require_parser22 = __commonJS3({
144509
144520
  var lines_1 = require_lines3();
144510
144521
  var comments_1 = require_comments3();
144511
144522
  var util = tslib_1.__importStar(require_util22());
144512
- function parse5(source, options) {
144523
+ function parse6(source, options) {
144513
144524
  options = (0, options_1.normalize)(options);
144514
144525
  var lines = (0, lines_1.fromString)(source, options);
144515
144526
  var sourceWithoutTabs = lines.toString({
@@ -144581,7 +144592,7 @@ var require_parser22 = __commonJS3({
144581
144592
  (0, comments_1.attach)(comments, program.body.length ? file.program : file, lines);
144582
144593
  return new TreeCopier(lines, tokens).copy(file);
144583
144594
  }
144584
- exports.parse = parse5;
144595
+ exports.parse = parse6;
144585
144596
  var TreeCopier = function TreeCopier2(lines, tokens) {
144586
144597
  assert_1.default.ok(this instanceof TreeCopier2);
144587
144598
  this.lines = lines;
@@ -165258,88 +165269,6 @@ function plugin_config(config) {
165258
165269
  return config.pluginConfig("houdini-react");
165259
165270
  }
165260
165271
 
165261
- // src/runtime/server/session.ts
165262
- var import_cookie_parser = __toESM(require_cookie_parser());
165263
- var session_cookie_name = "__houdini__";
165264
- function set_session(res, value) {
165265
- const today = new Date();
165266
- const expires = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1e3);
165267
- const serialized = JSON.stringify(value);
165268
- res.set_header(
165269
- "Set-Cookie",
165270
- `${session_cookie_name}=${serialized}; Path=/; HttpOnly; Secure; SameSite=Lax; Expires=${expires.toUTCString()} `
165271
- );
165272
- }
165273
- function get_session(req, secrets) {
165274
- const cookie = req.get("cookie");
165275
- if (!cookie) {
165276
- return {};
165277
- }
165278
- const parsed = import_cookie_parser.default.signedCookie(cookie, secrets);
165279
- if (!parsed) {
165280
- return {};
165281
- }
165282
- const houdini_session_cookie = parsed.split(";").map((s2) => s2.trim().split("=")).filter((s2) => s2[0] === session_cookie_name);
165283
- if (houdini_session_cookie.length === 1) {
165284
- return JSON.parse(houdini_session_cookie[0][1]);
165285
- }
165286
- return {};
165287
- }
165288
-
165289
- // src/runtime/server/index.ts
165290
- function configure_server({ server, config }) {
165291
- server.use(server_handler({ config }));
165292
- }
165293
- function server_handler({ config }) {
165294
- const plugin_config2 = plugin_config(config);
165295
- return (req, res, next) => {
165296
- if (!req.url) {
165297
- next();
165298
- return;
165299
- }
165300
- if (plugin_config2.auth && "redirect" in plugin_config2.auth && req.url.startsWith(plugin_config2.auth.redirect)) {
165301
- return redirect_auth(req, res, next);
165302
- }
165303
- next();
165304
- };
165305
- }
165306
- var redirect_auth = (req, res, next) => {
165307
- const { searchParams } = new URL(req.url, `http://${req.headers.get("host")}`);
165308
- const { redirectTo, ...session } = Object.fromEntries(searchParams.entries());
165309
- set_session(res, session);
165310
- if (redirectTo) {
165311
- return res.redirect(redirectTo);
165312
- }
165313
- next();
165314
- };
165315
-
165316
- // src/runtime/server/compat.ts
165317
- function dev_server({ server, config }) {
165318
- return {
165319
- use(fn) {
165320
- server.use((req, res, next) => {
165321
- fn(
165322
- {
165323
- url: req.url,
165324
- headers: new Headers(req.headers)
165325
- },
165326
- {
165327
- ...res,
165328
- redirect(url, status = 307) {
165329
- res.statusCode = status;
165330
- res.setHeader("location", url);
165331
- res.setHeader("content-length", "0");
165332
- return res.end();
165333
- },
165334
- set_header: res.setHeader.bind(res)
165335
- },
165336
- next
165337
- );
165338
- });
165339
- }
165340
- };
165341
- }
165342
-
165343
165272
  // src/plugin/vite.tsx
165344
165273
  var manifest;
165345
165274
  var vite_default = {
@@ -165459,17 +165388,32 @@ if (window.__houdini__nav_caches__ && window.__houdini__nav_caches__.artifact_ca
165459
165388
  }
165460
165389
  },
165461
165390
  configureServer(server) {
165462
- const houdini_server = dev_server({
165463
- server: server.middlewares,
165464
- config: server.houdiniConfig
165465
- });
165466
- configure_server({
165467
- server: houdini_server,
165468
- config: server.houdiniConfig
165469
- });
165391
+ server.middlewares.use(houdini_server(server));
165470
165392
  server.middlewares.use(render_stream(server));
165471
165393
  }
165472
165394
  };
165395
+ var houdini_server = (server) => {
165396
+ return async (req, res, next) => {
165397
+ if (!req.url) {
165398
+ return next();
165399
+ }
165400
+ handle_request({
165401
+ config: server.houdiniConfig.configFile,
165402
+ session_keys: plugin_config(server.houdiniConfig).auth?.sessionKeys ?? [],
165403
+ next,
165404
+ url: req.url,
165405
+ ...res,
165406
+ redirect(status = 307, url) {
165407
+ res.statusCode = status;
165408
+ res.setHeader("location", url);
165409
+ res.setHeader("content-length", "0");
165410
+ return res.end();
165411
+ },
165412
+ get_header: res.getHeader.bind(res),
165413
+ set_header: res.setHeader.bind(res)
165414
+ });
165415
+ };
165416
+ };
165473
165417
  var render_stream = (server) => async (request, response, next) => {
165474
165418
  if (!request.url) {
165475
165419
  return next();
@@ -165718,12 +165662,6 @@ function setManifest(newManifest) {
165718
165662
  * Copyright(c) 2015 Douglas Christopher Wilson
165719
165663
  * MIT Licensed
165720
165664
  */
165721
- /*!
165722
- * cookie-parser
165723
- * Copyright(c) 2014 TJ Holowaychuk
165724
- * Copyright(c) 2015 Douglas Christopher Wilson
165725
- * MIT Licensed
165726
- */
165727
165665
  /*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
165728
165666
  /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
165729
165667
  /*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */