wabe 0.6.8 → 0.6.9

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/dist/index.js CHANGED
@@ -33,14 +33,14 @@ var require_plugin_crypto = __commonJS((exports) => {
33
33
  function _interopDefault(ex) {
34
34
  return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex;
35
35
  }
36
- var crypto2 = _interopDefault(__require("crypto"));
36
+ var crypto4 = _interopDefault(__require("crypto"));
37
37
  var createDigest = (algorithm, hmacKey, counter) => {
38
- const hmac = crypto2.createHmac(algorithm, Buffer.from(hmacKey, "hex"));
38
+ const hmac = crypto4.createHmac(algorithm, Buffer.from(hmacKey, "hex"));
39
39
  const digest = hmac.update(Buffer.from(counter, "hex")).digest();
40
40
  return digest.toString("hex");
41
41
  };
42
42
  var createRandomBytes = (size, encoding) => {
43
- return crypto2.randomBytes(size).toString(encoding);
43
+ return crypto4.randomBytes(size).toString(encoding);
44
44
  };
45
45
  exports.createDigest = createDigest;
46
46
  exports.createRandomBytes = createRandomBytes;
@@ -270,7 +270,7 @@ var require_core = __commonJS((exports) => {
270
270
  }
271
271
  function keyuri(options) {
272
272
  const tmpl = `otpauth://${options.type}/{labelPrefix}:{accountName}?secret={secret}{query}`;
273
- const params = [];
273
+ const params2 = [];
274
274
  if (STRATEGY.indexOf(options.type) < 0) {
275
275
  throw new Error(`Expecting options.type to be one of ${STRATEGY.join(", ")}. Received ${options.type}.`);
276
276
  }
@@ -278,21 +278,21 @@ var require_core = __commonJS((exports) => {
278
278
  if (options.counter == null || typeof options.counter !== "number") {
279
279
  throw new Error('Expecting options.counter to be a number when options.type is "hotp".');
280
280
  }
281
- params.push(`&counter=${options.counter}`);
281
+ params2.push(`&counter=${options.counter}`);
282
282
  }
283
283
  if (options.type === "totp" && options.step) {
284
- params.push(`&period=${options.step}`);
284
+ params2.push(`&period=${options.step}`);
285
285
  }
286
286
  if (options.digits) {
287
- params.push(`&digits=${options.digits}`);
287
+ params2.push(`&digits=${options.digits}`);
288
288
  }
289
289
  if (options.algorithm) {
290
- params.push(`&algorithm=${options.algorithm.toUpperCase()}`);
290
+ params2.push(`&algorithm=${options.algorithm.toUpperCase()}`);
291
291
  }
292
292
  if (options.issuer) {
293
- params.push(`&issuer=${encodeURIComponent(options.issuer)}`);
293
+ params2.push(`&issuer=${encodeURIComponent(options.issuer)}`);
294
294
  }
295
- return tmpl.replace("{labelPrefix}", encodeURIComponent(options.issuer || options.accountName)).replace("{accountName}", encodeURIComponent(options.accountName)).replace("{secret}", options.secret).replace("{query}", params.join(""));
295
+ return tmpl.replace("{labelPrefix}", encodeURIComponent(options.issuer || options.accountName)).replace("{accountName}", encodeURIComponent(options.accountName)).replace("{secret}", options.secret).replace("{query}", params2.join(""));
296
296
  }
297
297
 
298
298
  class OTP {
@@ -1057,7 +1057,7 @@ var require_ecdsa_sig_formatter = __commonJS((exports, module) => {
1057
1057
  var require_jwa = __commonJS((exports, module) => {
1058
1058
  var bufferEqual = require_buffer_equal_constant_time();
1059
1059
  var Buffer2 = require_safe_buffer().Buffer;
1060
- var crypto2 = __require("crypto");
1060
+ var crypto4 = __require("crypto");
1061
1061
  var formatEcdsa = require_ecdsa_sig_formatter();
1062
1062
  var util = __require("util");
1063
1063
  var MSG_INVALID_ALGORITHM = `"%s" is not a valid algorithm.
@@ -1066,7 +1066,7 @@ var require_jwa = __commonJS((exports, module) => {
1066
1066
  var MSG_INVALID_SECRET = "secret must be a string or buffer";
1067
1067
  var MSG_INVALID_VERIFIER_KEY = "key must be a string or a buffer";
1068
1068
  var MSG_INVALID_SIGNER_KEY = "key must be a string, a buffer or an object";
1069
- var supportsKeyObjects = typeof crypto2.createPublicKey === "function";
1069
+ var supportsKeyObjects = typeof crypto4.createPublicKey === "function";
1070
1070
  if (supportsKeyObjects) {
1071
1071
  MSG_INVALID_VERIFIER_KEY += " or a KeyObject";
1072
1072
  MSG_INVALID_SECRET += "or a KeyObject";
@@ -1156,7 +1156,7 @@ var require_jwa = __commonJS((exports, module) => {
1156
1156
  return function sign(thing, secret) {
1157
1157
  checkIsSecretKey(secret);
1158
1158
  thing = normalizeInput(thing);
1159
- var hmac = crypto2.createHmac("sha" + bits, secret);
1159
+ var hmac = crypto4.createHmac("sha" + bits, secret);
1160
1160
  var sig = (hmac.update(thing), hmac.digest("base64"));
1161
1161
  return fromBase64(sig);
1162
1162
  };
@@ -1171,7 +1171,7 @@ var require_jwa = __commonJS((exports, module) => {
1171
1171
  return function sign(thing, privateKey) {
1172
1172
  checkIsPrivateKey(privateKey);
1173
1173
  thing = normalizeInput(thing);
1174
- var signer = crypto2.createSign("RSA-SHA" + bits);
1174
+ var signer = crypto4.createSign("RSA-SHA" + bits);
1175
1175
  var sig = (signer.update(thing), signer.sign(privateKey, "base64"));
1176
1176
  return fromBase64(sig);
1177
1177
  };
@@ -1181,7 +1181,7 @@ var require_jwa = __commonJS((exports, module) => {
1181
1181
  checkIsPublicKey(publicKey);
1182
1182
  thing = normalizeInput(thing);
1183
1183
  signature = toBase64(signature);
1184
- var verifier = crypto2.createVerify("RSA-SHA" + bits);
1184
+ var verifier = crypto4.createVerify("RSA-SHA" + bits);
1185
1185
  verifier.update(thing);
1186
1186
  return verifier.verify(publicKey, signature, "base64");
1187
1187
  };
@@ -1190,11 +1190,11 @@ var require_jwa = __commonJS((exports, module) => {
1190
1190
  return function sign(thing, privateKey) {
1191
1191
  checkIsPrivateKey(privateKey);
1192
1192
  thing = normalizeInput(thing);
1193
- var signer = crypto2.createSign("RSA-SHA" + bits);
1193
+ var signer = crypto4.createSign("RSA-SHA" + bits);
1194
1194
  var sig = (signer.update(thing), signer.sign({
1195
1195
  key: privateKey,
1196
- padding: crypto2.constants.RSA_PKCS1_PSS_PADDING,
1197
- saltLength: crypto2.constants.RSA_PSS_SALTLEN_DIGEST
1196
+ padding: crypto4.constants.RSA_PKCS1_PSS_PADDING,
1197
+ saltLength: crypto4.constants.RSA_PSS_SALTLEN_DIGEST
1198
1198
  }, "base64"));
1199
1199
  return fromBase64(sig);
1200
1200
  };
@@ -1204,12 +1204,12 @@ var require_jwa = __commonJS((exports, module) => {
1204
1204
  checkIsPublicKey(publicKey);
1205
1205
  thing = normalizeInput(thing);
1206
1206
  signature = toBase64(signature);
1207
- var verifier = crypto2.createVerify("RSA-SHA" + bits);
1207
+ var verifier = crypto4.createVerify("RSA-SHA" + bits);
1208
1208
  verifier.update(thing);
1209
1209
  return verifier.verify({
1210
1210
  key: publicKey,
1211
- padding: crypto2.constants.RSA_PKCS1_PSS_PADDING,
1212
- saltLength: crypto2.constants.RSA_PSS_SALTLEN_DIGEST
1211
+ padding: crypto4.constants.RSA_PKCS1_PSS_PADDING,
1212
+ saltLength: crypto4.constants.RSA_PSS_SALTLEN_DIGEST
1213
1213
  }, signature, "base64");
1214
1214
  };
1215
1215
  }
@@ -22825,7 +22825,7 @@ var require_utils2 = __commonJS((exports, module) => {
22825
22825
  function parseContentType(str) {
22826
22826
  if (str.length === 0)
22827
22827
  return;
22828
- const params = Object.create(null);
22828
+ const params2 = Object.create(null);
22829
22829
  let i = 0;
22830
22830
  for (;i < str.length; ++i) {
22831
22831
  const code = str.charCodeAt(i);
@@ -22844,7 +22844,7 @@ var require_utils2 = __commonJS((exports, module) => {
22844
22844
  if (TOKEN[code] !== 1) {
22845
22845
  if (i === subtypeStart)
22846
22846
  return;
22847
- if (parseContentTypeParams(str, i, params) === undefined)
22847
+ if (parseContentTypeParams(str, i, params2) === undefined)
22848
22848
  return;
22849
22849
  break;
22850
22850
  }
@@ -22852,9 +22852,9 @@ var require_utils2 = __commonJS((exports, module) => {
22852
22852
  if (i === subtypeStart)
22853
22853
  return;
22854
22854
  const subtype = str.slice(subtypeStart, i).toLowerCase();
22855
- return { type, subtype, params };
22855
+ return { type, subtype, params: params2 };
22856
22856
  }
22857
- function parseContentTypeParams(str, i, params) {
22857
+ function parseContentTypeParams(str, i, params2) {
22858
22858
  while (i < str.length) {
22859
22859
  for (;i < str.length; ++i) {
22860
22860
  const code = str.charCodeAt(i);
@@ -22937,28 +22937,28 @@ var require_utils2 = __commonJS((exports, module) => {
22937
22937
  value = str.slice(valueStart, i);
22938
22938
  }
22939
22939
  name = name.toLowerCase();
22940
- if (params[name] === undefined)
22941
- params[name] = value;
22940
+ if (params2[name] === undefined)
22941
+ params2[name] = value;
22942
22942
  }
22943
- return params;
22943
+ return params2;
22944
22944
  }
22945
22945
  function parseDisposition(str, defDecoder) {
22946
22946
  if (str.length === 0)
22947
22947
  return;
22948
- const params = Object.create(null);
22948
+ const params2 = Object.create(null);
22949
22949
  let i = 0;
22950
22950
  for (;i < str.length; ++i) {
22951
22951
  const code = str.charCodeAt(i);
22952
22952
  if (TOKEN[code] !== 1) {
22953
- if (parseDispositionParams(str, i, params, defDecoder) === undefined)
22953
+ if (parseDispositionParams(str, i, params2, defDecoder) === undefined)
22954
22954
  return;
22955
22955
  break;
22956
22956
  }
22957
22957
  }
22958
22958
  const type = str.slice(0, i).toLowerCase();
22959
- return { type, params };
22959
+ return { type, params: params2 };
22960
22960
  }
22961
- function parseDispositionParams(str, i, params, defDecoder) {
22961
+ function parseDispositionParams(str, i, params2, defDecoder) {
22962
22962
  while (i < str.length) {
22963
22963
  for (;i < str.length; ++i) {
22964
22964
  const code = str.charCodeAt(i);
@@ -23100,10 +23100,10 @@ var require_utils2 = __commonJS((exports, module) => {
23100
23100
  return;
23101
23101
  }
23102
23102
  name = name.toLowerCase();
23103
- if (params[name] === undefined)
23104
- params[name] = value;
23103
+ if (params2[name] === undefined)
23104
+ params2[name] = value;
23105
23105
  }
23106
- return params;
23106
+ return params2;
23107
23107
  }
23108
23108
  function getDecoder(charset) {
23109
23109
  let lc;
@@ -29439,14 +29439,14 @@ var deleteFile = async (hookObject) => {
29439
29439
  const schema = hookObject.context.wabe.config.schema?.classes?.find((currentClass) => currentClass.name === hookObject.className);
29440
29440
  if (!schema)
29441
29441
  return;
29442
- Object.entries(schema.fields).filter(([_, value]) => value.type === "File").map(async ([fieldName]) => {
29442
+ await Promise.all(Object.entries(schema.fields).filter(([_, value]) => value.type === "File").map(([fieldName]) => {
29443
29443
  const fileName = hookObject.originalObject?.[fieldName]?.name;
29444
29444
  if (!fileName)
29445
29445
  return;
29446
29446
  if (!hookObject.context.wabe.controllers.file)
29447
29447
  throw new Error("No file adapter found");
29448
- await hookObject.context.wabe.controllers.file?.deleteFile(fileName);
29449
- });
29448
+ return hookObject.context.wabe.controllers.file?.deleteFile(fileName);
29449
+ }));
29450
29450
  };
29451
29451
  var defaultAfterDeleteFile = (hookObject) => deleteFile(hookObject);
29452
29452
 
@@ -29464,7 +29464,7 @@ var getFile = async (hookObject) => {
29464
29464
  if (!fileName && fileInfo.url)
29465
29465
  return fileInfo.url;
29466
29466
  const fileUrlGeneratedAt = new Date(fileInfo.urlGeneratedAt);
29467
- if (fileUrlGeneratedAt && fileUrlGeneratedAt.getTime() + urlCacheInSeconds * 1000 > new Date().getTime())
29467
+ if (fileUrlGeneratedAt && fileUrlGeneratedAt.getTime() + urlCacheInSeconds * 1000 > Date.now())
29468
29468
  return;
29469
29469
  if (!hookObject.context.wabe.controllers.file)
29470
29470
  throw new Error("No file adapter found");
@@ -29480,7 +29480,7 @@ var getFile = async (hookObject) => {
29480
29480
  url: fileUrlFromBucket || fileInfo.url
29481
29481
  }
29482
29482
  },
29483
- skipHooks: true
29483
+ _skipHooks: true
29484
29484
  });
29485
29485
  }));
29486
29486
  };
@@ -29517,6 +29517,52 @@ var handleFile = async (hookObject) => {
29517
29517
  var defaultBeforeCreateUpload = (hookObject) => handleFile(hookObject);
29518
29518
  var defaultBeforeUpdateUpload = (hookObject) => handleFile(hookObject);
29519
29519
 
29520
+ // ../wabe/src/utils/crypto.ts
29521
+ import { randomBytes } from "node:crypto";
29522
+ import { promisify } from "node:util";
29523
+ var params = {
29524
+ parallelism: 1,
29525
+ tagLength: 64,
29526
+ memory: 65536,
29527
+ passes: 2
29528
+ };
29529
+ var hashArgon2 = async (text) => {
29530
+ if (process.versions.bun)
29531
+ return Bun.password.hash(text, { algorithm: "argon2id" });
29532
+ const argon2 = promisify(__require("node:crypto").argon2);
29533
+ const nonce = randomBytes(16);
29534
+ const result = await argon2("argon2id", {
29535
+ message: text,
29536
+ nonce,
29537
+ ...params
29538
+ });
29539
+ return `$argon2id$v=19$m=${params.memory},t=${params.passes},p=${params.parallelism}$${nonce.toString("base64").replace(/=+$/, "")}$${result.toString("base64").replace(/=+$/, "")}`;
29540
+ };
29541
+ var verifyArgon2 = async (password, hash) => {
29542
+ if (process.versions.bun)
29543
+ return Bun.password.verify(password, hash, "argon2id");
29544
+ const [, algorithm, , paramString, nonceHex, storedHashHex] = hash.split("$");
29545
+ const kvPairs = paramString?.split(",");
29546
+ const parsedParams = Object.fromEntries(kvPairs?.map((pair) => {
29547
+ const [key, value] = pair.split("=");
29548
+ return [key, Number.parseInt(value || "", 10)];
29549
+ }) || []);
29550
+ const memory = parsedParams.m;
29551
+ const passes = parsedParams.t;
29552
+ const parallelism = parsedParams.p;
29553
+ const newDerived = await promisify(__require("node:crypto"))(algorithm, {
29554
+ nonce: Buffer.from(nonceHex || "", "base64"),
29555
+ parallelism,
29556
+ tagLength: 64,
29557
+ memory,
29558
+ passes,
29559
+ message: password
29560
+ });
29561
+ const isMatch = crypto.timingSafeEqual(Buffer.from(newDerived), Buffer.from(storedHashHex || "", "base64"));
29562
+ return isMatch;
29563
+ };
29564
+ var isArgon2Hash = (value) => typeof value === "string" && value.startsWith("$argon2");
29565
+
29520
29566
  // ../wabe/src/utils/export.ts
29521
29567
  var contextWithRoot = (context) => ({
29522
29568
  ...context,
@@ -29637,13 +29683,51 @@ class HookObject {
29637
29683
  }
29638
29684
 
29639
29685
  // ../wabe/src/utils/index.ts
29640
- var toBase32 = (stringToEncode) => {
29641
- const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
29686
+ var contextWithoutGraphQLCall = (context) => ({
29687
+ ...context,
29688
+ isGraphQLCall: false
29689
+ });
29690
+ var RFC4648 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
29691
+ var RFC4648_HEX = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
29692
+ var CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
29693
+ var toUint8Array = (data) => {
29694
+ if (data instanceof Uint8Array)
29695
+ return data;
29696
+ if (typeof data === "string") {
29697
+ const encoder = new TextEncoder;
29698
+ return encoder.encode(data);
29699
+ }
29700
+ if (data instanceof ArrayBuffer)
29701
+ return new Uint8Array(data);
29702
+ throw new TypeError("Unsupported data type for base32 encoding");
29703
+ };
29704
+ var base32Encode = (data, variant, options = {}) => {
29705
+ let alphabet;
29706
+ let defaultPadding;
29707
+ switch (variant) {
29708
+ case "RFC3548":
29709
+ case "RFC4648":
29710
+ alphabet = RFC4648;
29711
+ defaultPadding = true;
29712
+ break;
29713
+ case "RFC4648-HEX":
29714
+ alphabet = RFC4648_HEX;
29715
+ defaultPadding = true;
29716
+ break;
29717
+ case "Crockford":
29718
+ alphabet = CROCKFORD;
29719
+ defaultPadding = false;
29720
+ break;
29721
+ default:
29722
+ throw new Error(`Unknown base32 variant: ${variant}`);
29723
+ }
29724
+ const padding = options.padding !== undefined ? options.padding : defaultPadding;
29725
+ const view = toUint8Array(data);
29642
29726
  let bits = 0;
29643
29727
  let value = 0;
29644
29728
  let output = "";
29645
- for (let i = 0;i < stringToEncode.length; i++) {
29646
- value = value << 8 | stringToEncode[i];
29729
+ for (let i = 0;i < view.length; i++) {
29730
+ value = value << 8 | view[i];
29647
29731
  bits += 8;
29648
29732
  while (bits >= 5) {
29649
29733
  output += alphabet[value >>> bits - 5 & 31];
@@ -29653,6 +29737,11 @@ var toBase32 = (stringToEncode) => {
29653
29737
  if (bits > 0) {
29654
29738
  output += alphabet[value << 5 - bits & 31];
29655
29739
  }
29740
+ if (padding) {
29741
+ while (output.length % 8 !== 0) {
29742
+ output += "=";
29743
+ }
29744
+ }
29656
29745
  return output;
29657
29746
  };
29658
29747
  var getNewObjectAfterUpdateNestedProperty = (obj, path, value) => {
@@ -29673,7 +29762,6 @@ var getNewObjectAfterUpdateNestedProperty = (obj, path, value) => {
29673
29762
  var getNestedProperty = (obj, path) => {
29674
29763
  return path.split(".").reduce((acc, part) => acc?.[part], obj);
29675
29764
  };
29676
- var isArgon2Hash = (value) => typeof value === "string" && value.startsWith("$argon2");
29677
29765
  var firstLetterInUpperCase = (str) => {
29678
29766
  const indexOfFirstLetter = str.search(/[a-z]/i);
29679
29767
  return str.slice(0, indexOfFirstLetter) + str[indexOfFirstLetter]?.toUpperCase() + str.slice(indexOfFirstLetter + 1);
@@ -29712,7 +29800,7 @@ var defaultBeforeCreateForCreatedAt = (object) => {
29712
29800
  var defaultBeforeUpdateForUpdatedAt = (object) => {
29713
29801
  object.upsertNewData("updatedAt", new Date);
29714
29802
  };
29715
- var defaultBeforeCreateForDefaultValue = async (object) => {
29803
+ var defaultBeforeCreateForDefaultValue = (object) => {
29716
29804
  const schemaClass = getClassFromClassName(object.className, object.context.wabe.config);
29717
29805
  const allFields = Object.keys(schemaClass.fields);
29718
29806
  allFields.map((field) => {
@@ -29749,7 +29837,7 @@ var convertOperationTypeToPermission = (operationType) => {
29749
29837
  };
29750
29838
  return template[operationType];
29751
29839
  };
29752
- var _getPermissionPropertiesOfAClass = async ({
29840
+ var _getPermissionPropertiesOfAClass = ({
29753
29841
  className,
29754
29842
  operation,
29755
29843
  context
@@ -29803,6 +29891,8 @@ var _checkProtected = (hookObject, operationType) => {
29803
29891
  if (operationType === "beforeRead" /* BeforeRead */) {
29804
29892
  Object.keys(hookObject.select).map((fieldName) => {
29805
29893
  const protectedForCurrentField = schemaClass.fields[fieldName]?.protected;
29894
+ if (!protectedForCurrentField)
29895
+ return;
29806
29896
  if (protectedForCurrentField?.protectedOperations.includes("read")) {
29807
29897
  if (isRoot && protectedForCurrentField.authorizedRoles.includes("rootOnly"))
29808
29898
  return;
@@ -29979,13 +30069,12 @@ var defaultSetupAclBeforeCreate = async (hookObject) => {
29979
30069
  var defaultSetupAclOnUserAfterCreate = async (hookObject) => setupAcl(hookObject);
29980
30070
 
29981
30071
  // ../wabe/src/hooks/hashFieldHook.ts
29982
- import { hash, Algorithm } from "@node-rs/argon2";
29983
30072
  var hashField = ({
29984
30073
  value
29985
30074
  }) => {
29986
30075
  if (!value || typeof value !== "string" || isArgon2Hash(value))
29987
30076
  return value;
29988
- return hash(value, { algorithm: Algorithm.Argon2id });
30077
+ return hashArgon2(value);
29989
30078
  };
29990
30079
  async function hashFieldHook(hookObject) {
29991
30080
  if (hookObject.operationType !== "beforeCreate" /* BeforeCreate */ && hookObject.operationType !== "beforeUpdate" /* BeforeUpdate */)
@@ -30037,6 +30126,62 @@ var defaultBeforeCreateUser = (object) => {
30037
30126
  throw new Error("Sign up is disabled");
30038
30127
  };
30039
30128
 
30129
+ // ../wabe/src/authentication/utils.ts
30130
+ var getAuthenticationMethod = (listOfMethods, context) => {
30131
+ const customAuthenticationConfig = context.wabe.config?.authentication?.customAuthenticationMethods;
30132
+ if (!customAuthenticationConfig)
30133
+ throw new Error("No custom authentication methods found");
30134
+ const authenticationMethods = listOfMethods.filter((method) => method !== "secondaryFactor");
30135
+ if (authenticationMethods.length > 1 || authenticationMethods.length === 0)
30136
+ throw new Error("One authentication method is required at the time");
30137
+ const authenticationMethod = authenticationMethods[0];
30138
+ const validAuthenticationMethod = customAuthenticationConfig.find((method) => method.name.toLowerCase() === authenticationMethod?.toLowerCase());
30139
+ if (!validAuthenticationMethod)
30140
+ throw new Error("No available custom authentication methods found");
30141
+ return validAuthenticationMethod;
30142
+ };
30143
+
30144
+ // ../wabe/src/hooks/authentication.ts
30145
+ var defaultCallAuthenticationProviderOnBeforeCreateUser = async (hookObject) => {
30146
+ if (!hookObject.isFieldUpdated("authentication") || hookObject.getNewData().isOauth)
30147
+ return;
30148
+ const context = hookObject.context;
30149
+ const authentication = hookObject.getNewData().authentication;
30150
+ if (authentication.emailPasswordSRP)
30151
+ return;
30152
+ const { provider, name } = getAuthenticationMethod(Object.keys(authentication), context);
30153
+ const inputOfTheGoodAuthenticationMethod = authentication[name];
30154
+ const { authenticationDataToSave } = await provider.onSignUp({
30155
+ input: inputOfTheGoodAuthenticationMethod,
30156
+ context
30157
+ });
30158
+ hookObject.upsertNewData("authentication", {
30159
+ [name]: authenticationDataToSave
30160
+ });
30161
+ };
30162
+ var defaultCallAuthenticationProviderOnBeforeUpdateUser = async (hookObject) => {
30163
+ if (!hookObject.isFieldUpdated("authentication") || hookObject.getNewData().isOauth)
30164
+ return;
30165
+ const context = hookObject.context;
30166
+ const authentication = hookObject.getNewData().authentication;
30167
+ if (authentication.emailPasswordSRP)
30168
+ return;
30169
+ const { provider, name } = getAuthenticationMethod(Object.keys(authentication), context);
30170
+ if (!provider.onUpdateAuthenticationData)
30171
+ return;
30172
+ const inputOfTheGoodAuthenticationMethod = authentication[name];
30173
+ if (!hookObject.object?.id)
30174
+ return;
30175
+ const { authenticationDataToSave } = await provider.onUpdateAuthenticationData({
30176
+ context,
30177
+ input: inputOfTheGoodAuthenticationMethod,
30178
+ userId: hookObject.object.id
30179
+ });
30180
+ hookObject.upsertNewData("authentication", {
30181
+ [name]: authenticationDataToSave
30182
+ });
30183
+ };
30184
+
30040
30185
  // ../wabe/src/hooks/index.ts
30041
30186
  var OperationType;
30042
30187
  ((OperationType2) => {
@@ -30073,9 +30218,9 @@ var initializeHook = ({
30073
30218
  return {};
30074
30219
  return context.wabe.controllers.database.getObject({
30075
30220
  className,
30076
- context: contextWithRoot(context),
30221
+ context: contextWithoutGraphQLCall(contextWithRoot(context)),
30077
30222
  id,
30078
- skipHooks: true
30223
+ _skipHooks: true
30079
30224
  });
30080
30225
  };
30081
30226
  const computeObjects = async ({
@@ -30086,9 +30231,9 @@ var initializeHook = ({
30086
30231
  return [{}];
30087
30232
  const res = await context.wabe.controllers.database.getObjects({
30088
30233
  className,
30089
- context: contextWithRoot(context),
30234
+ context: contextWithoutGraphQLCall(contextWithRoot(context)),
30090
30235
  where: where ? where : { id: { in: ids } },
30091
- skipHooks: true
30236
+ _skipHooks: true
30092
30237
  });
30093
30238
  if (res.length === 0)
30094
30239
  return [{}];
@@ -30106,7 +30251,7 @@ var initializeHook = ({
30106
30251
  className,
30107
30252
  newData,
30108
30253
  operationType: options.operationType,
30109
- context,
30254
+ context: contextWithoutGraphQLCall(context),
30110
30255
  object,
30111
30256
  originalObject: options.originalObject,
30112
30257
  select
@@ -30137,7 +30282,7 @@ var initializeHook = ({
30137
30282
  className,
30138
30283
  newData,
30139
30284
  operationType: options.operationType,
30140
- context,
30285
+ context: contextWithoutGraphQLCall(context),
30141
30286
  object,
30142
30287
  originalObject: originalObjectToUse,
30143
30288
  select
@@ -30301,6 +30446,18 @@ var getDefaultHooks = () => [
30301
30446
  operationType: "beforeCreate" /* BeforeCreate */,
30302
30447
  priority: 1,
30303
30448
  callback: defaultBeforeCreateUser
30449
+ },
30450
+ {
30451
+ className: "User",
30452
+ operationType: "beforeCreate" /* BeforeCreate */,
30453
+ priority: 1,
30454
+ callback: defaultCallAuthenticationProviderOnBeforeCreateUser
30455
+ },
30456
+ {
30457
+ className: "User",
30458
+ operationType: "beforeUpdate" /* BeforeUpdate */,
30459
+ priority: 1,
30460
+ callback: defaultCallAuthenticationProviderOnBeforeUpdateUser
30304
30461
  }
30305
30462
  ];
30306
30463
 
@@ -30453,7 +30610,7 @@ class DatabaseController {
30453
30610
  context,
30454
30611
  originClassName,
30455
30612
  object,
30456
- isGraphQLCall
30613
+ _skipHooks
30457
30614
  }) {
30458
30615
  return Object.entries(pointers).reduce(async (acc, [pointerField, { className: currentClassName, select: currentSelect }]) => {
30459
30616
  const accObject = await acc;
@@ -30473,7 +30630,8 @@ class DatabaseController {
30473
30630
  className: currentClassName,
30474
30631
  id: object[pointerField],
30475
30632
  context,
30476
- select: currentSelect
30633
+ select: currentSelect,
30634
+ _skipHooks
30477
30635
  });
30478
30636
  return {
30479
30637
  ...accObject,
@@ -30499,11 +30657,12 @@ class DatabaseController {
30499
30657
  className: currentClassName,
30500
30658
  select: selectWithoutTotalCount,
30501
30659
  where: { id: { in: object[pointerField] } },
30502
- context
30660
+ context,
30661
+ _skipHooks
30503
30662
  });
30504
30663
  return {
30505
- ...acc,
30506
- [pointerField]: isGraphQLCall ? {
30664
+ ...accObject,
30665
+ [pointerField]: context.isGraphQLCall ? {
30507
30666
  totalCount: relationObjects.length,
30508
30667
  edges: relationObjects.map((object2) => ({
30509
30668
  node: object2
@@ -30549,17 +30708,16 @@ class DatabaseController {
30549
30708
  select,
30550
30709
  className,
30551
30710
  context,
30552
- skipHooks,
30711
+ _skipHooks,
30553
30712
  id,
30554
- where,
30555
- isGraphQLCall = false
30713
+ where
30556
30714
  }) {
30557
30715
  const { pointers, selectWithoutPointers } = this._getSelectMinusPointersAndRelations({
30558
30716
  className,
30559
30717
  context,
30560
30718
  select
30561
30719
  });
30562
- const hook = !skipHooks ? initializeHook({
30720
+ const hook = !_skipHooks ? initializeHook({
30563
30721
  className,
30564
30722
  context,
30565
30723
  select: selectWithoutPointers
@@ -30591,7 +30749,7 @@ class DatabaseController {
30591
30749
  originClassName: className,
30592
30750
  pointers,
30593
30751
  object: objectToReturn,
30594
- isGraphQLCall
30752
+ _skipHooks
30595
30753
  })
30596
30754
  };
30597
30755
  }
@@ -30600,11 +30758,10 @@ class DatabaseController {
30600
30758
  select,
30601
30759
  context,
30602
30760
  where,
30603
- skipHooks,
30761
+ _skipHooks,
30604
30762
  first,
30605
30763
  offset,
30606
- order,
30607
- isGraphQLCall = false
30764
+ order
30608
30765
  }) {
30609
30766
  const { pointers, selectWithoutPointers } = this._getSelectMinusPointersAndRelations({
30610
30767
  className,
@@ -30617,7 +30774,7 @@ class DatabaseController {
30617
30774
  acc[fieldName] = true;
30618
30775
  return acc;
30619
30776
  }, selectWithoutPointers);
30620
- const hook = !skipHooks ? initializeHook({
30777
+ const hook = !_skipHooks ? initializeHook({
30621
30778
  className,
30622
30779
  select: selectWithoutPointers,
30623
30780
  context
@@ -30639,23 +30796,24 @@ class DatabaseController {
30639
30796
  select: !select ? undefined : selectWithPointersAndRelationsToGetId,
30640
30797
  order
30641
30798
  });
30642
- return Promise.all(objectsToReturn.map(async (object) => ({
30643
- ...object,
30644
- ...await this._getFinalObjectWithPointerAndRelation({
30645
- object,
30646
- context,
30647
- originClassName: className,
30648
- pointers,
30649
- isGraphQLCall
30650
- })
30651
- })));
30799
+ return Promise.all(objectsToReturn.map(async (object) => {
30800
+ return {
30801
+ ...object,
30802
+ ...await this._getFinalObjectWithPointerAndRelation({
30803
+ object,
30804
+ context,
30805
+ originClassName: className,
30806
+ pointers,
30807
+ _skipHooks
30808
+ })
30809
+ };
30810
+ }));
30652
30811
  }
30653
30812
  async createObject({
30654
30813
  className,
30655
30814
  context,
30656
30815
  data,
30657
- select,
30658
- isGraphQLCall = false
30816
+ select
30659
30817
  }) {
30660
30818
  const hook = initializeHook({
30661
30819
  className,
@@ -30683,8 +30841,7 @@ class DatabaseController {
30683
30841
  context: contextWithRoot(context),
30684
30842
  select,
30685
30843
  id,
30686
- skipHooks: true,
30687
- isGraphQLCall
30844
+ _skipHooks: true
30688
30845
  });
30689
30846
  }
30690
30847
  async createObjects({
@@ -30694,8 +30851,7 @@ class DatabaseController {
30694
30851
  context,
30695
30852
  first,
30696
30853
  offset,
30697
- order,
30698
- isGraphQLCall = false
30854
+ order
30699
30855
  }) {
30700
30856
  if (data.length === 0)
30701
30857
  return [];
@@ -30729,11 +30885,10 @@ class DatabaseController {
30729
30885
  context,
30730
30886
  select,
30731
30887
  where: { id: { in: ids } },
30732
- skipHooks: true,
30888
+ _skipHooks: true,
30733
30889
  first,
30734
30890
  offset,
30735
- order,
30736
- isGraphQLCall
30891
+ order
30737
30892
  });
30738
30893
  }
30739
30894
  async updateObject({
@@ -30742,10 +30897,9 @@ class DatabaseController {
30742
30897
  context,
30743
30898
  data,
30744
30899
  select,
30745
- skipHooks,
30746
- isGraphQLCall = false
30900
+ _skipHooks
30747
30901
  }) {
30748
- const hook = !skipHooks ? initializeHook({
30902
+ const hook = !_skipHooks ? initializeHook({
30749
30903
  className,
30750
30904
  context,
30751
30905
  newData: data,
@@ -30775,8 +30929,7 @@ class DatabaseController {
30775
30929
  className,
30776
30930
  context,
30777
30931
  select,
30778
- id,
30779
- isGraphQLCall
30932
+ id
30780
30933
  });
30781
30934
  }
30782
30935
  async updateObjects({
@@ -30788,11 +30941,10 @@ class DatabaseController {
30788
30941
  first,
30789
30942
  offset,
30790
30943
  order,
30791
- skipHooks,
30792
- isGraphQLCall = false
30944
+ _skipHooks
30793
30945
  }) {
30794
30946
  const whereObject = await this._getWhereObjectWithPointerOrRelation(className, where || {}, context);
30795
- const hook = !skipHooks ? initializeHook({
30947
+ const hook = !_skipHooks ? initializeHook({
30796
30948
  className,
30797
30949
  context,
30798
30950
  newData: data,
@@ -30828,16 +30980,14 @@ class DatabaseController {
30828
30980
  where: { id: { in: objectsId } },
30829
30981
  first,
30830
30982
  offset,
30831
- order,
30832
- isGraphQLCall
30983
+ order
30833
30984
  });
30834
30985
  }
30835
30986
  async deleteObject({
30836
30987
  context,
30837
30988
  className,
30838
30989
  id,
30839
- select,
30840
- isGraphQLCall = false
30990
+ select
30841
30991
  }) {
30842
30992
  const hook = initializeHook({
30843
30993
  className,
@@ -30851,8 +31001,7 @@ class DatabaseController {
30851
31001
  className,
30852
31002
  select,
30853
31003
  id,
30854
- context,
30855
- isGraphQLCall
31004
+ context
30856
31005
  });
30857
31006
  const resultOfBeforeDelete = await hook.runOnSingleObject({
30858
31007
  operationType: "beforeDelete" /* BeforeDelete */,
@@ -30878,8 +31027,7 @@ class DatabaseController {
30878
31027
  where,
30879
31028
  first,
30880
31029
  offset,
30881
- order,
30882
- isGraphQLCall = false
31030
+ order
30883
31031
  }) {
30884
31032
  const whereObject = await this._getWhereObjectWithPointerOrRelation(className, where || {}, context);
30885
31033
  const hook = initializeHook({
@@ -30897,8 +31045,7 @@ class DatabaseController {
30897
31045
  context,
30898
31046
  first,
30899
31047
  offset,
30900
- order,
30901
- isGraphQLCall
31048
+ order
30902
31049
  });
30903
31050
  const resultOfBeforeDelete = await hook.runOnMultipleObjects({
30904
31051
  operationType: "beforeDelete" /* BeforeDelete */,
@@ -30937,15 +31084,16 @@ var AuthenticationProvider;
30937
31084
  var SecondaryFactor;
30938
31085
  ((SecondaryFactor2) => {
30939
31086
  SecondaryFactor2["EmailOTP"] = "emailOTP";
31087
+ SecondaryFactor2["QRCodeOTP"] = "qrcodeOTP";
30940
31088
  })(SecondaryFactor ||= {});
30941
31089
  // ../wabe/src/authentication/oauth/utils.ts
30942
- import crypto from "node:crypto";
31090
+ import crypto3 from "node:crypto";
30943
31091
  var base64URLencode = (content) => {
30944
- const hasher = crypto.createHash("sha256").update(content);
31092
+ const hasher = crypto3.createHash("sha256").update(content);
30945
31093
  const result = hasher.digest("base64");
30946
31094
  return result.split("=")[0].replaceAll("+", "-").replaceAll("/", "_");
30947
31095
  };
30948
- var generateRandomValues = () => crypto.randomBytes(60).toString("base64url");
31096
+ var generateRandomValues = () => crypto3.randomBytes(60).toString("base64url");
30949
31097
 
30950
31098
  // ../wabe/src/authentication/oauth/Oauth2Client.ts
30951
31099
  class OAuth2Client {
@@ -31083,7 +31231,7 @@ class Google {
31083
31231
  // ../wabe/src/authentication/OTP.ts
31084
31232
  var import_otplib = __toESM(require_otplib(), 1);
31085
31233
  import { createHash } from "node:crypto";
31086
- var FIVE_MINUTES = 5;
31234
+ var TWO_MINUTES = 5;
31087
31235
 
31088
31236
  class OTP {
31089
31237
  secret;
@@ -31091,24 +31239,39 @@ class OTP {
31091
31239
  constructor(rootKey) {
31092
31240
  this.secret = rootKey;
31093
31241
  this.internalTotp = import_otplib.totp.clone({
31094
- window: [FIVE_MINUTES, 0]
31242
+ window: [TWO_MINUTES, 0]
31095
31243
  });
31096
31244
  }
31245
+ deriveSecret(userId) {
31246
+ const hash = createHash("sha256").update(`${this.secret}:${userId}`).digest();
31247
+ return base32Encode(hash, "RFC4648", { padding: false });
31248
+ }
31097
31249
  generate(userId) {
31098
- const hashedSecret = createHash("sha256").update(`${this.secret}:${userId}`).digest("hex");
31099
- return this.internalTotp.generate(hashedSecret);
31250
+ const secret = this.deriveSecret(userId);
31251
+ return this.internalTotp.generate(secret);
31100
31252
  }
31101
31253
  verify(otp, userId) {
31102
- const hashedSecret = createHash("sha256").update(`${this.secret}:${userId}`).digest("hex");
31103
- return this.internalTotp.verify({ secret: hashedSecret, token: otp });
31254
+ const secret = this.deriveSecret(userId);
31255
+ return this.internalTotp.verify({ secret, token: otp });
31256
+ }
31257
+ authenticatorGenerate(userId) {
31258
+ const secret = this.deriveSecret(userId);
31259
+ return import_otplib.authenticator.generate(secret);
31260
+ }
31261
+ authenticatorVerify(otp, userId) {
31262
+ const secret = this.deriveSecret(userId);
31263
+ return import_otplib.authenticator.verify({
31264
+ secret,
31265
+ token: otp
31266
+ });
31104
31267
  }
31105
31268
  generateKeyuri({
31106
31269
  userId,
31107
31270
  emailOrUsername,
31108
31271
  applicationName
31109
31272
  }) {
31110
- const hashedSecret = createHash("sha256").update(`${this.secret}:${userId}`).digest("hex");
31111
- return this.internalTotp.keyuri(emailOrUsername, applicationName, toBase32(hashedSecret));
31273
+ const secret = this.deriveSecret(userId);
31274
+ return import_otplib.authenticator.keyuri(emailOrUsername, applicationName, secret);
31112
31275
  }
31113
31276
  }
31114
31277
  // ../wabe/src/authentication/Session.ts
@@ -31133,6 +31296,14 @@ class Session {
31133
31296
  return new Date(Date.now() + expiresInMs);
31134
31297
  }
31135
31298
  async meFromAccessToken(accessToken, context) {
31299
+ if (!import_jsonwebtoken.verify(accessToken, context.wabe.config.authentication?.session?.jwtSecret || "dev", {})) {
31300
+ return {
31301
+ sessionId: null,
31302
+ user: null,
31303
+ accessToken: null,
31304
+ refreshToken: null
31305
+ };
31306
+ }
31136
31307
  const sessions = await context.wabe.controllers.database.getObjects({
31137
31308
  className: "_Session",
31138
31309
  where: {
@@ -31203,13 +31374,22 @@ class Session {
31203
31374
  };
31204
31375
  }
31205
31376
  async create(userId, context) {
31377
+ const jwtTokenFields = context.wabe.config.authentication?.session?.jwtTokenFields;
31378
+ const result = jwtTokenFields ? await context.wabe.controllers.database.getObject({
31379
+ className: "User",
31380
+ select: jwtTokenFields,
31381
+ context,
31382
+ id: userId
31383
+ }) : undefined;
31206
31384
  this.accessToken = import_jsonwebtoken.default.sign({
31207
31385
  userId,
31386
+ user: result,
31208
31387
  iat: Date.now(),
31209
31388
  exp: this.getAccessTokenExpireAt(context.wabe.config).getTime()
31210
31389
  }, context.wabe.config.authentication?.session?.jwtSecret || "dev");
31211
31390
  this.refreshToken = import_jsonwebtoken.default.sign({
31212
31391
  userId,
31392
+ user: result,
31213
31393
  iat: Date.now(),
31214
31394
  exp: this.getRefreshTokenExpireAt(context.wabe.config).getTime()
31215
31395
  }, context.wabe.config.authentication?.session?.jwtSecret || "dev");
@@ -31233,22 +31413,17 @@ class Session {
31233
31413
  sessionId: res.id
31234
31414
  };
31235
31415
  }
31236
- async delete(context) {
31237
- if (!context.sessionId)
31238
- return;
31239
- await context.wabe.controllers.database.deleteObject({
31240
- className: "_Session",
31241
- context: contextWithRoot(context),
31242
- id: context.sessionId,
31243
- select: {}
31244
- });
31245
- }
31246
- _isRefreshTokenExpired(userRefreshTokenExpiresAt, refreshTokenAgeInMs) {
31247
- const refreshTokenEmittedAt = userRefreshTokenExpiresAt.getTime() - refreshTokenAgeInMs;
31248
- const numberOfMsSinceRefreshTokenEmitted = Date.now() - refreshTokenEmittedAt;
31249
- return numberOfMsSinceRefreshTokenEmitted >= 0.75 * refreshTokenAgeInMs;
31250
- }
31251
31416
  async refresh(accessToken, refreshToken, context) {
31417
+ if (!import_jsonwebtoken.verify(accessToken, context.wabe.config.authentication?.session?.jwtSecret || "dev", {}))
31418
+ return {
31419
+ accessToken: null,
31420
+ refreshToken: null
31421
+ };
31422
+ if (!import_jsonwebtoken.verify(refreshToken, context.wabe.config.authentication?.session?.jwtSecret || "dev", {}))
31423
+ return {
31424
+ accessToken: null,
31425
+ refreshToken: null
31426
+ };
31252
31427
  const session = await context.wabe.controllers.database.getObjects({
31253
31428
  className: "_Session",
31254
31429
  where: {
@@ -31297,13 +31472,22 @@ class Session {
31297
31472
  accessToken: null,
31298
31473
  refreshToken: null
31299
31474
  };
31475
+ const jwtTokenFields = context.wabe.config.authentication?.session?.jwtTokenFields;
31476
+ const result = jwtTokenFields ? await context.wabe.controllers.database.getObject({
31477
+ className: "User",
31478
+ select: jwtTokenFields,
31479
+ context,
31480
+ id: userId
31481
+ }) : undefined;
31300
31482
  const newAccessToken = import_jsonwebtoken.default.sign({
31301
31483
  userId,
31484
+ user: result,
31302
31485
  iat: Date.now(),
31303
31486
  exp: this.getAccessTokenExpireAt(context.wabe.config).getTime()
31304
31487
  }, context.wabe.config.authentication?.session?.jwtSecret || "dev");
31305
31488
  const newRefreshToken = import_jsonwebtoken.default.sign({
31306
31489
  userId,
31490
+ user: result,
31307
31491
  iat: Date.now(),
31308
31492
  exp: this.getRefreshTokenExpireAt(context.wabe.config).getTime()
31309
31493
  }, context.wabe.config.authentication?.session?.jwtSecret || "dev");
@@ -31324,6 +31508,21 @@ class Session {
31324
31508
  refreshToken: newRefreshToken
31325
31509
  };
31326
31510
  }
31511
+ async delete(context) {
31512
+ if (!context.sessionId)
31513
+ return;
31514
+ await context.wabe.controllers.database.deleteObject({
31515
+ className: "_Session",
31516
+ context: contextWithRoot(context),
31517
+ id: context.sessionId,
31518
+ select: {}
31519
+ });
31520
+ }
31521
+ _isRefreshTokenExpired(userRefreshTokenExpiresAt, refreshTokenAgeInMs) {
31522
+ const refreshTokenEmittedAt = userRefreshTokenExpiresAt.getTime() - refreshTokenAgeInMs;
31523
+ const numberOfMsSinceRefreshTokenEmitted = Date.now() - refreshTokenEmittedAt;
31524
+ return numberOfMsSinceRefreshTokenEmitted >= 0.75 * refreshTokenAgeInMs;
31525
+ }
31327
31526
  }
31328
31527
 
31329
31528
  // ../wabe/src/authentication/resolvers/refreshResolver.ts
@@ -31347,25 +31546,6 @@ var signOutResolver = async (_, __, context) => {
31347
31546
  return true;
31348
31547
  };
31349
31548
 
31350
- // ../wabe/src/authentication/utils.ts
31351
- import { Algorithm as Algorithm2, hash as hash2 } from "@node-rs/argon2";
31352
- var getAuthenticationMethod = (listOfMethods, context) => {
31353
- const customAuthenticationConfig = context.wabe.config?.authentication?.customAuthenticationMethods;
31354
- if (!customAuthenticationConfig)
31355
- throw new Error("No custom authentication methods found");
31356
- const authenticationMethods = listOfMethods.filter((method) => method !== "secondaryFactor");
31357
- if (authenticationMethods.length > 1 || authenticationMethods.length === 0)
31358
- throw new Error("One authentication method is required at the time");
31359
- const authenticationMethod = authenticationMethods[0];
31360
- const validAuthenticationMethod = customAuthenticationConfig.find((method) => method.name.toLowerCase() === authenticationMethod?.toLowerCase());
31361
- if (!validAuthenticationMethod)
31362
- throw new Error("No available custom authentication methods found");
31363
- return validAuthenticationMethod;
31364
- };
31365
- var hashPassword = (password) => hash2(password, {
31366
- algorithm: Algorithm2.Argon2id
31367
- });
31368
-
31369
31549
  // ../wabe/src/authentication/resolvers/verifyChallenge.ts
31370
31550
  var verifyChallengeResolver = async (_, {
31371
31551
  input
@@ -31774,7 +31954,7 @@ var signInWithResolver = async (_, {
31774
31954
  context,
31775
31955
  user
31776
31956
  });
31777
- return { accessToken: null, refreshToken: null, id: userId };
31957
+ return { accessToken: null, refreshToken: null, user };
31778
31958
  }
31779
31959
  const session = new Session;
31780
31960
  const { refreshToken, accessToken } = await session.create(userId, context);
@@ -31796,7 +31976,7 @@ var signInWithResolver = async (_, {
31796
31976
  expires: accessTokenExpiresAt
31797
31977
  });
31798
31978
  }
31799
- return { accessToken, refreshToken, id: userId, srp };
31979
+ return { accessToken, refreshToken, user, srp };
31800
31980
  };
31801
31981
 
31802
31982
  // ../wabe/src/schema/Schema.ts
@@ -31891,7 +32071,10 @@ class Schema {
31891
32071
  outputObject: {
31892
32072
  name: "SignInWithOutput",
31893
32073
  fields: {
31894
- id: { type: "String" },
32074
+ user: {
32075
+ type: "Pointer",
32076
+ class: "User"
32077
+ },
31895
32078
  accessToken: {
31896
32079
  type: "String"
31897
32080
  },
@@ -32153,7 +32336,7 @@ class Schema {
32153
32336
  class: "_Session",
32154
32337
  protected: {
32155
32338
  authorizedRoles: ["rootOnly"],
32156
- protectedOperations: ["update", "read"]
32339
+ protectedOperations: ["create", "update"]
32157
32340
  }
32158
32341
  },
32159
32342
  secondFA: {
@@ -32248,7 +32431,7 @@ class Schema {
32248
32431
  },
32249
32432
  protected: {
32250
32433
  authorizedRoles: ["rootOnly"],
32251
- protectedOperations: ["update", "read"]
32434
+ protectedOperations: ["create", "update"]
32252
32435
  }
32253
32436
  },
32254
32437
  createdAt: {
@@ -35329,7 +35512,7 @@ var executeRelationOnFields = ({
35329
35512
  newAcc[fieldName] = await createAndLink({
35330
35513
  createAndLink: value.createAndLink,
35331
35514
  fieldName,
35332
- context,
35515
+ context: contextWithoutGraphQLCall(context),
35333
35516
  className
35334
35517
  });
35335
35518
  } else if (typeof value === "object" && value?.link) {
@@ -35340,13 +35523,13 @@ var executeRelationOnFields = ({
35340
35523
  newAcc[fieldName] = await createAndAdd({
35341
35524
  createAndAdd: value.createAndAdd,
35342
35525
  fieldName,
35343
- context,
35526
+ context: contextWithoutGraphQLCall(context),
35344
35527
  className
35345
35528
  });
35346
35529
  } else if (typeof value === "object" && value?.add) {
35347
35530
  const addValue = await add({
35348
35531
  add: value.add,
35349
- context,
35532
+ context: contextWithoutGraphQLCall(context),
35350
35533
  fieldName,
35351
35534
  typeOfExecution: typeOfExecution || "create",
35352
35535
  id,
@@ -35358,7 +35541,7 @@ var executeRelationOnFields = ({
35358
35541
  } else if (typeof value === "object" && value?.remove) {
35359
35542
  const removeValue = await remove({
35360
35543
  remove: value.remove,
35361
- context,
35544
+ context: contextWithoutGraphQLCall(context),
35362
35545
  fieldName,
35363
35546
  typeOfExecution: typeOfExecution || "create",
35364
35547
  id,
@@ -35386,8 +35569,7 @@ var queryForOneObject = (_, { id }, context, info, className) => {
35386
35569
  className,
35387
35570
  id,
35388
35571
  select,
35389
- context,
35390
- isGraphQLCall: true
35572
+ context
35391
35573
  });
35392
35574
  };
35393
35575
  var queryForMultipleObject = async (_, { where, offset, first, order }, context, info, className) => {
@@ -35400,8 +35582,7 @@ var queryForMultipleObject = async (_, { where, offset, first, order }, context,
35400
35582
  offset,
35401
35583
  first,
35402
35584
  context,
35403
- order: transformOrder(order),
35404
- isGraphQLCall: true
35585
+ order: transformOrder(order)
35405
35586
  });
35406
35587
  return {
35407
35588
  totalCount: totalCount ? await context.wabe.controllers.database.count({
@@ -35426,8 +35607,7 @@ var mutationToCreateObject = async (_, args, context, info, className) => {
35426
35607
  className,
35427
35608
  data: updatedFieldsToCreate,
35428
35609
  select,
35429
- context,
35430
- isGraphQLCall: true
35610
+ context
35431
35611
  }),
35432
35612
  ok: true
35433
35613
  };
@@ -35447,8 +35627,7 @@ var mutationToCreateMultipleObjects = async (_, { input: { fields, offset, first
35447
35627
  offset,
35448
35628
  first,
35449
35629
  context,
35450
- order: transformOrder(order),
35451
- isGraphQLCall: true
35630
+ order: transformOrder(order)
35452
35631
  });
35453
35632
  return {
35454
35633
  edges: objects.map((object) => ({ node: object }))
@@ -35469,8 +35648,7 @@ var mutationToUpdateObject = async (_, args, context, info, className) => {
35469
35648
  id: args.input?.id,
35470
35649
  data: updatedFields,
35471
35650
  select,
35472
- context,
35473
- isGraphQLCall: true
35651
+ context
35474
35652
  }),
35475
35653
  ok: true
35476
35654
  };
@@ -35492,8 +35670,7 @@ var mutationToUpdateMultipleObjects = async (_, { input: { fields, where, offset
35492
35670
  offset,
35493
35671
  first,
35494
35672
  context,
35495
- order,
35496
- isGraphQLCall: true
35673
+ order
35497
35674
  });
35498
35675
  return {
35499
35676
  edges: objects.map((object) => ({ node: object }))
@@ -35506,8 +35683,7 @@ var mutationToDeleteObject = async (_, args, context, info, className) => {
35506
35683
  className,
35507
35684
  id: args.input?.id,
35508
35685
  select,
35509
- context,
35510
- isGraphQLCall: true
35686
+ context
35511
35687
  }),
35512
35688
  ok: true
35513
35689
  };
@@ -35521,8 +35697,7 @@ var mutationToDeleteMultipleObjects = async (_, { input: { where, offset, first,
35521
35697
  offset,
35522
35698
  first,
35523
35699
  context,
35524
- order,
35525
- isGraphQLCall: true
35700
+ order
35526
35701
  });
35527
35702
  return {
35528
35703
  edges: objects.map((object) => ({ node: object }))
@@ -36234,7 +36409,7 @@ class RadixTree {
36234
36409
  if (pathLength === 1 && localPath === "/")
36235
36410
  return this.root;
36236
36411
  let nextIndexToEnd = 0;
36237
- let params = undefined;
36412
+ let params2 = undefined;
36238
36413
  const isNodeMatch = (node, indexToBegin, indexToEnd) => {
36239
36414
  const nextIndexToBegin = indexToBegin + (indexToEnd - indexToBegin);
36240
36415
  for (let i = 0;i < node.children.length; i++) {
@@ -36249,10 +36424,10 @@ class RadixTree {
36249
36424
  if (!isChildWildcardOrParameterNode && nextIndexToEnd - nextIndexToBegin !== childName.length)
36250
36425
  continue;
36251
36426
  if (child.isParameterNode) {
36252
- if (!params)
36253
- params = {};
36427
+ if (!params2)
36428
+ params2 = {};
36254
36429
  const indexToAddIfFirstNode = indexToBegin === 0 ? 0 : 1;
36255
- params[childName.slice(1 + indexToAddIfFirstNode)] = localPath.slice(nextIndexToBegin + indexToAddIfFirstNode, nextIndexToEnd);
36430
+ params2[childName.slice(1 + indexToAddIfFirstNode)] = localPath.slice(nextIndexToBegin + indexToAddIfFirstNode, nextIndexToEnd);
36256
36431
  }
36257
36432
  if (isChildWildcardOrParameterNode && child.children.length === 0 && child.method === method)
36258
36433
  return child;
@@ -36270,8 +36445,8 @@ class RadixTree {
36270
36445
  return null;
36271
36446
  };
36272
36447
  const route = isNodeMatch(this.root, 0, this.root.name.length);
36273
- if (params && route)
36274
- route.params = params;
36448
+ if (params2 && route)
36449
+ route.params = params2;
36275
36450
  return route;
36276
36451
  }
36277
36452
  optimizeTree() {
@@ -37223,11 +37398,11 @@ var resolveHeaders = (headers) => {
37223
37398
  return oHeaders;
37224
37399
  };
37225
37400
  var cleanQuery = (str) => str.replace(/([\s,]|#[^\n\r]+)+/g, ` `).trim();
37226
- var buildRequestConfig = (params) => {
37227
- if (!Array.isArray(params.query)) {
37228
- const params_2 = params;
37401
+ var buildRequestConfig = (params2) => {
37402
+ if (!Array.isArray(params2.query)) {
37403
+ const params_2 = params2;
37229
37404
  const search = [`query=${encodeURIComponent(cleanQuery(params_2.query))}`];
37230
- if (params.variables) {
37405
+ if (params2.variables) {
37231
37406
  search.push(`variables=${encodeURIComponent(params_2.jsonSerializer.stringify(params_2.variables))}`);
37232
37407
  }
37233
37408
  if (params_2.operationName) {
@@ -37235,11 +37410,11 @@ var buildRequestConfig = (params) => {
37235
37410
  }
37236
37411
  return search.join(`&`);
37237
37412
  }
37238
- if (typeof params.variables !== `undefined` && !Array.isArray(params.variables)) {
37413
+ if (typeof params2.variables !== `undefined` && !Array.isArray(params2.variables)) {
37239
37414
  throw new Error(`Cannot create query with given variable type, array expected`);
37240
37415
  }
37241
- const params_ = params;
37242
- const payload = params.query.reduce((acc, currentQuery, index) => {
37416
+ const params_ = params2;
37417
+ const payload = params2.query.reduce((acc, currentQuery, index) => {
37243
37418
  acc.push({
37244
37419
  query: cleanQuery(currentQuery),
37245
37420
  variables: params_.variables ? params_.jsonSerializer.stringify(params_.variables[index]) : undefined
@@ -37248,9 +37423,9 @@ var buildRequestConfig = (params) => {
37248
37423
  }, []);
37249
37424
  return `query=${encodeURIComponent(params_.jsonSerializer.stringify(payload))}`;
37250
37425
  };
37251
- var createHttpMethodFetcher = (method) => async (params) => {
37252
- const { url, query, variables, operationName, fetch: fetch2, fetchOptions, middleware } = params;
37253
- const headers = { ...params.headers };
37426
+ var createHttpMethodFetcher = (method) => async (params2) => {
37427
+ const { url, query, variables, operationName, fetch: fetch2, fetchOptions, middleware } = params2;
37428
+ const headers = { ...params2.headers };
37254
37429
  let queryParams = ``;
37255
37430
  let body = undefined;
37256
37431
  if (method === `POST`) {
@@ -37410,11 +37585,11 @@ class GraphQLClient {
37410
37585
  return this;
37411
37586
  }
37412
37587
  }
37413
- var makeRequest = async (params) => {
37414
- const { query, variables, fetchOptions } = params;
37415
- const fetcher = createHttpMethodFetcher(uppercase(params.method ?? `post`));
37416
- const isBatchingQuery = Array.isArray(params.query);
37417
- const response = await fetcher(params);
37588
+ var makeRequest = async (params2) => {
37589
+ const { query, variables, fetchOptions } = params2;
37590
+ const fetcher = createHttpMethodFetcher(uppercase(params2.method ?? `post`));
37591
+ const isBatchingQuery = Array.isArray(params2.query);
37592
+ const response = await fetcher(params2);
37418
37593
  const result2 = await getResult(response, fetchOptions.jsonSerializer ?? defaultJsonSerializer);
37419
37594
  const successfullyReceivedData = Array.isArray(result2) ? !result2.some(({ data }) => !data) : Boolean(result2.data);
37420
37595
  const successfullyPassedErrorPolicy = Array.isArray(result2) || !result2.errors || Array.isArray(result2.errors) && !result2.errors.length || fetchOptions.errorPolicy === `all` || fetchOptions.errorPolicy === `ignore`;
@@ -38005,8 +38180,7 @@ var generateCodegen = async ({
38005
38180
  };
38006
38181
 
38007
38182
  // ../wabe/src/authentication/providers/EmailPassword.ts
38008
- import { Algorithm as Algorithm3, verify } from "@node-rs/argon2";
38009
- var DUMMY_PASSWORD_HASH = "$argon2id$v=19$m=65536,t=2,p=1$YWJjZGVmZw$YzBhRkNiSEZlY3hzUVYxZg";
38183
+ var DUMMY_PASSWORD_HASH = "$argon2id$v=19$m=65536,t=2,p=1$wHZB9xRS/Mbo7L3SL9e935Ag5K+T2EuT/XgB8akwZgo$SPf8EZ4T1HYkuIll4v2hSzNCH7woX3VrZJo3yWg5u8U";
38010
38184
 
38011
38185
  class EmailPassword {
38012
38186
  async onSignIn({
@@ -38023,15 +38197,23 @@ class EmailPassword {
38023
38197
  }
38024
38198
  },
38025
38199
  context: contextWithRoot(context),
38026
- select: { id: true, authentication: true, secondFA: true, email: true },
38200
+ select: {
38201
+ authentication: true,
38202
+ role: true,
38203
+ secondFA: true,
38204
+ email: true,
38205
+ id: true,
38206
+ provider: true,
38207
+ isOauth: true,
38208
+ createdAt: true,
38209
+ updatedAt: true
38210
+ },
38027
38211
  first: 1
38028
38212
  });
38029
38213
  const user = users[0];
38030
38214
  const userDatabasePassword = user?.authentication?.emailPassword?.password;
38031
38215
  const passwordHashToCheck = userDatabasePassword ?? DUMMY_PASSWORD_HASH;
38032
- const isPasswordEquals = await verify(passwordHashToCheck, input.password, {
38033
- algorithm: Algorithm3.Argon2id
38034
- });
38216
+ const isPasswordEquals = await verifyArgon2(input.password, passwordHashToCheck);
38035
38217
  if (!user || !isPasswordEquals || input.email !== user.authentication?.emailPassword?.email)
38036
38218
  throw new Error("Invalid authentication credentials");
38037
38219
  return {
@@ -38058,7 +38240,7 @@ class EmailPassword {
38058
38240
  return {
38059
38241
  authenticationDataToSave: {
38060
38242
  email: input.email,
38061
- password: await hashPassword(input.password)
38243
+ password: input.password
38062
38244
  }
38063
38245
  };
38064
38246
  }
@@ -38083,7 +38265,7 @@ class EmailPassword {
38083
38265
  return {
38084
38266
  authenticationDataToSave: {
38085
38267
  email: input.email ?? user?.authentication?.emailPassword?.email,
38086
- password: input.password ? await hashPassword(input.password) : user?.authentication?.emailPassword?.password
38268
+ password: input.password ? input.password : user?.authentication?.emailPassword?.password
38087
38269
  }
38088
38270
  };
38089
38271
  }
@@ -38119,7 +38301,17 @@ var oAuthAuthentication = (oAuthProvider) => async ({
38119
38301
  },
38120
38302
  context: contextWithRoot(context),
38121
38303
  first: 1,
38122
- select: { id: true }
38304
+ select: {
38305
+ authentication: true,
38306
+ role: true,
38307
+ secondFA: true,
38308
+ email: true,
38309
+ id: true,
38310
+ provider: true,
38311
+ isOauth: true,
38312
+ createdAt: true,
38313
+ updatedAt: true
38314
+ }
38123
38315
  });
38124
38316
  if (user.length === 0) {
38125
38317
  const createdUser = await context.wabe.controllers.database.createObject({
@@ -38131,7 +38323,18 @@ var oAuthAuthentication = (oAuthProvider) => async ({
38131
38323
  [oAuthProvider]: userInfoToSave
38132
38324
  }
38133
38325
  },
38134
- context: contextWithRoot(context)
38326
+ context: contextWithRoot(context),
38327
+ select: {
38328
+ authentication: true,
38329
+ role: true,
38330
+ secondFA: true,
38331
+ email: true,
38332
+ id: true,
38333
+ provider: true,
38334
+ isOauth: true,
38335
+ createdAt: true,
38336
+ updatedAt: true
38337
+ }
38135
38338
  });
38136
38339
  if (!createdUser)
38137
38340
  throw new Error("User not found");
@@ -38167,8 +38370,7 @@ class GitHub2 {
38167
38370
  }
38168
38371
  }
38169
38372
  // ../wabe/src/authentication/providers/PhonePassword.ts
38170
- import { Algorithm as Algorithm4, verify as verify2 } from "@node-rs/argon2";
38171
- var DUMMY_PASSWORD_HASH2 = "$argon2id$v=19$m=65536,t=2,p=1$YWJjZGVmZw$YzBhRkNiSEZlY3hzUVYxZg";
38373
+ var DUMMY_PASSWORD_HASH2 = "$argon2id$v=19$m=65536,t=2,p=1$wHZB9xRS/Mbo7L3SL9e935Ag5K+T2EuT/XgB8akwZgo$SPf8EZ4T1HYkuIll4v2hSzNCH7woX3VrZJo3yWg5u8U";
38172
38374
 
38173
38375
  class PhonePassword {
38174
38376
  async onSignIn({
@@ -38185,15 +38387,23 @@ class PhonePassword {
38185
38387
  }
38186
38388
  },
38187
38389
  context: contextWithRoot(context),
38188
- select: { id: true, authentication: true },
38390
+ select: {
38391
+ authentication: true,
38392
+ role: true,
38393
+ secondFA: true,
38394
+ email: true,
38395
+ id: true,
38396
+ provider: true,
38397
+ isOauth: true,
38398
+ createdAt: true,
38399
+ updatedAt: true
38400
+ },
38189
38401
  first: 1
38190
38402
  });
38191
38403
  const user = users[0];
38192
38404
  const userDatabasePassword = user?.authentication?.phonePassword?.password;
38193
38405
  const passwordHashToCheck = userDatabasePassword ?? DUMMY_PASSWORD_HASH2;
38194
- const isPasswordEquals = await verify2(passwordHashToCheck, input.password, {
38195
- algorithm: Algorithm4.Argon2id
38196
- });
38406
+ const isPasswordEquals = await verifyArgon2(input.password, passwordHashToCheck);
38197
38407
  if (!user || !isPasswordEquals || input.phone !== user.authentication?.phonePassword?.phone)
38198
38408
  throw new Error("Invalid authentication credentials");
38199
38409
  return {
@@ -38220,7 +38430,7 @@ class PhonePassword {
38220
38430
  return {
38221
38431
  authenticationDataToSave: {
38222
38432
  phone: input.phone,
38223
- password: await hashPassword(input.password)
38433
+ password: input.password
38224
38434
  }
38225
38435
  };
38226
38436
  }
@@ -38245,7 +38455,7 @@ class PhonePassword {
38245
38455
  return {
38246
38456
  authenticationDataToSave: {
38247
38457
  phone: input.phone ?? user?.authentication?.phonePassword?.phone,
38248
- password: input.password ? await hashPassword(input.password) : user?.authentication?.phonePassword?.password
38458
+ password: input.password ? input.password : user?.authentication?.phonePassword?.password
38249
38459
  }
38250
38460
  };
38251
38461
  }
@@ -38287,7 +38497,17 @@ class EmailOTP {
38287
38497
  equalTo: input.email
38288
38498
  }
38289
38499
  },
38290
- select: { id: true, secondFA: true },
38500
+ select: {
38501
+ authentication: true,
38502
+ role: true,
38503
+ secondFA: true,
38504
+ email: true,
38505
+ id: true,
38506
+ provider: true,
38507
+ isOauth: true,
38508
+ createdAt: true,
38509
+ updatedAt: true
38510
+ },
38291
38511
  first: 1,
38292
38512
  context: contextWithRoot(context)
38293
38513
  });
@@ -38317,7 +38537,17 @@ class QRCodeOTP {
38317
38537
  equalTo: input.email
38318
38538
  }
38319
38539
  },
38320
- select: { id: true, secondFA: true },
38540
+ select: {
38541
+ authentication: true,
38542
+ role: true,
38543
+ secondFA: true,
38544
+ email: true,
38545
+ id: true,
38546
+ provider: true,
38547
+ isOauth: true,
38548
+ createdAt: true,
38549
+ updatedAt: true
38550
+ },
38321
38551
  first: 1,
38322
38552
  context: contextWithRoot(context)
38323
38553
  });
@@ -38325,7 +38555,7 @@ class QRCodeOTP {
38325
38555
  const userId = realUser?.id ?? DUMMY_USER_ID3;
38326
38556
  const isDevBypass = !context.wabe.config.isProduction && input.otp === "000000" && realUser !== null;
38327
38557
  const otpClass = new OTP(context.wabe.config.rootKey);
38328
- const isOtpValid = otpClass.verify(input.otp, userId);
38558
+ const isOtpValid = otpClass.authenticatorVerify(input.otp, userId);
38329
38559
  if (realUser && (isOtpValid || isDevBypass))
38330
38560
  return { userId: realUser.id };
38331
38561
  return null;
@@ -39869,7 +40099,7 @@ class SRPInt {
39869
40099
  return new SRPInt(this[bi].xor(value[bi]), this.hexLength);
39870
40100
  }
39871
40101
  }
39872
- var hash3 = async (hashAlgorithm, ...input) => {
40102
+ var hash = async (hashAlgorithm, ...input) => {
39873
40103
  const buffers = input.map((item) => typeof item === "string" ? encodeUtf8(item) : hexToBuffer(item.toHex()));
39874
40104
  const combined = new Uint8Array(buffers.reduce((offset, item) => offset + item.byteLength, 0));
39875
40105
  buffers.reduce((offset, item) => {
@@ -40033,7 +40263,7 @@ var getParams = (hashAlgorithm, primeGroup) => {
40033
40263
  const N = SRPInt.fromHex(group.N);
40034
40264
  const g = SRPInt.fromHex(group.g);
40035
40265
  const paddedHexLength = N.hexLength ?? 0;
40036
- const H = (...input) => hash3(hashAlgorithm, ...input);
40266
+ const H = (...input) => hash(hashAlgorithm, ...input);
40037
40267
  const PAD = (integer) => integer.pad(paddedHexLength);
40038
40268
  const k = () => H(N, PAD(g));
40039
40269
  return {
@@ -40102,10 +40332,15 @@ class EmailPasswordSRP {
40102
40332
  email: { equalTo: input.email }
40103
40333
  },
40104
40334
  select: {
40105
- id: true,
40106
40335
  authentication: true,
40336
+ role: true,
40107
40337
  secondFA: true,
40108
- email: true
40338
+ email: true,
40339
+ id: true,
40340
+ provider: true,
40341
+ isOauth: true,
40342
+ createdAt: true,
40343
+ updatedAt: true
40109
40344
  },
40110
40345
  first: 1
40111
40346
  });
@@ -47745,8 +47980,8 @@ async function parsePOSTMultipartRequest(request) {
47745
47980
 
47746
47981
  // ../../node_modules/graphql-yoga/esm/plugins/request-validation/use-check-graphql-query-params.js
47747
47982
  var expectedParameters = new Set(["query", "variables", "operationName", "extensions"]);
47748
- function assertInvalidParams(params, extraParamNames) {
47749
- if (params == null || typeof params !== "object") {
47983
+ function assertInvalidParams(params2, extraParamNames) {
47984
+ if (params2 == null || typeof params2 !== "object") {
47750
47985
  throw createGraphQLError('Invalid "params" in the request body', {
47751
47986
  extensions: {
47752
47987
  http: {
@@ -47756,8 +47991,8 @@ function assertInvalidParams(params, extraParamNames) {
47756
47991
  }
47757
47992
  });
47758
47993
  }
47759
- for (const paramKey in params) {
47760
- if (params[paramKey] == null) {
47994
+ for (const paramKey in params2) {
47995
+ if (params2[paramKey] == null) {
47761
47996
  continue;
47762
47997
  }
47763
47998
  if (!expectedParameters.has(paramKey)) {
@@ -47774,9 +48009,9 @@ function assertInvalidParams(params, extraParamNames) {
47774
48009
  }
47775
48010
  }
47776
48011
  }
47777
- function checkGraphQLQueryParams(params, extraParamNames) {
47778
- if (!isObject3(params)) {
47779
- throw createGraphQLError(`Expected params to be an object but given ${extendedTypeof(params)}.`, {
48012
+ function checkGraphQLQueryParams(params2, extraParamNames) {
48013
+ if (!isObject3(params2)) {
48014
+ throw createGraphQLError(`Expected params to be an object but given ${extendedTypeof(params2)}.`, {
47780
48015
  extensions: {
47781
48016
  http: {
47782
48017
  status: 400,
@@ -47787,8 +48022,8 @@ function checkGraphQLQueryParams(params, extraParamNames) {
47787
48022
  }
47788
48023
  });
47789
48024
  }
47790
- assertInvalidParams(params, extraParamNames);
47791
- if (params["query"] == null) {
48025
+ assertInvalidParams(params2, extraParamNames);
48026
+ if (params2["query"] == null) {
47792
48027
  throw createGraphQLError("Must provide query string.", {
47793
48028
  extensions: {
47794
48029
  http: {
@@ -47801,7 +48036,7 @@ function checkGraphQLQueryParams(params, extraParamNames) {
47801
48036
  }
47802
48037
  });
47803
48038
  }
47804
- const queryType = extendedTypeof(params["query"]);
48039
+ const queryType = extendedTypeof(params2["query"]);
47805
48040
  if (queryType !== "string") {
47806
48041
  throw createGraphQLError(`Expected "query" param to be a string, but given ${queryType}.`, {
47807
48042
  extensions: {
@@ -47814,7 +48049,7 @@ function checkGraphQLQueryParams(params, extraParamNames) {
47814
48049
  }
47815
48050
  });
47816
48051
  }
47817
- const variablesParamType = extendedTypeof(params["variables"]);
48052
+ const variablesParamType = extendedTypeof(params2["variables"]);
47818
48053
  if (!["object", "null", "undefined"].includes(variablesParamType)) {
47819
48054
  throw createGraphQLError(`Expected "variables" param to be empty or an object, but given ${variablesParamType}.`, {
47820
48055
  extensions: {
@@ -47827,7 +48062,7 @@ function checkGraphQLQueryParams(params, extraParamNames) {
47827
48062
  }
47828
48063
  });
47829
48064
  }
47830
- const extensionsParamType = extendedTypeof(params["extensions"]);
48065
+ const extensionsParamType = extendedTypeof(params2["extensions"]);
47831
48066
  if (!["object", "null", "undefined"].includes(extensionsParamType)) {
47832
48067
  throw createGraphQLError(`Expected "extensions" param to be empty or an object, but given ${extensionsParamType}.`, {
47833
48068
  extensions: {
@@ -47840,12 +48075,12 @@ function checkGraphQLQueryParams(params, extraParamNames) {
47840
48075
  }
47841
48076
  });
47842
48077
  }
47843
- return params;
48078
+ return params2;
47844
48079
  }
47845
48080
  function useCheckGraphQLQueryParams(extraParamNames) {
47846
48081
  return {
47847
- onParams({ params }) {
47848
- checkGraphQLQueryParams(params, extraParamNames);
48082
+ onParams({ params: params2 }) {
48083
+ checkGraphQLQueryParams(params2, extraParamNames);
47849
48084
  }
47850
48085
  };
47851
48086
  }
@@ -49126,8 +49361,8 @@ function _createLRUCache({ max = DEFAULT_MAX, ttl = DEFAULT_TTL } = {}) {
49126
49361
  function useParserAndValidationCache({ documentCache = _createLRUCache(), errorCache = _createLRUCache(), validationCache = true }) {
49127
49362
  const validationCacheByRules = _createLRUCache();
49128
49363
  return {
49129
- onParse({ params, setParsedDocument }) {
49130
- const strDocument = params.source.toString();
49364
+ onParse({ params: params2, setParsedDocument }) {
49365
+ const strDocument = params2.source.toString();
49131
49366
  const document = documentCache.get(strDocument);
49132
49367
  if (document) {
49133
49368
  setParsedDocument(document);
@@ -49199,10 +49434,10 @@ function getMediaTypesForRequestInOrder(request) {
49199
49434
  const accepts = (request.headers.get("accept") || "*/*").replace(/\s/g, "").toLowerCase().split(",");
49200
49435
  const mediaTypes = [];
49201
49436
  for (const accept of accepts) {
49202
- const [mediaType, ...params] = accept.split(";");
49437
+ const [mediaType, ...params2] = accept.split(";");
49203
49438
  if (mediaType === undefined)
49204
49439
  continue;
49205
- const charset = params?.find((param) => param.includes("charset=")) || "charset=utf-8";
49440
+ const charset = params2?.find((param) => param.includes("charset=")) || "charset=utf-8";
49206
49441
  if (charset !== "charset=utf-8") {
49207
49442
  continue;
49208
49443
  }
@@ -49559,8 +49794,8 @@ async function processResult({ request, result: result2, fetchAPI, onResultProce
49559
49794
  }
49560
49795
  return resultProcessor(result2, fetchAPI, acceptedMediaType);
49561
49796
  }
49562
- async function processRequest({ params, enveloped }) {
49563
- const document = enveloped.parse(params.query);
49797
+ async function processRequest({ params: params2, enveloped }) {
49798
+ const document = enveloped.parse(params2.query);
49564
49799
  const errors2 = enveloped.validate(enveloped.schema, document);
49565
49800
  if (errors2.length > 0) {
49566
49801
  return { errors: errors2 };
@@ -49570,10 +49805,10 @@ async function processRequest({ params, enveloped }) {
49570
49805
  schema: enveloped.schema,
49571
49806
  document,
49572
49807
  contextValue,
49573
- variableValues: params.variables,
49574
- operationName: params.operationName
49808
+ variableValues: params2.variables,
49809
+ operationName: params2.operationName
49575
49810
  };
49576
- const operation = import_graphql46.getOperationAST(document, params.operationName);
49811
+ const operation = import_graphql46.getOperationAST(document, params2.operationName);
49577
49812
  const executeFn = operation?.operation === "subscription" ? enveloped.subscribe : enveloped.execute;
49578
49813
  return executeFn(executionArgs);
49579
49814
  }
@@ -49800,20 +50035,20 @@ class YogaServer {
49800
50035
  }
49801
50036
  }
49802
50037
  }
49803
- handleParams = async ({ request, context, params }) => {
50038
+ handleParams = async ({ request, context, params: params2 }) => {
49804
50039
  let result2;
49805
50040
  try {
49806
50041
  const additionalContext = context["request"] === request ? {
49807
- params
50042
+ params: params2
49808
50043
  } : {
49809
50044
  request,
49810
- params
50045
+ params: params2
49811
50046
  };
49812
50047
  Object.assign(context, additionalContext);
49813
50048
  const enveloped = this.getEnveloped(context);
49814
50049
  this.logger.debug(`Processing GraphQL Parameters`);
49815
50050
  result2 = await processRequest({
49816
- params,
50051
+ params: params2,
49817
50052
  enveloped
49818
50053
  });
49819
50054
  this.logger.debug(`Processing GraphQL Parameters done.`);
@@ -49837,15 +50072,15 @@ class YogaServer {
49837
50072
  }
49838
50073
  return result2;
49839
50074
  };
49840
- async getResultForParams({ params, request }, context) {
50075
+ async getResultForParams({ params: params2, request }, context) {
49841
50076
  let result2;
49842
50077
  let paramsHandler = this.handleParams;
49843
50078
  for (const onParamsHook of this.onParamsHooks) {
49844
50079
  await onParamsHook({
49845
- params,
50080
+ params: params2,
49846
50081
  request,
49847
50082
  setParams(newParams) {
49848
- params = newParams;
50083
+ params2 = newParams;
49849
50084
  },
49850
50085
  paramsHandler,
49851
50086
  setParamsHandler(newHandler) {
@@ -49860,7 +50095,7 @@ class YogaServer {
49860
50095
  }
49861
50096
  result2 ??= await paramsHandler({
49862
50097
  request,
49863
- params,
50098
+ params: params2,
49864
50099
  context
49865
50100
  });
49866
50101
  for (const onExecutionResult of this.onExecutionResultHooks) {
@@ -49914,8 +50149,8 @@ class YogaServer {
49914
50149
  }
49915
50150
  });
49916
50151
  }
49917
- const result2 = await (Array.isArray(requestParserResult) ? Promise.all(requestParserResult.map((params) => this.getResultForParams({
49918
- params,
50152
+ const result2 = await (Array.isArray(requestParserResult) ? Promise.all(requestParserResult.map((params2) => this.getResultForParams({
50153
+ params: params2,
49919
50154
  request
49920
50155
  }, Object.create(serverContext)))) : this.getResultForParams({
49921
50156
  params: requestParserResult,
@@ -50048,13 +50283,15 @@ class FileController {
50048
50283
  import { timingSafeEqual } from "node:crypto";
50049
50284
  var defaultSessionHandler = (wabe) => async (ctx) => {
50050
50285
  const headers = ctx.request.headers;
50286
+ const isGraphQLCall = ctx.request.url.includes("/graphql");
50051
50287
  const headerRootKey = Buffer.from(headers.get("Wabe-Root-Key") || "");
50052
50288
  const rootKey = Buffer.from(wabe.config.rootKey);
50053
50289
  if (headerRootKey.length === rootKey.length && timingSafeEqual(rootKey, headerRootKey)) {
50054
50290
  ctx.wabe = {
50055
50291
  isRoot: true,
50056
50292
  wabe,
50057
- response: ctx.res
50293
+ response: ctx.res,
50294
+ isGraphQLCall
50058
50295
  };
50059
50296
  return;
50060
50297
  }
@@ -50073,7 +50310,8 @@ var defaultSessionHandler = (wabe) => async (ctx) => {
50073
50310
  ctx.wabe = {
50074
50311
  isRoot: false,
50075
50312
  wabe,
50076
- response: ctx.res
50313
+ response: ctx.res,
50314
+ isGraphQLCall
50077
50315
  };
50078
50316
  return;
50079
50317
  }
@@ -50085,14 +50323,16 @@ var defaultSessionHandler = (wabe) => async (ctx) => {
50085
50323
  refreshToken: newRefreshToken
50086
50324
  } = await session.meFromAccessToken(accessToken, {
50087
50325
  wabe,
50088
- isRoot: true
50326
+ isRoot: true,
50327
+ isGraphQLCall
50089
50328
  });
50090
50329
  ctx.wabe = {
50091
50330
  isRoot: false,
50092
50331
  sessionId,
50093
50332
  user,
50094
50333
  wabe,
50095
- response: ctx.res
50334
+ response: ctx.res,
50335
+ isGraphQLCall
50096
50336
  };
50097
50337
  if (wabe.config.authentication?.session?.cookieSession && newAccessToken && newRefreshToken && newAccessToken !== accessToken) {
50098
50338
  ctx.res.setCookie("accessToken", newAccessToken, {
@@ -50806,8 +51046,11 @@ var CronExpressions;
50806
51046
  CronExpressions2["EVERY_12_HOURS"] = "0 0 */12 * * *";
50807
51047
  })(CronExpressions ||= {});
50808
51048
  export {
51049
+ verifyArgon2,
50809
51050
  notEmpty,
51051
+ isArgon2Hash,
50810
51052
  initializeHook,
51053
+ hashArgon2,
50811
51054
  getDefaultHooks,
50812
51055
  generateCodegen,
50813
51056
  defaultRoutes,